Skip to main content

AI-powered ADR generator for Claude Code. Captures architectural decisions from coding sessions.

Project description

adrchive

AI-powered ADR generator for Claude Code. Captures architectural decisions made during coding sessions and drafts Architecture Decision Records before they're lost.

The Problem

Developers make decisions during AI coding sessions — schema choices, infrastructure picks, library selections — that disappear when the session ends. adrchive hooks into Claude Code's lifecycle to capture those decisions as structured MADR 4.0 markdown files automatically.

The end goal: a repository of architectural decisions within your project that AI tools can consult later to understand not just the codebase, but the reasoning behind the code.

Installation

pipx install adrchive

Quick Start

# Initialize adrchive in your project
cd your-project
adrchive init

# With Claude Code hook auto-setup (works with Claude Max plans — no API key needed)
adrchive init --hooks

# Or with API key mode (separate Anthropic API billing)
adrchive init --hooks --mode command

# Manually draft an ADR via /adr slash command in Claude Code
# Or from the CLI (requires API key):
adrchive draft --summary "Chose Redis over Memcached for session caching due to pub/sub support"

# Review and promote a draft
adrchive promote

# Scan codebase for undocumented decisions (requires API key)
adrchive audit

API Key

Some features require an ANTHROPIC_API_KEY (separate from a Claude Max subscription):

Feature Needs API key?
/adr slash command No — Claude drafts directly
Auto-detection (agent mode, default) No — uses Claude's session
Auto-detection (command mode) Yes
adrchive draft / adrchive audit Yes
adrchive promote/status/link/index No — local file operations

If you have an API key:

export ANTHROPIC_API_KEY=your-key-here

How It Works

Automatic Mode (Claude Code Hook)

When configured with --hooks, adrchive detects architectural decisions automatically after each Claude Code response. Two modes are available:

Agent mode (default, no API key):

adrchive init --hooks

A Claude subagent reviews the recent conversation for architectural decisions. If found, it drafts ADRs directly. Uses your existing Claude Max plan — no separate API billing.

Command mode (requires ANTHROPIC_API_KEY):

adrchive init --hooks --mode command

A Python process applies tiered gating (file size delta → message count → Haiku classifier) before drafting via Sonnet. More efficient for high-volume sessions since the first two tiers are free and instant.

In both modes, drafts are never canonical — they require human review before promotion.

Manual Mode (/adr Slash Command)

Mid-session in Claude Code:

/adr Chose Redis over Memcached for session caching because of pub/sub support

Claude drafts the ADR directly using the full conversation context — the highest quality path since it was part of the discussion.

Audit Mode

For codebases that predate adrchive:

adrchive audit

Scans dependency manifests, schema files, Dockerfiles, CI configs, and more. Identifies decisions implied by the code that have no ADR, then walks you through an interactive Q&A to fill in context.

CLI Reference

adrchive init [--hooks] [--mode agent|command]

Initialize adrchive for a project. Creates:

  • doc/adr/ and doc/adr/drafts/ directories
  • .adr-config.yml with defaults
  • ADR section in CLAUDE.md
  • doc/adr/INDEX.md

With --hooks: configures Claude Code's Stop hook in .claude/settings.json and installs the /adr slash command to .claude/skills/adr/. Requires a Claude Code restart to take effect.

  • --mode agent (default): uses a Claude subagent — no API key required
  • --mode command: uses adrchive auto via shell script — requires ANTHROPIC_API_KEY

adrchive auto

Called by the Claude Code Stop hook. Reads session transcript from stdin JSON, applies tiered gating, classifies decisions, and drafts ADRs. Not typically invoked directly.

adrchive draft

Manually draft an ADR:

adrchive draft --summary "Description of the decision"
adrchive draft --transcript /path/to/session.jsonl

adrchive promote

Promote a draft to the canonical ADR directory:

adrchive promote                                    # interactive selection
adrchive promote --draft DRAFT-use-redis.md          # specific draft
adrchive promote --draft DRAFT-use-redis.md --status rejected

adrchive status

Change an ADR's status with transition validation:

adrchive status --adr 20260416-use-redis.md --set deprecated

adrchive supersede

Create a new ADR that supersedes an existing one:

adrchive supersede --old 20260410-use-mysql.md --summary "Switch to PostgreSQL for JSONB support"

adrchive link

Create a bidirectional relationship between ADRs:

adrchive link --from 20260416-use-redis.md --to 20260412-api-caching.md --type relates-to

Relationship types: supersedes, amends, relates-to, enables (and their reverses).

adrchive index

Regenerate the INDEX.md file:

adrchive index

adrchive audit

Interactive codebase audit for undocumented decisions:

adrchive audit

ADR Format

adrchive produces MADR 4.0 formatted records with YAML frontmatter:

---
status: draft
date: 2026-04-16
decision-makers: []
tags: [infrastructure, caching]
supersedes: []
links: []
---

# Use Redis for Session Caching

## Context and Problem Statement

We need a caching layer for session data that supports cache invalidation
across multiple application instances.

## Considered Options

- Redis
- Memcached
- In-process cache

## Decision Outcome

Chosen option: "Redis", because it supports pub/sub for cache invalidation
across instances.

### Consequences

- Good, because cache invalidation is straightforward via pub/sub
- Bad, because it adds operational complexity (another service to manage)

Status Lifecycle

Draft --> Proposed --> Accepted
                  \-> Rejected

Accepted --> Deprecated
         \-> Superseded

Once accepted, ADRs are immutable. To change a decision, create a new ADR that supersedes the old one.

Configuration

.adr-config.yml in your project root:

adr_dir: doc/adr                          # where promoted ADRs live
draft_dir: doc/adr/drafts                 # where drafts are written
min_confidence: 0.75                      # classifier confidence threshold
classifier_model: claude-haiku-4-5-20251001  # fast/cheap model for detection
drafter_model: claude-sonnet-4-6-20250514    # thorough model for drafting
min_new_messages: 4                       # minimum new messages before classifying
session_ttl_days: 7                       # cleanup stale session state after N days
suggested_tags:                           # project-specific tag vocabulary
  - infrastructure
  - database
  - api

Development

git clone https://github.com/teczerniec/adrchive.git
cd adrchive
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adrchive-0.2.0.tar.gz (55.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adrchive-0.2.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file adrchive-0.2.0.tar.gz.

File metadata

  • Download URL: adrchive-0.2.0.tar.gz
  • Upload date:
  • Size: 55.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adrchive-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d83b82e94df75caeec59a49fe5a94e09ca9326b6f7f2b6d86c6a2d335339561c
MD5 0245b36ac14c67e9cec94ff45568ddac
BLAKE2b-256 e940275774e8a9becdbe46306323d1d5bd29112ecc47f37c750d88418803ec77

See more details on using hashes here.

Provenance

The following attestation bundles were made for adrchive-0.2.0.tar.gz:

Publisher: release.yml on tecz/adrchive

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adrchive-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: adrchive-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adrchive-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09af7fd772ccdb186651debb894bd36cdf222d1a09e09b08959802e2289af1ca
MD5 3caf48133658133e32da632be5c94f19
BLAKE2b-256 f597fefc4b284107c5a773133a9fd4e46e6b1dabed1260b8632ed261feb23f27

See more details on using hashes here.

Provenance

The following attestation bundles were made for adrchive-0.2.0-py3-none-any.whl:

Publisher: release.yml on tecz/adrchive

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page