From agent-instructions
Use when creating or updating agent instruction files (AGENTS.md for Pi, copilot-instructions.md for Copilot, per-path guides, or AGENTS.md router) — especially when instruction files are too long, generic, or stale, or when agents repeatedly make the same avoidable mistakes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agent-instructions:agent-instructionsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Purpose:** Create or refresh instruction files that guide agent behavior and reduce repeated mistakes without rewriting the repository or enforcing tool choices that contradict the codebase.
Purpose: Create or refresh instruction files that guide agent behavior and reduce repeated mistakes without rewriting the repository or enforcing tool choices that contradict the codebase.
Before adding any line to an instruction file, ask: "Can an agent discover this by reading the repo — README, code, config, scripts, directory tree?"
If YES: do not include. If NO, and it materially affects task success: include.
This filter ensures instruction files stay focused, reduce duplication, and remain a source of truth for the non-obvious and operationally critical.
Non-discoverable from repository files alone
Operationally significant
Actionable and specific
See discoverability-filter.md for deeper guidance and worked examples.
| Signal | Route to this skill | Route elsewhere |
|---|---|---|
| "Instructions need auditing" | ✓ | Review existing files first |
| "Agents keep doing X wrong" | ✓ | Check if a skill already addresses this |
| "I need a new instruction file" | ✓ | If the instruction is about code changes, use the relevant coding skill |
| "Update the README" | ✗ | User documentation belongs in README or project docs |
| "Enforce a linter or rule" | ✗ | Use tsconfig, eslint config, tooling setup (not instructions) |
| "Change the actual code" | ✗ | Use a coding or debugging skill |
| "Create or revise a reusable skill package" | ✗ | skill-authoring |
Before starting, clarify:
Scope: Which instruction files are in scope?
~/.pi/agent/AGENTS.md or ~/.pi/agent/CLAUDE.mdAGENTS.md or CLAUDE.md in repo root or parent directories (discovered upward from cwd)~/.copilot/copilot-instructions.md.github/copilot-instructions.md (repo root).github/instructions/*.md (with YAML frontmatter description and applyTo fields)AGENTS.md (agent roster and routing)Problem: What mistake or gap triggers this work?
Constraints: What is off-limits?
Audit current state:
Identify patterns:
Apply the Discoverability Filter:
description and applyTo, sections, learned rules)For each line in the instruction file:
Non-discoverable? Can an agent find this info by reading the repo (code, config, README, scripts)?
Accurate? Does this reflect the actual repository state right now?
Materially reduces mistakes? Would an agent make a noticeably better decision with this line?
Delete the line if any answer is NO.
Not a code walkthrough: Do not use instruction files as a substitute for comments, docstrings, or architecture documentation. Agents can read the code; tell them what the code cannot tell them.
Not a tool override: Do not use instructions to forbid a tool or force a specific choice unless the repository genuinely cannot use that tool (e.g., a Go project banning Node-only packages). If the tool is suitable here, say why and under what conditions.
Not a duplicate of automation: If a rule is already enforced by a linter, pre-commit hook, or CI gate, do not repeat it in instructions. Instead, instruct agents to run that tool and trust its feedback.
Not a policy engine: Do not use instructions to police coding style, commit message formatting, or PR review etiquette. Those belong in contributing guidelines or automated linting. Instruction files are for repository-specific non-obvious operational knowledge.
Stable before sharing: Do not create instruction files for code or patterns that are still in flux. Wait for the repository state to settle, then document it. Otherwise, agents will get stale guidance and waste time on outdated advice.
After writing or updating an instruction file:
Checklist:
*.instructions.md file in scope keeps both description and applyTo in YAML frontmatterTest with an agent:
Schedule review:
skill-authoring)The examples below each pass the 3-Question Check: non-discoverable, accurate, and materially useful to an agent.
Scenario: A TypeScript project repeatedly sees agents use any in main code, even though the repo has strict noImplicitAny and a clear pattern of using unknown at boundaries.
Discoverable? Partially — the tsconfig shows noImplicitAny: true, but the pattern of "use unknown at boundaries and narrow with guards" is a convention, not a rule.
Include? YES, because it's non-obvious to a new agent why any fails and how to fix it.
Line:
- Avoid `any` in source files; use `unknown` at module boundaries and narrow with type guards. The tsconfig enforces `noImplicitAny`, so use it as feedback for where to add guards.
Scenario: Someone wants to add: "The repository has src/, tests/, docs/, and scripts/. Use src/ for source code, tests/ for test files, etc."
Discoverable? YES — the directory names are self-documenting.
Include? NO — delete this line. It's visible in the tree.
Scenario: The repository has a 1Password-backed Git signing requirement. Commits without a valid signature will be rejected. This is not mentioned in any config file or script.
Discoverable? NO — there's no comment in the Git config or README explaining this.
Include? YES, because it materially affects whether a commit will be accepted.
Line:
- All commits must be signed via 1Password SSH signing; unsigned or GPG-signed commits will be rejected. If signing fails, validate the 1Password setup and approve the authorization in the app.
See instruction-examples.md for more worked examples.
references/discoverability-filter.md — deeper guidance and worked examples for applying the discoverability filterreferences/instruction-examples.md — real examples of good vs. bad instruction lines across several repositoriesCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub matt-riley/lucky-hat --plugin agent-instructions