Reverse Documentation Skill
Automatically generate comprehensive documentation for Rust and TypeScript codebases by analyzing existing code structure, patterns, and relationships.
When to use
Use this skill when you need to:
- Generate comprehensive API documentation for Rust crates
- Document React components and custom hooks
- Create architecture documentation from code analysis
- Generate migration guides for API changes
- Create README and implementation guides
- Document design patterns and relationships
- Build code examples and tutorials
- Cross-reference related functionality
Core concepts
Rust Documentation
This skill understands and documents:
- Module Organization: Workspace structure, crate dependencies, feature flags
- Types & Traits: Struct, enum, and trait definitions with full type signatures
- Error Handling: Result types, custom error types, error propagation patterns
- Async Patterns: Tokio-based async functions, futures, task spawning
- Generic Types: Type parameters, bounds, and lifetime annotations
- Implementation Details: Methods, associated functions, trait implementations
- Testing: Unit tests, integration tests, documentation examples
TypeScript Documentation
This skill understands and documents:
- Module Structure: Exports, re-exports, and module dependencies
- Type Definitions: Interfaces, types, generics, and utility types
- React Components: Functional components, props, state, lifecycle
- Custom Hooks: Hook composition, state management, side effects
- API Integration: Data fetching, request/response types, error handling
- State Patterns: useState, useReducer, Context API, state management libraries
- Next.js Patterns: Pages, layouts, API routes, middleware, server components
Quick start
For Rust codebases
Generate comprehensive documentation for the [crate-name] crate
Document the trait-based storage abstraction in edgequake-storage
Create API documentation for all public interfaces with examples
For TypeScript codebases
Generate documentation for all React components in src/components
Document the custom hooks in src/hooks with usage examples
Create type documentation for the API integration layer
Capabilities
Rust Capabilities
1. Crate Documentation
- Analyze Cargo.toml and workspace structure
- Extract and document all public types, traits, and functions
- Generate comprehensive README files
- Create architecture diagrams of trait relationships
- Document feature flags and optional dependencies
2. API Reference Generation
- Extract function signatures with parameters and return types
- Document error types and handling patterns
- Include working code examples
- Show generic type usage
- Cross-reference related types
3. Pattern Documentation
- Identify and document design patterns (Builder, Factory, Strategy, etc.)
- Explain async/await patterns and tokio usage
- Document error handling approaches
- Show trait implementations and polymorphism
- Explain generic type usage
4. Example Generation
- Create working code examples for public APIs
- Show error handling patterns
- Demonstrate async operations
- Include edge cases and common pitfalls
TypeScript Capabilities
1. Component Documentation
- Extract component props with types and defaults
- Document component behavior and event handlers
- Generate prop combinations and variants
- Create Storybook stories
- Show component composition patterns
2. Hook Documentation
- Document hook parameters and return values
- Show hook composition patterns
- Explain dependency arrays
- Include usage examples
- Identify potential performance issues
3. Type Documentation
- Extract and document all exported types and interfaces
- Show generic type parameters
- Document utility type usage
- Create type hierarchy diagrams
- Show API request/response types
4. Architecture Documentation
- Generate data flow diagrams
- Document state management patterns
- Show API integration patterns
- Identify dependency trees
- Document component hierarchies
Workflow
When you invoke this skill, the AI assistant will:
- Discovery Phase: Scan the codebase to find files and understand structure
- Analysis Phase: Parse code to extract types, functions, patterns, and relationships
- Understanding Phase: Identify design patterns, architectural decisions, and key concepts
- Generation Phase: Create comprehensive documentation in your chosen format
- Validation Phase: Verify examples compile and documentation is complete
Output formats
Markdown Documentation
- Module-level README files
- API reference documentation
- Architecture documentation
- Migration guides
- Best practices guides
Inline Documentation
- Rust doc comments (/// and //!)
- TypeScript JSDoc comments
- Follow language conventions
- Include examples and sections
Diagrams
- Trait relationship diagrams (Mermaid)
- Component hierarchy diagrams
- Data flow diagrams
- Module dependency graphs
Storybook Stories (TypeScript)
- Component prop variations
- Interactive examples
- Usage patterns
- Edge cases
Configuration options
Customize documentation generation:
# Scope of documentation
scope: "public" # or "all" for private items too
# Output format
format: "markdown" # or "inline" or "both"
# Include sections
include_examples: true
include_tests: true # Rust only
include_diagrams: true
include_stories: true # TypeScript only
# Documentation depth
depth: "comprehensive" # or "brief" or "detailed"
# Target audience
audience: "developers" # or "maintainers" or "contributors"
Best practices
Rust Documentation
- ✅ Document all public APIs
- ✅ Include working code examples that compile
- ✅ Show error cases and how to handle them
- ✅ Explain generic type parameters and constraints
- ✅ Document async/await usage and tokio requirements
- ✅ Cross-reference related types and traits
TypeScript Documentation
- ✅ Document all component props with types
- ✅ Show component prop variations
- ✅ Explain hook return values and side effects
- ✅ Document data flow and state management
- ✅ Include usage examples with actual code
- ✅ Document performance considerations
EdgeQuake-specific patterns
Rust
- Multi-crate Workspace:
edgequake-core, edgequake-storage, edgequake-llm, edgequake-api
- Trait Abstraction:
GraphStorage, LLMProvider, StorageAdapter traits
- Error Handling: Custom
StorageError, PipelineError types
- Async Pipeline: Document the entity extraction and graph building pipeline
- Entity Normalization: Special naming conventions (e.g., "SARAH_CHEN")
TypeScript
- Next.js 15 App Router: Document pages, layouts, and API routes
- shadcn/ui Components: Document UI component composition
- Data Fetching: SWR hooks and API integration patterns
- Form Handling: react-hook-form patterns
- State Management: Workspace, query, and document state patterns
- Streaming: SSE and streaming response handling
Examples
Rust Example
Generate comprehensive documentation for the edgequake-storage crate including:
- All trait definitions and implementations
- Storage backend comparison (Memory vs PostgreSQL)
- Error handling patterns
- Async operation patterns
- Integration tests
- Architecture diagram showing trait relationships
TypeScript Example
Generate documentation for the edgequake_webui components including:
- All React components with props
- Custom hooks in src/hooks
- API integration types
- Component composition examples
- Storybook stories for all components
- Data flow diagram
Troubleshooting
Documentation not generating
- ✓ Ensure files are accessible and readable
- ✓ Check file permissions
- ✓ Verify syntax is valid
Examples don't compile (Rust)
- ✓ Test examples before including them
- ✓ Ensure all imports are present
- ✓ Verify types are correct and in scope
Missing documentation
- ✓ Check if items are public/exported
- ✓ Verify exports are in correct module
- ✓ Ensure items are accessible from public API
Related skills
- makefile-dev-workflow: Development workflow commands
- playwright-ux-ui-capture: UI screenshot capture automation
- ux-ui-analyze-single-page: Single page UX analysis
See also
1---2name: reverse-documentation3description: Automatically generate comprehensive documentation for Rust and TypeScript codebases by analyzing code structure, patterns, and relationships. Supports trait-based patterns, async operations, React components, and Next.js applications.4license: Proprietary (repository internal)5---67# Reverse Documentation Skill89Automatically generate comprehensive documentation for Rust and TypeScript codebases by analyzing existing code structure, patterns, and relationships.1011## When to use1213Use this skill when you need to:1415- Generate comprehensive API documentation for Rust crates16- Document React components and custom hooks17- Create architecture documentation from code analysis18- Generate migration guides for API changes19- Create README and implementation guides20- Document design patterns and relationships21- Build code examples and tutorials22- Cross-reference related functionality2324## Core concepts2526### Rust Documentation2728This skill understands and documents:2930- **Module Organization**: Workspace structure, crate dependencies, feature flags31- **Types & Traits**: Struct, enum, and trait definitions with full type signatures32- **Error Handling**: Result types, custom error types, error propagation patterns33- **Async Patterns**: Tokio-based async functions, futures, task spawning34- **Generic Types**: Type parameters, bounds, and lifetime annotations35- **Implementation Details**: Methods, associated functions, trait implementations36- **Testing**: Unit tests, integration tests, documentation examples3738### TypeScript Documentation3940This skill understands and documents:4142- **Module Structure**: Exports, re-exports, and module dependencies43- **Type Definitions**: Interfaces, types, generics, and utility types44- **React Components**: Functional components, props, state, lifecycle45- **Custom Hooks**: Hook composition, state management, side effects46- **API Integration**: Data fetching, request/response types, error handling47- **State Patterns**: useState, useReducer, Context API, state management libraries48- **Next.js Patterns**: Pages, layouts, API routes, middleware, server components4950## Quick start5152### For Rust codebases5354```55Generate comprehensive documentation for the [crate-name] crate56```5758```59Document the trait-based storage abstraction in edgequake-storage60```6162```63Create API documentation for all public interfaces with examples64```6566### For TypeScript codebases6768```69Generate documentation for all React components in src/components70```7172```73Document the custom hooks in src/hooks with usage examples74```7576```77Create type documentation for the API integration layer78```7980## Capabilities8182### Rust Capabilities8384#### 1. Crate Documentation85- Analyze Cargo.toml and workspace structure86- Extract and document all public types, traits, and functions87- Generate comprehensive README files88- Create architecture diagrams of trait relationships89- Document feature flags and optional dependencies9091#### 2. API Reference Generation92- Extract function signatures with parameters and return types93- Document error types and handling patterns94- Include working code examples95- Show generic type usage96- Cross-reference related types9798#### 3. Pattern Documentation99- Identify and document design patterns (Builder, Factory, Strategy, etc.)100- Explain async/await patterns and tokio usage101- Document error handling approaches102- Show trait implementations and polymorphism103- Explain generic type usage104105#### 4. Example Generation106- Create working code examples for public APIs107- Show error handling patterns108- Demonstrate async operations109- Include edge cases and common pitfalls110111### TypeScript Capabilities112113#### 1. Component Documentation114- Extract component props with types and defaults115- Document component behavior and event handlers116- Generate prop combinations and variants117- Create Storybook stories118- Show component composition patterns119120#### 2. Hook Documentation121- Document hook parameters and return values122- Show hook composition patterns123- Explain dependency arrays124- Include usage examples125- Identify potential performance issues126127#### 3. Type Documentation128- Extract and document all exported types and interfaces129- Show generic type parameters130- Document utility type usage131- Create type hierarchy diagrams132- Show API request/response types133134#### 4. Architecture Documentation135- Generate data flow diagrams136- Document state management patterns137- Show API integration patterns138- Identify dependency trees139- Document component hierarchies140141## Workflow142143When you invoke this skill, the AI assistant will:1441451. **Discovery Phase**: Scan the codebase to find files and understand structure1462. **Analysis Phase**: Parse code to extract types, functions, patterns, and relationships1473. **Understanding Phase**: Identify design patterns, architectural decisions, and key concepts1484. **Generation Phase**: Create comprehensive documentation in your chosen format1495. **Validation Phase**: Verify examples compile and documentation is complete150151## Output formats152153### Markdown Documentation154- Module-level README files155- API reference documentation156- Architecture documentation157- Migration guides158- Best practices guides159160### Inline Documentation161- Rust doc comments (/// and //!)162- TypeScript JSDoc comments163- Follow language conventions164- Include examples and sections165166### Diagrams167- Trait relationship diagrams (Mermaid)168- Component hierarchy diagrams169- Data flow diagrams170- Module dependency graphs171172### Storybook Stories (TypeScript)173- Component prop variations174- Interactive examples175- Usage patterns176- Edge cases177178## Configuration options179180Customize documentation generation:181182```yaml183# Scope of documentation184scope: "public" # or "all" for private items too185186# Output format187format: "markdown" # or "inline" or "both"188189# Include sections190include_examples: true191include_tests: true # Rust only192include_diagrams: true193include_stories: true # TypeScript only194195# Documentation depth196depth: "comprehensive" # or "brief" or "detailed"197198# Target audience199audience: "developers" # or "maintainers" or "contributors"200```201202## Best practices203204### Rust Documentation205206- ✅ Document all public APIs207- ✅ Include working code examples that compile208- ✅ Show error cases and how to handle them209- ✅ Explain generic type parameters and constraints210- ✅ Document async/await usage and tokio requirements211- ✅ Cross-reference related types and traits212213### TypeScript Documentation214215- ✅ Document all component props with types216- ✅ Show component prop variations217- ✅ Explain hook return values and side effects218- ✅ Document data flow and state management219- ✅ Include usage examples with actual code220- ✅ Document performance considerations221222## EdgeQuake-specific patterns223224### Rust225226- **Multi-crate Workspace**: `edgequake-core`, `edgequake-storage`, `edgequake-llm`, `edgequake-api`227- **Trait Abstraction**: `GraphStorage`, `LLMProvider`, `StorageAdapter` traits228- **Error Handling**: Custom `StorageError`, `PipelineError` types229- **Async Pipeline**: Document the entity extraction and graph building pipeline230- **Entity Normalization**: Special naming conventions (e.g., "SARAH_CHEN")231232### TypeScript233234- **Next.js 15 App Router**: Document pages, layouts, and API routes235- **shadcn/ui Components**: Document UI component composition236- **Data Fetching**: SWR hooks and API integration patterns237- **Form Handling**: react-hook-form patterns238- **State Management**: Workspace, query, and document state patterns239- **Streaming**: SSE and streaming response handling240241## Examples242243### Rust Example244245```246Generate comprehensive documentation for the edgequake-storage crate including:247- All trait definitions and implementations248- Storage backend comparison (Memory vs PostgreSQL)249- Error handling patterns250- Async operation patterns251- Integration tests252- Architecture diagram showing trait relationships253```254255### TypeScript Example256257```258Generate documentation for the edgequake_webui components including:259- All React components with props260- Custom hooks in src/hooks261- API integration types262- Component composition examples263- Storybook stories for all components264- Data flow diagram265```266267## Troubleshooting268269### Documentation not generating270271- ✓ Ensure files are accessible and readable272- ✓ Check file permissions273- ✓ Verify syntax is valid274275### Examples don't compile (Rust)276277- ✓ Test examples before including them278- ✓ Ensure all imports are present279- ✓ Verify types are correct and in scope280281### Missing documentation282283- ✓ Check if items are public/exported284- ✓ Verify exports are in correct module285- ✓ Ensure items are accessible from public API286287## Related skills288289- **makefile-dev-workflow**: Development workflow commands290- **playwright-ux-ui-capture**: UI screenshot capture automation291- **ux-ui-analyze-single-page**: Single page UX analysis292293## See also294295- [Rust Book - Documentation](https://doc.rust-lang.org/book/ch14-04-installing-binaries.html#distributing-binaries-with-cargo-install)296- [TypeScript Documentation](https://www.typescriptlang.org/docs/)297- [React Documentation](https://react.dev/)298- [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/)