Skip to content

Commit 9f10330

Browse files
committed
docs(readme): updating readme
## Summary Re-center the README around the actual product: repo-native decision context for coding agents. ## Changes - move the agent workflow and trust model to the top of the document - clarify why code and tests alone are insufficient for agents - reorder demos and quick start around the primary agent workflow ## Testing - README update only
1 parent 16467c4 commit 9f10330

1 file changed

Lines changed: 74 additions & 61 deletions

File tree

README.md

Lines changed: 74 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# codecontext
22

3-
Decision context attached to code, with freshness checks when code changes.
3+
Repo-native decision context for coding agents, with freshness checks when code changes.
44

55
---
66

77
## The One-Character Bug That Cost $12,000
88

9-
Someone changed `>` to `>=`. Tests were green. Review was green. Deploy was green.
9+
An agent or engineer saw `>` and "cleaned it up" to `>=`. Tests were green. Review was green. Deploy was green.
1010

1111
Three days later, 0.3% of transactions started processing twice. The payment gateway sometimes emits timestamps exactly on the cutoff boundary during clock-skew windows. The original author knew that. `>` was not an accident. But the reason was trapped in an 8-month-old commit message buried under 47 more commits.
1212

@@ -27,17 +27,68 @@ Now the constraint is visible before anyone edits the code, human or agent. If s
2727

2828
A test would help, and you should still want one. But tests and context do different jobs. A test proves that `>=` breaks behavior only if someone already wrote the exact boundary-case test. `@context` explains why the odd-looking `>` is intentional before an editor, reviewer, or agent "cleans it up." Tests protect behavior. `@context` protects intent.
2929

30-
### Why Not Just Tests?
30+
Agents can read code and tests, but they still miss intent when the rationale is trapped in history instead of attached to the line they are editing.
31+
32+
### Why Code And Tests Are Not Enough For Agents
3133

3234
Because tests and decision context solve different problems.
3335

3436
- Tests tell you whether behavior is correct.
3537
- `@context` tells you why surprising-looking behavior is intentional.
3638
- Tests usually fail after someone changed the code.
3739
- `@context` shows up while they are editing the line, reading the diff, or reviewing the change.
40+
- Agents can read both code and tests, but they do not reliably reconstruct historical rationale from them.
3841

3942
Good teams want both: tests to protect behavior, and attached context to protect intent.
4043

44+
## Agent Workflow
45+
46+
This is the core loop:
47+
48+
```
49+
1. Brief the agent before edits
50+
2. Let it change code
51+
3. Check whether it invalidated attached decisions
52+
4. Force re-verification before the change lands
53+
```
54+
55+
In practice:
56+
57+
```bash
58+
$ npx codecontext --scope src/payments/gateway.ts
59+
$ <agent reads file and edits>
60+
$ npx codecontext --diff HEAD src/payments/gateway.ts
61+
```
62+
63+
The `--json` flag produces structured output that agents and tools can consume directly:
64+
65+
```bash
66+
$ npx codecontext --scope src/payments/gateway.ts --json
67+
```
68+
69+
```json
70+
{
71+
"file": "src/payments/gateway.ts",
72+
"entries": [
73+
{
74+
"line": 42,
75+
"type": "decision",
76+
"id": "docs/context/gate-42.md",
77+
"priority": "critical",
78+
"status": "verified",
79+
"summary": "strict > (not >=): upstream sends at-threshold values during clock skew",
80+
"ctxFile": {
81+
"body": "## Decision\n\nUse strict greater-than...",
82+
"verified": "2025-11-15",
83+
"traces": ["JIRA-1234", "INCIDENT-5678"]
84+
}
85+
}
86+
]
87+
}
88+
```
89+
90+
The trust model is simple: the context is repo-native, versioned, reviewable in PRs, visible in diffs, and enforceable in hooks and lint. That makes it far more durable for agents than rationale hidden in commit archaeology, external docs, or memory files.
91+
4192
## Why Everything Else Falls Short
4293

4394
You already have places to store decisions. They mostly fail at one job: **showing up at the exact moment someone is about to break the code.**
@@ -151,62 +202,21 @@ Examples live in [`examples/`](examples/) and include both TypeScript and Go sou
151202

152203
## Terminal Demos
153204

154-
If you want to see the workflow before reading the rest, these three short demos show the briefing, registry, and freshness gate.
205+
If you want to see the workflow before reading the rest, these three short demos show the briefing, freshness gate, and registry.
155206

156207
These demos are generated from source-controlled VHS tapes in [`docs/demos/tapes/`](docs/demos/tapes/) and can be re-rendered with `pnpm demo:render`.
157208

158209
### Scope briefing
159210

160211
![Scope briefing demo](docs/demos/gifs/scope.gif)
161212

162-
### Decision registry
163-
164-
![Decision registry demo](docs/demos/gifs/report.gif)
165-
166213
### Freshness gate after a code change
167214

168215
![Freshness gate demo](docs/demos/gifs/stale-check.gif)
169216

170-
## Agent Workflow
171-
172-
Coding agents are powerful but context-poor. They read code, but not the decision chain that made the code look this way. They see `>` and have no native way to know it is load-bearing.
173-
174-
codecontext gives them a simple briefing loop:
175-
176-
```
177-
Agent workflow:
178-
1. npx codecontext --scope <file> ← "what should I know?"
179-
2. Read the file ← "now I'll read the code"
180-
3. Make changes ← "informed by context"
181-
4. npx codecontext --diff HEAD <file> ← "did I break any decisions?"
182-
```
183-
184-
The `--json` flag produces structured output that agents and tools can consume directly:
185-
186-
```bash
187-
$ npx codecontext --scope src/payments/gateway.ts --json
188-
```
217+
### Decision registry
189218

190-
```json
191-
{
192-
"file": "src/payments/gateway.ts",
193-
"entries": [
194-
{
195-
"line": 42,
196-
"type": "decision",
197-
"id": "docs/context/gate-42.md",
198-
"priority": "critical",
199-
"status": "verified",
200-
"summary": "strict > (not >=): upstream sends at-threshold values during clock skew",
201-
"ctxFile": {
202-
"body": "## Decision\n\nUse strict greater-than...",
203-
"verified": "2025-11-15",
204-
"traces": ["JIRA-1234", "INCIDENT-5678"]
205-
}
206-
}
207-
]
208-
}
209-
```
219+
![Decision registry demo](docs/demos/gifs/report.gif)
210220

211221
A Claude skill is included in `skills/codecontext/` to automate this workflow: read context before edits, check invalidation after edits, and maintain annotations as code evolves.
212222

@@ -401,7 +411,20 @@ pnpm add -D @recallnet/codecontext-eslint-plugin
401411
pnpm add -D @recallnet/codecontext-tsdoc
402412
```
403413

404-
### 3. Configure ESLint (optional)
414+
### 3. Run the core agent loop
415+
416+
```bash
417+
# Brief the agent before editing
418+
npx codecontext --scope src/your-file.ts
419+
420+
# Check intent after editing
421+
npx codecontext --diff HEAD src/your-file.ts
422+
423+
# Enforce freshness in hooks
424+
npx codecontext --staged
425+
```
426+
427+
### 4. Configure ESLint (optional)
405428

406429
```javascript
407430
// eslint.config.js
@@ -413,13 +436,13 @@ export default [
413436
];
414437
```
415438

416-
### 4. Create context directory
439+
### 5. Create context directory
417440

418441
```bash
419442
mkdir -p docs/context
420443
```
421444

422-
### 5. Configure TSDoc (optional)
445+
### 6. Configure TSDoc (optional)
423446

424447
```json
425448
{
@@ -428,22 +451,12 @@ mkdir -p docs/context
428451
}
429452
```
430453

431-
### 6. Add your first `@context` tag
454+
### 7. Add your first `@context` tag
432455

433456
```typescript
434457
// @context decision !high — chose approach A over B because of X
435458
```
436459

437-
### 7. Run the CLI
438-
439-
```bash
440-
# Briefing before editing
441-
npx codecontext --scope src/your-file.ts
442-
443-
# Check after editing
444-
npx codecontext --diff HEAD src/your-file.ts
445-
```
446-
447460
### Pre-commit hook (recommended)
448461

449462
```bash

0 commit comments

Comments
 (0)