/docs is not documented as a built-in Claude Code command. This entry is a
custom command recipe: create a Markdown file in .claude/commands/, and Claude
Code exposes it as /docs because the command name comes from the filename.
Use this recipe when you repeatedly ask Claude to draft README sections, API
notes, usage examples, contributor docs, or source-grounded explanations and you
want that workflow to be consistent.
Create the command
Create .claude/commands/docs.md:
---
description: Draft source-grounded project documentation for a file, package, feature, or docs gap
argument-hint: [file-or-topic]
---
Draft documentation for $ARGUMENTS.
Before writing, inspect the relevant source files, existing docs, package
metadata, tests, and examples. Then produce:
1. The concrete behavior supported by the source.
2. Any prerequisites, environment variables, flags, or limits that are actually
present in the project.
3. A concise draft in the repository's existing docs style.
4. Copy/paste-ready examples that use real names from the codebase.
5. A verification checklist listing the files or commands used to confirm the
documentation.
Do not invent options, endpoint fields, CLI flags, output formats, diagrams, or
support claims that are not visible in the source or cited docs.
Usage
/docs src/api/users.ts
/docs "document the package installation flow in packages/registry"
/docs README.md -- refresh quickstart from the current package scripts
Text after /docs is normal prompt input, not a CLI option parser. There are no
source-backed built-in flags such as --api, --pdf, --interactive, or
--confluence; ask for those focuses in plain language only when the repository
already supports them.
Suggested workflow
- Ground the target. Point the command at a real file, package, existing
doc, or issue.
- Read before writing. Have Claude inspect source, tests, package scripts,
schemas, and nearby docs before drafting prose.
- Match the repository. Reuse existing headings, tone, command examples,
and terminology.
- Separate facts from guesses. Ask the command to list unsupported or
uncertain claims instead of filling gaps with invented behavior.
- Verify examples. Run or inspect any command/API examples before merging
the generated docs.
Source Verification Notes
Verified on 2026-06-19:
- Claude Code's skills documentation says existing
.claude/commands/*.md files
still create slash invocations based on filename, while skills are the newer
recommended form.
- Claude Code's commands reference explains that slash commands take text after
the command name as arguments.
- This page packages those documented mechanics into a user-authored
/docs
recipe. It does not claim an official built-in /docs generator command.
Duplicate Check
/generate-tests and /test-advanced focus on automated test drafting.
/docs focuses on source-grounded documentation prose, examples, and
verification notes.
Troubleshooting
- If the draft invents behavior, rerun with: "List only claims supported by the
source files you inspected."
- If examples are generic, point the command at a real test, route, config file,
or package script.
- If API docs are needed, verify the project already exposes an OpenAPI schema,
route map, or typed client before asking for endpoint tables.