Skip to content
Development
Command

/xdocs

Generate and maintain comprehensive documentation from code

From plugin
claude-code
11045 skills45 commands29 hooks

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/xdocs

Context preview

What this command does when you run it.

Generate and maintain comprehensive documentation from code

Command definition

xdocs.md
description: Generate and maintain comprehensive documentation from code
tags: [documentation, generation, maintenance]

Generate and maintain documentation from code, keeping it in sync with implementation.

Usage Examples

**Basic documentation generation:**

/xdocs

**Generate API documentation:**

/xdocs --api

**Check documentation coverage:**

/xdocs --check

**Generate README:**

/xdocs --readme

**Help and options:**

/xdocs --help

Implementation

If $ARGUMENTS contains "help" or "--help": Display this usage information and exit.

Parse documentation options from $ARGUMENTS (--generate, --api, --readme, --check, or specific module/file).

1. Analyze Current Documentation

Check existing documentation: !find . -name "*.md" | grep -v node_modules | head -20 !test -f README.md && echo "README exists" || echo "No README.md found" !find . -name "*.py" -exec grep -l '"""' {} \; | wc -l

2. Generate Documentation

Based on the arguments and project type, generate appropriate documentation.

For Python projects, extract docstrings: !python -c "import ast; import os; [print(f'{f}: {len([n for n in ast.walk(ast.parse(open(f).read())) if isinstance(n, ast.FunctionDef) and ast.get_docstring(n)])} documented functions') for f in os.listdir('.') if f.endswith('.py')]" 2>/dev/null

For JavaScript/TypeScript projects: !grep -E "^(export |const |function |class )" *.js *.ts 2>/dev/null | head -20

3. API Documentation

If --api flag is present, analyze API endpoints: !grep -r -E "@(app|router)\.(get|post|put|delete|patch)" . --include="*.py" 2>/dev/null | head -20 !grep -r -E "(app|router)\.(get|post|put|delete|patch)" . --include="*.js" 2>/dev/null | head -20

4. Check Documentation Coverage

Count undocumented functions: !find . -name "*.py" -exec grep -E "^def |^class " {} \; | wc -l !find . -name "*.py" -exec grep -A1 -E "^def |^class " {} \; | grep '"""' | wc -l

Think step by step about documentation needs and:

1. Identify what documentation is missing 2. Generate appropriate documentation based on code analysis 3. Create templates for missing documentation 4. Ensure examples are included where helpful

Generate documentation in this format:

For README.md:

# Project Name

Brief description of what this project does.

## Installation

```bash
# Installation commands based on package.json or requirements.txt

Usage

# Example usage based on main entry points

API Reference

[Function/Class Name]

[Description from docstring or inferred from code]

**Parameters:**

  • `param_name` (type): Description

**Returns:**

  • type: Description

**Example:**

# Example usage

Contributing

See CONTRIBUTING.md for details.

License

[License information]


For API documentation:
```markdown
# API Documentation

## Endpoints

### GET /endpoint
Description of what this endpoint does.

**Parameters:**
- `param` (query/path/body): Description

**Response:**
```json
{
  "field": "example"
}

**Example:**

curl -X GET http://localhost:8000/endpoint

If --check flag is present, generate a documentation coverage report:

๐Ÿ“š DOCUMENTATION COVERAGE REPORT โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” Overall Coverage: X%

โœ… DOCUMENTED (X/Y) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โœ“ module.py: X/Y functions โœ“ api.py: X/Y endpoints

โŒ MISSING DOCUMENTATION (X/Y) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โœ— utils.py: functionName (line X) โœ— models.py: ClassName (line X)

๐Ÿ”ง QUICK FIXES โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 1. Add docstring to functionName in utils.py 2. Document ClassName in models.py 3. Create API documentation for /endpoint

๐Ÿ“ TEMPLATES TO ADD โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

  • README.md sections: Usage, Examples
  • API.md: Missing endpoint documentation
  • CONTRIBUTING.md: Development setup

If --generate flag with specific file, create documentation for that file.
If --update flag, update existing documentation to match code changes.
Read more
Ships withclaude-code

Transform Claude Code into a complete development platform with 45 AI-powered commands that automate your entire software development workflow. Now with improved git identity management!

Get the whole plugin

Other commands on claude-code.