Skip to content

/document-feature - Comprehensive Feature Documentation

Purpose

The /document-feature prompt creates multi-perspective documentation that captures not just what a feature does, but why it exists, how it works, and how to use it effectively. It adapts to different audiences and maintains living documentation that evolves with your code.

Use Cases

  1. Feature Documentation: Document new or existing features comprehensively
  2. API Documentation: Create developer-friendly API guides
  3. User Guides: Generate end-user documentation
  4. Technical Specs: Document architecture and implementation
  5. Knowledge Transfer: Capture tribal knowledge permanently

Argument Structure

/document-feature <feature-name> [target-audience] [--options]

Arguments

  1. feature-name (required)

    • Feature to document
    • Can be specific: "user-authentication"
    • Or descriptive: "The billing system"
  2. target-audience (optional)

    • Primary audience for docs
    • Options: "developers", "users", "ops", "all"
    • Defaults to multi-audience
  3. options (optional)

    • --depth: Documentation depth (quick, standard, comprehensive)
    • --format: Output format (markdown, api-spec, guide)
    • --update: Update existing documentation

Examples

bash
# Basic feature documentation
/document-feature "user authentication"

# Developer-focused API docs
/document-feature "REST API" "developers"

# Comprehensive system documentation
/document-feature "payment processing" --depth=comprehensive

# Update existing docs
/document-feature "notification system" --update

Adaptation Strategies

Multi-Perspective Analysis

The prompt examines features from:

  1. User Perspective

    • What problem it solves
    • How to use it
    • Common scenarios
    • Troubleshooting
  2. Developer Perspective

    • Architecture overview
    • API reference
    • Integration guide
    • Code examples
  3. Operations Perspective

    • Deployment requirements
    • Configuration options
    • Monitoring points
    • Maintenance procedures
  4. Business Perspective

    • Value proposition
    • Use cases
    • Metrics and KPIs
    • Future roadmap

Intelligent Discovery

Before documenting:

  • Analyzes code structure
  • Identifies entry points
  • Maps data flows
  • Discovers edge cases
  • Extracts configurations

Living Documentation

Creates docs that:

  • Reference actual code
  • Include real examples
  • Update indicators
  • Version tracking
  • Deprecation notices

Memory Usage

Documentation Structure

project/
├── docs/
│   ├── features/
│   │   ├── authentication/
│   │   │   ├── README.md          # Overview
│   │   │   ├── api.md             # API reference
│   │   │   ├── guide.md           # User guide
│   │   │   ├── architecture.md    # Technical details
│   │   │   └── troubleshooting.md # Common issues
│   │   └── billing/
│   │       ├── README.md
│   │       ├── integration.md
│   │       └── webhooks.md
│   └── api/
│       ├── reference.md
│       └── examples.md
└── .orchestre/
    └── documentation/
        ├── coverage.md             # What's documented
        └── updates.md              # Documentation log

Documentation Example

markdown
# User Authentication System

## Overview

The authentication system provides secure user registration, login, and session management with support for multiple authentication methods.

## Quick Start

### Basic Login Flow
```javascript
// Frontend login
const { data } = await api.post('/auth/login', {
  email: 'user@example.com',
  password: 'secure-password'
});

// Store token
localStorage.setItem('token', data.token);

// Use authenticated requests
api.defaults.headers.common['Authorization'] = `Bearer ${data.token}`;

Architecture

System Components

┌─────────────┐     ┌─────────────┐     ┌──────────────┐
│   Client    │────▶│   API       │────▶│   Auth       │
│   (React)   │     │  Gateway    │     │   Service    │
└─────────────┘     └─────────────┘     └──────────────┘
                            │                    │
                            ▼                    ▼
                    ┌─────────────┐     ┌──────────────┐
                    │   Session   │     │   Database   │
                    │   Store     │     │ (PostgreSQL) │
                    │   (Redis)   │     └──────────────┘
                    └─────────────┘

Security Features

  • Password hashing: bcrypt (cost factor: 12)
  • Session management: JWT with refresh tokens
  • Rate limiting: 5 attempts per 15 minutes
  • 2FA support: TOTP-based

API Reference

POST /auth/register

Register a new user account.

Request Body:

json
{
  "email": "user@example.com",
  "password": "minimum-12-chars",
  "name": "John Doe"
}

Response:

json
{
  "user": {
    "id": "uuid",
    "email": "user@example.com",
    "name": "John Doe"
  },
  "token": "jwt-token"
}

POST /auth/login

Authenticate user and receive access token.

Request Body:

json
{
  "email": "user@example.com",
  "password": "user-password"
}

Response:

json
{
  "user": { ... },
  "token": "jwt-token",
  "refreshToken": "refresh-token"
}

Configuration

Environment Variables

bash
# JWT Configuration
JWT_SECRET=your-secret-key
JWT_EXPIRY=15m
REFRESH_TOKEN_EXPIRY=7d

# Security Settings
BCRYPT_ROUNDS=12
MAX_LOGIN_ATTEMPTS=5
LOCKOUT_DURATION=15m

Troubleshooting

Common Issues

  1. "Invalid credentials" error

    • Verify email exists in database
    • Check password requirements
    • Ensure account is not locked
  2. "Token expired" error

    • Implement token refresh flow
    • Check client clock sync
    • Verify JWT_EXPIRY setting
  3. Rate limit exceeded

    • Wait for lockout period
    • Check for brute force attempts
    • Review rate limit settings

Monitoring

Key Metrics

  • Login success rate
  • Average login time
  • Failed login attempts
  • Active sessions count
  • Token refresh rate

Alerts

  • Multiple failed logins from same IP
  • Unusual login patterns
  • High token generation rate
  • Database connection issues

## Workflow Examples

### New Feature Documentation
```bash
# 1. Implement feature
/execute-task "Add social login with Google OAuth"

# 2. Document comprehensively
/document-feature "social login" --depth=comprehensive

# 3. Add integration guide
/document-feature "OAuth integration" "developers"

# 4. Create user guide
/document-feature "Login with Google" "users"

API Documentation Update

bash
# 1. Analyze current API
/discover-context ./src/api

# 2. Generate API docs
/document-feature "REST API v2" "developers" --format=api-spec

# 3. Add examples
/execute-task "Create Postman collection from API documentation"

# 4. Publish docs
/execute-task "Set up API documentation site with Swagger"

System Documentation

bash
# 1. Document architecture
/document-feature "microservices architecture" --depth=comprehensive

# 2. Add operational guides
/document-feature "deployment procedures" "ops"

# 3. Create runbooks
/document-feature "incident response" "ops" --format=runbook

# 4. Knowledge base
/document-feature "system overview" "all"

Documentation Types

1. User Documentation

Focuses on:

  • Getting started guides
  • Feature walkthroughs
  • FAQs and troubleshooting
  • Best practices
  • Video tutorials

2. Developer Documentation

Includes:

  • API references
  • Code examples
  • Integration guides
  • Architecture diagrams
  • Contributing guidelines

3. Operational Documentation

Contains:

  • Deployment procedures
  • Configuration management
  • Monitoring setup
  • Backup procedures
  • Disaster recovery

4. Business Documentation

Covers:

  • Feature specifications
  • User stories
  • Success metrics
  • ROI analysis
  • Competitive analysis

Intelligent Features

Auto-Discovery

  • Finds undocumented features
  • Identifies API endpoints
  • Extracts configuration options
  • Maps dependencies
  • Discovers test cases

Code Synchronization

  • Links to source code
  • Updates on changes
  • Deprecation warnings
  • Version tracking
  • Migration guides

Example Generation

  • Real code examples
  • Working snippets
  • Error scenarios
  • Edge cases
  • Best practices

Multi-Format Output

  • Markdown for repositories
  • OpenAPI for APIs
  • JSDoc for code
  • AsciiDoc for books
  • HTML for sites

Documentation Standards

Structure Template

markdown
# Feature Name

## Overview
Brief description and purpose

## Quick Start
Minimal working example

## Concepts
Key concepts and terminology

## Usage
### Basic Usage
Simple examples

### Advanced Usage
Complex scenarios

## API Reference
Detailed API documentation

## Configuration
All configuration options

## Best Practices
Recommended patterns

## Troubleshooting
Common issues and solutions

## Related
Links to related features

Quality Checklist

  • [ ] Clear overview
  • [ ] Working examples
  • [ ] Complete API coverage
  • [ ] Configuration documented
  • [ ] Error scenarios covered
  • [ ] Performance notes
  • [ ] Security considerations
  • [ ] Migration guides

Integration Points

With Other Prompts

  • ← /execute-task: Document after building
  • ← /discover-context: Understand before documenting
  • → /orchestrate: Use docs for planning
  • → /review: Validate documentation

With Development Workflow

  • Pre-commit documentation
  • PR documentation requirements
  • Release notes generation
  • Changelog updates
  • Version documentation

Best Practices

  1. Document Early

    bash
    # During development
    /document-feature "new caching layer" --depth=quick
    
    # After implementation
    /document-feature "caching layer" --update --depth=comprehensive
  2. Multiple Audiences

    bash
    # Technical documentation
    /document-feature "database schema" "developers"
    
    # User documentation  
    /document-feature "data export" "users"
    
    # Combined approach
    /document-feature "reporting system" "all"
  3. Keep Updated

    bash
    # Regular updates
    /document-feature "api endpoints" --update
    
    # After changes
    /execute-task "Update API v2"
    /document-feature "api v2" --update

Advanced Documentation

Interactive Documentation

bash
/document-feature "api playground" --format=interactive
# Generates executable API documentation

Video Documentation

bash
/document-feature "user onboarding" --format=video-script
# Creates video tutorial scripts

Multilingual Docs

bash
/document-feature "user guide" --languages="en,es,fr"
# Prepares for translation

Tips

  1. Start Simple: Basic docs are better than no docs
  2. Use Examples: Show, don't just tell
  3. Think Long-term: Docs outlive code
  4. Automate Updates: Link to living code
  5. Get Feedback: Docs are for readers, not writers

Built with ❤️ for the AI Coding community, by Praney Behl