Skip to content

Claude Code guide in three levels, Beginner to Advanced: hands-on lessons with checked exercises, every volatile fact cited to its source. Independent community guide.

docs: ship an Agent Skill and correct the frontmatter contract (#23)

Wesam Abousaid8cd4779d830b
diff --git a/.claude/skills/claude-md-review/SKILL.md b/.claude/skills/claude-md-review/SKILL.md
new file mode 100644
index 0000000..2716fe5
--- /dev/null
+++ b/.claude/skills/claude-md-review/SKILL.md
@@ -0,0 +1,76 @@
+---
+description: Audit a CLAUDE.md file for the patterns that actually degrade Claude Code's output — vagueness, unnamed files, stale facts, and bloat. Use when asked to review, audit, improve, shrink, or fix a CLAUDE.md, and when a project's results feel inconsistent or Claude keeps rediscovering the same context.
+when_to_use: Trigger phrases include "review my CLAUDE.md", "why does Claude keep forgetting", "my CLAUDE.md is too long", "Claude ignores my instructions", "audit project instructions".
+argument-hint: "[path to CLAUDE.md, defaults to ./CLAUDE.md]"
+allowed-tools: Read, Glob, Grep
+---
+
+# CLAUDE.md Review
+
+Audit a `CLAUDE.md` against the failure modes that actually cost output quality.
+
+**Premise:** `CLAUDE.md` loads into context on every single session, so every line is either paying rent or costing you tokens on every turn forever. Most "the model isn't following instructions" problems are instruction problems.
+
+## Steps
+
+1. Read the target file (default `./CLAUDE.md`; also check `~/.claude/CLAUDE.md` and any nested `**/CLAUDE.md` if the project has them, since the closest one wins).
+2. Score each dimension below and quote the specific lines that fail.
+3. Output the report format at the bottom. Propose concrete rewrites, not "consider being more specific."
+
+## What to check
+
+**Specificity** — the highest-leverage dimension.
+- Flag unfalsifiable directives: "write clean code", "follow best practices", "be careful", "use good naming".
+- Every rule should be checkable by reading a diff. `"Refactor functions over 40 lines"` is checkable; `"keep functions short"` is not.
+
+**Named anchors.**
+- Rules that reference "the config", "our API layer", or "the usual pattern" force rediscovery every session. Replace with real paths: `src/config/env.ts`, `src/api/client.ts`.
+- Verify every path, command, and filename mentioned still exists. Report the dead ones — a `CLAUDE.md` pointing at a deleted file actively misleads.
+
+**Staleness.**
+- Version numbers, model names, and tool commands that no longer match the repo.
+- Instructions for a framework, script, or directory that's since been removed.
+- Cross-check build/test/lint commands against `package.json`, `Makefile`, `pyproject.toml`, or equivalent — a wrong test command is worse than none.
+
+**Bloat and rent.**
+- Anything derivable from the code itself (file tree listings, dependency lists, restating what a function does). Claude can read the repo.
+- Long procedures that only apply to one occasional task: those belong in a skill, whose body loads only when used, rather than in context on every turn.
+- Generic advice that applies to all software everywhere and therefore teaches nothing about *this* project.
+
+**Conflicts.**
+- Rules that contradict each other, or contradict what the code actually does. Flag both sides and ask which wins.
+- Precedence surprises: a nested `CLAUDE.md` or `~/.claude/CLAUDE.md` overriding what the author expects.
+
+**What's missing.** The gaps worth calling out, if absent:
+- How to run tests, build, and lint — the three things needed to self-verify a change.
+- Non-obvious project constraints (a directory that must not be touched, a generated file, a required migration step).
+- Conventions that are genuinely surprising and not visible from a quick read of the code.
+
+## Output format
+
+```
+## CLAUDE.md review — <path> (<N> lines)
+
+**Verdict:** <one sentence>
+
+### Blocking
+- L<n>: <quoted line> → <concrete rewrite>
+
+### Worth fixing
+- L<n>: <quoted line> → <concrete rewrite>
+
+### Delete (costs context on every session, earns nothing)
+- L<n>–<m>: <what and why>
+
+### Missing
+- <gap> → <suggested line to add>
+
+**Estimated size after edits:** <N> lines (from <M>)
+```
+
+## Rules
+
+- Quote real line numbers and real text. Never invent a finding to fill a section.
+- If a section has no findings, write `None.` — a clean file is a valid result.
+- Prefer deleting to rewriting. The best `CLAUDE.md` is short enough that people actually read it.
+- Do not edit the file unless asked. Report first.
diff --git a/README.md b/README.md
index c30f605..cd119a2 100644
--- a/README.md
+++ b/README.md
@@ -144,19 +144,28 @@ Once Claude Code is running, try one of these:
Creates a project-level instruction file that Claude reads on every session — your project's "house rules." More on this in [Prompt Engineering Deep Dive](#prompt-engineering-deep-dive).
-#### 5. (Bonus) See a real Claude Code project setup
+<a id="steal-this-setup"></a>
+#### 5. (Bonus) Steal this repo's setup
-This repo's own [`.claude/`](.claude/) directory is a working example of a fully-configured Claude Code project. Browse it as a reference for what a polished setup looks like:
+This repo's [`.claude/`](.claude/) directory is a **working, runnable** Claude Code project — one of each extension point, not screenshots of one. Every path below is something you can copy into your own project today:
-| Path | What it does |
-|---|---|
-| [`.claude/settings.json`](.claude/settings.json) | Project-level Claude Code settings — permissions and hooks |
-| [`.claude/agents/`](.claude/agents) | 5 specialized subagents (frontend, tech lead, PM, UX designer, code reviewer) |
-| [`.claude/commands/`](.claude/commands) | 7 custom skills — `/pr`, `/review`, `/tdd`, `/test`, `/five`, `/ux`, `/todo`. Slash commands and Agent Skills are now one system — see [Skills](#claude-skills). |
-| [`.claude/hooks/`](.claude/hooks) | Python hook scripts (`post_tool_use.py`, `notification.py`, `stop.py`, `subagent_stop.py`) — see [Hooks](#hooks) |
-| [`.claude/workflows/`](.claude/workflows) | A runnable [dynamic workflow](#dynamic-workflows) — `/stale-docs-audit` fans agents across the docs and refutes its own findings |
+| Path | What you get | Copy it when… |
+|---|---|---|
+| [`.claude/commands/`](.claude/commands) | 7 slash skills — `/pr`, `/review`, `/tdd`, `/test`, `/five`, `/ux`, `/todo` | You want PR hygiene and review rigor without writing the prompts |
+| [`.claude/skills/`](.claude/skills) | An Agent Skill — `/claude-md-review` audits a `CLAUDE.md` for vagueness, dead paths, and bloat | You want a worked example of the [frontmatter contract](docs/skills.md#frontmatter-reference) |
+| [`.claude/agents/`](.claude/agents) | 5 subagents, plus [10 more role prompts](#3-specialized-subagents--drop-in-role-prompts) in `specialized-agents/` | You want specialists without authoring role prompts — they double as [Agent Teams](#agent-teams-experimental) teammates |
+| [`.claude/workflows/`](.claude/workflows) | A [dynamic workflow](#dynamic-workflows) — `/stale-docs-audit` fans agents across your docs, then refutes its own findings | You want a real script to read before writing your own |
+| [`.claude/hooks/`](.claude/hooks) | Python hooks — `post_tool_use.py`, `notification.py`, `stop.py`, `subagent_stop.py` | You want [lifecycle automation](#hooks) (needs [`uv`](https://docs.astral.sh/uv/getting-started/installation/)) |
+| [`.claude/settings.json`](.claude/settings.json) | Permissions + hook wiring | You're copying the hooks — swap the hardcoded `uv` path for `$(which uv)` |
+
+```bash
+git clone --depth 1 https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know /tmp/cc-guide
+cp -r /tmp/cc-guide/.claude/commands/pr.md your-project/.claude/commands/ # take what you want
+```
+
+> ⚠️ **Read before you copy.** Skills, hooks, agents, and workflows are executable instructions that run with your permissions — including from *this* repo. Copy file by file and read each one, the same way you'd review a shell script before sourcing it. Don't `cp -r` a whole `.claude/` you haven't opened.
-> 💡 **Next:** Once you're comfortable with the basics, jump to [Claude Skills](#claude-skills) to build reusable slash commands in 3 minutes.
+> 💡 **Next:** [Claude Skills](#claude-skills) to build your own in 3 minutes.
---
### Prompt Engineering Deep Dive
@@ -324,9 +333,9 @@ That's it — a working slash skill. Promote it to an Agent Skill later by movin
The [full Skills guide in `docs/skills.md`](docs/skills.md) covers:
-- The 7 custom slash skills in this repo's `.claude/commands/`: `/pr`, `/review`, `/tdd`, `/test`, `/five`, `/ux`, `/todo`
+- The 8 skills shipped here: `/pr`, `/review`, `/tdd`, `/test`, `/five`, `/ux`, `/todo`, plus the Agent Skill [`/claude-md-review`](.claude/skills/claude-md-review/SKILL.md)
- Bundled built-in skills (e.g. `/dataviz`, `/debug`, `/keybindings-help`)
-- Slash skills vs Agent Skills — when to use each, frontmatter contract, conversion path
+- Slash skills vs Agent Skills, and the [full frontmatter reference](docs/skills.md#frontmatter-reference) — including why `allowed-tools` **grants** permission rather than restricting it
- Workflow recipes — feature dev with TDD + PR, bug investigation, UX-first dev
- How to write your own skills (file format, scope, examples)
- Skills FAQ, troubleshooting, and best practices
diff --git a/docs/skills.md b/docs/skills.md
index 4491006..accbcf5 100644
--- a/docs/skills.md
+++ b/docs/skills.md
@@ -11,10 +11,11 @@
| | Slash skills *(custom slash commands)* | Agent Skills |
|---|---|---|
| **File path** | `.claude/commands/<name>.md` | `.claude/skills/<name>/SKILL.md` |
-| **Frontmatter** | None required | YAML — `name`, `description` (required); `allowed-tools`, `model`, `paths` (optional) |
-| **Invocation** | User types `/<name>` | Model auto-invokes when its description matches the request |
+| **Frontmatter** | Optional — supports the same fields | Optional, but `description` is what lets Claude auto-invoke |
+| **Invocation** | User types `/<name>` | **Both** — you type `/<name>`, *and* Claude auto-invokes when the description matches |
| **Scope** | Project (`.claude/`) or user (`~/.claude/`) | Project (`.claude/skills/`) or user (`~/.claude/skills/`) |
| **Loading** | Loaded on `/` autocomplete | Metadata pre-loaded; full content read on demand (progressive disclosure) |
+| **Extras** | — | A whole directory for supporting files (`scripts/`, `references/`, `assets/`) |
| **Best for** | Workflows you want to trigger explicitly | Capabilities Claude should reach for when relevant |
> 💡 **Which to write?** Start with slash skills — simpler, no frontmatter, and you control invocation. Reach for Agent Skills when you want Claude to *decide* when the workflow applies (e.g., "if the user asks about PDFs, invoke `pdf-handler`"). The wider community has converged on Agent Skills as the format for shareable capabilities — see [The skills ecosystem](#the-skills-ecosystem) below.
@@ -98,29 +99,20 @@ Claude Skills (a.k.a. *custom slash commands*) are markdown files in `.claude/co
| `debug` | Troubleshoot the current session and configuration | `/debug` |
| `keybindings-help` | Customize keyboard shortcuts and modify `~/.claude/keybindings.json` | `/keybindings-help` |
-**Custom skills** (in this repository's `.claude/commands/`):
+**Custom skills** (shipped in this repository):
-| Skill | Category | Complexity |
+| Skill | Format | What it does |
|---|---|---|
-| `/pr` | Workflow | High |
-| `/review` | Quality | High |
-| `/test` | Quality | Medium |
-| `/tdd` | Workflow | High |
-| `/five` | Persona | Low |
-| `/ux` | Persona | Medium |
-| `/todo` | Task | Low |
+| `/pr` | Slash | Automated pull request creation with branch management and commit splitting |
+| `/review` | Slash | Multi-perspective code review (PM, Dev, QA, Security, DevOps, UX) |
+| `/test` | Slash | Unit testing best-practices checklist for LLM-driven test generation |
+| `/tdd` | Slash | Complete test-driven development workflow with Red-Green-Refactor cycle |
+| `/five` | Slash | Five Whys root-cause analysis for debugging and problem-solving |
+| `/ux` | Slash | User-experience designer persona for empathetic, user-centric design |
+| `/todo` | Slash | Task management in `todos.md` with due dates and completion tracking |
+| `/claude-md-review` | **Agent Skill** | Audits a `CLAUDE.md` for vagueness, dead file paths, stale commands, and bloat — and Claude reaches for it on its own when a project's instructions look like the problem |
-**What each skill does:**
-
-| Skill | Description |
-|---|---|
-| `/pr` | Automated pull request creation with branch management and commit splitting |
-| `/review` | Multi-perspective code review (PM, Dev, QA, Security, DevOps, UX) |
-| `/test` | Unit testing best-practices checklist for LLM-driven test generation |
-| `/tdd` | Complete test-driven development workflow with Red-Green-Refactor cycle |
-| `/five` | Five Whys root-cause analysis for debugging and problem-solving |
-| `/ux` | User-experience designer persona for empathetic, user-centric design |
-| `/todo` | Task management in `todos.md` with due dates and completion tracking |
+The first seven live in [`.claude/commands/`](../.claude/commands) as plain markdown. [`/claude-md-review`](../.claude/skills/claude-md-review/SKILL.md) lives in `.claude/skills/` and is the worked example of the [frontmatter contract](#frontmatter-reference) — read it alongside the field table below.
> 💡 **Pro tip:** Start with simple skills like `/five` or `/todo` to understand the pattern, then progress to complex workflows like `/tdd` or `/review`.
@@ -851,18 +843,47 @@ claude
> /reload-skills # reload skill files without restarting (v2.1.152+)
```
-> 💡 **Convert a slash skill to an Agent Skill.** Move `.claude/commands/<name>.md` to `.claude/skills/<name>/SKILL.md`, add YAML frontmatter at the top (`name`, `description`), and Claude will start invoking it automatically when the description matches the user's request — no more typing `/<name>`.
+> 💡 **Convert a slash skill to an Agent Skill.** Move `.claude/commands/<name>.md` to `.claude/skills/<name>/SKILL.md` and add a `description`. Claude will then invoke it automatically when the description matches the request, on top of you still being able to type `/<name>`.
+
+<a id="frontmatter-reference"></a>
+
+### Frontmatter reference
+
+**Every field is optional.** Only `description` is *recommended* — it's how Claude decides when to apply the skill. Without it, the first paragraph of the body is used instead.
```yaml
---
-name: my-skill
description: Use when the user asks for X, Y, or Z. Adds A and B.
-allowed-tools: ["Read", "Edit", "Bash"] # optional
+allowed-tools: Read, Grep
---
# Skill body — same structured prompt you'd put in a slash skill
```
+The fields worth knowing:
+
+| Field | What it does |
+|---|---|
+| `description` | What the skill does **and when to use it**. Put the key use case first — `description` + `when_to_use` is truncated at **1,536 characters** in the skill listing |
+| `when_to_use` | Extra trigger phrases and example requests; appended to `description`, counts toward the same cap |
+| `disable-model-invocation` | `true` = only *you* can invoke it. Use for anything with side effects (`/deploy`, `/commit`) — you don't want Claude deciding your code looks ready to ship |
+| `user-invocable` | `false` = hide from the `/` menu. For background knowledge users shouldn't trigger directly |
+| `allowed-tools` | **Pre-approves** tools for the invoking turn — see the warning below |
+| `disallowed-tools` | Removes tools from Claude's pool while the skill is active. *This* is the restricting field |
+| `paths` | Globs that limit auto-activation to matching files — e.g. only load a Terraform skill when touching `**/*.tf` |
+| `model` / `effort` | Override model or [effort level](reference/effort-levels.md) while the skill is active; reverts on your next prompt |
+| `context: fork` | Run the skill in its own subagent context (pair with `agent:` to pick the type, `background: false` to wait for the result) |
+| `argument-hint` / `arguments` | Autocomplete hint, and named positional args for `$name` substitution in the body |
+| `hooks` | Hooks scoped to this skill's lifecycle |
+
+> ⚠️ **`allowed-tools` grants, it does not restrict.** It lets Claude use the listed tools **without asking you** during the turn that invokes the skill. Every other tool stays callable under your normal permission settings — this field never sandboxes anything. To actually remove tools, use `disallowed-tools`.
+>
+> For project skills in `.claude/skills/`, `allowed-tools` takes effect once you accept the workspace trust dialog. **A skill can grant itself broad tool access, so read project skills before trusting a repository.**
+
+> ⚠️ **`name` is not the command.** In a project or personal skill, the command comes from the **directory name** (`.claude/skills/deploy/SKILL.md` → `/deploy`) and frontmatter `name` only sets the display label in listings. Only in *plugin* skills does `name` set the last command segment.
+
+> ℹ️ Skill content is loaded **once** — the rendered `SKILL.md` enters the conversation as a single message and stays for the session. Claude does not re-read the file on later turns, so write standing instructions rather than one-time steps. The `allowed-tools` grant, by contrast, clears on your next message.
+
---
[← Back to README](../README.md#claude-skills) · [Hooks](../README.md#hooks) · [MCP](../README.md#model-context-protocol-mcp)