add-rule

A workflow for recording a team's coding convention in the project's Claude rules or agent files so it is applied automatically in the relevant work.

In plain words
What is it for?
Use it to add rules about testing, context handling, CLI output formats, or other conventions, while choosing the appropriate file and scope.
Why use it?
It turns informal advice or corrections into reusable project guidance and preserves the reason behind each rule for future decisions.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/stacklok/toolhive/add-rule
Any agent
npx skills add stacklok/toolhive --skill add-rule
Clone the repo
git clone --depth 1 https://github.com/stacklok/toolhive

Made for: Claude Code, Codex.

Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,163 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.01163
Opus 5 $0.00015 $0.00581
Sonnet 5 $0.00006 $0.00233
Haiku 4.5 $0.00003 $0.00116

Measured 2d ago against content hash 01603ed05788, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

add-rule scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/add-rule/SKILL.md · 100 lines

How it starts

The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Add Rule — Capture a Team Convention

Purpose

Formalize a convention, best practice, or correction into the project's .claude/rules/ or .claude/agents/ files so it applies automatically for all team members.

Input

The user provides a convention in natural language. Examples:

  • /add-rule "prefer require.NoError over t.Fatal for error assertions"
  • /add-rule "use context.Background() in tests, not context.TODO()"
  • /add-rule "CLI commands must support --format json"

If no argument is provided, ask: "What convention would you like to add?"

Instructions

1. Understand the Convention

Parse the user's input to identify:

  • The rule: What should or should not be done
  • The scope: Which files or areas it applies to (Go code, tests, CLI, operator, etc.)
  • The reason: Why this convention exists (ask if not provided — the "why" is critical for future developers to judge edge cases)

2. Find the Right Target File

Rules vs Agents — key principle: Rules define conventions; agents reference rules. Never duplicate rule content in agent files.

  • Rules files (.claude/rules/): Auto-loaded based on paths: frontmatter globs when Claude touches matching files. These define the canonical conventions (style, testing patterns, error handling, etc.).
  • Agent files (.claude/agents/): Define agent-specific behavior — persona, review checklist, output format, workflow steps. Agents inherit the full conversation context (including CLAUDE.md), so they already have access to all loaded rules. Agent files should reference rules (e.g., "Follows conventions in .claude/rules/testing.md"), never restate them.

Match the convention to an existing file based on scope:

Scope Target file What goes here
General Go code .claude/rules/go-style.md Style, naming, error handling conventions
Test files .claude/rules/testing.md Testing patterns, framework usage
CLI commands .claude/rules/cli-commands.md CLI architecture, flag conventions
Kubernetes operator .claude/rules/operator.md CRD, controller conventions
PR creation .claude/rules/pr-creation.md PR format, review expectations
Agent workflow/persona .claude/agents/<agent-name>.md Agent-specific behavior, checklists, output format

Read the full file on GitHub · 100 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 100 lines · 31 tokens per session scan A 01603ed05788

Subscribe to this mod's changes

add-rule is a skill published in the GitHub repository stacklok/toolhive (2,065 stars, last pushed today), licensed Apache-2.0. It adds 31 tokens to every session and 1,163 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

testing-mcp-server-security

Testing Model Context Protocol (MCP) servers and the clients that consume them for tool poisoning, prompt injection via tool descriptions/outputs, over-permissioned and local-credential-stealing tools, config/trust bypasses, and unauthenticated RCE during authorized penetration tests of AI agent infrastructure.

xalgorix/xalgorix · 66 tokens

skill-inspector

Review AI agent skills before installation using NVIDIA SkillSpector and source-aware semantic review. Use when asked whether a skill or downloaded skill folder is safe, trustworthy, installable, over-permissioned, or malicious.

NVIDIA/SkillSpector · 47 tokens

fastmcp-client-cli

Query and invoke tools on MCP servers using fastmcp list and fastmcp call. Use when you need to discover what tools a server offers, call tools, or integrate MCP servers into workflows.

PrefectHQ/fastmcp · 46 tokens

chatgpt-app-builder

Build, modify, debug, migrate, review, or verify TypeScript MCP servers and MCP Apps with mcp-use. Use for tools, resources, prompts, middleware, Views, authentication, Skills over MCP, scaffolding, and advanced features.

mcp-use/mcp-use · 55 tokens

underdeclared-agent

A helpful assistant agent.

NVIDIA/SkillSpector · 9 tokens

integrate-arcjet-guard-claude-agent-sdk

Integrate Arcjet security into a Claude Agent SDK agent using @arcjet/guard — wrap tool() handlers, screen inbound prompts with UserPromptSubmit, and deny unwrapped built-in/MCP tools with PreToolUse. Use when asked to add Arcjet to a Claude Agent SDK or Claude Code agent, rate limit its tools, screen inbound…

arcjet/arcjet-js · 92 tokens