Documentation generation

From JeremyDev87/codingbuddy · View interactive version

Documentation generation is an AI agent skill from the GitHub repository JeremyDev87/codingbuddy. Use when creating or updating README, API docs, architecture docs, or CHANGELOG. Generates clear, accurate documentation from code structure and context.

How to use this skill

Skill file

Documentation Generation

Overview

Good documentation is the gift you give your future self and your team. It is NOT optional.

Core principle: Documentation describes behavior, not code. If the code changes, update the docs.

Iron Law:

DOCS ARE OUTDATED THE MOMENT THEY ARE WRITTEN — AUTOMATE OR ACCEPT THE DEBT

When to Use

Document Types & Templates

1. README.md

A good README answers: What is this? How do I run it? How do I use it?

# Project Name

One-sentence description of what this does and who it's for.

## Quick Start

\`\`\`bash
npm install
npm run dev
\`\`\`

## Features

- Feature 1: Brief description
- Feature 2: Brief description

## Installation

\`\`\`bash
# Prerequisites
node >= 18
npm >= 9

# Install
npm install

# Configure
cp .env.example .env
# Edit .env with your values

# Run
npm start
\`\`\`

## Configuration

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `PORT` | No | `3000` | Server port |
| `DATABASE_URL` | Yes | — | PostgreSQL connection string |

## API Reference

See [API Documentation](./docs/api.md) for full reference.

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md).

## License

MIT

2. API Documentation

# API Reference

## Authentication

All endpoints require Bearer token:
\`\`\`
Authorization: Bearer <token>
\`\`\`

## Endpoints

### GET /users

List all users.

**Parameters:**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | No | Page number (default: 1) |
| `limit` | integer | No | Per-page count (default: 20, max: 100) |

**Response:**
\`\`\`json
{
  "data": [{ "id": "123", "email": "user@example.com" }],
  "meta": { "total": 42, "page": 1 }
}
\`\`\`

**Errors:**
| Code | Status | Description |
|------|--------|-------------|
| `UNAUTHORIZED` | 401 | Missing or invalid token |
| `FORBIDDEN` | 403 | Insufficient permissions |

3. Architecture Decision Record (ADR)

# ADR-001: Use NestJS for MCP Server

**Date:** 2024-01-15
**Status:** Accepted

## Context

We need a Node.js framework for the MCP server with dependency injection and testability.

## Decision

Use NestJS with TypeScript.

## Rationale

- Built-in dependency injection for testable code
- Decorator-based approach matches MCP patterns
- Strong TypeScript support
- Module system aligns with MCP's separation of concerns

## Consequences

- Higher initial complexity than Express
- Requires understanding of NestJS modules
- Excellent testing support out of the box

4. CHANGELOG

Follow Keep a Changelog format:

# Changelog

## [Unreleased]

### Added
- New feature X

## [1.2.0] - 2024-01-15

### Added
- Support for SSE transport mode
- Bearer token authentication for SSE

### Changed
- Improved error messages for invalid rules

### Fixed
- Memory leak in rule file watcher

### Security
- Fixed token exposure in debug logs

## [1.1.0] - 2024-01-01
...

Generation Process

Step 1: Gather Context

# Understand the project structure
ls -la
cat package.json
git log --oneline -20   # Recent changes for CHANGELOG

# Find existing documentation
find . -name "*.md" -not -path "*/node_modules/*"

Step 2: Extract Information from Code

For TypeScript projects, extract JSDoc/TSDoc:

/**
 * Search rules by query string.
 * @param query - Search term to match against rule content
 * @param options - Optional filters
 * @returns Matching rules sorted by relevance
 */
async searchRules(query: string, options?: SearchOptions): Promise<Rule[]>

For configuration:

// Extract environment variables
grep -rn "process.env\." src/ | grep -o "process\.env\.[A-Z_]*" | sort -u

Step 3: Write Documentation

Principles:

Step 4: Verify Accuracy

- [ ] All code examples are runnable
- [ ] Environment variables list matches .env.example
- [ ] API endpoints match actual routes
- [ ] Prerequisites match actual requirements
- [ ] Links are not broken

Documentation Checklist by Type

README

API Docs

CHANGELOG

ADR

Common Mistakes

| Mistake | Fix |

|---------|-----|

| Documenting code, not behavior | Describe what it does, not how |

| Outdated examples | Add docs to definition of done |

| No quick start | First 5 minutes → working system |

| Wall of text | Use tables, code blocks, lists |

| Missing error docs | Document failure modes |

| Internal jargon | Write for a new team member |

Tools to Accelerate

# TypeScript → API docs
npx typedoc --out docs/api src/

# Markdown linting
npx markdownlint-cli "**/*.md"

# Link checking
npx markdown-link-check README.md

# CHANGELOG generation from git log
npx conventional-changelog-cli -p angular
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.