Skip to content

Commit f71d8ce

Browse files
Claudeclaude
authored andcommitted
feat: add docs examples section with first scar story (OD-741)
Add Examples section to Fumadocs showing real anonymized scar application stories. First example: "The Silent Migration" — a migration CLI silently reads the wrong directory, and institutional memory catches it before production corruption. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9b7be3e commit f71d8ce

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Examples
3+
description: Real stories of institutional memory preventing mistakes.
4+
---
5+
6+
# Examples
7+
8+
These are real stories from production AI agent workflows — anonymized, but not invented. Each one follows the same arc:
9+
10+
1. **The Situation** — An agent hits a problem during real work
11+
2. **The Scar** — The lesson is captured as institutional memory
12+
3. **The Save** — In a later session, `recall` surfaces the scar before the agent repeats the mistake
13+
4. **The Takeaway** — What makes this pattern worth remembering
14+
15+
Every example includes actual (anonymized) snippets: the scar JSON that was created, the recall output that surfaced it, and the `confirm_scars` response that acknowledged it.
16+
17+
## Why Examples Matter
18+
19+
GitMem's value isn't theoretical. It's concrete: a warning that appears at exactly the right moment, written by a past version of you (or your team) who already made the mistake.
20+
21+
These stories show that loop in action.
22+
23+
## Available Examples
24+
25+
- [The Silent Migration](/docs/examples/silent-migration-wrong-directory) — A CLI tool silently reads the wrong directory, and institutional memory catches it before a database gets corrupted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Examples",
3+
"pages": ["index", "silent-migration-wrong-directory"]
4+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: "The Silent Migration"
3+
description: A database migration CLI silently reads the wrong directory. Institutional memory catches it before production gets corrupted.
4+
---
5+
6+
# The Silent Migration
7+
8+
A migration CLI runs without error — but it's reading the wrong directory. No warning, no failure, just the wrong migrations applied to a production database. This is the kind of bug that doesn't announce itself until the damage is done.
9+
10+
## The Situation
11+
12+
A team manages a monorepo with two services that share the same database:
13+
14+
```
15+
my-project/
16+
├── backend/
17+
│ └── migrations/ # 12 migration files
18+
└── services/
19+
└── migrations/ # 3 migration files
20+
```
21+
22+
Both directories contain migrations targeting the same database. The migration CLI determines which migrations to apply based on the current working directory — it looks for a `migrations/` folder relative to where you run the command.
23+
24+
An agent working on a deployment task ran:
25+
26+
```bash
27+
cd /workspace/my-project/services
28+
db-migrate push --linked
29+
```
30+
31+
The CLI found 3 migrations in `services/migrations/` and compared them against the 12 remote migrations already applied. It printed:
32+
33+
```
34+
Error: Remote migration versions not found in local migrations directory
35+
```
36+
37+
The agent spent 20 minutes investigating — checking remote state, comparing version hashes, verifying database connectivity. The actual problem? It was running from the wrong directory. The 12 migrations it needed were in `backend/migrations/`, not `services/migrations/`.
38+
39+
The fix was one command:
40+
41+
```bash
42+
cd /workspace/my-project/backend
43+
db-migrate push --linked
44+
# ✅ All 12 migrations found, push successful
45+
```
46+
47+
## The Scar
48+
49+
After the incident, the agent created this scar:
50+
51+
```json
52+
{
53+
"learning_type": "scar",
54+
"title": "db-migrate push from wrong CWD silently reads the wrong migrations directory",
55+
"description": "When backend/migrations/ and services/migrations/ both target the same database, running db-migrate push from the wrong directory causes it to read the wrong migrations. The CLI uses migrations/ relative to CWD, not an absolute path. This produced a confusing 'Remote migration versions not found' error. The fix was simply running from the correct directory.",
56+
"severity": "medium",
57+
"scar_type": "process",
58+
"counter_arguments": [
59+
"You might think db-migrate push uses the linked project ref to determine which migrations to read — but the project ref only determines the remote target. Local migration discovery is purely CWD-based.",
60+
"You might think the error message 'Remote versions not found' means the remote has unknown migrations — but it can also mean you're looking at the wrong local directory."
61+
]
62+
}
63+
```
64+
65+
Two things make this scar effective:
66+
67+
1. **The counter-arguments pre-empt the exact wrong assumptions** the agent made during the incident. "You might think the project ref determines which migrations to read" — that's exactly what it thought, and exactly what's wrong.
68+
69+
2. **The title includes the mechanism** (`from wrong CWD`) not just the symptom. This makes it findable when a future agent plans any migration-related work.
70+
71+
## The Save
72+
73+
Three weeks later, a different session picked up a database migration task. The agent called `recall` before starting:
74+
75+
```
76+
recall({ plan: "run database migration for new user fields" })
77+
```
78+
79+
GitMem surfaced the scar:
80+
81+
```
82+
🧠 INSTITUTIONAL MEMORY ACTIVATED
83+
84+
Found 2 relevant scars for your plan:
85+
86+
🟡 db-migrate push from wrong CWD silently reads the wrong
87+
migrations directory (medium, score: 0.74)
88+
When backend/migrations/ and services/migrations/ both target
89+
the same database, running db-migrate push from the wrong
90+
directory causes it to read the wrong migrations...
91+
```
92+
93+
The agent confirmed the scar before proceeding:
94+
95+
```
96+
confirm_scars([{
97+
scar_id: "...",
98+
decision: "APPLYING",
99+
evidence: "Verified CWD is /workspace/my-project/backend before running db-migrate push. Confirmed 12 migration files visible in backend/migrations/.",
100+
relevance: "high"
101+
}])
102+
```
103+
104+
The agent explicitly checked its working directory, confirmed the right migrations were visible, and then ran the command. No 20-minute debugging session. No risk of applying the wrong migrations to production.
105+
106+
## The Takeaway
107+
108+
This example shows three properties of effective institutional memory:
109+
110+
**Silent failures are the most valuable scars.** The migration CLI didn't crash — it ran successfully against the wrong data. These bugs don't leave stack traces. They leave corrupted databases. A scar is the only thing standing between "it worked" and "it worked on the wrong thing."
111+
112+
**Counter-arguments encode the debugging dead ends.** The two counter-arguments in this scar document the exact wrong mental models that led to the 20-minute investigation. Future agents skip those dead ends entirely because the scar says "you might think X — but actually Y."
113+
114+
**The confirm protocol forces verification.** The agent didn't just see the scar and move on. The `APPLYING` decision required past-tense evidence: "Verified CWD is `/workspace/my-project/backend`." This turns a warning into a checklist item with proof of compliance.

apps/docs/content/docs/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"concepts",
66
"tools",
77
"guides",
8+
"examples",
89
"contributing",
910
"changelog"
1011
]

0 commit comments

Comments
 (0)