0ef5fcb1c5
Security / Dependency audit (pip-audit) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Security / Secret scan (gitleaks) (push) Has been cancelled
rust / test (ubuntu) (push) Has been cancelled
rust / simulator e2e (macos-latest) (push) Has been cancelled
rust / simulator e2e (ubuntu-latest) (push) Has been cancelled
rust / simulator e2e (windows-latest) (push) Has been cancelled
rust / wheels (aarch64-apple-darwin) (push) Has been cancelled
rust / wheels (x86_64-unknown-linux-gnu) (push) Has been cancelled
rust / wheels (x86_64-apple-darwin) (push) Has been cancelled
rust / audit (push) Has been cancelled
rust / parity (nightly, allowed to fail during Phase 0) (push) Has been cancelled
CI / commitlint (push) Has been skipped
Dev Containers / validate (.devcontainer/devcontainer.json, default) (push) Failing after 0s
Dev Containers / validate (.devcontainer/memory-stack/devcontainer.json, memory-stack) (push) Failing after 0s
Dev Containers / validate-worktree (push) Failing after 0s
CI / changes (push) Failing after 4s
Deploy Documentation / validate (push) Has been skipped
Deploy Documentation / deploy (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, claude) (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, codex) (push) Failing after 1s
Install Native E2E / install-native (ubuntu-latest) (push) Failing after 1s
OpenCode Plugin / typecheck + build + test (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, copilot) (push) Failing after 1s
Release Please / release-please (push) Failing after 1s
Wrap E2E / docker-wrap-e2e (push) Failing after 1s
Wrap Native E2E / wrap-native (ubuntu-latest) (push) Failing after 1s
Init E2E / docker-init-e2e (push) Failing after 4s
Merge Conflicts / merge-conflicts (push) Failing after 4s
CI / lint (push) Has been cancelled
CI / build-wheel (push) Has been cancelled
CI / build-wheel-windows (push) Has been cancelled
CI / prefetch-model (push) Has been cancelled
CI / test-dashboard-ui (push) Has been cancelled
CI / test (1) (push) Has been cancelled
CI / test (2) (push) Has been cancelled
CI / test (3) (push) Has been cancelled
CI / test (4) (push) Has been cancelled
CI / test-extras (push) Has been cancelled
CI / test-agno (push) Has been cancelled
CI / build (push) Has been cancelled
CI / workflow-validation (push) Has been cancelled
CI / docker-native-e2e (push) Has been cancelled
CI / windows-native-wrapper (push) Has been cancelled
CI / macos-native-wrapper (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / promote-latest (push) Has been cancelled
Init Native E2E / init-native (macos-latest, claude) (push) Has been cancelled
Init Native E2E / init-native (macos-latest, codex) (push) Has been cancelled
Init Native E2E / init-native (macos-latest, copilot) (push) Has been cancelled
Install Native E2E / install-native (macos-latest) (push) Has been cancelled
Wrap Native E2E / wrap-native (macos-latest) (push) Has been cancelled
158 lines
5.3 KiB
Plaintext
158 lines
5.3 KiB
Plaintext
---
|
|
title: Failure Learning
|
|
description: Offline failure analysis for coding agents. Analyzes past sessions, finds what went wrong, correlates with what fixed it, and writes project-level learnings.
|
|
---
|
|
|
|
`headroom learn` analyzes past coding agent sessions, finds what went wrong, correlates each failure with what eventually worked, and writes specific project-level learnings that prevent the same mistakes next session.
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# See recommendations for current project (dry-run, no changes)
|
|
headroom learn
|
|
|
|
# Write recommendations to CLAUDE.local.md and MEMORY.md
|
|
headroom learn --apply
|
|
|
|
# Analyze a specific project
|
|
headroom learn --project ~/my-project --apply
|
|
|
|
# Analyze all projects
|
|
headroom learn --all --apply
|
|
|
|
# Write to the team-shared CLAUDE.md instead of CLAUDE.local.md
|
|
headroom learn --apply --target CLAUDE.md
|
|
```
|
|
|
|
## Success Correlation
|
|
|
|
The core innovation. Instead of cataloging failures ("Read failed 5 times"), Headroom finds what the model did to **fix** each failure:
|
|
|
|
- **Failed**: `Read axion-formats/src/main/java/.../FirstClassEntity.java`
|
|
- **Then succeeded**: `Read axion-scala-common/src/main/scala/.../FirstClassEntity.scala`
|
|
- **Learning**: "`FirstClassEntity` is at `axion-scala-common/`, not `axion-formats/`"
|
|
|
|
This produces specific, actionable corrections -- not generic advice.
|
|
|
|
## What It Learns
|
|
|
|
### Environment Facts
|
|
|
|
Which runtime commands work vs fail.
|
|
|
|
```markdown
|
|
### Environment
|
|
- **Python**: use `uv run python` (not `python3` -- modules not available outside venv)
|
|
```
|
|
|
|
### File Path Corrections
|
|
|
|
Wrong paths the model keeps guessing, with the correct locations.
|
|
|
|
```markdown
|
|
### File Path Corrections
|
|
- `axion-common/src/.../AxionSparkConstants.scala`
|
|
-> actually at `axion-spark-common/src/.../AxionSparkConstants.scala`
|
|
```
|
|
|
|
### Search Scope
|
|
|
|
Which directories to search in (narrow paths fail, broader ones work).
|
|
|
|
```markdown
|
|
### Search Scope
|
|
- Don't search `axion-model/` -> use `axion/` (the repo root)
|
|
```
|
|
|
|
### Command Patterns
|
|
|
|
How commands should (and should not) be run.
|
|
|
|
```markdown
|
|
### Command Patterns
|
|
- **user_prefers_manual**: User rejected gradle 18 times -- show the command, don't execute
|
|
- **python_runtime**: Use `uv run python` not `python3` (ModuleNotFoundError)
|
|
```
|
|
|
|
### Known Large Files
|
|
|
|
Files that need `offset`/`limit` with Read.
|
|
|
|
```markdown
|
|
### Known Large Files
|
|
- `proxy/server.py` (~8000 lines) -- always use offset/limit
|
|
```
|
|
|
|
## Where Learnings Go
|
|
|
|
| Pattern | Destination | Why |
|
|
|---------|-------------|-----|
|
|
| Environment, paths, search scope, commands, large files | **CLAUDE.local.md** | Personal facts (machine-specific paths), gitignored by default |
|
|
| Missing paths, retry patterns, permissions | **MEMORY.md** | May change, agent-specific |
|
|
|
|
`CLAUDE.local.md` lives in your project directory. It is the **personal** local
|
|
memory file in Claude Code's [memory convention](https://docs.claude.com/en/docs/claude-code/memory)
|
|
— meant to be gitignored — so machine-specific learnings (absolute paths,
|
|
tool-discovery byproducts) don't pollute the team-shared `CLAUDE.md`. Make sure
|
|
`CLAUDE.local.md` is listed in your `.gitignore`. Pass `--target CLAUDE.md` to
|
|
opt into the shared file instead, or `--target <path>` for any custom location.
|
|
MEMORY.md lives in `~/.claude/projects/*/memory/`.
|
|
|
|
If an older Headroom version already wrote a learned-patterns block into your
|
|
team-shared `CLAUDE.md`, the next `headroom learn --apply` moves it into
|
|
`CLAUDE.local.md` and prints a warning so you can review the diff before
|
|
committing. If `CLAUDE.md` contained nothing but the Headroom block, it is
|
|
removed entirely.
|
|
|
|
## Marker-Based Updates
|
|
|
|
Headroom manages a clearly-delimited section in each file:
|
|
|
|
```markdown
|
|
<!-- headroom:learn:start -->
|
|
## Headroom Learned Patterns
|
|
*Auto-generated by `headroom learn` -- do not edit manually*
|
|
...
|
|
<!-- headroom:learn:end -->
|
|
```
|
|
|
|
On re-run, only the content between markers is replaced. Your existing file content is preserved.
|
|
|
|
## Architecture
|
|
|
|
The system is built with an adapter pattern so it can support multiple agent systems:
|
|
|
|
- **Scanners** read tool-specific log formats (e.g., `~/.claude/projects/*.jsonl`) and produce normalized `ToolCall` sequences
|
|
- **Analyzers** work on `ToolCall` data -- same analysis logic for any agent system
|
|
- **Writers** output to tool-specific context injection mechanisms (e.g., CLAUDE.md)
|
|
|
|
To add support for a new agent (e.g., Cursor), you write a Scanner that reads its log format and a Writer that outputs to `.cursorrules`. The analyzers stay the same.
|
|
|
|
## CLI Reference
|
|
|
|
```bash
|
|
headroom learn [OPTIONS]
|
|
|
|
Options:
|
|
--project PATH Project directory to analyze (default: current directory)
|
|
--all Analyze all discovered projects
|
|
--apply Write recommendations (default: dry-run)
|
|
--target TEXT Context file to write to, Claude Code only (default:
|
|
CLAUDE.local.md). Relative to project root, or absolute.
|
|
--agent TEXT Agent to analyze (e.g. claude, codex, gemini, opencode)
|
|
--model TEXT LLM model to use for analysis
|
|
--workers INT Number of parallel workers
|
|
```
|
|
|
|
## Real-World Results
|
|
|
|
Tested on 67,583 tool calls across 23 projects:
|
|
|
|
| Metric | Value |
|
|
|--------|-------|
|
|
| Failure rate | 7.5% (5,066 failures) |
|
|
| Corrections extracted | 164 per project (avg) |
|
|
| Path corrections | 22 (axion project) |
|
|
| Search scope corrections | 24 (axion project) |
|
|
| Command patterns learned | 5 (axion project) |
|