一键导入
docs
Add or improve documentation for code. Use when code needs JSDoc comments, inline explanations, README files, or documentation updates.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add or improve documentation for code. Use when code needs JSDoc comments, inline explanations, README files, or documentation updates.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
End-of-session routine. Ensures test coverage, performs self-review, runs validation, and commits cleanly. Use when finishing a unit of work.
Full feature implementation workflow with explore, plan, code, test, validate, and commit phases. Use for new features, enhancements, or significant code changes.
Iterate on an open PR until CI passes and all review feedback is addressed. Fetches status, categorizes findings by severity, applies fixes, and loops until clean.
Create a detailed implementation plan without writing code. Read-only analysis and planning with user approval gate. Use before implementing features or making significant changes.
Systematic security audit with confidence-based reporting. Analyzes attack surfaces, checks against OWASP categories, and reports only confirmed or likely vulnerabilities. Use for pre-merge security review or periodic audits.
Run validation checks to ensure code quality, security, and correctness. Supports quick (scoped), full (CI pipeline), fix (auto-correct), and CI mirror modes.
| name | docs |
| description | Add or improve documentation for code. Use when code needs JSDoc comments, inline explanations, README files, or documentation updates. |
| category | meta |
| triggers | ["add documentation","needs docs","document this","JSDoc","README"] |
Purpose: Add or improve documentation for code Usage:
/docs [scope flags] <description>
Note: Command examples use
npmas default. Adapt to the project's package manager perai-assistant-protocol— Project Commands.
/test-coverage/explore/adr/add-todo/init| Flag | Description |
|---|---|
--files=<paths> | Document only specified files/directories |
Examples:
/docs --files=src/utils/ # Document all utils
/docs --files=src/api/client.ts # Document specific file
/docs add JSDoc to exported functions
Determine what needs documentation:
# Find files without JSDoc comments
# Look for exported functions/classes
# Check for missing README files
find . -type d -name "src" -exec test ! -f {}/README.md \; -print
Target areas:
If all exported functions, classes, and interfaces already have complete, accurate JSDoc: Report "Documentation is complete — no changes needed" and exit.
Before documenting, understand:
Read the implementation and any existing tests to understand behavior.
Finding test files: Look for tests in common locations:
__tests__/ directory adjacent to the source file.spec.ts or .test.ts suffix next to the source filetests/ directory at the project rootFor Functions (JSDoc):
/**
* Brief description of what the function does.
*
* @param paramName - Description of the parameter
* @returns Description of the return value
* @throws {ErrorType} Description of when this error is thrown
*
* @example
* ```typescript
* const result = functionName(input);
* ```
*/
export function functionName(paramName: Type): ReturnType {
// ...
}
For Classes:
/**
* Brief description of the class purpose.
*
* @example
* ```typescript
* const instance = new ClassName(config);
* instance.method();
* ```
*/
export class ClassName {
// ...
}
For Interfaces and Type Aliases:
/**
* Brief description of the interface purpose.
* Explain when this type is used and any important constraints.
*
* @example
* ```typescript
* const config: InterfaceName = { key: 'value' };
* ```
*/
export interface InterfaceName {
/** Description of this property */
propertyName: Type;
}
For Complex Logic (Inline Comments):
// Explain WHY, not WHAT
// Good: "Skip validation for internal calls to avoid circular dependency"
// Bad: "Check if internal is true"
if (isInternal) {
return data;
}
For Modules/Packages (README.md):
# Module Name
Brief description of module purpose.
## Usage
\`\`\`typescript
import { something } from './module';
\`\`\`
## API
### `functionName(param)`
Description of the function.
Do:
Don't:
Present a summary of planned documentation changes before applying:
## Planned Documentation Changes
| File | Change |
|------|--------|
| `src/services/payment.service.ts` | Add JSDoc to `processPayment()`, `getPaymentStatus()` |
| `src/services/payment.service.ts` | Update stale JSDoc on `refundPayment()` |
| `src/services/payment.service.ts` | Add interface docs for `PaymentConfig` |
**Apply these changes?** (yes / edit / cancel)
GATE: User must approve documentation plan before changes are applied.
After adding documentation:
npm run typecheck
Present the documentation report using the Output Format defined below. Include what was added, updated, and skipped.
Report what was documented:
## Documentation Report
### Files Updated
- `src/utils/parser.ts` - Added JSDoc to 3 functions
- `src/services/api.ts` - Added module description
- `src/components/README.md` - Created package README
### Documentation Added
- `parseConfig()` - Function description, params, return, example
- `ApiService` - Class description, usage example
- `src/components/` - README with usage and API docs
### Notes
- `legacyHandler()` - Skipped, marked for deprecation
- Consider adding architecture docs for data flow
| Tag | Purpose | Example |
|---|---|---|
@param | Parameter description | @param name - User's display name |
@returns | Return value | @returns The parsed configuration |
@throws | Exceptions | @throws {Error} If config is invalid |
@example | Usage example | See code block examples above |
@deprecated | Mark as deprecated | @deprecated Use newFunction instead |
@see | Reference related | @see parseConfig |
| ID | Type | Prompt / Condition | Expected |
|---|---|---|---|
| DOC-T1 | Positive | "Add JSDoc to this file" | Skill triggers |
| DOC-T2 | Positive | "Document the public API" | Skill triggers |
| DOC-T3 | Positive | "This module needs a README" | Skill triggers |
| DOC-T4 | Negative | "Add tests for this code" | Does NOT trigger (-> /test-coverage) |
| DOC-T5 | Negative | "How does this work?" | Does NOT trigger (-> /explore) |
| DOC-T6 | Negative | "Record why we chose this approach" | Does NOT trigger (-> /adr) |
| DOC-T7 | Boundary | "Explain this function" | Context-dependent — if user wants docs added, trigger; if exploring to understand, route to /explore |
| DOC-T8 | Positive | /docs --files=src/services/payment.service.ts | Skill triggers, scopes to the specified file |
| DOC-T9 | Positive | "Update the stale JSDoc on this function" | Skill triggers — stale doc update is in scope |
| DOC-T10 | Positive | "Document this interface" | Skill triggers — interface documentation is in scope |
| DOC-T11 | Negative | "Document this private helper" | Does NOT document — private/non-exported helpers are out of scope |
| DOC-T12 | Boundary | "Add @throws tags to error-throwing functions" | Skill triggers — @throws documentation is in scope |
| DOC-T13 | Early-exit | All exports already have complete JSDoc | Reports "Documentation is complete — no changes needed" and exits |