Custom commands and skills in Claude Code
PLCustom commands in Claude Code are packaged as Agent Skills under .claude/skills/<name>/SKILL.md (with legacy .claude/commands/<name>.md files still supported). Each skill becomes a shared /<name> workflow with structured frontmatter, invocation controls, supporting scripts, and optional subagent isolation—turning ad-hoc personal prompts into versioned, verifiable team standards.
One engineer’s pre-PR checklist catches missing tests and unparameterised queries, while teammates run different prompts and catch those defects only during human review. This guide is for developers tired of pasting the same procedures into chat and tech leads standardising repeatable workflows across an entire repository.
Skills versus legacy command files
Section titled “Skills versus legacy command files”Author every new workflow as a skill under .claude/skills/<name>/SKILL.md. Skills follow the open Agent Skills standard (also catalogued at skills.wondel.ai) so the core instruction body transfers across Claude Code, Codex, and Cursor while supporting Claude-specific extensions such as invocation guards, inline command injection, and forked subagent execution.
| Capability | Legacy .claude/commands/<name>.md | Skill .claude/skills/<name>/SKILL.md |
|---|---|---|
| Invocation | /<name> (subfolders add : prefixes) | /<name> or frontmatter name |
| Supporting files (scripts, templates, refs) | No | Yes, alongside SKILL.md |
| Name collision outcome | Overridden by skill | Takes precedence |
| Cross-agent portability | Claude Code only | Open SKILL.md standard (drop Claude-only fields when porting) |
Skills conserve context budget: only each skill’s short description sits in context until invoked, at which point the full body enters the conversation. Write terse standing instructions rather than narrative prose, because every line stays in context across subsequent turns.
Scopes and precedence rules
Section titled “Scopes and precedence rules”Commit team workflows to .claude/skills/ inside the repository; package cross-repository commands as a namespaced team plugin (plugins ecosystem).
| Scope | Path | Active in |
|---|---|---|
| Managed (enterprise) | Managed settings skills directory | Every user on organization-managed machines |
| Personal | ~/.claude/skills/<name>/SKILL.md | Local projects on your machine (not cloud or remote runs) |
| Project | .claude/skills/<name>/SKILL.md | Everyone who clones this repository |
| Nested | <subdir>/.claude/skills/<name>/SKILL.md | Sessions started in or touching <subdir> |
| Plugin | <plugin>/skills/<name>/SKILL.md | Enabled repos, namespaced as /<plugin>:<name> |
Three precedence invariants prevent silent shadowing:
- Enterprise beats personal, and personal beats project. A local
~/.claude/skills/deploy/silently shadows the team’s.claude/skills/deploy/on your machine alone. - Avoid built-in aliases such as
/review. A project skill cannot hijack the built-in/reviewalias for/code-review; name team review workflows distinctly (for example/pre-pror/team-review). - Plugin skills never collide because their plugin prefix namespaces them automatically.
Designing an evidence-producing skill
Section titled “Designing an evidence-producing skill”A high-leverage team command runs real repository gates and outputs a fixed evidence structure rather than open-ended commentary.
-
Create
.claude/skills/pre-pr/SKILL.mdand align the gate commands with your repository scripts:---description: Run repository merge gates on the current branch and report a structured readiness verdict. Use before opening a pull request.disable-model-invocation: trueallowed-tools: Bash(git diff *) Bash(npm run *)---## Changed files!`git diff --stat origin/main...HEAD`## Standing instructions1. Run `npm run typecheck`, `npm run lint`, and `npm run test` in order. Record exact commands and exit codes.2. On failure, print the first failing file and line. Do not edit source code.3. For every modified file under `src/`, identify the covering test or flag the file as untested.4. Reply strictly in this format:VERDICT: READY | BLOCKED| Gate | Command | Exit code |Untested files: <list or "none">Review first: up to three file:line locations with one reason each -
Parameterise repeatable workflows with named arguments. Use
$ARGUMENTSor explicitargumentswithargument-hint(for example/fix-issue 482) so teammates see expected inputs in autocomplete. -
Commit the skill and protect
.claude/inCODEOWNERS. Because skills shape agent behaviour and can pre-approve tool rules across every developer machine, review skill edits with the same scrutiny as CI workflows.
Invocation boundaries, permissions, and forked execution
Section titled “Invocation boundaries, permissions, and forked execution”Three frontmatter controls govern safety and context hygiene. Consult the official Claude Code documentation for the complete frontmatter schema and shell-injection settings.
| Frontmatter setting | User invokes | Claude auto-invokes | Best fit |
|---|---|---|---|
| Default | Yes | Yes | Safe, read-only checklists and reusable reference steps |
disable-model-invocation: true | Yes | No | Anything with side effects: commits, pushes, deploys, messages, /pre-pr |
user-invocable: false | No | Yes | Background domain guidance loaded only when relevant |
Understand two critical security and context mechanics before shipping skills to a team:
allowed-toolsgrants permissions rather than restricting them. Listing tools inallowed-toolspre-approves them for that invocation turn while leaving all other tools governed by normal policy—and project skill grants can apply even in non-interactive runs without a workspace trust prompt. Usedisallowed-toolsorpermissions.denyto restrict capabilities, review.claude/skills/before running Claude on untrusted repos, and enforcedisableSkillShellExecutionin managed settings when shell injection (!`command`) must be disabled org-wide.- Offload heavy inspection with
context: fork. When a command sweeps dozens of files (such as finding every call site of a public API before refactoring), addcontext: forkandagent: Exploreso the skill runs inside an isolated read-only subagent and returns only a concise summary instead of filling your main session (custom subagents).
Proving a skill actually works
Section titled “Proving a skill actually works”Seeing a slash command print text proves only that the file loaded. Verify skills across four objective gates:
- Automated frontmatter validation in CI. Claude Code silently ignores misspelt frontmatter keys or malformed YAML—meaning a typo in
disable-model-invocationquietly lets Claude auto-trigger a deploy skill. Run a zero-secret CI script on every PR touching.claude/that checks opening---on line 1, valid YAML parsing, requireddescription, and known schema keys, and runnpx @wondelai/harness-auditto audit skill hygiene alongside hooks and memory (Harness Audit). Protect both.claude/and.github/underCODEOWNERS. - Fresh-session A/B evaluation. Test three realistic requests in clean sessions with the skill enabled versus disabled (or run automated trigger/output evals when shipping plugin skills). Writing and testing in the same session hides instruction gaps.
- Structured, re-runnable output. Require a fixed verdict and command/exit-code table so reviewers can verify claims in seconds rather than reading transcripts.
- Context-budget pruning. Audit skill token overhead and actual usage periodically (via Claude Code’s built-in skill diagnostics) and remove unused skills whose descriptions tax every turn.
When custom commands and skills misbehave
Section titled “When custom commands and skills misbehave”| Symptom | Likely cause | Recovery |
|---|---|---|
/name missing from menu | Skill lives in an unvisited nested directory or .claude/skills/ was created mid-session | Reload skills or restart the session; inspect loaded skills via /skills |
| Frontmatter guard has no effect | Opening --- is not on line 1, YAML failed to parse, or a key is misspelt | Run your CI frontmatter linter and launch with --debug to view parse errors |
Teammate gets different behaviour for the same /name | A personal copy in ~/.claude/skills/ shadows the committed project skill | Delete or rename the personal skill; personal scope outranks project scope |
/review ignores a custom team command | /review is reserved as an alias for built-in /code-review | Rename the team skill distinctly (for example /team-review or /pre-pr) |
| Shell injection aborts the command | An inline !`command` exited non-zero or hit a permission rule | Handle expected non-zero exits explicitly or pre-approve the safe command in allowed-tools |
| Skill influence fades in long sessions | Compaction truncates re-attached skill bodies | Keep skill bodies concise, re-invoke when needed, and move hard invariants into hooks |
| Claude stops auto-selecting the right skill | Too many installed skills exceed the description listing budget | Put the trigger condition first in description and disable unused skills |
Official docs and next steps
Section titled “Official docs and next steps”Refer to the official Claude Code documentation for exact frontmatter fields, plugin evaluation commands, and built-in skills, and browse the open standard at Agent Skills and skills.wondel.ai.
- Custom subagents: define dedicated read-only or worktree-isolated specialists for
context: forkskills. - Hooks automation: enforce non-negotiable rules deterministically instead of relying on skill instructions.
- Memory system: decide what belongs in
CLAUDE.mdversus an on-demand skill. - Skills ecosystem: security, supply-chain review, and cross-tool portability across Claude Code, Codex, and Cursor.
Did this guide help you?
One tap, no sign-in.
What will you do with it?
How did it read?
What got in the way? Pick any that apply
Your role?
Thanks. I read every answer. Michał Jaskólski
Did this guide help?
One tap each. Close whenever you like.
no sign-in