| name | house-style-documentation |
| description | Consistently and thoroughly document TypeScript/Node code following the project's "house style". Use this skill whenever documenting, refactoring, or creating new TypeScript modules to ensure they meet the specific JSDoc, method, and naming standards. Also use this skill whenever drafting or reviewing an implementation plan to ensure it adheres to the project structure. |
| triggers | implementation plan, drafting plan, documentation, refactoring, TypeScript modules, review-ip, ip-review |
House Style Documentation
Enforce a specific set of documentation and style standards for TypeScript files in this repository.
High-Level Standards
- Module Headers: Every file must have a brief JSDoc header describing its purpose.
- Function/Method Documentation: All exported functions, methods, and classes must have JSDoc-style comments.
- Variable/Constant Documentation: Important configuration or global objects should be documented with JSDoc or clear block comments.
- Error Handling: Utilize Custom Error classes (e.g.,
PlatformIOError) extending from the base error structure, instead of throwing raw Error objects where appropriate.
- Naming Conventions: File names MUST strictly use
kebab-case. Types, Interfaces, Classes, and Zod schemas MUST be PascalCase. Variables and functions MUST be camelCase.
- Formatting/Linting: The codebase utilizes ESLint, Prettier, and stricter TypeScript configurations (
strict: true, noUnusedLocals, etc.). Ensure code is clean and handles types properly. Zod is used for parsing JSON data.
- Implementation Plans: All implementation plans must be reviewed for house style (Goal, Review Required, Proposed Changes, Verification).
1. Module Headers
Every TypeScript file MUST start with a brief JSDoc header describing the module's overall responsibility. Do not include large proprietary or C++ style copyright blocks, but DO include a one-line summary of the functions and constants that the module provides.
Format:
[!IMPORTANT]
While TypeScript handles exports implicitly, providing this one-line summary list in the header allows developers to quickly see the services offered by the module without reading the whole file.
2. Function, Class, and Method Documentation
Use standard JSDoc comment blocks for all exported declarations, classes, schemas, and complex internal functions.
Format:
export async function executeTask(config: TaskConfig): Promise<Result> {
}
3. Scoped Variables and Constants
For important constants, types, schemas, or variables defined at the module scope, add a short JSDoc or inline comment.
Example:
const DEFAULT_TIMEOUT = 300000;
---
## 4. Type and Interface Properties
For properties within exported interfaces or type aliases, prefer using single-line trailing `//` comments instead of multiline JSDoc blocks. This keeps complex data shapes compact and easy to scan. The main interface or type declaration should still use a JSDoc block.
### Example:
```typescript
/**
* Detailed specification parameters for a single PlatformIO development board.
*/
export interface BoardInfo {
id: string;
name: string;
platform: string;
mcu: string;
frequency?: string;
}
5. Error Handling Style
This library wraps operations that may fail (like CLI commands). Ensure errors are handled explicitly, and use the custom error hierarchy (e.g., PlatformIOError, PlatformIONotInstalledError) defined in src/utils/errors.ts.
Example:
if (!result.success) {
throw new PlatformIOError(
`Command failed: ${result.message}`,
'COMMAND_FAILED',
{ detail: result }
);
}
5. Naming Conventions
All file names and code symbols MUST follow standard TypeScript conventions.
Requirements:
- File Names: Use strictly
kebab-case.ts (e.g., board-manager.ts).
- Types, Interfaces, Classes, Schemas: Use
PascalCase (e.g., PlatformIOExecutor, BoardInfo, GetBoardInfoParamsSchema).
- Functions, Methods, Variables: Use
camelCase (e.g., getBoardInfo, listBoards).
- Global / Module-Scoped Constants: Use
UPPER_SNAKE_CASE for immutable static data (e.g., DEFAULT_TIMEOUT, LOG_DIR).
6. Implementation Plans
Whenever an implementation plan is produced, it MUST be reviewed and updated to adhere to the project's house style.
Structure:
- Goal Description: Clear, concise explanation of the objective.
- User Review Required: Highlight critical decisions or breaking changes using GitHub alerts.
- Proposed Changes: Grouped by component, using
[MODIFY], [NEW], and [DELETE] tags with repository-relative file links (e.g., [file.ts](src/tools/file.ts)). Absolute paths to the project directory are FORBIDDEN.
- Verification Plan: Practical steps for automated and manual verification.
Workflow
- Read the target file OR implementation plan.
- Identity missing or substandard documentation/content based on the rules above.
- Ensure the file name and module naming follow the TypeScript naming conventions.
- For implementation plans, ensure all standard sections are present and correctly formatted.
- Regenerate the content with the improved house style.
- Ensure existing logic or plan details are PRESERVED exactly; only formatting and clarity should change.