Skip to main content
rule CX Codex

consuming-dotnettool — Claude Code rule: what it does, how to install

The consuming-dotnettool rule keeps .NET tool dependencies in a manifest, pins their versions, and adds restore steps for CI/CD. Use it when projects need repeatable tool setup.

Apache-2.0 ★ 138 updated 2025-03-29

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/consuming-dotnettool.mdc
Open on GitHub

What consuming-dotnettool does

consuming-dotnettool sets project guidance for consuming dotnet tool packages in .NET projects. It asks the project to keep a manifest at .config/dotnet-tools.json, pin every tool to an explicit version, and commit that file to version control. A new manifest starts with dotnet new tool-manifest; packages are added with dotnet tool install <tool-package> --version <version>.

The rule covers installation, updates, restoration, and periodic manifest checks. It also asks for tool purpose and troubleshooting notes in the README or contributing guidelines. CI/CD should run dotnet tool restore before build or test stages, verify expected versions, and may cache restored tools between runs. Security guidance covers trusted sources, licensing, and avoiding wildcard or range versions.

CI/CD must restore tools before build or test, or those stages will not have the manifest dependencies prepared by this process.

What it helps with

  • create a manifest for project-local .NET tools
  • pin dotnet tool packages to explicit versions
  • restore tools before build and test jobs
  • update a tool without changing its version implicitly
  • audit the manifest for unused or outdated tools

Example prompts for the agent

  • Set up .config/dotnet-tools.json for this .NET project and explain which tools belong in it.
  • Create the manifest with dotnet new tool-manifest, then add <tool-package> at version <version>.
  • Add dotnet tool restore before the build and test stages in the CI/CD pipeline, then document the tools in the README.

How to install consuming-dotnettool

Manually: put the files in place

.cursor/rules/consuming-dotnettool.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about consuming-dotnettool

How do I install consuming-dotnettool in Claude Code?

Create the rule file at .claude/rules/consuming-dotnettool.md and place the consuming-dotnettool contents there.

What does consuming-dotnettool do?

It guides projects to manage dotnet tool dependencies through a committed manifest, explicit versions, restore steps, and maintenance documentation.

Which platforms support consuming-dotnettool?

The rule is provided for Claude Code and Cursor. Claude Code uses .claude/rules/consuming-dotnettool.md, while Cursor uses .cursor/rules/consuming-dotnettool.mdc.

Source text

consuming-dotnettool.mdc · Apache-2.0
---
description: This tool is used for helping manage and organize the installation of `dotnet tool` instances that are used for .NET projects.
globs: 
alwaysApply: false
---

# Cursor Rules File: Best Practices for Consuming dotnet Tool Instances
# This file provides guidelines for projects that depend on dotnet tools. It ensures that:
# - A tool manifest is maintained for local and CI/CD consistency.
# - Tool versions are explicitly defined.
# - Proper installation, updating, and documentation practices are followed.

General:
  Description: >
    Projects consuming dotnet tool instances must manage their tool dependencies through a tool manifest.
    This approach promotes reproducible builds and clear dependency management, ensuring that the correct
    tool versions are used consistently across different environments.
  Requirements:
    - Maintain a tool manifest file (typically located at `.config/dotnet-tools.json`) in the project root.
    - Use explicit versioning for all dotnet tools to prevent unexpected updates.
    - Integrate tool management into the CI/CD pipeline for automated restoration.

Preparation:
  - If a tool manifest does not exist, create one by running:
      - `dotnet new tool-manifest`
  - Update the tool manifest with the necessary tools by executing:
      - `dotnet tool install <tool-package> --version <version>`
  - Ensure the manifest file (`.config/dotnet-tools.json`) is checked into version control for consistency.

Tool Management:
  - Installation:
      - Use `dotnet tool install` with an explicit version to add a tool to the manifest.
      - Verify that the installed tool versions match the ones specified in the manifest.
      - For tools that support both global and local installation, prefer local installation via manifest.
  - Updating:
      - To update a tool, use `dotnet tool update <tool-package> --version <version>`.
      - After updating, validate that the manifest reflects the new version.
  - Restoration:
      - Ensure that `dotnet tool restore` is executed as part of local setup and CI/CD processes to install all tools defined in the manifest.
  - Verification:
      - Periodically review the manifest to confirm that all tool versions are current and that deprecated or unused tools are removed.

Integration & CI/CD:
  - Include the following steps in your CI/CD pipeline:
      - **Restore Tools:** Run `dotnet tool restore` prior to build or test phases.
      - **Version Check:** Validate that the manifest has not drifted from the expected tool versions.
      - **Cache Tools:** Consider caching the restored tools between pipeline runs to improve build times.
  - Document the usage of these tools in your project README or contributing guidelines for clarity.

Documentation & Maintenance:
  - Document in your project README:
      - The purpose of each dotnet tool listed in the manifest.
      - Instructions for installing, updating, or troubleshooting the tools.
  - Regularly audit the manifest to:
      - Remove outdated or unused tools.
      - Update tools when new versions become available and are verified for compatibility.
  - Maintain clear commit messages when changes are made to the tool manifest.

Security & Compliance:
  - Ensure that all tools come from trusted sources and have proper licensing.
  - Avoid using wildcard or range versioning to mitigate the risk of unintentional upgrades.
  - Document any security advisories or considerations related to the consumed tools.

Automation:
  - Automate tool restoration by incorporating `dotnet tool restore` into your build scripts.
  - Consider using scripts or CI/CD tasks to:
      - Check for available updates to the tools.
      - Validate the integrity and security compliance of the manifest file.
      - Monitor for security advisories related to installed tools.
      - Automatically create PRs for tool updates after successful testing.
      
# End of Cursor Rules File

© Aaronontheweb · Apache-2.0 · Aaronontheweb/dotnet-cursor-rules

Similar IDE rules

All IDE rules for Programming languages →

From the same set11

The whole set →
meta The meta rule guides edits to *.mdc files, preserving their formatting and steering agents toward existing rule files before creating new ones. CX Codex +1 ★ 138repo stars publishing-dotnettool Guides AI agents when creating and publishing dotnet tools to NuGet. Ensures semantic versioning, correct packaging, and compatibility across .NET versions. CX Codex +1 ★ 138repo stars code-signing Enforces .NET code signing patterns and SignClient configuration for NuGet packages in CI/CD pipelines. CX Codex +1 ★ 138repo stars dependency-management Rule for secure NuGet dependency management: vulnerability scanning, license compliance, versioning via dotnet CLI. Auto-applies to project files. CX Codex +1 ★ 138repo stars solution-management solution-management standardizes .NET solution architecture with explicit SDK pinning, shared build properties, and centralized package management. CX Codex +1 ★ 138repo stars benchmarking The benchmarking rule teaches the agent to write valid .NET performance tests using BenchmarkDotNet. Useful when you need to measure code speed and track regressions. CX Codex +1 ★ 138repo stars nuget-package-publishing nuget-package-publishing — a rule that teaches the agent to pack .NET libraries into NuGet packages following industry standards: SPDX license, README, and debug symbols. CX Codex +1 ★ 138repo stars testing Defines xUnit testing conventions for .NET: project configurations, test isolation, coverage thresholds, and integration test setup. CX Codex +1 ★ 138repo stars

Project sponsors

Companies that keep this analytics open