ravnhq

agent-add-rule

0
0
# Install this skill:
npx skills add ravnhq/ai-toolkit --skill "agent-add-rule"

Install specific skill from multi-skill repository

# Description

>

# SKILL.md


name: agent-add-rule
description: >
Add a new rule, convention, or instruction to the project's agent configuration.
Analyzes the rule and helps decide placement: root CLAUDE.md (universal rules),
docs/agents/ files (topic-specific guidance), or a new skill (complex workflows).
Triggers on: '/agent-add-rule', 'add a rule', 'add convention', 'new coding standard',
'add instruction for claude', 'update claude.md with'.


Add Rule β€” Place Agent Instructions Correctly

Add a new rule or convention to the right location in the progressive disclosure structure.

Context Spectrum

Static (root CLAUDE.md)      β€” loaded every conversation. Token cost always paid.
Semi-dynamic (docs/agents/)  β€” linked from root. Loaded when Claude follows a link.
Fully dynamic (skills)       β€” metadata only in context. Body loaded on trigger.

Workflow

Step 1: Ask

Ask the user: "What rule or convention do you want to add?"

Accept free text. If the user already provided it (e.g., /agent-add-rule always use snake_case for database columns), skip this step.

Step 2: Analyze Current Structure

Read:

  • Root CLAUDE.md
  • List files in docs/agents/
  • List available skills

Understand what already exists so you don't duplicate or contradict.

Step 3: Classify

Apply this decision tree:

Does the agent consistently get this wrong WITHOUT being told?
β”œβ”€β”€ NO β†’ Challenge: "Does this justify its token cost?"
β”‚        If user still wants it β†’ treat as semi-dynamic
β”‚
β”œβ”€β”€ YES β†’ Does it apply to EVERY task?
β”‚   β”œβ”€β”€ YES β†’ Root CLAUDE.md (static)
β”‚   β”‚         Examples: package manager, multi-tenancy, project scripts
β”‚   β”‚
β”‚   └── NO β†’ docs/agents/ file (semi-dynamic)
β”‚             Examples: lint rules, test thresholds, API conventions
β”‚
└── Is it a repeatable workflow or procedural knowledge?
    β”œβ”€β”€ YES β†’ Skill (fully dynamic)
    β”‚         Examples: deployment process, PR review checklist, migration procedure
    β”‚
    └── NO β†’ Probably not needed. Ask: "Does this justify its token cost?"

Key questions to ask the user:

  1. "Does the agent consistently get this wrong?" β€” If no, consider skipping
  2. "Does this apply to every task or just some?" β€” Static vs semi-dynamic
  3. "Is this a rule or a workflow?" β€” docs/agents/ vs skill
  4. "Will this change frequently?" β€” Skills are easier to evolve independently

Step 4: Recommend

Present the recommended placement with reasoning:

Recommendation: Add to docs/agents/guardrails.md

Reasoning:
- This is a data handling rule, not a universal workflow rule
- It applies only when working with the database
- guardrails.md already covers data isolation patterns
- Adding to root would cost tokens on every conversation unnecessarily

Step 5: Confirm

Ask the user to confirm or override. If they override, respect their choice but note the trade-off:

  • Moving to root: "This adds ~X lines to every conversation's context"
  • Moving to docs/agents/: "This won't be visible unless Claude follows the link"
  • Moving to skill: "This will only load when triggered by matching keywords"

Step 6: Write

Based on confirmed placement:

If root CLAUDE.md:

  • Add the rule under the appropriate section (Key Rules, Workflow, etc.)
  • Warn: "This adds to every conversation's token budget"
  • Keep it concise β€” 1-2 lines max

If existing docs/agents/ file:

  • Read the target file
  • Add the rule under the appropriate section
  • Keep consistent formatting with existing content

If new docs/agents/ file:

  • Create the file with a clear heading and the rule
  • Update root CLAUDE.md links section with a new entry including routing signal
  • Example: - [API Conventions](docs/agents/api-conventions.md) β€” REST patterns, error response format, pagination

If skill:

  • Tell the user to run /agent-skill-creator to scaffold it
  • Provide the rule content as input for the skill body

Examples

Example 1: Universal Rule β†’ Root

User: "Always use pnpm, never npm"

Classification: Agent gets this wrong without being told + applies to every task β†’ Root

Action: Add to Key Rules section in CLAUDE.md

Example 2: Topic-Specific Rule β†’ docs/agents/

User: "API responses must always include a requestId field"

Classification: Agent might get wrong + only applies to API work β†’ Semi-dynamic

Action: Add to docs/agents/guardrails.md or create docs/agents/api-conventions.md

Example 3: Complex Workflow β†’ Skill

User: "When deploying, always run migrations first, then build, then deploy to staging, verify, then production"

Classification: Repeatable multi-step procedure β†’ Fully dynamic (skill)

Action: Suggest /agent-skill-creator to create a deployment skill

Example 4: Unnecessary Rule β†’ Challenge

User: "Always use const instead of let"

Classification: ESLint already enforces this β†’ Not needed

Response: "ESLint already enforces this via the prefer-const rule. Adding it to agent instructions would cost tokens without benefit. Skip?"

Principles

  • Challenge before adding: Every rule costs tokens. Ask "does this justify its token cost?"
  • No duplication: If ESLint, TypeScript, or another tool already enforces it, don't add it
  • Routing signals matter: When adding to docs/agents/, update the root CLAUDE.md link description so Claude knows when to follow it
  • One level deep: Never cross-reference between docs/agents/ files. All links go from root

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.