$npx -y skills add Jeffallan/claude-skills --skill code-documenterGenerates, formats, and validates technical documentation — including docstrings, OpenAPI/Swagger specs, JSDoc annotations, doc portals, and user guides. Use when adding docstrings to functions or classes, creating API documentation, building documentation sites, or writing tutor
| 1 | # Code Documenter |
| 2 | |
| 3 | Documentation specialist for inline documentation, API specs, documentation sites, and developer guides. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Applies to any task involving code documentation, API specs, or developer-facing guides. See the reference table below for specific sub-topics. |
| 8 | |
| 9 | ## Core Workflow |
| 10 | |
| 11 | 1. **Discover** - Ask for format preference and exclusions |
| 12 | 2. **Detect** - Identify language and framework |
| 13 | 3. **Analyze** - Find undocumented code |
| 14 | 4. **Document** - Apply consistent format |
| 15 | 5. **Validate** - Test all code examples compile/run: |
| 16 | - Python: `python -m doctest file.py` for doctest blocks; `pytest --doctest-modules` for module-wide checks |
| 17 | - TypeScript/JavaScript: `tsc --noEmit` to confirm typed examples compile |
| 18 | - OpenAPI: validate spec with `npx @redocly/cli lint openapi.yaml` |
| 19 | - If validation fails: fix examples and re-validate before proceeding to the Report step |
| 20 | 6. **Report** - Generate coverage summary |
| 21 | |
| 22 | ## Quick-Reference Examples |
| 23 | |
| 24 | ### Google-style Docstring (Python) |
| 25 | ```python |
| 26 | def fetch_user(user_id: int, active_only: bool = True) -> dict: |
| 27 | """Fetch a single user record by ID. |
| 28 | |
| 29 | Args: |
| 30 | user_id: Unique identifier for the user. |
| 31 | active_only: When True, raise an error for inactive users. |
| 32 | |
| 33 | Returns: |
| 34 | A dict containing user fields (id, name, email, created_at). |
| 35 | |
| 36 | Raises: |
| 37 | ValueError: If user_id is not a positive integer. |
| 38 | UserNotFoundError: If no matching user exists. |
| 39 | """ |
| 40 | ``` |
| 41 | |
| 42 | ### NumPy-style Docstring (Python) |
| 43 | ```python |
| 44 | def compute_similarity(vec_a: np.ndarray, vec_b: np.ndarray) -> float: |
| 45 | """Compute cosine similarity between two vectors. |
| 46 | |
| 47 | Parameters |
| 48 | ---------- |
| 49 | vec_a : np.ndarray |
| 50 | First input vector, shape (n,). |
| 51 | vec_b : np.ndarray |
| 52 | Second input vector, shape (n,). |
| 53 | |
| 54 | Returns |
| 55 | ------- |
| 56 | float |
| 57 | Cosine similarity in the range [-1, 1]. |
| 58 | |
| 59 | Raises |
| 60 | ------ |
| 61 | ValueError |
| 62 | If vectors have different lengths. |
| 63 | """ |
| 64 | ``` |
| 65 | |
| 66 | ### JSDoc (TypeScript) |
| 67 | ```typescript |
| 68 | /** |
| 69 | * Fetches a paginated list of products from the catalog. |
| 70 | * |
| 71 | * @param {string} categoryId - The category to filter by. |
| 72 | * @param {number} [page=1] - Page number (1-indexed). |
| 73 | * @param {number} [limit=20] - Maximum items per page. |
| 74 | * @returns {Promise<ProductPage>} Resolves to a page of product records. |
| 75 | * @throws {NotFoundError} If the category does not exist. |
| 76 | * |
| 77 | * @example |
| 78 | * const page = await fetchProducts('electronics', 2, 10); |
| 79 | * console.log(page.items); |
| 80 | */ |
| 81 | async function fetchProducts( |
| 82 | categoryId: string, |
| 83 | page = 1, |
| 84 | limit = 20 |
| 85 | ): Promise<ProductPage> { ... } |
| 86 | ``` |
| 87 | |
| 88 | ## Reference Guide |
| 89 | |
| 90 | Load detailed guidance based on context: |
| 91 | |
| 92 | | Topic | Reference | Load When | |
| 93 | |-------|-----------|-----------| |
| 94 | | Python Docstrings | `references/python-docstrings.md` | Google, NumPy, Sphinx styles | |
| 95 | | TypeScript JSDoc | `references/typescript-jsdoc.md` | JSDoc patterns, TypeScript | |
| 96 | | FastAPI/Django API | `references/api-docs-fastapi-django.md` | Python API documentation | |
| 97 | | NestJS/Express API | `references/api-docs-nestjs-express.md` | Node.js API documentation | |
| 98 | | Coverage Reports | `references/coverage-reports.md` | Generating documentation reports | |
| 99 | | Documentation Systems | `references/documentation-systems.md` | Doc sites, static generators, search, testing | |
| 100 | | Interactive API Docs | `references/interactive-api-docs.md` | OpenAPI 3.1, portals, GraphQL, WebSocket, gRPC, SDKs | |
| 101 | | User Guides & Tutorials | `references/user-guides-tutorials.md` | Getting started, tutorials, troubleshooting, FAQs | |
| 102 | |
| 103 | ## Constraints |
| 104 | |
| 105 | ### MUST DO |
| 106 | - Ask for format preference before starting |
| 107 | - Detect framework for correct API doc strategy |
| 108 | - Document all public functions/classes |
| 109 | - Include parameter types and descriptions |
| 110 | - Document exceptions/errors |
| 111 | - Test code examples in documentation |
| 112 | - Generate coverage report |
| 113 | |
| 114 | ### MUST NOT DO |
| 115 | - Assume docstring format without asking |
| 116 | - Apply wrong API doc strategy for framework |
| 117 | - Write inaccurate or untested documentation |
| 118 | - Skip error documentation |
| 119 | - Document obvious getters/setters verbosely |
| 120 | - Create documentation that's hard to maintain |
| 121 | |
| 122 | ## Output Formats |
| 123 | |
| 124 | Depending on the task, provide: |
| 125 | 1. **Code Documentation:** Documented files + coverage report |
| 126 | 2. **API |