code-anchored-context 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,496 +0,0 @@
1
- # Giving AI Agents The Context Around The Code
2
-
3
- AI agents are becoming more capable at reading repositories, editing files,
4
- and following instructions. But in large enterprise codebases, code is not the
5
- whole story.
6
-
7
- The hard part is not whether an agent can change a file. The hard part is
8
- whether it understands the intent behind the change, the current release scope,
9
- the decisions already made, the work deliberately deferred, how the change
10
- should be verified, how it will ship, and what infrastructure or operational
11
- risks surround it.
12
-
13
- That context usually exists somewhere: chats, tickets, pull request comments,
14
- planning notes, architecture discussions, test plans, deployment notes,
15
- infrastructure conversations, and people's heads. The problem is that agents
16
- need this context in a structured, discoverable form.
17
-
18
- This is why I started separating **released product documentation** from
19
- **working context**.
20
-
21
- ```text
22
- docs/
23
- What shipped.
24
-
25
- context/
26
- What we are planning, building, deciding, testing, shipping, hosting,
27
- deferring, and learning.
28
- ```
29
-
30
- Product documentation should stay stable and release-accurate. It should
31
- describe the behavior of a known release, not the current shape of an unfinished
32
- branch.
33
-
34
- Working context is different. It is allowed to evolve. It is where humans
35
- and agents work through ambiguity.
36
-
37
- Over time, I have started thinking about this as **Code-Anchored Context**.
38
-
39
- Not a new methodology. More a rule of thumb.
40
-
41
- Keep truth as close to code as possible, and keep the surrounding context
42
- structured enough that both humans and agents can find it.
43
-
44
- It is opinionated on purpose: prefer repository-local context, explicit
45
- lifetimes, and navigable structure over scattered notes that only make sense to
46
- the people who were in the room. Repository-local context beats private notes
47
- because it scales beyond one person. Shared `.mcp` registrations, machine-independent
48
- continuity, and persisted context snapshots carry decisions forward without
49
- re-compressing them every session, cutting noise while preserving intent.
50
-
51
- One practical benefit is that the reasoning travels with the work.
52
-
53
- When context is materialized in the repository, it stops being tied to one
54
- chat transcript, IDE, agent, or session. A team can switch tools without
55
- losing the trail of why the system is shaped the way it is. The next human or
56
- agent can open the repo, read the working context, and continue from the
57
- same accumulated understanding instead of reconstructing it from memory. That
58
- continuity keeps hours of planning from being lost and makes handoffs between
59
- models and team members materially better.
60
-
61
- ```mermaid
62
- flowchart LR
63
- Code["Codebase<br/>What exists in the system"]
64
- Dev["context/<br/>What is being planned, built, decided, tested, shipped, hosted, deferred, and learned"]
65
- Docs["docs/<br/>What shipped in a known release"]
66
- Agents["Agents and humans<br/>Need context before changing behavior"]
67
-
68
- Agents --> Code
69
- Agents --> Dev
70
- Dev -->|"release-doc-notes.md captures future docs impact"| Docs
71
- Docs -->|"stable release truth"| Agents
72
- ```
73
-
74
- ## The Navigation Problem
75
-
76
- In large repositories, agents and IDEs do not always open the workspace from
77
- the root. They may start in product code, CI/CD config, infrastructure code,
78
- generated artifacts, a specific application, or a nested project folder.
79
-
80
- If all guidance lives at the top, it may be missed. But if each area keeps its
81
- own plans, cross-project work becomes fragmented.
82
-
83
- So the rule became:
84
-
85
- > Denormalize navigation, not knowledge.
86
-
87
- Local `AGENTS.md` files can point agents toward the right place. But plans,
88
- specs, ADRs, release context, testing strategy, delivery notes, and
89
- infrastructure context should live centrally under `context/`.
90
-
91
- ```mermaid
92
- flowchart TD
93
- Root["Repository root"]
94
- AreaA["product area AGENTS.md<br/>local signpost"]
95
- AreaB["delivery area AGENTS.md<br/>local signpost"]
96
- AreaC["nested project AGENTS.md<br/>local signpost"]
97
- Dev["context/<br/>central working context"]
98
- Initiative["Release initiative<br/>single delivery story"]
99
-
100
- Root --> Dev
101
- AreaA --> Dev
102
- AreaB --> Dev
103
- AreaC --> Dev
104
- Dev --> Initiative
105
- ```
106
-
107
- ## The Core Model
108
-
109
- Code-Anchored Context uses explicit terminology, captured in
110
- `context/terminology.md`. That matters because agents need stable
111
- vocabulary as much as humans do.
112
-
113
- The main containers are:
114
-
115
- ```text
116
- Program
117
- Long-lived multi-release effort.
118
-
119
- Planned initiative
120
- A scoped future delivery slice inside a program.
121
-
122
- Release initiative
123
- Active or historical delivery work for a specific release.
124
-
125
- Context backlog item
126
- Isolated work cut from scope but worth preserving.
127
-
128
- Program release slice
129
- A summary of what a release contributes to a program.
130
- ```
131
-
132
- This gives each kind of context a natural home.
133
-
134
- ```text
135
- context/
136
- terminology.md
137
- current.md
138
- programs/
139
- backlog/
140
- releases/
141
- _templates/
142
- ```
143
-
144
- The structure follows delivery concerns, not technologies. A file should be
145
- named for the kind of knowledge it preserves, not for the tool that produced
146
- it.
147
-
148
- ```mermaid
149
- flowchart TD
150
- Current["current.md<br/>active release pointer"]
151
- Release["releases/&lt;version&gt;/<br/>release-scoped context"]
152
- Initiative["initiatives/&lt;initiative&gt;/<br/>active or historical delivery slice"]
153
- Program["programs/&lt;program&gt;/<br/>multi-release context"]
154
- Planned["planned-initiatives/&lt;initiative&gt;/<br/>future scoped program work"]
155
- ProgramSlice["program releases/&lt;version&gt;.md<br/>program release slice"]
156
- Backlog["backlog/items/<br/>deferred isolated work"]
157
-
158
- Current --> Release
159
- Release --> Initiative
160
- Program --> Planned
161
- Program --> ProgramSlice
162
- Planned -.->|"promoted when target release becomes current"| Initiative
163
- Initiative -->|"scope cut, preserved for later"| Backlog
164
- ```
165
-
166
- ## Release Initiatives
167
-
168
- Release initiatives are the main unit of active delivery.
169
-
170
- ```text
171
- context/releases/v0_1_0/initiatives/<initiative>/
172
- README.md
173
- plan.md
174
- spec.md
175
- interface.md
176
- architecture.md
177
- testing.md
178
- delivery.md
179
- infrastructure.md
180
- operations.md
181
- backlog.md
182
- decisions/
183
- release-doc-notes.md
184
- ```
185
-
186
- Even if a change only affects one application, the initiative still lives
187
- centrally. Many meaningful changes eventually touch UI, API, data, tests,
188
- pipelines, deployment, infrastructure, support processes, or release
189
- documentation. Keeping the story together prevents each folder from telling
190
- only part of the truth.
191
-
192
- The most important file is `plan.md`.
193
-
194
- `plan.md` is the working alignment space for humans and agents. It can contain
195
- rough notes, options, questions, tradeoffs, and discussion residue.
196
-
197
- But with one rule:
198
-
199
- > `plan.md` is allowed to be messy, but it must not become the only place where
200
- > settled truth lives.
201
-
202
- Once something stabilizes, it moves into the right durable file:
203
-
204
- ```text
205
- spec.md
206
- What the system should do.
207
-
208
- interface.md
209
- How humans, clients, APIs, config, reports, or tools interact with it.
210
-
211
- architecture.md
212
- Internal shape, boundaries, data flow, contracts, and tradeoffs.
213
-
214
- testing.md
215
- Verification strategy, automated and manual coverage, test data,
216
- release gates, and known gaps.
217
-
218
- delivery.md
219
- CI/CD, build behavior, deployment flow, environment promotion,
220
- release toggles, and delivery automation.
221
-
222
- infrastructure.md
223
- Environment shape, IaC, resources, networking, identity, storage,
224
- secrets, and environment dependencies.
225
-
226
- operations.md
227
- Actionable runtime and support context: observability, failure modes,
228
- rollback, repair, support procedures, and tooling.
229
-
230
- backlog.md
231
- Trackable work items and implementation progress.
232
-
233
- decisions/
234
- Durable decisions and consequences.
235
-
236
- release-doc-notes.md
237
- What should become product documentation later.
238
- ```
239
-
240
- ```mermaid
241
- flowchart TD
242
- Plan["plan.md<br/>working alignment space"]
243
- Stable["Settled truth"]
244
- Spec["spec.md<br/>behavior"]
245
- Interface["interface.md<br/>interaction surface"]
246
- Architecture["architecture.md<br/>internal shape"]
247
- Testing["testing.md<br/>verification"]
248
- Delivery["delivery.md<br/>shipping path"]
249
- Infrastructure["infrastructure.md<br/>hosting dependencies"]
250
- Operations["operations.md<br/>runtime support"]
251
- Backlog["backlog.md<br/>tracked work"]
252
- Decisions["decisions/<br/>ADRs"]
253
- ReleaseDocs["release-doc-notes.md<br/>future product docs"]
254
-
255
- Plan --> Stable
256
- Stable --> Spec
257
- Stable --> Interface
258
- Stable --> Architecture
259
- Stable --> Testing
260
- Stable --> Delivery
261
- Stable --> Infrastructure
262
- Stable --> Operations
263
- Stable --> Backlog
264
- Stable --> Decisions
265
- Stable --> ReleaseDocs
266
- ```
267
-
268
- Not every initiative needs every file. A small UI-only change may not need
269
- infrastructure notes. A backend migration may need detailed testing and
270
- rollback notes. A hosting change may need infrastructure and delivery context
271
- more than interface context.
272
-
273
- The point is not to fill templates for their own sake. The point is to give
274
- stable knowledge a place to land.
275
-
276
- ## Testing, Delivery, And Infrastructure
277
-
278
- The model treats verification, delivery, and infrastructure as first-class
279
- working context.
280
-
281
- That matters because agents often need to answer questions beyond "what code
282
- should change?"
283
-
284
- They also need to know:
285
-
286
- - What proves this is safe to ship?
287
- - Which automated, manual, regression, smoke, contract, or performance tests
288
- matter?
289
- - What test data or environments are required?
290
- - Which gates must pass before merge, deployment, promotion, or release?
291
- - Does the pipeline, build, artifact, deployment order, or environment
292
- promotion flow change?
293
- - Are there feature flags, kill switches, staged rollout controls, or delivery
294
- scripts?
295
- - Does the work require new infrastructure, secrets, identity boundaries,
296
- storage, networking, runtime hosts, or IaC changes?
297
- - Are there provisioning, migration, compatibility, or cleanup constraints?
298
-
299
- Those answers do not belong only in scattered pipeline files, pull requests, or
300
- private memory. They belong near the initiative, where future humans and agents
301
- can find them.
302
-
303
- This also keeps `operations.md` focused. Operations is for actionable runtime
304
- and support context: observability, failure modes, rollback, repair, and
305
- support tooling. Testing, delivery, and infrastructure each have their own home
306
- when those concerns affect how the work is verified, shipped, deployed, or
307
- hosted.
308
-
309
- ```mermaid
310
- flowchart LR
311
- Change["Behavior change"]
312
- Testing["testing.md<br/>How do we prove it?"]
313
- Delivery["delivery.md<br/>How does it ship?"]
314
- Infrastructure["infrastructure.md<br/>Where does it run?"]
315
- Operations["operations.md<br/>How is it supported?"]
316
- Release["Release decision"]
317
-
318
- Change --> Testing
319
- Change --> Delivery
320
- Change --> Infrastructure
321
- Change --> Operations
322
- Testing --> Release
323
- Delivery --> Release
324
- Infrastructure --> Release
325
- Operations --> Release
326
- ```
327
-
328
- ## Programs And Planned Initiatives
329
-
330
- Some work is bigger than one release.
331
-
332
- A program holds durable context for multi-release work:
333
-
334
- ```text
335
- context/programs/<program>/
336
- README.md
337
- context.md
338
- roadmap.md
339
- backlog.md
340
- decisions/
341
- planned-initiatives/
342
- releases/
343
- ```
344
-
345
- A program is where the long arc lives: the roadmap, phase history, durable
346
- decisions, and release-by-release summaries.
347
-
348
- But not all future work should become a release initiative immediately. If a
349
- future phase is clear enough to plan, but the target release is not current
350
- yet, it becomes a planned initiative:
351
-
352
- ```text
353
- context/programs/<program>/planned-initiatives/<initiative>/
354
- ```
355
-
356
- A planned initiative can also preserve future testing, delivery, or
357
- infrastructure intent before the work becomes active. That is useful when the
358
- future phase depends on a migration path, environment readiness, release gates,
359
- or rollout sequencing.
360
-
361
- This solves an important problem. Future work can be preserved without
362
- pretending it is active in the current release.
363
-
364
- When the target release becomes current, the planned initiative is promoted
365
- into:
366
-
367
- ```text
368
- context/releases/<version>/initiatives/<initiative>/
369
- ```
370
-
371
- Promotion is explicit and traceable. The original planned initiative remains
372
- as historical planning context.
373
-
374
- ```mermaid
375
- flowchart LR
376
- Program["Program<br/>durable multi-release effort"]
377
- Planned["Planned initiative<br/>future scoped slice"]
378
- Current["current.md<br/>target release becomes current"]
379
- Release["Release initiative<br/>active delivery slice"]
380
- History["Original planned initiative<br/>kept as historical context"]
381
-
382
- Program --> Planned
383
- Planned --> Current
384
- Current --> Release
385
- Planned --> History
386
- History -.->|"links to promoted initiative"| Release
387
- ```
388
-
389
- ## Context Backlog
390
-
391
- Not every deferred item deserves a program or planned initiative.
392
-
393
- Sometimes work is cut from scope because of risk, timing, or focus, but it is
394
- still worth preserving. That belongs in:
395
-
396
- ```text
397
- context/backlog/items/
398
- <originating-initiative>--<item>.md
399
- ```
400
-
401
- Each item records where it came from, why it was deferred, future value, and
402
- re-entry criteria.
403
-
404
- If it is picked up later, it is marked as promoted and linked to the new
405
- release initiative. It is not silently rewritten.
406
-
407
- ## Release Transitions
408
-
409
- Changing the current release is not just editing a pointer.
410
-
411
- `context/current.md` identifies the active release, but moving from one
412
- release to another is a release transition. During that transition, agents
413
- should scan program planned initiatives, find items targeting the new release,
414
- promote them into the release folder, and update links both ways.
415
-
416
- That makes future planning usable instead of forgotten.
417
-
418
- It also matters for delivery concerns. Planned testing strategy, rollout
419
- constraints, infrastructure prerequisites, and release gates should move into
420
- the active release context when the initiative becomes real delivery work.
421
-
422
- ```mermaid
423
- flowchart TD
424
- Start["Set a new current release"]
425
- Folder["Create release folder if needed"]
426
- Scan["Scan program planned initiatives"]
427
- Match["Find initiatives targeting the new release"]
428
- Promote["Promote into releases/&lt;version&gt;/initiatives/"]
429
- Link["Update links both ways"]
430
- Preserve["Preserve original planned initiative as history"]
431
-
432
- Start --> Folder
433
- Folder --> Scan
434
- Scan --> Match
435
- Match --> Promote
436
- Promote --> Link
437
- Link --> Preserve
438
- ```
439
-
440
- ## Why This Matters
441
-
442
- Code-Anchored Context is not documentation for documentation's sake. It is
443
- context continuity.
444
-
445
- It helps agents and humans answer:
446
-
447
- - What is active now?
448
- - What belongs to a future phase?
449
- - What was cut from scope?
450
- - Why was this decision made?
451
- - Which release owns this work?
452
- - How should this be tested?
453
- - What gates must pass before release?
454
- - How will this be built, deployed, promoted, or rolled out?
455
- - What infrastructure does this depend on?
456
- - What operational risks need support or rollback context?
457
- - What should become product documentation later?
458
- - What should not be changed by accident?
459
- - What reasoning needs to survive a change of IDE, agent, or session?
460
- - What context should travel with the repository instead of a private chat?
461
-
462
- The mental model is simple:
463
-
464
- ```text
465
- docs/
466
- Released truth.
467
-
468
- context/releases/
469
- Release-scoped delivery truth.
470
-
471
- context/programs/
472
- Multi-release truth.
473
-
474
- context/programs/*/planned-initiatives/
475
- Future scoped program work.
476
-
477
- context/backlog/
478
- Deferred isolated work.
479
-
480
- context/terminology.md
481
- Shared vocabulary.
482
-
483
- AGENTS.md
484
- Local signposts for agents.
485
- ```
486
-
487
- Code tells an agent what exists.
488
-
489
- Working context tells it why it exists, where it is going, what has
490
- already been decided, how it should be verified, how it should ship, what
491
- infrastructure it relies on, and what has intentionally been left for later.
492
-
493
- As AI agents become part of normal software delivery, repositories need to
494
- become easier to navigate not only for humans, but for human-agent
495
- collaboration. Code-Anchored Context is one opinionated way to make that
496
- collaboration explicit, durable, and safer.
package/docs/.order DELETED
@@ -1,2 +0,0 @@
1
- Welcome
2
- releases
package/docs/Welcome.md DELETED
@@ -1,48 +0,0 @@
1
- # PROJECT_NAME Docs
2
-
3
- Welcome to the release-anchored documentation for PROJECT_NAME.
4
-
5
- This folder describes shipped behavior for a known release or tag. It is not
6
- the place for in-progress feature planning, implementation notes, or draft
7
- architecture decisions. Put that work in `context/`.
8
-
9
- ## How These Docs Are Organized
10
-
11
- ```text
12
- docs/
13
- .order
14
- Welcome.md
15
- releases/
16
- index.md
17
- _authoring/
18
- README.md
19
- workflow.md
20
- terminology.md
21
- areas/
22
- <area>.md
23
- <Area>/
24
- README.md
25
- features/
26
- <feature>.md
27
- ```
28
-
29
- Every documented area should have:
30
-
31
- - a high-level `README.md` that explains the area's purpose and architecture
32
- - one page per feature under `features/`
33
- - an authoring guide under `docs/_authoring/areas/`
34
-
35
- ## Contributing
36
-
37
- - Refresh docs only when explicitly asked.
38
- - For existing projects with no docs, create baseline documentation only when
39
- explicitly asked; otherwise document touched behavior during future release
40
- refreshes.
41
- - Write for non-developer technical readers unless the project states
42
- otherwise.
43
- - Write from behavior outward: product-readable first, technically anchored
44
- where details affect shipped behavior, operations, or support.
45
- - Describe behavior, inputs, outputs, permissions, errors, business rules, and
46
- operational expectations in domain language.
47
- - Prefer Mermaid diagrams for flows, architecture, and relationships.
48
- - Add release refreshes to `docs/releases/index.md`.