Revise existing project documentation to reflect the current state of the codebase. The user may provide an optional scope argument: $ARGUMENTS
Determine scope:
- •If a path argument is provided (e.g.
docs/api.md), revise only that file. - •If a component name is provided (e.g.
api,auth), revisedocs/<name>.md. - •If no argument is provided, revise ALL files in
docs/.
For each documentation file in scope, follow these steps:
- •
Read the existing documentation file and understand what is currently documented.
- •
Read the actual source files that the doc describes — compare documented behavior against the real code to find discrepancies.
- •
Check recent changes — run
git log --oneline -30 -- <relevant source paths>to see what has changed since the docs were last updated. Also rungit log --oneline -5 -- <doc file>to see when the doc itself was last modified. - •
Identify discrepancies and gaps:
- •Stale content — APIs, functions, classes, or behaviors documented but no longer present in the code
- •Undocumented additions — new modules, endpoints, functions, or features added to the code but not yet in the docs
- •Incorrect descriptions — behavior that has changed since the doc was written
- •Missing context — new design decisions or rationale that should be added
- •Broken references — file paths, line numbers, or links that no longer point to the right place
- •New components — entirely new modules or subsystems that need their own doc file
- •
Update the documentation:
- •Remove references to deleted/removed code
- •Add documentation for new APIs, modules, features, or configuration
- •Correct any inaccurate descriptions or examples
- •Update file structure sections if files were added, removed, or renamed
- •Update dependency lists if new libraries or services were added
- •Refresh code snippets if the actual implementation has changed
- •Update API/interface tables to match the current signatures
- •
Update
docs/README.mdif the revision scope includes it or if component docs were added/removed:- •Ensure the index links are correct and complete
- •Update component descriptions if their scope changed
- •Update setup/build/test instructions if they changed
- •
Delete obsolete docs — if a component was entirely removed from the project, delete its documentation file and remove it from the index.
- •
Create missing docs — if you discover a component that exists in the code but has no documentation file at all, create one following the same structure as
docs-init. - •
Format with Prettier — after modifying each markdown file, run
npx prettier --write <file>. - •
Print a revision summary at the end:
- •Files updated (with a brief list of what changed in each)
- •Files created (new docs for previously undocumented components)
- •Files deleted (docs for removed components)
- •Items that could not be automatically resolved (ambiguities, questions for the user)