Generate comprehensive feature documentation including Storybook stories, JSDoc comments, and feature guides. Use after completing a feature (may span multiple commits). Creates documentation for humans and AI to understand features, usage patterns, and design decisions.
Generates comprehensive documentation including Storybook stories, JSDoc comments, and feature guides after completing features. Triggers when you finish implementing components, hooks, or multi-commit features that need usage documentation for humans and AI.
/plugin marketplace add buzzdan/ai-coding-rules/plugin install ts-react-linter-driven-development@ai-coding-rulesThis skill inherits all available tools. When active, it can use any tool Claude has access to.
reference.mdGenerate comprehensive documentation for features, components, and hooks.
Purpose: Visual documentation of component usage and variants
Creates: .stories.tsx files alongside components
Purpose: Inline documentation for types, props, complex functions
Location: In source files (.ts, .tsx)
Purpose: WHY decisions were made, HOW feature works, WHAT to extend
Creates: docs/features/[feature-name].md
Ask:
For each component, create stories showing:
Example:
// src/components/Button/Button.stories.tsx
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from './Button'
const meta: Meta<typeof Button> = {
title: 'Components/Button',
component: Button,
parameters: {
layout: 'centered'
},
tags: ['autodocs'],
argTypes: {
variant: {
control: 'select',
options: ['primary', 'secondary', 'danger']
}
}
}
export default meta
type Story = StoryObj<typeof Button>
// Default story
export const Primary: Story = {
args: {
label: 'Button',
variant: 'primary',
onClick: () => alert('clicked')
}
}
// Variants
export const Secondary: Story = {
args: {
...Primary.args,
variant: 'secondary'
}
}
export const Danger: Story = {
args: {
...Primary.args,
variant: 'danger'
}
}
// States
export const Disabled: Story = {
args: {
...Primary.args,
isDisabled: true
}
}
export const Loading: Story = {
args: {
...Primary.args,
isLoading: true
}
}
// Interactive example
export const WithIcon: Story = {
args: {
...Primary.args,
icon: <IconCheck />
}
}
For public types and interfaces:
/**
* Props for the Button component.
*
* @example
* ```tsx
* <Button
* label="Click me"
* variant="primary"
* onClick={() => console.log('clicked')}
* />
* ```
*/
export interface ButtonProps {
/** The text to display on the button */
label: string
/** The visual style variant of the button */
variant?: 'primary' | 'secondary' | 'danger'
/** Callback fired when the button is clicked */
onClick: () => void
/** If true, the button will be disabled */
isDisabled?: boolean
/** If true, the button will show a loading spinner */
isLoading?: boolean
}
For custom hooks:
/**
* Custom hook for managing user authentication state.
*
* Handles login, logout, and persisting auth state to localStorage.
* Automatically refreshes token when it expires.
*
* @param options - Configuration options for authentication
* @returns Authentication state and methods
*
* @example
* ```tsx
* function LoginForm() {
* const { login, isLoading, error } = useAuth()
*
* const handleSubmit = async (email: string, password: string) => {
* await login(email, password)
* }
*
* return <Form onSubmit={handleSubmit} isLoading={isLoading} error={error} />
* }
* ```
*/
export function useAuth(options?: AuthOptions): UseAuthReturn {
// Implementation
}
For complex types:
/**
* Represents the state of an asynchronous operation.
*
* Uses discriminated union to ensure invalid states are impossible
* (e.g., cannot have both data and error simultaneously).
*
* @template T - The type of data returned on success
*
* @example
* ```typescript
* const [state, setState] = useState<AsyncState<User>>({ status: 'idle' })
*
* // Type narrowing works automatically
* if (state.status === 'success') {
* console.log(state.data.name) // state.data is available and typed
* }
* ```
*/
export type AsyncState<T> =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'success'; data: T }
| { status: 'error'; error: Error }
For completed features, create docs/features/[feature-name].md:
Template:
# Feature: [Feature Name]
## Overview
Brief description of what the feature does and why it exists.
## Problem
What problem does this feature solve? What was the pain point?
## Solution
How does this feature solve the problem? What approach was taken?
## Architecture
### Components
- **ComponentName**: Purpose and responsibility
- **AnotherComponent**: Purpose and responsibility
### Hooks
- **useFeatureHook**: What it does and why it's separate
### Context
- **FeatureContext**: What state it manages and why context was needed
### Types
- **KeyType**: What it represents and why it's a custom type
## Key Design Decisions
### 1. [Decision Title]
**Decision**: What was decided
**Rationale**: Why this approach was chosen
**Alternatives**: What other approaches were considered
**Trade-offs**: What we gained and what we gave up
### 2. [Another Decision]
...
## Usage
### Basic Usage
```typescript
// Simple example showing most common use case
// Example showing advanced features or edge cases
How this feature integrates with other parts of the application.
Props:
propName (Type): DescriptionEvents:
onEvent: When it fires and what it provides...
Parameters:
param (Type): DescriptionReturns:
returnValue (Type): Descriptiontype TypeName = ...
Description of when and how to use this type.
Symptom: What users will see Cause: Why this happens Solution: How to fix it
(If replacing existing functionality)
// Old way
// New way
## Output Format
After generating documentation:
📚 DOCUMENTATION GENERATED
Feature: User Authentication
Generated Files: ✅ Storybook Stories (3 components)
✅ JSDoc Comments Added
✅ Feature Documentation
📖 Documentation includes:
🎯 Next Steps:
📝 Maintenance:
## Documentation Principles
### For Humans AND AI
Documentation serves two audiences:
1. **Human developers**: Need to understand and extend code
2. **AI assistants**: Need context to help debug and extend features
Write documentation that helps both audiences understand:
- **WHY** decisions were made (context for future changes)
- **HOW** the feature works (architecture and flow)
- **WHAT** can be extended (integration points)
### Show, Don't Tell
Prefer code examples over prose descriptions:
**❌ Bad**:
The Button component accepts a variant prop that can be primary, secondary, or danger, and will style the button accordingly.
**✅ Good**:
```typescript
<Button variant="primary" label="Save" />
<Button variant="secondary" label="Cancel" />
<Button variant="danger" label="Delete" />
Storybook stories and JSDoc examples should be real, working code that compiles and runs.
Most important: WHY decisions were made.
❌ Bad:
// Uses context for state management
✅ Good:
/**
* Uses AuthContext for state management instead of prop drilling.
*
* Decision: Context chosen because auth state is needed in 10+
* components across different nesting levels (nav, profile, settings,
* protected routes). Prop drilling would be unmaintainable.
*
* Alternative considered: Redux - overkill for single feature state
*/
@param, @returns, @example tags@see# Run Storybook locally
npm run storybook
# Build static Storybook
npm run build-storybook
# Test stories (interaction testing)
npm run test-storybook
# Generate API documentation from TypeScript
npx typedoc --entryPoints src/index.ts
See reference.md for detailed principles:
See reference.md for complete documentation templates and examples.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.