Documentation and adrs

Records decisions and documentation.

How to use it

Claude Code
  1. Run the line below. It pulls the whole folder into ~/.claude/skills/documentation-and-adrs, including the files SKILL.md points to.
  2. Describe your job in plain words. Claude Code follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit addyosmani/agent-skills/skills/documentation-and-adrs#main ~/.claude/skills/documentation-and-adrs

For one project only, change the path to .claude/skills/documentation-and-adrs. This skill also uses 0004-title.md — copying SKILL.md alone won't be enough. See the folder on GitHub.

Claude (web or desktop app)
  1. On this page open ⋯ → Download .md.
  2. Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
  3. Pick the file and Save. Claude shows the name and description and runs a security scan.
  4. Check the skill is switched on.
  5. Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
  1. ChatGPT: make a Project and paste it into Instructions.
  2. Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Source of Documentation and adrs

Show the full text289 lines
namedescription
documentation-and-adrsRecords decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

Documentation and ADRs

Overview

Document decisions, not just code. The most valuable documentation captures the why — the context, constraints, and trade-offs that led to a decision. Code shows what was built; documentation explains why it was built this way and what alternatives were considered. This context is essential for future humans and agents working in the codebase.

When to Use

  • Making a significant architectural decision
  • Choosing between competing approaches
  • Adding or changing a public API
  • Shipping a feature that changes user-facing behavior
  • Onboarding new team members (or agents) to the project
  • When you find yourself explaining the same thing repeatedly

When NOT to use: Don't document obvious code. Don't add comments that restate what the code already says. Don't write docs for throwaway prototypes.

Architecture Decision Records (ADRs)

ADRs capture the reasoning behind significant technical decisions. They're the highest-value documentation you can write.

When to Write an ADR
  • Choosing a framework, library, or major dependency
  • Designing a data model or database schema
  • Selecting an authentication strategy
  • Deciding on an API architecture (REST vs. GraphQL vs. tRPC)
  • Choosing between build tools, hosting platforms, or infrastructure
  • Any decision that would be expensive to reverse
Match the existing convention first

Before creating an ADR, inspect the available repository context for an established convention — existing ADRs, project instructions, and ADR-related configuration or tooling (e.g. an .adr-dir file). An established convention overrides the defaults below. Match:

  • Location and format — e.g. docs/adr/*.md, Documentation/Decisions/*.rst, a MADR layout, or an adr-tools setup. Match the existing directory, file extension, and markup (Markdown vs reStructuredText).
  • Numbering and naming — continue the existing sequence and filename pattern (ADR-004-Title.rst, 0004-title.md, …); don't restart at 001 or introduce a second scheme.
  • Section headings — reuse the project's heading set rather than imposing this template's.

If the available evidence conflicts, surface the conflict rather than silently introducing another scheme. Only when no convention can be established do you apply the default below.

ADR Template

Store ADRs in docs/decisions/ with sequential numbering (unless the project already uses another location — see above):

# ADR-001: Use PostgreSQL for primary database

## Status
Accepted | Superseded by ADR-XXX | Deprecated

## Date
2025-01-15

## Context
We need a primary database for the task management application. Key requirements:
- Relational data model (users, tasks, teams with relationships)
- ACID transactions for task state changes
- Support for full-text search on task content
- Managed hosting available (for small team, limited ops capacity)

## Decision
Use PostgreSQL with Prisma ORM.

## Alternatives Considered

### MongoDB
- Pros: Flexible schema, easy to start with
- Cons: Our data is inherently relational; would need to manage relationships manually
- Rejected: Relational data in a document store leads to complex joins or data duplication

### SQLite
- Pros: Zero configuration, embedded, fast for reads
- Cons: Limited concurrent write support, no managed hosting for production
- Rejected: Not suitable for multi-user web application in production

### MySQL
- Pros: Mature, widely supported
- Cons: PostgreSQL has better JSON support, full-text search, and ecosystem tooling
- Rejected: PostgreSQL is the better fit for our feature requirements

## Consequences
- Prisma provides type-safe database access and migration management
- We can use PostgreSQL's full-text search instead of adding Elasticsearch
- Team needs PostgreSQL knowledge (standard skill, low risk)
- Hosting on managed service (Supabase, Neon, or RDS)
ADR Lifecycle
PROPOSED → ACCEPTED → (SUPERSEDED or DEPRECATED)
  • Don't delete old ADRs. They capture historical context.
  • When a decision changes, write a new ADR that references and supersedes the old one.

Inline Documentation

When to Comment

Comment the why, not the what:

// BAD: Restates the code
// Increment counter by 1
counter += 1;

// GOOD: Explains non-obvious intent
// Rate limit uses a sliding window — reset counter at window boundary,
// not on a fixed schedule, to prevent burst attacks at window edges
if (now - windowStart > WINDOW_SIZE_MS) {
  counter = 0;
  windowStart = now;
}
When NOT to Comment
// Don't comment self-explanatory code
function calculateTotal(items: CartItem[]): number {
  return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}

// Don't leave TODO comments for things you should just do now
// TODO: add error handling  ← Just add it

// Don't leave commented-out code
// const oldImplementation = () => { ... }  ← Delete it, git has history
Document Known Gotchas
/**
 * IMPORTANT: This function must be called before the first render.
 * If called after hydration, it causes a flash of unstyled content
 * because the theme context isn't available during SSR.
 *
 * See ADR-003 for the full design rationale.
 */
export function initializeTheme(theme: Theme): void {
  // ...
}

API Documentation

For public APIs (REST, GraphQL, library interfaces):

Inline with Types (Preferred for TypeScript)
/**
 * Creates a new task.
 *
 * @param input - Task creation data (title required, description optional)
 * @returns The created task with server-generated ID and timestamps
 * @throws {ValidationError} If title is empty or exceeds 200 characters
 * @throws {AuthenticationError} If the user is not authenticated
 *
 * @example
 * const task = await createTask({ title: 'Buy groceries' });
 * console.log(task.id); // "task_abc123"
 */
export async function createTask(input: CreateTaskInput): Promise<Task> {
  // ...
}
OpenAPI / Swagger for REST APIs
paths:
  /api/tasks:
    post:
      summary: Create a task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskInput'
      responses:
        '201':
          description: Task created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        '422':
          description: Validation error

README Structure

Every project should have a README that covers:

# Project Name

One-paragraph description of what this project does.

## Quick Start
1. Clone the repo
2. Install dependencies: `npm install`
3. Set up environment: `cp .env.example .env`
4. Run the dev server: `npm run dev`

## Commands
| Command | Description |
|---------|-------------|
| `npm run dev` | Start development server |
| `npm test` | Run tests |
| `npm run build` | Production build |
| `npm run lint` | Run linter |

## Architecture
Brief overview of the project structure and key design decisions.
Link to ADRs for details.

## Contributing
How to contribute, coding standards, PR process.

Changelog Maintenance

For shipped features:

# Changelog

## [1.2.0] - 2025-01-20
### Added
- Task sharing: users can share tasks with team members (#123)
- Email notifications for task assignments (#124)

### Fixed
- Duplicate tasks appearing when rapidly clicking create button (#125)

### Changed
- Task list now loads 50 items per page (was 20) for better UX (#126)

Documentation for Agents

Special consideration for AI agent context:

  • CLAUDE.md / rules files — Document project conventions so agents follow them
  • Spec files — Keep specs updated so agents build the right thing
  • ADRs — Help agents understand why past decisions were made (prevents re-deciding)
  • Inline gotchas — Prevent agents from falling into known traps

Common Rationalizations

Rationalization Reality
"The code is self-documenting" Code shows what. It doesn't show why, what alternatives were rejected, or what constraints apply.
"We'll write docs when the API stabilizes" APIs stabilize faster when you document them. The doc is the first test of the design.
"Nobody reads docs" Agents do. Future engineers do. Your 3-months-later self does.
"ADRs are overhead" A 10-minute ADR prevents a 2-hour debate about the same decision six months later.
"Comments get outdated" Comments on why are stable. Comments on what get outdated — that's why you only write the former.

Red Flags

  • Architectural decisions with no written rationale
  • Public APIs with no documentation or types
  • README that doesn't explain how to run the project
  • Commented-out code instead of deletion
  • TODO comments that have been there for weeks
  • No ADRs in a project with significant architectural choices
  • Documentation that restates the code instead of explaining intent

Verification

After documenting:

  • ADRs exist for all significant architectural decisions
  • README covers quick start, commands, and architecture overview
  • API functions have parameter and return type documentation
  • Known gotchas are documented inline where they matter
  • No commented-out code remains
  • Rules files (CLAUDE.md etc.) are current and accurate
1---
2name: documentation-and-adrs
3description: Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.
4---
5 
6# Documentation and ADRs
7 
8## Overview
9 
10Document decisions, not just code. The most valuable documentation captures the *why* — the context, constraints, and trade-offs that led to a decision. Code shows *what* was built; documentation explains *why it was built this way* and *what alternatives were considered*. This context is essential for future humans and agents working in the codebase.
11 
12## When to Use
13 
14- Making a significant architectural decision
15- Choosing between competing approaches
16- Adding or changing a public API
17- Shipping a feature that changes user-facing behavior
18- Onboarding new team members (or agents) to the project
19- When you find yourself explaining the same thing repeatedly
20 
21**When NOT to use:** Don't document obvious code. Don't add comments that restate what the code already says. Don't write docs for throwaway prototypes.
22 
23## Architecture Decision Records (ADRs)
24 
25ADRs capture the reasoning behind significant technical decisions. They're the highest-value documentation you can write.
26 
27### When to Write an ADR
28 
29- Choosing a framework, library, or major dependency
30- Designing a data model or database schema
31- Selecting an authentication strategy
32- Deciding on an API architecture (REST vs. GraphQL vs. tRPC)
33- Choosing between build tools, hosting platforms, or infrastructure
34- Any decision that would be expensive to reverse
35 
36### Match the existing convention first
37 
38Before creating an ADR, inspect the available repository context for an established convention — existing ADRs, project instructions, and ADR-related configuration or tooling (e.g. an `.adr-dir` file). An established convention overrides the defaults below. Match:
39 
40- **Location and format** — e.g. `docs/adr/*.md`, `Documentation/Decisions/*.rst`, a MADR layout, or an `adr-tools` setup. Match the existing directory, file extension, and markup (Markdown vs reStructuredText).
41- **Numbering and naming** — continue the existing sequence and filename pattern (`ADR-004-Title.rst`, `0004-title.md`, …); don't restart at 001 or introduce a second scheme.
42- **Section headings** — reuse the project's heading set rather than imposing this template's.
43 
44If the available evidence conflicts, surface the conflict rather than silently introducing another scheme. Only when no convention can be established do you apply the default below.
45 
46### ADR Template
47 
48Store ADRs in `docs/decisions/` with sequential numbering (unless the project already uses another location — see above):
49 
50```markdown
51# ADR-001: Use PostgreSQL for primary database
52 
53## Status
54Accepted | Superseded by ADR-XXX | Deprecated
55 
56## Date
572025-01-15
58 
59## Context
60We need a primary database for the task management application. Key requirements:
61- Relational data model (users, tasks, teams with relationships)
62- ACID transactions for task state changes
63- Support for full-text search on task content
64- Managed hosting available (for small team, limited ops capacity)
65 
66## Decision
67Use PostgreSQL with Prisma ORM.
68 
69## Alternatives Considered
70 
71### MongoDB
72- Pros: Flexible schema, easy to start with
73- Cons: Our data is inherently relational; would need to manage relationships manually
74- Rejected: Relational data in a document store leads to complex joins or data duplication
75 
76### SQLite
77- Pros: Zero configuration, embedded, fast for reads
78- Cons: Limited concurrent write support, no managed hosting for production
79- Rejected: Not suitable for multi-user web application in production
80 
81### MySQL
82- Pros: Mature, widely supported
83- Cons: PostgreSQL has better JSON support, full-text search, and ecosystem tooling
84- Rejected: PostgreSQL is the better fit for our feature requirements
85 
86## Consequences
87- Prisma provides type-safe database access and migration management
88- We can use PostgreSQL's full-text search instead of adding Elasticsearch
89- Team needs PostgreSQL knowledge (standard skill, low risk)
90- Hosting on managed service (Supabase, Neon, or RDS)
91```
92 
93### ADR Lifecycle
94 
95```
96PROPOSED → ACCEPTED → (SUPERSEDED or DEPRECATED)
97```
98 
99- **Don't delete old ADRs.** They capture historical context.
100- When a decision changes, write a new ADR that references and supersedes the old one.
101 
102## Inline Documentation
103 
104### When to Comment
105 
106Comment the *why*, not the *what*:
107 
108```typescript
109// BAD: Restates the code
110// Increment counter by 1
111counter += 1;
112 
113// GOOD: Explains non-obvious intent
114// Rate limit uses a sliding window — reset counter at window boundary,
115// not on a fixed schedule, to prevent burst attacks at window edges
116if (now - windowStart > WINDOW_SIZE_MS) {
117 counter = 0;
118 windowStart = now;
119}
120```
121 
122### When NOT to Comment
123 
124```typescript
125// Don't comment self-explanatory code
126function calculateTotal(items: CartItem[]): number {
127 return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
128}
129 
130// Don't leave TODO comments for things you should just do now
131// TODO: add error handling ← Just add it
132 
133// Don't leave commented-out code
134// const oldImplementation = () => { ... } ← Delete it, git has history
135```
136 
137### Document Known Gotchas
138 
139```typescript
140/**
141 * IMPORTANT: This function must be called before the first render.
142 * If called after hydration, it causes a flash of unstyled content
143 * because the theme context isn't available during SSR.
144 *
145 * See ADR-003 for the full design rationale.
146 */
147export function initializeTheme(theme: Theme): void {
148 // ...
149}
150```
151 
152## API Documentation
153 
154For public APIs (REST, GraphQL, library interfaces):
155 
156### Inline with Types (Preferred for TypeScript)
157 
158```typescript
159/**
160 * Creates a new task.
161 *
162 * @param input - Task creation data (title required, description optional)
163 * @returns The created task with server-generated ID and timestamps
164 * @throws {ValidationError} If title is empty or exceeds 200 characters
165 * @throws {AuthenticationError} If the user is not authenticated
166 *
167 * @example
168 * const task = await createTask({ title: 'Buy groceries' });
169 * console.log(task.id); // "task_abc123"
170 */
171export async function createTask(input: CreateTaskInput): Promise<Task> {
172 // ...
173}
174```
175 
176### OpenAPI / Swagger for REST APIs
177 
178```yaml
179paths:
180 /api/tasks:
181 post:
182 summary: Create a task
183 requestBody:
184 required: true
185 content:
186 application/json:
187 schema:
188 $ref: '#/components/schemas/CreateTaskInput'
189 responses:
190 '201':
191 description: Task created
192 content:
193 application/json:
194 schema:
195 $ref: '#/components/schemas/Task'
196 '422':
197 description: Validation error
198```
199 
200## README Structure
201 
202Every project should have a README that covers:
203 
204```markdown
205# Project Name
206 
207One-paragraph description of what this project does.
208 
209## Quick Start
2101. Clone the repo
2112. Install dependencies: `npm install`
2123. Set up environment: `cp .env.example .env`
2134. Run the dev server: `npm run dev`
214 
215## Commands
216| Command | Description |
217|---------|-------------|
218| `npm run dev` | Start development server |
219| `npm test` | Run tests |
220| `npm run build` | Production build |
221| `npm run lint` | Run linter |
222 
223## Architecture
224Brief overview of the project structure and key design decisions.
225Link to ADRs for details.
226 
227## Contributing
228How to contribute, coding standards, PR process.
229```
230 
231## Changelog Maintenance
232 
233For shipped features:
234 
235```markdown
236# Changelog
237 
238## [1.2.0] - 2025-01-20
239### Added
240- Task sharing: users can share tasks with team members (#123)
241- Email notifications for task assignments (#124)
242 
243### Fixed
244- Duplicate tasks appearing when rapidly clicking create button (#125)
245 
246### Changed
247- Task list now loads 50 items per page (was 20) for better UX (#126)
248```
249 
250## Documentation for Agents
251 
252Special consideration for AI agent context:
253 
254- **CLAUDE.md / rules files** — Document project conventions so agents follow them
255- **Spec files** — Keep specs updated so agents build the right thing
256- **ADRs** — Help agents understand why past decisions were made (prevents re-deciding)
257- **Inline gotchas** — Prevent agents from falling into known traps
258 
259## Common Rationalizations
260 
261| Rationalization | Reality |
262|---|---|
263| "The code is self-documenting" | Code shows what. It doesn't show why, what alternatives were rejected, or what constraints apply. |
264| "We'll write docs when the API stabilizes" | APIs stabilize faster when you document them. The doc is the first test of the design. |
265| "Nobody reads docs" | Agents do. Future engineers do. Your 3-months-later self does. |
266| "ADRs are overhead" | A 10-minute ADR prevents a 2-hour debate about the same decision six months later. |
267| "Comments get outdated" | Comments on *why* are stable. Comments on *what* get outdated — that's why you only write the former. |
268 
269## Red Flags
270 
271- Architectural decisions with no written rationale
272- Public APIs with no documentation or types
273- README that doesn't explain how to run the project
274- Commented-out code instead of deletion
275- TODO comments that have been there for weeks
276- No ADRs in a project with significant architectural choices
277- Documentation that restates the code instead of explaining intent
278 
279## Verification
280 
281After documenting:
282 
283- [ ] ADRs exist for all significant architectural decisions
284- [ ] README covers quick start, commands, and architecture overview
285- [ ] API functions have parameter and return type documentation
286- [ ] Known gotchas are documented inline where they matter
287- [ ] No commented-out code remains
288- [ ] Rules files (CLAUDE.md etc.) are current and accurate
289 

Discussion

Alternatives

Also in Developer docsSee all 533 in Development →
Github repository analysis and enhancementAct as a GitHub Repository Analyst to perform in-depth analysis and suggest improvements for repository structure, documentation, code quality, and community engagement.Coding · CC0-1.0Multi-Audience Application Discovery & Documentation PromptA prompt designed to analyze a codebase and generate comprehensive Markdown documentation tailored for executive, technical, product, and business audiences. It guides an AI to extract high-level system purpose, architecture, key components, workflows, product features, business domains, and limitations, producing an onboarding and discovery document suitable for both technical and non-technical stakeholders.Coding · CC0-1.0Treatment-Plan DocumentationFormat and structurally validate local treatment-plan documentation after clinical decisions have already been supplied and verified by authorized licensed professionals. Use for source traceability, clinician-authored intervention records, goals and checkpoints, shared-decision records, reconciliation handoffs, and release gates—not for clinical decision-making.Science · MITCodebase ScannerScans the codebase to generate project-doc.md and AGENTS.md. Use when bootstrapping a new agent-driven repo, refreshing project documentation after architectural changes, or running a delta scan to detect drift. Runs a full scan on first use and a smart delta scan on subsequent runs. Uses understand-anything + context-mode when available, falls back to native tools otherwise. Only updates AGENTS.md on detected architectural changes with human confirmation.Business & ops · MIT