Agent skill
new-rule
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/new-rule
SKILL.md
Scaffold a New Rule (TDD)
Arguments: $ARGUMENTS
Example: /new-rule {RuleId} "Large struct passed by value"
Validation
- Parse
$1as the rule ID and everything after as the title - Verify the rule ID matches the prefix defined in CLAUDE.md followed by a numeric ID — reject otherwise
- Verify no existing descriptor matches
id: "$1"insrc/Spire.Analyzers/Descriptors.cs— abort if duplicate
Scaffolding (TDD order — tests and descriptor BEFORE analyzer)
- Add descriptor to
src/Spire.Analyzers/Descriptors.cs- Field name:
{RuleId}_{TitlePascalCase} - Add in sequential order
- Field name:
- Create test folder:
tests/Spire.Analyzers.Tests/{RuleId}/ - Create test case folder:
tests/Spire.Analyzers.Tests/{RuleId}/cases/ - Create shared preamble:
tests/Spire.Analyzers.Tests/{RuleId}/cases/_shared.cs- Use
global usingdirectives (not plainusing) — they apply to all case files since_shared.csis a separate syntax tree in the same compilation - Always include:
global using System;,global using System.Collections.Generic;,global using System.Threading.Tasks;,global using Spire.Analyzers; - Add rule-specific
global usingdirectives as needed (e.g.,global using System.Buffers;) - Include shared type definitions relevant to the rule
- Use
- Create test runner from template:
tests/Spire.Analyzers.Tests/{RuleId}/{RuleId}Tests.cs- Replace
{{RULE_ID}},{{ANALYZER_TYPE}} - Inherits
AnalyzerTestBase<TAnalyzer>— cases discovered at runtime, no[InlineData]needed
- Replace
- Create docs:
docs/rules/{RuleId}.md- Replace
{{RULE_ID}},{{RULE_TITLE}} - Follow
docs/style-guide.mdfor documentation style
- Replace
Verify
- Run
dotnet build— must succeed with zero warnings - Report all created files
What this skill does NOT do
- Does NOT create the analyzer file — that is the implementer's job, after tests are written
- Does NOT create test case files — the lead writes those based on the rule plan's spec tables
- Only scaffolds the structure so the lead can immediately start writing test cases
Constraints
- Do NOT implement detection logic — the analyzer file is not created at this stage
- Do NOT modify existing analyzer files or descriptors (only append the new descriptor)
- Do NOT proceed if validation fails — report the error and stop
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?