diff --git a/.claude/skills/_ctx-qa/SKILL.md b/.claude/skills/_ctx-qa/SKILL.md index 1e3352e18..46ed228a3 100644 --- a/.claude/skills/_ctx-qa/SKILL.md +++ b/.claude/skills/_ctx-qa/SKILL.md @@ -76,7 +76,7 @@ make smoke ``` Builds the binary and exercises `ctx init`, `ctx status`, -`ctx agent`, `ctx drift`, `ctx add task`, and +`ctx agent`, `ctx drift`, `ctx task add`, and `ctx journal source` in a temporary directory. ## Shortcut diff --git a/.context/AGENT_PLAYBOOK.md b/.context/AGENT_PLAYBOOK.md index 6ba48fe9c..ab3aab9a7 100644 --- a/.context/AGENT_PLAYBOOK.md +++ b/.context/AGENT_PLAYBOOK.md @@ -261,7 +261,7 @@ Track task progress with timestamps for session correlation: | Tag | When to Add | Format | |------------|------------------------------------------|----------------------| -| `#added` | Auto-added by `ctx add task` | `YYYY-MM-DD-HHMMSS` | +| `#added` | Auto-added by `ctx task add` | `YYYY-MM-DD-HHMMSS` | | `#started` | When you begin working on the task | `YYYY-MM-DD-HHMMSS` | ## Collaboration Defaults diff --git a/.context/CONVENTIONS.md b/.context/CONVENTIONS.md index adf3d8624..de39c8fea 100644 --- a/.context/CONVENTIONS.md +++ b/.context/CONVENTIONS.md @@ -26,9 +26,39 @@ DO NOT UPDATE FOR: - **Maps reference constants**: Use constants as keys, not literals - `map[string]X{ConstKey: value}` not `map[string]X{"literal": value}` +## Casing + +- **Proper nouns keep their casing** in comments, strings, and docs + - `Markdown` not `markdown` (it's a language name) + - `YAML`, `JSON`, `TOML` — always uppercase + - `GitHub`, `JavaScript`, `PostgreSQL` — match official casing + - Exception: code fence language identifiers are lowercase (`` ```markdown ``) + +## Predicates + +- **No Is/Has/Can prefixes**: `Completed()` not + `IsCompleted()`, `Empty()` not `IsEmpty()` +- Applies to exported methods that return bool +- Private helpers may use prefixes when it reads more naturally + +## File Organization + +- **Public API in main file, private helpers in separate logical files** + - `loader.go` (exports `Load()`) + `process.go` (unexported helpers) + - NOT: one file with unexported functions stacked at the bottom +- Reasoning: agent loads only the public API file unless + it needs implementation detail +- **Name files after what they contain, not their role** + - `format.go`, `sort.go`, `parse.go` — named by responsibility + - NOT: `util.go`, `utils.go`, `helper.go`, `common.go` — junk drawer names + - If a file can't be named without a generic label, + its contents don't belong together + - Existing junk drawers should be split as their contents grow + ## Patterns -- **Centralize magic strings**: All repeated literals belong in a `config` or `constants` package +- **Centralize magic strings**: All repeated literals + belong in a `config` or `constants` package - If a string appears in 3+ files, it needs a constant - If a string is used for comparison, it needs a constant - **Path construction**: Always use stdlib path joining @@ -37,19 +67,75 @@ DO NOT UPDATE FOR: - Node: `path.join(dir, file)` - Never: `dir + "/" + file` - **Constants reference constants**: Self-referential definitions - - `FileType[UpdateTypeTask] = FilenameTask` not `FileType["task"] = "TASKS.md"` + - `FileType[UpdateTypeTask] = FilenameTask` not + `FileType["task"] = "TASKS.md"` +- **No error variable shadowing**: Use descriptive names + when multiple errors exist in a function + - `readErr`, `writeErr`, `indexErr` — not repeated `err` / `err :=` + - Shadowed `err` silently disconnects from the outer + variable, causing subtle bugs - **Colocate related code**: Group by feature, not by type - `session/run.go`, `session/types.go`, `session/parse.go` - Not: `runners/session.go`, `types/session.go`, `parsers/session.go` +## Line Width + +- **Target ~80 characters**: Highly encouraged, not a hard limit + - Some lines will naturally exceed it (long strings, + struct tags, URLs) — that's fine + - Drift accumulates silently, especially in test code + - Break at natural points: function arguments, struct fields, chained calls + +## Duplication + +- **Non-test code**: Apply the rule of three — extract + when a block appears 3+ times + - Watch for copy-paste during task-focused sessions + where the agent prioritizes completion over shape +- **Test code**: Some duplication is acceptable for readability + - When the same setup/assertion block appears 3+ times, extract a test helper + - Use `t.Helper()` so failure messages point to the caller, not the helper + ## Testing - **Colocate tests**: Test files live next to source files - `foo.go` → `foo_test.go` in same package - Not a separate `tests/` folder -- **Test the unit, not the file**: One test file can test multiple related functions +- **Test the unit, not the file**: One test file can test + multiple related functions - **Integration tests are separate**: `cli_test.go` for end-to-end binary tests +## Code Change Heuristics + +- **Present interpretations, don't pick silently**: If a request has multiple + valid readings, lay them out rather than guessing +- **Push back when warranted**: If a simpler approach exists, say so +- **"Would a senior engineer call this overcomplicated?"**: If yes, simplify +- **Match existing style**: Even if you'd write it differently in a greenfield +- **Every changed line traces to the request**: If it doesn't, revert it + +## Decision Heuristics + +- **"Would I start this today?"**: If not, continuing is + the sunk cost — evaluate only future value +- **"Reversible or one-way door?"**: Reversible decisions + don't need deep analysis +- **"Does the analysis cost more than the decision?"**: + Stop deliberating when the options are within an order + of magnitude +- **"Order of magnitude, not precision"**: 10x better + matters; 10% better usually doesn't + +## Refactoring + +- **Measure the end state, not the effort**: When refactoring, ask what the + codebase looks like *after*, not how much work the change is +- **Three questions before restructuring**: + 1. What's the smallest codebase that solves this? + 2. Does the proposed change result in less total code? + 3. What can we delete now that this change makes obsolete? +- **Deletion is a feature**: Writing 50 lines that delete 200 is a net win + ## Documentation - **Godoc format**: Use canonical sections @@ -66,5 +152,121 @@ DO NOT UPDATE FOR: // - Type: Description of return value func FunctionName(param1, param2 string) error ``` -- **Package doc in doc.go**: Each package gets a `doc.go` with package-level documentation +- **Struct field documentation**: Exported structs with 2+ fields + must document every field. Two accepted forms: + ```go + // Option A: Fields section in docblock (preferred for 4+ fields) + // TypeName describes X. + // + // Fields: + // - FieldA: Description + // - FieldB: Description + type TypeName struct { + + // Option B: Inline comments (acceptable for 2-3 fields) + // TypeName describes X. + type TypeName struct { + // FieldA is the description. + FieldA string + FieldB string // Description + } + ``` +- **Package doc in doc.go**: Each package gets a `doc.go` with package-level + documentation describing behavior, not structure. Do NOT include + `# File Organization` sections listing files — they drift when files are + added, renamed, or removed, and the filesystem is self-documenting - **Copyright headers**: All source files get the project copyright header + +## Blog Publishing + +- **Checklist for ideas/ → docs/blog/ promotion**: + 1. Update date in frontmatter to publish date + 2. Fix relative paths (from `../docs/blog/` to peer references) + 3. Add cross-links to/from companion posts ("See also" sections) + 4. Add "The Arc" section connecting to the series narrative + 5. Update `docs/blog/index.md` with entry (newest first) + 6. Verify all link targets exist + 7. Build and test before commit +- **Arc section**: Every post includes "The Arc" near the end, framing + where the post sits in the broader blog narrative +- **See also links**: Use italic `*See also: [Title](file) -- one-line + description connecting the two posts.*` format at the end of posts +- **Frontmatter**: Include copyright header, title, date, author, topics list +- **Blog index order**: Newest post first, with topic tags and 3-4 line summary + +- **Update admonitions for historical blog content**: Use MkDocs admonitions + (`!!! note "Update"`) at the top of blog post sections where features have + been superseded or installation has changed. Link to current documentation. + Keep original content intact below for historical context. +- **New CLI subcommand documentation checklist**: Update docs in at least + three places: (1) Feature page — commands table, usage section, skill/NL + table. (2) CLI reference — full reference entry with args, flags, examples. + (3) Relevant recipes. (4) zensical.toml — only if adding a new page. +- **Rename/refactor documentation checklist**: Scope ALL documentation impact + before implementation. Three anchors plus one tangential: (1) Docstrings. + (2) User-facing docs (`docs/`). (3) Recipes (`docs/recipes/`). (4) Blog + posts and release notes. Also check: skills, hook messages, YAML text + files, `.context/` files, and specs. +- **Stage site/ with docs/ changes**: The generated HTML is tracked in git + with no CI build step + +## Error Handling + +- **Zero silent error discard**: Handle every error, never suppress with + `_ =` or `//nolint:errcheck`. Production: defer-close logs to stderr + via `log.Warn()`. Test: `t.Fatal(err)` for setup, `t.Log(err)` for + cleanup. For gosec false positives: fix the code rather than adding + nolint markers — the goal is zero golangci-lint suppressions +- **Error constructors in internal/err**: Never in per-package err.go + files — eliminates the broken-window pattern where agents add local + errors when they see a local err.go exists + +## CLI Structure + +- **CLI package taxonomy**: Every package under `internal/cli/` follows: + parent.go (Cmd wiring), doc.go, `cmd/root/` or `cmd//` + (implementation), `core/` (shared helpers) +- **cmd/ directories**: Only cmd.go, run.go, and tests — helpers and + output go to `core/` +- **core/ structs**: Consolidated into a single `types.go` file +- **User-facing text via assets**: All text routed through + `internal/assets` with YAML-backed TextDescKeys — no inline strings + in `core/` or `cmd/` packages +- **config/ doc.go**: Every package under `internal/config/` must have + a doc.go with the project header and a one-line package comment +- **DescKey prefix**: Not CmdDescKey — `cmd.DescKeyFoo` not + `cmd.CmdDescKeyFoo` (Go package hygiene, avoids stutter) +- **Cobra Use: fields**: Must reference `cmd.Use*` constants, never raw + strings or `cmd.DescKey*` +- **Run functions exported PascalCase**: `Run`, `RunImport`, + `RunArchive` etc. No private `runXXX` variants +- **write/ packages write to stdio only**: Functions take + `*cobra.Command`, not `io.Writer`. Exception: `write/rc` writes to + `os.Stderr` because rc loads before cobra +- **Package directory names singular**: Unless Go convention requires + plural +- **Import grouping**: stdlib — blank line — external deps (cobra, + yaml) — blank line — ctx imports. Three groups, always in this order +- **camelCase import aliases**: `cFlag` not `cflag`, `cfgFmt` not + `cfgfmt` +- **Icons and symbols as token constants**: Not unicode escapes +- **Cross-cutting domain types in internal/entity**: Types used by one + package stay in that package; types used across packages go to entity + +- Warn format strings centralized in config/warn/ — use warn.Close, + warn.Write, warn.Remove, warn.Mkdir, warn.Rename, warn.Walk, warn.Getwd, + warn.Readdir, warn.Marshal instead of inline format strings in log.Warn calls + +- Nav frontmatter title: fields must not contain ctx — frontmatter does not + support backticks, so the brand stays out of nav titles entirely (Hub, not The + ctx Hub). Body headings can use `ctx` since markdown supports backticks. + +- CLI flags and slash-commands inside headings or admonition titles must be + backticked: `--keep-frontmatter=false`, `/ctx-reflect`. The title-case engine + in hack/title-case-headings.py protects these patterns automatically, but + authors should still backtick at write time for clarity. + +- File extensions inside headings must be backticked when title-case + capitalization would otherwise apply: write `CONSTITUTION.md`, not + CONSTITUTION.Md. The title-case engine refuses to capitalize lowercase tokens + following a literal . dot, but explicit backticks remain the clearest signal. diff --git a/.context/DECISIONS.md b/.context/DECISIONS.md index 557f48513..7a09107c5 100644 --- a/.context/DECISIONS.md +++ b/.context/DECISIONS.md @@ -3,6 +3,82 @@ | Date | Decision | |----|--------| +| 2026-04-16 | Deprecate and remove ctx backup | +| 2026-04-14 | doc.go quality floor: behavior-grounded, ~25-100 body lines, related-packages section required | +| 2026-04-14 | Bootstrap stays under ctx system bootstrap (reverted experimental top-level promotion) | +| 2026-04-14 | Title Case style for docs is AP-leaning with explicit ambiguity carve-outs | +| 2026-04-13 | Walk boundary uses git as a hint, not a requirement | +| 2026-04-11 | Journal stays local; LEARNINGS.md is the shareable layer | +| 2026-04-11 | `Entry.Author` is server-authoritative, not client-authoritative | +| 2026-04-09 | Architecture skill pipeline is a triad not a quartet | +| 2026-04-08 | Remove #done tag convention, simplify task archival | +| 2026-04-06 | Use hook relay for session provenance instead of JSONL parsing or env vars | +| 2026-04-04 | TestNoMagicStrings and TestNoMagicValues no longer exempt const/var definitions outside config/ | +| 2026-04-04 | String-typed enums belong in config/, not domain packages | +| 2026-04-03 | Output functions belong in write/ (consolidated) | +| 2026-04-03 | YAML text externalization pipeline (consolidated) | +| 2026-04-03 | Package taxonomy and code placement (consolidated) | +| 2026-04-03 | Eager init over lazy loading (consolidated) | +| 2026-04-03 | Pure logic separation of concerns (consolidated) | +| 2026-04-03 | config/ explosion is correct — fix is documentation, not restructuring | +| 2026-04-01 | IRC to Discord as primary community channel | +| 2026-04-01 | AST audit tests live in internal/audit/, one file per check | +| 2026-04-01 | Split assets/hooks/ into assets/integrations/ + assets/hooks/messages/ | +| 2026-04-01 | Rename ctx hook → ctx setup to disambiguate from the hook system | +| 2026-03-31 | Split log into log/event and log/warn to break import cycles | +| 2026-03-31 | Context-load-gate injects only CONSTITUTION and AGENT_PLAYBOOK_GATE, not full ReadOrder | +| 2026-03-31 | Spec signal words and nudge threshold are user-configurable via .ctxrc | +| 2026-03-30 | Flags-not-subcommands for journal source: list and show are view modes on a noun, not independent entities | +| 2026-03-30 | Journal consumed recall — recall CLI package deleted | +| 2026-03-30 | Classify rules are user-configurable via .ctxrc | +| 2026-03-25 | Architecture analysis and enrichment are separate skills — constraint is the feature | +| 2026-03-25 | Companion tools documented as optional MCP enhancements with runtime check | +| 2026-03-25 | Prompt templates removed — skills are the single agent instruction mechanism | +| 2026-03-24 | Write-once baseline with explicit end-consolidation for consolidation lifecycle | +| 2026-03-23 | Pre/pre HTML tags promoted to shared constants in config/marker | +| 2026-03-22 | Output functions belong in write/, never in core/ or cmd/ | +| 2026-03-20 | Shared formatting utilities belong in internal/format | +| 2026-03-20 | Go-YAML linkage check added to lint-drift as check 5 | +| 2026-03-18 | Singular command names for all CLI entities | +| 2026-03-17 | Pre-compute-then-print for write package output blocks | +| 2026-03-16 | Resource name constants in config/mcp/resource, mapping in server/resource | +| 2026-03-16 | Rename --consequences flag to --consequence for singular consistency | +| 2026-03-14 | Error package taxonomy: 22 domain files replace monolithic errors.go | +| 2026-03-14 | Session prefixes are parser vocabulary, not i18n text | +| 2026-03-14 | System path deny-list as safety net, not security boundary | +| 2026-03-14 | Config-driven freshness check with per-file review URLs | +| 2026-03-13 | Delete ctx-context-monitor skill — hook output is self-sufficient | +| 2026-03-13 | build target depends on sync-why to prevent embedded doc drift | +| 2026-03-12 | Recommend companion RAGs as peer MCP servers not bridge through ctx | +| 2026-03-12 | Rename ctx-map skill to ctx-architecture | +| 2026-03-07 | Use composite directory path constants for multi-segment paths | +| 2026-03-06 | Drop fatih/color dependency — Unicode symbols are sufficient for terminal output, color was redundant | +| 2026-03-06 | PR #27 (MCP server) meets v0.1 spec requirements — merge-ready pending 3 compliance fixes | +| 2026-03-06 | Skills stay CLI-based; MCP Prompts are the protocol equivalent | +| 2026-03-06 | Peer MCP model for external tool integration | +| 2026-03-06 | Create internal/parse for shared text-to-typed-value conversions | +| 2026-03-06 | Centralize errors in internal/err, not per-package err.go files | +| 2026-03-05 | Gitignore .context/memory/ for this project | +| 2026-03-05 | Memory bridge design: three-phase architecture with hook nudge + on-demand | +| 2026-03-05 | Revised strategic analysis: blog-first execution order, bidirectional sync as top-level section | +| 2026-03-04 | Interface-based GraphBuilder for multi-ecosystem ctx deps | +| 2026-03-02 | Billing threshold piggybacks on check-context-size, not heartbeat | +| 2026-03-02 | Replace auto-migration with stderr warning for legacy keys | +| 2026-03-02 | Consolidate all session state to .context/state/ | +| 2026-03-01 | PersistentPreRunE init guard with three-level exemption | +| 2026-03-01 | Global encryption key at ~/.ctx/.ctx.key | +| 2026-03-01 | Heartbeat token telemetry: conditional fields, not always-present | +| 2026-03-01 | Hook log rotation: size-based with one previous generation, matching eventlog pattern | +| 2026-03-01 | Promote 6 private skills to bundled plugin skills; keep 7 project-local | +| 2026-02-27 | Context window detection: JSONL-first fallback order | +| 2026-02-27 | Context injection architecture v2 (consolidated) | +| 2026-02-26 | .context/state/ directory for project-scoped runtime state | +| 2026-02-26 | Hook and notification design (consolidated) | +| 2026-02-26 | ctx init and CLAUDE.md handling (consolidated) | +| 2026-02-26 | Task and knowledge management (consolidated) | +| 2026-02-26 | Agent autonomy and separation of concerns (consolidated) | +| 2026-02-26 | Security and permissions (consolidated) | +| 2026-02-27 | Webhook and notification design (consolidated) | | 2026-04-25 | Use t.Setenv for subprocess env in tests, not append(os.Environ(), ...) | | 2026-04-25 | Tighten state.Dir / rc.ContextDir to (string, error) with sentinel errors | @@ -51,6 +127,1683 @@ For significant decisions: ✗ No real alternatives existed --> + +## [2026-04-16-011520] Deprecate and remove ctx backup + +**Status**: Accepted + +**Context**: ctx backup is environment-specific (SMB/GVFS), fires nag hooks for +unconfigured users, and solves a problem that belongs to the OS layer. ctx hub +already handles cross-machine knowledge persistence. + +**Decision**: Deprecate and remove ctx backup + +**Rationale**: Hub handles persistence, backup is env-specific, wrong layer for +ctx to own. No external users depend on it. Broadcom mirror issue and GVFS +Linux-only dependency add maintenance burden. + +**Consequence**: Need backup-strategy runbook before removal. Maintainer must +set up replacement cron job. About 60 files to remove across CLI, config, hooks, +docs, skills. Spec: specs/deprecate-ctx-backup.md + +--- + +## [2026-04-14-010205] doc.go quality floor: behavior-grounded, ~25-100 body lines, related-packages section required + +**Status**: Accepted + +**Context**: About 140 doc.go files were rewritten this session. User flagged +the original 5-line Key exports + See source files + Part of subsystem pattern +as lazy minimum effort. + +**Decision**: doc.go quality floor: behavior-grounded, ~25-100 body lines, +related-packages section required + +**Rationale**: Behavior-grounded rewrites (read source first, then write) are +the only acceptable form for any non-trivial package. The lazy template +communicates nothing a future reader cannot grep for; it satisfies tooling +without adding signal. + +**Consequence**: Every non-trivial package's doc.go now leads with the package's +actual purpose, names key behaviors, calls out non-obvious design choices +(Raft-lite, two-step indirection, idempotency contracts), and lists related +packages with paths. New packages should follow the same shape. + +--- + +## [2026-04-14-010205] Bootstrap stays under ctx system bootstrap (reverted experimental top-level promotion) + +**Status**: Accepted + +**Context**: Mid-session promoted ctx bootstrap to top-level to make a stale +CLAUDE.md instruction work. User reverted it and reaffirmed the original design. + +**Decision**: Bootstrap stays under ctx system bootstrap (reverted experimental +top-level promotion) + +**Rationale**: The ctx system namespace is for agent and hook plumbing the user +does not type by hand. Bootstrap is invoked by AI agents at session start; +surfacing it at top-level pollutes ctx --help for humans without benefit. + +**Consequence**: internal/bootstrap/group.go reverted; +internal/config/embed/cmd/system.go header now correctly states bootstrap is +intentionally not promoted. The CLAUDE.md template across the repo (and the +workspace copy) updated to reference ctx system bootstrap as canonical. + +--- + +## [2026-04-14-010205] Title Case style for docs is AP-leaning with explicit ambiguity carve-outs + +**Status**: Accepted + +**Context**: Needed a deterministic Title Case engine for headings and +admonition titles across docs/. User precedent (Working with AI lowercase with) +ruled out strict Chicago. + +**Decision**: Title Case style for docs is AP-leaning with explicit ambiguity +carve-outs + +**Rationale**: AP lowercase prepositions regardless of length matches +user-approved titles. But strict AP would lowercase ambiguous prep/conj/adv +words like before, after, since, until, past, near, down, up, off, hurting +common cases. Carve-outs leave them at default-cap and let the engine reach a +sensible result for ~95 percent of headings without manual review. + +**Consequence**: hack/title-case-headings.py ships an AP-leaning with ambiguity +carve-outs PREPOSITIONS set. Future style changes must touch that set explicitly +with reasoning. New brand or acronym additions go through the same audited +pattern. + +--- + +## [2026-04-13-153617] Walk boundary uses git as a hint, not a requirement + +**Status**: Accepted + +**Context**: ctx init failed when a non-ctx-initialized repo lived inside a +ctx-initialized parent workspace. walkForContextDir walked up and found the +parent's .context, then the boundary check rejected it. We considered +project-marker heuristics (go.mod, package.json) and making git mandatory. + +**Decision**: Walk boundary uses git as a hint, not a requirement + +**Rationale**: Project markers are unreliable (e.g. package.json for customer +shipments, Haskell projects have no common marker). Making git mandatory breaks +ctx's 'git recommended but not required' stance. Git-as-hint resolves the bug +without new dependencies: walk finds candidate, validate against git root, +discard if outside; fall back to CWD when no git is found. + +**Consequence**: walkForContextDir now consults findGitRoot to anchor ancestor +.context candidates. Monorepos, submodules, and nested workspaces resolve +correctly. No-git projects still work via CWD fallback. + +--- + +## [2026-04-11-200000] Journal stays local; LEARNINGS.md is the shareable layer + +**Status**: Accepted + +**Context**: With the hub now carrying shared project context between machines +and eventually between teammates, the question came up whether enriched +journal entries should ride along — either the raw `.context/journal/` files +or an "export enriched entries as shareable learning items" pipeline layered +on top of `/ctx-journal-enrich`. The journal is already gitignored per the +2026-03-05 `.context/memory/` decision and for the same reason: it's a +first-person log of raw prompts, half-formed thoughts, dead ends, personal +names, and things the user talks through with themselves. It sits in the +same trust tier as shell history or a private notebook. + +The trade-off is real: shared journals would make it trivial for teammates +(or future-me on another machine) to see the full reasoning trail behind a +decision. But "full reasoning trail" is precisely the thing that makes a +journal journal and not a changelog — it includes the parts the author +hasn't decided to stand behind yet, plus incidental private content. + +**Decision**: The journal is **Tier-0 personal** and never leaves the +originating machine. No hub sync, no export-by-default, no +enriched-entries-as-shareable-items pipeline. The enrichment pipeline +(`/ctx-journal-enrich`) stays as-is: journal → human-in-the-loop review → +explicit promotion to LEARNINGS.md / DECISIONS.md / CONVENTIONS.md via the +existing `/ctx-learning-add`, `/ctx-decision-add`, `/ctx-convention-add` +commands. Those distilled artifacts are **Tier-1 shareable** and are what +the hub syncs when a team opts into shared context. + +The promotion boundary is therefore the enrichment step, not a new export +pipeline. The user is the gate. + +**Rationale**: Any "shareable enriched journal entry" pipeline would have to +re-implement the trust boundary that `/ctx-learning-add` already enforces: +the human decides what's worth sharing, strips incidental private content, +and rewrites it as a standalone artifact. A second pipeline that tries to +do this automatically would either (a) leak private content by accident, or +(b) require the same human review and thus collapse back into +`/ctx-learning-add`. The principled answer is that there is no second +pipeline — LEARNINGS.md *is* the shareable form of the journal. + +This also preserves the psychological safety of the journal: the author +can write freely because they know nothing they write is one sync away +from a teammate's screen. Lose that property and the journal stops being a +journal and starts being a changelog draft. + +**Consequence**: + +- Journal files stay gitignored and stay out of `ctx hub` sync paths. Any + future code that walks context files for replication must exclude + `.context/journal/` explicitly and be covered by a test. +- `/ctx-journal-enrich` remains the promotion boundary. Its output targets + are LEARNINGS.md / DECISIONS.md / CONVENTIONS.md, never a separate + "shareable journal" bucket. +- Hub docs (`docs/home/hub.md`, `docs/recipes/hub-personal.md`, + `docs/recipes/hub-team.md`, `docs/security/hub.md`) should state the + Tier-0 / Tier-1 split explicitly so users building team workflows don't + assume "shared context" means "shared everything." +- The sync code path in `internal/hub/sync_helper.go` and any future + replication of context files must enforce this exclusion at the + code level — a gitignore entry is a user-convenience signal, not a + hub-trust boundary. +- A potential future "personal multi-machine journal sync" (same human, + different laptops) is explicitly **out of scope** of this decision. If + it ever ships, it rides a different transport (encrypted-at-rest, + single-user, not the team hub) and needs its own decision record. + +**Alternatives considered**: + +- **Sync raw journal files via hub**: rejected. Inverts the gitignore + decision, leaks private content by construction, destroys the + journal's "safe to write freely" property. +- **Auto-export enriched entries as a new shareable artifact type**: + rejected. Duplicates `/ctx-learning-add` without the human gate, or + collapses back into it. No real difference from the status quo except + the opportunity for accidental leakage. +- **Opt-in per-entry "publish to hub" flag in the journal**: rejected as + premature. If the user wants an entry on the hub, the existing flow is + one command away — write it as a learning or decision. A second path + adds surface area without adding capability. + +**Related**: Reinforces the 2026-03-05 `.context/memory/` gitignore +decision (same trust-tier reasoning for a different private artifact). + +## [2026-04-11-180000] `Entry.Author` is server-authoritative, not client-authoritative + +**Status**: Accepted + +**Context**: The `Entry.Author` field on hub entries is copied verbatim from +the client's publish request (`handler.go:82`). It's optional, freeform, and +unauthenticated — a client with a valid token for project `alpha` can publish +entries claiming `Author: "bob@acme.com"` regardless of who actually +authenticated. This is the same spoofing pattern as `Origin` (audit finding +H-04) and was flagged as audit finding H-22 with three options: keep, drop, +override, or promote. The decision was never formally closed. + +The premise that resolved it: **identity is eventually part of the token**. +Under the sysadmin-registry MVP, the server already knows `{user_id, project}` +from the authenticated token. Under the PKI stretch, the signed claim carries +identity cryptographically. In both models, the client has nothing to say about +authorship that the server doesn't already know with higher confidence. + +**Decision**: `Entry.Author` is **server-authoritative**. The server stamps it +from the authenticated identity source on every publish. The client's +`pe.Author` input is ignored (or rejected — implementation choice, not +semantic difference). The field stays in the wire format but its semantics +change from "whatever the client said" to "whatever the server's auth layer +resolved." + +Stamping source by phase: + +- **Today (pre-registry)**: `Author = ClientInfo.ProjectName`, same source as + the `Origin` server-enforcement fix (H-04). Lossy but consistent. +- **Registry MVP**: `Author = users.json` row's `user_id` (e.g., + `alice@acme.com`). Precise per-human attribution. +- **PKI stretch**: `Author = signed claim's sub field`. Cryptographic identity. + +**Rationale**: Dropping the field is wrong because the registry MVP will +already give us a per-user identity to stamp — removing Author just to re-add +it later is churn. "Override" and "promote" are cosmetically different forms +of the same decision (server fills from auth context); "promote" is what +happens naturally once the registry MVP types the field as `UserID`. +Client-sourced Author is indefensible because it replicates the Origin +spoofing vector in a second field. + +**Consequence**: + +- The Author field stays on the wire and in `Entry{}`. +- Client-side code that populates `pe.Author` from local config becomes a + no-op. Audit `ctx connect publish` and `ctx add --share` for any such + code paths before the server-enforcement fix lands. +- `handler.go publish()` fills Author from the authenticated context (the + same `ClientInfo` that H-04 pulls for Origin). Single unified + auth-to-handler pipe. +- `docs/security/hub.md` "Compromised client token" section gets rewritten: + attribution becomes **wrong** on compromise (attacker's token maps to + attacker's identity), not **forgeable** (attacker cannot stamp someone + else's name). +- The sysadmin-registry spec (`specs/hub-identity-registry.md`, tasked) + MUST include a `user_id` field per row — it's the stamping source. +- Three open tasks collapse into one: H-22 resolves to "implement + server-authoritative Author" instead of "decide Author fate." TASKS.md + updated. + +**Alternatives considered**: + +- **Keep client-authoritative**: rejected. Same spoofing vector as Origin; + trivially defeats any downstream attribution check. +- **Drop the field**: rejected. The registry MVP will need per-human + attribution anyway. Dropping today is churn that gets undone + immediately. +- **Override at client-side before publish**: rejected. Puts the security + boundary on the wrong side of the trust zone. Must be server-side. + +**Follow-up — client-advisory metadata**: the client still has useful +information to share that isn't an identity claim: a human-friendly +display name, the machine that made the publish, the tool version, a +CI system label, a team/role handle. This lives on a **new sibling +field `Meta`** (a `ClientMetadata` sub-struct), not on `Author`. The +separation of types is what protects the security property: `Author` +is reserved for server-authoritative identity, `Meta` is +client-advisory and explicitly labeled as such in any rendered +surface. `Meta` fields are size-capped individually (256 bytes) and +in aggregate (2 KB), validated for plain-string content (no +newlines, no control characters), and never claimed as attribution +in any API response. The renderer MUST label `Meta`-sourced values +with prose like "client label" or "client-reported" so readers +cannot mistake them for authoritative identity. See TASKS.md for +the implementation task. + +--- + +## [2026-04-09-001332] Architecture skill pipeline is a triad not a quartet + +**Status**: Accepted + +**Context**: Had a proposed ctx-architecture-extend for extension point mapping, +making four skills + +**Decision**: Architecture skill pipeline is a triad not a quartet + +**Rationale**: Extension points already covered per-module in DETAILED_DESIGN +and by registration site discovery in enrich. Fourth skill fragments pipeline +without distinct value + +**Consequence**: Pipeline is map enrich hunt. Three skills three questions: how +does it work, how well does it connect, where will it break + +--- + +## [2026-04-08-013731] Remove #done tag convention, simplify task archival + +**Status**: Accepted + +**Context**: Tasks had #done:YYYY-MM-DD timestamps that agents added +inconsistently and nobody read. compact --archive filtered by age using these +timestamps. + +**Decision**: Remove #done tag convention, simplify task archival + +**Rationale**: [x] checkbox is semantically sufficient. git blame provides the +completion timestamp. Removing #done eliminates redundant ceremony and +simplifies compact --archive to archive all completed tasks regardless of age. + +**Consequence**: compact --archive no longer filters by archive_after_days for +tasks. The .ctxrc field is inert but retained for backwards compatibility. +Historical #done tags in archives are preserved. + +--- + +## [2026-04-06-204212] Use hook relay for session provenance instead of JSONL parsing or env vars + +**Status**: Accepted + +**Context**: Needed to give agents awareness of their session ID, branch, and +commit hash for task/decision/learning provenance. Considered three approaches: +(1) parsing most-recent JSONL at runtime, (2) CTX_SESSION_ID env var, (3) hook +relay via UserPromptSubmit. + +**Decision**: Use hook relay for session provenance instead of JSONL parsing or +env vars + +**Rationale**: JSONL parsing breaks with parallel sessions (wrong file picked). +Env vars aren't exported by Claude Code. Hook relay is zero-state: the hook +receives session_id from Claude Code on every prompt, emits it, agent absorbs +through repetition. No counters, no cleanup, no resume edge cases. + +**Consequence**: Provenance depends on the hook being registered (enabledPlugins +in settings.local.json). Projects without plugin registration get no provenance. +Filed as separate bug. + +--- + +## [2026-04-04-025755] TestNoMagicStrings and TestNoMagicValues no longer exempt const/var definitions outside config/ + +**Status**: Accepted + +**Context**: The isConstDef/isVarDef blanket exemption masked 156+ string and 7 +numeric constants in the wrong package + +**Decision**: TestNoMagicStrings and TestNoMagicValues no longer exempt +const/var definitions outside config/ + +**Rationale**: Const definitions outside config/ are magic values in the wrong +place — naming them does not fix the structural problem + +**Consequence**: All new code with string/numeric constants outside config/ +fails these tests immediately + +--- + +## [2026-04-04-025746] String-typed enums belong in config/, not domain packages + +**Status**: Accepted + +**Context**: Debated whether type IssueType string with const values belongs in +domain or config. The string value is the same regardless of type annotation. + +**Decision**: String-typed enums belong in config/, not domain packages + +**Rationale**: Types without behavior belong in config. Promote to entity/ only +when methods/interfaces appear. + +**Consequence**: All type Foo string + const blocks outside config/ are now +caught by TestNoMagicStrings. + +--- + +## [2026-04-03-180000] Output functions belong in write/ (consolidated) + +**Status**: Accepted + +**Consolidated from**: 2 entries (2026-03-21 to 2026-03-22) + +**Decision**: Output functions belong in write/, logic and types in core/, +orchestration in cmd/ + +**Rationale**: The write/ taxonomy is flat by domain — each CLI feature gets +its own write/ package. core/ owns domain logic and types. cmd/ owns Cobra +orchestration. Functions that call cmd.Print/Println/Printf belong in write/. +core/ never imports cobra for output purposes. + +**Consequence**: All new CLI output must go through a write/ package. No +cmd.Print* calls in internal/cli/ outside of internal/write/. + +--- + +## [2026-04-03-180000] YAML text externalization pipeline (consolidated) + +**Status**: Accepted + +**Consolidated from**: 5 entries (2026-03-06 to 2026-04-03) + +**Decision**: All user-facing text externalized to embedded YAML domain files, +justified by agent legibility and drift prevention — not i18n + +**Rationale**: The real justification is agent legibility (named DescKey +constants as traversable graphs) and drift prevention (TestDescKeyYAMLLinkage +catches orphans mechanically). i18n is a free downstream consequence. The +exhaustive test verifies all constants resolve to non-empty YAML values — new +keys are automatically covered. + +**Consequence**: commands.yaml split into 4 domain files (commands, flags, text, +examples) loaded via dedicated loaders. text.yaml split into 6 domain files +loaded via loadYAMLDir. The 3-file ceremony (DescKey + YAML + write/err +function) is the cost of agent-legible, drift-proof output. + +--- + +## [2026-04-03-180000] Package taxonomy and code placement (consolidated) + +**Status**: Accepted + +**Consolidated from**: 3 entries (2026-03-06 to 2026-03-13) + +**Decision**: Three-zone taxonomy: cmd/ for Cobra wiring (cmd.go + run.go), +core/ for logic and types, assets/ for templates and user-facing text. config/ +for structural constants only. + +**Rationale**: Taxonomical symmetry makes navigation instant and agent-friendly. +Domain types that multiple packages consume belong in domain packages +(internal/entry), not CLI subpackages. Templates and user-facing text live in +assets/ for i18n readiness; structural constants (paths, limits, regexes) stay +in config/. + +**Consequence**: Every CLI package has the same predictable shape. Shared entry +types live in internal/entry. Template files (tpl_*.go) moved from config/ to +assets/. 474 files changed in initial restructuring. + +--- + +## [2026-04-03-180000] Eager init over lazy loading (consolidated) + +**Status**: Accepted + +**Consolidated from**: 2 entries (2026-03-16 to 2026-03-18) + +**Decision**: Explicit Init() called eagerly at startup for static embedded data +and resource lookups, instead of per-accessor sync.Once or package-level init() + +**Rationale**: Static embedded data is required at startup — sync.Once per +accessor is cargo cult. Package-level init() hides startup dependencies and +makes ordering unclear. Explicit Init() called from main.go / NewServer makes +the dependency visible and testable. + +**Consequence**: Maps unexported, accessors are plain lookups. Tests call Init() +in TestMain. res.Init() called from NewServer before ToList(). No package-level +side effects, zero sync.Once in the lookup pipeline. + +--- + +## [2026-04-03-180000] Pure logic separation of concerns (consolidated) + +**Status**: Accepted + +**Consolidated from**: 3 entries (2026-03-15 to 2026-03-23) + +**Decision**: Pure-logic functions return data structs; callers own I/O, file +writes, and reporting. Function pointers in param structs replaced with text +keys. + +**Rationale**: Pure logic with no I/O lets both MCP (JSON-RPC) and CLI (cobra) +callers control output independently. Methods that don't access receiver state +hide their true dependencies — make them free functions. If all callers of a +callback vary only by a string key, the callback is data in disguise. + +**Consequence**: CompactContext returns CompactResult; callers iterate +FileUpdates. Server response helpers in server/out, prompt builders in +server/prompt. All cross-cutting param structs in entity are +function-pointer-free. + +--- + +## [2026-04-03-133244] config/ explosion is correct — fix is documentation, not restructuring + +**Status**: Accepted + +**Context**: Architecture analysis flagged 60+ config sub-packages as a +bottleneck. Evaluation showed the alternative (8-10 domain packages) trades +granular imports for fat dependency units. Current structure gives zero internal +dependencies, surgical dependency tracking, and minimal recompile scope. + +**Decision**: config/ explosion is correct — fix is documentation, not +restructuring + +**Rationale**: Go's compilation unit is the package. Granular packages mean +precise dependency tracking. The developer experience cost (IDE noise, package +discovery) is real but solvable with a README decision tree, not restructuring. +Restructuring would be massive mechanical churn for cosmetic benefit. + +**Consequence**: config/README.md written with organizational guide and decision +tree. No restructuring planned. embed/text/ file count will shrink naturally +when tpl/ migrates to text/template. + +--- + +## [2026-04-01-233247] IRC to Discord as primary community channel + +**Status**: Accepted + +**Context**: Discord server exists at https://ctx.ist/discord; IRC/libera.chat +references were stale + +**Decision**: IRC to Discord as primary community channel + +**Rationale**: Discord is faster for async community support; IRC was historical + +**Consequence**: Updated zensical.toml, README, community docs, journal +template. Added community footer to ctx help and ctx init output via YAML assets +pipeline + +--- + +## [2026-04-01-233246] AST audit tests live in internal/audit/, one file per check + +**Status**: Accepted + +**Context**: Needed a home for AST-based codebase invariant tests separate from +the existing compliance_test.go monolith + +**Decision**: AST audit tests live in internal/audit/, one file per check + +**Rationale**: One test per file prevents the 1200+ line monster pattern. Shared +helpers in helpers_test.go with sync.Once caching. Package is all _test.go +except doc.go — produces no binary, not importable + +**Consequence**: New checks are added as individual *_test.go files; the pattern +(loadPackages, walk AST, collect violations, t.Error) is established and +repeatable + +--- + +## [2026-04-01-074417] Split assets/hooks/ into assets/integrations/ + assets/hooks/messages/ + +**Status**: Accepted + +**Context**: The directory mixed Copilot integration templates with hook message +templates + +**Decision**: Split assets/hooks/ into assets/integrations/ + +assets/hooks/messages/ + +**Rationale**: Integration assets (Copilot instructions, AGENTS.md, CLI +scripts/skills) are not hooks. Hook messages ARE the hook system templates. + +**Consequence**: integrations/ for tool integration assets, hooks/messages/ for +hook system templates. Embed directives and all config constants updated. + +--- + +## [2026-04-01-074416] Rename ctx hook → ctx setup to disambiguate from the hook system + +**Status**: Accepted + +**Context**: PR #45 contributor assumed hook meant the setup command, causing +naming collisions with the PreToolUse/PostToolUse hook system + +**Decision**: Rename ctx hook → ctx setup to disambiguate from the hook system + +**Rationale**: hook has a specific meaning in ctx; setup accurately describes +generating AI tool integration configs + +**Consequence**: CLI breaking change. All docs, specs, TypeScript extension, and +YAML assets updated. Released specs left as historical. + +--- + +## [2026-03-31-224245] Split log into log/event and log/warn to break import cycles + +**Status**: Accepted + +**Context**: io and notify could not import log.Warn because log imported both +of them for event logging, creating circular dependencies + +**Decision**: Split log into log/event and log/warn to break import cycles + +**Rationale**: Separating concerns (stderr sink vs JSONL event log) into +subpackages eliminated the cycle. Warn sink is foundation-level with only config +imports, event logging is higher-level + +**Consequence**: All stderr warnings now route through logWarn.Warn(). New code +importing log/warn has no cycle risk. Event types moved to internal/entity + +--- + +## [2026-03-31-182003] Context-load-gate injects only CONSTITUTION and AGENT_PLAYBOOK_GATE, not full ReadOrder + +**Status**: Accepted + +**Context**: Force-loading ~14k tokens of context files (8 files) every session +diluted attention without proportional value. CLAUDE.md already instructs agents +to read full context files on-demand. Behavioral prose in force-loaded content +was routinely skipped. + +**Decision**: Context-load-gate injects only CONSTITUTION and +AGENT_PLAYBOOK_GATE, not full ReadOrder + +**Rationale**: Hard rules (CONSTITUTION) must be present before any action. +Distilled directives (gate file) provide actionable session-start guidance in +~2k tokens. Full playbook, conventions, architecture, decisions, learnings are +pulled on-demand when task context requires them. + +**Consequence**: New AGENT_PLAYBOOK_GATE.md file must stay in sync with +AGENT_PLAYBOOK.md. HTML comment cross-reference added to playbook header for +contributor discoverability. + +--- + +## [2026-03-31-005113] Spec signal words and nudge threshold are user-configurable via .ctxrc + +**Status**: Accepted + +**Context**: Initially hardcoded signal words and 150-char threshold in run.go. +User pointed out these are localizable vocabulary, following the +session_prefixes / classify_rules pattern + +**Decision**: Spec signal words and nudge threshold are user-configurable via +.ctxrc + +**Rationale**: Signal words are language-dependent and project-dependent — a +Spanish-speaking user or a non-Go project would have different signal terms + +**Consequence**: Added spec_signal_words and spec_nudge_min_len to CtxRC struct, +rc accessors with defaults in config/entry, JSON schema updated + +--- + +## [2026-03-30-075927] Flags-not-subcommands for journal source: list and show are view modes on a noun, not independent entities + +**Status**: Accepted + +**Context**: During the journal-recall merge, recall had separate list and show +subcommands. Merging them into journal created a design choice: source list + +source show (three levels) vs source --show (two levels). + +**Decision**: Flags-not-subcommands for journal source: list and show are view +modes on a noun, not independent entities + +**Rationale**: Keeps CLI nesting to two levels max. Default behavior (bare +source) lists sessions; --show switches to inspect mode. When two operations +differ only in how they view the same data, make them flags on one command. + +**Consequence**: journal source dispatches via --show flag rather than +positional subcommand. Future view-mode toggles should follow this pattern. + +--- + +## [2026-03-30-003756] Journal consumed recall — recall CLI package deleted + +**Status**: Accepted + +**Context**: ctx recall was never registered in bootstrap; ctx journal had all +the same subcommands + +**Decision**: Journal consumed recall — recall CLI package deleted + +**Rationale**: One dead command group creates confusion in docs and skills. +Journal is the canonical command group. + +**Consequence**: internal/cli/recall/ deleted, 19 doc files updated, +docs/cli/recall.md renamed to journal.md, zensical.toml updated. MCP tool +ctx_recall rename tasked separately (API contract) + +--- + +## [2026-03-30-003745] Classify rules are user-configurable via .ctxrc + +**Status**: Accepted + +**Context**: Memory entry classification used hardcoded keyword rules that could +not be customized + +**Decision**: Classify rules are user-configurable via .ctxrc + +**Rationale**: Users may work in domains where the default keywords do not match +(non-English, specialized terminology). Same pattern as session_prefixes. + +**Consequence**: classify_rules in .ctxrc overrides defaults; schema updated; +rc.ClassifyRules() accessor with fallback to config/memory.DefaultClassifyRules + +--- + +## [2026-03-25-233646] Architecture analysis and enrichment are separate skills — constraint is the feature + +**Status**: Accepted + +**Context**: Observed that agents take shortcuts when code intelligence tools +are available during architecture analysis. A 5.2x depth reduction was measured +(5866 vs 1124 lines) when GitNexus was available during reading. Mentioning +unavailable tools by name in a skill plants the idea for the agent to use them. + +**Decision**: Architecture analysis and enrichment are separate skills — +constraint is the feature + +**Rationale**: Discovery requires forced reading without shortcuts. Validation +and quantification are a separate pass. Two-pass compiler analogy: semantic +parsing (human-style reading) then static analysis (graph enrichment). Never +mention tools you want the agent to avoid — absence is the only reliable +constraint. + +**Consequence**: ctx-architecture deliberately excludes code intelligence tools +from allowed-tools and never mentions them. ctx-architecture-enrich is a +separate skill that runs after, using the deep artifacts as baseline. Gemini is +allowed in both for upstream/external lookups only. + +--- + +## [2026-03-25-173337] Companion tools documented as optional MCP enhancements with runtime check + +**Status**: Accepted + +**Context**: Gemini Search and GitNexus improve skills but no docs mentioned +them and no code checked their availability + +**Decision**: Companion tools documented as optional MCP enhancements with +runtime check + +**Rationale**: Users should know what tools enhance their workflow without being +forced to install them. Suppressible via .ctxrc for users who don't want them. + +**Consequence**: /ctx-remember smoke-tests MCPs at session start. +companion_check: false suppresses. + +--- + +## [2026-03-25-173336] Prompt templates removed — skills are the single agent instruction mechanism + +**Status**: Accepted + +**Context**: Prompt templates (.context/prompts/) overlapped with skills but had +no discoverability — even the project creator didn't know they existed + +**Decision**: Prompt templates removed — skills are the single agent +instruction mechanism + +**Rationale**: Adding metadata to prompts to fix discoverability would recreate +the skill system. One concept is better than two. + +**Consequence**: code-review, explain, refactor promoted to proper skills. ctx +prompt CLI removed. loop.md retained as ctx loop config file at +.context/loop.md. + +--- + +## [2026-03-24-001001] Write-once baseline with explicit end-consolidation for consolidation lifecycle + +**Status**: Accepted + +**Context**: Designing the consolidation nudge hook; multi-pass consolidation +spans dozens of sessions and you cannot programmatically distinguish feature +from consolidation sessions + +**Decision**: Write-once baseline with explicit end-consolidation for +consolidation lifecycle + +**Rationale**: First ctx-consolidate stamps baseline (write-once), user runs +end-consolidation when done. Failure mode is silence (no stale nudges), not +wrong behavior + +**Consequence**: Requires mark-consolidation, end-consolidation, and +snooze-consolidation plumbing commands. Spec: specs/consolidation-nudge-hook.md + +--- + +## [2026-03-23-165612] Pre/pre HTML tags promoted to shared constants in config/marker + +**Status**: Accepted + +**Context**: Two packages (normalize and format) used hardcoded pre strings +independently + +**Decision**: Pre/pre HTML tags promoted to shared constants in config/marker + +**Rationale**: Cross-package magic strings belong in config constants per +CONVENTIONS.md + +**Consequence**: marker.TagPre and marker.TagPreClose are the canonical +references; package-local constants deleted + +--- + +## [2026-03-22-084316] Output functions belong in write/, never in core/ or cmd/ + +**Status**: Accepted + +**Context**: System write migration revealed that cmd.Print* calls scattered +across core/ and cmd/ packages prevented localization and violated separation of +concerns + +**Decision**: Output functions belong in write/, never in core/ or cmd/ + +**Rationale**: The write/ taxonomy is flat by domain — each CLI feature gets +its own write/ package. core/ owns logic and types, cmd/ owns orchestration, +write/ owns all output. + +**Consequence**: All new CLI output must go through a write/ package. No +cmd.Print* calls in internal/cli/ outside of internal/write/. + +--- + +## [2026-03-20-232506] Shared formatting utilities belong in internal/format + +**Status**: Accepted + +**Context**: Pluralize, Duration, DurationAgo, and TruncateFirstLine were +duplicated across memory/core, change/core, and other CLI packages + +**Decision**: Shared formatting utilities belong in internal/format + +**Rationale**: internal/format already existed with TimeAgo and Number +formatters. Centralizing prevents duplication and matches the convention that +domain-agnostic utilities live in shared packages, not CLI subpackages + +**Consequence**: CLI packages import internal/format instead of defining local +helpers. Local copies deleted. + +--- + +## [2026-03-20-160103] Go-YAML linkage check added to lint-drift as check 5 + +**Status**: Accepted + +**Context**: Prior refactoring sessions left broken and orphan linkages between +Go DescKey constants and YAML entries that caused silent runtime failures + +**Decision**: Go-YAML linkage check added to lint-drift as check 5 + +**Rationale**: Shell-based grep+comm approach fits the existing lint-drift +pattern, runs at CI time, and is simpler than programmatic Go AST parsing + +**Consequence**: CI-time check catches orphans in both directions plus +cross-namespace duplicates, preventing recurrence + +--- + +## [2026-03-18-193623] Singular command names for all CLI entities + +**Status**: Accepted + +**Context**: ctx add used learning (singular) but ctx learnings was plural. +Inconsistency across 6 commands. + +**Decision**: Singular command names for all CLI entities + +**Rationale**: Less headache for i18n; one rule (singular = entity); developers +think in OOP. Use field values come from DescKey constants for +single-source-of-truth renaming. + +**Consequence**: All commands singular: task, decision, learning, change, +permission, dep. YAML keys, desc constants, directory names, and 50+ files +updated. + +--- + +## [2026-03-17-105627] Pre-compute-then-print for write package output blocks + +**Status**: Accepted + +**Context**: Audit of internal/write/ found 337 Println calls across 160 +functions. Asked whether text/template or single format strings would clean up +multi-Println functions like InfoLoopGenerated. + +**Decision**: Pre-compute-then-print for write package output blocks + +**Rationale**: text/template trades compile-time safety for runtime errors and +only 38 of 160 functions benefit from consolidation. fmt.Sprintf with +pre-computed conditional args handles all cases without new dependencies. +Loop-based functions stay imperative. + +**Consequence**: Functions with 4+ Printlns pre-compute conditionals into +strings, then emit one cmd.Println with a multiline block template. Per-line +Tpl* constants replaced with TplXxxBlock. Trivial (1-3 line) and loop-based +functions excluded. + +--- + +## [2026-03-16-104142] Resource name constants in config/mcp/resource, mapping in server/resource + +**Status**: Accepted + +**Context**: MCP resource handler had string literals scattered through +handle_resource.go and rebuilt the resource list on every call + +**Decision**: Resource name constants in config/mcp/resource, mapping in +server/resource + +**Rationale**: Constants follow the same pattern as config/mcp/tool. Mapping +stays in server/resource because it bridges config constants with assets text +(too many cross-cutting deps for a config package). Resource list and URI lookup +are pre-built once at server init. + +**Consequence**: URI-to-file lookup is O(1) via pre-built map; resource list +built once in NewServer, not per request; no string literals in handler code + +--- + +## [2026-03-16-022635] Rename --consequences flag to --consequence for singular consistency + +**Status**: Accepted + +**Context**: All other CLI flags (context, rationale, lesson, application) are +singular nouns. consequences was the only plural. + +**Decision**: Rename --consequences flag to --consequence for singular +consistency + +**Rationale**: Singular form matches the pattern. Consistency wins over natural +language preference. + +**Consequence**: 75+ files updated. Breaking change for --consequences users. + +--- + +## [2026-03-14-180905] Error package taxonomy: 22 domain files replace monolithic errors.go + +**Status**: Accepted + +**Context**: internal/err/errors.go was 1995 lines with 188 functions in one +file + +**Decision**: Error package taxonomy: 22 domain files replace monolithic +errors.go + +**Rationale**: Convention requires files named by responsibility, not junk +drawers; domain grouping makes it possible to find error constructors by domain + +**Consequence**: 22 files (backup, config, crypto, date, fs, git, hook, init, +journal, memory, notify, pad, parser, prompt, recall, reminder, session, site, +skill, state, task, validation); errors.go deleted + +--- + +## [2026-03-14-131152] Session prefixes are parser vocabulary, not i18n text + +**Status**: Accepted + +**Context**: Markdown session parser had hardcoded Session:/Oturum: pair in +text.yaml as session_prefix/session_prefix_alt — didn't scale beyond two +languages + +**Decision**: Session prefixes are parser vocabulary, not i18n text + +**Rationale**: Session header prefixes are recognition patterns for parsing, not +user-facing interface strings. Separating content recognition from interface +language lets users parse multilingual session files without code changes. +Single-language default (Session:) avoids implicit favoritism. + +**Consequence**: Prefixes moved to .ctxrc session_prefixes list. text.yaml +entries and embed.go constants removed. Parser reads from rc.SessionPrefixes() +with fallback to config/parser.DefaultSessionPrefixes. Users extend via .ctxrc. + +--- + +## [2026-03-14-110748] System path deny-list as safety net, not security boundary + +**Status**: Accepted + +**Context**: Replacing nolint:gosec directives with centralized I/O wrappers in +internal/io + +**Decision**: System path deny-list as safety net, not security boundary + +**Rationale**: ctx paths are internally constructed from config constants. The +deny-list catches agent hallucinations (writing to /etc), not adversarial input. +Public security docs would imply a threat model that does not exist. + +**Consequence**: internal/io/doc.go documents limitations honestly for +contributors. No user-facing security docs. The deny-list is a modicum of +protection, not a promise. + +--- + +## [2026-03-14-093748] Config-driven freshness check with per-file review URLs + +**Status**: Accepted + +**Context**: Building a hook to warn when technology-dependent constants go +stale. Initially hardcoded the file list and Anthropic docs URL in the binary, +but this only worked inside the ctx repo and assumed all projects care about +Anthropic docs. + +**Decision**: Config-driven freshness check with per-file review URLs + +**Rationale**: Making the file list and review URLs configurable via .ctxrc +freshness_files means any project can opt in. Per-file review_url avoids +special-casing by project name — ctx sets Anthropic docs, other projects set +their own vendor links or omit it entirely. + +**Consequence**: The hook is a no-op by default (opt-in). ctx's own .ctxrc +carries the tracked files. All nudge text goes through assets/text.yaml for +localization. No project detection logic needed. + +--- + +## [2026-03-13-223111] Delete ctx-context-monitor skill — hook output is self-sufficient + +**Status**: Accepted + +**Context**: The skill documented how to relay context window warnings, but the +hook message already includes IMPORTANT: Relay this context window warning to +the user VERBATIM which agents follow without the skill. + +**Decision**: Delete ctx-context-monitor skill — hook output is +self-sufficient + +**Rationale**: No mechanism exists for hooks to trigger skills. The skill was +never loaded during sessions. Adding enforcement elsewhere would either be too +far back in context (playbook) or dilute the already-crisp hook message. + +**Consequence**: One fewer skill to maintain. No behavioral change — agents +continue relaying warnings as before. + +--- + +## [2026-03-13-151955] build target depends on sync-why to prevent embedded doc drift + +**Status**: Accepted + +**Context**: assets/why/ files had silently drifted from their docs/ sources + +**Decision**: build target depends on sync-why to prevent embedded doc drift + +**Rationale**: Derived assets that are not in the build dependency chain will +drift — the only reliable enforcement is making the build fail without sync + +**Consequence**: Every make build now copies docs into assets before compiling + +--- + +## [2026-03-12-133007] Recommend companion RAGs as peer MCP servers not bridge through ctx + +**Status**: Accepted + +**Context**: Explored whether ctx should proxy RAG queries or integrate a RAG +directly + +**Decision**: Recommend companion RAGs as peer MCP servers not bridge through +ctx + +**Rationale**: MCP is the composition layer — agents already compose multiple +servers. ctx is context, RAGs are intelligence. No bridging, no plugin system, +no schema abstraction + +**Consequence**: Spec created at ideas/spec-companion-intelligence.md; future +work is documentation and UX only + +--- + +## [2026-03-12-133007] Rename ctx-map skill to ctx-architecture + +**Status**: Accepted + +**Context**: The name 'map' didn't convey the iterative, architectural nature of +the ritual + +**Decision**: Rename ctx-map skill to ctx-architecture + +**Rationale**: 'architecture' better describes surveying and evolving project +structure across sessions + +**Consequence**: All cross-references updated across skills, docs, .context +files, and settings + +--- + +## [2026-03-07-221155] Use composite directory path constants for multi-segment paths + +**Status**: Accepted + +**Context**: Needed a constant for hooks/messages path used in message.go and +message_cmd.go + +**Decision**: Use composite directory path constants for multi-segment paths + +**Rationale**: Matches existing pattern of DirClaudeHooks = '.claude/hooks' — +keeps filepath.Join calls cleaner and avoids scattering path segments + +**Consequence**: New multi-segment directory paths should be single constants +(e.g. DirHooksMessages, DirMemoryArchive) rather than joined from individual +segment constants + +--- + +## [2026-03-06-200306] Drop fatih/color dependency — Unicode symbols are sufficient for terminal output, color was redundant + +**Status**: Accepted + +**Context**: fatih/color was used in 32 files for green checkmarks, yellow +warnings, cyan headings, dim text + +**Decision**: Drop fatih/color dependency — Unicode symbols are sufficient for +terminal output, color was redundant + +**Rationale**: Every colored output already had a semantic symbol (✓, ⚠, +○) that conveyed the same meaning; color added visual noise in non-terminal +contexts (logs, pipes) + +**Consequence**: Removed --no-color flag (only existed for color.NoColor); one +fewer external dependency; FlagNoColor retained in config for CLI compatibility + +--- + +## [2026-03-06-141507] PR #27 (MCP server) meets v0.1 spec requirements — merge-ready pending 3 compliance fixes + +**Status**: Accepted + +**Context**: Reviewed PR against specs/mcp-server.md; all 7 action items +addressed, CI fails on 3 mechanical compliance issues + +**Decision**: PR #27 (MCP server) meets v0.1 spec requirements — merge-ready +pending 3 compliance fixes + +**Rationale**: All spec requirements met; CI failures are trivial and low-risk; +keeping PR open risks merge conflicts during active refactoring + +**Consequence**: Merge and fix compliance issues in follow-up commit on main + +--- + +## [2026-03-06-184816] Skills stay CLI-based; MCP Prompts are the protocol equivalent + +**Status**: Accepted + +**Context**: Question arose whether skills should switch from ctx CLI (Bash) to +MCP tool calls once the MCP server ships + +**Decision**: Skills stay CLI-based; MCP Prompts are the protocol equivalent + +**Rationale**: CLI is always available (PATH prerequisite); MCP requires +optional configuration. Hooks will always be CLI (shell commands). Two access +patterns in the same tool is gratuitous complexity. + +**Consequence**: Skills call CLI. MCP Prompts call MCP Tools. Hooks call CLI. +Clean layer separation; no replacement, only parallel access paths. + +--- + +## [2026-03-06-184812] Peer MCP model for external tool integration + +**Status**: Accepted + +**Context**: Evaluated three integration models (orchestrator, peer, hub) for +how ctx relates to GitNexus and context-mode + +**Decision**: Peer MCP model for external tool integration + +**Rationale**: Peer model (side-by-side MCP servers, each queried independently +by the agent) respects ctx's markdown-on-filesystem invariant and avoids +coupling. ctx provides behavioral scaffolding; external tools provide their +specialties. + +**Consequence**: ctx MCP Prompts can reference external tools by convention +without tight coupling. No plugin registry needed. + +--- + +## [2026-03-06-050132] Create internal/parse for shared text-to-typed-value conversions + +**Status**: Accepted + +**Context**: parseDate with 2006-01-02 duplicated in 5+ files; needed a home +that is not internal/utils or internal/strings (collides with stdlib) + +**Decision**: Create internal/parse for shared text-to-typed-value conversions + +**Rationale**: internal/parse scopes to convert text to typed values without +becoming a junk drawer. Name invites sibling functions (duration, identifier +parsing) naturally. + +**Consequence**: parse.Date() is the first function; config.DateFormat holds the +layout constant. Other time.Parse callers can migrate incrementally. + +--- + +## [2026-03-06-050131] Centralize errors in internal/err, not per-package err.go files + +**Status**: Accepted + +**Context**: Duplicate error constructors across 5+ CLI packages; agents copying +the pattern when they see a local err.go + +**Decision**: Centralize errors in internal/err, not per-package err.go files + +**Rationale**: Single location makes duplicates visible, enables future sentinel +errors, and prevents broken-window accumulation + +**Consequence**: All CLI err.go files migrated and deleted. New errors go to +internal/err/errors.go exclusively. + +--- + +## [2026-03-05-205424] Gitignore .context/memory/ for this project + +**Status**: Accepted + +**Context**: Memory mirror contains copies of MEMORY.md which holds strategic +analysis and session notes + +**Decision**: Gitignore .context/memory/ for this project + +**Rationale**: Strategic content should not be in git history. Docs updated to +say 'often git-tracked' for the general recommendation — this project is the +exception. + +**Consequence**: Mirror and archives are local-only for this project. Other +projects can still track them. Sync and drift detection work the same way +regardless. + +--- + +## [2026-03-05-042154] Memory bridge design: three-phase architecture with hook nudge + on-demand + +**Status**: Accepted + +**Context**: Brainstormed how to bridge Claude Code MEMORY.md with ctx +structured context files + +**Decision**: Memory bridge design: three-phase architecture with hook nudge + +on-demand + +**Rationale**: Hook nudge + on-demand gives user choice and freedom. Wrap-up is +the publish trigger, never commit (footgun). Heuristic classification for v1, no +LLM. Marker-based merge for bidirectional conflict. Mirror is git-tracked + +timestamped archives. Foundation spec delivers sync/status/diff/hook; import and +publish are future phases. + +**Consequence**: Foundation spec in specs/memory-bridge.md, import/publish specs +deferred to ideas/. Tasked out as S-0.1.1 through S-0.1.10 in ideas/TASKS.md. + +--- + +## [2026-03-05-023937] Revised strategic analysis: blog-first execution order, bidirectional sync as top-level section + +**Status**: Accepted + +**Context**: Editorial review of ideas/claude-memory-strategic-analysis.md +surfaced six structural weaknesses in competitive positioning + +**Decision**: Revised strategic analysis: blog-first execution order, +bidirectional sync as top-level section + +**Rationale**: 200-line cap is fragile differentiator (demoted); org-scoped +memory is the real threat (elevated to HIGH); model agnosticism is premature +(parked with trigger condition); bidirectional sync is the most underweighted +insight (promoted); narrative shapes categories before implementation does (blog +first) + +**Consequence**: Execution order is now S-3 (blog) -> S-0 -> S-1 -> S-2. +Strategic doc restructured from 9 to 10 sections. Blog post shipped as first +deliverable. + +--- + +## [2026-03-04-105238] Interface-based GraphBuilder for multi-ecosystem ctx deps + +**Status**: Accepted + +**Context**: P-1.3 questioned whether non-Go dependency support would introduce +bloat and whether a semantic approach was better + +**Decision**: Interface-based GraphBuilder for multi-ecosystem ctx deps + +**Rationale**: The output pipeline (map[string][]string to Mermaid/table/JSON) +was already language-agnostic. Each ecosystem builder is ~40 lines — this is +finishing what was started, not bloat. Static manifest parsing (no external +tools for Node/Python) keeps dependencies minimal. + +**Consequence**: ctx deps now auto-detects Go, Node.js, Python, Rust. --type +flag overrides detection. ctx-architecture skill works across ecosystems without +changes. + +--- + +## [2026-03-02-165038] Billing threshold piggybacks on check-context-size, not heartbeat + +**Status**: Accepted + +**Context**: User wanted a configurable token-count nudge for billing awareness +(Claude Pro 1M context, extra cost after 200k). Heartbeat produces zero stdout +and can't relay to user. + +**Decision**: Billing threshold piggybacks on check-context-size, not heartbeat + +**Rationale**: check-context-size already reads tokens, has VERBATIM relay +working, and runs every prompt. Adding a third independent trigger there is +minimal code and follows established patterns. + +**Consequence**: New .ctxrc field billing_token_warn (default 0 = disabled). +One-shot per session via billing-warned-{sessionID} state file. +Template-overridable via check-context-size/billing.txt. + +--- + +## [2026-03-02-123611] Replace auto-migration with stderr warning for legacy keys + +**Status**: Accepted + +**Context**: Auto-migration code existed for promoting keys from +~/.local/ctx/keys/ and .context/.ctx.key to ~/.ctx/.ctx.key. Userbase is small +and this is alpha — no need to bloat the codebase. + +**Decision**: Replace auto-migration with stderr warning for legacy keys + +**Rationale**: Warn-only is simpler, avoids silent file operations, and puts the +user in control. Migration instructions in docs are sufficient for the small +userbase. + +**Consequence**: MigrateKeyFile() now only warns on stderr. promoteToGlobal() +helper deleted. Tests verify keys are not moved. + +--- + +## [2026-03-02-005213] Consolidate all session state to .context/state/ + +**Status**: Accepted + +**Context**: Session-scoped state (cooldown tombstones, pause markers, daily +throttle markers) was split between /tmp (via secureTempDir()) and +.context/state/ for project-scoped state + +**Decision**: Consolidate all session state to .context/state/ + +**Rationale**: Single location simplifies mental model, eliminates duplicated +secureTempDir() in two packages, removes the cleanup-tmp SessionEnd hook +entirely. .context/state/ is already gitignored and project-scoped. + +**Consequence**: All 18 callers updated. Tests switch from XDG_RUNTIME_DIR +mocking to CTX_DIR + rc.Reset(). Hook lifecycle drops from 4 events to 3 +(SessionEnd removed). + +--- + +## [2026-03-01-222733] PersistentPreRunE init guard with three-level exemption + +**Status**: Accepted + +**Context**: ctx commands handled missing .context/ inconsistently — some +caught errors, some got confusing file-not-found messages, some produced empty +output + +**Decision**: PersistentPreRunE init guard with three-level exemption + +**Rationale**: Single PersistentPreRunE on root command gives one clear error. +Three-level exemption (hidden commands, annotated commands, grouping commands) +covers all edge cases without per-command boilerplate + +**Consequence**: Boundary violation now returns an error instead of os.Exit(1), +making it testable. The subprocess-based boundary test was simplified to a +direct error assertion + +--- + +## [2026-03-01-161457] Global encryption key at ~/.ctx/.ctx.key + +**Status**: Superseded by [2026-03-02] global key simplification + +**Context**: Key stored next to ciphertext (.context/.ctx.key) was a security +antipattern and broke in worktrees. The slug-based per-project key system at +~/.local/ctx/keys/ was over-engineered for the common case (one user, one +machine, one key). + +**Decision**: Single global key at ~/.ctx/.ctx.key. Project-local override via +.ctxrc key_path or .context/.ctx.key. + +**Rationale**: One key per machine covers 99% of users. Per-project slug +filenames and three-tier resolution added complexity without clear benefit. +~/.ctx/ is the natural home (matches ~/.claude/ convention). Tilde expansion in +.ctxrc key_path fixes a standalone bug. + +**Consequence**: Auto-migration promotes legacy keys (project-local, +~/.local/ctx/keys/) to ~/.ctx/.ctx.key. Deleted KeyDir(), ProjectKeySlug(), +ProjectKeyPath(). ResolveKeyPath simplified to two params. 15+ doc files +updated. + +--- + +## [2026-03-01-112544] Heartbeat token telemetry: conditional fields, not always-present + +**Status**: Accepted + +**Context**: Adding tokens, context_window, usage_pct to heartbeat payloads. +First prompt of a session has no JSONL usage data yet. + +**Decision**: Heartbeat token telemetry: conditional fields, not always-present + +**Rationale**: Token fields are only included in the template ref when tokens > +0. This avoids misleading pct=0% on the first heartbeat and keeps payloads clean +for receivers that filter on field presence. + +**Consequence**: Webhook consumers must handle heartbeats both with and without +token fields. The message string also varies (with/without tokens=N pct=N% +suffix). + +--- + +## [2026-03-01-092613] Hook log rotation: size-based with one previous generation, matching eventlog pattern + +**Status**: Accepted + +**Context**: .context/logs/ files grow unbounded (~200KB after one month); +needed a cap + +**Decision**: Hook log rotation: size-based with one previous generation, +matching eventlog pattern + +**Rationale**: Architectural symmetry with eventlog, O(1) size check vs O(n) +line counting, diagnostic logs don't need deep history (webhooks cover serious +setups) + +**Consequence**: Each log file caps at ~2MB (current + .1). config.LogMaxBytes = +1MB, same as EventLogMaxBytes + +--- + +## [2026-03-01-090124] Promote 6 private skills to bundled plugin skills; keep 7 project-local + +**Status**: Accepted + +**Context**: Reviewed all 13 _ctx-* private skills to determine which are +universally useful for any ctx user vs specific to the ctx codebase or personal +infra. + +**Decision**: Promote 6 private skills to bundled plugin skills; keep 7 +project-local + +**Rationale**: Promote if the skill benefits any ctx-powered project without +project-specific hardcoding. Keep private if it references this repo's Go +internals, personal infra, or language-specific tooling. Promote list: _ctx-spec +(generic scaffolding), _ctx-brainstorm (design facilitation), _ctx-verify (claim +verification), _ctx-skill-create (skill authoring), _ctx-link-check (doc link +audit), _ctx-permission-sanitize (Claude Code permissions audit). Keep list: +_ctx-audit (Go/ctx checks), _ctx-qa (Go Makefile), _ctx-backup (SMB infra), +_ctx-release/_ctx-release-notes (ctx release workflow), _ctx-update-docs (ctx +package mapping), _ctx-absorb (borderline, revisit later). + +**Consequence**: Six skills move from .claude/skills/ to +internal/assets/claude/skills/ and become available to all ctx users via ctx +init. Cross-references between skills need updating (e.g., /_ctx-brainstorm +becomes /ctx-brainstorm). The seven remaining private skills stay project-local. + +--- + +## [2026-02-27-230718] Context window detection: JSONL-first fallback order + +**Status**: Accepted + +**Context**: check-context-size defaults to 200k but user runs 1M-context model, +causing false 110% warnings. JSONL contains the model name which maps to actual +window size. + +**Decision**: Context window detection: JSONL-first fallback order + +**Rationale**: effective_window = detect_from_jsonl(model) ?? +ctxrc.context_window ?? 200_000. JSONL is ground truth (reflects actual model in +use); ctxrc is fallback for first-hook-of-session or unknown models; 200k is +safe last resort. Having ctxrc override JSONL would artificially restrict the +check when a user forgets to update their config after switching models. + +**Consequence**: Most users get correct window automatically. ctxrc +context_window becomes a fallback, not an override. Task exists for +implementation. + +--- + +## [2026-02-27-002830] Context injection architecture v2 (consolidated) + +**Status**: Accepted + +**Consolidated from**: 3 decisions (2026-02-26) + +- **Diagram extraction**: ARCHITECTURE.md contained ~600 lines of ASCII/Mermaid + diagrams (~12K tokens). Extracted to 5 architecture-dia-*.md files outside + FileReadOrder. Agents get verbal summaries at session start; diagrams + available on demand. Total injection dropped 53% (20K→9.5K tokens). +- **Auto-injection replaces directives**: Soft instructions have ~75-85% + compliance ceiling because "don't apply judgment" is itself evaluated by + judgment. The v2 context-load-gate injects content directly via + `additionalContext` — agents never choose whether to comply. Injection + strategy: CONSTITUTION, CONVENTIONS, ARCHITECTURE, AGENT_PLAYBOOK verbatim; + DECISIONS, LEARNINGS index-only; TASKS mention-only. Total ~7,700 tokens. See: + `specs/context-load-gate-v2.md`. +- **Imperative framing**: Advisory framing allowed agents to assess relevance + and skip files. Imperative framing with unconditional compliance checkpoint + removes the escape hatch. Verbatim relay is fallback safety net, not primary + instruction. + +--- + +## [2026-02-26-200001] .context/state/ directory for project-scoped runtime state + +**Status**: Accepted + +New gitignored directory under `context_dir` resolution for ephemeral +project-scoped state. Follows `.context/logs/` precedent — added to +`config.GitignoreEntries` and root `.gitignore`. + +First use: injection oversize flag written by context-load-gate when injected +tokens exceed the configurable `injection_token_warn` threshold (`.ctxrc`, +default 15000). The check-context-size VERBATIM hook reads the flag and nudges +the user to run `/ctx-consolidate`. + +See: `specs/injection-oversize-nudge.md`. + +--- + +## [2026-02-26-100001] Hook and notification design (consolidated) + +**Status**: Accepted + +**Consolidated from**: 4 decisions (2026-02-12 to 2026-02-24) + +- Tone down proactive content suggestion claims in docs rather than add more + hooks. Already have 9 UserPromptSubmit hooks; adding another risks fatigue. + Conversational prompting already works. +- Hook commands must use structured JSON output + (hookSpecificOutput.additionalContext) instead of plain text, because Claude + Code treats plain text as ignorable ambient context. +- Drop prompt-coach hook entirely: zero useful tips fired, output channel + invisible to user, orphan temp file accumulation. The prompting guide already + covers best practices. +- De-emphasize /ctx-journal-normalize from the default journal pipeline. The + normalize skill is expensive and nondeterministic; programmatic normalization + handles most cases. Skill remains available for targeted per-file use. + +--- + +## [2026-02-26-100002] ctx init and CLAUDE.md handling (consolidated) + +**Status**: Accepted + +**Consolidated from**: 3 decisions (2026-01-20) + +- `ctx init` handles CLAUDE.md intelligently: creates if missing, backs up and + offers merge if existing, uses marker comment for idempotency. The `--merge` + flag enables non-interactive append. +- `ctx init` always generates `.claude/hooks/` alongside `.context/` with no + flag needed. Other AI tools ignore `.claude/`; Claude Code users get seamless + zero-config experience. +- Core tool stays generic and tool-agnostic, with optional Claude Code + enhancements via `.claude/hooks/`. Other AI tools can be supported similarly + (`ctx hook cursor`, etc.). + +--- + +## [2026-02-26-100004] Task and knowledge management (consolidated) + +**Status**: Accepted + +**Consolidated from**: 4 decisions (2026-01-27 to 2026-02-18) + +- Tasks must include explicit deliverables, not just implementation steps. + Parent tasks define WHAT the user gets; subtasks decompose HOW to build it. + Without explicit deliverables, AI optimizes for checking boxes. +- Use reverse-chronological order (newest first) for DECISIONS.md and + LEARNINGS.md. Ensures most recent items are read first regardless of token + budget. +- Add quick reference index to DECISIONS.md: compact table at top allows + scanning; agents can grep for full timestamp to jump to entry. Auto-updated on + `ctx add decision`. +- Knowledge scaling via archive path for decisions and learnings: follow the + task archive pattern, move old entries to `.context/archive/`, extend `ctx + compact --archive` to cover all three file types. + +--- + +## [2026-02-26-100005] Agent autonomy and separation of concerns (consolidated) + +**Status**: Accepted + +**Consolidated from**: 3 decisions (2026-01-21 to 2026-01-28) + +- Removed AGENTS.md from project root. Consolidated on CLAUDE.md (auto-loaded) + + .context/AGENT_PLAYBOOK.md as the canonical agent instruction path. Projects + using ctx should not create AGENTS.md. +- ~~Separate orchestrator directive from agent tasks~~ (superseded 2026-03-25: + IMPLEMENTATION_PLAN.md removed — TASKS.md is the single source of truth for + work items, AGENT_PLAYBOOK.md covers agent behavior). +- No custom UI -- IDE is the interface. UI is a liability; IDEs already excel at + file browsing, search, markdown editing, and git integration. Focus CLI + efforts on good markdown output. + +--- + +## [2026-02-26-100006] Security and permissions (consolidated) + +**Status**: Accepted + +**Consolidated from**: 4 decisions (2026-01-21 to 2026-02-24) + +- Keep CONSTITUTION.md minimal: only truly inviolable rules (security, + correctness, process invariants). Style preferences go in CONVENTIONS.md. + Overly strict constitution gets ignored. +- Centralize constants with semantic prefixes in `internal/config/config.go`: + `Dir*` for directories, `File*` for paths, `Filename*` for names, + `UpdateType*` for entry types. Single source of truth, compile-time typo + checks. +- Hooks use `ctx` from PATH, not hardcoded absolute paths. Standard Unix + practice; portable across machines/users. `ctx init` checks PATH availability + before proceeding. +- Drop absolute-path-to-ctx regex from block-dangerous-commands shell script. + The block-non-path-ctx Go subcommand already covers this with better patterns; + duplicating creates two sources of truth. + +--- + +## [2026-02-27-002831] Webhook and notification design (consolidated) + +**Status**: Accepted + +**Consolidated from**: 3 decisions (2026-02-22 to 2026-02-26) + +- **Session attribution**: All webhook payloads must include session_id. Reading + it from stdin costs nothing and enables multi-agent diagnostics. All run + functions take stdin parameter; tests use createTempStdin. +- **Opt-in events**: Notify events are opt-in, not opt-out. EventAllowed returns + false for nil/empty event lists. The correct default for notifications is + silence. `ctx notify test` bypasses the filter as a special case. +- **Shared encryption key**: Webhook URLs encrypted with the shared .ctx.key + (AES-256-GCM), not a dedicated key. One key, one gitignore entry, one rotation + cycle. Notify is a peer of scratchpad — both store user secrets encrypted at + rest. + +--- + +## [2026-02-11] Remove .context/sessions/ storage layer and ctx session command + +**Status**: Accepted + +**Context**: The session/recall/journal system had three overlapping storage +layers: `~/.claude/projects/` (raw JSONL transcripts, owned by Claude Code), +`.context/sessions/` (JSONL copies + context snapshots), and `.context/journal/` +(enriched markdown from `ctx recall import`). The recall pipeline reads directly +from `~/.claude/projects/`, making `.context/sessions/` a dead-end write sink +that nothing reads from. The auto-save hook copied transcripts to a directory +nobody consumed. The `ctx session save` command created context snapshots that +git already provides through version history. This was ~15 Go source files, a +shell hook, ~20 config constants, and 30+ doc references supporting +infrastructure with no consumers. + +**Decision**: Remove `.context/sessions/` entirely. Two stores remain: raw +transcripts (global, tool-owned in `~/.claude/projects/`) and enriched journal +(project-local in `.context/journal/`). + +**Rationale**: Dead-end write sinks waste code surface, maintenance effort, and +user attention. The recall pipeline already proved that reading directly from +`~/.claude/projects/` is sufficient. Context snapshots are redundant with git +history. Removing the middle layer simplifies the architecture from three stores +to two, eliminates an entire CLI command tree (`ctx session`), and removes a +shell hook that fired on every session end. + +**Consequence**: Deleted `internal/cli/session/` (15 files), removed auto-save +hook, removed `--auto-save` from watch, removed pre-compact auto-save from +compact, removed `/ctx-save` skill, updated ~45 documentation files. Four +earlier decisions superseded (SessionEnd hook, Auto-Save Before Compact, Session +Filename Format, Two-Tier Persistence Model). Users who want session history use +`ctx journal source`/`ctx journal import` instead. + +--- + + +*Module-specific, already-shipped, and historical decisions: +[decisions-reference.md](decisions-reference.md)* + +--- + ## [2026-04-25-014704] Use t.Setenv for subprocess env in tests, not append(os.Environ(), ...) **Status**: Accepted diff --git a/.context/LEARNINGS.md b/.context/LEARNINGS.md index e967c8248..cacda61f2 100644 --- a/.context/LEARNINGS.md +++ b/.context/LEARNINGS.md @@ -17,12 +17,1660 @@ DO NOT UPDATE FOR: | Date | Learning | |----|--------| +| 2026-04-14 | Constitution forbids context window as a deferral excuse | +| 2026-04-14 | docs/cli/system.md and embed/cmd/system.go diverged on bootstrap promotion intent | +| 2026-04-14 | Raft-lite trade-off is the load-bearing choice in internal/hub | +| 2026-04-14 | AST stutter test only checks FuncDecl, not GenDecl | +| 2026-04-14 | Brand-name handling in title-case engines must cover possessives | +| 2026-04-13 | GPG signing from non-TTY contexts requires pinentry-mac (or equivalent) | +| 2026-04-13 | Load average measures a queue, not CPU utilization | +| 2026-04-13 | rc.ContextDir() is the single source of truth — fix the resolver, not callers | +| 2026-04-09 | Pad index shifting is a real UX bug in batch operations | +| 2026-04-08 | fmt.Fprintf to strings.Builder silently discards errors | +| 2026-04-08 | AST audit tests must cover unexported functions too | +| 2026-04-06 | Agents ignore system-reminder content without explicit relay instructions | +| 2026-04-04 | Format-verb strings are localizable text, not exempt from magic string checks | +| 2026-04-04 | Agents add allowlist entries to make tests pass — guard every exemption | +| 2026-04-03 | Subagent scope creep and cleanup (consolidated) | +| 2026-04-03 | Bulk rename and replace_all hazards (consolidated) | +| 2026-04-03 | Import cycles and package splits (consolidated) | +| 2026-04-03 | Lint suppression and gosec patterns (consolidated) | +| 2026-04-03 | Skill lifecycle and promotion (consolidated) | +| 2026-04-03 | Cross-cutting change ripple (consolidated) | +| 2026-04-03 | Dead code detection (consolidated) | +| 2026-04-03 | desc.Text() is the single highest-connectivity symbol in the codebase | +| 2026-04-01 | Raw I/O migration unlocks downstream checks for free | +| 2026-04-01 | go/packages respects build tags — darwin-only violations invisible on Linux | +| 2026-04-01 | Copilot CLI skills need a sync mechanism to prevent drift from ctx skills | +| 2026-04-01 | Contributor PRs based on older code reintroduce removed features | +| 2026-03-31 | Magic string cleanup compounds: each pass reveals the next layer | +| 2026-03-31 | Force-loaded behavioral prose gets ignored — action-gating hooks don't | +| 2026-03-31 | Legacy key directory cleanup was specified but not automated | +| 2026-03-31 | Convention audits must check cmd/ purity, not just types and docstrings | +| 2026-03-31 | JSON Schema default fields cause linter errors with some validators | +| 2026-03-30 | Architecture diagrams drift silently during feature additions | +| 2026-03-30 | Python-generated doc.go files need gofmt — formatter strips bare // padding lines | +| 2026-03-30 | lint-docstrings.sh greedy sed hid all return-type violations | +| 2026-03-25 | Machine-generated CLAUDE.md content consumes per-turn budget without proportional value | +| 2026-03-25 | Template improvements don't propagate to existing projects | +| 2026-03-24 | lint-drift false positives from conflating constant namespaces | +| 2026-03-24 | git describe --tags follows ancestry, not global tag list | +| 2026-03-23 | Typography detection script needs exclusion lists for intentional uses | +| 2026-03-23 | Splitting core/ into subpackages reveals hidden structure | +| 2026-03-23 | Higher-order callbacks in param structs are a code smell | +| 2026-03-20 | Commit messages containing script paths trigger PreToolUse hooks | +| 2026-03-18 | Lazy sync.Once per-accessor is a code smell for static embedded data | +| 2026-03-17 | Write package output census: 69 trivial/simple, 38 consolidation candidates, 18 complex | +| 2026-03-16 | Docstring tasks require reading CONVENTIONS.md Documentation section first | +| 2026-03-16 | Convention enforcement needs mechanical verification, not behavioral repetition | +| 2026-03-16 | One-liner method wrappers hide dependencies without adding value | +| 2026-03-16 | Agents reliably introduce gofmt issues during bulk renames | +| 2026-03-15 | Contributor PRs need post-merge follow-up commits for convention alignment | +| 2026-03-15 | Grep for callers must cover entire working tree before deleting functions | +| 2026-03-14 | Stderr error messages are user-facing text that belongs in assets | +| 2026-03-14 | Hardcoded _alt suffixes create implicit language favoritism | +| 2026-03-13 | sync-why mechanism existed but was not wired to build | +| 2026-03-12 | Project-root files vs context files are distinct categories | +| 2026-03-12 | Constants belong in their domain package not in god objects | +| 2026-03-07 | Always search for existing constants before adding new ones | +| 2026-03-07 | SafeReadFile requires split base+filename paths | +| 2026-03-06 | Stale directory inodes cause invisible files over SSH | +| 2026-03-06 | Stats sort uses string comparison on RFC3339 timestamps with mixed timezones | +| 2026-03-06 | Claude Code supports PreCompact and SessionStart hooks that ctx does not use | +| 2026-03-06 | Package-local err.go files invite broken windows from future agents | +| 2026-03-05 | State directory accumulates silently without auto-prune | +| 2026-03-05 | Global tombstones suppress hooks across all sessions | +| 2026-03-05 | Claude Code has two separate memory systems behind feature flags | +| 2026-03-05 | Blog post editorial feedback is higher-leverage than drafting | +| 2026-03-04 | CONSTITUTION hook compliance is non-negotiable — don't work around it | +| 2026-03-02 | Hook message registry test enforces exhaustive coverage of embedded templates | +| 2026-03-02 | Existing Projects is ambiguous framing for migration notes | +| 2026-03-02 | Claude Code JSONL model ID does not distinguish 200k from 1M context | +| 2026-03-01 | Gosec G306 flags test file WriteFile with 0644 permissions | +| 2026-03-01 | Converting PersistentPreRun to PersistentPreRunE changes exit behavior | +| 2026-03-01 | Test HOME isolation is required for user-level path functions | +| 2026-03-01 | Task descriptions can be stale in reverse — implementation done but task not marked complete | +| 2026-03-01 | Model-to-window mapping requires ordered prefix matching | +| 2026-03-01 | TASKS.md template checkbox syntax inside HTML comments is parsed by RegExTaskMultiline | +| 2026-03-01 | Hook logs had no rotation; event log already did | +| 2026-02-28 | ctx pad import, ctx pad export, and ctx system resources make three hack scripts redundant | +| 2026-02-28 | Getting-started docs assumed Claude Code as the only agent | +| 2026-02-28 | Plugin reload script must rebuild cache, not just delete it | +| 2026-02-27 | site/ directory must be committed with docs changes | +| 2026-02-27 | Doctor token_budget vs context_window confusion | +| 2026-02-27 | Drift detector false positives on illustrative code examples | +| 2026-02-27 | Context injection and compliance strategy (consolidated) | +| 2026-02-26 | Webhook silence after ctxrc profile swap is the most common notify debugging red herring | +| 2026-02-26 | Documentation drift and auditing (consolidated) | +| 2026-02-26 | Agent context loading and task routing (consolidated) | +| 2026-02-26 | Go testing patterns (consolidated) | +| 2026-02-26 | PATH and binary handling (consolidated) | +| 2026-02-26 | Task management and exit criteria (consolidated) | +| 2026-02-26 | Agent behavioral patterns (consolidated) | +| 2026-02-26 | Hook compliance and output routing (consolidated) | +| 2026-02-26 | ctx add and decision recording (consolidated) | +| 2026-02-24 | CLI tools don't benefit from in-memory caching of context files | +| 2026-02-22 | Hook behavior and patterns (consolidated) | +| 2026-02-22 | UserPromptSubmit hook output channels (consolidated) | +| 2026-02-22 | Linting and static analysis (consolidated) | +| 2026-02-22 | Permission and settings drift (consolidated) | +| 2026-02-22 | Gitignore and filesystem hygiene (consolidated) | +| 2026-01-28 | IDE is already the UI | | 2026-04-25 | Confident code comments can pull an LLM away from first-principles knowledge | | 2026-04-25 | filepath.Join('', rel) returns rel as CWD-relative, not error | | 2026-04-25 | Parallel go test ./... packages can race on ~/.claude/settings.json | - +--- + +## [2026-04-14-010134] Constitution forbids context window as a deferral excuse + +**Context**: Mid-session, agent proposed pacing through doc.go rewrites with the +reasoning that context budget was tight. + +**Lesson**: The CONSTITUTION explicitly lists 'We are running out of context +window' as a forbidden deferral phrase under No Excuse Generation. The rule is +real and applies to agent self-pacing, not just user-facing answers. + +**Application**: When tempted to scope down because context is tight, re-read +the constitution. The right move is to do the work end-to-end, not to ask the +user which slice to skip. + +--- + +## [2026-04-14-010134] docs/cli/system.md and embed/cmd/system.go diverged on bootstrap promotion intent + +**Context**: Header comment in internal/config/embed/cmd/system.go claimed +bootstrap was promoted to top-level; the bootstrap.go registration never +actually promoted it. Two contradictory sources of truth coexisted silently. + +**Lesson**: Header-comment claims about command-tree structure are unaudited; +they can drift from registrations without any test failing. Trust the code, not +the comment. + +**Application**: When evaluating any package_name namespace cleanup type claim +about command structure, verify against the actual cobra registration in +internal/bootstrap/group.go before acting. + +--- + +## [2026-04-14-010134] Raft-lite trade-off is the load-bearing choice in internal/hub + +**Context**: Discovered while writing thorough doc.go for internal/hub. The +package embeds HashiCorp Raft for leader election only; data replication is +sequence-based gRPC sync over the append-only JSONL store. + +**Lesson**: A leader crash window between accept and replicate can lose the most +recent write. Append-only storage plus idempotent clients make this acceptable; +full Raft log replication would not be needed and would not be simpler. + +**Application**: Any future make hub stronger proposal must engage with this +trade-off explicitly. Do not abandon Raft-lite accidentally by introducing +log-replicated state; that would invalidate the simplicity argument. + +--- + +## [2026-04-14-010134] AST stutter test only checks FuncDecl, not GenDecl + +**Context**: tpl.TplEntryMarkdown stuttered for a long time because +TestNoStutteryFunctions in internal/audit walks *ast.FuncDecl only; the constant +slipped through. + +**Lesson**: The audit suite has a real coverage gap for *ast.GenDecl (consts, +vars, types). Stuttery type/const names will not be caught until the audit is +extended to walk those node kinds. + +**Application**: When a stuttery identifier is reported by a human, check both +the offending file and whether the audit can catch it; if not, file an +audit-extension task. + +--- + +## [2026-04-14-010105] Brand-name handling in title-case engines must cover possessives + +**Context**: First pass of hack/title-case-headings.py produced 'Ctx's' from +'ctx's' because the brand check matched the bare token only. + +**Lesson**: A brand allowlist needs to recognize , 's, s, +and short apostrophe-suffixed variants. Single-word matching misses contractions +and possessives. + +**Application**: When adding a new always-lowercase brand to +hack/title-case-headings.py, extend the suffix-aware loop in title_case_word, +not just the BRAND_LOWER set. + +--- + +## [2026-04-13-153618] GPG signing from non-TTY contexts requires pinentry-mac (or equivalent) + +**Context**: git commit failed from Claude Code's shell with 'gpg: signing +failed: No such file or directory' — the default pinentry-curses cannot open a +TTY in agent-invoked shells. Manual commits from a real terminal worked fine. + +**Lesson**: GPG's default curses pinentry requires an interactive TTY. In +non-TTY contexts (Claude Code, CI, scripts, cron), signing fails silently-ish. +The fix is to configure a GUI pinentry that uses the OS keychain: brew install +pinentry-mac; echo 'pinentry-program $(brew --prefix)/bin/pinentry-mac' >> +~/.gnupg/gpg-agent.conf; gpgconf --kill gpg-agent. Once the passphrase is saved +in Keychain, signing works from any context. + +**Application**: If agents or CI need to sign commits, configure pinentry-mac +(macOS) or pinentry-gtk/pinentry-qt (Linux) with the OS keychain, not +pinentry-curses. This is a one-time setup per machine. + +--- + +## [2026-04-13-153618] Load average measures a queue, not CPU utilization + +**Context**: The 'Load Xx CPU count' resource alert fired at 1.74x while htop +showed per-core utilization well under 50% and idle cores. Load average counts +runnable + uninterruptible-sleep processes, smoothed over 1/5/15 minutes. + +**Lesson**: Load average and CPU% measure different things. High load with low +CPU% typically means many short-lived processes or I/O-bound work (e.g., go test +spawning hundreds of parallel test binaries). The 1-minute average is too +reactive for dev machines that periodically run test suites — 5-minute smooths +transient spikes without hiding sustained pressure. + +**Application**: For alerting thresholds based on system load, prefer 5-minute +over 1-minute averages. 1-minute is useful for interactive debugging; 5-minute +is better for automated alerts that should not fire on normal build/test +activity. + +--- + +## [2026-04-13-153618] rc.ContextDir() is the single source of truth — fix the resolver, not callers + +**Context**: When ctx init failed with a boundary error, my first instinct was +to have init bypass rc.ContextDir() and use filepath.Join(cwd, dir.Context) +directly. Volkan shut that down: rc.ContextDir() encodes invariants (team +shares, symlinks, network mounts, .ctxrc overrides) that individual commands +cannot reason about. + +**Lesson**: Resolution chains with multiple fallbacks are contracts. If one +command bypasses the chain, it silently diverges from every other command's +notion of 'the context directory.' When a resolver produces a wrong answer for a +specific case, fix the resolver — don't let callers opt out. + +**Application**: Any time you see rc.ContextDir(), rc.RC(), or similar central +resolvers producing a bad result, the fix belongs in the resolver itself (or in +its input data like .ctxrc). Caller-side bypasses create drift. + +--- + +## [2026-04-09-001323] Pad index shifting is a real UX bug in batch operations + +**Context**: ctx pad rm 10; rm 11; rm 12 deleted wrong entries because indices +shifted after each deletion + +**Lesson**: Any ID-based system where users chain operations needs stable IDs. +Look-then-act is safe for single ops; look-then-batch-act breaks with shifting +indices + +**Application**: Both pad and remind now use stable IDs with batch delete and +range support. Apply same pattern to any future numbered-list subsystem + +--- + +## [2026-04-08-074612] fmt.Fprintf to strings.Builder silently discards errors + +**Context**: golangci-lint errcheck allows fmt.Fprintf to strings.Builder +because Write never fails, but project convention says zero silent discard + +**Lesson**: Linter coverage gaps exist where language guarantees mask +conventions. AST tests fill the gap + +**Application**: Created TestNoUncheckedFmtWrite to enforce fmt.Fprintf error +handling. Use if _, err := fmt.Fprintf(...) with log.Warn on the error path + +--- + +## [2026-04-08-074604] AST audit tests must cover unexported functions too + +**Context**: TestDocCommentStructure only checked exported functions, so +agent-written helpers in format.go had no godoc enforcement + +**Lesson**: Convention enforcement tests must default to scanning all documented +functions. Use explicit opt-outs (test files) not opt-ins (exported only) + +**Application**: When adding AST audit tests, scan all functions. We fixed +TestDocCommentStructure to drop the IsExported gate and fixed 84 violations + +--- + +## [2026-04-06-204226] Agents ignore system-reminder content without explicit relay instructions + +**Context**: Provenance line (Session: abc | Branch: main @ hash) was emitted by +hook but agents in other projects silently ignored it. The line appeared in the +system-reminder but the agent treated it as internal metadata. + +**Lesson**: Claude Code surfaces hook stdout as system-reminder tags. Agents +only relay content that has explicit display instructions. IMPORTANT: means pay +attention internally. Display this line verbatim means show to user. Without the +instruction, even correct output is invisible to the user. + +**Application**: Any hook output intended for the user must include an explicit +relay instruction like Display this line verbatim at the start of your response. +Do not rely on IMPORTANT: alone — it signals internal priority, not +user-facing output. + +--- + +## [2026-04-04-025813] Format-verb strings are localizable text, not exempt from magic string checks + +**Context**: Strings like '%d entries checked' were passing TestNoMagicStrings +because the format-verb exemption was too broad + +**Lesson**: Any string containing English words alongside format directives is +user-facing text that belongs in YAML assets + +**Application**: Removed format-verb, URL-scheme, HTML-entity, and err/ +exemptions from TestNoMagicStrings + +--- + +## [2026-04-04-025805] Agents add allowlist entries to make tests pass — guard every exemption + +**Context**: Found that every exemption map/allowlist in audit tests is a +tempting shortcut for agents + +**Lesson**: Added DO NOT widen guard comments to all 10 exemption data +structures across 7 test files + +**Application**: Every new audit test with an exemption must include the guard +comment. Review PRs for drive-by allowlist additions. + +--- + +## [2026-04-03-180000] Subagent scope creep and cleanup (consolidated) + +**Consolidated from**: 4 entries (2026-03-06 to 2026-03-23) + +- Subagents reliably rename functions, restructure files, change import aliases, + and modify function signatures beyond their stated scope — even narrowly + scoped tasks like fixing em-dashes in comments +- Subagents create new files during refactors but consistently fail to delete + the originals — always audit for stale files, duplicate definitions, and + orphaned imports afterward +- After any agent-driven refactor: run `git diff --stat` and `git diff + --name-only HEAD`, revert anything outside the intended scope, and check for + stale package declarations before building + +--- + +## [2026-04-03-180000] Bulk rename and replace_all hazards (consolidated) + +**Consolidated from**: 3 entries (2026-03-15 to 2026-03-20) + +- `replace_all` on short tokens (e.g. `core.`, function names) matches inside + longer identifiers and function definitions — `remindcore.` becomes + `remindtidy.`, `func HumanAgo` becomes `func format.DurationAgo` (invalid Go) +- `sed` insert-before-first-match does not understand Go import aliases — the + alias attaches to whatever line sed inserts, not the original target +- For function renames: delete the old definition separately rather than using + replace_all. For bulk import additions: check for aliased imports first and + handle them separately, or use goimports + +--- + +## [2026-04-03-180000] Import cycles and package splits (consolidated) + +**Consolidated from**: 5 entries (2026-03-06 to 2026-03-22) + +- Types in god-object files (e.g. hook/types.go with 15+ types from 8 domains) + create circular dependencies — move types to their owning domain package +- Tests in parent package X cannot import X/sub packages that import X back — + move tests to the sub-package they exercise +- Variable shadowing causes cascading failures after splits: `dir`, `file`, + `entry` are common Go variable names that collide with new sub-package names + — run `go test ./...` before committing splits +- When moving constants between packages, change imports and all references in a + single atomic write so the linter never sees an inconsistent state +- Import cycle rule: the package providing implementation logic must own the + shared types; the facade package aliases them (e.g. `entry.Params` aliases + `add/core.EntryParams`) + +--- + +## [2026-04-03-180000] Lint suppression and gosec patterns (consolidated) + +**Consolidated from**: 4 entries (2026-03-04 to 2026-03-19) + +- Rename constants to avoid gosec G101 false positives (Tokens->Usage, + Passed->OK) instead of adding nolint/nosec/path exclusions — exclusions + break on file reorganization +- `nolint:goconst` for trivial values normalizes magic strings — use config + constants instead of suppressing the linter +- `nolint:errcheck` in tests teaches agents to spread the pattern to production + code — use `t.Fatal(err)` for setup, `defer func() { _ = f.Close() }()` for + cleanup +- golangci-lint v2 ignores inline nolint directives for some linters — use + config-level `exclusions.rules` for gosec patterns, fix the code instead of + suppressing errcheck + +--- + +## [2026-04-03-180000] Skill lifecycle and promotion (consolidated) + +**Consolidated from**: 4 entries (2026-03-01 to 2026-03-14) + +- Internal skill renames and promotions require synchronized updates across 6+ + layers: SKILL.md frontmatter, internal cross-references, external docs, + embed_test.go expected list, recipe/reference docs, and plugin cache rebuild + + session restart +- Skill behavior changes ripple through hook messages, fallback strings in Go + code, doc descriptions, and Makefile hints — grep for the skill name across + the entire repo +- Skills without a trigger mechanism (no user invocation, no hook loading) are + dead code — audit skills for reachability +- After promoting skills: grep -r for the old name across the whole tree, run + plugin-reload.sh, restart session to verify autocomplete, and clean stale + Skill() entries from settings.local.json + +--- + +## [2026-04-03-180000] Cross-cutting change ripple (consolidated) + +**Consolidated from**: 4 entries (2026-02-19 to 2026-03-01) + +- Path changes (e.g. key file location) ripple across 15+ doc files and 2 skills + — grep broadly (not just code) and budget for 15+ file touches +- Removing embedded asset directories requires synchronized cleanup across 5+ + layers: embed directive, accessor functions, callers, tests, config constants, + build targets, documentation — work outward from the embed +- Absorbing shell scripts into Go commands creates a discoverability gap — + update contributing.md, common-workflows.md, and CLI index as part of the + absorption checklist +- A feature without docs is invisible to users: always check feature page, + cli-reference.md, relevant recipes, and zensical.toml nav after implementing a + new CLI subcommand + +--- + +## [2026-04-03-180000] Dead code detection (consolidated) + +**Consolidated from**: 3 entries (2026-03-15 to 2026-03-30) + +- Dead packages can build and test green while being completely unreachable — + detection requires checking bootstrap registration, not just build success + (e.g. internal/cli/recall/ existed with tests but was never wired into the + command tree) +- Files created by `ctx init` that no agent, hook, or skill ever reads are dead + on arrival — verify there is at least one consumer before adding to init + scaffolding +- When touching legacy compat code, first ask whether the legacy path has real + users — if not, delete it entirely rather than improving it (MigrateKeyFile + had 5 callers and test coverage but zero users) + +--- + +## [2026-04-03-133244] desc.Text() is the single highest-connectivity symbol in the codebase + +**Context**: GitNexus enrichment during architecture analysis revealed +desc.Text() (internal/assets/read/desc/desc.go:75) has 30+ direct callers +spanning every architectural layer (MCP handler, format, index, tidy, trace, +memory, sysinfo, io) and participates in 53 execution flows. + +**Lesson**: TestDescKeyYAMLLinkage is the most critical guard in the codebase +— it protects the symbol with the widest blast radius. If YAML text loading +breaks, the entire CLI and MCP server output blank strings silently (no crash, +no warning). + +**Application**: Treat desc.Text() as a frozen API — add new functions rather +than modifying the existing signature. Any change to config/embed/text or +assets/read/desc should be followed by running the linkage audit. Monitor this +symbol during major refactors. + +--- + +## [2026-04-01-233250] Raw I/O migration unlocks downstream checks for free + +**Context**: TestNoRawPermissions had zero violations because the raw I/O +migration moved all octal literals into internal/io/ which already used +config/fs constants + +**Lesson**: Chokepoint migrations have cascading benefits — centralizing one +concern (file I/O) automatically resolves other drift (raw permissions) + +**Application**: Prioritize chokepoint migrations (io, exec, write, err) before +smaller checks that depend on them + +--- + +## [2026-04-01-233248] go/packages respects build tags — darwin-only violations invisible on Linux + +**Context**: TestNoExecOutsideExecPkg could not detect violations in _darwin.go +files when running on Linux + +**Lesson**: AST checks using go/packages only see files matching the current +GOOS. Cross-platform violations need either multi-GOOS CI or a go/parser +fallback + +**Application**: When writing audit checks for code with build tags, fix the +violations regardless (code correctness) but note that test coverage is +platform-dependent + +--- + +## [2026-04-01-074419] Copilot CLI skills need a sync mechanism to prevent drift from ctx skills + +**Context**: 5 Copilot CLI skills were condensed versions of ctx skills, +independently maintained with no drift detection + +**Lesson**: Any time the same content exists in two locations without a sync +mechanism, it will drift silently + +**Application**: make sync-copilot-skills added to build deps, make +check-copilot-skills added to audit target + +--- + +## [2026-04-01-074418] Contributor PRs based on older code reintroduce removed features + +**Context**: PR #45 brought back prompt templates, PROMPT.md, and +IMPLEMENTATION_PLAN.md that were explicitly removed in March + +**Lesson**: When resolving contributor merge conflicts, check decisions history +for intentional removals — do not assume the PR content is additive + +**Application**: Cross-reference DECISIONS.md before accepting PR content that +adds files or features + +--- + +## [2026-03-31-224247] Magic string cleanup compounds: each pass reveals the next layer + +**Context**: What started as fix 4 fmt.Fprintf(os.Stderr) calls expanded to +over-tokenized format strings, magic hex perms, unstandardized TOML parsing +tokens, missing docstrings on new constants — each fix exposed adjacent +violations + +**Lesson**: Mechanical cleanup is fractal. The first sweep finds the obvious +violations, but fixing them puts adjacent code under scrutiny. Budget for 2-3x +the initial estimate + +**Application**: When scoping cleanup tasks, do not commit to done in one pass. +Commit after each layer and let the user decide when to stop + +--- + +## [2026-03-31-182054] Force-loaded behavioral prose gets ignored — action-gating hooks don't + +**Context**: AGENT_PLAYBOOK was force-injected at ~14k tokens every session. +Agent routinely skipped its Context Readback directive when the user's first +message was a concrete task. Meanwhile, hooks that gate actions (qa-reminder, +specs-nudge, block-dangerous-commands) were consistently followed because they +fire at the moment of violation. + +**Lesson**: Prose instructions compete with the user's immediate request and +lose. Hooks that intercept actions at execution time are enforceable. More +injected content means less attention per token — slim injection to only what +must be internalized before any action. + +**Application**: When adding agent directives, prefer action-gating hooks over +injected prose. If it must be injected, keep it small and directive-only. +Reserve force-injection for hard rules (CONSTITUTION) and distilled actionable +checklists (gate file). + +--- + +## [2026-03-31-112534] Legacy key directory cleanup was specified but not automated + +**Context**: ~/.local/ctx/keys/ accumulated 584 orphan keys from test runs +before the v0.8.0 migration to ~/.ctx/.ctx.key + +**Lesson**: Migration specs that call for manual cleanup of old paths should +include an automated step — either in the migration code itself or as a +post-release cleanup task. Tests that write to global paths must isolate HOME. + +**Application**: When writing migration specs, always include automated cleanup +of the old path. When writing tests that touch user-level directories, verify +HOME is isolated via t.Setenv. + +--- + +## [2026-03-31-005112] Convention audits must check cmd/ purity, not just types and docstrings + +**Context**: Placed needsSpec helper in cmd/root/run.go instead of +core/entry/predicate.go. Missed it because the audit checklist only covered +types and docstrings + +**Lesson**: cmd/ directories must contain only Cmd() and Run*() — all helper +functions, unexported logic, and types belong in core/. Added TestCmdDirPurity +compliance test to enforce this mechanically + +**Application**: The compliance test now catches this automatically. 28 +pre-existing violations grandfathered in the allowlist + +--- + +## [2026-03-31-005110] JSON Schema default fields cause linter errors with some validators + +**Context**: ctxrc.schema.json had default: values on 16 fields that triggered +incompatible type errors in the user's linter + +**Lesson**: Move default values into the description string instead of using the +default keyword — Go rc.*() accessors handle the actual defaults + +**Application**: When adding new .ctxrc fields, document defaults in the +description, never use default: in the schema + +--- + +## [2026-03-30-075941] Architecture diagrams drift silently during feature additions + +**Context**: During the journal-recall merge, architecture-dia-build.md listed +23 CLI packages but 31 existed. 8 packages added over months without updating +the diagram. + +**Lesson**: Exhaustive lists and counts in architecture docs go stale every time +a package is added. The drift is invisible because nobody re-counts. + +**Application**: After adding a new CLI package, grep architecture diagrams for +package counts and directory listings. Consider adding a drift-check comment +that validates the count programmatically. + +--- + +## [2026-03-30-003734] Python-generated doc.go files need gofmt — formatter strips bare // padding lines + +**Context**: Batch-generated doc.go files used blank // lines for padding, which +gofmt removes as unnecessary whitespace + +**Lesson**: Programmatic Go file generation must produce substantive content +lines, not blank comment padding — gofmt enforces this + +**Application**: Always run gofmt after any scripted Go file generation + +--- + +## [2026-03-30-003707] lint-docstrings.sh greedy sed hid all return-type violations + +**Context**: sed 's/.*) //' consumed return type parens, leaving { — functions +with return types were invisible to the script for months + +**Lesson**: Greedy regex in shell scripts can silently suppress entire +categories of lint violations — test with edge cases, not just happy paths + +**Application**: When writing sed-based lint checks, test with multi-paren +signatures (func Foo() (string, error)) + +--- + +## [2026-03-25-234039] Machine-generated CLAUDE.md content consumes per-turn budget without proportional value + +**Context**: GitNexus injected 121 lines (61% of CLAUDE.md) with auto-generated +skill pointers like 'Work in the Watch area (39 symbols)' — generic index data +loaded on every conversation turn + +**Lesson**: CLAUDE.md is prime real estate — every token competes with +project-specific instructions. Auto-generated content belongs in on-demand +skills, not in always-loaded files + +**Application**: Audit CLAUDE.md periodically for content that could be +delivered via skills instead. Prefer a one-line pointer over inline content for +companion tools + +--- + +## [2026-03-25-173338] Template improvements don't propagate to existing projects + +**Context**: 5 of 8 context files in the ctx project itself had stale/missing +comment headers — templates evolved but non-destructive init never re-synced +them + +**Lesson**: Any template change is invisible to existing users until they run +ctx init --force + +**Application**: Added drift detection (checkTemplateHeaders) to ctx drift. +Consider surfacing this during ctx status too. + +--- + +## [2026-03-24-001001] lint-drift false positives from conflating constant namespaces + +**Context**: lint-drift.sh checked all string constants in embed/cmd/*.go +against commands.yaml, but Use* constants are cobra syntax strings, not YAML +lookup keys + +**Lesson**: Shell grep on constant values cannot distinguish constant types; +only DescKey* constants are YAML keys. AST-based analysis is needed for +type-aware checks + +**Application**: Already captured in specs/ast-audit-tests.md; the lint-drift +fix is shipped in v0.8.0 + +--- + +## [2026-03-24-000959] git describe --tags follows ancestry, not global tag list + +**Context**: Release notes skill diffed against v0.3.0 instead of v0.6.0 because +the release branch diverged before v0.6.0 was tagged + +**Lesson**: git describe --tags --abbrev=0 follows reachability from HEAD; use +git tag --sort=-v:refname | head -1 for the latest tag globally + +**Application**: Any script or skill that needs the latest release should use +sorted tag list, not describe + +--- + +## [2026-03-23-165611] Typography detection script needs exclusion lists for intentional uses + +**Context**: detect-ai-typography.sh flagged config/token/delim.go (intentional +delimiter constants) and test files (test data containing em-dashes) + +**Lesson**: Detection scripts for convention enforcement need exclusion patterns +for files where the flagged patterns are intentional data, not prose + +**Application**: Add exclusion patterns proactively when creating detection +scripts; *_test.go and constant-definition files are common false positive +sources + +--- + +## [2026-03-23-003544] Splitting core/ into subpackages reveals hidden structure + +**Context**: init core/ was a flat bag of domain objects — splitting into +backup/, claude/, entry/, merge/, plan/, plugin/, project/, prompt/, tpl/, +validate/ exposed duplicated logic, misplaced types, and function-pointer +smuggling that were invisible in the flat layout + +**Lesson**: Flat core/ packages hide coupling — circular dependency resolution +during splits naturally groups related items, increases cohesion, and surfaces +objects that don't belong + +**Application**: When a core/ package grows, split it into subpackages even if +it creates temporary circular deps — resolving those deps is the design work +that reveals the right structure + +--- + +## [2026-03-23-003353] Higher-order callbacks in param structs are a code smell + +**Context**: MergeParams.UpdateFn and DeployParams.ListErr/ReadErr were function +pointers where all callers passed thin wrappers varying only by a text key + +**Lesson**: If all callers pass thin wrappers around the same pattern +(fmt.Errorf with different keys), the callback is just data in disguise + +**Application**: When a struct field is a function pointer, check if all callers +vary only by a string key — if so, replace the callback with the key and let +the consumer do the dispatch + +--- + +## [2026-03-20-160112] Commit messages containing script paths trigger PreToolUse hooks + +**Context**: Git commit message body contained a path to a shell script under +the hack directory which matched a hook pattern that blocks direct script +invocation + +**Lesson**: Hooks scan all Bash tool input including heredoc content used for +commit messages, not just the command itself + +**Application**: Rephrase commit messages and ctx add content to avoid paths +that match hook deny patterns, use generic references instead of literal file +paths + +--- + +## [2026-03-18-133457] Lazy sync.Once per-accessor is a code smell for static embedded data + +**Context**: assets package had 4 sync.Once guards, 4 exported maps, 4 Load*() +functions, and a wrapper desc package — all to lazily load YAML from embed.FS +that never mutates. Every accessor call went through sync.Once + global map + +wrapper indirection. + +**Lesson**: When data is static and loaded from embedded bytes, scatter-loading +with per-accessor sync.Once is over-engineering. A single Init() called eagerly +at startup is simpler, and one sync.Once on Init() itself provides the test +safety net. Exported maps that exist only for wrapper packages to reach are a +sign the abstraction boundary is wrong. + +**Application**: Prefer eager Init() in main.go for static embedded data. Keep +maps unexported. Accessors do plain map lookups. If a wrapper package exists +solely to break a cycle caused by exported state, delete the wrapper and +unexport the state. + +--- + +## [2026-03-17-105637] Write package output census: 69 trivial/simple, 38 consolidation candidates, 18 complex + +**Context**: Full audit of internal/write/ (26 files, 160 functions, 337 Println +calls) to evaluate whether block template consolidation is worth a systematic +refactor. + +**Lesson**: Only 30% of write functions benefit from output consolidation. The +sweet spot is multi-line (16) and conditional (22) functions. + +**Application**: Check function category before consolidating. Trivial/simple +stay as-is. Conditional functions need pre-computation before block templates. +Loop-based complex functions stay imperative. Don't bulk-refactor. + +--- + +## [2026-03-16-114227] Docstring tasks require reading CONVENTIONS.md Documentation section first + +**Context**: Agent was asked to review docstrings in server.go but skipped +convention loading, missed incomplete Parameter/Returns sections, and needed +three hints to recall the known issue + +**Lesson**: Any task involving docstrings, comments, or documentation formatting +is a convention-sensitive task — read CONVENTIONS.md (Documentation section) +and LEARNINGS.md (for known gaps) before reviewing or writing + +**Application**: On any docstring/comment task: (1) load CONVENTIONS.md +Documentation section, (2) check LEARNINGS.md for related entries, (3) audit all +functions in scope against the convention template, not just the ones in the +diff + +--- + +## [2026-03-16-104146] Convention enforcement needs mechanical verification, not behavioral repetition + +**Context**: Godoc Parameters/Returns sections were missed repeatedly across +sessions despite memory entries and feedback + +**Lesson**: System-level brevity instructions outcompete context-injected +conventions. Memory shifts probability (~40% to ~70%) but doesn't create +invariants. The competing pressures are architectural, not a recall problem. + +**Application**: Invest in linter rules or PreToolUse gates for +mechanically-checkable conventions. Reserve behavioral nudges for judgment calls +that can't be linted. See ideas/spec-convention-enforcement.md for the +three-tier strategy. + +--- + +## [2026-03-16-022650] One-liner method wrappers hide dependencies without adding value + +**Context**: checkBoundary() and loadContext() were methods on Handler that just +called validation.ValidateBoundary and context.Load with h.ContextDir + +**Lesson**: If a method only passes a struct field to a stdlib function, inline +it — the wrapper obscures the real dependency + +**Application**: Before extracting a helper method, check if it just forwards a +field to another function. If so, call the function directly. + +--- + +## [2026-03-16-022642] Agents reliably introduce gofmt issues during bulk renames + +**Context**: Subagents renamed consequences->consequence across 75+ files but +left formatting errors in 12 Go files + +**Lesson**: Always run gofmt -l after agent-driven refactors before trusting the +build + +**Application**: Add gofmt -w pass as a standard step after any agent-driven +bulk edit + +--- + +## [2026-03-15-101342] Contributor PRs need post-merge follow-up commits for convention alignment + +**Context**: PR #42 (MCP v0.2) addressed bulk of review feedback but left ~12 +inline strings, no embed_test coverage, and substring matching in +containsOverlap + +**Lesson**: Merging with known gaps is fine when the gaps are mechanical, but +the follow-up must be immediate — track in ideas/done/ with a review status +doc + +**Application**: For future contributor PRs: create ideas/pr{N}-review-status.md +during review, merge when architecture is sound, fix convention gaps in a +same-day follow-up commit + +--- + +## [2026-03-15-040642] Grep for callers must cover entire working tree before deleting functions + +**Context**: Deleted 7 err/prompt functions as dead code, but callers existed in +unstaged refactoring files — caused build failures + +**Lesson**: When the working tree has unstaged changes from a prior session, +grep hits only committed+staged code; must grep the full tree or build-test +before declaring functions dead + +**Application**: Always run make build after deleting functions, even if grep +shows zero callers + +--- + +## [2026-03-14-180903] Stderr error messages are user-facing text that belongs in assets + +**Context**: Added fmt.Fprintf(os.Stderr) error reporting to event log, +initially with inline strings + +**Lesson**: Any string that reaches the user, including stderr warnings, routes +through assets.TextDesc() for i18n readiness + +**Application**: When adding stderr output, create text.yaml entries and asset +keys first + +--- + +## [2026-03-14-131202] Hardcoded _alt suffixes create implicit language favoritism + +**Context**: Session parser had session_prefix_alt hardcoding Turkish as a +special case alongside English default + +**Lesson**: Naming a constant _alt and hardcoding one non-English language as a +built-in default discriminates by giving that language special status. The +pattern doesn't scale (alt_2? alt_3?) and signals that adding languages requires +code changes. + +**Application**: When a feature needs multi-value support, use configurable +lists from the start — not hardcoded pairs with _alt suffixes. Default to a +single canonical value; all extensions are user-configured equally. + +--- + +## [2026-03-13-151952] sync-why mechanism existed but was not wired to build + +**Context**: assets/why/ had drifted from docs/ — the sync targets existed in +the Makefile but build did not depend on sync-why + +**Lesson**: Freshness checks that are not in the critical path will be +forgotten. Wire them as build prerequisites, not optional audit steps + +**Application**: Any derived or copied asset should be a prerequisite of build, +not just audit + +--- + +## [2026-03-12-133008] Project-root files vs context files are distinct categories + +**Context**: Tried moving ImplementationPlan constant to config/ctx assuming it +was a context file. (Note: IMPLEMENTATION_PLAN.md was removed in 2026-03-25 as a +dead file — no agent consumer.) + +**Lesson**: Files created by ctx init in the project root (Makefile) are +scaffolding, not context files loaded via ReadOrder. They belong in config/file, +not config/ctx + +**Application**: Before moving a file constant, check whether it is in ReadOrder +(context) or created by init (project-root) + +--- + +## [2026-03-12-133007] Constants belong in their domain package not in god objects + +**Context**: file.go held agent scoring constants, budget percentages, cooldown +durations — none related to file config + +**Lesson**: When a constant is only used by one domain (e.g. agent scoring), it +should live in that domain's config package + +**Application**: Check callers before placing constants; if all callers are in +one domain, the constant belongs there + +--- + +## [2026-03-07-221151] Always search for existing constants before adding new ones + +**Context**: Added ExtJsonl constant to config/file.go but ExtJSONL already +existed with the same value, causing a duplicate + +**Lesson**: Grep for the value (e.g. '.jsonl') across config/ before creating a +new constant — naming variations (camelCase vs ALLCAPS) make duplicates easy +to miss + +**Application**: Before adding any new constant to internal/config, search by +value not just by name + +--- + +## [2026-03-07-221148] SafeReadFile requires split base+filename paths + +**Context**: During system/core cleanup, persistence.go passed a full path to +validation.SafeReadFile which expects (baseDir, filename) separately + +**Lesson**: Use filepath.Dir(path) and filepath.Base(path) to split full paths +when adapting os.ReadFile calls to SafeReadFile + +**Application**: When converting os.ReadFile to SafeReadFile, always check +whether the existing code has a full path or separate components + +--- + +## [2026-03-06-141506] Stale directory inodes cause invisible files over SSH + +**Context**: Files created by Claude Code hooks were visible inside the VM but +not from the SSH terminal + +**Lesson**: If a directory is recreated (e.g. by auto-prune), an SSH shell +holding the old directory inode will not see new files — ls returns no such +file even though cat with the full path works from other shells + +**Application**: After ctx system prune or any state directory recreation, SSH +sessions need cd-dot or re-login to pick up the new inode + +--- + +## [2026-03-06-141504] Stats sort uses string comparison on RFC3339 timestamps with mixed timezones + +**Context**: ctx system stats showed only old sessions, hiding the current one + +**Lesson**: RFC3339 string comparison breaks when entries mix UTC (Z) and offset +(-08:00) formats — 13:00-08:00 sorts before 18:00Z lexicographically despite +being later in absolute time + +**Application**: Always parse to time.Time before comparing RFC3339 timestamps; +never rely on lexicographic sort + +--- + +## [2026-03-06-184820] Claude Code supports PreCompact and SessionStart hooks that ctx does not use + +**Context**: context-mode proves both hooks work in production across 5 +platforms + +**Lesson**: ctx's hook architecture only uses UserPromptSubmit, PreToolUse, and +PostToolUse — two lifecycle events are untapped + +**Application**: PreCompact snapshot plus SessionStart re-injection would +eliminate post-compaction disorientation without any new persistence layer since +ctx agent already generates the content + +--- + +## [2026-03-06-050125] Package-local err.go files invite broken windows from future agents + +**Context**: Found err.go files in 5 CLI packages with heavily duplicated error +constructors (errFileWrite, errMkdir, errZensicalNotFound repeated across +packages) + +**Lesson**: Centralizing errors in internal/err eliminates duplication and +prevents agents from continuing the pattern of adding local err.go files when +they see one exists + +**Application**: New error constructors go to internal/err/errors.go. No err.go +files in CLI packages. + +--- + +## [2026-03-05-205422] State directory accumulates silently without auto-prune + +**Context**: Found 234 files in .context/state/ from weeks of sessions with no +cleanup mechanism + +**Lesson**: Session tombstones are write-only. Without auto-prune, the state +directory grows unbounded. Added autoPrune(7) to context-load-gate so cleanup +happens once per session at startup. + +**Application**: Auto-prune is now wired into session start via +context-load-gate. Manual prune still available via ctx system prune for +aggressive cleanup. + +--- + +## [2026-03-05-205419] Global tombstones suppress hooks across all sessions + +**Context**: Memory drift nudge used memory-drift-nudged with no session ID in +filename + +**Lesson**: Any tombstone file intended to be session-scoped must include the +session ID in its filename, otherwise it suppresses across all concurrent and +future sessions. Use the UUID pattern so prune can clean them up. + +**Application**: Audit all tombstone files for session-scoping; fixed +memory-drift, but backup-reminded, ceremony-reminded, check-knowledge, +journal-reminded, version-checked, ctx-wrapped-up still have this bug + +--- + +## [2026-03-05-042157] Claude Code has two separate memory systems behind feature flags + +**Context**: Filesystem and behavioral analysis of Claude Code v2.1.69 + +**Lesson**: Claude Code has two separate memory systems behind feature flags. +Auto memory writes MEMORY.md to disk (user-visible, toggleable via settings). +Session memory is a separate background extraction pipeline with compaction and +team sync (push/pull model). The two systems serve different purposes and are +independently feature-flagged. + +**Application**: ctx memory bridge targets auto memory (MEMORY.md on disk). +Session memory is API-side and not directly accessible. Full findings in +ideas/claude-code-project-directory-structure.md. + +--- + +## [2026-03-05-023941] Blog post editorial feedback is higher-leverage than drafting + +**Context**: Draft of Agent Memory Is Infrastructure was publication-quality on +first pass; user editorial feedback (structural emphasis, rhetorical sharpening, +amnesia/archaeology bridge) elevated it significantly more than initial +generation + +**Lesson**: For narrative content, the first draft captures the argument; the +editorial pass captures the voice. Both are necessary but the editorial pass has +disproportionate impact on quality. + +**Application**: For future blog posts, invest more in the editorial cycle +(structural feedback then targeted refinements) rather than trying to nail voice +on first generation. + +--- + +## [2026-03-04-105239] CONSTITUTION hook compliance is non-negotiable — don't work around it + +**Context**: After make build, ran ./ctx deps --help which was blocked by +block-non-path-ctx. Instead of asking user to install, tried cp ctx ~/bin/ — +escalating workarounds. + +**Lesson**: When a hook blocks an action, the correct response is to follow the +hook's instruction (ask the user to sudo make install), not to find creative +bypasses. + +**Application**: Always ask the user to install when testing a freshly built +binary. Never attempt alternative install paths to circumvent a hook. + +--- + +## [2026-03-02-165039] Hook message registry test enforces exhaustive coverage of embedded templates + +**Context**: Adding billing.txt to embedded assets without a registry entry +caused TestRegistryCoversAllEmbeddedFiles to fail immediately + +**Lesson**: Every new .txt file under internal/assets/hooks/messages/ must have +a corresponding entry in registry.go — the test acts as an exhaustive +bidirectional check + +**Application**: When adding new hook message variants, update the registry +entry before running tests + +--- + +## [2026-03-02-123613] Existing Projects is ambiguous framing for migration notes + +**Context**: A doc admonition said Existing Projects: if you have an older key +at X, it auto-migrates. Every project is existing once installed — the framing +does not tell you how far behind you need to be. + +**Lesson**: Version-anchored framing (Key Folder Change v0.7.0+) is clearer than +relative framing (Existing Projects, Legacy). State the version boundary and the +concrete action. + +**Application**: When writing migration notes, anchor to a version number and +give copy-pasteable commands, not vague auto-handled assurances. + +--- + +## [2026-03-02-005217] Claude Code JSONL model ID does not distinguish 200k from 1M context + +**Context**: Heartbeat hook was reporting 16% usage at 162k tokens because it +assumed claude-opus-4-6 always has 1M context window + +**Lesson**: The JSONL model field is identical for both variants (both report +claude-opus-4-6). The 1M context requires a beta header, not a different model +ID. The user's model selection is stored in ~/.claude/settings.json with a [1m] +suffix when 1M is active. + +**Application**: Auto-detect context window from ~/.claude/settings.json model +field containing [1m]. Default to 200k for all Claude models. The .ctxrc +context_window setting is a no-op for Claude Code users. + +--- + +## [2026-03-01-222739] Gosec G306 flags test file WriteFile with 0644 permissions + +**Context**: New tests used os.WriteFile(..., 0o644) for temp context files; +lint flagged all three occurrences + +**Lesson**: Gosec enforces 0600 max on WriteFile even in test code. Use 0o600 +for test temp files + +**Application**: Default to 0o600 for os.WriteFile in tests; only use wider +permissions when testing permission behavior specifically + +--- + +## [2026-03-01-222738] Converting PersistentPreRun to PersistentPreRunE changes exit behavior + +**Context**: Boundary violation test used subprocess pattern because original +code called os.Exit(1) + +**Lesson**: With PersistentPreRunE, errors propagate through Cobra Execute() +return — no os.Exit call. Subprocess-based tests that expected exit codes need +converting to direct error assertions + +**Application**: When converting PreRun to PreRunE in Cobra commands, audit all +tests that relied on os.Exit behavior + +--- + +## [2026-03-01-161459] Test HOME isolation is required for user-level path functions + +**Context**: After adding ~/.ctx/.ctx.key as global key location, test suites +wrote real files to the developer home directory + +**Lesson**: Any code that uses os.UserHomeDir() needs t.Setenv(HOME, tmpDir) in +tests — especially test helpers called by many tests (like setupEncrypted and +helper) + +**Application**: When adding features that write to user-level paths (~/.ctx/, +~/.config/), always add HOME isolation to test setup functions first + +--- + +## [2026-03-01-133014] Task descriptions can be stale in reverse — implementation done but task not marked complete + +**Context**: ctx recall sync task said 'command is not registered in Cobra' but +the code was fully wired and all tests passed. The task description was stale. + +**Lesson**: Tasks can become stale in the opposite direction from docs: +implementation gets completed but the task is not updated. Always verify with +ctx --help before assuming work remains. + +**Application**: Before starting implementation on a 'code exists but not wired' +task, run the command first to check if it already works. + +--- + +## [2026-03-01-124921] Model-to-window mapping requires ordered prefix matching + +**Context**: Implementing modelContextWindow() for the three-tier context window +fallback. Claude model IDs use nested prefixes (claude-sonnet-4-5 vs +claude-sonnet-4-20250514). + +**Lesson**: A switch with ordered HasPrefix cases (most specific first) is +cleaner and safer than iterating separate prefix lists. The catch-all 'claude-*' +returns 200k for unrecognized Claude models. + +**Application**: When adding new model families to modelContextWindow() in +session_tokens.go, add the most specific prefix first to avoid shadowing shorter +prefixes. + +--- + +## [2026-03-01-095709] TASKS.md template checkbox syntax inside HTML comments is parsed by RegExTaskMultiline + +**Context**: Template had example checkboxes (- [x], - [ ]) in HTML comments +that the line-based regex matched as real tasks, causing +TestArchiveCommand_NoCompletedTasks to fail + +**Lesson**: RegExTaskMultiline is line-based and has no awareness of HTML +comment blocks — checkbox-like patterns inside comments get counted as real +tasks + +**Application**: Use backtick-quoted or indented references instead of actual +checkbox syntax in template comments. When adding examples to TASKS.md +templates, avoid patterns that match regExTaskPattern + +--- + +## [2026-03-01-092611] Hook logs had no rotation; event log already did + +**Context**: Investigated .context/logs/ and .context/state/ file management + +**Lesson**: eventlog already rotates at 1MB with one previous generation. +logMessage() in state.go was pure append-only with no size check. + +**Application**: When adding new log sinks, follow the established rotation +pattern (size-based, single previous generation) + +--- + +## [2026-02-28-184758] ctx pad import, ctx pad export, and ctx system resources make three hack scripts redundant + +**Context**: Audited hack/ scripts against ctx CLI surface + +**Lesson**: As ctx CLI grew, several hack scripts became wrappers around +built-in commands (pad-import.sh -> ctx pad import, pad-export-blobs.sh -> ctx +pad export, resource-watch.sh -> watch -n5 ctx system resources) + +**Application**: Periodically audit hack/ for scripts that ctx has absorbed + +--- + +## [2026-02-28-184647] Getting-started docs assumed Claude Code as the only agent + +**Context**: The installation section opened with 'A full ctx installation has +two parts' — binary + Claude Code plugin — leaving non-Claude-Code users +without a clear path + +**Lesson**: Installation docs should lead with the universal requirement (the +binary) and present agent-specific integration as conditional + +**Application**: When writing docs for multi-tool projects, frame the common +denominator first, then branch by tool + +--- + +## [2026-02-28-150701] Plugin reload script must rebuild cache, not just delete it + +**Context**: hack/plugin-reload.sh was deleting +~/.claude/plugins/cache/activememory-ctx/ without repopulating it. Claude Code's +installed_plugins.json still referenced the cache path, so the plugin appeared +enabled but hooks.json was missing — all plugin hooks silently stopped firing. + +**Lesson**: Claude Code snapshots plugin hooks from the cache directory at +session startup. If the cache is deleted, plugin hooks vanish silently with no +error. The reload script must rebuild the cache from source assets +(internal/assets/claude/) after clearing it, and warn that a session restart is +required. + +**Application**: Always rebuild the plugin cache in hack/plugin-reload.sh. When +debugging hooks that don't fire, check ~/.claude/plugins/cache/ first — a +missing hooks.json is the most likely cause. + +--- + +## [2026-02-27-231228] site/ directory must be committed with docs changes + +**Context**: The site/ directory contains generated HTML served directly from +the repo (no CI build step). Multiple sessions have committed docs/ changes +without the corresponding site/ output, or ignored site/ as 'generated noise'. + +**Lesson**: site/ is intentionally tracked in git — there is no GitHub Pages +workflow or CI step to build it. When docs change, the regenerated site/ HTML +must be staged and committed alongside the source. + +**Application**: Always git add site/ when committing changes under docs/. Never +gitignore site/. + +--- + +## [2026-02-27-230741] Doctor token_budget vs context_window confusion + +**Context**: ctx doctor reported context size against token_budget (8k) instead +of context_window (200k), making 22k tokens look alarming. + +**Lesson**: token_budget (ctx agent output trim target) and context_window +(model capacity) serve different purposes. Health checks about context fitting +should use context_window, with warning threshold proportional (e.g., 20% of +window). + +**Application**: Doctor now uses rc.ContextWindow() with 20% threshold and shows +per-file token breakdown for actionable insight into which files are heavy. + +--- + +## [2026-02-27-230738] Drift detector false positives on illustrative code examples + +**Context**: ctx drift flagged 23 warnings for backtick-quoted paths in +CONVENTIONS.md and ARCHITECTURE.md that were prose examples (loader.go, +session/run.go, sync.Once), not real file references. + +**Lesson**: Path reference detection should verify the top-level directory +exists on disk before flagging. Bare filenames and paths under non-existent +directories are almost always examples in documentation. + +**Application**: The fix checks os.Stat(topDir) on the first path component. +Future drift checks on documentation-heavy files should use the same heuristic. + +--- + +## [2026-02-27-002830] Context injection and compliance strategy (consolidated) + +**Consolidated from**: 3 entries (2026-02-26) + +- Verbal summaries with linked diagram files cut ARCHITECTURE.md from ~12K to + ~3.8K tokens. Extract diagrams to linked files outside FileReadOrder; keep + prose summaries inline. The 4-chars-per-token estimator is accurate — + optimize content, not the estimator. +- Soft instructions have a ~75-85% compliance ceiling because "don't apply + judgment" is itself evaluated by judgment. When 100% compliance is required, + don't instruct — inject via `additionalContext`. Reserve soft instructions + for ~80% acceptable compliance. +- Once ~7K tokens are auto-injected (fait accompli), the agent's rationalization + inverts from "skip to save effort" to "marginal cost is trivial." Front-load + highest-value content as injection, then use sunk cost to motivate on-demand + reads for the remainder. + +--- + +## [2026-02-26-003854] Webhook silence after ctxrc profile swap is the most common notify debugging red herring + +**Context**: Spent time investigating why webhooks weren't firing — checked +binary version, hook configs, notify.Send internals. Actual cause was .ctxrc +swapped to prod profile (notify commented out) earlier in session. + +**Lesson**: When webhooks stop, check .ctxrc profile first (`ctx config +status`). Also: not all tool uses trigger webhook-sending hooks — Read only +triggers context-load-gate (one-shot) and ctx agent (no webhook). qa-reminder +requires Edit matcher. + +**Application**: Before debugging notify internals, run `ctx config status` and +verify the event would actually match a hook with notify.Send. + +--- + +## [2026-02-26-100000] Documentation drift and auditing (consolidated) + +**Consolidated from**: 6 entries (2026-01-29 to 2026-02-24) + +- CLI reference docs can outpace implementation: ctx remind had no CLI, ctx + recall sync had no Cobra wiring, key file naming diverged between docs and + code. Always verify with `ctx --help` before releasing docs. +- Structural doc sections (project layouts, command tables, skill counts) drift + silently. Add `` markers above any + section that mirrors codebase structure. +- Agent sweeps for style violations are unreliable (8 found vs 48+ actual). + Always follow agent results with targeted grep and manual classification. +- ARCHITECTURE.md missed 4 core packages and 4 CLI commands. The /ctx-drift + skill catches stale paths but not missing entries — run /ctx-architecture + after adding new packages or commands. +- Documentation audits must compare against known-good examples and + pattern-match for the COMPLETE standard, not just presence of any comment. +- Dead link checking belongs in /consolidate's check list (check 12), not as a + standalone concern. When a new audit concern emerges, check if it fits an + existing audit skill first. + +--- + +## [2026-02-26-100002] Agent context loading and task routing (consolidated) + +**Consolidated from**: 5 entries (2026-01-20 to 2026-01-25) + +- `ctx agent` is optimized for task execution (filters pending tasks, surfaces + constitution, token-budget aware). Manual file reading is better for + exploratory/memory questions (session history, timestamps, completed tasks). +- On "Do you remember?" questions, immediately read .context/ files and run `ctx + journal source --limit 5`. Never ask "would you like me to check?" — that is + the obvious intent. +- .context/ is NOT a Claude Code primitive. Only CLAUDE.md and + .claude/settings.json are auto-loaded. The .context/ directory requires a hook + or explicit CLAUDE.md instruction to be discovered. +- ~~Orchestrator (IMPLEMENTATION_PLAN.md) and agent (.context/TASKS.md) task + lists must be separate.~~ (Superseded 2026-03-25: IMPLEMENTATION_PLAN.md + removed. TASKS.md is the single task source.) +- Only CLAUDE.md is auto-loaded by Claude Code. Projects using ctx should rely + on the CLAUDE.md -> AGENT_PLAYBOOK.md chain, not AGENTS.md. + +--- + +## [2026-02-26-100005] Go testing patterns (consolidated) + +**Consolidated from**: 7 entries (2026-01-19 to 2026-02-26) + +- Compiler-driven refactoring misses test files: `go build ./...` catches + production callsite breaks but not test files. Always run `go test ./...` + after signature changes. +- All runCmd() returns must be consumed in tests: even setup calls need `_, _ = + runCmd(...)` to satisfy errcheck. +- Set `color.NoColor = true` in a package-level init function to disable ANSI + codes for CLI test string assertions. +- Recall CLI tests isolate via HOME env var: `t.Setenv("HOME", tmpDir)` with + `.claude/projects/` structure gives full isolation from real session data. +- `formatDuration` accepts an interface with a Minutes method, not time.Duration + directly. Use a stubDuration struct for testing. +- CI tests need `CTX_SKIP_PATH_CHECK=1` env var because init checks if ctx is in + PATH. +- CGO must be disabled for ARM64 Linux (`CGO_ENABLED=0`) — CGO causes + cross-compilation issues with `-m64` flag. + +--- + +## [2026-02-26-100006] PATH and binary handling (consolidated) + +**Consolidated from**: 3 entries (2026-01-21 to 2026-02-17) + +- Always use `ctx` from PATH, never `./dist/ctx-linux-arm64` or `go run + ./cmd/ctx`. Check `which ctx` if unsure. +- Hooks must use PATH, not hardcoded paths. `ctx init` checks if ctx is in PATH + before proceeding. Tests can skip with `CTX_SKIP_PATH_CHECK=1`. +- Agent must never place binaries in any bin directory (not via cp, mv, or go + install). Build with `make build`, then ask the user to run the privileged + install step. Hooks in block-dangerous-commands.sh enforce this. + +--- + +## [2026-02-26-100007] Task management and exit criteria (consolidated) + +**Consolidated from**: 4 entries (2026-01-21 to 2026-02-17) + +- Specs get lost without cross-references from TASKS.md. Three-layer defense: + (1) playbook instruction, (2) spec reference in Phase header, (3) bold + breadcrumb in first task. +- Subtask completion is implementation progress, not delivery. Parent tasks + should have explicit deliverables; don't close until deliverable is verified. +- Exit criteria must include verification: integration tests (binary executes + correctly), coverage targets, and smoke tests. "All tasks checked off" does + not equal "implementation works." +- Reports graduate to ideas/done/ only after all items are tracked or resolved. + Cross-reference every item against TASKS.md and the codebase before moving. + +--- + +## [2026-02-26-100008] Agent behavioral patterns (consolidated) + +**Consolidated from**: 5 entries (2026-01-25 to 2026-02-22) + +- Interaction pattern capture risks softening agent rigor. Do not build implicit + user-modeling from session history. Rely on explicit, human-reviewed context + (learnings, conventions, hooks) for behavioral shaping. +- Chain-of-thought prompting improves agent reasoning accuracy (17.7% to 78.7%). + Added "Reason Before Acting" to AGENT_PLAYBOOK.md and reasoning nudges to 7 + skills. +- Say "project conventions" not "idiomatic X" to ensure Claude looks at project + files first rather than triggering training priors (stdlib conventions). +- Autonomous "YOLO mode" is effective for feature velocity but accumulates + technical debt (magic strings, monolithic tests, hardcoded paths). Schedule + periodic consolidation sessions. +- Trust the binary output over source code analysis. A single ambiguous CLI + output is not proof of absence — re-run the exact command before claiming + something is missing. + +--- + +## [2026-02-26-100009] Hook compliance and output routing (consolidated) + +**Consolidated from**: 3 entries (2026-02-22 to 2026-02-25) + +- Plain-text hook output is silently ignored by the agent. Claude Code parses + hook stdout starting with `{` as JSON directives; plain text is disposable. + All hooks should return JSON via `printHookContext()`. +- Hook compliance degrades on narrow mid-session tasks (~15-25% partial skip + rate). Root cause: CLAUDE.md's "may or may not be relevant" system reminder + competes with hook authority. Fix: CLAUDE.md explicitly elevates hook + authority. The mandatory checkpoint relay block is the compliance canary. +- No reliable agent-side before-session-end event exists. SessionEnd fires after + the agent is gone. Mid-session nudges and explicit /ctx-wrap-up are the only + reliable persistence mechanisms. + +--- + +## [2026-02-26-100010] ctx add and decision recording (consolidated) + +**Consolidated from**: 4 entries (2026-01-27 to 2026-02-14) + +- `ctx add learning` requires `--context`, `--lesson`, `--application` flags. + `ctx add decision` requires `--context`, `--rationale`, `--consequence`. A + bare string only sets the title and the command will fail without required + flags. +- Structured entries with Context/Lesson/Application are more useful than + one-liners. Agents are guided via AGENT_PLAYBOOK.md. +- Always complete decision record sections — placeholder text like "[Add + context here]" is a code smell. Decisions without rationale lose their value + over time. +- Slash commands using `!` bash syntax require matching permissions in + settings.local.json. When adding new /ctx-* commands, ensure ctx init + pre-seeds the required `Bash(ctx :*)` permissions. + +--- + +## [2026-02-24-032945] CLI tools don't benefit from in-memory caching of context files + +**Context**: Discussed whether ctx should read and cache LEARNINGS.md, +DECISIONS.md etc. in memory + +**Lesson**: ctx is a short-lived CLI process, not a daemon. Context files are +tiny (few KB), sub-millisecond to read. Cache invalidation complexity exceeds +the read cost. Caching only makes sense if ctx becomes a long-lived process (MCP +server, watch daemon). + +**Application**: Don't add caching layers to ctx's file reads. If an MCP server +mode is ever added, revisit then. + +--- + +## [2026-02-22-120000] Hook behavior and patterns (consolidated) + +**Consolidated from**: 8 entries (2026-01-25 to 2026-02-17) + +- Hook scripts receive JSON via stdin (not env vars); parse with + `HOOK_INPUT=$(cat)` then jq +- Hook key names are case-sensitive: `PreToolUse` and `SessionEnd` (not + `PreToolUseHooks`) +- Use `$CLAUDE_PROJECT_DIR` in hook paths, never hardcode absolute paths +- Hook regex can overfit: `ctx` as binary vs directory name differ; anchor + patterns to command-start positions with `(^|;|&&|\|\|)\s*` +- grep patterns match inside quoted arguments — test with `ctx add learning + "...blocked words..."` to verify no false positives +- Hook scripts can silently lose execute permission; verify with `ls -la + .claude/hooks/*.sh` after edits +- Two-tier output is sufficient: unprefixed (agent context, may or may not + relay) and `IMPORTANT: Relay VERBATIM` (guaranteed relay); don't add new + severity prefixes +- Repeated injection causes agent repetition fatigue; use `--session $PPID + --cooldown 10m` and pair with a readback instruction + +--- + +## [2026-02-22-120001] UserPromptSubmit hook output channels (consolidated) + +**Consolidated from**: 2 entries (2026-02-12) + +- UserPromptSubmit hook stdout is prepended as AI context (not shown to user); + stderr with exit 0 is swallowed entirely +- User-visible output requires `{"systemMessage": "..."}` JSON on stdout + (warning banner) or exit 2 (blocks prompt) +- There is no non-blocking user-visible output channel for this hook type +- Design hooks for their actual audience: AI-facing = plain stdout, user-facing + = systemMessage JSON + +--- + +## [2026-02-22-120002] Linting and static analysis (consolidated) + +**Consolidated from**: 7 entries (2026-01-25 to 2026-02-20) + +- Full pre-commit gate: (1) `CGO_ENABLED=0 go build ./cmd/ctx`, (2) + `golangci-lint run`, (3) `CGO_ENABLED=0 go test` — all three, every time +- Own the codebase: fix pre-existing lint issues even if you didn't introduce + them +- gosec G301/G306: use 0o750 for dirs, 0o600 for files everywhere including + tests +- gosec G304 (file inclusion): safe to suppress with `//nolint:gosec` in test + files using `t.TempDir()` paths +- golangci-lint errcheck: use `cmd.Printf`/`cmd.Println` in Cobra commands + instead of `fmt.Fprintf` +- `defer os.Chdir(x)` fails errcheck; use `defer func() { _ = os.Chdir(x) }()` +- golangci-lint Go version mismatch in CI: use `install-mode: goinstall` to + build linter from source + +--- + +## [2026-02-22-120006] Permission and settings drift (consolidated) + +**Consolidated from**: 4 entries (2026-02-15) + +- Permission drift is distinct from code drift — settings.local.json is + gitignored, no review catches stale entries +- `Skill()` permissions don't support name prefix globs — list each skill + individually +- Wildcard trusted binaries (`Bash(ctx:*)`, `Bash(make:*)`), but keep git + commands granular (never `Bash(git:*)`) +- settings.local.json accumulates session debris; run periodic hygiene via + `/sanitize-permissions` and `/ctx-drift` + +--- + +## [2026-02-22-120008] Gitignore and filesystem hygiene (consolidated) + +**Consolidated from**: 3 entries (2026-02-11 to 2026-02-15) + +- Gitignored directories are invisible to `git status`; stale artifacts persist + indefinitely — periodically `ls` gitignored working directories +- Add editor artifacts (*.swp, *.swo, *~) to .gitignore alongside IDE + directories from day one +- Gitignore entries for sensitive paths are security controls, not documentation + — never remove during cleanup sweeps + +--- + +## [2026-01-28-051426] IDE is already the UI + +**Context**: Considering whether to build custom UI for .context/ files + +**Lesson**: Discovery, search, and editing of .context/ markdown files works +better in VS Code/IDE than any custom UI we'd build. Full-text search, +git integration, extensions - all free. + +**Application**: Don't reinvent the editor. Let users use their preferred IDE. + +--- + + +*Module-specific, niche, and historical learnings: +[learnings-reference.md](learnings-reference.md)* + +--- + ## [2026-04-25-014704] Confident code comments can pull an LLM away from first-principles knowledge **Context**: cli_test.go had a comment claiming 'parent's t.Setenv doesn't propagate to exec'd children unless we build it into cmd.Env' which is wrong. I patched the helper's CTX_DIR dedup instead of questioning the helper itself, despite knowing t.Setenv semantics. diff --git a/.context/TASKS.md b/.context/TASKS.md index 7ffb93439..e0ea58010 100644 --- a/.context/TASKS.md +++ b/.context/TASKS.md @@ -25,13 +25,2117 @@ TASK STATUS LABELS: `#in-progress`: currently being worked on (add inline, don't move task) --> -### Phase 1: [Name] `#priority:high` -- [ ] Task 1 -- [ ] Task 2 +### Misc -### Phase 2: [Name] `#priority:medium` -- [ ] Task 1 -- [ ] Task 2 +- [x] If context is not initialized, hooks should not run. Right now they run + and give a "context diretory outside project root" (that's a side effect). But + the issue is the project does not have a .context folder and we don't detect + it. **Progress 2026-04-13**: Boundary side effect resolved by git-anchored + walk + (commit e24941d2). `state.Initialized()` guards added to `check_resource` and + `check_backup_age` — the two user-visible relay-nag hooks that were missing + them. **Completed 2026-04-16**: `state.Initialized()` guards added to + `mark_journal`, `mark_wrapped_up`, `pause`, `resume`. `bootstrap` left + unguarded intentionally — its job is to report context dir status, and it + already has its own `os.Stat` guard. Safety hooks + (`block_dangerous_command`, `block_non_path_ctx`) intentionally run + regardless. + +- [x] Move `ctx bootstrap` back to `ctx system bootstrap` (hidden). Bootstrap is + agent-only plumbing — no human types it interactively. It was incorrectly + promoted to top-level in the namespace cleanup. Move the package back to + `internal/cli/system/cmd/bootstrap/`, restore + `UseSystemBootstrap`/`DescKeySystemBootstrap` constants, re-add `Hidden: + true`, update CLAUDE.md templates and skills back to `ctx system bootstrap`, + remove from `docs/cli/bootstrap.md` and `docs/cli/index.md` Diagnostics group, + remove from `zensical.toml` nav. Spec: specs/cli-namespace-cleanup.md + #priority:high #added:2026-04-11 #done:2026-04-12 + +- [x] Rename `ctx stats` to `ctx usage`. "Stats for what?" — the current name + lost its anchor when promoted from `ctx system stats`. `ctx usage` + communicates intent: "show me my token usage." `ctx session stats` was + considered but rejected as premature — a parent with one child is worse than + a flat command. Revisit when `ctx session` has 2+ children. Spec: + specs/cli-namespace-cleanup.md #priority:medium #added:2026-04-11 + #done:2026-04-12 + +- [x] Rename `ctx resource` to `ctx sysinfo`. Without the `system` prefix, + "resource" sounds like it manages project resources (files, assets, + infrastructure). It's actually a system-health snapshot: memory, swap, disk, + CPU load. `sysinfo` matches the internal package name (`internal/sysinfo`) and + is unambiguous. `health` was considered but rejected — too similar to `ctx + doctor` and `ctx doctor health` reads wrong. Same rename pattern. Spec: + specs/cli-namespace-cleanup.md #priority:medium #added:2026-04-11 + #done:2026-04-12 + +- [x] Remove `ctx dep`. Utility is marginal: agents rarely need a flat + dependency inventory to make decisions, and `go list -m all` / `npm ls` + already cover the use case. Doesn't clear the "would I miss it if it + vanished?" bar. Removed command, all support packages, docs, and recipes. + #priority:low #added:2026-04-11 #done:2026-04-12 + +- [x] Introduce `ctx hook` parent command — consolidate hook-related + user-facing commands under a single namespace: `ctx hook message + list/show/edit/reset` (currently `ctx message`), `ctx hook notify` (currently + `ctx notify`), `ctx hook pause` / `ctx hook resume` (currently top-level `ctx + pause` / `ctx resume`). "What are we pausing?" — hooks. The current + top-level `pause` loses that context. Clarifies the `ctx trigger` vs `ctx + hook` distinction: `trigger` = user-authored scripts, `hook` = plugin-shipped + machinery + its user-facing controls. Future children: `ctx hook status` + (which hooks fired recently), `ctx hook test` (dry-run), `ctx hook event` + (currently `ctx event`). Same rename pattern as previous namespace cleanups. + Spec: specs/cli-namespace-cleanup.md #priority:medium #added:2026-04-11 + #done:2026-04-12 + +### Agents + +- [-] Add `ctx explore` command — scaffolds `.arch-explorer/` in a workspace + directory with manifest.json, PROMPT.md (from + `hack/agents/architecture-explorer.md`), run-log.md, and a README. Similar to + `ctx init` but for multi-repo architecture exploration. The prompt template + lives in `hack/agents/architecture-explorer.md` and ships embedded. + #priority:low #added:2026-04-13 + **Skipped 2026-04-16**: Superseded by + `docs/operations/runbooks/architecture-exploration.md`. A runbook is the right + weight — a CLI scaffolding command was speculative abstraction for a + workflow + that's better served by a discoverable doc with an embedded prompt. + +### Runbooks + +- [x] Create `docs/operations/runbooks/release-checklist.md` — canonical + pre-release + sequence: run codebase-audit, docs-semantic-audit, sanitize-permissions, `make + test`, bump version, generate release notes, tag, push. Today this lives in + the operator's head + scattered across docs/operations/. Cross-link with + `_ctx-release` skill. #priority:high #added:2026-04-11 + **Completed 2026-04-16**: Created at + `docs/operations/runbooks/release-checklist.md`. + All runbooks moved from `hack/runbooks/` to `docs/operations/runbooks/` for + discoverability on ctx.ist. + +- [x] Create `docs/operations/runbooks/breaking-migration.md` — template for + users + upgrading across breaking CLI renames. What commands changed, how to + regenerate CLAUDE.md (`ctx init --force`), how to update personal scripts and + hook configs. One instance per breaking release, or a generic template with a + per-release appendix. #priority:medium #added:2026-04-11 + **Completed 2026-04-16**: Created at + `docs/operations/runbooks/breaking-migration.md`. + +- [x] Create `docs/operations/runbooks/hub-deployment.md` — linear runbook for + setting up + a ctx Hub for a team: generate admin token, distribute, register clients, + verify sync, configure TLS (when H-01/H-02 land). Consolidates pieces + currently scattered across hub recipes. #priority:medium #added:2026-04-11 + **Completed 2026-04-16**: Created at + `docs/operations/runbooks/hub-deployment.md`. + +- [x] Create `docs/operations/runbooks/new-contributor.md` — onboarding + sequence: clone + → `ctx init` → `make build && sudo make install` → verify hooks (`claude + mcp list`) → run first session → verify context persistence. Currently + scattered across README, contributing.md, and setup docs. #priority:medium + #added:2026-04-11 + **Completed 2026-04-16**: Created at + `docs/operations/runbooks/new-contributor.md`. + +- [x] Create `docs/operations/runbooks/plugin-release.md` — plugin-specific + release + procedure: update hooks.json, bump version, test against fresh Claude Code + install, publish to marketplace, verify `claude mcp list` shows updated + version. Not covered by the general release checklist. #priority:low + #added:2026-04-11 + **Completed 2026-04-16**: Created at + `docs/operations/runbooks/plugin-release.md`. + +### Misc + +- [ ] Human: Read the entire documentation page-by-page, line-by-line, with a + critical mind, including blog posts. Take notes for agent to rectify, or + directly update the docs whenever it makes sense. + +- [ ] Human: Do a documentation audit for AI-generated artifacts. #important + #not-urgent + +- [ ] Human: test `ctx init` on a fresh ubuntu install. + +- [ ] Improve hub failover client: distinguish auth errors + (Unauthenticated/PermissionDenied) from connection errors. Fail fast on auth + failures instead of cycling through all peers with the same invalid token. + #priority:low #added:2026-04-08-194612 + +- [ ] Add file locking to ctx connect sync state to prevent concurrent sync + races. Two sync processes (hook + manual) can both load the same LastSequence, + process the same entries, and write duplicate content to .context/shared/. + #priority:medium #added:2026-04-08-194557 + +- [ ] Fix fanout broadcast entry loss: non-blocking send drops entries to slow + listeners silently. Log when entries are dropped. Consider per-listener + backpressure or disconnect-on-lag. Buffer of 64 is too small for busy hubs. + #priority:medium #added:2026-04-08-194542 + +- [ ] Prevent duplicate client registration in hub store: RegisterClient should + reject if ProjectName already exists. Add token revocation support (delete + client by ID/project). Currently tokens are valid forever with no way to + disable compromised ones. #priority:medium #added:2026-04-08-194529 + +- [ ] Fix hub cluster: NewCluster result is discarded (not stored on Server), so + Raft runs but leadership status is never queryable. Store cluster reference on + Server, wire IsLeader/LeaderAddr into Status RPC and hub status command. + #priority:medium #added:2026-04-08-194511 + +- [ ] Use crypto/subtle.ConstantTimeCompare for hub token validation instead of + string equality. Current Store.ValidateToken uses == which is vulnerable to + timing attacks. Also replace O(n) linear scan with a map[string]*ClientInfo + for O(1) lookup. #priority:high #added:2026-04-08-194458 + +- [ ] Fix silent error suppression in hub: (1) ctx add --share silently ignores + publish failures — warn user on failure, (2) hubsync hook swallows all + errors — log to event system, (3) replication loop drops errors silently — + add structured logging for debug. #priority:high #added:2026-04-08-194443 + +- [ ] Add input validation to hub Publish handler: reject empty ID, validate + Type against allowed set (decision/learning/convention/task), enforce Content + length limit (1MB), require non-empty Origin. Prevents garbage data and DoS + via unbounded content. #priority:high #added:2026-04-08-194430 + +- [ ] Fix ctx connect listen: currently only does initial sync then blocks on + ctx.Done() without ever calling the Listen RPC. Must stream entries in + real-time via the server-streaming Listen RPC, writing to .context/shared/ as + entries arrive. #priority:high #added:2026-04-08-194415 + +- [x] Remove any superpowers library references and implement all needed + workflow mechanisms (brainstorm, plan, execute, review, subagent dispatch) + natively in ctx. No external plugin libraries should be used — ctx must be + self-contained. Clean up docs/superpowers/ directory and any remaining + references. #priority:high #added:2026-04-06-121002 #done:2026-04-06 + +- [ ] Deprecate and remove `ctx backup`: hub handles cross-machine persistence, + backup is environment-specific (SMB/GVFS/rsync), and it is the wrong layer + for ctx to own. Replace with a backup-strategy runbook. About 60 files to + remove across CLI, config, hooks, docs, skills. Implementation order: runbook + first, then hook removal, then command removal, then docs cleanup. + Spec: specs/deprecate-ctx-backup.md #priority:medium + #added:2026-04-04-010000 #updated:2026-04-16 + +### Architecture Docs + +- [ ] Publish architecture docs to docs/: copy ARCHITECTURE.md, + DETAILED_DESIGN domain files, and CHEAT-SHEETS.md to docs/reference/. + Sanitize intervention points into docs/contributing/. + Exclude DANGER-ZONES.md and ARCHITECTURE-PRINCIPAL.md (internal only). + Spec: specs/publish-architecture-docs.md #priority:medium + #added:2026-04-03-150000 + +- [ ] Update ctx-architecture skill to append discovered terms to GLOSSARY.md + during Phase 3. Additive only, max 10 terms per run, project-specific only, + alphabetical insertion, skip if GLOSSARY.md empty. Print added terms in + convergence report. Spec: specs/publish-architecture-docs.md #priority:low + #added:2026-04-03-153000 + +### Code Cleanup Findings + + +- [x] Extend flagbind helpers (IntFlag, DurationFlag, DurationFlagP, StringP, + BoolP) and migrate ~50 call sites to unblock TestNoFlagBindOutsideFlagbind + #added:2026-04-01-233250 + +- [ ] Implement journal compaction: Elastic-style tiered storage with tar.gz + backup. Spec: specs/journal-compact.md #added:2026-03-31-110005 + +- [x] Refactor 28 grandfathered cmd/ purity violations found by + TestCmdDirPurity: move unexported helpers, exported non-Cmd/Run functions, + and types from cmd/ directories to core/. See grandfathered map in + compliance_test.go for the full list. #priority:medium + #added:2026-03-31-005115 + + +- [x] PD.4.5: Update AGENT_PLAYBOOK.md — add generic "check available skills" + instruction #priority:medium #added:2026-03-25-203340 + +**PD.5 — Validate:** + + +### Phase -3: DevEx + +- [x] Plugin enablement gap: Ref: + `ideas/plugin-enablement-gap.md`. Local-installed plugins get + registered in `installed_plugins.json` but not auto-added to + `enabledPlugins`, so slash commands are invisible in non-ctx + projects. + +- [x] Add cobra Example fields to CLI commands via + examples.yaml #added:2026-03-20-163413 + +- [x] Add CLI YAML drift detection test: verify flag names in + examples.yaml match actual registered flags, and Use: patterns + in commands.yaml match Use constants. Structural linkage is + already tested; this covers content-level drift. Semantic + accuracy (does the description match behavior?) needs periodic + LLM audit — not automatable. #priority:medium #added:2026-04-05 + +- [-] Create ctx-docstrings skill: audit and fix docstrings + against CONVENTIONS.md Documentation section. Superseded by + TestDocCommentStructure compliance test (68 grandfathered). + #added:2026-03-20-163413 + #added:2026-03-16-114445 + +### Phase -2: Task completion nudge: + +- [x] Move 6 grandfathered cross-package MCP types to entity/ #session:cc97cb0d + #branch:main #commit:e8d5c60a #added:2026-04-08-074620 + +- [ ] Design UserPromptSubmit hook that runs `make audit` at + session start and surfaces failures as a consolidation-debt + warning before the agent acts on stale assumptions. + Project-level hook (not bundled in ctx), configurable via + .ctxrc or settings.json. Related: consolidation nudge hook + spec. #added:2026-03-23-223500 + +- [ ] Design UserPromptSubmit hook that runs go build and + surfaces compilation errors before the agent acts on stale + assumptions #added:2026-03-23-120136 + +- [ ] Architecture Mapping (Enrichment): + **Context**: Skill that incrementally builds and maintains + ARCHITECTURE.md and DETAILED_DESIGN.md. Coverage tracked in + map-tracking.json. Spec: `specs/ctx-architecture.md` + - [x] Create ctx-architecture-enrich skill: takes existing + /ctx-architecture principal-mode artifacts as baseline, runs + comprehensive enrichment pass via GitNexus MCP (blast radius + verification, registration site discovery, execution flow + tracing, domain clustering comparison, shallow module + deep-dive). Spec: `ideas/spec-architecture-enrich.md`. + Reference implementation: kubernetes-service enrichment pass + 2026-03-25. #added:2026-03-25-120000 + +- [ ]: ctx-architecture-failure-analysis + **Context**: Adversarial analysis skill that identifies where + a codebase will silently betray you. Requires + `ctx-architecture` artifacts as input (ARCHITECTURE.md, + DETAILED_DESIGN*.md, map-tracking.json). Does its own + targeted deep reads focusing on mutation points, shared + mutable state, error swallowing, concurrency, implicit + ordering, missing enforcement, and scaling cliffs. Uses + available tooling (GitNexus, Gemini Search) to + cross-reference patterns. + + Produces `DANGER-ZONES.md` — a ranked inventory of silent + failure points with: location, failure mode, blast radius, + detection gap, and suggested fix. Two tiers: "most likely to + cause production incidents" and "less likely but equally + dangerous." + + Distinct from a security threat model (which would be + `ctx-threat-model` — a separate skill for auth bypass, + injection, privilege escalation, supply chain). This skill + focuses on correctness: race conditions, ordering + assumptions, cache staleness, fan-out amplification, + non-atomic ownership, inverted logic, force-delete orphans, + global state mutation. + + - [x] Design SKILL.md for ctx-architecture-failure-analysis: + inputs (architecture artifacts), analysis phases, output + format (DANGER-ZONES.md), quality checklist + #added:2026-03-25-060000 + - [x] Define the adversarial analysis framework: categories + of silent failure (concurrency, ordering, cache, + amplification, ownership, error swallowing, global state) + with heuristics for each #added:2026-03-25-060000 + - [x] Implement skill with GitNexus integration: use impact + analysis for blast radius estimation, use context for + shared-state detection #added:2026-03-25-060000 + - [x] Add Gemini Search integration: cross-reference + discovered patterns against known failure modes in similar + systems. #added:2026-03-25-060000 + +- [-] ctx-architecture-extend + Skipped: extension point analysis is covered by /ctx-architecture + DETAILED_DESIGN (per-module) and /ctx-architecture-enrich + (registration sites). A fourth skill fragments the pipeline + without enough distinct value. Three is the right number: + map, enrich, hunt. + **Context**: Companion to `ctx-architecture` and + `ctx-failure-analysis`, completing a trilogy: how does it + work → where will it break → where does it grow. Reads + architecture artifacts → identifies registration patterns + (interfaces, factory functions, plugin systems, ordered + slices, scheme registrations) → traces recent additions via + git log to confirm which extension points are actually used + → produces `EXTENSION-POINTS.md` ranked by frequency, with + exact file locations, function signatures, and the typical + feature pattern (e.g., "most features require a variable + + a mutator + a machine-agent task"). + + Valuable for onboarding ("I need to add feature X, where do + I start?") and architecture review ("are we adding features + in the right places?"). + + - [-] Design SKILL.md for ctx-extension-map + Skipped: parent task skipped. + #added:2026-03-25-062000 + - [-] Define extension point detection heuristics + Skipped: parent task skipped. + #added:2026-03-25-062000 + - [-] Add git log frequency analysis + Skipped: parent task skipped. + #added:2026-03-25-062000 + - [-] Integrate with GitNexus for registration sites + Skipped: parent task skipped. + #added:2026-03-25-062000 + +### Phase CT: Companion Tool Integration + +Session-start checks, suppressibility, and registry for companion MCP tools. + +- [ ] ctx-remember preflight: verify ctx binary in PATH, + plugin installed and enabled, binary version matches plugin + version #priority:medium #added:2026-03-25-234514 + +- [ ] Design suppressible companion check system: .ctxrc + configures which companion tools to check (one search MCP, + one graph MCP), smoke tests only run for configured tools, + not auto-discovered. Keeps bootstrap fast and predictable. + #priority:medium #added:2026-03-25-234516 + +- [ ] Add per-tool suppression for ctx-remember checks: allow + suppressing individual preflight checks (ctx binary, plugin, + search MCP, graph MCP) via .ctxrc fields, not just + companion_check: false blanket toggle + #priority:low #added:2026-03-25-234518 + +### Phase CLI-FIX: CLI Infrastructure Fixes + +- [x] Bug: ctx add task appends to the last Phase section instead of a dedicated + location. Tasks added via CLI land inside whatever Phase happens to be last in + TASKS.md, breaking Phase structure. Fix: add mandatory --section flag to ctx + add + task. If the named section does not exist, create it. If --section is + omitted, error with message. Heading level fixed from ## to ### to match + TASKS.md structure. + #priority:high #added:2026-03-25-234813 #done:2026-04-06 + +### Phase BLOG: Blog Posts + +- [ ] Write blog post about architecture analysis + enrichment two-pass design + after dogfooding run on ctx itself. Cover: the 5.2x depth observation, + constraint-as-feature principle, watermelon-rind anti-pattern, and results + from the ctx self-analysis. #priority:medium #added:2026-03-25-233650 + +- [ ] Blog post: "Writing a CONSTITUTION for your AI agent" — showcase ctx's + CONSTITUTION.md as a pattern for hard invariants that agents cannot violate. + Cover: why advisory rules fail (agents game qualifiers), what belongs in a + constitution vs conventions, the spec-at-commit enforcement story from this + session, examples of good rules (absolute, binary, no interpretation needed). + Include a recipe for writing your own. + #priority:medium #added:2026-03-27-115500 + +- [ ] Recipe: "How to write a good CONSTITUTION.md" — practical guide with + categories (security, quality, process, structure), anti-patterns (vague + qualifiers, unenforced rules), enforcement mechanisms (hooks, commit gates), + and a starter template. #priority:medium #added:2026-03-27-115500 + +- [ ] Import grouping compliance test: parse all .go files, verify imports + follow stdlib — external — ctx three-group ordering. Add to + internal/compliance/. Catches violations that goimports misses (it merges + external and ctx into one group). #priority:medium #added:2026-03-27-120000 + +- [ ] drift check should notify if claude permissions have insecure stuff in it. + +- [ ] task: sync workspace to ARI_INBOX + +### Phase -1: Hack Script Absorption + +Absorb remaining `hack/` scripts into Go subcommands. Eliminates shell +dependencies, improves portability, and makes the skill layer call `ctx` +directly instead of `make` targets. + +### Phase 0.9: Suppress Nudges After Wrap-Up + +Spec: `specs/suppress-nudges-after-wrap-up.md`. Read the spec before starting +any P0.9 task. + +**Phase 3 — Skill integration:** + +- [-] P0.9.2: Split cli-reference.md — moved to Future + #added:2026-02-24-204208 + +- [-] P0.9.3: Investigate proactive content suggestions — moved to Future + #added:2026-02-24-185754 + +### Phase 0.8: RSS/Atom Feed Generation (`ctx site feed`) + +Spec: `specs/rss-feed.md`. Read the spec before starting any P0.8 task. + +### Phase 0.4: Hook Message Templates + +Spec: `specs/future-complete/hook-message-templates.md`. Read the spec before +starting any P0.4 task. + +**Phase 2 — Discoverability + documentation:** + +Spec: `specs/future-complete/hook-message-customization.md`. + +- [ ] Migrate hook message templates from .txt files to YAML + localization #added:2026-03-20-163801 + +### Phase 0.4.9: Injection Oversize Nudge + +Spec: `specs/injection-oversize-nudge.md`. Read the spec before starting +any P0.4.9 task. + +### Phase 0.4.10: Context Window Token Usage + +Spec: `specs/context-window-usage.md`. Read the spec before starting any +P0.4.10 task. + +### Phase 0.5 Cleanup + +* Human: internal/recall/parser requires a serious refactoring; for example + the parser object and its private and public methods need to go to its own + package and other helper functions need to go to a different adjacent package. +* Human: internal/notify/notify.go requires refactoring (all functions bagged in + one file; types need to go to types.go per convention etc etc) +* Human: split err package into sub packages. + + +- [ ] Refactor site/cmd/feed: extract helpers and types to core/, make Run + public #added:2026-03-21-074859 + +- [ ] Add Use* constants for all cobra subcommand Use + strings #added:2026-03-20-184639 + +- [ ] Systematic audit: extract all magic flag name strings across CLI commands + into config/flag constants #added:2026-03-20-175155 + +- [-] Move generic string helpers from cli/add/core/strings.go to + internal/format — file no longer exists, helpers already moved or deleted + #added:2026-03-20-175046 + +- [ ] Add missing flag name constants (priority, section, file) and priority + level constants (high, medium, low) to config/flag #added:2026-03-20-170842 + +### Phase 0: Ideas + +**User-Facing Documentation** (from `ideas/done/REPORT-7-documentation.md`): +Docs are feature-organized, not problem-organized. Key structural improvements: + +**Agent Team Strategies** (from `ideas/REPORT-8-agent-teams.md`): +8 team compositions proposed. Reference material, not tasks. Key takeaways: + +- [ ] Scan all config/**/* constants and catalog which ones should be ctxrc + entries for user configurability #priority:medium #added:2026-03-22-095552 + +- [ ] Update user-facing documentation for changed CLI flag + shorthands #added:2026-03-21-102755 + +- [ ] Add Unicode-aware slugification for non-ASCII + content #added:2026-03-21-070953 + +- [ ] Make TitleSlugMaxLen configurable via .ctxrc #added:2026-03-21-070944 + +- [ ] Spec and implement CRLF-to-LF newline normalization for journal and + context files #added:2026-03-20-224845 + +- [ ] Test ctx on Windows — validate build, init, agent, drift, journal + pipeline #added:2026-03-20-224835 + +- [ ] Evaluate Windows support for sysinfo.Collect and path + handling #added:2026-03-20-194930 + +- [ ] Make doctor thresholds configurable via .ctxrc #added:2026-03-20-194923 + +- [ ] Evaluate cross-platform path handling in change/core/scan.go — git + always + uses "/" but UniqueTopDirs should consider filepath.ToSlash for Windows + robustness #added:2026-03-20-182103 + +- [ ] Replace English-only Pluralize helper in change/core/detect.go with + i18n-safe approach #added:2026-03-20-180502 + +- [ ] Replace ASCII-only alnum check in agent/core/score.go with + unicode.IsLetter/IsDigit #added:2026-03-20-175943 + +### Phase S-0: Memory Bridge Groundwork + +Prerequisites that unblocked the memory bridge phases. + + +### Phase MB: Memory Bridge Foundation (`ctx memory`) + +Spec: `specs/memory-bridge.md`. Read the spec before starting any MB task. + +Bridge Claude Code's auto memory (MEMORY.md) into `.context/` with discovery, +mirroring, and drift detection. Foundation for future import/publish phases. + +### Phase MI: Memory Import Pipeline (`ctx memory import`) + +Spec: `specs/memory-import.md`. Read the spec before starting any MI task. + +Import entries from Claude Code's MEMORY.md into structured `.context/` files +using heuristic classification. Builds on Phase MB foundation (discover, +mirror, state). + +- [-] MI.future: `--interactive` mode for agent-assisted classification — + skipped: `--dry-run` covers review; agents can use `ctx add` directly for + overrides; interactive CLI prompts don't compose with agent workflows + +### Phase S-3: Blog Post — "Agent Memory is Infrastructure" + +Spec: `specs/blog-agent-memory-infrastructure.md`. + + +### Phase MP: Memory Publish (`ctx memory publish`) + +Spec: `specs/memory-publish.md`. Read the spec before starting any MP task. + +Push curated context from `.context/` into Claude Code's MEMORY.md so the agent +sees structured project context on session start without needing hooks. + +### Phase 9: Context Consolidation Skill `#priority:medium` + +**Context**: `/ctx-consolidate` skill that groups overlapping entries by keyword +similarity and merges them with user approval. Originals archived, not deleted. +Spec: `specs/context-consolidation.md` +Ref: https://github.com/ActiveMemory/ctx/issues/19 (Phase 3) + +- [ ] Implement consolidation nudge hook: count sessions since last + consolidation, nudge after 6. Spec: + `specs/consolidation-nudge-hook.md` #added:2026-03-23-223000 + +- [ ] Auto-record consolidation baseline commit: `/ctx-consolidate` and `ctx + system mark-consolidation` should stamp HEAD hash + date into + `.context/state/consolidation.json` only on first invocation (write-once until + reset). Subsequent consolidation sessions preserve the original baseline. The + baseline resets only when the consolidation nudge counter resets (i.e., when a + new feature cycle begins). This way multi-pass consolidation keeps the true + starting point. Related: + `specs/consolidation-nudge-hook.md` #added:2026-03-23-224000 + +### Phase EM: Extension Map Skill (`/ctx-extension-map`) + +question: is this done; or needs planning? + +### Phase WC: Write Consolidation + +Baseline commit: `4ec5999` (Auto-prune state directory on session start). +Goal: consolidate user-facing messages into `internal/write/` as the central +output package. All CLI commands should route printed output through +this package. + +- [ ] Migrate moc.go hardcoded strings to YAML or Go + templates #added:2026-03-20-214922 + +- [ ] Design terminal-aware truncation for CLI output #added:2026-03-20-184509 + +### Phase SP: Configurable Session Prefixes + +Spec: `specs/session-prefixes.md`. Read the spec before starting any SP task. + +Replace hardcoded `session_prefix` / `session_prefix_alt` pair with a +user-extensible `session_prefixes` list in `.ctxrc`. Parser vocabulary +is not i18n text — it belongs in runtime config. + +### Phase EH: Error Handling Audit + +Systematic audit of silently discarded errors across the codebase. +Many call sites use `_ =` or `_, _ =` to discard errors without +any feedback. Some are legitimate (best-effort cleanup), most are +lazy escapes that hide failures. + + +- [ ] EH.1: Catalogue all silent error discards — recursive walk of + `internal/` + for patterns: `_ = `, `_, _ = `, `//nolint:errcheck`, bare `return` after + error-producing calls. Group by category: + (a) file close in defer — often legitimate but should log on failure + (b) file write/read — data loss risk, must surface + (c) os.Remove/Rename — state corruption risk + (d) fmt.Fprint to stderr — truly best-effort, acceptable + Commands: `grep -rn '_ =' internal/`, `grep -rn + 'nolint:errcheck' internal/` + Output: spreadsheet in `.context/` with file, line, expression, category, + and recommended action (log-stderr, return-error, acceptable-as-is). + DoD: every `_ =` in the codebase is categorised and has a + recommended action + #priority:high #added:2026-03-14 + +- [ ] EH.2: Address category (b) — file write/read discards. These risk silent + data loss. Fix: return the error, or at minimum emit to stderr with + `fmt.Fprintf(os.Stderr, "ctx: ...: %v\n", err)` following the pattern + established in `internal/log/event.go`. + DoD: no write/read error is silently discarded + #priority:high #added:2026-03-14 + +- [ ] EH.3: Address category (a) — file close in defer. Most are `defer func() + { _ = f.Close() }()`. For read-only files, close errors are rare but + should still surface. For write/append files, close can fail if the + final flush fails — these are data loss. Fix: `if err := f.Close(); + err != nil { fmt.Fprintf(os.Stderr, "ctx: close %s: %v\n", path, err) }`. + DoD: all defer-close sites log failures to stderr + #priority:medium #added:2026-03-14 + +- [ ] EH.4: Address category (c) — os.Remove/Rename discards. These are state + operations (rotation, pruning, temp file cleanup). Silent failure leaves + stale state. Fix: stderr warning at minimum; for rotation/rename, consider + returning the error. + DoD: no Remove/Rename error is silently discarded + #priority:medium #added:2026-03-14 + +- [ ] EH.5: Validate — `grep -rn '_ =' internal/` returns only category (d) + entries (fmt.Fprint to stderr) and entries explicitly annotated as + acceptable. Run `make lint && make test` to confirm no regressions. + DoD: grep output is clean or fully annotated; CI green + #priority:high #added:2026-03-14 + +- [ ] Add AST-based lint test to detect exported functions with no external + callers #added:2026-03-21-070357 + +- [ ] Audit exported functions used only within their own package and make them + private #added:2026-03-21-070346 + +- [ ] Audit and remove side-effect output from error-returning + functions #added:2026-03-20-212212 + +### Phase ET: Error Package Taxonomy (`internal/err/`) + +`errors.go` is 1995 lines with 188 functions in a single file. Split into +domain-grouped files. No API changes — same package, same function signatures, +just file reorganization. + +Taxonomy (from prefix analysis): + +| File | Prefixes / Domain | ~Count | +|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------| +| `memory.go` | Memory*, Discover* | 17 | +| `parser.go` | Parser* | 7 | +| `crypto.go` | Crypto*, Encrypt*, Decrypt*, GenerateKey, SaveKey, LoadKey, NoKeyAt | 14 | +| `task.go` | Task*, NoTaskSpecified, NoTaskMatch, NoCompletedTasks | 8 | +| `journal.go` | LoadJournalState*, SaveJournalState*, ReadJournalDir, NoJournalDir, NoJournalEntries, ScanJournal, UnknownStage, StageNotSet | 10 | +| `session.go` | Session*, FindSessions, NoSessionsFound, All*, Ambiguous* | 8 | +| `pad.go` | Edit*, Blob*, ReadScratchpad, OutFlagRequiresBlob, NoConflict*, Resolve* | 10 | +| `recall.go` | Reindex*, Stats*, EventLog* | 6 | +| `fs.go` | Read*, Write*, Open*, Stat*, File*, Mkdir*, CreateDir, DirNotFound, NotDirectory, Boundary* | 30 | +| `backup.go` | Backup*, CreateBackup*, CreateArchive* | 6 | +| `prompt.go` | Prompt*, NoPromptTemplate, ListTemplates, ReadTemplate, NoTemplate | 7 | +| `hook.go` | Embedded*, Override*, UnknownHook, UnknownVariant, MarkerNotFound | 6 | +| `skill.go` | Skill* | 2 | +| `config.go` | UnknownProfile, ReadProfile, UnknownFormat, UnknownProjectType, InvalidTool, UnsupportedTool, NotInitialized, ContextNotInitialized, ContextDirNotFound, FlagRequires* | 12 | +| `errors.go` | Remaining general-purpose: WorkingDirectory, CtxNotInPath, ReadInput, InvalidDate*, Reminder*, Drift*, Git*, Webhook*, etc. | ~25 | + +- [ ] Add freshness_files to .ctxrc defaults seeded by ctx init — currently + the + freshness config is only in the gitignored .ctxrc, so new clones don't get it. + Consider a .ctxrc.defaults pattern or seeding via ctx init template. + #priority:medium #added:2026-03-14-105143 + +- [ ] SEC.1: Security-sensitive file change hook — PostToolUse on Edit/Write + matching security-critical paths (.claude/settings.local.json, + .claude/settings.json, CLAUDE.md, .claude/CLAUDE.md, + .context/CONSTITUTION.md). Three actions: (1) nudge user in-session, (2) relay + to webhook for out-of-band alerting (autonomous loops), (3) append to + dedicated security log (.context/state/security-events.jsonl) for forensics. + Separate from general event log. Spec needed. #priority:high #added:2026-03-13 + +- [ ] O.5: Session timeline view — add --sessions flag to ctx system events. + Per-session breakdown of eval/fired counts with hook list. See + ideas/spec-hook-observability.md Phase 5 #added:2026-03-12-145401 + +- [ ] O.4: Doctor hook health check — surface hook activity in ctx doctor + output + (active/evaluated-never-fired/never-evaluated). See + ideas/spec-hook-observability.md Phase 4 #added:2026-03-12-145401 + +- [ ] O.3: Skip reason logging — add eventlog.Skip() with standard reason + constants (paused, throttled, condition-not-met). Instrument 19 hook + early-exit paths. See ideas/spec-hook-observability.md Phase + 3 #added:2026-03-12-145401 + +- [ ] O.2: Event summary view — add --summary flag to ctx system events. + Aggregates eval/fired counts per hook, shows last-eval/last-fired timestamps, + lists never-evaluated hooks. See ideas/spec-hook-observability.md Phase + 2 #added:2026-03-12-145401 + +- [ ] O.1: Hook eval logging — wrap hook cobra commands to log 'eval' events + on + every invocation. Refactor Run() signatures from os.Stdin to io.Reader + (peek+replay pattern). Adds eventlog.Eval(), EventTypeEval constant. See + ideas/spec-hook-observability.md Phase 1 #added:2026-03-12-145401 + +- [ ] Companion intelligence recommendation: implement spec from + ideas/spec-companion-intelligence.md — ctx doctor companion detection, ctx + init recommendation tip, ctx agent awareness in + packets #added:2026-03-12-133008 + +- [ ] Add configurable assets layer: allow users to plug their own YAML files + for localization (language selection, custom text overrides). Currently all + user-facing text is hardcoded in commands.yaml; need a mechanism to load + user-provided YAML that overlays or replaces built-in text. This enables i18n + without forking. #priority:low #added:2026-03-07-233756 + +- [-] Cleanup internal/cli/system/core/persistence.go: move 10 (base for + ParseInt) to config constant — not actionable, 10 is stdlib decimal base + convention, not a magic number #priority:low #added:2026-03-07-220825 + +- [-] Cleanup internal/cli/system/core/session_tokens.go: move SessionStats from + state.go to types.go — file and type no longer exist, refactored away + #priority:low #added:2026-03-07-220825 + + + + +- [-] SMB mount path support: add `CTX_BACKUP_MOUNT_PATH` env var so + `ctx backup` can use fstab/systemd automounts instead of requiring GVFS. + Spec: specs/smb-mount-path-support.md #priority:medium + #added:2026-04-04-010000 + **Skipped 2026-04-16**: Duplicate of line 214. Superseded by + specs/deprecate-ctx-backup.md (full removal, not mount path fix). + +- [ ] Make AutoPruneStaleDays configurable via ctxrc. Currently hardcoded to 7 + days in config.AutoPruneStaleDays; add a ctxrc key (e.g., auto_prune_days) and + fallback to the default. #priority:low #added:2026-03-07-220512 + +- [-] Refactor check_backup_age/run.go: move consts (lines 23-24) to config, + magic directories (line 59) to config, symbolic constants for strings (line + 72), messages to assets (lines 79, 90-91), extract non-Run functions to + system/core, fix docstrings #priority:medium #added:2026-03-07-180020 + **Skipped 2026-04-16**: Superseded by specs/deprecate-ctx-backup.md + (check_backup_age will be removed entirely, not refactored). + +- [ ] Add ctxrc support for recall.list.limit to make the default --limit for + recall list configurable. Currently hardcoded as config.DefaultRecallListLimit + (20). #priority:low #added:2026-03-07-164342 + +- [ ] Extract journal/core into a standalone journal parser package — + functionally isolated enough for its own package rather than remaining as + core/ #added:2026-03-07-093815 + +- [ ] Move PluginInstalled/PluginEnabledGlobally/PluginEnabledLocally from + initialize to internal/claude — these are Claude Code plugin detection + functions, not init-specific #added:2026-03-07-091656 + +- [ ] Move guide/cmd/root/run.go text to assets, listCommands to separate file + + internal/write #added:2026-03-07-090322 + +- [ ] Move drift/core/sanitize.go strings to assets #added:2026-03-07-090322 + +- [ ] Move drift/core/out.go output functions to internal/write per + convention #added:2026-03-07-090322 + +- [ ] Move drift/core/fix.go fmt.Sprintf strings to assets — user-facing + output + text for i18n #added:2026-03-07-090322 + +- [ ] Move drift/cmd/root/run.go cmd.Print* output strings to internal/write per + convention #added:2026-03-07-084152 + +- [ ] Extract doctor/core/checks.go strings — 105 inline Name/Category/Message + values to assets (i18n) and config (Name/Category + constants) #added:2026-03-07-083428 + +- [ ] Split deps/core builders into per-ecosystem packages — go.go, node.go, + python.go, rust.go are specific enough for their own packages under deps/core/ + or deps/builders/ #added:2026-03-07-082827 + +- [ ] Audit git graceful degradation — verify all exec.Command(git) call sites + degrade gracefully when git is absent, per project guide + recommendation #added:2026-03-07-081625 + +- [ ] Fix 19 doc.go quality issues: system (13 missing subcmds), agent (phantom + refs), load/loop (header typo), claude (stale migration note), 13 minimal + descriptions (pause, resume, task, notify, decision, learnings, remind, + context, eventlog, index, rc, recall/parser, + task/core) #added:2026-03-07-075741 + +- [ ] Move cmd.Print* output strings in compact/cmd/root/run.go to + internal/write per convention #added:2026-03-07-074737 + +- [ ] Extract changes format.go rendering templates to assets — headings, + labels, and format strings are user-facing text for + i18n #added:2026-03-07-074719 + +- [ ] Lift HumanAgo and Pluralize to a common package — reusable time + formatting, used by changes and potentially + status/recall #added:2026-03-07-074649 + +- [ ] Extract isAlnum predicate for localization — currently ASCII-only in + agent + keyword extraction (score.go:141) #added:2026-03-07-073900 + +- [ ] Make stopwords configurable via .ctxrc — currently embedded in assets, + domain users need custom terms #added:2026-03-07-073900 + +- [ ] Make recency scoring thresholds and relevance match cap configurable via + .ctxrc — currently hardcoded in config (7/30/90 days, cap + 3) #added:2026-03-07-073900 + +- [ ] Make DefaultAgentCooldown configurable via .ctxrc — currently hardcoded + at + 10 minutes in config #added:2026-03-07-073106 + +- [ ] Make TaskBudgetPct and ConventionBudgetPct configurable via .ctxrc — + currently hardcoded at 0.40 and 0.20 in config #added:2026-03-07-072714 + +- [ ] Localization inventory: audit config constants, write package templates, + and assets YAML for i18n mapping — low priority, most users are + English-first + developers #added:2026-03-06-192419 + +- [ ] Consider indexing tasks and conventions in TASKS.md and CONVENTIONS.md + (currently only decisions and learnings have index + tables) #added:2026-03-06-190225 + +- [ ] Implement journal compaction: Elastic-style tiered storage with tar.gz + backup. Spec: specs/journal-compact.md #added:2026-03-31-110005 + +- [ ] Validate .ctxrc against ctxrc.schema.json at load time — schema is + embedded but never enforced, doctor does field-level checks without using + it #added:2026-03-06-174851 + + +- [ ] Add PostToolUse session event capture. Append lightweight event records + (tool name, files touched, timestamp) to .context/state/session-events.jsonl + on significant PostToolUse events (file edits, git operations, errors). Not + SQLite — just JSONL append. This feeds the PreCompact snapshot hook with + richer input so it can report what the agent was actively working on, not just + static file state. #added:2026-03-06-185126 + +- [ ] Add next-step hints to ctx agent and ctx status output. Append actionable + suggestions based on context health (e.g. stale tasks, high completion ratio, + drift findings). Pattern learned from GitNexus self-guiding agent + workflows. #added:2026-03-06-184829 + +- [ ] Implement PreCompact and SessionStart hooks for session continuity across + compaction. Wire ctx agent --budget 4000 to both events: PreCompact outputs + context packet before compaction so compactor preserves key info; SessionStart + re-injects context packet so fresh/post-compact sessions start oriented. Two + thin ctx system subcommands, two entries in hooks.json. See + ideas/gitnexus-contextmode-analysis.md for design + rationale. #added:2026-03-06-184825 + +- [ ] Audit fatih/color removal across ~35 files — removed from recall/run.go, + recall/lock.go, write/validate.go; ~30 files remain. Separate consolidation + pass. #added:2026-03-06-050140 + +- [ ] Audit remaining 2006-01-02 usages across codebase — 5+ files still use + the + literal instead of config.DateFormat. Incremental + migration. #added:2026-03-06-050140 + +- [ ] WC.2: Audit CLI packages for direct fmt.Print/Println usage — candidates + for migration #added:2026-03-06 + +### Phase WC2: Write Output Block Consolidation + +Spec: `specs/write-output-consolidation.md`. Read the spec before starting any +WC2 task. + +Consolidate multi-line imperative `cmd.Println` sequences in `internal/write/` +into pre-computed single-print block patterns. Separates conditional logic from +I/O and replaces 4-8 individual Tpl\* constants per function with one +block template. + +- [ ] WC2.1: Tier 1 — Consolidate multi-line functions with no conditionals: + `InfoInitNextSteps`, `InfoObsidianGenerated`, `InfoJournalSiteGenerated`, + `InfoDepsNoProject`, `ArchiveDryRun`, `ImportScanHeader`. Add `TplXxxBlock` + YAML entries, wire through embed.go + config.go, remove replaced individual + constants. #added:2026-03-17 +- [ ] WC2.2: Tier 2a — Consolidate conditional functions in info.go: + `InfoLoopGenerated` (pre-compute iterLine). Prove the pre-computation pattern + on the function that motivated this spec. #added:2026-03-17 +- [ ] WC2.3: Tier 2b — Consolidate conditional functions in + sync/recall/notify: + `SyncResult`, `CtxSyncHeader`, `CtxSyncAction`, `SessionMetadata`, + `TestResult`, `SyncDryRun`, `PruneSummary`. Each needs 1-3 pre-computed + strings before the single print call. #added:2026-03-17 +- [ ] WC2.4: Constant cleanup — verify all replaced individual `TplXxx*` + config + vars, `TextDescKey*` constants, and YAML entries are removed. Run `make lint` + and `go test ./internal/write/...` to confirm no + regressions. #added:2026-03-17 +- [ ] WC2.5: Update CONVENTIONS.md — add a "Write Package Output" subsection + documenting the pre-compute-then-print pattern for future functions with 4+ + Printlns and conditionals. #added:2026-03-17 + +## MCP-related + +### Phase MCP-V3: MCP v0.3 Expansion + +- [ ] Add drift check: MCP prompt coverage vs bundled skills — programmatic + check comparing config/mcp/prompt constants against assets.ListSkills() to + detect skills without MCP prompt equivalents. Pair with the tool coverage + drift check. @CoderMungan #priority:medium #added:2026-03-15-120519 + +- [ ] MCP v0.3: expand MCP prompts to cover more skills — current 5 prompts + (session-start, add-decision, add-learning, reflect, checkpoint) are a subset + of ~30 bundled skills. Evaluate which skills benefit from protocol-native MCP + prompt equivalents. Decision 2026-03-06 established 'Skills stay CLI-based; + MCP Prompts are the protocol equivalent.' @CoderMungan + #priority:medium #added:2026-03-15-120519 + +- [ ] Add drift check: MCP tool coverage vs CLI commands — programmatic check + that compares registered MCP tool names (config/mcp/tool) against ctx CLI + subcommands to detect newly added CLI commands without MCP equivalents. Could + be a drift detector check or a compliance test. @CoderMungan + #priority:medium #added:2026-03-15-120116 + +- [ ] MCP v0.3: expose additional CLI commands as MCP tools — candidates: + ctx_load (full context packet), ctx_agent (token-budgeted packet), ctx_reindex + (rebuild indices), ctx_sync (reconcile docs/code), ctx_doctor (health check). + Evaluate which provide value over the protocol vs requiring terminal + interaction. @CoderMungan #priority:medium #added:2026-03-15-120025 + +- [ ] Make MCP defaults configurable via .ctxrc — add mcp_recall_limit, + mcp_truncate_len, mcp_truncate_content_len, mcp_min_word_len, + mcp_min_word_overlap fields to .ctxrc schema; expose via rc.MCP*() with + fallback to config/mcp/cfg defaults; update tools.go to read from rc instead + of cfg constants. @CoderMungan #priority:medium #added:2026-03-15-114700 + +- [ ] MCP tools.go cleanup pass: magic strings, duplicated fragments, nested + templates. Lines: 461:481 + 186:196 duplicated code; 335 magic number; 382:385 + nested TextDescs → single template; 390+851 magic time literal; 443+499+800 + magic words; 557+892+902 magic numbers; 590+638 nested TextDesc templating; + 820 prefixed %s; 854 suffix %s #priority:high #added:2026-03-15-110429 + +### Phase MCP-SAN: MCP Server Input Sanitization + +[ ] Assignee: @CoderMungan -- https://github.com/ActiveMemory/ctx/issues/49 + +### Phase MCP-COV: MCP Test Coverage + +[ ] Assignee: @CoderMungan -- https://github.com/ActiveMemory/ctx/issues/50 + +## Later + +### Phase PR: State Pruning (`ctx system prune`) + +Clean stale per-session state files from `.context/state/`. Files with UUID +session ID suffixes accumulate ~6-8 per session with no cleanup. Strategy: +age-based — prune files older than N days (default 7). + +- [ ] Regenerate site/ for state-maintenance recipe + (docs/recipes/state-maintenance.md added but site not + rebuilt) #added:2026-03-05-205425 + +- [ ] Audit remaining global tombstones for session-scoping: + backup-reminded, ceremony-reminded, check-knowledge, + journal-reminded, version-checked, ctx-wrapped-up all have + the same cross-session suppression bug as + memory-drift-nudged #added:2026-03-05-205425 + +- [ ] F.2: ctx journal import (remote) — import Claude Code + session JSONLs from local or remote (~/.claude/projects/) + into local ~/.claude/projects/. Pure Go: local copy with + os.CopyFS-style walk, remote via os/exec ssh+scp (no rsync + dependency). --source flag accepts local path or user@host. + --dry-run shows what would be copied. Skips existing files + (content-addressed by UUID filenames). Enables journal export + from sessions that ran on other machines. + #added:2026-03-05-141912 + +- [ ] P0.5: Blog: "Building a Claude Code Marketplace Plugin" + — narrative from session history, journals, and git diff of + feat/plugin-conversion branch. Covers: motivation (shell + hooks to Go subcommands), plugin directory layout, + marketplace.json, eliminating make plugin, bugs found during + dogfooding (hooks creating partial .context/), and the fix. + Use /ctx-blog-changelog with branch diff as source material. + #added:2026-02-16-111948 +- [ ] P9.2: Test manually on this project's LEARNINGS.md (20+ entries). + #priority:medium #added:2026-02-19 +- [ ] P0.8.1: Install golangci-lint on the integration server #for-human + #priority:medium #added:2026-02-23 #added:2026-02-23-170213 +- [ ] PM.3: Review hook diagnostic logs after a long session. Check + `.context/logs/check-persistence.log` and + `.context/logs/check-context-size.log` to verify hooks fire correctly. + Tune nudge frequency if needed. #priority:medium #added:2026-02-09 +- [ ] PM.4: Run `/consolidate` to address codebase drift. Considerable drift has + accumulated (predicate naming, magic strings, hardcoded permissions, + godoc style). #priority:medium #added:2026-02-06 +- [ ] Improve test coverage for core packages at 0% #added:2026-03-20-164324 + +- [ ] PM.7: Aider/Cursor parser implementations: the recall architecture was + designed for extensibility (tool-agnostic Session type with + tool-specific parsers). Adding basic Aider and Cursor parsers would + validate the parser interface, broaden the user base, and fulfill + the "works with any AI tool" promise. Aider format is simpler than + Claude Code's. #priority:medium #source:report-6 #added:2026-02-17 + +## Future + +- [ ] P0.8.5: Enable webhook notifications in worktrees. Currently `ctx notify` + silently fails because `.context.key` is gitignored and absent in + worktrees. For autonomous runs with opaque worktree agents, notifications + are the one feature that would genuinely be useful. Possible approaches: + resolve the key via `git rev-parse --git-common-dir` to find the main + checkout, or copy the key into worktrees at creation time (ctx-worktree + skill). #priority:medium #added:2026-02-22 +- [ ] P0.9.2: Split cli-reference.md (1633 lines) into command group pages: + cli-overview, cli-init-status, cli-context, cli-recall, cli-tools, + cli-system — + each page covers a natural command group with its subcommands and flags + #added:2026-02-24-204208 +- [ ] P0.9.3: Investigate proactive content suggestions: + docs/recipes/publishing.md claims + agents suggest blog posts and journal rebuilds at natural moments, but no hook + or playbook mechanism exists to trigger this — either wire it up (e.g. + post-task-completion nudge) or tone down the docs to match reality + #added:2026-02-24-185754 +- [ ] PG.1: Add agent/tool compatibility matrix to prompting guide — + document which + patterns degrade gracefully when agents lack file access, CLI tools, or + ctx integration. Treat as a "works best with / degrades to" table. + #priority:medium #added:2026-02-25 +- [ ] PG.2: Add versioning/stability note to prompting guide — "these + principles are + stable; examples evolve" + doc date in frontmatter. Needed once the guide + becomes canonical and people start quoting it. + #priority:low #added:2026-02-25 +- [ ] P0.1: Brainstorm: Standardize drift-check comment format and + integrate with + `/ctx-drift` — formalize ad-hoc `` markers, teach + drift skill to parse/execute them, publish pattern in docs/recipes. Benefits + tooling/CLI but AI handles ad-hoc fine for now. + #priority:medium #added:2026-02-28 +- [ ] F.1: MCP server integration: expose context as tools/resources via Model + Context Protocol. Would enable deep integration with any + MCP-compatible client. #priority:low #source:report-6 +- [ ] Q.1: Docstring cross-reference audit — compliance test that + flags docstrings + mentioning domains that don't match their callers. Start with `write/**`, + extend to all `internal/`. Spec: `specs/docstring-cross-reference-audit.md` + #priority:medium #added:2026-03-17 + +- [ ] Migrate Sprintf-based templates (tpl_*.go) to Go text/template or embedded + template files — ObsidianReadme, LoopScript, and other multi-line format + strings that can't move to YAML #added:2026-03-18-163629 + +- [ ] Split internal/assets/embed_test.go — tests that call read/ packages + must + move to their respective read/ package to avoid import + cycles #added:2026-03-18-192914 + +- [ ] Improve recall/core format tests — replace hardcoded string assertions + (e.g. Contains Tokens) with semantic checks that verify structure and values, + not label text #added:2026-03-19-194645 + +### Phase BT: Build Tooling — `cmd/ctxctl` + +Replace shell-based build scripts (Makefile shell +expansions, `hack/build-all.sh`, +`hack/release.sh`, `hack/tag.sh`, `sync-*`/`check-*` targets) with a first-class +Go binary at `cmd/ctxctl`. Shares internal packages with `ctx` (version, assets, +embed FS). Installable: `go +install github.com/ActiveMemory/ctx/cmd/ctxctl@latest`. +Eliminates `jq` build dependency. Testable, cross-platform. + +- [ ] Bug: release script versions.md table insertion fails silently. The sed + pattern on line 133 uses `$` anchor but the actual Markdown table header has + column padding spaces before the trailing `|`. The row is never inserted. Fix: + relax the header match pattern or switch to a simpler approach (e.g., insert + after the separator line directly). Also verify the "latest stable" sed + handles trailing `).\n` correctly. #priority:high #added:2026-03-23-221500 + +- [ ] Replace hack/lint-drift.sh with AST-based Go tests in internal/audit/. + Spec: `specs/ast-audit-tests.md` #added:2026-03-23-210000 + +- [ ] Rewrite lint-style scripts in Go as ctxctl subcommands — + blocked: prerequisite ctxctl does not exist yet. Deferred. + #added:2026-03-29-082958 + +Dividing line: `ctx` is the user/agent tool, `ctxctl` is +the maintainer/contributor +tool. If a developer clones the repo and needs to build, test, release, +or validate +— that's `ctxctl`. If a user is working in a project and needs context — +that's `ctx`. + +Strong fits beyond build/release: +- `ctxctl plugin package` — package .claude-plugin for marketplace publishing +- `ctxctl plugin validate` — validate plugin.json, hooks.json, skill structure +- `ctxctl doctor` — contributor pre-flight (Go version, tools, GPG, hooks); + absorbs `hack/gpg-fix.sh` and `hack/gpg-test.sh` +- `ctxctl changelog` — deterministic release notes from git log + +Reasonable fits if project grows: +- `ctxctl test smoke` — replaces the shell pipeline in `make smoke` +- `ctxctl site build/serve` — wraps zensical + feed generation +- `ctxctl mcp register` — replaces `hack/gemini-search.sh` and future + MCP registrations + +Not a fit (keep in `ctx`): +- Anything user-facing in a project context (status, agent, drift, recall) +- Anything Claude Code hooks call — hooks must call `ctx`, not `ctxctl` + +- [ ] Design `ctxctl` CLI surface: `ctxctl sync`, `ctxctl build`, `ctxctl + release`, `ctxctl check`, `ctxctl tag` #added:2026-03-25-050000 +- [ ] Implement `ctxctl sync` — stamps VERSION into plugin.json + syncs why + docs; replaces `sync-version`, `sync-why` #added:2026-03-25-050000 +- [ ] Implement `ctxctl check` — drift checks: version sync, why docs, + lint-drift, lint-docs; replaces `check-*` targets #added:2026-03-25-050000 +- [ ] Implement `ctxctl build` — cross-platform builds with version stamping; + replaces `build-all.sh` #added:2026-03-25-050000 +- [ ] Implement `ctxctl release` — full release flow (sync, build, tag, + checksums); replaces `release.sh` + `tag.sh` #added:2026-03-25-050000 +- [ ] Simplify Makefile to thin wrappers: `make build` → `go run ./cmd/ctxctl + build` #added:2026-03-25-050000 +- [ ] Remove `jq` build dependency once ctxctl handles JSON + natively #added:2026-03-25-050000 + +- [ ] Implement MCP warm-up in /ctx-remember session ceremony — when a + graph/RAG + tool is configured in .ctxrc, run one orientation query at session start to + build procedural familiarity. Spec: + `ideas/spec-mcp-warm-up-ceremony.md` #added:2026-03-25-120000 + +- [ ] Update ctx doctor to check for graph tool availability — detect if a + graph/RAG MCP is configured in .ctxrc, verify connection status, recommend + installation if missing #added:2026-03-25-120000 + +- [ ] Explore pluggable graph tool interface — replace hardcoded GitNexus + references in skill text with configurable .ctxrc graph_tool key. Skills use + template placeholder instead of literal tool names. Define minimum interface + contract (query, context, impact). Spec: + `ideas/spec-mcp-warm-up-ceremony.md` #added:2026-03-25-120000 + +- [x] HUB-1: Define hub.proto — gRPC service definition with Register, + Publish, Sync, Listen, Status RPCs. Generate Go code. Spec: + specs/context-hub.md #priority:high #added:2026-04-06-113020 #done:2026-04-06 + +- [x] HUB-2: Implement internal/hub/store.go — JSONL append-only entry storage + with sequence assignment, type filtering, and since-sequence queries. Spec: + specs/hub_implementation.md #priority:high #added:2026-04-06-113021 + #done:2026-04-06 + +- [x] HUB-3: Implement internal/hub/auth.go — admin token generation on first + run, client token issuance via Register RPC, gRPC interceptor for Bearer token + validation. Spec: specs/context-hub.md #priority:high #added:2026-04-06-113022 + #done:2026-04-06 + +- [x] HUB-4: Implement internal/hub/server.go — gRPC server with Register, + Publish, Sync RPCs. Wire auth interceptor, JSONL store, TLS support. Spec: + specs/context-hub.md #priority:high #added:2026-04-06-113024 #done:2026-04-06 + +- [x] HUB-5: Implement ctx serve --shared CLI command — starts gRPC hub server + on specified port, generates admin token on first run, supports + --tls-cert/--tls-key flags. Spec: specs/context-hub.md #priority:high + #added:2026-04-06-113030 #done:2026-04-06 + +- [x] HUB-6: Implement internal/hub/client.go — gRPC client with Register, + Sync, Publish, Listen methods. Connection config encrypted storage via + internal/crypto (same pattern as notify). Spec: specs/context-hub.md + #priority:high #added:2026-04-06-113032 #done:2026-04-06 + +- [x] HUB-7: Implement ctx connect register — one-time registration with hub, + stores encrypted connection config in .context/.connect.enc. Spec: + specs/context-hub.md #priority:high #added:2026-04-06-113033 #done:2026-04-06 + +- [x] HUB-8: Implement ctx connect subscribe — set entry type filters + (decisions, learnings, conventions), persist in local connection config. Spec: + specs/context-hub.md #priority:medium #added:2026-04-06-113035 + #done:2026-04-07 + +- [x] HUB-9: Implement ctx connect sync — initial full pull of matching + entries from hub, write to .context/shared/ as markdown files with origin + tags, record last-seen sequence in .sync-state.json. Spec: + specs/context-hub.md #priority:medium #added:2026-04-06-113041 + #done:2026-04-07 + +- [x] HUB-10: Implement ctx connect publish and --share flag — push local + entries to hub. Add --share flag to ctx add so entries go to local file AND + hub simultaneously. Spec: specs/context-hub.md #priority:medium + #added:2026-04-06-113043 #done:2026-04-07 + +- [x] HUB-11: Implement Listen RPC with fan-out — server-streaming RPC that + pushes new entries to connected clients in real-time. ctx connect listen with + auto-reconnect on disconnect. Spec: specs/context-hub.md #priority:medium + #added:2026-04-06-113044 #done:2026-04-07 + +- [x] HUB-12: Implement ctx connect status — show server address, connection + state, last sync time, subscription config, entry counts by type. Includes + hub-side Status RPC. Spec: specs/context-hub.md #priority:medium + #added:2026-04-06-113046 #done:2026-04-07 + +- [x] HUB-13: Implement ctx agent --include-shared — add Tier 8 budget for + shared knowledge in agent packet assembly. Shared entries from + .context/shared/ included when --include-shared flag is passed. Spec: + specs/context-hub.md #priority:medium #added:2026-04-06-113053 + #done:2026-04-07 + +- [x] HUB-14: Implement --daemon flag for ctx serve --shared — background + process with PID file, --stop to kill, graceful shutdown. Required for + federation. Spec: specs/hub-federation.md #priority:medium + #added:2026-04-06-113054 + +- [x] HUB-15: Integrate hashicorp/raft for leader election — Raft-lite: use + Raft ONLY for master election, not data consensus. --peers flag for cluster + membership. Single-node mode auto-elects. Spec: specs/hub-federation.md + #priority:medium #added:2026-04-06-113056 + +- [x] HUB-16: Implement master-to-follower replication — master pushes entries + to followers via gRPC stream. Followers catch up via sequence-based sync on + reconnect. Spec: specs/hub-federation.md #priority:medium + #added:2026-04-06-113058 + +- [x] HUB-17: Implement client failover — clients maintain ordered peer list, + auto-reconnect to new master on connection failure. Follower redirects client + to current master address. Spec: specs/hub-federation.md #priority:medium + #added:2026-04-06-113104 + +- [x] HUB-18: Implement ctx hub status/peer/stepdown — cluster status display + (role, peers, sync state, entries, uptime), runtime peer add/remove, graceful + leadership transfer. Spec: specs/hub-federation.md #priority:low + #added:2026-04-06-113106 + +- [x] HUB-19: Update compliance test — add internal/hub/ to allowed-net-import + list alongside internal/notify/. Core packages remain network-free. Spec: + specs/hub_implementation.md #priority:high #added:2026-04-06-113107 + +- [x] HUB-20: End-to-end integration test — spin up hub, register 2 clients, + publish from one, verify sync on other. Test --share flag, Listen stream, and + reconnect behavior. Spec: specs/context-hub.md #priority:medium + #added:2026-04-06-113109 + +- [x] HUB-2a: Implement hub client registry and meta persistence — + clients.json for registered client tokens/project names, meta.json for + sequence counter and hub metadata. Separate from entries.jsonl. Spec: + specs/context-hub.md #priority:high #added:2026-04-06-114131 + +- [x] HUB-9a: Implement shared file renderer — convert Entry objects to + markdown with origin tags and date headers, create/append to + .context/shared/*.md files. Reused by both ctx connect sync and ctx connect + listen. Spec: specs/context-hub.md #priority:medium #added:2026-04-06-114131 + +- [x] HUB-21: Unit tests for internal/hub/ — store (append, query, rotation), + auth (token generation, validation, interceptor), client (connect, reconnect), + renderer (markdown output). Each package tested independently. Spec: + specs/hub_implementation.md #priority:medium #added:2026-04-06-114131 + +- [x] HUB-22: Documentation — create docs/cli/connect.md and docs/cli/serve.md + for new commands, update docs/cli/agent.md for --include-shared flag and + --shared-budget option. Spec: specs/context-hub.md #priority:low + #added:2026-04-06-114131 + +### Phase: ctx Hub follow-ups (PR #60) + +**Context**: PR #60 `feat: ctx Hub for cross-project knowledge +sharing` (parlakisik) merged despite open review feedback from @bilersan and +a pending review request. Author is heads-down on his Ph.D.; these tasks +capture the cleanup and documentation debt we accepted by merging. +PR: https://github.com/ActiveMemory/ctx/pull/60 +Review with findings: +https://github.com/ActiveMemory/ctx/pull/60#pullrequestreview-PRR_kwDOQ9VoNc7ze3nA + +#### Build / platform + +- [x] Fix Windows build: `internal/exec/daemon/daemon.go` uses + `syscall.SysProcAttr{Setsid: true}` (Unix-only). Split into + `daemon.go` (platform-agnostic), `detach_unix.go` (`//go:build !windows`, + `Setsid`), `detach_windows.go` (`//go:build windows`, + `CREATE_NEW_PROCESS_GROUP | HideWindow`). Verified with + `GOOS=windows go build ./...`. #priority:high #added:2026-04-11 #pr:60 + #done:2026-04-11 +- [ ] Add Windows job to CI so this class of regression is caught at PR time, + not by reviewers running local builds. #priority:high #added:2026-04-11 #pr:60 +- [ ] Triage the 16 package-level test failures @bilersan reported on Windows + — classify as platform-specific vs genuine bugs. #added:2026-04-11 #pr:60 + +#### Convention drift + +- [x] Fix 38 `types.go` convention violations introduced by `internal/hub` + and related packages. Resolved upstream in commit `9efe1a94 fix: reconcile + hub code with main's audit tests after rebase` — `make audit` now reports + "All checks passed!" on Linux, and `make lint` is 0 issues. + #priority:high #added:2026-04-11 #pr:60 #done:2026-04-11 +- [ ] Audit `internal/hub`, `internal/cli/connect`, `internal/cli/hub`, + `internal/cli/serve` against CONVENTIONS.md (godoc format, import aliases, + error wrapping, package layout). #added:2026-04-11 #pr:60 +- [ ] Run `/ctx-code-review` over the hub subsystem for edge cases missed in + the merge: token rotation, connection-config migration, Raft leader + handoff failure modes, sync cursor corruption recovery. #added:2026-04-11 + #pr:60 + +#### User-facing docs (cornerstone — scope first) + +- [x] Enumerate all doc surfaces touched by the hub: `docs/cli/connect.md`, + `docs/cli/hub.md`, `docs/cli/serve.md`, `docs/cli/init-status.md`, + `docs/cli/index.md` already existed from the PR but the three new CLI + pages were NOT wired into `zensical.toml` nav — fixed. Added three new + recipes, two operations docs, and one security doc; wired all into nav. + #priority:high #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Write a **Getting Started: Shared Hub** recipe: single-node hub on + localhost, register first project, publish a decision, sync from a second + project, `ctx agent --include-shared`. Written to + `docs/recipes/hub-getting-started.md` and wired into nav. + #priority:high #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Write a **Multi-machine hub** recipe: `ctx serve --shared --daemon` + on a LAN host, firewall/port guidance, bearer token provisioning, + `.connect.enc` distribution, `ctx connect register` from clients. + Written to `docs/recipes/hub-multi-machine.md`, wired into nav. + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Write a **High-availability cluster** recipe: Raft peers with + `--peers`, `ctx hub peer add/remove`, `ctx hub stepdown`, failure-mode + walkthrough (leader loss, split brain, recovery). Written to + `docs/recipes/hub-cluster.md`, wired into nav. + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Write a **Security model** doc: bearer token lifecycle, AES-256-GCM + `.connect.enc` at-rest, constant-time comparison, 1 MB content cap, type + allowlist. Threat model and operational hardening checklist. Written to + `docs/security/hub.md`, wired into nav. #priority:high + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Write an **Operations** doc: starting/stopping the daemon, log + locations, `ctx serve --stop`, `ctx hub status`, JSONL store layout, + backup/restore of the append-only log, systemd unit, log rotation. + Written to `docs/operations/hub.md`, wired into nav. + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [ ] Document the auto-sync-on-session-start hook: what it does, how to + opt out, interaction with existing UserPromptSubmit hooks, performance + impact on large hubs. Partially covered in connect.md (`check-hub-sync` + mention); a dedicated section is still owed. #added:2026-04-11 #pr:60 +- [x] Document `ctx add --share` and `ctx agent --include-shared` — already + covered in `docs/cli/connect.md` (`--share`) and `docs/cli/init-status.md` + (`--include-shared` flag + Tier 8 explanation); playbook update deferred + until a dedicated "shared knowledge in agent packets" section is written. + #priority:high #added:2026-04-11 #pr:60 #done:2026-04-11 +- [ ] Add an **architecture** section to `ARCHITECTURE.md` / + `DETAILED_DESIGN.md` covering: JSONL append-only store, JSON-over-gRPC + codec (no protoc), fan-out broadcaster, Raft-lite (election only, data + via gRPC sync), sequence-based replication. #added:2026-04-11 #pr:60 +- [x] Add a **failure analysis** page for the hub: what happens on network + partition, disk full, corrupted JSONL, token rotation during active + streams, clock skew between peers. Written to + `docs/operations/hub-failure-modes.md`, wired into nav. Covers + reminder [7]. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [ ] Record a DECISION explaining why we merged PR #60 with known Windows + breakage and convention drift — trade-off, author context, mitigation + plan (this task group). #added:2026-04-11 #pr:60 +- [ ] Update CONVENTIONS.md if any new patterns from the hub are worth + canonicalizing (gRPC handler layout, JSONL store access, bearer-token + middleware). #added:2026-04-11 #pr:60 + +#### Framing and mental model (2026-04-11 follow-up) + +- [x] Write `docs/recipes/hub-overview.md` — mental model in one + paragraph, what flows / what does not flow, two explicit user stories + (personal cross-project brain vs small trusted team), "when not to + use it" section. Wired as the first entry in the ctx Hub + nav section. #priority:high #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rewrite the opening of `docs/recipes/hub-getting-started.md` + to plant stakes ("what you'll get out of this recipe", "what this + recipe does not cover") and point at the overview before any commands. + #priority:high #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Add a "read the overview first" signpost to the top of + `hub-multi-machine.md` and `hub-cluster.md`, naming + each recipe as Story 2 (trusted team) shape. #added:2026-04-11 #pr:60 + #done:2026-04-11 +- [x] Give `docs/cli/connect.md` a real "what is this" intro — unit of + identity is a project not a user, only four entry types flow, link + to the recipes. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Give `docs/cli/hub.md` a real "who needs this page" intro — + operator commands only, link to `ctx connect` for clients and to the + overview for the mental model. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Give `docs/operations/hub.md` an operator-cheat-sheet + intro (four entry types, project identity, append-only model) and + link to the overview. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Fix factual error in `docs/security/hub.md`: + `clients.json` stores client tokens **plaintext**, not hashed. + Replaced the "hashed" claim with a prominent warning admonition, + listed filesystem-level mitigations, and referenced the follow-up + task for hashing / keyring storage. Updated + `docs/operations/hub-failure-modes.md` compromise scenarios + to match (including a new "Compromised hub host" entry). Also + documented that `Origin` is self-asserted on publish, so attribution + cannot be trusted after token compromise. #priority:high + #added:2026-04-11 #pr:60 #done:2026-04-11 + +#### Design follow-ups surfaced by the brainstorm (2026-04-11) + +- [ ] Decide the product story: "personal cross-project brain", + "small trusted team", or both — then align the overview, recipes, + and CONTRIBUTING guidance to match. #priority:high #added:2026-04-11 + #pr:60 +- [ ] Server-enforce `Origin` on publish: reject entries whose + `Origin` does not match the authenticated client's `ProjectName`. + Closes a spoofing vector and eliminates accidental mislabeling. + Small change in `internal/hub/handler.go publish()`. + #priority:high #added:2026-04-11 #pr:60 +- [ ] Hash `clients.json` tokens or move them behind the local + keyring (reuse `internal/crypto`). Removes the plaintext-token + footgun documented in the security page. + #priority:high #added:2026-04-11 #pr:60 +- [x] Decide the fate of `Entry.Author`: keep, drop, or promote to + a real identity field. **Decided**: server-authoritative. The + server stamps Author from the authenticated identity source on + every publish; client input is ignored. Pre-registry: stamp with + `ClientInfo.ProjectName`. Registry MVP: stamp with + `users.json.user_id`. PKI stretch: stamp with signed-claim `sub`. + See `.context/DECISIONS.md` [2026-04-11-180000]. Implementation + tasks land under H-22 in the security audit phase. + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [ ] Explore journal-entry → `learning` export path: the density + users expect from "shared context" lives in enriched journal + entries, not in manually written `ctx add learning`. Would let + the hub surface the lessons agents already recorded in sessions + without actually replicating journals. #added:2026-04-11 #pr:60 + +#### Phase: Hub identity layer for public-internet usage (2026-04-11) + +**Context**: The current hub has no concept of user identity. +Tokens identify **projects**, not humans. `Origin` is +self-asserted on publish. `clients.json` stores tokens in +plaintext. For the "personal" and "small trusted team" stories +(overview.md Stories 1 and 2) this is acceptable — the trust +model is "everyone holding a token is friendly." + +For public-internet usage (the "Story 3" shape we explicitly +declared out of scope in the overview) these become real gaps: +no per-user attribution, no way to revoke individual humans, no +audit trail that proves who published what, and `clients.json` +compromise equals total hub compromise. + +**Near-term MVP**: a pre-seeded identity registry owned by the +sysadmin. Instead of dynamic token issuance via admin token, +the hub reads a `users.json` file the sysadmin hand-edits, and +client registration validates against that pre-seeded list. +This is simpler than OAuth/OIDC, doesn't require a separate +identity service, and matches how internal services at small +orgs usually start before adopting an SSO. + +**Eventual design requirements** (decision record TBD): + +- Per-human identity, not per-project +- Tokens tied to a user ID, not a project name +- Server-enforced `Origin` matches the authenticated user (or + a user's declared project list, with server validation) +- Revocation by removing a user row from the registry and + forcing token rotation +- Hashed token storage at rest +- Optional: attribution-bearing audit log distinct from + `entries.jsonl` + +The following tasks feed into this track (they already exist +in the "Design follow-ups surfaced by the brainstorm" section +above; do not duplicate here): + +- Server-enforce `Origin` on publish (blocks spoofing) +- Hash `clients.json` tokens (blocks plaintext compromise) +- Decide the fate of `Entry.Author` (promote, drop, or keep + unauthenticated) + +Tasks unique to this phase: + +- [ ] Write a spec for the sysadmin-curated identity registry: + filename, format, schema, bootstrap flow, revocation + procedure, migration path from today's `clients.json`. + `specs/hub-identity-registry.md`. Must resolve: + + - **Token issuance**: out-of-band on the server + (`ctx hub users add` prints the plaintext token once + on stdout; only a hash is persisted). + - **Client pickup**: user receives the token out-of-band + and runs `ctx connect register --token + ctx_cli_... --project `; hub validates against + the registry. + - **TTL decision** (pick one, document in the spec): + * **Option A** (recommended): no TTL, manual revocation + only. `ctx hub users remove ` is the only + expiry path. Matches today's `clients.json` + semantics, zero surprise breakage on migration. + * **Option B**: optional `expires_at` per user row. + Tokens without it are valid forever (Option A + behavior); tokens with it are rejected after the + timestamp. Ship as an additive follow-up. + * **Option C** (explicitly rejected): rolling + expiry based on `last_used_at`. Garbage-collects + dormant tokens but breaks users who take long + vacations. Not worth the support cost. + - **Revocation procedure**: sysadmin edits `users.json`, + signals the hub to reload, affected tokens fail + immediately on next RPC. + - **Migration from `clients.json`**: one-shot converter + that reads today's `clients.json`, prompts the + sysadmin for a `user_id` per row, and writes + `users.json`. Leave `clients.json` in place as a + read fallback during migration, delete once + everyone is on the new path. + + #priority:high #added:2026-04-11 #pr:60 +- [ ] Implement `users.json` format: `{user_id: {project_ids: + [...], token_hash: "...", created_at: "...", notes: "..."}}`. + Read on hub start and on each Register RPC. Hot-reload via + SIGHUP or file watcher. #added:2026-04-11 #pr:60 +- [ ] Change `Register` RPC semantics: instead of minting a + new client token from the admin token, look up the + requested `ProjectName` in `users.json`. Reject if not + pre-seeded. Return the pre-hashed token only if the caller + presents an initial-provisioning credential the sysadmin + seeded alongside the registry row. #added:2026-04-11 #pr:60 +- [ ] Add `ctx hub users` subcommand group for sysadmin + operations: `add`, `remove`, `rotate`, `list`. These edit + `users.json` directly and signal the running hub to + reload. #added:2026-04-11 #pr:60 +- [ ] Add per-user audit log (`audits.jsonl` beside + `entries.jsonl`). Each RPC records user_id, method, result + status, timestamp. Separate from `entries.jsonl` so it can + be retained on a different schedule. #added:2026-04-11 + #pr:60 +- [ ] Write `docs/security/hub-identity.md` explaining the + registry-based identity model, the threat model it closes, + the threats it still doesn't close, and the operational + procedures (seed the registry, rotate a token, revoke a + user). #added:2026-04-11 #pr:60 +- [ ] Decide whether to ship the identity layer as a + **breaking change** (existing `clients.json` deployments + must migrate) or as an **opt-in flag** (`ctx hub start + --identity users.json`). Document in the spec above. + #added:2026-04-11 #pr:60 +- [ ] Update the hub overview and team recipe to name the + identity registry as the "upgrade path to larger teams" + story: "once your team grows past ~10 people or you need + auditable attribution, enable the identity registry." The + current overview treats Story 3 as unsupported — with the + registry this becomes Story 2.5: "small trusted team with + real attribution." #added:2026-04-11 #pr:60 +- [ ] Stretch: OIDC/OAuth bridge. Once the registry layer is + stable, consider adding an optional provider bridge so + `users.json` can be auto-populated from an external + identity source (Google Workspace, GitHub orgs, etc.). Not + a near-term priority — registry-only covers the first + order of magnitude of users. #added:2026-04-11 #pr:60 +- [ ] Stretch: signed-claim / PKI authentication. The + sysadmin-registry MVP and the OIDC bridge are both + **bearer token** models — possession of the token bytes + is identity. This is fine for trusted orgs but has + well-known replay/rotation/identity limits for true + public-internet usage. + + The next tier up is **asymmetric / signed-claim** auth: + sysadmin holds a private signing key, issues short-lived + claims `{user, project, expiry}` signed with that key, + clients present the signed claim on each RPC, server + verifies with the public key. Benefits: + + - Private key never leaves the sysadmin's machine. + - Claims expire in minutes → revocation is automatic. + - Each claim carries identity cryptographically. + - No per-RPC registry lookup — signature verification + is cheap. + + Reference designs to evaluate: JWT (RS256/ES256/EdDSA), + mTLS client certificates, SPIFFE/SPIRE workload + identities. Decision driver: does ctx ever want to run + as a real public-internet service, or does "trusted + team" always remain the upper bound? + + This is the Story 3 → true multi-tenant upgrade. Not a + near-term priority; captured here so the registry-first + MVP doesn't get confused for a final-state solution. + #added:2026-04-11 #pr:60 + +#### Phase: "dependency-free" claim cleanup (2026-04-11) + +**Context**: The design-invariant list in marketing and +reference docs historically included "dependency-free" +as one of five properties (alongside local-first, +file-based, CLI-driven, developer-controlled). This was +accurate when ctx was a single Go binary with no +external services. PR #60 (hub), the zensical +integration (`ctx serve`), the Claude Code plugin + +MCP, and future networked features make the blanket +claim false. + +**Replacement framing (adopted 2026-04-11)**: +"**single-binary core**". The context persistence path +(`init`, `add`, `agent`, `status`, `drift`, `load`, +`sync`, `compact`, `task`, `decision`, `learning`, and +siblings) remains a single Go binary with no required +runtime dependencies. Optional integrations — `ctx +trace` (needs `git`), `ctx serve` (needs `zensical`), +`ctx` Hub (needs a running hub), Claude Code plugin +(needs `claude`) — are opt-in and each declares its +dependency explicitly. + +This framing is load-bearing: it communicates the +design intent (nothing you don't opt into) without +claiming a literal falsehood. + +- [x] Update `docs/reference/comparison.md` bullet list + from "dependency-free" to "single-binary core" with + an explicit list of optional integrations and their + dependencies. #added:2026-04-11 #done:2026-04-11 +- [x] Update `docs/thesis/index.md:73` (the five-property + claim) from "zero runtime dependencies" to "a + single-binary core with zero required runtime + dependencies for the persistence path". + #added:2026-04-11 #done:2026-04-11 +- [-] `docs/thesis/index.md:412` (the primitive + comparison table saying "Document: Zero-dependency: + Yes"): left intact. The claim is about the document + primitive itself (markdown files have no runtime + deps), not about ctx as an implementation. Accurate. + #added:2026-04-11 #skipped:primitive-claim-is-correct +- [ ] Add a design-invariants reference note: the + blanket claim "dependency-free" MUST NOT be + reintroduced in new docs. Any new framing should use + "single-binary core" or name the specific path + (e.g., "persistence path", "agent packet assembly"). + #priority:medium #added:2026-04-11 +- [ ] Pre-release re-sweep: before each minor release, + grep `docs/`, `README.md`, and any blog drafts for + `dependency-free|dependency free|zero dependencies| + no dependencies` and verify each occurrence is + scoped to a path that is still dependency-free. Add + to the release runbook. #priority:medium + #added:2026-04-11 +- [ ] Update `docs/reference/design-invariants.md` to + explicitly list "single-binary core" as an invariant + with the scope definition, so future doc authors + have a canonical source to reference instead of + re-deriving the phrase. #priority:medium + #added:2026-04-11 + +#### Phase: Hub security audit (2026-04-11) + +**Context**: Full security audit of the hub subsystem, +completed during the PR #60 follow-up brainstorm as a +precondition for any public-internet deployment. 30 +findings total — 5 Critical, 12 High, 7 Medium, 4 Low, 2 +Info — covering transport security, identity, +attribution, DoS surface, Raft cluster integrity, and +storage integrity. + +The audit lives at `specs/hub-security-audit.md` and is +the canonical reference for the rest of the hub security +work. Each finding has a concrete remediation, +complexity estimate, and cross-reference to existing +tasks where applicable. The spec also contains +recommendations grouped by timeline (do-now / short / +medium / long). + +**Per-story verdicts from the audit**: + +- **Story 1** (personal cross-project brain, localhost): + acceptable as-is. No adversary in scope. +- **Story 2** (small trusted team on LAN): acceptable + with documented caveats — LAN private, hub host + hardened, admin token held only by the sysadmin. The + `hub-team.md` recipe already names these. +- **Story 3** (public-internet / multi-user): **UNSAFE**. + Do not deploy. Five critical findings apply, several + high-severity findings compound catastrophically + without transport security, and the Raft cluster is + a remote unauthenticated DoS surface. + +**This phase tracks the findings as actionable work**. +Individual findings are numbered H-01 through H-30 in +the spec; this task list references them by number and +links back to the spec for detail. + +- [ ] Read and internalize + [`specs/hub-security-audit.md`](../specs/hub-security-audit.md) + before starting any hub-security implementation. + The spec is the single source of truth for findings, + severity, and remediation patterns. #priority:high + #added:2026-04-11 #pr:60 + +**Do-now track** (prerequisites for non-localhost deployments): + +- [ ] **H-01** Add server-side TLS: `--tls-cert` and + `--tls-key` flags on `ctx hub start`, wire into + `grpc.NewServer` via `grpc.Creds`. Keep plaintext + default for Story 1. #priority:critical + #added:2026-04-11 #pr:60 #audit:H-01 +- [ ] **H-02** Add client-side TLS: accept `grpc://` + and `grpcs://` schemes in `hub_addr`. Update + `NewClient`, `replicateOnce`, `NewFailoverClient` to + switch credentials per scheme. Optional `--ca-cert` + for self-signed. Update + `docs/recipes/hub-multi-machine.md` to document both + forms (the current nginx-reverse-proxy recommendation + is un-implementable until this ships). #priority:critical + #added:2026-04-11 #pr:60 #audit:H-02 +- [ ] **H-04** Server-enforce `Origin` on publish: + `validateBearer` attaches `ClientInfo` to context; + `handler.go publish()` overwrites `pe.Origin` with + the authenticated `ClientInfo.ProjectName` before + store. Add a test that a client authenticated as + `alpha` cannot publish as `beta`. #priority:high + #added:2026-04-11 #pr:60 #audit:H-04 +- [ ] **H-15** Fix `appendFile` in `internal/hub/persist.go` + to use real `O_APPEND` instead of read-all-rewrite. + Closes both a performance bug (O(N²) publishes) and + a data-loss risk (partial write can truncate history). + #priority:high #added:2026-04-11 #pr:60 #audit:H-15 + +**Short-term track** (Story 2 hardening): + +- [ ] **H-03** Hash `clients.json` tokens with argon2id. + One-shot migration reads old file, hashes each token, + rewrites. Plaintext token only passes through memory + at registration time; disk only stores hashes. + Already referenced in the design-follow-ups section + above; this entry ties it to the audit. #priority:high + #added:2026-04-11 #pr:60 #audit:H-03 +- [ ] **H-08** Per-token Publish rate limiting using + `golang.org/x/time/rate`. Starting target: 10 entries/sec + per token, 100 burst. Return `ResourceExhausted` with + Retry-After hint. #priority:high #added:2026-04-11 #pr:60 + #audit:H-08 +- [ ] **H-09** Per-token Listen stream cap (suggested + limit: 4 concurrent streams per token, 256 total). + Track in the `fanOut` struct; reject further subscribes + with `ResourceExhausted`. #priority:high + #added:2026-04-11 #pr:60 #audit:H-09 +- [ ] **H-17** Cap `PublishRequest.Entries` at 32 per + request; reject larger batches with + `InvalidArgument`. Document the limit. #priority:high + #added:2026-04-11 #pr:60 #audit:H-17 +- [ ] **H-18** Add `audits.jsonl` as a per-RPC audit log + distinct from `entries.jsonl`. Records + `{ts, method, user, project, status, entry_count}` + per call, including authentication failures. Exposed + via `ctx hub status --audit`. Independent rotation + cadence. Already referenced in the identity-layer + phase; this entry ties it to the audit. #priority:high + #added:2026-04-11 #pr:60 #audit:H-18 +- [ ] **H-19** Implement real revocation: `ctx hub users + remove ` edits the registry and signals the hub + to reload via `fsnotify`. Revoked tokens fail + immediately on next RPC. Revocation events logged to + `audits.jsonl`. Merged with the Hub identity layer + phase implementation. #priority:high #added:2026-04-11 + #pr:60 #audit:H-19 +- [x] **H-22 (decide)** Decide `Entry.Author` fate. + **Decided** 2026-04-11: server-authoritative — stamp + from the authenticated identity source, ignore client + input. See `.context/DECISIONS.md` [2026-04-11-180000]. + #added:2026-04-11 #pr:60 #audit:H-22 #done:2026-04-11 +- [ ] **H-22 (implement)** Implement server-authoritative + `Entry.Author`. Identical mechanism to H-04 (Origin + enforcement): `validateBearer` attaches `ClientInfo` + to the gRPC context; `handler.go publish()` reads + `ClientInfo` and stamps `entries[i].Author` from the + server-known identity before calling `store.Append`. + Pre-registry the stamping source is + `ClientInfo.ProjectName`; after the registry MVP the + source becomes `users.json` row's `user_id`; after + the PKI stretch it becomes the signed-claim `sub`. + Same commit as H-04 is fine — they share the + `authFromContext` plumbing. Add a test that a client + authenticated as project `alpha` cannot publish an + entry whose stored `Author` differs from `alpha`. + Audit client-side callers in `ctx connect publish` + and `ctx add --share` for any that populate + `pe.Author` from local config and remove them (or + document them as ignored). #priority:high + #added:2026-04-11 #pr:60 #audit:H-22 +- [x] **H-22 (meta type + wire + validation)** Schema + update landed on the `feature/ctx-hub-next` branch: + + - `EntryMeta` struct defined in + `internal/hub/types.go` with fields `DisplayName`, + `Host`, `Tool`, `Via` (all optional strings). + - `Entry.Author`, `PublishEntry.Author`, + `EntryMsg.Author` all **removed**. Replaced with + `Meta EntryMeta` on each of the three structs. + - `handler.go publish()` copies `pe.Meta` into + `entries[i].Meta` verbatim. + - `message.go entryToMsg()` copies `e.Meta` into the + wire `EntryMsg.Meta`. + - `sync_helper.go replicateOnce()` copies + `msg.Meta` into the replicated `Entry.Meta`. + - `entry_validate.go` enforces: + `maxMetaFieldLen = 256` per field, + `maxMetaTotalLen = 2048` total, no C0 control + characters (newline, carriage return, NUL, DEL, + bell, etc.) except horizontal tab. + - `internal/hub/entry_validate_test.go` added with + six regression tests: empty accepted, round-trip, + field oversize rejected, total at cap accepted, + each control char rejected (nul/lf/cr/bell/del), + tab allowed. + - JSON wire key is `"meta"` on all three structs. + Pre-existing `entries.jsonl` entries with `author` + fields load cleanly (JSON ignores unknown fields) + and silently lose the hint — acceptable on the + feature branch with no production data. + + Still open as follow-up tasks below (H-22 a through + e). #priority:high #added:2026-04-11 #pr:60 + #audit:H-22 #done:2026-04-11 +- [ ] **H-22a (server-authoritative Origin stamping)** + Implement H-04-style server-enforcement for + `Entry.Origin`: `validateBearer` attaches + `ClientInfo` to the gRPC context; + `handler.go publish()` reads `ClientInfo` and + overwrites `entries[i].Origin` with + `ClientInfo.ProjectName` before `store.Append`. + Client's `pe.Origin` becomes advisory and is + ignored. This is the actual security property + the Author→Meta split was enabling — the + schema change made room for it but the + enforcement still needs to land. Add a test: + client authenticated as `alpha` cannot publish + an entry whose stored Origin is `beta`. + #priority:high #added:2026-04-11 #pr:60 #audit:H-22 +- [ ] **H-22b (renderer labels Meta as advisory)** + Update `internal/cli/connect/core/render/` (and any + other place that writes fanned-out entries to + `.context/hub/*.md`) so `Meta`-sourced values are + labeled as "client label" or "client-reported" in + prose. The word "Origin" is reserved for the + server-authoritative project name. Example output: + + ```markdown + ## [2026-04-11] Use UTC timestamps everywhere + **Origin**: alpha (client label: Alice via ctx@0.8.1) + ``` + + Add a test verifying that a Meta.DisplayName of + `"bob"` does NOT cause the rendered output to show + `Origin: bob`. #priority:high #added:2026-04-11 + #pr:60 #audit:H-22 +- [ ] **H-22c (client publish path supports Meta)** + Update `ctx connect publish` (and `ctx add --share` + if it reaches the hub) to accept `--display-name`, + `--host`, `--tool`, `--via` flags (or a single + `--meta key=val` repeatable flag — implementation + choice). Defaults: `--tool=ctx@`, + `--host=`, `--via=` left empty, + `--display-name=` left empty. Document in + `docs/cli/connect.md`. #priority:medium + #added:2026-04-11 #pr:60 #audit:H-22 +- [ ] **H-22d (docs: `Meta` is advisory)** Add a + prominent note to `docs/cli/connect.md`, + `docs/security/hub.md`, and + `docs/recipes/hub-overview.md` explaining that + `Meta` fields are client-reported hints, not + attribution. Cross-reference the decision record + [2026-04-11-180000]. #added:2026-04-11 #pr:60 + #audit:H-22 +- [ ] **H-22e (audit spec update)** Update + `specs/hub-security-audit.md` H-22 finding to + reflect the landed schema change: the "decide" + phase is done, the "meta type" phase is done, the + remaining work is the Origin stamping (a), the + renderer labels (b), and the client-side plumbing + (c). Also note the six regression tests as "partial + coverage" of the finding. #added:2026-04-11 #pr:60 + #audit:H-22 +- [ ] **H-30** gRPC server hardening: `KeepaliveEnforcementPolicy`, + `KeepaliveParams`, `MaxConcurrentStreams`, total + concurrent connection limit at the listener level. + #priority:medium #added:2026-04-11 #pr:60 #audit:H-30 + +**Medium-term track** (correctness + cluster integrity): + +- [ ] **H-12** Deterministic Raft bootstrap: single + `--bootstrap` node calls `BootstrapCluster`, others + join via `AddVoter`. Persist a `bootstrapped` flag + in the raft data dir to avoid double-bootstrapping + on restart. #priority:medium #added:2026-04-11 #pr:60 + #audit:H-12 +- [ ] **H-13** Follower-side replication validation: + call `validateEntry` on every entry received from + master before appending. Defense-in-depth against a + compromised master (which becomes possible under any + Raft transport compromise — see H-10/H-11). + #priority:medium #added:2026-04-11 #pr:60 #audit:H-13 +- [ ] **H-14** Preserve master sequence on replication: + add `masterSequence` field to Entry, followers + remember master-assigned sequences alongside local + ones. Clients cursor by master sequence so failover + doesn't re-replicate the entire log. #priority:medium + #added:2026-04-11 #pr:60 #audit:H-14 +- [ ] **H-24** `ctx hub redact ` subcommand: mark + the entry in `entries_redacted.jsonl`, broadcast a + redaction notice via Listen, filter on queries, log + to `audits.jsonl`. #priority:medium #added:2026-04-11 + #pr:60 #audit:H-24 +- [ ] **H-29** Bounded in-memory entry cache: LRU over + `entries.jsonl` with a persistent offset index + (`entries.idx`). O(log N) seeks without full-file + reads. Secondary: entries.jsonl rotation at threshold. + #priority:medium #added:2026-04-11 #pr:60 #audit:H-29 + +**Long-term track** (Story 3 enablement): + +- [ ] **H-10 + H-11** Authenticated + encrypted Raft + transport. Replace `raft.NewTCPTransport` with a + TLS-wrapped transport using mTLS between cluster + peers. Peer certs issued from a cluster CA managed + by the sysadmin. Precondition for any non-localhost + multi-node deployment. #priority:critical + #added:2026-04-11 #pr:60 #audit:H-10,H-11 +- [ ] **H-28** Decouple Raft bind port from gRPC port. + Accept a dedicated `--raft-bind` flag; default to a + random high port or refuse to start. Makes port + scanning less productive. #priority:low + #added:2026-04-11 #pr:60 #audit:H-28 +- [ ] Signed-entry mode: publishing clients sign their + entries with a per-client signing key; followers + verify on replication. Eliminates the "trust the + master" assumption even if H-10 fails. Merged with + the PKI stretch task in the Hub identity layer + phase. #added:2026-04-11 #pr:60 #audit:H-13 + +**Low-priority polish** (defense-in-depth): + +- [ ] **H-16** Escape / fence `Content` when the + client-side renderer writes to `.context/hub/*.md`. + Wrap every entry in explicit markers + (``) so malicious + triple-dash patterns can't inject fake frontmatter. + #added:2026-04-11 #pr:60 #audit:H-16 +- [ ] **H-20** Strict constant-time token validation: + iterate all `ClientInfo` entries and OR the results + of `subtle.ConstantTimeCompare` instead of a map + lookup followed by a constant-time compare. Rolled + into the H-03 hashing work. #added:2026-04-11 #pr:60 + #audit:H-20 +- [ ] **H-21** Require exact `Bearer ` prefix in the + `authorization` header; reject otherwise with + `Unauthenticated`. Trivial one-line tightening. + #added:2026-04-11 #pr:60 #audit:H-21 +- [ ] **H-23** Offer passphrase-derived admin token + storage (argon2id) instead of plaintext `admin.token` + on disk. Optional; document in + `docs/operations/hub.md`. #added:2026-04-11 #pr:60 + #audit:H-23 +- [ ] **H-25** Collapse auth error messages to a single + generic `Unauthenticated` reason ("authentication + required"). Log the specific reason server-side + only. #added:2026-04-11 #pr:60 #audit:H-25 + +**Informational (no action needed)**: + +- H-26: daemon re-exec flag — already fixed earlier in + this session as part of the `ctx serve --hub` → `ctx + hub start` split. Recorded in the audit for audit- + trail completeness. +- H-27: mTLS / asymmetric auth discussion — covered by + the PKI stretch task in the Hub identity layer + phase. No separate task needed. + +**Out of scope for this audit** (tracked elsewhere): + +- Supply chain (Go module pinning, CVE monitoring, + reproducible builds) +- Build integrity (signed binaries, transparency log) +- Third-party library CVEs (`hashicorp/raft`, `grpc`, + `raft-boltdb`) +- AI-agent misbehavior (accidental secret publishing + via `--share` — covered by the "secret-leak runbook" + task in the PR #60 follow-up section above) +- Per-project read ACLs (still out of scope even after + the identity layer MVP) + +#### Rename "Shared Context Hub" → "`ctx` Hub" (2026-04-11) + +Brainstorm outcome: "shared" was overloaded (shared memory, +shared journal, shared state) and actively primed the wrong +mental model in docs. `ctx` Hub is the canonical name; `Hub` is +used alone in nav and operator contexts where surrounding text +disambiguates. + +- [x] Rename nav entries: Recipes subsection "Shared Context Hub" + → "Hub"; add `docs/home/hub.md` as a home-level intro; split + Operations section into `Hub` / `Operating ctx` / `Maintainers` + subsections. `zensical.toml` updated. #added:2026-04-11 #pr:60 + #done:2026-04-11 +- [x] Create `docs/home/hub.md` — home-level introduction, names + the two user stories, lists what flows vs what does not, + points readers at recipes/overview for the five-minute + walkthrough. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rewrite `docs/operations/index.md` with three audience-keyed + sections (Hub / Operating ctx / Maintainers). Matches the new + nav structure. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rename doc files: `docs/recipes/shared-hub-*.md` → + `docs/recipes/hub-*.md`, `docs/operations/shared-hub*.md` → + `docs/operations/hub*.md`, `docs/security/shared-hub.md` → + `docs/security/hub.md`. Updated all internal cross-links. + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rename spec files: `specs/shared-context-hub.md` → + `specs/context-hub.md`, `specs/shared-hub-federation.md` → + `specs/hub-federation.md`. Updated prose and cross-refs in + remaining spec files (`hub_implementation.md`, + `task-allocation.md`, `hub-federation.md`). #added:2026-04-11 + #pr:60 #done:2026-04-11 +- [x] Rename Go packages: `internal/cli/agent/core/shared` → + `internal/cli/agent/core/hub`; `internal/cli/serve/core/shared` + → `internal/cli/serve/core/hub`. Resolved the package-name + collision with `internal/hub` by aliasing the inner import to + `hublib` in the two files that need both. Updated audit-test + exempt lists (`magic_strings_test.go`, `magic_values_test.go`) + to match. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rename Go constants and flag definitions: + `cFlag.Shared` → `cFlag.Hub`, `cFlag.IncludeShared` → + `cFlag.IncludeHub`, `DescKeyServeShared` → `DescKeyServeHub`, + `DescKeyAgentIncludeShared` → `DescKeyAgentIncludeHub`. + YAML keys in `flags.yaml` and `commands.yaml` updated to + match. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rename CLI flags: `ctx serve --shared` → `ctx serve --hub`, + `ctx agent --include-shared` → `ctx agent --include-hub`. + `ctx add --share` kept (verb form is still correct). + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rename on-disk directory: `.context/shared/` → + `.context/hub/`. Updated constants (`sharedDir` → `hubDir` in + `agent/core/hub/load.go` and `connect/core/render/render.go`), + path literals in `connect/core/sync/state.go`, and all test + fixtures in `connect/core/render/render_test.go`. + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Rename `packet.Shared` / `AssembledPacket.Shared` struct + field → `Hub`, with matching json tag. Updated + `assemble.go`, `out.go`, `render.go`, `types.go` in + `internal/cli/agent/core/budget`. Tier 8 comment updated. + #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Fix a bug surfaced by the rename: `internal/cli/serve/core/hub/daemon.go` + was spawning child processes with the stale flag + `ctx serve --shared` — now correctly passes `--hub`. Without + this fix, `ctx serve --hub --daemon` would have failed silently + on the re-exec. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Fix stuttery function name flagged by audit: + `hub.hubDir()` → `hub.defaultDataDir()` in + `internal/cli/serve/core/hub/setup.go`. #added:2026-04-11 + #pr:60 #done:2026-04-11 +- [x] Prose sweep across all hub docs: "Shared Context Hub" → + "`ctx` Hub", "shared hub" → "hub", `--shared` → `--hub`, + `.context/shared/` → `.context/hub/`. Covered + `docs/home/`, `docs/recipes/`, `docs/operations/`, + `docs/security/`, `docs/cli/`. #added:2026-04-11 #pr:60 + #done:2026-04-11 +- [x] Verify all nav targets exist after rename. All sixteen + hub-related paths referenced in `zensical.toml` resolve to + real files. #added:2026-04-11 #pr:60 #done:2026-04-11 +- [x] Full QA gate: `go build ./...` (Linux), + `GOOS=windows go build ./...`, `make lint` (0 issues), + `make test` (0 failures including the audit exempt-list + update and the `gofmt` round-trip on `serve/cmd/root/cmd.go`). + #added:2026-04-11 #pr:60 #done:2026-04-11 + +### Later + +- [ ] Optional follow-up doc.go pass: a handful of tiny per-subcommand wrappers + under internal/cli/*/cmd/* still have ~5-line bodies. Most are + accurate-but-brief; expand only if the brief form proves insufficient in + review. #session:4b37e2f6 #branch:feat/copilot-cli-skill-parity-rebased + #commit:edaac81786c9379333b352dae0d55df0ae0f72bb #added:2026-04-14-010311 + +- [ ] Extend internal/audit/stuttery_functions_test.go to cover *ast.GenDecl + (consts, vars, types). Current implementation walks *ast.FuncDecl only and + missed tpl.TplEntryMarkdown (since renamed to HubEntryMarkdown). + #session:4b37e2f6 #branch:feat/copilot-cli-skill-parity-rebased + #commit:edaac81786c9379333b352dae0d55df0ae0f72bb #added:2026-04-14-010311 + +- [ ] Decide whether to delete docs/cli/connect.md — verified dead duplicate + of docs/cli/connection.md (uses old ctx connect command name; zero inbound + references; not in zensical.toml). Awaiting explicit user OK before git rm. + #session:4b37e2f6 #branch:feat/copilot-cli-skill-parity-rebased + #commit:edaac81786c9379333b352dae0d55df0ae0f72bb #added:2026-04-14-010311 + +- [-] PROMPT.md design — belongs in another project; skipped here. + #session:4b37e2f6 #added:2026-04-14-010311 #skipped:2026-04-14 ### Phase CP: Ceremony Profiles `#priority:medium #added:2026-04-26` @@ -44,5 +2148,3 @@ Spec: `specs/ceremony-profiles.md` - [ ] Show active ceremony profile (one line) in `ctx status` output - [ ] Tests: default profile renders `/ctx-remember` `/ctx-wrap-up`; project with `ceremony.remember: dp-remember` renders `/dp-remember` and scanner only counts `dp-remember` as fulfilling the open-bookend - [ ] Document in `docs/recipes/` with the editorial-project (DR knowledgebase) consumer as the worked example - -## Blocked diff --git a/README.md b/README.md index a25cd601b..6b510e38b 100644 --- a/README.md +++ b/README.md @@ -111,12 +111,12 @@ ctx status ctx agent --budget 4000 # Add tasks, decisions, learnings -ctx add task "Implement user authentication" -ctx add decision "Use PostgreSQL for primary database" \ +ctx task add "Implement user authentication" +ctx decision add "Use PostgreSQL for primary database" \ --context "Need a reliable database for production workloads" \ --rationale "PostgreSQL offers ACID compliance, JSON support, and team familiarity" \ --consequence "Team needs PostgreSQL training; must set up replication" -ctx add learning "Mock functions must be hoisted in Jest" +ctx learning add "Mock functions must be hoisted in Jest" ``` `ctx activate` emits `export CTX_DIR=...` for your shell; one-shot diff --git a/SECURITY.md b/SECURITY.md index bc396331c..92184c307 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -77,7 +77,7 @@ the current user can be supplied. This is by design: `ctx` runs as the local user and does not elevate privileges. In an AI-agent context, be aware that a confused or prompt-injected agent -could be instructed to run `ctx add task --file /etc/shadow`, which would +could be instructed to run `ctx task add --file /etc/shadow`, which would copy that file's contents into `.context/TASKS.md`. Hooks and constitution rules are the appropriate mitigation layer here. diff --git a/docs/cli/connect.md b/docs/cli/connect.md index 053c2a7dd..30bf7dd73 100644 --- a/docs/cli/connect.md +++ b/docs/cli/connect.md @@ -99,7 +99,7 @@ ctx connect status Use `--share` on `ctx add` to write locally AND publish to the hub: ```bash -ctx add decision "Use UTC" --share \ +ctx decision add "Use UTC" --share \ --context "Need consistency" \ --rationale "Avoid timezone bugs" \ --consequence "UI does conversion" diff --git a/docs/cli/connection.md b/docs/cli/connection.md index e4928b95d..c56a8e6eb 100644 --- a/docs/cli/connection.md +++ b/docs/cli/connection.md @@ -112,7 +112,7 @@ ctx connection status Use `--share` on `ctx add` to write locally AND publish to the ctx Hub: ```bash -ctx add decision "Use UTC" --share \ +ctx decision add "Use UTC" --share \ --context "Need consistency" \ --rationale "Avoid timezone bugs" \ --consequence "UI does conversion" diff --git a/docs/cli/context.md b/docs/cli/context.md index 0288858e2..9a43eff50 100644 --- a/docs/cli/context.md +++ b/docs/cli/context.md @@ -11,24 +11,30 @@ icon: lucide/layers ![ctx](../images/ctx-banner.png) -### `ctx add` +### Adding entries -Add a new item to a context file. +Each context-artifact noun (`task`, `decision`, `learning`, +`convention`) owns its own `add` subcommand under the +noun-first command tree: ```bash -ctx add [flags] +ctx task add [flags] +ctx decision add [flags] +ctx learning add [flags] +ctx convention add [flags] ``` -**Types**: +**Target files**: -| Type | Target File | -|--------------|------------------| -| `task` | `TASKS.md` | -| `decision` | `DECISIONS.md` | -| `learning` | `LEARNINGS.md` | -| `convention` | `CONVENTIONS.md` | +| Subcommand | Target File | +|-------------------------|------------------| +| `ctx task add` | `TASKS.md` | +| `ctx decision add` | `DECISIONS.md` | +| `ctx learning add` | `LEARNINGS.md` | +| `ctx convention add` | `CONVENTIONS.md` | -**Flags**: +**Flags** (shared by every `add` subcommand; per-noun +required-flag rules surface as command errors): | Flag | Short | Description | |---------------------------|-------|-------------------------------------------------------------| @@ -45,27 +51,27 @@ ctx add [flags] ```bash # Add a task -ctx add task "Implement user authentication" \ +ctx task add "Implement user authentication" \ --session-id abc12345 --branch main --commit 68fbc00a -ctx add task "Fix login bug" --priority high \ +ctx task add "Fix login bug" --priority high \ --session-id abc12345 --branch main --commit 68fbc00a # Record a decision (requires all ADR (Architectural Decision Record) fields) -ctx add decision "Use PostgreSQL for primary database" \ +ctx decision add "Use PostgreSQL for primary database" \ --context "Need a reliable database for production" \ --rationale "PostgreSQL offers ACID compliance and JSON support" \ --consequence "Team needs PostgreSQL training" \ --session-id abc12345 --branch main --commit 68fbc00a # Note a learning (requires context, lesson, and application) -ctx add learning "Vitest mocks must be hoisted" \ +ctx learning add "Vitest mocks must be hoisted" \ --context "Tests failed with undefined mock errors" \ --lesson "Vitest hoists vi.mock() calls to top of file" \ --application "Always place vi.mock() before imports in test files" \ --session-id abc12345 --branch main --commit 68fbc00a # Add to specific section -ctx add convention "Use kebab-case for filenames" --section "Naming" +ctx convention add "Use kebab-case for filenames" --section "Naming" ``` --- diff --git a/docs/cli/index.md b/docs/cli/index.md index 52795f18b..24b820ea7 100644 --- a/docs/cli/index.md +++ b/docs/cli/index.md @@ -70,16 +70,16 @@ have been initialized by `ctx init` (otherwise commands return | Command | Description | |-----------------------------------------------|----------------------------------------------------------| -| [`ctx add`](context.md#ctx-add) | Add a task, decision, learning, or convention | | [`ctx load`](context.md#ctx-load) | Output assembled context in read order | | [`ctx agent`](context.md#ctx-agent) | Print token-budgeted context packet for AI consumption | | [`ctx sync`](context.md#ctx-sync) | Reconcile context with codebase state | | [`ctx drift`](context.md#ctx-drift) | Detect stale paths, secrets, missing files | | [`ctx compact`](context.md#ctx-compact) | Archive completed tasks, clean up files | | [`ctx fmt`](context.md#ctx-fmt) | Format context files to 80-char line width | -| [`ctx decision`](context.md#ctx-decision) | Manage `DECISIONS.md` (reindex) | -| [`ctx learning`](context.md#ctx-learning) | Manage `LEARNINGS.md` (reindex) | -| [`ctx task`](context.md#ctx-task) | Task completion, archival, and snapshots | +| [`ctx task`](context.md#ctx-task) | Add tasks, mark complete, archive, snapshot | +| [`ctx decision`](context.md#ctx-decision) | Add decisions and reindex `DECISIONS.md` | +| [`ctx learning`](context.md#ctx-learning) | Add learnings and reindex `LEARNINGS.md` | +| [`ctx convention`](context.md#ctx-convention) | Add conventions to `CONVENTIONS.md` | | [`ctx reindex`](context.md#ctx-reindex) | Regenerate indices for `DECISIONS.md` and `LEARNINGS.md` | | [`ctx permission`](context.md#ctx-permission) | Permission snapshots (golden image) | | [`ctx change`](change.md#ctx-change) | Show what changed since last session | diff --git a/docs/cli/init-status.md b/docs/cli/init-status.md index 4b93a4ae5..8a19c7533 100644 --- a/docs/cli/init-status.md +++ b/docs/cli/init-status.md @@ -46,7 +46,7 @@ ctx init ctx init --minimal # Force overwrite existing -ctx init --force +ctx init --reset # Merge into existing files ctx init --merge diff --git a/docs/home/common-workflows.md b/docs/home/common-workflows.md index ed0c46bfb..d436ab554 100644 --- a/docs/home/common-workflows.md +++ b/docs/home/common-workflows.md @@ -32,18 +32,18 @@ For deeper, step-by-step guides, see [Recipes](../recipes/index.md). ```bash # Add a task -ctx add task "Implement user authentication" \ +ctx task add "Implement user authentication" \ --session-id abc12345 --branch main --commit 68fbc00a # Record a decision (full ADR fields required) -ctx add decision "Use PostgreSQL for primary database" \ +ctx decision add "Use PostgreSQL for primary database" \ --context "Need a reliable database for production" \ --rationale "PostgreSQL offers ACID compliance and JSON support" \ --consequence "Team needs PostgreSQL training" \ --session-id abc12345 --branch main --commit 68fbc00a # Note a learning -ctx add learning "Mock functions must be hoisted in Jest" \ +ctx learning add "Mock functions must be hoisted in Jest" \ --context "Tests failed with undefined mock errors" \ --lesson "Jest hoists mock calls to top of file" \ --application "Place jest.mock() before imports" \ @@ -326,10 +326,10 @@ agent's judgment. |----------------------|-----------------------|------------------------------------------------------------| | `ctx drift` | `/ctx-drift` | Semantic analysis: catches meaning drift the CLI misses | | `ctx status` | `/ctx-status` | Interpreted summary with recommendations | -| `ctx add task` | `/ctx-task-add` | Agent decomposes vague goals into concrete tasks | -| `ctx add decision` | `/ctx-decision-add` | Agent drafts rationale and consequences from discussion | -| `ctx add learning` | `/ctx-learning-add` | Agent extracts the lesson from a debugging session | -| `ctx add convention` | `/ctx-convention-add` | Agent observes a repeated pattern and codifies it | +| `ctx task add` | `/ctx-task-add` | Agent decomposes vague goals into concrete tasks | +| `ctx decision add` | `/ctx-decision-add` | Agent drafts rationale and consequences from discussion | +| `ctx learning add` | `/ctx-learning-add` | Agent extracts the lesson from a debugging session | +| `ctx convention add` | `/ctx-convention-add` | Agent observes a repeated pattern and codifies it | | `ctx task archive` | `/ctx-archive` | Agent reviews which tasks are truly done | | `ctx pad` | `/ctx-pad` | Agent reads/writes scratchpad entries in conversation flow | | `ctx journal` | `/ctx-history` | Agent searches session history with semantic understanding | diff --git a/docs/home/context-files.md b/docs/home/context-files.md index d9fc14609..90abd4b94 100644 --- a/docs/home/context-files.md +++ b/docs/home/context-files.md @@ -37,8 +37,8 @@ context packet: Two subdirectories under `.context/` are **implementation details** that are user-editable but not part of the priority read order: -- **`.context/templates/`**: format templates for `ctx add decision` - and `ctx add learning`. See [templates](#templates) below. +- **`.context/templates/`**: format templates for `ctx decision add` + and `ctx learning add`. See [templates](#templates) below. - **`.context/steering/`**: behavioral rules with YAML frontmatter that get synced into each AI tool's native config. See [steering](#steering) below, and the full @@ -184,7 +184,7 @@ Use inline backtick-wrapped tags for metadata: | Tag | Format | When to add | |------------|----------------------|------------------------------------| -| `#added` | `YYYY-MM-DD-HHMMSS` | Auto-added by `ctx add task` | +| `#added` | `YYYY-MM-DD-HHMMSS` | Auto-added by `ctx task add` | | `#started` | `YYYY-MM-DD-HHMMSS` | When beginning work on the task | These timestamps help correlate tasks with session files and track which @@ -481,7 +481,7 @@ for full documentation. **Location**: `.context/templates/`. **Status**: implementation detail, user-editable. -**Purpose**: Format templates for `ctx add decision` and `ctx add learning`. +**Purpose**: Format templates for `ctx decision add` and `ctx learning add`. These control the structure of new entries appended to DECISIONS.md and LEARNINGS.md. diff --git a/docs/home/first-session.md b/docs/home/first-session.md index f84b2c19b..4420aebd0 100644 --- a/docs/home/first-session.md +++ b/docs/home/first-session.md @@ -74,12 +74,12 @@ options (multiple `.context/` directories, scripts, CI), see Add a **task** and a **decision**: These are the entries your AI will remember: ```bash -ctx add task "Implement user authentication" \ +ctx task add "Implement user authentication" \ --session-id abc12345 --branch main --commit 68fbc00a # Output: ✓ Added to TASKS.md -ctx add decision "Use PostgreSQL for primary database" \ +ctx decision add "Use PostgreSQL for primary database" \ --context "Need a reliable database for production" \ --rationale "PostgreSQL offers ACID compliance and JSON support" \ --consequence "Team needs PostgreSQL training" \ diff --git a/docs/home/is-ctx-right.md b/docs/home/is-ctx-right.md index c6fae66c5..304db285f 100644 --- a/docs/home/is-ctx-right.md +++ b/docs/home/is-ctx-right.md @@ -117,7 +117,7 @@ ctx init eval "$(ctx activate)" # 3. Add one real decision from your project -ctx add decision "Your actual architectural choice" \ +ctx decision add "Your actual architectural choice" \ --context "What prompted this decision" \ --rationale "Why you chose this approach" \ --consequence "What changes as a result" \ diff --git a/docs/home/joining-a-project.md b/docs/home/joining-a-project.md index 16b9c7825..a51acb443 100644 --- a/docs/home/joining-a-project.md +++ b/docs/home/joining-a-project.md @@ -94,18 +94,18 @@ As you work, you'll discover things worth recording. Use the CLI: ```bash # Record a decision you made or learned about -ctx add decision "Use connection pooling for DB access" \ +ctx decision add "Use connection pooling for DB access" \ --rationale "Reduces connection overhead under load" \ --session-id abc12345 --branch main --commit 68fbc00a # Capture a gotcha you hit -ctx add learning "Redis timeout defaults to 5s" \ +ctx learning add "Redis timeout defaults to 5s" \ --context "Hit timeouts during bulk operations" \ --application "Set explicit timeout for batch jobs" \ --session-id abc12345 --branch main --commit 68fbc00a # Add a convention you noticed the team follows -ctx add convention "All API handlers return structured errors" +ctx convention add "All API handlers return structured errors" ``` You can also just tell the AI: "Record this as a learning" or diff --git a/docs/home/repeated-mistakes.md b/docs/home/repeated-mistakes.md index d4fbcb6dc..6632bdd8a 100644 --- a/docs/home/repeated-mistakes.md +++ b/docs/home/repeated-mistakes.md @@ -116,12 +116,12 @@ team changes, and model upgrades. The context outlives any single session. Capture your first decision or learning right now: ```bash -ctx add decision "Use PostgreSQL" \ +ctx decision add "Use PostgreSQL" \ --context "Need a relational database for the project" \ --rationale "Team expertise, JSONB support, mature ecosystem" \ --session-id abc12345 --branch main --commit 68fbc00a -ctx add learning "Vitest mock hoisting" \ +ctx learning add "Vitest mock hoisting" \ --context "Tests failing intermittently" \ --lesson "vi.mock() must be at file top level" \ --application "Use vi.doMock() for dynamic mocks" \ diff --git a/docs/operations/autonomous-loop.md b/docs/operations/autonomous-loop.md index 2e7c62bd5..1afc269c2 100644 --- a/docs/operations/autonomous-loop.md +++ b/docs/operations/autonomous-loop.md @@ -268,7 +268,7 @@ Or emit an update command (parsed by `ctx watch`): **Add learning:** ```bash -ctx add learning "Rate limiting requires Redis connection" \ +ctx learning add "Rate limiting requires Redis connection" \ --session-id abc12345 --branch main --commit 68fbc00a ``` @@ -283,7 +283,7 @@ Or via update command: **Record decision:** ```bash -ctx add decision "Use JWT tokens for API authentication" \ +ctx decision add "Use JWT tokens for API authentication" \ --session-id abc12345 --branch main --commit 68fbc00a ``` @@ -384,7 +384,7 @@ End EVERY response with one of: ```markdown After completing a task, you MUST: 1. Run: ctx task complete "" -2. Add learnings: ctx add learning "..." --session-id abc12345 --branch main --commit 68fbc00a +2. Add learnings: ctx learning add "..." --session-id abc12345 --branch main --commit 68fbc00a ``` ### Tasks Getting Repeated diff --git a/docs/operations/migration.md b/docs/operations/migration.md index 51fcd0a07..c71a4fe14 100644 --- a/docs/operations/migration.md +++ b/docs/operations/migration.md @@ -31,7 +31,7 @@ which tools your team uses. |--------------------------------------|---------------------------------------------------|------------------------------------------------------| | Nothing (*greenfield*) | `ctx init` | Creates `.context/`, `CLAUDE.md`, permissions | | Existing `CLAUDE.md` | `ctx init --merge` | Backs up your file, inserts `ctx` block after the H1 | -| Existing `CLAUDE.md` + `ctx` markers | `ctx init --force` | Replaces the `ctx` block, leaves your content intact | +| Existing `CLAUDE.md` + `ctx` markers | `ctx init --reset` | Replaces the `ctx` block, leaves your content intact | | `.cursorrules` / `.aider.conf.yml` | `ctx init` | `ctx` ignores those files: they coexist cleanly | | Team repo, first adopter | `ctx init --merge && git add .context/ CLAUDE.md` | Initialize and commit for the team | @@ -135,7 +135,7 @@ default behavior is to skip it. Use `--force` to replace the `ctx` block with th latest template: This is useful after **upgrading** `ctx`: ```bash -ctx init --force +ctx init --reset ``` This only replaces content between `` and ``. diff --git a/docs/operations/runbooks/breaking-migration.md b/docs/operations/runbooks/breaking-migration.md index 96bf83caf..59fcb3aa0 100644 --- a/docs/operations/runbooks/breaking-migration.md +++ b/docs/operations/runbooks/breaking-migration.md @@ -48,7 +48,7 @@ Or use the `/_ctx-command-audit` skill after the rename. make build && sudo make install # Regenerate CLAUDE.md and permissions -ctx init --force --merge +ctx init --reset --merge ``` `--merge` preserves your knowledge files (TASKS.md, DECISIONS.md, @@ -118,7 +118,7 @@ in the release notes using this template: The old name is removed (no deprecation alias). **Action required**: -1. Run `ctx init --force --merge` to update CLAUDE.md +1. Run `ctx init --reset --merge` to update CLAUDE.md 2. Update any scripts referencing `ctx old-command` 3. Update hook configs if applicable diff --git a/docs/operations/runbooks/hub-deployment.md b/docs/operations/runbooks/hub-deployment.md index 4b2924699..49776c59b 100644 --- a/docs/operations/runbooks/hub-deployment.md +++ b/docs/operations/runbooks/hub-deployment.md @@ -109,7 +109,7 @@ otherwise `ctx add` and `ctx status` fail with ```bash # Client A (in its project directory, after activating): -ctx add learning "Hub sync test" --context "Verifying hub setup" +ctx learning add "Hub sync test" --context "Verifying hub setup" # Client B (in its project directory, after activating): ctx status # should show the new learning diff --git a/docs/operations/runbooks/sanitize-permissions.md b/docs/operations/runbooks/sanitize-permissions.md index 46867201a..21c7bf1d9 100644 --- a/docs/operations/runbooks/sanitize-permissions.md +++ b/docs/operations/runbooks/sanitize-permissions.md @@ -62,7 +62,7 @@ that were accepted during a specific debugging session: ``` Bash(git -C /home/jose/WORKSPACE/ctx log --oneline --all -20) -Bash(/home/jose/WORKSPACE/ctx/ctx add decision "Use PostgreSQL" --context ...) +Bash(/home/jose/WORKSPACE/ctx/ctx decision add "Use PostgreSQL" --context ...) ``` Signs of a one-off: diff --git a/docs/operations/upgrading.md b/docs/operations/upgrading.md index 8a9602eb7..b5ebfed49 100644 --- a/docs/operations/upgrading.md +++ b/docs/operations/upgrading.md @@ -22,7 +22,7 @@ or plugin hooks and skills. The `ctx` **binary** is separate: [rebuild from source or download a new release](../home/getting-started.md#installation) - when one is available, then run `ctx init --force --merge`. + when one is available, then run `ctx init --reset --merge`. Knowledge files are preserved automatically. ## TL:DR @@ -31,11 +31,11 @@ or plugin hooks and skills. # Plugin users (Claude Code) # /plugin → select ctx → Update now # Then update the binary and reinitialize: -ctx init --force --merge +ctx init --reset --merge # From-source / manual users # install new ctx binary, then: -ctx init --force --merge +ctx init --reset --merge # /plugin → select ctx → Update now (if using Claude Code) ``` @@ -68,7 +68,7 @@ ctx --version # verify ### 2. Reinitialize ```bash -ctx init --force --merge +ctx init --reset --merge ``` * `--force` regenerates infrastructure files (permissions, ctx-managed diff --git a/docs/recipes/external-context.md b/docs/recipes/external-context.md index 9a5bf7f23..d052b03ef 100644 --- a/docs/recipes/external-context.md +++ b/docs/recipes/external-context.md @@ -272,7 +272,7 @@ Your AI assistant can do this too. When ending a session: ```text You: "Save what we learned and push the context repo." -Agent: [runs ctx add learning, then commits and pushes the context repo] +Agent: [runs ctx learning add, then commits and pushes the context repo] ``` You can also set up a post-session habit: project code gets committed to the diff --git a/docs/recipes/guide-your-agent.md b/docs/recipes/guide-your-agent.md index 3a75ae5fa..2d2c44e93 100644 --- a/docs/recipes/guide-your-agent.md +++ b/docs/recipes/guide-your-agent.md @@ -6,7 +6,7 @@ icon: lucide/sparkles ![ctx](../images/ctx-banner.png) !!! tip "Commands vs. Skills" - **Commands** (`ctx status`, `ctx add task`) run in your + **Commands** (`ctx status`, `ctx task add`) run in your terminal. **Skills** (`/ctx-reflect`, `/ctx-next`) run inside diff --git a/docs/recipes/hub-getting-started.md b/docs/recipes/hub-getting-started.md index 16efbd931..d695f5883 100644 --- a/docs/recipes/hub-getting-started.md +++ b/docs/recipes/hub-getting-started.md @@ -108,7 +108,7 @@ and `listen`. Either use `ctx add --share` to write locally *and* push to the ctx Hub: ```bash -ctx add decision "Use UTC timestamps everywhere" --share \ +ctx decision add "Use UTC timestamps everywhere" --share \ --context "We had timezone drift between the API and journal" \ --rationale "Single source of truth avoids conversion bugs" \ --consequence "The UI does conversion at render time" diff --git a/docs/recipes/hub-overview.md b/docs/recipes/hub-overview.md index cbc93e4ef..2688571d6 100644 --- a/docs/recipes/hub-overview.md +++ b/docs/recipes/hub-overview.md @@ -86,7 +86,7 @@ codified in one project to be visible as-you-type in another. **Concrete payoff:** -- `ctx add learning --share "..."` in project A → +- `ctx learning add --share "..."` in project A → `ctx agent --include-hub` in project B shows that learning in the next context packet. - A decision recorded in your personal "dotfiles" project is diff --git a/docs/recipes/hub-personal.md b/docs/recipes/hub-personal.md index 7346bbef5..ed8e8e28e 100644 --- a/docs/recipes/hub-personal.md +++ b/docs/recipes/hub-personal.md @@ -92,7 +92,7 @@ out. This is the kind of thing you'd normally add to Go service you'll ever write, not just this one. So: ```bash -ctx add learning --share \ +ctx learning add --share \ --context "Go http.Client retries mask the final error" \ --lesson "Transport timeouts don't surface as errors when the retry loop re-assigns err without wrapping. Check for context.DeadlineExceeded on the request context instead." \ --application "Any retry loop over http.Client.Do that uses a per-attempt timeout" @@ -101,7 +101,7 @@ ctx add learning --share \ The `--share` flag does two things: 1. Writes the learning to `api/.context/LEARNINGS.md` - locally (as a normal `ctx add learning` would). + locally (as a normal `ctx learning add` would). 2. Publishes the same entry to the ctx Hub, which stores it in the append-only JSONL and fans it out to every subscribed client. @@ -133,7 +133,7 @@ touch. Record it in `dotfiles` (since that's your ```bash cd ~/projects/dotfiles -ctx add convention --share \ +ctx convention add --share \ "Error messages: lowercase start, no trailing period, single sentence (follows Go's stdlib style)" ``` @@ -158,11 +158,11 @@ Stripped of prose, the day's commands were: # Morning: nothing. Agent loads --include-hub automatically. # Mid-morning: record a learning that should cross projects -ctx add learning --share \ +ctx learning add --share \ --context "..." --lesson "..." --application "..." # Afternoon: codify a convention in the "standards" project -ctx add convention --share "..." +ctx convention add --share "..." # Evening: nothing. Everything's already propagated. ``` diff --git a/docs/recipes/hub-team.md b/docs/recipes/hub-team.md index 3c75ab8d0..9785a0b17 100644 --- a/docs/recipes/hub-team.md +++ b/docs/recipes/hub-team.md @@ -140,7 +140,7 @@ concurrency. Postmortem on Tuesday, but right now she records the learning: ```bash -ctx add learning --share \ +ctx learning add --share \ --context "Payment service 3 AM incident, 2026-04-03" \ --lesson "grpc-go v1.62+ changes DialContext behavior under high \ concurrency: connections from a single channel can deadlock if the \ @@ -163,7 +163,7 @@ header-based instead of URL-based. Platform lead Carol records the decision: ```bash -ctx add decision --share \ +ctx decision add --share \ --context "Need consistent API versioning across all 6 services. \ Current URL-based /v1/ isn't working for gradual rollouts." \ --rationale "Header-based versioning lets us route by header at the \ diff --git a/docs/recipes/index.md b/docs/recipes/index.md index 791318b95..5b043a426 100644 --- a/docs/recipes/index.md +++ b/docs/recipes/index.md @@ -128,8 +128,8 @@ Record **architectural decisions** with **rationale**, capture **gotchas** and lessons learned, and **codify** conventions so they survive across sessions and team members. -**Uses**: `ctx add decision`, `ctx add learning`, -`ctx add convention`, `ctx decision reindex`, +**Uses**: `ctx decision add`, `ctx learning add`, +`ctx convention add`, `ctx decision reindex`, `ctx learning reindex`, `/ctx-decision-add`, `/ctx-learning-add`, `/ctx-convention-add`, `/ctx-reflect` @@ -141,7 +141,7 @@ survive across sessions and team members. `TASKS.md` focused as your project evolves across dozens of sessions. -**Uses**: `ctx add task`, `ctx task complete`, `ctx task archive`, +**Uses**: `ctx task add`, `ctx task complete`, `ctx task archive`, `ctx task snapshot`, `/ctx-task-add`, `/ctx-archive`, `/ctx-next` --- diff --git a/docs/recipes/knowledge-capture.md b/docs/recipes/knowledge-capture.md index 812d0702a..e12a2b05e 100644 --- a/docs/recipes/knowledge-capture.md +++ b/docs/recipes/knowledge-capture.md @@ -45,9 +45,9 @@ Or just tell your agent: *"What have we learned this session?"* | Tool | Type | Purpose | |------------------------|---------|-----------------------------------------------| -| `ctx add decision` | Command | Record an architectural decision | -| `ctx add learning` | Command | Record a gotcha, tip, or lesson | -| `ctx add convention` | Command | Record a coding pattern or standard | +| `ctx decision add` | Command | Record an architectural decision | +| `ctx learning add` | Command | Record a gotcha, tip, or lesson | +| `ctx convention add` | Command | Record a coding pattern or standard | | `ctx reindex` | Command | Rebuild both quick-reference indices | | `ctx decision reindex` | Command | Rebuild the DECISIONS.md index | | `ctx learning reindex` | Command | Rebuild the LEARNINGS.md index | @@ -122,7 +122,7 @@ and against [alternatives], to achieve [benefit], accepting that [trade-off].*" use the CLI directly with structured flags: ```bash - ctx add decision "Use file-based cooldown tokens instead of env vars" \ + ctx decision add "Use file-based cooldown tokens instead of env vars" \ --context "Hook subprocesses cannot persist env vars to parent shell" \ --rationale "File tokens survive across processes. Simpler than IPC. Cleanup is automatic via TTL." \ --consequence "Tombstone files accumulate in /tmp. Cannot share state across machines." \ @@ -170,7 +170,7 @@ The `/ctx-learning-add` skill applies three quality filters: When no agent is in the loop: ```bash - ctx add learning "Claude Code hooks run in a subprocess" \ + ctx learning add "Claude Code hooks run in a subprocess" \ --context "Set env var in PreToolUse hook, but it was not visible in the main session" \ --lesson "Hook scripts execute in a child process. Env changes do not propagate to parent." \ --application "Use tombstone files for hook-to-session communication. Never rely on hook env vars." \ @@ -193,7 +193,7 @@ Agent: "Added to CONVENTIONS.md under Naming: Or from the terminal: ```bash -ctx add convention "Use kebab-case for all CLI flag names" --section "Naming" +ctx convention add "Use kebab-case for all CLI flag names" --section "Naming" ``` Conventions work best for rules that come up repeatedly. Codify a pattern the @@ -247,9 +247,9 @@ discovered that hook subprocesses cannot set env vars in the parent. I'd suggest persisting: - **Learning**: Hook subprocesses cannot propagate env vars - `ctx add learning "..." --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a` + `ctx learning add "..." --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a` - **Decision**: File-based cooldown tokens over env vars - `ctx add decision "..." --context "..." --rationale "..." --consequence "..." --session-id abc12345 --branch main --commit 68fbc00a` + `ctx decision add "..." --context "..." --rationale "..." --consequence "..." --session-id abc12345 --branch main --commit 68fbc00a` Want me to persist any of these? ``` @@ -319,21 +319,21 @@ rather than waiting for explicit instructions. ```bash # Decision: record the trade-off -ctx add decision "Use PostgreSQL over SQLite" \ +ctx decision add "Use PostgreSQL over SQLite" \ --context "Need concurrent multi-user access" \ --rationale "SQLite locks on writes; Postgres handles concurrency" \ --consequence "Requires a database server; team needs Postgres training" \ --session-id abc12345 --branch main --commit 68fbc00a # Learning: record the gotcha -ctx add learning "SQL migrations must be idempotent" \ +ctx learning add "SQL migrations must be idempotent" \ --context "Deploy failed when migration ran twice after rollback" \ --lesson "CREATE TABLE without IF NOT EXISTS fails on retry" \ --application "Always use IF NOT EXISTS guards in migrations" \ --session-id abc12345 --branch main --commit 68fbc00a # Convention: record the pattern -ctx add convention "API handlers return structured errors" --section "API" +ctx convention add "API handlers return structured errors" --section "API" # Reindex after manual edits ctx reindex diff --git a/docs/recipes/session-lifecycle.md b/docs/recipes/session-lifecycle.md index 3c258674b..a16320240 100644 --- a/docs/recipes/session-lifecycle.md +++ b/docs/recipes/session-lifecycle.md @@ -235,8 +235,8 @@ After the commit succeeds, it prompts you: - **Neither**: No context to capture; we are done. ``` -If you made a decision, the skill records it with `ctx add decision`. If you -learned something, it records it with `ctx add learning` including context, +If you made a decision, the skill records it with `ctx decision add`. If you +learned something, it records it with `ctx learning add` including context, lesson, and application fields. This is the bridge between committing code and remembering why the code looks the way it does. @@ -278,10 +278,10 @@ to run: I would suggest persisting: - **Learning**: `$PPID` in PreToolUse hooks resolves to the Claude Code PID - `ctx add learning --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a` + `ctx learning add --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a` - **Task**: mark "Add cooldown to ctx agent" as done - **Decision**: tombstone-based cooldown with 10m default - `ctx add decision "..." --session-id abc12345 --branch main --commit 68fbc00a` + `ctx decision add "..." --session-id abc12345 --branch main --commit 68fbc00a` Want me to persist any of these? ``` @@ -415,7 +415,7 @@ Context is up to date. You are good to close. !!! tip "Notice What Happened" In the above workflow, the user never typed `/ctx-reflect` or - `ctx add learning`. + `ctx learning add`. The agent moved through **Load**, **Orient**, **Pick**, **Work**, **Commit**, and **Reflect** driven by **natural conversation**. diff --git a/docs/recipes/steering.md b/docs/recipes/steering.md index 0c1a1ccbc..8165a7789 100644 --- a/docs/recipes/steering.md +++ b/docs/recipes/steering.md @@ -353,7 +353,7 @@ narrow the descriptions so they don't overlap. **Putting decisions in steering.** "We decided to use PostgreSQL" is a decision, not a rule for the AI to follow on -every prompt. Record decisions with `ctx add decision`, not +every prompt. Record decisions with `ctx decision add`, not `ctx steering add`. **Committing `inclusion: always` without thinking.** Rules diff --git a/docs/recipes/task-management.md b/docs/recipes/task-management.md index b28e595f6..a6b52cd2c 100644 --- a/docs/recipes/task-management.md +++ b/docs/recipes/task-management.md @@ -18,12 +18,12 @@ How do you manage work items that span multiple sessions without losing context? !!! tip "Prefer Skills over Raw Commands" When working with an AI agent, use `/ctx-task-add` instead of raw - `ctx add task`. The agent automatically picks up session ID, branch, + `ctx task add`. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed. !!! warning "Activate the Project First" Run `eval "$(ctx activate)"` once per terminal in the project - root. If you skip it, the `ctx add task` / `ctx task ...` + root. If you skip it, the `ctx task add` / `ctx task ...` commands below fail with `Error: no context directory specified`. See [Activating a Context Directory](activating-context.md). @@ -33,9 +33,9 @@ How do you manage work items that span multiple sessions without losing context? **Manage Tasks**: ```bash -ctx add task "Fix race condition" --priority high \ +ctx task add "Fix race condition" --priority high \ --session-id abc12345 --branch main --commit 68fbc00a # add -ctx add task "Write tests" --section "Phase 2" \ +ctx task add "Write tests" --section "Phase 2" \ --session-id abc12345 --branch main --commit 68fbc00a # add to phase ctx task complete "race condition" # mark done ctx task snapshot "before-refactor" # backup @@ -54,7 +54,7 @@ Read on for the full workflow and conversational patterns. | Tool | Type | Purpose | |---------------------|---------|---------------------------------------------| -| `ctx add task` | Command | Add a new task to `TASKS.md` | +| `ctx task add` | Command | Add a new task to `TASKS.md` | | `ctx task complete` | Command | Mark a task as done by number or text | | `ctx task snapshot` | Command | Create a point-in-time backup of `TASKS.md` | | `ctx task archive` | Command | Move completed tasks to archive file | @@ -66,21 +66,21 @@ Read on for the full workflow and conversational patterns. ### Step 1: Add Tasks with Priorities -Every piece of follow-up work gets a task. Use `ctx add task` from the terminal +Every piece of follow-up work gets a task. Use `ctx task add` from the terminal or `/ctx-task-add` from your AI assistant. Tasks should start with a verb and be specific enough that someone unfamiliar with the session could act on them. ```bash # High-priority bug found during code review -ctx add task "Fix race condition in session cooldown" --priority high \ +ctx task add "Fix race condition in session cooldown" --priority high \ --session-id abc12345 --branch main --commit 68fbc00a # Medium-priority feature work -ctx add task "Add --format json flag to ctx status for CI integration" --priority medium \ +ctx task add "Add --format json flag to ctx status for CI integration" --priority medium \ --session-id abc12345 --branch main --commit 68fbc00a # Low-priority cleanup -ctx add task "Remove deprecated --raw flag from ctx load" --priority low \ +ctx task add "Remove deprecated --raw flag from ctx load" --priority low \ --session-id abc12345 --branch main --commit 68fbc00a ``` @@ -97,7 +97,7 @@ If you say "*fix the bug,*" it will ask you to clarify which bug and where. After completing a feature, the agent will often identify follow-up work: tests, docs, edge cases, error handling, and offer to add them as tasks. - You do not need to dictate `ctx add task` commands; the agent picks up on + You do not need to dictate `ctx task add` commands; the agent picks up on work context and suggests tasks naturally. ### Step 2: Organize with Phase Sections @@ -114,7 +114,7 @@ status is tracked via checkboxes and inline tags. - [x] Implement ctx add command - [x] Implement ctx task complete command -- [ ] Add --section flag to ctx add task `#priority:medium` +- [ ] Add --section flag to ctx task add `#priority:medium` ## Phase 2: AI Integration @@ -131,7 +131,7 @@ status is tracked via checkboxes and inline tags. Use `--section` when adding a task to a specific phase: ```bash -ctx add task "Add ctx watch XML parsing" --priority medium --section \ +ctx task add "Add ctx watch XML parsing" --priority medium --section \ "Phase 2: AI Integration" \ --session-id abc12345 --branch main --commit 68fbc00a ``` @@ -163,7 +163,7 @@ The output looks like this: Still in-progress from yesterday's session. The tombstone file approach is half-built. Finishing is cheaper than context-switching. -**2. Add --section flag to ctx add task** `#priority:medium` +**2. Add --section flag to ctx task add** `#priority:medium` Last Phase 1 item. Quick win that unblocks organized task entry. @@ -257,7 +257,7 @@ The steps above show the CLI commands for task management. In practice, most task management happens conversationally: An agent that has loaded the context files does not need you to type -`ctx add task`. It tracks work naturally and offers the right operations. +`ctx task add`. It tracks work naturally and offers the right operations. ### Use Natural Language Instead of Commands @@ -265,11 +265,11 @@ These conversational prompts replace explicit commands during interactive sessio | Instead of typing... | Just say... | |----------------------------------------|----------------------------------------------------| -| `ctx add task "Write tests for X" --session-id ID --branch BR --commit HASH` | "We should add tests for this: track that?" | +| `ctx task add "Write tests for X" --session-id ID --branch BR --commit HASH` | "We should add tests for this: track that?" | | `/ctx-next` | "What should we work on?" | | `ctx task complete "rate limiting"` | "The rate limiter is done, what's next?" | | `ctx task archive` | "`TASKS.md` is getting long, can you clean it up?" | -| `ctx add task ... --session-id ID --branch BR --commit HASH && ctx add task ...` | "Add follow-ups for what we just built." | +| `ctx task add ... --session-id ID --branch BR --commit HASH && ctx task add ...` | "Add follow-ups for what we just built." | The agent translates these into the right `ctx` operations behind the scenes. @@ -356,7 +356,7 @@ You: Agent: "Marked 'Implement ctx agent cooldown' as done. Your highest- -priority remaining task is 'Add --section flag to ctx add task'. +priority remaining task is 'Add --section flag to ctx task add'. It's the last item in Phase 1 and a quick win. Want to start on that?" ``` @@ -409,7 +409,7 @@ Agent: Nice. I'll mark "Implement ctx agent cooldown" as done. You: Yes to both. What's next? Agent: Added the cleanup task as high priority. Next up is "Add --section - flag to ctx add task": last item in Phase 1. It should be + flag to ctx task add": last item in Phase 1. It should be straightforward since the flag parsing pattern already exists in the codebase. Ready? ``` @@ -425,11 +425,11 @@ Agent: Added the cleanup task as high priority. Next up is "Add --section ```bash # Add a task -ctx add task "Implement rate limiting for API endpoints" --priority high \ +ctx task add "Implement rate limiting for API endpoints" --priority high \ --session-id abc12345 --branch main --commit 68fbc00a # Add to a specific phase -ctx add task "Write integration tests for rate limiter" --section "Phase 2" \ +ctx task add "Write integration tests for rate limiter" --section "Phase 2" \ --session-id abc12345 --branch main --commit 68fbc00a # See what to work on diff --git a/docs/reference/skills.md b/docs/reference/skills.md index 78108bd3c..a829291a0 100644 --- a/docs/reference/skills.md +++ b/docs/reference/skills.md @@ -157,7 +157,7 @@ capture decisions and learnings. Pause and reflect on session progress. Walks through a checklist of learnings, decisions, task completions, and session notes to persist. -**Wraps**: chains to `ctx add learning`, `ctx add decision`, +**Wraps**: chains to `ctx learning add`, `ctx decision add`, manual TASKS.md updates **See also**: [The Complete Session](../recipes/session-lifecycle.md), @@ -174,8 +174,8 @@ structured fields for user approval, then persists via `ctx add`. Offers `/ctx-commit` if uncommitted changes remain. **Ceremony skill**: invoke explicitly at session end. -**Wraps**: `git diff --stat`, `git log`, `ctx add learning`, -`ctx add decision`, `ctx add convention`, `ctx add task`, +**Wraps**: `git diff --stat`, `git log`, `ctx learning add`, +`ctx decision add`, `ctx convention add`, `ctx task add`, chains to `/ctx-commit` **See also**: [Session Ceremonies](../recipes/session-ceremonies.md), @@ -192,7 +192,7 @@ conventions: into `.context/` files. Add an actionable task with optional priority and phase section. -**Wraps**: `ctx add task "description" [--priority high|medium|low] +**Wraps**: `ctx task add "description" [--priority high|medium|low] --session-id ID --branch BR --commit HASH` **See also**: [Tracking Work Across Sessions](../recipes/task-management.md) @@ -204,7 +204,7 @@ Add an actionable task with optional priority and phase section. Record an architectural decision with context, rationale, and consequence. Supports Y-statement (lightweight) and full ADR formats. -**Wraps**: `ctx add decision "title" --context "..." --rationale "..." +**Wraps**: `ctx decision add "title" --context "..." --rationale "..." --consequence "..." --session-id ID --branch BR --commit HASH` **See also**: @@ -218,7 +218,7 @@ Record a project-specific gotcha, bug, or unexpected behavior. Filters for insights that are searchable, project-specific, and required real effort to discover. -**Wraps**: `ctx add learning "title" --context "..." --lesson "..." +**Wraps**: `ctx learning add "title" --context "..." --lesson "..." --application "..." --session-id ID --branch BR --commit HASH` **See also**: @@ -231,7 +231,7 @@ required real effort to discover. Record a coding convention that should be standardized across sessions. Targets patterns seen 2-3+ times. -**Wraps**: `ctx add convention "rule" --section "Name"` +**Wraps**: `ctx convention add "rule" --section "Name"` **See also**: [Persisting Decisions, Learnings, and Conventions](../recipes/knowledge-capture.md) diff --git a/internal/assets/claude/skills/ctx-brainstorm/SKILL.md b/internal/assets/claude/skills/ctx-brainstorm/SKILL.md index 52503003c..36375694a 100644 --- a/internal/assets/claude/skills/ctx-brainstorm/SKILL.md +++ b/internal/assets/claude/skills/ctx-brainstorm/SKILL.md @@ -177,7 +177,7 @@ Once validated, persist outputs: ```bash # Record key decisions -ctx add decision "..." \ +ctx decision add "..." \ --session-id ID --branch BR --commit HASH \ --context "..." --rationale "..." --consequence "..." ``` diff --git a/internal/assets/claude/skills/ctx-commit/SKILL.md b/internal/assets/claude/skills/ctx-commit/SKILL.md index 81443ad50..441ce2940 100644 --- a/internal/assets/claude/skills/ctx-commit/SKILL.md +++ b/internal/assets/claude/skills/ctx-commit/SKILL.md @@ -106,7 +106,7 @@ Wait for the user's response. If they provide a decision or learning, record it using the appropriate command: ```bash -ctx add decision "Use PostgreSQL" \ +ctx decision add "Use PostgreSQL" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "Need a reliable database" \ --rationale "ACID compliance and JSON support" \ @@ -114,7 +114,7 @@ ctx add decision "Use PostgreSQL" \ ``` ```bash -ctx add learning "Go embed requires files in same package" \ +ctx learning add "Go embed requires files in same package" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "..." --lesson "..." --application "..." ``` diff --git a/internal/assets/claude/skills/ctx-convention-add/SKILL.md b/internal/assets/claude/skills/ctx-convention-add/SKILL.md index a2ec268ad..8d1dec33c 100644 --- a/internal/assets/claude/skills/ctx-convention-add/SKILL.md +++ b/internal/assets/claude/skills/ctx-convention-add/SKILL.md @@ -40,15 +40,15 @@ this alongside it or update the existing one?"* ## Execution ```bash -ctx add convention "Use kebab-case for all CLI flag names" --section "Naming" +ctx convention add "Use kebab-case for all CLI flag names" --section "Naming" ``` ```bash -ctx add convention "Use cmd.Printf/cmd.Println for CLI output, never fmt.Printf/fmt.Println" --section "Output" +ctx convention add "Use cmd.Printf/cmd.Println for CLI output, never fmt.Printf/fmt.Println" --section "Output" ``` ```bash -ctx add convention "Colocate test files with implementation (*_test.go next to *.go)" --section "Testing" +ctx convention add "Colocate test files with implementation (*_test.go next to *.go)" --section "Testing" ``` If no `--section` is provided, the convention is appended to the end diff --git a/internal/assets/claude/skills/ctx-decision-add/SKILL.md b/internal/assets/claude/skills/ctx-decision-add/SKILL.md index 5f557747e..26b185ca3 100644 --- a/internal/assets/claude/skills/ctx-decision-add/SKILL.md +++ b/internal/assets/claude/skills/ctx-decision-add/SKILL.md @@ -72,13 +72,13 @@ Provenance flags (`--session-id`, `--branch`, `--commit`) are **required**. Get these values from the hook-relayed provenance line in your context (e.g., `Session: abc12345 | Branch: main @ 68fbc00a`). -**Prefer this skill over raw `ctx add decision`**: the conversational +**Prefer this skill over raw `ctx decision add`**: the conversational approach lets you automatically pick up session ID, branch, and commit from the provenance line already in your context window. **Quick format:** ```bash -ctx add decision "Use Cobra for CLI framework" \ +ctx decision add "Use Cobra for CLI framework" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "Need CLI framework for Go project" \ --rationale "Better subcommand support than urfave/cli, team familiarity" \ @@ -87,7 +87,7 @@ ctx add decision "Use Cobra for CLI framework" \ **Full format with alternatives:** ```bash -ctx add decision "Use PostgreSQL for primary database" \ +ctx decision add "Use PostgreSQL for primary database" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "Need ACID-compliant database for e-commerce transactions" \ --rationale "PostgreSQL offers JSONB, full-text search, and team has experience. Chose over MySQL (weaker JSON) and MongoDB (no multi-doc ACID)." \ diff --git a/internal/assets/claude/skills/ctx-drift/SKILL.md b/internal/assets/claude/skills/ctx-drift/SKILL.md index 59960173d..23384c28f 100644 --- a/internal/assets/claude/skills/ctx-drift/SKILL.md +++ b/internal/assets/claude/skills/ctx-drift/SKILL.md @@ -129,12 +129,12 @@ templates shipped with `ctx`. ### Procedure -1. Create a temp directory and run `ctx init --force` inside +1. Create a temp directory and run `ctx init --reset` inside it to get the latest templates: ```bash CTX_TPL_DIR=$(mktemp -d) - cd "$CTX_TPL_DIR" && ctx init --force 2>/dev/null + cd "$CTX_TPL_DIR" && ctx init --reset 2>/dev/null ``` 2. Compare each skill in the project against the template: @@ -191,7 +191,7 @@ drifts independently from the codebase. To get the authoritative list: ```bash - ctx init --force 2>/dev/null # in a temp dir + ctx init --reset 2>/dev/null # in a temp dir ``` Then compare permissions from the generated diff --git a/internal/assets/claude/skills/ctx-learning-add/SKILL.md b/internal/assets/claude/skills/ctx-learning-add/SKILL.md index 556e0e1a1..f281efdb7 100644 --- a/internal/assets/claude/skills/ctx-learning-add/SKILL.md +++ b/internal/assets/claude/skills/ctx-learning-add/SKILL.md @@ -42,19 +42,19 @@ Provenance flags (`--session-id`, `--branch`, `--commit`) are **required**. Get these values from the hook-relayed provenance line in your context (e.g., `Session: abc12345 | Branch: main @ 68fbc00a`). -**Prefer this skill over raw `ctx add learning`**: the conversational +**Prefer this skill over raw `ctx learning add`**: the conversational approach lets you automatically pick up session ID, branch, and commit from the provenance line already in your context window. ```bash -ctx add learning "Title" \ +ctx learning add "Title" \ --session-id SESSION --branch BRANCH --commit HASH \ --context "..." --lesson "..." --application "..." ``` **Example: behavioral pattern:** ```bash -ctx add learning "Agent ignores repeated hook output (repetition fatigue)" \ +ctx learning add "Agent ignores repeated hook output (repetition fatigue)" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "PreToolUse hook ran ctx agent on every tool use, injecting the same context packet repeatedly. Agent tuned it out and didn't follow conventions." \ --lesson "Repeated injection causes the agent to ignore the output. A cooldown tombstone emits once per window. A readback instruction creates a behavioral gate harder to skip than silent injection." \ @@ -63,7 +63,7 @@ ctx add learning "Agent ignores repeated hook output (repetition fatigue)" \ **Example: technical gotcha:** ```bash -ctx add learning "go:embed only works with files in same or child directories" \ +ctx learning add "go:embed only works with files in same or child directories" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "Tried to embed files from parent directory, got compile error" \ --lesson "go:embed paths are relative to the source file and cannot use .. to escape the package" \ @@ -72,7 +72,7 @@ ctx add learning "go:embed only works with files in same or child directories" \ **Example: workflow insight:** ```bash -ctx add learning "ctx init overwrites user content without guard" \ +ctx learning add "ctx init overwrites user content without guard" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "Commit a9df9dd wiped 18 decisions from DECISIONS.md, replacing with empty template" \ --lesson "Init treats all context files as templates, but after first use they contain user data" \ diff --git a/internal/assets/claude/skills/ctx-pad/SKILL.md b/internal/assets/claude/skills/ctx-pad/SKILL.md index 5e71d2ea1..4802d71fc 100644 --- a/internal/assets/claude/skills/ctx-pad/SKILL.md +++ b/internal/assets/claude/skills/ctx-pad/SKILL.md @@ -17,9 +17,9 @@ command. ## When NOT to Use -- For structured tasks (use `ctx add task` instead) -- For architectural decisions (use `ctx add decision` instead) -- For lessons learned (use `ctx add learning` instead) +- For structured tasks (use `ctx task add` instead) +- For architectural decisions (use `ctx decision add` instead) +- For lessons learned (use `ctx learning add` instead) ## Command Mapping diff --git a/internal/assets/claude/skills/ctx-reflect/SKILL.md b/internal/assets/claude/skills/ctx-reflect/SKILL.md index ce78db11c..fae3ba6bd 100644 --- a/internal/assets/claude/skills/ctx-reflect/SKILL.md +++ b/internal/assets/claude/skills/ctx-reflect/SKILL.md @@ -87,10 +87,10 @@ After reflecting, provide: > I'd suggest persisting: > - **Learning**: `$PPID` in PreToolUse hooks resolves to > the Claude Code PID (unique per session) -> `ctx add learning "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` +> `ctx learning add "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` > - **Task**: mark "Add cooldown to ctx agent" as done > - **Decision**: tombstone-based cooldown with 10m default -> `ctx add decision "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` +> `ctx decision add "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` > > Want me to persist any of these? @@ -106,10 +106,10 @@ After reflecting, provide: | What to persist | Command | |------------------|----------------------------------------------------------------------------------------------------------------------------| -| Learning | `ctx add learning "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | -| Decision | `ctx add decision "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | +| Learning | `ctx learning add "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | +| Decision | `ctx decision add "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | | Task completed | Edit TASKS.md directly | -| New task | `ctx add task "Description" --session-id ID --branch BR --commit HASH` | +| New task | `ctx task add "Description" --session-id ID --branch BR --commit HASH` | ## Quality Checklist diff --git a/internal/assets/claude/skills/ctx-remind/SKILL.md b/internal/assets/claude/skills/ctx-remind/SKILL.md index 24b4c7d6f..8208caafb 100644 --- a/internal/assets/claude/skills/ctx-remind/SKILL.md +++ b/internal/assets/claude/skills/ctx-remind/SKILL.md @@ -17,9 +17,9 @@ command. ## When NOT to Use -- For structured tasks with status tracking (use `ctx add task`) +- For structured tasks with status tracking (use `ctx task add`) - For sensitive values or quick notes (use `ctx pad`) -- For architectural decisions (use `ctx add decision`) +- For architectural decisions (use `ctx decision add`) - Create a reminder only when the user explicitly says "remind me": for everything else, let the conversation proceed without creating records diff --git a/internal/assets/claude/skills/ctx-task-add/SKILL.md b/internal/assets/claude/skills/ctx-task-add/SKILL.md index 92dfd31c7..97a53f988 100644 --- a/internal/assets/claude/skills/ctx-task-add/SKILL.md +++ b/internal/assets/claude/skills/ctx-task-add/SKILL.md @@ -39,7 +39,7 @@ If the user provides only a topic, ask: ## Execution ```bash -ctx add task "Task description" \ +ctx task add "Task description" \ --session-id SESSION --branch BRANCH --commit HASH \ [--priority high|medium|low] [--section "Phase N"] ``` @@ -48,7 +48,7 @@ Provenance flags (`--session-id`, `--branch`, `--commit`) are **required**. Get these values from the hook-relayed provenance line in your context (e.g., `Session: abc12345 | Branch: main @ 68fbc00a`). -**Prefer this skill over raw `ctx add task`**: the conversational +**Prefer this skill over raw `ctx task add`**: the conversational approach lets you automatically pick up session ID, branch, and commit from the provenance line already in your context window. @@ -58,30 +58,30 @@ a specific section (e.g., `--section "Maintenance"`). **Example: specific and actionable:** ```bash -ctx add task "Add --cooldown flag to ctx agent to suppress repeated output within a time window. Use tombstone file per session for isolation." \ +ctx task add "Add --cooldown flag to ctx agent to suppress repeated output within a time window. Use tombstone file per session for isolation." \ --session-id abc12345 --branch main --commit 68fbc00a \ --priority medium ``` **Example: with context for why:** ```bash -ctx add task "Investigate ctx init overwriting user-generated content in context files. Commit a9df9dd wiped 18 decisions from DECISIONS.md. Need guard to prevent reinit from destroying user data." \ +ctx task add "Investigate ctx init overwriting user-generated content in context files. Commit a9df9dd wiped 18 decisions from DECISIONS.md. Need guard to prevent reinit from destroying user data." \ --session-id abc12345 --branch main --commit 68fbc00a \ --priority high ``` **Example: scoped subtask:** ```bash -ctx add task "Add topic-based navigation to blog when post count reaches 15+" \ +ctx task add "Add topic-based navigation to blog when post count reaches 15+" \ --session-id abc12345 --branch main --commit 68fbc00a \ --priority low ``` **Bad examples (too shallow):** ```bash -ctx add task "Fix bug" # What bug? Where? -ctx add task "Improve performance" # Of what? How? -ctx add task "Authentication" # That's a topic, not a task +ctx task add "Fix bug" # What bug? Where? +ctx task add "Improve performance" # Of what? How? +ctx task add "Authentication" # That's a topic, not a task # Also bad: missing --session-id, --branch, --commit ``` diff --git a/internal/assets/claude/skills/ctx-wrap-up/SKILL.md b/internal/assets/claude/skills/ctx-wrap-up/SKILL.md index c2362009b..ab9ebd15b 100644 --- a/internal/assets/claude/skills/ctx-wrap-up/SKILL.md +++ b/internal/assets/claude/skills/ctx-wrap-up/SKILL.md @@ -102,10 +102,10 @@ For each approved candidate, run the appropriate command: | Type | Command | |-------------|--------------------------------------------------------------------------------------------------------------------------------| -| Learning | `ctx add learning "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | -| Decision | `ctx add decision "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | -| Convention | `ctx add convention "Description"` | -| Task (new) | `ctx add task "Description" --session-id ID --branch BR --commit HASH` | +| Learning | `ctx learning add "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | +| Decision | `ctx decision add "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | +| Convention | `ctx convention add "Description"` | +| Task (new) | `ctx task add "Description" --session-id ID --branch BR --commit HASH` | | Task (done) | Edit TASKS.md to mark complete | Report the result of each command. If any fail, report the error diff --git a/internal/assets/commands/commands.yaml b/internal/assets/commands/commands.yaml index 815d77a2e..2e7ac7009 100644 --- a/internal/assets/commands/commands.yaml +++ b/internal/assets/commands/commands.yaml @@ -43,41 +43,29 @@ deactivate: Pairs with `ctx activate` for symmetric shell integration. short: Emit shell unset for CTX_DIR -add: +convention: long: |- - Add a new decision, task, learning, or convention - to the appropriate context file. + Manage the CONVENTIONS.md file. - Types: - decision Add to DECISIONS.md (requires --session-id, --branch, --commit, --context, --rationale, --consequence) - learning Add to LEARNINGS.md (requires --session-id, --branch, --commit, --context, --lesson, --application) - task Add to TASKS.md (requires --session-id, --branch, --commit) - convention Add to CONVENTIONS.md + Subcommands: + add Add a new convention entry to CONVENTIONS.md + short: Manage CONVENTIONS.md file +convention.add: + long: |- + Add a new convention entry to CONVENTIONS.md. - Provenance flags (--session-id, --branch, --commit) are required for - task, decision, and learning entries. They link entries to the AI - session and code state that created them. + Conventions capture team or project-wide coding patterns and standards. + They appear as list items at the end of the file. Content can be provided as: - - Command argument: ctx add learning "title here" - - File: ctx add learning --file /path/to/content.md - - Stdin: echo "title" | ctx add learning + - Command argument: ctx convention add "title here" + - File: ctx convention add --file /path/to/content.md + - Stdin: echo "title" | ctx convention add Examples: - ctx add decision "Use PostgreSQL" \ - --session-id abc12345 --branch main --commit 68fbc00a \ - --context "Need a reliable database for production" \ - --rationale "PostgreSQL offers ACID compliance and JSON support" \ - --consequence "Team needs PostgreSQL training" - ctx add learning "Go embed requires files in same package" \ - --session-id abc12345 --branch main --commit 68fbc00a \ - --context "Tried to embed files from parent directory" \ - --lesson "go:embed only works with files in same or child directories" \ - --application "Keep embedded files in internal/templates/, not project root" - ctx add task "Implement user authentication" \ - --session-id abc12345 --branch main --commit 68fbc00a \ - --priority high - short: Add a new item to a context file + ctx convention add "Use camelCase for function names" + ctx convention add "All API responses use JSON" + short: Add a new convention entry to CONVENTIONS.md agent: long: |- Print a concise context packet optimized for AI consumption. @@ -265,14 +253,41 @@ decision: Manage the DECISIONS.md file and its quick-reference index. The decisions file maintains an auto-generated index at the top for quick - scanning. Use the subcommands to manage this index. + scanning. Use the subcommands to add entries and manage the index. Subcommands: + add Add a new decision entry to DECISIONS.md reindex Regenerate the quick-reference index Examples: + ctx decision add "Use PostgreSQL" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --context "Need a reliable database" \ + --rationale "ACID compliance and JSON support" \ + --consequence "Team needs PostgreSQL training" ctx decision reindex short: Manage DECISIONS.md file +decision.add: + long: |- + Add a new decision entry to DECISIONS.md. + + Required flags: --session-id, --branch, --commit, --context, + --rationale, --consequence. These link the decision to the AI + session and code state that created it, and capture the + structured ADR-style content. + + Content (the decision title) can be provided as: + - Command argument: ctx decision add "title here" + - File: ctx decision add --file /path/to/content.md + - Stdin: echo "title" | ctx decision add + + Examples: + ctx decision add "Use PostgreSQL for primary database" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --context "Need a reliable database for production" \ + --rationale "PostgreSQL offers ACID compliance and JSON support" \ + --consequence "Team needs PostgreSQL training" + short: Add a new decision entry to DECISIONS.md decision.reindex: long: |- Regenerate the quick-reference index at the top of DECISIONS.md. @@ -465,7 +480,8 @@ initialize: ctx init # Collaborative mode (agent asks questions) ctx init --ralph # Autonomous mode (agent works independently) ctx init --minimal # Only essential files (TASKS, DECISIONS, CONSTITUTION) - ctx init --force # Overwrite existing files without prompting + ctx init --reset # Reset existing populated context (interactive, + # backs up to .context/.backup-init-/) ctx init --merge # Auto-merge ctx content into existing files short: Initialize a new .context/ directory with template files journal: @@ -542,14 +558,41 @@ learning: Manage the LEARNINGS.md file and its quick-reference index. The learning file maintains an auto-generated index at the top for quick - scanning. Use the subcommands to manage this index. + scanning. Use the subcommands to add entries and manage the index. Subcommands: + add Add a new learning entry to LEARNINGS.md reindex Regenerate the quick-reference index Examples: + ctx learning add "Go embed gotcha" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --context "Tried to embed files from parent directory" \ + --lesson "go:embed only works with files in same or child directories" \ + --application "Keep embedded files in internal/templates/" ctx learning reindex short: Manage LEARNINGS.md file +learning.add: + long: |- + Add a new learning entry to LEARNINGS.md. + + Required flags: --session-id, --branch, --commit, --context, + --lesson, --application. These link the learning to the AI + session and code state that created it, and capture the + structured context/lesson/application content. + + Content (the learning title) can be provided as: + - Command argument: ctx learning add "title here" + - File: ctx learning add --file /path/to/content.md + - Stdin: echo "title" | ctx learning add + + Examples: + ctx learning add "Go embed requires files in same package" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --context "Tried to embed files from parent directory" \ + --lesson "go:embed only works with files in same or child directories" \ + --application "Keep embedded files in internal/templates/, not project root" + short: Add a new learning entry to LEARNINGS.md learning.reindex: long: |- Regenerate the quick-reference index at the top of LEARNINGS.md. @@ -1484,16 +1527,43 @@ usage: short: Show session token usage task: long: |- - Manage task archival and snapshots. - - Tasks can be archived to move completed items out of TASKS.md while - preserving them for historical reference. Snapshots create point-in-time - copies without modifying the original. + Manage TASKS.md entries. Subcommands: + add Add a new task entry to TASKS.md + complete Mark a task as completed archive Move completed tasks to timestamped archive file snapshot Create point-in-time snapshot of TASKS.md - short: Manage task archival and snapshots + + Examples: + ctx task add "Implement user authentication" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --priority high + ctx task complete 3 + ctx task archive + short: Manage TASKS.md entries +task.add: + long: |- + Add a new task entry to TASKS.md. + + Provenance flags (--session-id, --branch, --commit) are required; + they link the task to the AI session and code state that created it. + Use --priority to set high/medium/low and --section to target a + specific phase header. + + Content can be provided as: + - Command argument: ctx task add "title here" + - File: ctx task add --file /path/to/content.md + - Stdin: echo "title" | ctx task add + + Examples: + ctx task add "Implement user authentication" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --priority high + ctx task add "Fix login bug" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --priority high --section "Phase 1" + short: Add a new task entry to TASKS.md task.archive: long: |- Move completed tasks from TASKS.md to an archive file. diff --git a/internal/assets/commands/examples.yaml b/internal/assets/commands/examples.yaml index 97df674b2..12ddaecc5 100644 --- a/internal/assets/commands/examples.yaml +++ b/internal/assets/commands/examples.yaml @@ -17,36 +17,33 @@ deactivate: short: |2- eval "$(ctx deactivate)" -add: +convention.add: short: |2- - ctx add decision "Use PostgreSQL" --context "..." --rationale "..." --consequence "..." - ctx add task "Implement auth" --priority high - ctx add learning "Go embed gotcha" --context "..." --lesson "..." --application "..." + ctx convention add "Use camelCase for function names" + ctx convention add "All API responses use JSON" -add.convention: +decision.add: short: |2- - ctx add convention "Use camelCase for function names" - ctx add convention "All API responses use JSON" + ctx decision add "Use PostgreSQL for primary database" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --context "Need a reliable database for production" \ + --rationale "ACID compliance and JSON support" \ + --consequence "Team needs PostgreSQL training" -add.decision: +learning.add: short: |2- - ctx add decision "Use PostgreSQL for primary database" - ctx add decision "Adopt Go 1.22 for range-over-func support" - -add.default: - short: ' ctx add "your content here"' - -add.learning: - short: |2- - ctx add learning "Go embed requires files in same package" \ + ctx learning add "Go embed requires files in same package" \ + --session-id abc12345 --branch main --commit 68fbc00a \ --context "Tried to embed files from parent directory" \ --lesson "go:embed only works with files in same or child directories" \ --application "Keep embedded files in internal/templates/" -add.task: +task.add: short: |2- - ctx add task "Implement user authentication" - ctx add task "Fix login bug" --priority high + ctx task add "Implement user authentication" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --priority high + ctx task add "Fix login bug" --session-id ... --branch ... --commit ... agent: short: |2- diff --git a/internal/assets/commands/flags.yaml b/internal/assets/commands/flags.yaml index 9f855270e..28876dea2 100644 --- a/internal/assets/commands/flags.yaml +++ b/internal/assets/commands/flags.yaml @@ -73,8 +73,8 @@ trigger.test.tool: short: Tool name for mock input setup.write: short: Write the configuration file instead of printing -initialize.force: - short: Overwrite existing context files +initialize.reset: + short: Reset an existing context (interactive only; backs up existing files to .context/.backup-init-/ before overwriting) initialize.merge: short: Auto-merge ctx content into existing CLAUDE.md initialize.minimal: diff --git a/internal/assets/commands/text/errors.yaml b/internal/assets/commands/text/errors.yaml index 6744e7247..37112b0c4 100644 --- a/internal/assets/commands/text/errors.yaml +++ b/internal/assets/commands/text/errors.yaml @@ -587,3 +587,13 @@ err.parser.missing-open-delim: short: missing opening frontmatter delimiter (---) err.parser.missing-close-delim: short: missing closing frontmatter delimiter (---) +err.init-context-populated: + short: '%w (directory: %s; populated: %s; to discard, run `ctx init %s`, which backs up to %s before overwriting and requires interactive y/N confirmation)' +err.init-reset-requires-interactive: + short: '%w (reset is destructive: run `ctx init --reset` directly from a terminal — not via --caller — so you can confirm the file list before overwriting)' +err.init-backup-mkdir: + short: 'create backup dir %s: %w' +err.init-backup-read: + short: 'read %s for backup: %w' +err.init-backup-write: + short: 'write backup %s: %w' diff --git a/internal/assets/commands/text/ui.yaml b/internal/assets/commands/text/ui.yaml index 322a8b807..1b3a8ca93 100644 --- a/internal/assets/commands/text/ui.yaml +++ b/internal/assets/commands/text/ui.yaml @@ -185,7 +185,7 @@ drift.check-required: drift.check-file-age: short: No stale files by age drift.stale-header: - short: 'comment header in %s does not match template: run ctx init --force to sync' + short: 'comment header in %s does not match template: run ctx init --reset to sync' drift.check-template-header: short: All context file headers match templates drift.invalid-tool: diff --git a/internal/assets/commands/text/write.yaml b/internal/assets/commands/text/write.yaml index 19f324c83..1b5184eb2 100644 --- a/internal/assets/commands/text/write.yaml +++ b/internal/assets/commands/text/write.yaml @@ -265,8 +265,20 @@ write.init-getting-started-saved: short: ' ✓ Quick-start reference saved to %s' write.init-no-changes: short: ' ○ %s (no changes needed)' -write.init-overwrite-prompt: - short: '%s is already initialized. Re-run init? Existing files are preserved; missing ones are added. (Use --force to overwrite existing files.) [y/N] ' +write.init-reset-prompt-header: + short: 'ctx init --reset will OVERWRITE the following populated context files:' +write.init-reset-prompt-dir: + short: ' directory: %s' +write.init-reset-prompt-file: + short: ' - %s' +write.init-reset-prompt-footer: + short: |- + Each file will first be copied to .context/.backup-init-/ + for recovery. + + Continue? [y/N]: +write.init-backup-written: + short: 'backup written to: %s' write.init-perms-allow: short: ' ✓ %s (added ctx permissions)' write.init-perms-allow-deny: diff --git a/internal/assets/context/AGENT_PLAYBOOK.md b/internal/assets/context/AGENT_PLAYBOOK.md index 6ba48fe9c..ab3aab9a7 100644 --- a/internal/assets/context/AGENT_PLAYBOOK.md +++ b/internal/assets/context/AGENT_PLAYBOOK.md @@ -261,7 +261,7 @@ Track task progress with timestamps for session correlation: | Tag | When to Add | Format | |------------|------------------------------------------|----------------------| -| `#added` | Auto-added by `ctx add task` | `YYYY-MM-DD-HHMMSS` | +| `#added` | Auto-added by `ctx task add` | `YYYY-MM-DD-HHMMSS` | | `#started` | When you begin working on the task | `YYYY-MM-DD-HHMMSS` | ## Collaboration Defaults diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-add-convention/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-add-convention/SKILL.md index dcf929503..10f4c1e90 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-add-convention/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-add-convention/SKILL.md @@ -35,7 +35,7 @@ correctly: don't create a new section if an existing one fits. ## Execution ```bash -ctx add convention "Use kebab-case for all CLI flag names" --section "Naming" +ctx convention add "Use kebab-case for all CLI flag names" --section "Naming" ``` ## Quality Checklist diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-add-decision/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-add-decision/SKILL.md index 82f3698f0..776327b02 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-add-decision/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-add-decision/SKILL.md @@ -33,7 +33,7 @@ Gather: Context, Alternatives, Decision, Rationale, Consequence. ## Execution ```bash -ctx add decision "Use Cobra for CLI framework" \ +ctx decision add "Use Cobra for CLI framework" \ --context "Need CLI framework for Go project" \ --rationale "Better subcommand support, team familiarity" \ --consequence "More boilerplate, but clearer command structure" diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-add-learning/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-add-learning/SKILL.md index 7ac679724..631e6a7a8 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-add-learning/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-add-learning/SKILL.md @@ -31,7 +31,7 @@ Learnings should capture **principles and heuristics**, not code snippets. ## Execution ```bash -ctx add learning "Title" \ +ctx learning add "Title" \ --context "What were you doing when you discovered this?" \ --lesson "What's the key insight?" \ --application "How should we handle this going forward?" diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-add-task/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-add-task/SKILL.md index 7090eaabe..01d4d96f4 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-add-task/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-add-task/SKILL.md @@ -31,19 +31,19 @@ Tasks should describe **what to do and why**, not just a topic. ## Execution ```bash -ctx add task "Task description" [--priority high|medium|low] [--section "Phase N"] +ctx task add "Task description" [--priority high|medium|low] [--section "Phase N"] ``` **Good examples:** ```bash -ctx add task "Add --cooldown flag to ctx agent" --priority medium -ctx add task "Investigate ctx init overwriting user content" --priority high +ctx task add "Add --cooldown flag to ctx agent" --priority medium +ctx task add "Investigate ctx init overwriting user content" --priority high ``` **Bad examples (too shallow):** ```bash -ctx add task "Fix bug" # What bug? Where? -ctx add task "Improve performance" # Of what? How? +ctx task add "Fix bug" # What bug? Where? +ctx task add "Improve performance" # Of what? How? ``` ## Quality Checklist diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-brainstorm/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-brainstorm/SKILL.md index 52503003c..36375694a 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-brainstorm/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-brainstorm/SKILL.md @@ -177,7 +177,7 @@ Once validated, persist outputs: ```bash # Record key decisions -ctx add decision "..." \ +ctx decision add "..." \ --session-id ID --branch BR --commit HASH \ --context "..." --rationale "..." --consequence "..." ``` diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-commit/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-commit/SKILL.md index 81443ad50..441ce2940 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-commit/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-commit/SKILL.md @@ -106,7 +106,7 @@ Wait for the user's response. If they provide a decision or learning, record it using the appropriate command: ```bash -ctx add decision "Use PostgreSQL" \ +ctx decision add "Use PostgreSQL" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "Need a reliable database" \ --rationale "ACID compliance and JSON support" \ @@ -114,7 +114,7 @@ ctx add decision "Use PostgreSQL" \ ``` ```bash -ctx add learning "Go embed requires files in same package" \ +ctx learning add "Go embed requires files in same package" \ --session-id abc12345 --branch main --commit 68fbc00a \ --context "..." --lesson "..." --application "..." ``` diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-drift/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-drift/SKILL.md index da7aabcab..b6f1e3596 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-drift/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-drift/SKILL.md @@ -128,12 +128,12 @@ templates shipped with `ctx`. ### Procedure -1. Create a temp directory and run `ctx init --force` inside +1. Create a temp directory and run `ctx init --reset` inside it to get the latest templates: ```bash CTX_TPL_DIR=$(mktemp -d) - cd "$CTX_TPL_DIR" && ctx init --force 2>/dev/null + cd "$CTX_TPL_DIR" && ctx init --reset 2>/dev/null ``` 2. Compare each skill in the project against the template: @@ -190,7 +190,7 @@ drifts independently from the codebase. To get the authoritative list: ```bash - ctx init --force 2>/dev/null # in a temp dir + ctx init --reset 2>/dev/null # in a temp dir ``` Then compare permissions from the generated diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-pad/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-pad/SKILL.md index 5ff0aa9f0..19553e1d7 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-pad/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-pad/SKILL.md @@ -16,9 +16,9 @@ command. ## When NOT to Use -- For structured tasks (use `ctx add task` instead) -- For architectural decisions (use `ctx add decision` instead) -- For lessons learned (use `ctx add learning` instead) +- For structured tasks (use `ctx task add` instead) +- For architectural decisions (use `ctx decision add` instead) +- For lessons learned (use `ctx learning add` instead) ## Command Mapping diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-reflect/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-reflect/SKILL.md index ce78db11c..fae3ba6bd 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-reflect/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-reflect/SKILL.md @@ -87,10 +87,10 @@ After reflecting, provide: > I'd suggest persisting: > - **Learning**: `$PPID` in PreToolUse hooks resolves to > the Claude Code PID (unique per session) -> `ctx add learning "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` +> `ctx learning add "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` > - **Task**: mark "Add cooldown to ctx agent" as done > - **Decision**: tombstone-based cooldown with 10m default -> `ctx add decision "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` +> `ctx decision add "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` > > Want me to persist any of these? @@ -106,10 +106,10 @@ After reflecting, provide: | What to persist | Command | |------------------|----------------------------------------------------------------------------------------------------------------------------| -| Learning | `ctx add learning "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | -| Decision | `ctx add decision "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | +| Learning | `ctx learning add "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | +| Decision | `ctx decision add "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | | Task completed | Edit TASKS.md directly | -| New task | `ctx add task "Description" --session-id ID --branch BR --commit HASH` | +| New task | `ctx task add "Description" --session-id ID --branch BR --commit HASH` | ## Quality Checklist diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-remind/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-remind/SKILL.md index d020799c6..62ce87e7f 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-remind/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-remind/SKILL.md @@ -16,9 +16,9 @@ command. ## When NOT to Use -- For structured tasks with status tracking (use `ctx add task`) +- For structured tasks with status tracking (use `ctx task add`) - For sensitive values or quick notes (use `ctx pad`) -- For architectural decisions (use `ctx add decision`) +- For architectural decisions (use `ctx decision add`) - Create a reminder only when the user explicitly says "remind me": for everything else, let the conversation proceed without creating records diff --git a/internal/assets/integrations/copilot-cli/skills/ctx-wrap-up/SKILL.md b/internal/assets/integrations/copilot-cli/skills/ctx-wrap-up/SKILL.md index 6c9a21a51..f59820389 100644 --- a/internal/assets/integrations/copilot-cli/skills/ctx-wrap-up/SKILL.md +++ b/internal/assets/integrations/copilot-cli/skills/ctx-wrap-up/SKILL.md @@ -101,10 +101,10 @@ For each approved candidate, run the appropriate command: | Type | Command | |-------------|--------------------------------------------------------------------------------------------------------------------------------| -| Learning | `ctx add learning "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | -| Decision | `ctx add decision "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | -| Convention | `ctx add convention "Description"` | -| Task (new) | `ctx add task "Description" --session-id ID --branch BR --commit HASH` | +| Learning | `ctx learning add "Title" --session-id ID --branch BR --commit HASH --context "..." --lesson "..." --application "..."` | +| Decision | `ctx decision add "Title" --session-id ID --branch BR --commit HASH --context "..." --rationale "..." --consequence "..."` | +| Convention | `ctx convention add "Description"` | +| Task (new) | `ctx task add "Description" --session-id ID --branch BR --commit HASH` | | Task (done) | Edit TASKS.md to mark complete | Report the result of each command. If any fail, report the error diff --git a/internal/assets/tpl/doc.go b/internal/assets/tpl/doc.go index 4125b1845..884ae4f22 100644 --- a/internal/assets/tpl/doc.go +++ b/internal/assets/tpl/doc.go @@ -19,7 +19,7 @@ // - **`tpl_entry.go`**: the canonical TASKS.md task // line and its inline tags (`#priority:`, // `#session:`, `#branch:`, `#commit:`, `#added:`). -// Used by `ctx add task`. +// Used by `ctx task add`. // - **`tpl_hub_entry.go`**: markdown rendering of one // hub entry (date header + origin tag + content // body + horizontal rule). Consumed by diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go index 31caded06..0e509eba0 100644 --- a/internal/bootstrap/bootstrap_test.go +++ b/internal/bootstrap/bootstrap_test.go @@ -80,7 +80,6 @@ func TestInitialize(t *testing.T) { "init", "status", "load", - "add", "agent", "drift", "sync", @@ -90,6 +89,7 @@ func TestInitialize(t *testing.T) { "setup", "learning", "task", + "convention", "loop", "journal", "serve", diff --git a/internal/bootstrap/group.go b/internal/bootstrap/group.go index 3a29f6fa1..395f1571d 100644 --- a/internal/bootstrap/group.go +++ b/internal/bootstrap/group.go @@ -8,12 +8,12 @@ package bootstrap import ( "github.com/ActiveMemory/ctx/internal/cli/activate" - "github.com/ActiveMemory/ctx/internal/cli/add" "github.com/ActiveMemory/ctx/internal/cli/agent" "github.com/ActiveMemory/ctx/internal/cli/change" "github.com/ActiveMemory/ctx/internal/cli/compact" "github.com/ActiveMemory/ctx/internal/cli/config" "github.com/ActiveMemory/ctx/internal/cli/connection" + "github.com/ActiveMemory/ctx/internal/cli/convention" "github.com/ActiveMemory/ctx/internal/cli/deactivate" "github.com/ActiveMemory/ctx/internal/cli/decision" "github.com/ActiveMemory/ctx/internal/cli/doctor" @@ -71,15 +71,15 @@ func gettingStarted() []registration { // // These commands operate on the full set of context source-of-truth // files (TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md): -// adding entries, loading for agents, formatting, reconciling with -// the codebase, detecting drift, and archiving completed work. +// loading for agents, formatting, reconciling with the codebase, +// detecting drift, and archiving completed work. Per-noun add +// commands live under the artifacts group as ctx add. // // Returns: -// - []registration: Add, load, agent, skill, sync, drift, -// compact, and fmt commands +// - []registration: Load, agent, skill, sync, drift, compact, +// and fmt commands func contextCmds() []registration { return []registration{ - {add.Cmd, embedCmd.GroupContext}, {load.Cmd, embedCmd.GroupContext}, {agent.Cmd, embedCmd.GroupContext}, {skill.Cmd, embedCmd.GroupContext}, @@ -93,18 +93,20 @@ func contextCmds() []registration { // artifacts returns command registrations for the artifacts group. // // These commands operate on specific artifact files inside -// .context/: the DECISIONS.md, LEARNINGS.md, and TASKS.md -// stores, plus the `reindex` shortcut that rebuilds the -// decision/learning index tables in a single call. +// .context/: the DECISIONS.md, LEARNINGS.md, TASKS.md, and +// CONVENTIONS.md stores, plus the `reindex` shortcut that +// rebuilds the decision/learning index tables in a single call. +// Each noun parent owns its add subcommand (ctx add). // // Returns: -// - []registration: Decision, learning, task, and reindex -// commands +// - []registration: Decision, learning, task, convention, +// and reindex commands func artifacts() []registration { return []registration{ {decision.Cmd, embedCmd.GroupArtifacts}, {learning.Cmd, embedCmd.GroupArtifacts}, {task.Cmd, embedCmd.GroupArtifacts}, + {convention.Cmd, embedCmd.GroupArtifacts}, {reindex.Cmd, embedCmd.GroupArtifacts}, } } diff --git a/internal/cli/add/add.go b/internal/cli/add/add.go deleted file mode 100644 index c1d459521..000000000 --- a/internal/cli/add/add.go +++ /dev/null @@ -1,21 +0,0 @@ -// / ctx: https://ctx.ist -// ,'`./ do you remember? -// `.,'\ -// \ Copyright 2026-present Context contributors. -// SPDX-License-Identifier: Apache-2.0 - -package add - -import ( - "github.com/spf13/cobra" - - "github.com/ActiveMemory/ctx/internal/cli/add/cmd/root" -) - -// Cmd returns the "ctx add" command. -// -// Returns: -// - *cobra.Command: Configured add command -func Cmd() *cobra.Command { - return root.Cmd() -} diff --git a/internal/cli/add/add_test.go b/internal/cli/add/add_test.go deleted file mode 100644 index cb47d3ac7..000000000 --- a/internal/cli/add/add_test.go +++ /dev/null @@ -1,383 +0,0 @@ -// / ctx: https://ctx.ist -// ,'`./ do you remember? -// `.,'\ -// \ Copyright 2026-present Context contributors. -// SPDX-License-Identifier: Apache-2.0 - -package add - -import ( - "os" - "path/filepath" - "strings" - "testing" - - "github.com/ActiveMemory/ctx/internal/cli/initialize" - "github.com/ActiveMemory/ctx/internal/testutil/testctx" -) - -// TestAddCommand tests the add command. -func TestAddCommand(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "cli-add-test-*") - if err != nil { - t.Fatalf("failed to create temp dir: %v", err) - } - defer func() { _ = os.RemoveAll(tmpDir) }() - - origDir, _ := os.Getwd() - if err = os.Chdir(tmpDir); err != nil { - t.Fatalf("failed to chdir: %v", err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - // First init - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err = initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - // Test adding a task - addCmd := Cmd() - addCmd.SetArgs([]string{"task", "Test task for integration", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) - if err = addCmd.Execute(); err != nil { - t.Fatalf("add task command failed: %v", err) - } - - // Verify the task was added - tasksPath := filepath.Join(tmpDir, ".context", "TASKS.md") - content, err := os.ReadFile(filepath.Clean(tasksPath)) - if err != nil { - t.Fatalf("failed to read TASKS.md: %v", err) - } - - if !strings.Contains(string(content), "Test task for integration") { - t.Errorf("task was not added to TASKS.md") - } -} - -// TestAddDecisionAndLearning tests adding decisions and learnings. -func TestAddDecisionAndLearning(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "cli-add-dl-test-*") - if err != nil { - t.Fatalf("failed to create temp dir: %v", err) - } - defer func() { _ = os.RemoveAll(tmpDir) }() - - origDir, _ := os.Getwd() - if err := os.Chdir(tmpDir); err != nil { - t.Fatalf("failed to chdir: %v", err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - // First init - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err := initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - // Test adding a decision with required flags - t.Run("add decision", func(t *testing.T) { - addCmd := Cmd() - addCmd.SetArgs([]string{ - "decision", "Use PostgreSQL for database", - "--session-id", "test1234", "--branch", "main", "--commit", "abc123", - "--context", "Need a reliable database", - "--rationale", "PostgreSQL is well-supported", - "--consequence", "Team needs training", - }) - if err := addCmd.Execute(); err != nil { - t.Fatalf("add decision failed: %v", err) - } - - content, err := os.ReadFile(".context/DECISIONS.md") - if err != nil { - t.Fatalf("failed to read DECISIONS.md: %v", err) - } - contentStr := string(content) - if !strings.Contains(contentStr, "Use PostgreSQL for database") { - t.Error("decision title was not added to DECISIONS.md") - } - if !strings.Contains(contentStr, "Need a reliable database") { - t.Error("decision context was not added to DECISIONS.md") - } - if !strings.Contains(contentStr, "PostgreSQL is well-supported") { - t.Error("decision rationale was not added to DECISIONS.md") - } - if !strings.Contains(contentStr, "Team needs training") { - t.Error("decision consequences was not added to DECISIONS.md") - } - }) - - // Test that decision without required flags fails - t.Run("add decision without flags fails", func(t *testing.T) { - addCmd := Cmd() - addCmd.SetArgs([]string{"decision", "Incomplete decision"}) - err := addCmd.Execute() - if err == nil { - t.Fatal("expected error when adding decision without required flags") - } - if !strings.Contains(err.Error(), "--session-id") { - t.Errorf("error should mention missing --session-id flag: %v", err) - } - }) - - // Test adding a learning with required flags - t.Run("add learning", func(t *testing.T) { - addCmd := Cmd() - addCmd.SetArgs([]string{ - "learning", "Always check for nil before dereferencing", - "--session-id", "test1234", "--branch", "main", "--commit", "abc123", - "--context", "Got a nil pointer panic in production", - "--lesson", "Always validate pointers before use", - "--application", "Add nil checks in all pointer-receiving functions", - }) - if err := addCmd.Execute(); err != nil { - t.Fatalf("add learning failed: %v", err) - } - - content, err := os.ReadFile(".context/LEARNINGS.md") - if err != nil { - t.Fatalf("failed to read LEARNINGS.md: %v", err) - } - contentStr := string(content) - wantTitle := "Always check for nil before dereferencing" - if !strings.Contains(contentStr, wantTitle) { - t.Error("learning title was not added to LEARNINGS.md") - } - if !strings.Contains(contentStr, "Got a nil pointer panic in production") { - t.Error("learning context was not added to LEARNINGS.md") - } - if !strings.Contains(contentStr, "Always validate pointers before use") { - t.Error("learning lesson was not added to LEARNINGS.md") - } - wantApp := "Add nil checks in all pointer-receiving functions" - if !strings.Contains(contentStr, wantApp) { - t.Error("learning application was not added to LEARNINGS.md") - } - }) - - // Test that learning without required flags fails - t.Run("add learning without flags fails", func(t *testing.T) { - addCmd := Cmd() - addCmd.SetArgs([]string{"learning", "Incomplete learning"}) - err := addCmd.Execute() - if err == nil { - t.Fatal("expected error when adding learning without required flags") - } - if !strings.Contains(err.Error(), "--session-id") { - t.Errorf("error should mention missing --session-id flag: %v", err) - } - }) - - // Test that task without provenance flags fails - t.Run("add task without provenance fails", func(t *testing.T) { - addCmd := Cmd() - addCmd.SetArgs([]string{"task", "Missing provenance", "--section", "Misc"}) - err := addCmd.Execute() - if err == nil { - t.Fatal("expected error when adding task without provenance") - } - if !strings.Contains(err.Error(), "--session-id") { - t.Errorf("error should mention --session-id: %v", err) - } - }) - - // Test adding a convention - t.Run("add convention", func(t *testing.T) { - addCmd := Cmd() - addCmd.SetArgs([]string{"convention", "Use camelCase for variable names"}) - if err := addCmd.Execute(); err != nil { - t.Fatalf("add convention failed: %v", err) - } - - content, err := os.ReadFile(".context/CONVENTIONS.md") - if err != nil { - t.Fatalf("failed to read CONVENTIONS.md: %v", err) - } - if !strings.Contains(string(content), "Use camelCase for variable names") { - t.Error("convention was not added to CONVENTIONS.md") - } - }) -} - -// TestPrependOrder tests that decisions and learnings -// are prepended (newest first). -func TestPrependOrder(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "cli-add-prepend-test-*") - if err != nil { - t.Fatalf("failed to create temp dir: %v", err) - } - defer func() { _ = os.RemoveAll(tmpDir) }() - - origDir, _ := os.Getwd() - if err := os.Chdir(tmpDir); err != nil { - t.Fatalf("failed to chdir: %v", err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - // First init - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err := initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - t.Run("decisions are prepended", func(t *testing.T) { - // Add first decision - addCmd := Cmd() - addCmd.SetArgs([]string{ - "decision", "First decision", - "--session-id", "test1234", "--branch", "main", "--commit", "abc123", - "--context", "First context", - "--rationale", "First rationale", - "--consequence", "First consequences", - }) - if err := addCmd.Execute(); err != nil { - t.Fatalf("add first decision failed: %v", err) - } - - // Add second decision - addCmd = Cmd() - addCmd.SetArgs([]string{ - "decision", "Second decision", - "--session-id", "test1234", "--branch", "main", "--commit", "abc123", - "--context", "Second context", - "--rationale", "Second rationale", - "--consequence", "Second consequences", - }) - if err := addCmd.Execute(); err != nil { - t.Fatalf("add second decision failed: %v", err) - } - - content, err := os.ReadFile(".context/DECISIONS.md") - if err != nil { - t.Fatalf("failed to read DECISIONS.md: %v", err) - } - - contentStr := string(content) - firstIdx := strings.Index(contentStr, "First decision") - secondIdx := strings.Index(contentStr, "Second decision") - - if firstIdx == -1 || secondIdx == -1 { - t.Fatal("decisions not found in file") - } - if secondIdx >= firstIdx { - t.Errorf( - "second decision should appear before"+ - " first (prepended), but first at %d,"+ - " second at %d", - firstIdx, secondIdx, - ) - } - }) - - t.Run("learnings are prepended", func(t *testing.T) { - // Add first learning - addCmd := Cmd() - addCmd.SetArgs([]string{ - "learning", "First learning", - "--session-id", "test1234", "--branch", "main", "--commit", "abc123", - "--context", "First context", - "--lesson", "First lesson", - "--application", "First application", - }) - if err := addCmd.Execute(); err != nil { - t.Fatalf("add first learning failed: %v", err) - } - - // Add second learning - addCmd = Cmd() - addCmd.SetArgs([]string{ - "learning", "Second learning", - "--session-id", "test1234", "--branch", "main", "--commit", "abc123", - "--context", "Second context", - "--lesson", "Second lesson", - "--application", "Second application", - }) - if err := addCmd.Execute(); err != nil { - t.Fatalf("add second learning failed: %v", err) - } - - content, err := os.ReadFile(".context/LEARNINGS.md") - if err != nil { - t.Fatalf("failed to read LEARNINGS.md: %v", err) - } - - contentStr := string(content) - firstIdx := strings.Index(contentStr, "First learning") - secondIdx := strings.Index(contentStr, "Second learning") - - if firstIdx == -1 || secondIdx == -1 { - t.Fatal("learnings not found in file") - } - if secondIdx >= firstIdx { - t.Errorf( - "second learning should appear before"+ - " first (prepended), but first at %d,"+ - " second at %d", - firstIdx, secondIdx, - ) - } - }) -} - -// TestAddFromFile tests adding content from a file. -func TestAddFromFile(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "cli-add-file-test-*") - if err != nil { - t.Fatalf("failed to create temp dir: %v", err) - } - defer func() { _ = os.RemoveAll(tmpDir) }() - - origDir, _ := os.Getwd() - if err = os.Chdir(tmpDir); err != nil { - t.Fatalf("failed to chdir: %v", err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - // First init - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err = initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - // Create a file with content (title) - contentFile := filepath.Join(tmpDir, "learning-content.md") - if err = os.WriteFile( - contentFile, []byte("Content from file test"), 0600, - ); err != nil { - t.Fatalf("failed to create content file: %v", err) - } - - // Test adding from file (still needs flags for learning) - addCmd := Cmd() - addCmd.SetArgs([]string{ - "learning", "--file", contentFile, - "--session-id", "test1234", "--branch", "main", "--commit", "abc123", - "--context", "Testing file input", - "--lesson", "File input works", - "--application", "Use --file for long content", - }) - if err = addCmd.Execute(); err != nil { - t.Fatalf("add from file failed: %v", err) - } - - content, err := os.ReadFile(".context/LEARNINGS.md") - if err != nil { - t.Fatalf("failed to read LEARNINGS.md: %v", err) - } - if !strings.Contains(string(content), "Content from file test") { - t.Error("content from file was not added to LEARNINGS.md") - } -} diff --git a/internal/cli/add/cmd/coverage_test.go b/internal/cli/add/cmd/coverage_test.go deleted file mode 100644 index a826a743b..000000000 --- a/internal/cli/add/cmd/coverage_test.go +++ /dev/null @@ -1,921 +0,0 @@ -// / ctx: https://ctx.ist -// ,'`./ do you remember? -// `.,'\ -// \ Copyright 2026-present Context contributors. -// SPDX-License-Identifier: Apache-2.0 - -package cmd - -import ( - "os" - "path/filepath" - "strings" - "testing" - - "github.com/ActiveMemory/ctx/internal/assets/read/desc" - "github.com/ActiveMemory/ctx/internal/cli/add/cmd/root" - coreEntry "github.com/ActiveMemory/ctx/internal/cli/add/core/entry" - "github.com/ActiveMemory/ctx/internal/cli/add/core/example" - "github.com/ActiveMemory/ctx/internal/cli/add/core/extract" - "github.com/ActiveMemory/ctx/internal/cli/add/core/format" - "github.com/ActiveMemory/ctx/internal/cli/add/core/insert" - "github.com/ActiveMemory/ctx/internal/cli/add/core/normalize" - "github.com/ActiveMemory/ctx/internal/config/embed/text" - "github.com/ActiveMemory/ctx/internal/config/marker" - errAdd "github.com/ActiveMemory/ctx/internal/err/add" - errFs "github.com/ActiveMemory/ctx/internal/err/fs" - "github.com/ActiveMemory/ctx/internal/inspect" - "github.com/ActiveMemory/ctx/internal/rc" - "github.com/spf13/cobra" - - "github.com/ActiveMemory/ctx/internal/cli/initialize" - entryType "github.com/ActiveMemory/ctx/internal/config/entry" - "github.com/ActiveMemory/ctx/internal/entity" - "github.com/ActiveMemory/ctx/internal/entry" - "github.com/ActiveMemory/ctx/internal/testutil/testctx" -) - -// --------------------------------------------------------------------------- -// err.go coverage -// --------------------------------------------------------------------------- - -func TestErrNoContent(t *testing.T) { - err := errAdd.NoContent() - if err == nil || err.Error() != "no content provided" { - t.Errorf("NoContent() = %v, want 'no content provided'", err) - } -} - -func TestErrNoContentProvided(t *testing.T) { - for _, fType := range []string{ - entryType.Decision, entryType.Task, - entryType.Learning, entryType.Convention, - entryType.Unknown, - } { - t.Run(fType, func(t *testing.T) { - err := errAdd.NoContentProvided(fType, example.ForType(fType)) - if err == nil { - t.Fatal("expected non-nil error") - } - msg := err.Error() - if !strings.Contains(msg, "no content provided") { - t.Errorf("error should contain 'no content provided', got: %s", msg) - } - if !strings.Contains(msg, fType) { - t.Errorf("error should contain type %q, got: %s", fType, msg) - } - }) - } -} - -func TestErrFileRead(t *testing.T) { - err := errFs.FileRead("/some/path", os.ErrNotExist) - if err == nil { - t.Fatal("expected non-nil error") - } - if !strings.Contains(err.Error(), "/some/path") { - t.Errorf("error should contain path, got: %s", err.Error()) - } -} - -func TestErrFileWrite(t *testing.T) { - err := errFs.FileWrite("/some/path", os.ErrPermission) - if err == nil { - t.Fatal("expected non-nil error") - } - if !strings.Contains(err.Error(), "/some/path") { - t.Errorf("error should contain path, got: %s", err.Error()) - } -} - -func TestErrStdinRead(t *testing.T) { - err := errFs.StdinRead(os.ErrClosed) - if err == nil { - t.Fatal("expected non-nil error") - } - if !strings.Contains(err.Error(), "stdin") { - t.Errorf("error should mention stdin, got: %s", err.Error()) - } -} - -func TestErrIndexUpdate(t *testing.T) { - err := errAdd.IndexUpdate("/some/file", os.ErrPermission) - if err == nil { - t.Fatal("expected non-nil error") - } - if !strings.Contains(err.Error(), "index") { - t.Errorf("error should mention index, got: %s", err.Error()) - } -} - -func TestErrUnknownType(t *testing.T) { - err := errAdd.UnknownType("foobar") - if err == nil { - t.Fatal("expected non-nil error") - } - msg := err.Error() - if !strings.Contains(msg, "foobar") { - t.Errorf("error should contain the type, got: %s", msg) - } - if !strings.Contains(msg, "Valid types") { - t.Errorf("error should list valid types, got: %s", msg) - } -} - -func TestErrFileNotFound(t *testing.T) { - err := errAdd.FileNotFound("/missing/file") - if err == nil { - t.Fatal("expected non-nil error") - } - msg := err.Error() - if !strings.Contains(msg, "/missing/file") { - t.Errorf("error should contain path, got: %s", msg) - } - if !strings.Contains(msg, "ctx init") { - t.Errorf("error should suggest 'ctx init', got: %s", msg) - } -} - -func TestErrMissingFields(t *testing.T) { - err := errAdd.MissingFields("decision", []string{"context", "rationale"}) - if err == nil { - t.Fatal("expected non-nil error") - } - msg := err.Error() - if !strings.Contains(msg, "decision") { - t.Errorf("error should contain entry type, got: %s", msg) - } - if !strings.Contains(msg, "context") || !strings.Contains(msg, "rationale") { - t.Errorf("error should list missing fields, got: %s", msg) - } -} - -// --------------------------------------------------------------------------- -// example.go coverage -// --------------------------------------------------------------------------- - -func TestExamplesForType(t *testing.T) { - tests := []struct { - fType string - contains string - }{ - {entryType.Decision, "ctx add decision"}, - {entryType.Task, "ctx add task"}, - {entryType.Learning, "ctx add learning"}, - {entryType.Convention, "ctx add convention"}, - {entryType.Unknown, "ctx add "}, - } - for _, tt := range tests { - t.Run(tt.fType, func(t *testing.T) { - result := example.ForType(tt.fType) - if !strings.Contains(result, tt.contains) { - t.Errorf( - "ForType(%q) should contain %q, got: %s", - tt.fType, tt.contains, result, - ) - } - }) - } -} - -// --------------------------------------------------------------------------- -// fmt.go coverage - Task with priority -// --------------------------------------------------------------------------- - -func TestFormatTaskWithPriority(t *testing.T) { - result := format.Task("My task", "high", "abc12345", "main", "68fbc00a") - if !strings.Contains(result, "#priority:high") { - t.Errorf( - "Task with priority should contain"+ - " '#priority:high', got: %s", result, - ) - } - if !strings.Contains(result, "My task") { - t.Errorf("Task should contain task content, got: %s", result) - } - if !strings.Contains(result, "#added:") { - t.Errorf("Task should contain '#added:' timestamp, got: %s", result) - } - if !strings.Contains(result, "#session:abc12345") { - t.Errorf("Task should contain '#session:abc12345', got: %s", result) - } - if !strings.Contains(result, "#branch:main") { - t.Errorf("Task should contain '#branch:main', got: %s", result) - } - if !strings.Contains(result, "#commit:68fbc00a") { - t.Errorf("Task should contain '#commit:68fbc00a', got: %s", result) - } -} - -func TestFormatTaskWithoutPriority(t *testing.T) { - result := format.Task("Simple task", "", "", "", "") - if strings.Contains(result, "#priority:") { - t.Errorf( - "Task without priority should not"+ - " contain '#priority:', got: %s", result, - ) - } - if !strings.Contains(result, "Simple task") { - t.Errorf("Task should contain task content, got: %s", result) - } - if !strings.Contains(result, "#session:unknown") { - t.Errorf("Task should contain '#session:unknown' when empty, got: %s", result) - } - if !strings.Contains(result, "#branch:unknown") { - t.Errorf("Task should contain '#branch:unknown' when empty, got: %s", result) - } - if !strings.Contains(result, "#commit:unknown") { - t.Errorf("Task should contain '#commit:unknown' when empty, got: %s", result) - } -} - -// --------------------------------------------------------------------------- -// inspect.go coverage -// --------------------------------------------------------------------------- - -func TestSkipNewline(t *testing.T) { - tests := []struct { - name string - s string - pos int - want int - }{ - {"LF", "abc\ndef", 3, 4}, - {"CRLF", "abc\r\ndef", 3, 5}, - {"no newline", "abcdef", 3, 3}, - {"at end", "abc", 3, 3}, - {"past end", "abc", 5, 5}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := inspect.SkipNewline(tt.s, tt.pos) - if got != tt.want { - t.Errorf("SkipNewline(%q, %d) = %d, want %d", tt.s, tt.pos, got, tt.want) - } - }) - } -} - -func TestSkipWhitespace(t *testing.T) { - tests := []struct { - name string - s string - pos int - want int - }{ - {"spaces", " abc", 0, 3}, - {"tabs", "\t\tabc", 0, 2}, - {"newlines", "\n\nabc", 0, 2}, - {"mixed", " \t\n abc", 0, 4}, - {"crlf", "\r\n\r\nabc", 0, 4}, - {"none", "abc", 0, 0}, - {"at end", "abc ", 3, 6}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := inspect.SkipWhitespace(tt.s, tt.pos) - if got != tt.want { - t.Errorf("SkipWhitespace(%q, %d) = %d, want %d", tt.s, tt.pos, got, tt.want) - } - }) - } -} - -func TestFindNewline(t *testing.T) { - tests := []struct { - name string - s string - want int - }{ - {"LF", "abc\ndef", 3}, - {"CRLF", "abc\r\ndef", 3}, - {"none", "abcdef", -1}, - {"empty", "", -1}, - {"starts with LF", "\nabc", 0}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := inspect.FindNewline(tt.s) - if got != tt.want { - t.Errorf("FindNewline(%q) = %d, want %d", tt.s, got, tt.want) - } - }) - } -} - -// --------------------------------------------------------------------------- -// strings.go coverage - ContainsEndComment -// --------------------------------------------------------------------------- - -func TestContainsEndComment(t *testing.T) { - t.Run("found", func(t *testing.T) { - found, idx := inspect.ContainsEndComment("some text --> more") - if !found { - t.Error("expected to find comment close marker") - } - if idx != 10 { - t.Errorf("expected index 10, got %d", idx) - } - }) - - t.Run("not found", func(t *testing.T) { - found, idx := inspect.ContainsEndComment("no comment close here") - if found { - t.Error("should not find comment close marker") - } - if idx != -1 { - t.Errorf("expected index -1, got %d", idx) - } - }) -} - -// --------------------------------------------------------------------------- -// normalize.go coverage - TargetSection both branches -// --------------------------------------------------------------------------- - -func TestNormalizeTargetSection(t *testing.T) { - t.Run("without prefix", func(t *testing.T) { - result := normalize.TargetSection("Phase 1") - if result != "### Phase 1" { - t.Errorf("expected '### Phase 1', got %q", result) - } - }) - - t.Run("with prefix", func(t *testing.T) { - result := normalize.TargetSection("### Phase 1") - if result != "### Phase 1" { - t.Errorf("expected '### Phase 1', got %q", result) - } - }) -} - -// --------------------------------------------------------------------------- -// insert.go coverage - edge cases -// --------------------------------------------------------------------------- - -func TestInsertAfterHeader_NoHeader(t *testing.T) { - content := "Some content without any matching header\n" - entry := "- New entry\n" - - result := insert.AfterHeader(content, entry, "# Missing Header") - resultStr := string(result) - - if !strings.Contains(resultStr, "New entry") { - t.Error("entry should be appended when header not found") - } -} - -func TestInsertAfterHeader_HeaderAtEndOfFile(t *testing.T) { - // Header exists but no newline after it (file ends with header line) - content := "# Heading" - entry := "- New entry\n" - - result := insert.AfterHeader(content, entry, "# Heading") - resultStr := string(result) - - if !strings.Contains(resultStr, "New entry") { - t.Error("entry should be appended when header has no newline after") - } -} - -func TestInsertAfterHeader_WithCtxMarkers(t *testing.T) { - content := "# Learnings\n" + - marker.CtxStart + "\nsome context\n" + marker.CommentClose + "\n\n" + - "## [2026-01-01] Existing\n" - entry := "## [2026-01-02] New\n" - - // The header "# Learnings" is found, then markers are skipped - heading := desc.Text(text.DescKeyHeadingLearnings) - result := insert.AfterHeader(content, entry, heading) - resultStr := string(result) - - if !strings.Contains(resultStr, "New") { - t.Errorf("entry not found in result: %s", resultStr) - } -} - -func TestInsertAfterHeader_CtxMarkerWithoutClose(t *testing.T) { - // ctx marker start present but no close marker - content := "# Learnings\n" + - marker.CtxStart + - "\nunclosed marker content\nExisting\n" - entry := "## New entry\n" - - heading := desc.Text(text.DescKeyHeadingLearnings) - result := insert.AfterHeader(content, entry, heading) - resultStr := string(result) - - if !strings.Contains(resultStr, "New entry") { - t.Errorf("entry not found in result: %s", resultStr) - } -} - -func TestAppendAtEnd_WithNewline(t *testing.T) { - result := insert.AppendAtEnd("content\n", "entry\n") - resultStr := string(result) - if !strings.Contains(resultStr, "entry") { - t.Error("entry should be appended") - } -} - -func TestAppendAtEnd_WithoutNewline(t *testing.T) { - result := insert.AppendAtEnd("content", "entry\n") - resultStr := string(result) - if !strings.Contains(resultStr, "entry") { - t.Error("entry should be appended") - } - // content should get a newline added before the entry - if !strings.Contains(resultStr, "content\n") { - t.Errorf("content should end with newline, got: %q", resultStr) - } -} - -func TestInsertTask_NoPendingNoNewline(t *testing.T) { - // No unchecked tasks and no trailing newline - existing := "# Tasks\n\n- [x] Done task" - entry := "- [ ] New task\n" - - result := insert.Task(entry, existing, "") - resultStr := string(result) - - if !strings.Contains(resultStr, "New task") { - t.Errorf("new task not found in result: %s", resultStr) - } -} - -func TestInsertTaskAfterSection_SectionNotFound(t *testing.T) { - content := "# Tasks\n\n- [x] Done\n" - entry := "- [ ] New task\n" - - result := insert.TaskAfterSection(entry, content, "Missing Section") - resultStr := string(result) - - if !strings.Contains(resultStr, "New task") { - t.Error("entry should be appended when section not found") - } - if !strings.Contains(resultStr, "### Missing Section") { - t.Error("section header should be created when not found") - } -} - -func TestInsertTaskAfterSection_SectionAtEnd(t *testing.T) { - // Section header at end of file without trailing newline after it - content := "# Tasks\n\n### Phase 1" - entry := "- [ ] New task\n" - - result := insert.TaskAfterSection(entry, content, "Phase 1") - resultStr := string(result) - - if !strings.Contains(resultStr, "New task") { - t.Errorf("entry not found in result: %s", resultStr) - } -} - -func TestInsertTaskAfterSection_ContentNoNewline(t *testing.T) { - // Section not found and no trailing newline - content := "# Tasks" - entry := "- [ ] New task\n" - - result := insert.TaskAfterSection(entry, content, "Missing") - resultStr := string(result) - - if !strings.Contains(resultStr, "New task") { - t.Error("entry should be appended") - } -} - -// --------------------------------------------------------------------------- -// content.go coverage - Content -// --------------------------------------------------------------------------- - -func TestExtractContent_FromFile(t *testing.T) { - tmpFile := filepath.Join(t.TempDir(), "content.txt") - if err := os.WriteFile(tmpFile, []byte(" file content "), 0600); err != nil { - t.Fatal(err) - } - - cfg := entity.AddConfig{FromFile: tmpFile} - content, err := extract.Content([]string{"task"}, cfg) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if content != "file content" { - t.Errorf("expected 'file content', got %q", content) - } -} - -func TestExtractContent_FromFileMissing(t *testing.T) { - cfg := entity.AddConfig{FromFile: "/nonexistent/file"} - _, err := extract.Content([]string{"task"}, cfg) - if err == nil { - t.Fatal("expected error for missing file") - } -} - -func TestExtractContent_FromArgs(t *testing.T) { - content, err := extract.Content( - []string{"task", "hello", "world"}, - entity.AddConfig{}, - ) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if content != "hello world" { - t.Errorf("expected 'hello world', got %q", content) - } -} - -func TestExtractContent_NoContent(t *testing.T) { - // Only one arg (the type), no file, and stdin is not a pipe in tests - _, err := extract.Content([]string{"task"}, entity.AddConfig{}) - if err == nil { - t.Fatal("expected error when no content source") - } -} - -// --------------------------------------------------------------------------- -// run.go coverage - ValidateEntry -// --------------------------------------------------------------------------- - -func TestValidateEntry(t *testing.T) { - t.Run("empty content", func(t *testing.T) { - err := entry.Validate(entity.EntryParams{Type: "task", Content: ""}, nil) - if err == nil { - t.Fatal("expected error for empty content") - } - if !strings.Contains(err.Error(), "no content provided") { - t.Errorf("unexpected error: %v", err) - } - }) - - t.Run("valid task", func(t *testing.T) { - p := entity.EntryParams{Type: "task", Content: "Do something", Section: "Misc", SessionID: "test1234", Branch: "main", Commit: "abc123"} - err := entry.Validate(p, nil) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - }) - - t.Run("task missing section", func(t *testing.T) { - p := entity.EntryParams{Type: "task", Content: "Do something"} - err := entry.Validate(p, nil) - if err == nil { - t.Fatal("expected error for missing section") - } - if !strings.Contains(err.Error(), "--section") { - t.Errorf("error should mention --section: %v", err) - } - }) - - t.Run("valid convention", func(t *testing.T) { - p := entity.EntryParams{Type: "convention", Content: "Use camelCase"} - err := entry.Validate(p, nil) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - }) - - t.Run("decision missing fields", func(t *testing.T) { - err := entry.Validate(entity.EntryParams{ - Type: "decision", - Content: "Some decision", - }, nil) - if err == nil { - t.Fatal("expected error for missing decision fields") - } - msg := err.Error() - if !strings.Contains(msg, "context") { - t.Errorf("error should mention missing context: %s", msg) - } - }) - - t.Run("decision valid", func(t *testing.T) { - err := entry.Validate(entity.EntryParams{ - Type: "decision", - Content: "Use Go", - SessionID: "test1234", - Branch: "main", - Commit: "abc123", - Context: "Need a language", - Rationale: "Go is fast", - Consequence: "Need training", - }, nil) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - }) - - t.Run("learning missing fields", func(t *testing.T) { - err := entry.Validate(entity.EntryParams{ - Type: "learning", - Content: "Some learning", - }, nil) - if err == nil { - t.Fatal("expected error for missing learning fields") - } - msg := err.Error() - if !strings.Contains(msg, "context") { - t.Errorf("error should mention missing context: %s", msg) - } - }) - - t.Run("learning valid", func(t *testing.T) { - err := entry.Validate(entity.EntryParams{ - Type: "learning", - Content: "Go embed", - SessionID: "test1234", - Branch: "main", - Commit: "abc123", - Context: "Tried embedding", - Lesson: "Same dir only", - Application: "Keep files local", - }, nil) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - }) -} - -// --------------------------------------------------------------------------- -// run.go coverage - WriteEntry error paths -// --------------------------------------------------------------------------- - -func TestWriteEntry_UnknownType(t *testing.T) { - err := entry.Write(entity.EntryParams{ - Type: "foobar", - Content: "something", - }) - if err == nil { - t.Fatal("expected error for unknown type") - } - if !strings.Contains(err.Error(), "foobar") { - t.Errorf("error should mention the unknown type, got: %v", err) - } -} - -func TestWriteEntry_FileNotFound(t *testing.T) { - tmpDir := t.TempDir() - origDir, _ := os.Getwd() - if err := os.Chdir(tmpDir); err != nil { - t.Fatal(err) - } - defer func() { _ = os.Chdir(origDir) }() - - // Declare a non-existent context dir so we hit "file not found" - // rather than "context directory not declared". - t.Setenv("CTX_DIR", filepath.Join(tmpDir, ".context")) - rc.Reset() - t.Cleanup(rc.Reset) - - err := entry.Write(entity.EntryParams{ - Type: "task", - Content: "something", - }) - if err == nil { - t.Fatal("expected error for missing context file") - } - if !strings.Contains(err.Error(), "not found") { - t.Errorf("error should mention file not found, got: %v", err) - } -} - -// --------------------------------------------------------------------------- -// run.go coverage - Run with unknown type -// --------------------------------------------------------------------------- - -func TestRun_UnknownType(t *testing.T) { - tmpDir := t.TempDir() - origDir, _ := os.Getwd() - if err := os.Chdir(tmpDir); err != nil { - t.Fatal(err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err := initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - addCmd := &cobra.Command{} - addCmd.SetOut(&strings.Builder{}) - addCmd.SetErr(&strings.Builder{}) - err := root.Run( - addCmd, - []string{"invalidtype", "Some content"}, - entity.AddConfig{}, - ) - if err == nil { - t.Fatal("expected error for unknown type") - } -} - -// --------------------------------------------------------------------------- -// run.go coverage - Run with no content (only type arg, no file/stdin) -// --------------------------------------------------------------------------- - -func TestRun_NoContent(t *testing.T) { - tmpDir := t.TempDir() - origDir, _ := os.Getwd() - if err := os.Chdir(tmpDir); err != nil { - t.Fatal(err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err := initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - addCmd := &cobra.Command{} - addCmd.SetOut(&strings.Builder{}) - addCmd.SetErr(&strings.Builder{}) - err := root.Run(addCmd, []string{"task"}, entity.AddConfig{}) - if err == nil { - t.Fatal("expected error when no content provided") - } - if !strings.Contains(err.Error(), "no content provided") { - t.Errorf("expected 'no content provided' error, got: %v", err) - } -} - -// --------------------------------------------------------------------------- -// run.go coverage - task with priority via Run -// --------------------------------------------------------------------------- - -func TestRun_TaskWithPriority(t *testing.T) { - tmpDir := t.TempDir() - origDir, _ := os.Getwd() - if err := os.Chdir(tmpDir); err != nil { - t.Fatal(err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err := initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - addCmd := &cobra.Command{} - addCmd.SetOut(&strings.Builder{}) - addCmd.SetErr(&strings.Builder{}) - err := root.Run( - addCmd, - []string{"task", "High priority task"}, - entity.AddConfig{Priority: "high", Section: "Misc", SessionID: "test1234", Branch: "main", Commit: "abc123"}, - ) - if err != nil { - t.Fatalf("Run task with priority failed: %v", err) - } - - content, readErr := os.ReadFile(".context/TASKS.md") - if readErr != nil { - t.Fatalf("failed to read TASKS.md: %v", readErr) - } - if !strings.Contains(string(content), "#priority:high") { - t.Error("task with priority should contain '#priority:high'") - } -} - -// --------------------------------------------------------------------------- -// run.go coverage - task with section -// --------------------------------------------------------------------------- - -func TestRun_TaskWithSection(t *testing.T) { - tmpDir := t.TempDir() - origDir, _ := os.Getwd() - if err := os.Chdir(tmpDir); err != nil { - t.Fatal(err) - } - defer func() { _ = os.Chdir(origDir) }() - - testctx.Declare(t, tmpDir) - - initCmd := initialize.Cmd() - initCmd.SetArgs([]string{}) - if err := initCmd.Execute(); err != nil { - t.Fatalf("init failed: %v", err) - } - - addCmd := &cobra.Command{} - addCmd.SetOut(&strings.Builder{}) - addCmd.SetErr(&strings.Builder{}) - err := root.Run( - addCmd, - []string{"task", "Sectioned task"}, - entity.AddConfig{Section: "Next Up", SessionID: "test1234", Branch: "main", Commit: "abc123"}, - ) - if err != nil { - t.Fatalf("Run task with section failed: %v", err) - } - - content, readErr := os.ReadFile(".context/TASKS.md") - if readErr != nil { - t.Fatalf("failed to read TASKS.md: %v", readErr) - } - if !strings.Contains(string(content), "Sectioned task") { - t.Error("task should be added to TASKS.md") - } -} - -// --------------------------------------------------------------------------- -// Predicate coverage (already at 100% but ensure plural forms work) -// --------------------------------------------------------------------------- - -func TestPredicates(t *testing.T) { - // Test plural forms - if !coreEntry.FileTypeIsTask("tasks") { - t.Error("FileTypeIsTask should accept 'tasks'") - } - if !coreEntry.FileTypeIsDecision("decisions") { - t.Error("FileTypeIsDecision should accept 'decisions'") - } - if !coreEntry.FileTypeIsLearning("learnings") { - t.Error("FileTypeIsLearning should accept 'learnings'") - } - // Test negative cases - if coreEntry.FileTypeIsTask("decision") { - t.Error("FileTypeIsTask should reject 'decision'") - } - if coreEntry.FileTypeIsDecision("task") { - t.Error("FileTypeIsDecision should reject 'task'") - } - if coreEntry.FileTypeIsLearning("convention") { - t.Error("FileTypeIsLearning should reject 'convention'") - } -} - -// --------------------------------------------------------------------------- -// strings.go coverage - EndsWithNewline edge cases -// --------------------------------------------------------------------------- - -func TestEndsWithNewline(t *testing.T) { - tests := []struct { - name string - s string - want bool - }{ - {"LF", "content\n", true}, - {"CRLF", "content\r\n", true}, - {"no newline", "content", false}, - {"empty", "", false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := inspect.EndsWithNewline(tt.s) - if got != tt.want { - t.Errorf("EndsWithNewline(%q) = %v, want %v", tt.s, got, tt.want) - } - }) - } -} - -func TestContains(t *testing.T) { - t.Run("found", func(t *testing.T) { - found, idx := inspect.Contains("hello world", "world") - if !found || idx != 6 { - t.Errorf("Contains() = (%v, %d), want (true, 6)", found, idx) - } - }) - t.Run("not found", func(t *testing.T) { - found, idx := inspect.Contains("hello", "world") - if found || idx != -1 { - t.Errorf("Contains() = (%v, %d), want (false, -1)", found, idx) - } - }) -} - -func TestContainsNewLine(t *testing.T) { - t.Run("found", func(t *testing.T) { - found, idx := inspect.ContainsNewLine("abc\ndef") - if !found || idx != 3 { - t.Errorf("ContainsNewLine() = (%v, %d), want (true, 3)", found, idx) - } - }) - t.Run("not found", func(t *testing.T) { - found, idx := inspect.ContainsNewLine("abcdef") - if found || idx != -1 { - t.Errorf("ContainsNewLine() = (%v, %d), want (false, -1)", found, idx) - } - }) -} - -func TestStartsWithCtxMarker(t *testing.T) { - if !inspect.StartsWithCtxMarker(marker.CtxStart + " rest") { - t.Error("should detect CtxStart") - } - if !inspect.StartsWithCtxMarker(marker.CtxEnd + " rest") { - t.Error("should detect CtxEnd") - } - if inspect.StartsWithCtxMarker("no marker here") { - t.Error("should not detect marker in plain text") - } -} diff --git a/internal/cli/add/cmd/doc.go b/internal/cli/add/cmd/doc.go deleted file mode 100644 index 8cd925bdc..000000000 --- a/internal/cli/add/cmd/doc.go +++ /dev/null @@ -1,41 +0,0 @@ -// / ctx: https://ctx.ist -// ,'`./ do you remember? -// `.,'\\ -// \ Copyright 2026-present Context contributors. -// SPDX-License-Identifier: Apache-2.0 - -// Package cmd wires the cobra subcommands for the -// "ctx add" command tree. -// -// # Purpose -// -// This package registers the root add command and its -// type-specific subcommands under a single parent. -// Each subcommand delegates to [root.Run] with flags -// that control which context file receives the entry. -// -// # Subcommand Registration -// -// The package imports and wires the root subcommand -// from the root/ child package. The root command -// accepts a positional type argument (task, decision, -// learning, convention) and dispatches accordingly. -// -// # Entry Types -// -// Supported entry types and their target files: -// -// - task -> TASKS.md -// - decision -> DECISIONS.md -// - learning -> LEARNINGS.md -// - convention -> CONVENTIONS.md -// -// Both singular and plural forms are accepted. -// -// # Output -// -// On success the command prints a confirmation line -// naming the file that was updated. When --share is -// set it also publishes the entry to a connected -// ctx Hub instance. -package cmd diff --git a/internal/cli/add/cmd/root/doc.go b/internal/cli/add/cmd/root/doc.go deleted file mode 100644 index d7440208b..000000000 --- a/internal/cli/add/cmd/root/doc.go +++ /dev/null @@ -1,39 +0,0 @@ -// / ctx: https://ctx.ist -// ,'`./ do you remember? -// `.,'\ -// \ Copyright 2026-present Context contributors. -// SPDX-License-Identifier: Apache-2.0 - -// Package root implements **`ctx add`**, the command -// that adds a new entry (task / decision / learning / -// convention) to the corresponding `.context/` file with -// validated provenance, canonical formatting, and an -// auto-updated index table. -// -// # Public Surface -// -// - **[Cmd]**: cobra command with the type -// selector (`-t task|decision|learning|convention`) -// plus type-specific flags (`--priority`, -// `--rationale`, `--consequence`, `--lesson`, -// `--branch`, `--commit`, `--session-id`, -// `--from-file`, `--application`, etc.). -// - **[Run]**: validates the supplied flags -// against the type's required-fields list, -// extracts content from positional args or -// `--from-file`, formats the entry via the -// `core/format` siblings, and inserts it via -// [internal/cli/add/core/insert]. -// -// # Validation Boundaries -// -// All hard checks (required fields, secret patterns, -// length limits, provenance requirements per -// `.ctxrc`) live in [internal/entry] so the rules -// are identical regardless of caller (CLI here, MCP -// `ctx_add` tool elsewhere). -// -// # Concurrency -// -// Single-process, sequential. -package root diff --git a/internal/cli/add/cmd/testmain_test.go b/internal/cli/add/cmd/testmain_test.go deleted file mode 100644 index 22e548d80..000000000 --- a/internal/cli/add/cmd/testmain_test.go +++ /dev/null @@ -1,19 +0,0 @@ -// / ctx: https://ctx.ist -// ,'`./ do you remember? -// `.,'\\ -// \ Copyright 2026-present Context contributors. -// SPDX-License-Identifier: Apache-2.0 - -package cmd - -import ( - "os" - "testing" - - "github.com/ActiveMemory/ctx/internal/assets/read/lookup" -) - -func TestMain(m *testing.M) { - lookup.Init() - os.Exit(m.Run()) -} diff --git a/internal/cli/add/cmd/root/cmd.go b/internal/cli/add/core/build/build.go similarity index 64% rename from internal/cli/add/cmd/root/cmd.go rename to internal/cli/add/core/build/build.go index 0fa32977f..137e92df5 100644 --- a/internal/cli/add/cmd/root/cmd.go +++ b/internal/cli/add/core/build/build.go @@ -4,39 +4,33 @@ // \ Copyright 2026-present Context contributors. // SPDX-License-Identifier: Apache-2.0 -package root +package build import ( "github.com/spf13/cobra" "github.com/ActiveMemory/ctx/internal/assets/read/desc" - "github.com/ActiveMemory/ctx/internal/config/embed/cmd" + "github.com/ActiveMemory/ctx/internal/cli/add/core/run" "github.com/ActiveMemory/ctx/internal/config/embed/flag" - "github.com/ActiveMemory/ctx/internal/config/entry" + cfgEntry "github.com/ActiveMemory/ctx/internal/config/entry" cFlag "github.com/ActiveMemory/ctx/internal/config/flag" "github.com/ActiveMemory/ctx/internal/entity" "github.com/ActiveMemory/ctx/internal/flagbind" ) -// Cmd returns the "ctx add" command for appending entries to context files. +// Cmd builds a cobra add subcommand for the given noun. // -// Supported types are defined in [config.FileType] (both singular and plural -// forms accepted, e.g., "decision" or "decisions"). Content can be provided -// via command argument, --file flag, or stdin pipe. -// -// Flags: -// - --priority, -p: Priority level for tasks (high, medium, low) -// - --section, -s: Target section within the file -// - --file, -f: Read content from a file instead of argument -// - --context, -c: Context for decisions/learnings (required) -// - --rationale, -r: Rationale for decisions (required for decisions) -// - --consequence: Consequence for decisions (required for decisions) -// - --lesson, -l: Lesson for learnings (required for learnings) -// - --application, -a: Application for learnings (required for learnings) +// Parameters: +// - noun: One of entry.{Task,Decision,Learning,Convention}. +// Prepended to args before invoking run.Run. +// - descKey: Description key for the embedded asset lookup +// (e.g., "task.add", "decision.add"). +// - useStr: Cobra Use string (typically "add [content]"). // // Returns: -// - *cobra.Command: Configured add command with flags registered -func Cmd() *cobra.Command { +// - *cobra.Command: Configured add subcommand with all flags +// registered. +func Cmd(noun, descKey, useStr string) *cobra.Command { var ( priority string section string @@ -52,22 +46,16 @@ func Cmd() *cobra.Command { share bool ) - short, long := desc.Command(cmd.DescKeyAdd) + short, long := desc.Command(descKey) c := &cobra.Command{ - Use: cmd.UseAdd, + Use: useStr, Short: short, Long: long, - Example: desc.Example(cmd.DescKeyAdd), - Args: cobra.MinimumNArgs(1), - ValidArgs: []string{ - entry.Task, - entry.Decision, - entry.Learning, - entry.Convention, - }, + Example: desc.Example(descKey), RunE: func(cmd *cobra.Command, args []string) error { - return Run(cmd, args, entity.AddConfig{ + withNoun := append([]string{noun}, args...) + return run.Run(cmd, withNoun, entity.AddConfig{ Priority: priority, Section: section, FromFile: fromFile, @@ -129,7 +117,7 @@ func Cmd() *cobra.Command { cFlag.Priority, func( _ *cobra.Command, _ []string, _ string, ) ([]string, cobra.ShellCompDirective) { - return entry.Priorities, + return cfgEntry.Priorities, cobra.ShellCompDirectiveNoFileComp }) diff --git a/internal/cli/add/core/build/doc.go b/internal/cli/add/core/build/doc.go new file mode 100644 index 000000000..79955993f --- /dev/null +++ b/internal/cli/add/core/build/doc.go @@ -0,0 +1,26 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package build assembles a cobra add subcommand bound to a +// specific noun (task / decision / learning / convention). +// +// Each noun-first parent (ctx task, ctx decision, ctx +// learning, ctx convention) registers an add subcommand by +// calling [Cmd] with its noun, description key, and Use +// string. The returned command shares all flag wiring and +// completion logic; the noun is prepended to the args slice +// before delegating to [run.Run]. +// +// # Why a Builder? +// +// Without this helper each noun's cmd/add package would have +// to duplicate ~100 lines of cobra flag wiring (priority, +// section, file, context, rationale, consequence, lesson, +// application, session-id, branch, commit, share, plus +// completion). Centralizing here keeps the per-noun adapter +// down to a single Cmd() that selects the right description +// key. +package build diff --git a/internal/cli/add/core/normalize/doc.go b/internal/cli/add/core/normalize/doc.go index c8f867d46..e3f0a504b 100644 --- a/internal/cli/add/core/normalize/doc.go +++ b/internal/cli/add/core/normalize/doc.go @@ -24,7 +24,7 @@ // // A user runs: // -// ctx add task "fix tests" --section "Phase 1" +// ctx task add "fix tests" --section "Phase 1" // // The insert subpackage calls TargetSection("Phase 1") // which returns "## Phase 1". The insert logic then diff --git a/internal/cli/add/core/run/doc.go b/internal/cli/add/core/run/doc.go new file mode 100644 index 000000000..978f63970 --- /dev/null +++ b/internal/cli/add/core/run/doc.go @@ -0,0 +1,33 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package run provides the shared add execution logic invoked +// by every noun-first add subcommand (ctx task add, ctx +// decision add, ctx learning add, ctx convention add). +// +// The function is split out from the noun cobra wiring so all +// four noun packages can call into the same validation, +// extraction, formatting, insertion, and trace-recording +// pipeline without duplicating it. +// +// # Public Surface +// +// - [Run] executes one add operation. Caller passes the +// noun as args[0] (followed by any positional content +// tokens) and an entity.AddConfig with the resolved +// flag values. +// +// # Validation Boundaries +// +// Hard checks (required fields, secret patterns, length +// limits, provenance requirements per .ctxrc) live in +// [internal/entry] so the rules are identical regardless of +// caller (CLI here, MCP ctx_add tool elsewhere). +// +// # Concurrency +// +// Single-process, sequential. +package run diff --git a/internal/cli/add/cmd/root/run.go b/internal/cli/add/core/run/run.go similarity index 80% rename from internal/cli/add/cmd/root/run.go rename to internal/cli/add/core/run/run.go index cf588fd6e..48516017a 100644 --- a/internal/cli/add/cmd/root/run.go +++ b/internal/cli/add/core/run/run.go @@ -4,7 +4,7 @@ // \ Copyright 2026-present Context contributors. // SPDX-License-Identifier: Apache-2.0 -package root +package run import ( "path/filepath" @@ -29,19 +29,22 @@ import ( writeConnect "github.com/ActiveMemory/ctx/internal/write/connect" ) -// Run executes the add command logic. +// Run executes the add command logic for the four noun-first +// add subcommands. // -// Reads content from the specified source (argument, file, or stdin), -// validates the entry, and writes it to the appropriate context file. +// Reads content from the specified source (argument, file, or +// stdin), validates the entry, and writes it to the appropriate +// context file. // // Parameters: // - cmd: Cobra command for output -// - args: Command arguments; args[0] is the entry type, args[1:] is content +// - args: Command arguments; args[0] is the entry type +// (task/decision/learning/convention) and args[1:] is content // - flags: All flag values from the command // // Returns: -// - error: Non-nil if content is missing, type is invalid, required flags -// are missing, or file operations fail +// - error: Non-nil if content is missing, type is invalid, +// required flags are missing, or file operations fail func Run(cmd *cobra.Command, args []string, flags entity.AddConfig) error { if _, ctxErr := rc.RequireContextDir(); ctxErr != nil { cmd.SilenceUsage = true @@ -91,7 +94,6 @@ func Run(cmd *cobra.Command, args []string, flags entity.AddConfig) error { return dirErr } - // Best-effort: publish to ctx Hub if --share is set. if flags.Share { pubEntry := hub.PublishEntry{ Type: fType, @@ -109,10 +111,6 @@ func Run(cmd *cobra.Command, args []string, flags entity.AddConfig) error { writeAdd.SpecNudge(cmd) } - // Best-effort: record pending context for commit tracing. - // Decisions and learnings are prepended (see insert.AppendEntry), - // so the new entry is always #1 in file order. This coupling is - // intentional: if the prepend logic changes, this must be updated. if fType == cfgEntry.Decision || fType == cfgEntry.Learning { _ = trace.Record(fType+cfgTrace.RefFirstEntry, stateDir) } diff --git a/internal/cli/add/doc.go b/internal/cli/add/doc.go index f6d900308..8b0509123 100644 --- a/internal/cli/add/doc.go +++ b/internal/cli/add/doc.go @@ -4,35 +4,20 @@ // \ Copyright 2026-present Context contributors. // SPDX-License-Identifier: Apache-2.0 -// Package add provides the "ctx add" command for appending -// entries to context files. -// -// The add command is the primary write interface for -// populating .context/ files. It accepts content via -// positional argument, --file flag, or stdin pipe and -// routes entries to the appropriate file based on the -// entry type argument. -// -// # Supported Entry Types -// -// Entry types map to [config.FileType] values: -// -// - decision / decisions: appends to DECISIONS.md -// - task / tasks: inserts into TASKS.md before the -// first unchecked item, or under a named section -// when --section is provided -// - learning / learnings: appends to LEARNINGS.md -// - convention / conventions: appends to CONVENTIONS.md -// -// # Example Usage -// -// ctx add decision "Use PostgreSQL for primary DB" -// ctx add task "Implement auth" --section "Phase 1" -// ctx add learning --file notes.md -// echo "Use camelCase" | ctx add convention -// -// # Subpackages -// -// - cmd/root: cobra command definition and flag binding -// - core: file-type routing and content insertion logic +// Package add hosts the shared core libraries that power +// every noun-first add subcommand: +// +// - ctx task add (internal/cli/task/cmd/add) +// - ctx decision add (internal/cli/decision/cmd/add) +// - ctx learning add (internal/cli/learning/cmd/add) +// - ctx convention add (internal/cli/convention/cmd/add) +// +// The directory contains no Go source at the top level. Its +// child package core/ groups validation, content extraction, +// markdown formatting, section-aware insertion, and section +// normalization, plus the build/ helper that assembles a +// noun-bound cobra command and the run/ entry point that +// executes the add pipeline. The verb-first ctx add parent +// was retired by specs/cli-add-symmetry.md; this directory +// remains as a logical home for the shared add machinery. package add diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index f3206c686..e9db11ffe 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -131,10 +131,10 @@ func TestBinaryIntegration(t *testing.T) { } }) - // Subtest: ctx add learning modifies LEARNINGS.md - t.Run("add learning modifies LEARNINGS.md", func(t *testing.T) { + // Subtest: ctx learning add modifies LEARNINGS.md + t.Run("learning add modifies LEARNINGS.md", func(t *testing.T) { addCmd := exec.Command(binaryPath, //nolint:gosec // test binary - "add", "learning", + "learning", "add", "Test learning from integration test", "--session-id", "test1234", "--branch", "main", "--commit", "abc123", "--context", "Testing integration", @@ -143,7 +143,7 @@ func TestBinaryIntegration(t *testing.T) { ) addCmd.Dir = testDir if output, err := addCmd.CombinedOutput(); err != nil { - t.Fatalf("ctx add learning failed: %v\n%s", err, output) + t.Fatalf("ctx learning add failed: %v\n%s", err, output) } // Verify learning was added diff --git a/internal/cli/compact/compact_test.go b/internal/cli/compact/compact_test.go index 8a1285b8e..96e362176 100644 --- a/internal/cli/compact/compact_test.go +++ b/internal/cli/compact/compact_test.go @@ -10,8 +10,8 @@ import ( "os" "testing" - "github.com/ActiveMemory/ctx/internal/cli/add" "github.com/ActiveMemory/ctx/internal/cli/initialize" + taskAdd "github.com/ActiveMemory/ctx/internal/cli/task/cmd/add" taskComplete "github.com/ActiveMemory/ctx/internal/cli/task/cmd/complete" "github.com/ActiveMemory/ctx/internal/testutil/testctx" ) @@ -71,8 +71,8 @@ func TestCompactWithTasks(t *testing.T) { } // Add and complete a task - addCmd := add.Cmd() - addCmd.SetArgs([]string{"task", "Task to complete", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) + addCmd := taskAdd.Cmd() + addCmd.SetArgs([]string{"Task to complete", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) if err := addCmd.Execute(); err != nil { t.Fatalf("add task failed: %v", err) } diff --git a/internal/cli/convention/cmd/add/add_test.go b/internal/cli/convention/cmd/add/add_test.go new file mode 100644 index 000000000..d5959467c --- /dev/null +++ b/internal/cli/convention/cmd/add/add_test.go @@ -0,0 +1,54 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "os" + "strings" + "testing" + + "github.com/ActiveMemory/ctx/internal/cli/initialize" + "github.com/ActiveMemory/ctx/internal/testutil/testctx" +) + +// TestConventionAdd verifies the noun-first ctx convention add +// subcommand writes an entry to CONVENTIONS.md. +func TestConventionAdd(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-convention-add-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{"Use camelCase for variable names"}) + if err = addCmd.Execute(); err != nil { + t.Fatalf("ctx convention add failed: %v", err) + } + + content, err := os.ReadFile(".context/CONVENTIONS.md") + if err != nil { + t.Fatalf("failed to read CONVENTIONS.md: %v", err) + } + if !strings.Contains(string(content), "Use camelCase for variable names") { + t.Error("convention was not added to CONVENTIONS.md") + } +} diff --git a/internal/cli/convention/cmd/add/cmd.go b/internal/cli/convention/cmd/add/cmd.go new file mode 100644 index 000000000..5ae3d44c2 --- /dev/null +++ b/internal/cli/convention/cmd/add/cmd.go @@ -0,0 +1,30 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "github.com/spf13/cobra" + + "github.com/ActiveMemory/ctx/internal/cli/add/core/build" + "github.com/ActiveMemory/ctx/internal/config/embed/cmd" + "github.com/ActiveMemory/ctx/internal/config/entry" +) + +// Cmd returns the "ctx convention add" subcommand. +// +// Adds a new convention entry to CONVENTIONS.md. +// Implementation lives in the shared add core. +// +// Returns: +// - *cobra.Command: Configured convention add subcommand +func Cmd() *cobra.Command { + return build.Cmd( + entry.Convention, + cmd.DescKeyConventionAdd, + cmd.UseConventionAdd, + ) +} diff --git a/internal/cli/convention/cmd/add/doc.go b/internal/cli/convention/cmd/add/doc.go new file mode 100644 index 000000000..cfb78c969 --- /dev/null +++ b/internal/cli/convention/cmd/add/doc.go @@ -0,0 +1,15 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package add wires the cobra "ctx convention add" subcommand. +// +// The cobra wiring delegates entirely to the shared add core +// at internal/cli/add/core/build, which constructs a fully +// configured add command bound to entry.Convention. This +// package exists only to keep the noun-first command tree +// uniform: every artifact noun owns its own cmd/add child, +// even when the parent has no other subcommands today. +package add diff --git a/internal/cli/convention/convention.go b/internal/cli/convention/convention.go new file mode 100644 index 000000000..542588f83 --- /dev/null +++ b/internal/cli/convention/convention.go @@ -0,0 +1,29 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package convention + +import ( + "github.com/spf13/cobra" + + "github.com/ActiveMemory/ctx/internal/cli/convention/cmd/add" + "github.com/ActiveMemory/ctx/internal/cli/parent" + "github.com/ActiveMemory/ctx/internal/config/embed/cmd" +) + +// Cmd returns the convention command with subcommands. +// +// The convention command provides utilities for managing the +// CONVENTIONS.md file, currently limited to adding new +// entries via "ctx convention add". +// +// Returns: +// - *cobra.Command: The convention command with subcommands +func Cmd() *cobra.Command { + return parent.Cmd(cmd.DescKeyConvention, cmd.UseConvention, + add.Cmd(), + ) +} diff --git a/internal/cli/convention/doc.go b/internal/cli/convention/doc.go new file mode 100644 index 000000000..68ac90513 --- /dev/null +++ b/internal/cli/convention/doc.go @@ -0,0 +1,15 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package convention exposes the "ctx convention" command +// tree. +// +// Subcommands operate on CONVENTIONS.md, the +// project-conventions store under .context/. The current +// surface is just "ctx convention add"; future operations +// (such as a quick-reference reindex, mirroring decision and +// learning) plug in here. +package convention diff --git a/internal/cli/decision/cmd/add/add_test.go b/internal/cli/decision/cmd/add/add_test.go new file mode 100644 index 000000000..afeb1e308 --- /dev/null +++ b/internal/cli/decision/cmd/add/add_test.go @@ -0,0 +1,104 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "os" + "strings" + "testing" + + "github.com/ActiveMemory/ctx/internal/cli/initialize" + "github.com/ActiveMemory/ctx/internal/testutil/testctx" +) + +// TestDecisionAdd verifies the noun-first ctx decision add +// subcommand writes a structured ADR entry to DECISIONS.md. +func TestDecisionAdd(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-decision-add-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{ + "Use PostgreSQL for database", + "--session-id", "test1234", + "--branch", "main", + "--commit", "abc123", + "--context", "Need a reliable database", + "--rationale", "PostgreSQL is well-supported", + "--consequence", "Team needs training", + }) + if err = addCmd.Execute(); err != nil { + t.Fatalf("ctx decision add failed: %v", err) + } + + content, err := os.ReadFile(".context/DECISIONS.md") + if err != nil { + t.Fatalf("failed to read DECISIONS.md: %v", err) + } + contentStr := string(content) + for _, want := range []string{ + "Use PostgreSQL for database", + "Need a reliable database", + "PostgreSQL is well-supported", + "Team needs training", + } { + if !strings.Contains(contentStr, want) { + t.Errorf("expected %q in DECISIONS.md", want) + } + } +} + +// TestDecisionAddRequiresFlags verifies that omitting +// required flags produces an error. +func TestDecisionAddRequiresFlags(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-decision-add-req-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{"Incomplete decision"}) + err = addCmd.Execute() + if err == nil { + t.Fatal("expected error when adding decision without required flags") + } + if !strings.Contains(err.Error(), "--session-id") { + t.Errorf("error should mention missing --session-id flag: %v", err) + } +} diff --git a/internal/cli/decision/cmd/add/cmd.go b/internal/cli/decision/cmd/add/cmd.go new file mode 100644 index 000000000..8df16e67d --- /dev/null +++ b/internal/cli/decision/cmd/add/cmd.go @@ -0,0 +1,27 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "github.com/spf13/cobra" + + "github.com/ActiveMemory/ctx/internal/cli/add/core/build" + "github.com/ActiveMemory/ctx/internal/config/embed/cmd" + "github.com/ActiveMemory/ctx/internal/config/entry" +) + +// Cmd returns the "ctx decision add" subcommand. +// +// Adds a new decision entry to DECISIONS.md with the +// required provenance, context, rationale, and consequence +// flags. Implementation lives in the shared add core. +// +// Returns: +// - *cobra.Command: Configured decision add subcommand +func Cmd() *cobra.Command { + return build.Cmd(entry.Decision, cmd.DescKeyDecisionAdd, cmd.UseDecisionAdd) +} diff --git a/internal/cli/decision/cmd/add/doc.go b/internal/cli/decision/cmd/add/doc.go new file mode 100644 index 000000000..80be60d16 --- /dev/null +++ b/internal/cli/decision/cmd/add/doc.go @@ -0,0 +1,12 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package add wires the cobra "ctx decision add" subcommand. +// +// The cobra wiring delegates entirely to the shared add core +// at internal/cli/add/core/build. The package exists only to +// keep the noun-first command tree symmetric with reindex. +package add diff --git a/internal/cli/decision/decision.go b/internal/cli/decision/decision.go index c220c1ab3..959567a26 100644 --- a/internal/cli/decision/decision.go +++ b/internal/cli/decision/decision.go @@ -9,6 +9,7 @@ package decision import ( "github.com/spf13/cobra" + "github.com/ActiveMemory/ctx/internal/cli/decision/cmd/add" "github.com/ActiveMemory/ctx/internal/cli/decision/cmd/reindex" "github.com/ActiveMemory/ctx/internal/cli/parent" "github.com/ActiveMemory/ctx/internal/config/embed/cmd" @@ -17,13 +18,15 @@ import ( // Cmd returns the decision command with subcommands. // // The decision command provides utilities for managing the -// DECISIONS.md file, including regenerating the quick-reference -// index. +// DECISIONS.md file: +// - add: Add a new decision entry +// - reindex: Regenerate the quick-reference index // // Returns: // - *cobra.Command: The decision command with subcommands func Cmd() *cobra.Command { return parent.Cmd(cmd.DescKeyDecision, cmd.UseDecision, + add.Cmd(), reindex.Cmd(), ) } diff --git a/internal/cli/decision/doc.go b/internal/cli/decision/doc.go index 3d048bee2..ed7184611 100644 --- a/internal/cli/decision/doc.go +++ b/internal/cli/decision/doc.go @@ -15,6 +15,10 @@ // // # Subcommands // +// - add: appends a new decision entry with structured +// ADR-style fields (context, rationale, consequence) +// plus required provenance metadata (session-id, branch, +// commit) // - reindex: scans DECISIONS.md entries and regenerates // the index table at the top of the file, ensuring // numbering and summaries stay consistent with the @@ -22,5 +26,6 @@ // // # Subpackages // +// cmd/add: cobra command for noun-first decision addition // cmd/reindex: cobra command for index regeneration package decision diff --git a/internal/cli/initialize/cmd/root/cmd.go b/internal/cli/initialize/cmd/root/cmd.go index d63b167ff..27b013abf 100644 --- a/internal/cli/initialize/cmd/root/cmd.go +++ b/internal/cli/initialize/cmd/root/cmd.go @@ -23,8 +23,18 @@ import ( // for AI coding assistants. Files include constitution rules, tasks, // decisions, learnings, conventions, and architecture documentation. // +// When the target .context/ directory already contains a populated +// context (any of the essential files exists), init refuses with a +// helpful error pointing at --reset. The retired --force flag is +// gone: it silently overwrote curated content on a quiet [y/N] +// prompt, which destroyed thousands of lines of decisions and +// learnings in the 2026-04-25 incident +// (specs/ctx-init-overwrite-safety.md). +// // Flags: -// - --force, -f: Overwrite existing context files without prompting +// - --reset: Reset an existing context. Interactive only; backs up +// populated files to .context/.backup-init-/ before +// overwriting. Refuses when --caller is set. // - --minimal, -m: Only create essential files // (TASKS, DECISIONS, CONSTITUTION) // - --merge: Auto-merge ctx content into existing CLAUDE.md @@ -37,7 +47,7 @@ import ( // - *cobra.Command: Configured init command with flags registered func Cmd() *cobra.Command { var ( - force bool + reset bool minimal bool merge bool noPluginEnable bool @@ -54,20 +64,16 @@ func Cmd() *cobra.Command { Example: desc.Example(cmd.DescKeyInitialize), RunE: func(cmd *cobra.Command, args []string) error { return Run( - cmd, force, minimal, merge, + cmd, reset, minimal, merge, noPluginEnable, noSteeringInit, caller, ) }, } - flagbind.BindBoolFlagsP(c, - []*bool{&force, &minimal}, - []string{cFlag.Force, cFlag.Minimal}, - []string{cFlag.ShortForce, cFlag.ShortMinimal}, - []string{ - flag.DescKeyInitializeForce, - flag.DescKeyInitializeMinimal, - }, + flagbind.BoolFlag(c, &reset, cFlag.Reset, flag.DescKeyInitializeReset) + flagbind.BoolFlagP(c, + &minimal, cFlag.Minimal, cFlag.ShortMinimal, + flag.DescKeyInitializeMinimal, ) flagbind.BindBoolFlags(c, []*bool{&merge, &noPluginEnable, &noSteeringInit}, diff --git a/internal/cli/initialize/cmd/root/run.go b/internal/cli/initialize/cmd/root/run.go index 9edced4d3..94d391f2e 100644 --- a/internal/cli/initialize/cmd/root/run.go +++ b/internal/cli/initialize/cmd/root/run.go @@ -18,6 +18,7 @@ import ( "github.com/ActiveMemory/ctx/internal/assets/read/catalog" "github.com/ActiveMemory/ctx/internal/assets/read/desc" "github.com/ActiveMemory/ctx/internal/assets/read/template" + "github.com/ActiveMemory/ctx/internal/cli/initialize/core/backup" coreClaude "github.com/ActiveMemory/ctx/internal/cli/initialize/core/claude" coreCC "github.com/ActiveMemory/ctx/internal/cli/initialize/core/claude_check" "github.com/ActiveMemory/ctx/internal/cli/initialize/core/entry" @@ -38,6 +39,7 @@ import ( "github.com/ActiveMemory/ctx/internal/config/token" errCtx "github.com/ActiveMemory/ctx/internal/err/context" errFs "github.com/ActiveMemory/ctx/internal/err/fs" + errInit "github.com/ActiveMemory/ctx/internal/err/initialize" errPrompt "github.com/ActiveMemory/ctx/internal/err/prompt" ctxIo "github.com/ActiveMemory/ctx/internal/io" "github.com/ActiveMemory/ctx/internal/rc" @@ -60,13 +62,36 @@ import ( // The basename guard does not apply at init time because init // *creates* the canonical-named directory. // +// # Existing-context handling +// +// When the target .context/ already contains a populated context +// (any file in ctx.FilesRequired exists), behavior depends on +// --reset: +// +// - Without --reset: refuse with errInit.Populated, listing the +// populated files and pointing at --reset for recovery. The +// directory is left untouched. +// - With --reset and a non-interactive caller (--caller set): +// refuse with errInit.ResetRequiresInteractive. Reset is +// destructive and must come from a real terminal session. +// - With --reset interactively: enumerate the populated files, +// prompt y/N, and on confirmation copy them to +// .context/.backup-init-/ before scaffolding. +// +// When the directory is missing or only contains state/ / hook +// scratch (no essential files), init scaffolds the missing +// templates as before. +// +// Spec: specs/ctx-init-overwrite-safety.md. +// // After materializing the directory, init prints the shell activation // hint via InfoActivateHint so the user's next ctx call in a new // process finds the right CTX_DIR. // // Parameters: // - cmd: Cobra command for output and input streams -// - force: If true, overwrite existing files without prompting +// - reset: If true, attempt destructive reset of an existing +// populated context (interactive only; backs up first) // - minimal: If true, only create essential files // - merge: If true, auto-merge ctx content into existing files // - noPluginEnable: If true, skip auto-enabling the plugin globally @@ -76,10 +101,11 @@ import ( // (e.g. "vscode") for template overrides // // Returns: -// - error: Non-nil if directory creation or file operations fail +// - error: Non-nil if refusal triggers, directory creation fails, +// or file operations fail func Run( cmd *cobra.Command, - force, minimal, merge, noPluginEnable, noSteeringInit bool, + reset, minimal, merge, noPluginEnable, noSteeringInit bool, caller string, ) error { // Check if ctx is in PATH (required for hooks to work). @@ -110,20 +136,21 @@ func Run( contextDir = filepath.Join(cwd, dir.Context) } - // Check if .context/ already exists and is properly initialized. - // A directory with only logs/ (created by hooks before init) is - // treated as uninitialized - no overwrite prompt needed. + // Existing-context handling: refuse by default; --reset takes a + // backup and only proceeds on interactive y/N confirmation. if _, statErr := os.Stat(contextDir); statErr == nil { - if !force && validate.EssentialFilesPresent(contextDir) { - // When called from an editor (--caller), stdin is unavailable. - // Skip the interactive prompt to prevent hanging. + populated := validate.PopulatedFiles(contextDir) + if len(populated) > 0 { + if !reset { + cmd.SilenceUsage = true + return errInit.Populated(contextDir, populated) + } if caller != "" { - initialize.InfoAborted(cmd) - return nil + cmd.SilenceUsage = true + return errInit.ResetRequiresInteractive() } - // Prompt for confirmation - initialize.InfoOverwritePrompt(cmd, contextDir) - reader := bufio.NewReader(os.Stdin) + initialize.InfoResetPrompt(cmd, contextDir, populated) + reader := bufio.NewReader(cmd.InOrStdin()) response, readErr := reader.ReadString(token.NewlineLF[0]) if readErr != nil { return errFs.ReadInput(readErr) @@ -133,6 +160,11 @@ func Run( initialize.InfoAborted(cmd) return nil } + backupDir, backupErr := backup.WriteSnapshot(contextDir, populated) + if backupErr != nil { + return backupErr + } + initialize.InfoBackupWritten(cmd, backupDir) } } @@ -183,8 +215,8 @@ func Run( for _, name := range templatesToCreate { targetPath := filepath.Join(contextDir, name) - // Check if the file exists and --force not set - if _, statErr := os.Stat(targetPath); statErr == nil && !force { + // Check if the file exists and --reset not set + if _, statErr := os.Stat(targetPath); statErr == nil && !reset { initialize.InfoExistsSkipped(cmd, name) continue } @@ -206,7 +238,7 @@ func Run( initialize.Initialized(cmd, contextDir) // Create entry templates in .context/templates/ - if tplErr := entry.CreateTemplates(cmd, contextDir, force); tplErr != nil { + if tplErr := entry.CreateTemplates(cmd, contextDir, reset); tplErr != nil { // Non-fatal: warn but continue label := desc.Text(text.DescKeyInitLabelEntryTemplates) initialize.InfoWarnNonFatal(cmd, label, tplErr) @@ -250,7 +282,7 @@ func Run( } // Handle CLAUDE.md creation/merge - if claudeErr := coreClaude.HandleMd(cmd, force, merge); claudeErr != nil { + if claudeErr := coreClaude.HandleMd(cmd, reset, merge); claudeErr != nil { // Non-fatal: warn but continue initialize.InfoWarnNonFatal(cmd, claude.Md, claudeErr) } diff --git a/internal/cli/initialize/core/backup/backup.go b/internal/cli/initialize/core/backup/backup.go new file mode 100644 index 000000000..cb3f62254 --- /dev/null +++ b/internal/cli/initialize/core/backup/backup.go @@ -0,0 +1,72 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package backup writes a timestamped snapshot of the populated +// essential context files before ctx init --reset overwrites +// them. +// +// The backup directory lives inside the same .context/ tree +// (.context/.backup-init-/) so it travels with the +// project and is easy to recover from. The leading dot keeps +// it out of glob-driven listings; the timestamp suffix makes +// every reset uniquely identifiable. +package backup + +import ( + "os" + "path/filepath" + "time" + + "github.com/ActiveMemory/ctx/internal/config/fs" + cfgInit "github.com/ActiveMemory/ctx/internal/config/initialize" + errInit "github.com/ActiveMemory/ctx/internal/err/initialize" + ctxIo "github.com/ActiveMemory/ctx/internal/io" +) + +// WriteSnapshot copies each named file from contextDir into a +// fresh timestamped backup directory and returns the absolute +// path of that directory. +// +// Best-effort: a file that has disappeared between the +// populated-files probe and the snapshot call is skipped (no +// error). Any other read or write failure aborts and surfaces +// the cause to the caller; init must not proceed with an +// incomplete backup. +// +// Parameters: +// - contextDir: absolute path to the .context/ directory +// - files: basenames (relative to contextDir) to copy +// +// Returns: +// - string: absolute path of the backup directory created +// - error: non-nil on mkdir, read, or write failure +func WriteSnapshot(contextDir string, files []string) (string, error) { + stamp := time.Now().UTC().Format(cfgInit.BackupTimestampLayout) + backupDir := filepath.Join( + contextDir, + cfgInit.BackupDirPrefix+stamp, + ) + if mkErr := ctxIo.SafeMkdirAll(backupDir, fs.PermExec); mkErr != nil { + return "", errInit.BackupMkdir(backupDir, mkErr) + } + + for _, name := range files { + src := filepath.Join(contextDir, name) + data, readErr := ctxIo.SafeReadUserFile(src) + if readErr != nil { + if os.IsNotExist(readErr) { + continue + } + return "", errInit.BackupRead(src, readErr) + } + dst := filepath.Join(backupDir, name) + if writeErr := ctxIo.SafeWriteFile(dst, data, fs.PermFile); writeErr != nil { + return "", errInit.BackupWrite(dst, writeErr) + } + } + + return backupDir, nil +} diff --git a/internal/cli/initialize/core/validate/doc.go b/internal/cli/initialize/core/validate/doc.go index ceaaee313..c39b2d5b1 100644 --- a/internal/cli/initialize/core/validate/doc.go +++ b/internal/cli/initialize/core/validate/doc.go @@ -18,7 +18,7 @@ // // [CheckCtxInPath] uses exec.LookPath to verify the ctx // binary is reachable via PATH, warning if it is missing. -// [EssentialFilesPresent] checks for TASKS.md, +// [PopulatedFiles] checks for TASKS.md, // CONSTITUTION.md, or DECISIONS.md, treating a directory // without them as uninitialised. // @@ -30,7 +30,7 @@ // an error. The check can be skipped by setting the // CTX_SKIP_PATH_CHECK environment variable to "true". // -// EssentialFilesPresent checks for the presence of any +// PopulatedFiles checks for the presence of any // file in the required files list (TASKS.md, // CONSTITUTION.md, DECISIONS.md). A directory that // contains only logs or other non-essential content is diff --git a/internal/cli/initialize/core/validate/essential.go b/internal/cli/initialize/core/validate/essential.go deleted file mode 100644 index 9fb6eb251..000000000 --- a/internal/cli/initialize/core/validate/essential.go +++ /dev/null @@ -1,33 +0,0 @@ -// / ctx: https://ctx.ist -// ,'`./ do you remember? -// `.,'\ -// \ Copyright 2026-present Context contributors. -// SPDX-License-Identifier: Apache-2.0 - -package validate - -import ( - "os" - "path/filepath" - - "github.com/ActiveMemory/ctx/internal/config/ctx" -) - -// EssentialFilesPresent reports whether contextDir contains at least one of -// the essential context files (TASKS.md, CONSTITUTION.md, DECISIONS.md). A -// directory with only logs/ or other non-essential content is considered -// uninitialized. -// -// Parameters: -// - contextDir: Absolute path to the context directory to inspect -// -// Returns: -// - bool: True if at least one essential file exists -func EssentialFilesPresent(contextDir string) bool { - for _, f := range ctx.FilesRequired { - if _, statErr := os.Stat(filepath.Join(contextDir, f)); statErr == nil { - return true - } - } - return false -} diff --git a/internal/cli/initialize/core/validate/populated.go b/internal/cli/initialize/core/validate/populated.go new file mode 100644 index 000000000..0213aad3b --- /dev/null +++ b/internal/cli/initialize/core/validate/populated.go @@ -0,0 +1,40 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package validate + +import ( + "os" + "path/filepath" + + "github.com/ActiveMemory/ctx/internal/config/ctx" +) + +// PopulatedFiles returns the basenames of the essential context +// files that already exist in contextDir. +// +// Used by ctx init to enumerate the destructive blast radius +// before refusing or, with --reset, before backing up and +// overwriting. Returns nil when none of the essential files +// exist (the directory is effectively empty / never +// initialized). +// +// Parameters: +// - contextDir: Absolute path to the context directory +// +// Returns: +// - []string: Basenames of populated essential files +// (subset of ctx.FilesRequired), in the canonical order +// declared by FilesRequired. +func PopulatedFiles(contextDir string) []string { + var present []string + for _, f := range ctx.FilesRequired { + if _, statErr := os.Stat(filepath.Join(contextDir, f)); statErr == nil { + present = append(present, f) + } + } + return present +} diff --git a/internal/cli/initialize/init_test.go b/internal/cli/initialize/init_test.go index 1c1970550..f20089614 100644 --- a/internal/cli/initialize/init_test.go +++ b/internal/cli/initialize/init_test.go @@ -8,6 +8,7 @@ package initialize import ( "encoding/json" + "errors" "os" "path/filepath" "strings" @@ -17,6 +18,7 @@ import ( cfgClaude "github.com/ActiveMemory/ctx/internal/config/claude" "github.com/ActiveMemory/ctx/internal/config/ctx" "github.com/ActiveMemory/ctx/internal/config/env" + errInit "github.com/ActiveMemory/ctx/internal/err/initialize" ) // TestInitCommand tests the init command creates the .context directory. @@ -129,8 +131,11 @@ func TestInitSkipsExistingSteeringHooksSkillsDirs(t *testing.T) { } } + // No --reset needed: pre-existing subdirs without essential files + // are not "populated" — init scaffolds the templates without + // touching the marker files. cmd := Cmd() - cmd.SetArgs([]string{"--force"}) + cmd.SetArgs([]string{}) if err = cmd.Execute(); err != nil { t.Fatalf("init command failed: %v", err) } @@ -434,14 +439,14 @@ func TestCmd_Flags(t *testing.T) { if cmd.Use != "init" { t.Errorf("Cmd().Use = %q, want %q", cmd.Use, "init") } - flags := []string{"force", "minimal", "merge"} + flags := []string{"reset", "minimal", "merge"} for _, f := range flags { if cmd.Flags().Lookup(f) == nil { t.Errorf("missing --%s flag", f) } } - if cmd.Flags().ShorthandLookup("f") == nil { - t.Error("missing -f shorthand for --force") + if cmd.Flags().Lookup("force") != nil { + t.Error("--force flag should be retired (replaced by --reset)") } if cmd.Flags().ShorthandLookup("m") == nil { t.Error("missing -m shorthand for --minimal") @@ -483,8 +488,13 @@ func TestRunInit_Minimal(t *testing.T) { } } -func TestRunInit_Force(t *testing.T) { - tmpDir, err := os.MkdirTemp("", "ctx-init-force-*") +// TestRunInit_RefuseWhenPopulated verifies that a second init +// against an already-initialized .context/ refuses with +// errInit.ErrContextPopulated rather than silently overwriting. +// This is the regression guard for the 2026-04-25 incident +// (specs/ctx-init-overwrite-safety.md). +func TestRunInit_RefuseWhenPopulated(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "ctx-init-refuse-*") if err != nil { t.Fatalf("failed to create temp dir: %v", err) } @@ -505,14 +515,197 @@ func TestRunInit_Force(t *testing.T) { t.Fatalf("first init failed: %v", err) } + // Mark TASKS.md so we can prove it survives the refused second init. + tasksPath := filepath.Join(".context", ctx.Task) + originalTasks, readErr := os.ReadFile(tasksPath) + if readErr != nil { + t.Fatalf("read TASKS.md before refusal: %v", readErr) + } + sentinel := make([]byte, 0, len(originalTasks)+50) + sentinel = append(sentinel, originalTasks...) + sentinel = append(sentinel, []byte("\n# CURATED USER CONTENT — must survive\n")...) + if writeErr := os.WriteFile(filepath.Clean(tasksPath), sentinel, 0o644); writeErr != nil { //nolint:gosec // test temp file + t.Fatalf("write sentinel: %v", writeErr) + } + cmd2 := Cmd() - cmd2.SetArgs([]string{"--force"}) + cmd2.SetArgs([]string{}) + err = cmd2.Execute() + if err == nil { + t.Fatal("second init without --reset must refuse, got nil error") + } + if !errors.Is(err, errInit.ErrContextPopulated) { + t.Errorf("got %v, want errInit.ErrContextPopulated", err) + } + + got, readErr := os.ReadFile(tasksPath) + if readErr != nil { + t.Fatalf("read TASKS.md after refusal: %v", readErr) + } + if !strings.Contains(string(got), "CURATED USER CONTENT") { + t.Error("refused init must not modify TASKS.md") + } +} + +// TestRunInit_ResetRequiresInteractive verifies that --reset +// refuses when --caller is set (the editor / scripted entry +// point gate). Reset is destructive; only real terminal sessions +// may invoke it. +func TestRunInit_ResetRequiresInteractive(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "ctx-init-reset-tty-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + t.Setenv("HOME", tmpDir) + t.Setenv(env.CtxDir, filepath.Join(tmpDir, ".context")) + t.Setenv(env.SkipPathCheck, env.True) + + cmd := Cmd() + cmd.SetArgs([]string{}) + if err = cmd.Execute(); err != nil { + t.Fatalf("first init failed: %v", err) + } + + cmd2 := Cmd() + cmd2.SetArgs([]string{"--reset", "--caller", "vscode"}) + err = cmd2.Execute() + if err == nil { + t.Fatal("--reset with --caller must refuse, got nil error") + } + if !errors.Is(err, errInit.ErrResetRequiresInteractive) { + t.Errorf("got %v, want errInit.ErrResetRequiresInteractive", err) + } +} + +// TestRunInit_ResetWithConfirmationBacksUp verifies the happy +// path: --reset prompts, accepts y, copies populated files into +// a timestamped .backup-init-* subdirectory, then scaffolds +// fresh templates. +func TestRunInit_ResetWithConfirmationBacksUp(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "ctx-init-reset-ok-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + t.Setenv("HOME", tmpDir) + t.Setenv(env.CtxDir, filepath.Join(tmpDir, ".context")) + t.Setenv(env.SkipPathCheck, env.True) + + cmd := Cmd() + cmd.SetArgs([]string{}) + if err = cmd.Execute(); err != nil { + t.Fatalf("first init failed: %v", err) + } + + tasksPath := filepath.Join(".context", ctx.Task) + curated := []byte("# Curated tasks before reset\n") + if writeErr := os.WriteFile(tasksPath, curated, 0o644); writeErr != nil { + t.Fatalf("write curated TASKS.md: %v", writeErr) + } + + cmd2 := Cmd() + cmd2.SetIn(strings.NewReader("y\n")) + cmd2.SetArgs([]string{"--reset"}) + if err = cmd2.Execute(); err != nil { + t.Fatalf("init --reset failed: %v", err) + } + + // CONSTITUTION must be scaffolded (templates landed). + if _, statErr := os.Stat(filepath.Join(".context", ctx.Constitution)); statErr != nil { + t.Error("CONSTITUTION.md missing after reset") + } + + // A backup directory must contain the curated TASKS.md. + entries, readErr := os.ReadDir(".context") + if readErr != nil { + t.Fatalf("read .context: %v", readErr) + } + var foundBackup bool + for _, e := range entries { + if !e.IsDir() || !strings.HasPrefix(e.Name(), ".backup-init-") { + continue + } + foundBackup = true + backedUp, backupErr := os.ReadFile(filepath.Join( + ".context", e.Name(), ctx.Task, + )) + if backupErr != nil { + t.Errorf("read backup TASKS.md: %v", backupErr) + continue + } + if !strings.Contains(string(backedUp), "Curated tasks before reset") { + t.Error("backup did not preserve curated content") + } + } + if !foundBackup { + t.Error("--reset must create .backup-init-/ before overwriting") + } +} + +// TestRunInit_ResetDeclinedNoChanges verifies that answering 'n' +// at the --reset prompt aborts cleanly: no backup is written +// and the existing files are left untouched. +func TestRunInit_ResetDeclinedNoChanges(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "ctx-init-reset-n-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + t.Setenv("HOME", tmpDir) + t.Setenv(env.CtxDir, filepath.Join(tmpDir, ".context")) + t.Setenv(env.SkipPathCheck, env.True) + + cmd := Cmd() + cmd.SetArgs([]string{}) + if err = cmd.Execute(); err != nil { + t.Fatalf("first init failed: %v", err) + } + + tasksPath := filepath.Join(".context", ctx.Task) + curated := []byte("# Curated tasks must not be touched\n") + if writeErr := os.WriteFile(tasksPath, curated, 0o644); writeErr != nil { + t.Fatalf("write curated TASKS.md: %v", writeErr) + } + + cmd2 := Cmd() + cmd2.SetIn(strings.NewReader("n\n")) + cmd2.SetArgs([]string{"--reset"}) if err = cmd2.Execute(); err != nil { - t.Fatalf("init --force failed: %v", err) + t.Fatalf("init --reset declined returned error: %v", err) + } + + got, readErr := os.ReadFile(tasksPath) + if readErr != nil { + t.Fatalf("read TASKS.md: %v", readErr) + } + if !strings.Contains(string(got), "Curated tasks must not be touched") { + t.Error("declined reset must not modify TASKS.md") } - if _, err := os.Stat(filepath.Join(".context", ctx.Constitution)); err != nil { - t.Error("CONSTITUTION.md missing after force reinit") + entries, _ := os.ReadDir(".context") + for _, e := range entries { + if e.IsDir() && strings.HasPrefix(e.Name(), ".backup-init-") { + t.Errorf("declined reset must not create backup, found %s", e.Name()) + } } } diff --git a/internal/cli/learning/cmd/add/add_test.go b/internal/cli/learning/cmd/add/add_test.go new file mode 100644 index 000000000..6ede31fa9 --- /dev/null +++ b/internal/cli/learning/cmd/add/add_test.go @@ -0,0 +1,157 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/ActiveMemory/ctx/internal/cli/initialize" + "github.com/ActiveMemory/ctx/internal/testutil/testctx" +) + +// TestLearningAdd verifies the noun-first ctx learning add +// subcommand writes a structured entry to LEARNINGS.md. +func TestLearningAdd(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-learning-add-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{ + "Always check for nil before dereferencing", + "--session-id", "test1234", + "--branch", "main", + "--commit", "abc123", + "--context", "Got a nil pointer panic in production", + "--lesson", "Always validate pointers before use", + "--application", "Add nil checks in all pointer-receiving functions", + }) + if err = addCmd.Execute(); err != nil { + t.Fatalf("ctx learning add failed: %v", err) + } + + content, err := os.ReadFile(".context/LEARNINGS.md") + if err != nil { + t.Fatalf("failed to read LEARNINGS.md: %v", err) + } + contentStr := string(content) + for _, want := range []string{ + "Always check for nil before dereferencing", + "Got a nil pointer panic in production", + "Always validate pointers before use", + "Add nil checks in all pointer-receiving functions", + } { + if !strings.Contains(contentStr, want) { + t.Errorf("expected %q in LEARNINGS.md", want) + } + } +} + +// TestLearningAddRequiresFlags verifies that omitting +// required flags produces an error. +func TestLearningAddRequiresFlags(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-learning-add-req-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{"Incomplete learning"}) + err = addCmd.Execute() + if err == nil { + t.Fatal("expected error when adding learning without required flags") + } + if !strings.Contains(err.Error(), "--session-id") { + t.Errorf("error should mention missing --session-id flag: %v", err) + } +} + +// TestLearningAddFromFile verifies reading content from --file. +func TestLearningAddFromFile(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-learning-add-file-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + contentFile := filepath.Join(tmpDir, "learning-content.md") + if err = os.WriteFile( + contentFile, []byte("Content from file test"), 0600, + ); err != nil { + t.Fatalf("failed to create content file: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{ + "--file", contentFile, + "--session-id", "test1234", + "--branch", "main", + "--commit", "abc123", + "--context", "Testing file input", + "--lesson", "File input works", + "--application", "Use --file for long content", + }) + if err = addCmd.Execute(); err != nil { + t.Fatalf("ctx learning add --file failed: %v", err) + } + + content, err := os.ReadFile(".context/LEARNINGS.md") + if err != nil { + t.Fatalf("failed to read LEARNINGS.md: %v", err) + } + if !strings.Contains(string(content), "Content from file test") { + t.Error("content from file was not added to LEARNINGS.md") + } +} diff --git a/internal/cli/learning/cmd/add/cmd.go b/internal/cli/learning/cmd/add/cmd.go new file mode 100644 index 000000000..49ca03f20 --- /dev/null +++ b/internal/cli/learning/cmd/add/cmd.go @@ -0,0 +1,27 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "github.com/spf13/cobra" + + "github.com/ActiveMemory/ctx/internal/cli/add/core/build" + "github.com/ActiveMemory/ctx/internal/config/embed/cmd" + "github.com/ActiveMemory/ctx/internal/config/entry" +) + +// Cmd returns the "ctx learning add" subcommand. +// +// Adds a new learning entry to LEARNINGS.md with the +// required provenance, context, lesson, and application +// flags. Implementation lives in the shared add core. +// +// Returns: +// - *cobra.Command: Configured learning add subcommand +func Cmd() *cobra.Command { + return build.Cmd(entry.Learning, cmd.DescKeyLearningAdd, cmd.UseLearningAdd) +} diff --git a/internal/cli/learning/cmd/add/doc.go b/internal/cli/learning/cmd/add/doc.go new file mode 100644 index 000000000..65aa038d8 --- /dev/null +++ b/internal/cli/learning/cmd/add/doc.go @@ -0,0 +1,12 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package add wires the cobra "ctx learning add" subcommand. +// +// The cobra wiring delegates entirely to the shared add core +// at internal/cli/add/core/build. The package exists only to +// keep the noun-first command tree symmetric with reindex. +package add diff --git a/internal/cli/learning/doc.go b/internal/cli/learning/doc.go index 364ddb895..7ab7d77ac 100644 --- a/internal/cli/learning/doc.go +++ b/internal/cli/learning/doc.go @@ -18,6 +18,12 @@ // // # Subcommands // +// - **`ctx learning add [content]`**: appends a new +// learning entry with structured context, lesson, and +// application fields plus required provenance metadata +// (session-id, branch, commit). Implementation in +// [internal/cli/learning/cmd/add] delegates to the +// shared add core. // - **`ctx learning reindex`**: rebuilds the index // table by parsing every entry header in // `LEARNINGS.md` and emitting a fresh @@ -27,13 +33,14 @@ // [internal/cli/learning/cmd/reindex] for the // implementation. // -// # Adding Entries +// # Shared Add Core // -// New learnings are added through `ctx add learning` -// (the `add` family lives in [internal/cli/add]); this -// package currently only owns the index-maintenance -// side. The `_ctx-learning-add` skill wraps the add -// flow with a guided prompt. +// The cmd/add subcommand is a thin adapter; the +// validation, content extraction, formatting, and +// insertion pipeline lives in [internal/cli/add/core] +// (used by every noun-first add command). The +// `_ctx-learning-add` skill wraps `ctx learning add` +// with a guided prompt. // // # Concurrency // diff --git a/internal/cli/learning/learning.go b/internal/cli/learning/learning.go index 056f38bf8..bd7c29c4f 100644 --- a/internal/cli/learning/learning.go +++ b/internal/cli/learning/learning.go @@ -9,6 +9,7 @@ package learning import ( "github.com/spf13/cobra" + "github.com/ActiveMemory/ctx/internal/cli/learning/cmd/add" "github.com/ActiveMemory/ctx/internal/cli/learning/cmd/reindex" "github.com/ActiveMemory/ctx/internal/cli/parent" "github.com/ActiveMemory/ctx/internal/config/embed/cmd" @@ -17,13 +18,15 @@ import ( // Cmd returns the learning command with subcommands. // // The learning command provides utilities for managing the -// LEARNINGS.md file, including regenerating the quick-reference -// index. +// LEARNINGS.md file: +// - add: Add a new learning entry +// - reindex: Regenerate the quick-reference index // // Returns: // - *cobra.Command: The learning command with subcommands func Cmd() *cobra.Command { return parent.Cmd(cmd.DescKeyLearning, cmd.UseLearning, + add.Cmd(), reindex.Cmd(), ) } diff --git a/internal/cli/system/core/session/session_token.go b/internal/cli/system/core/session/session_token.go index 2e0514761..a8101a18e 100644 --- a/internal/cli/system/core/session/session_token.go +++ b/internal/cli/system/core/session/session_token.go @@ -63,6 +63,13 @@ func ReadTokenInfo(sessionID string) (entity.TokenInfo, error) { // Caches the result in StateDir()/jsonl-path-{sessionID} so the glob // runs once per session. // +// Bails when the context directory is not initialized: hooks fire +// from many entry points (including provenance.Emit, which is +// intentionally unconditional) and we must not materialize +// .context/state/ as a side effect of glob caching in projects that +// have never run ctx init. Returns ("", nil) — caller treats as +// "no token data" and proceeds. +// // Parameters: // - sessionID: The Claude Code session ID // @@ -70,7 +77,10 @@ func ReadTokenInfo(sessionID string) (entity.TokenInfo, error) { // - string: Path to the JSONL file, or empty if not found // - error: Non-nil only on unexpected errors func FindJSONLPath(sessionID string) (string, error) { - // Check cache first + if initialized, _ := state.Initialized(); !initialized { + return "", nil + } + stateDir, dirErr := state.Dir() if dirErr != nil { return "", dirErr diff --git a/internal/cli/system/core/session/session_token_test.go b/internal/cli/system/core/session/session_token_test.go index dd2c9283d..c8c59f896 100644 --- a/internal/cli/system/core/session/session_token_test.go +++ b/internal/cli/system/core/session/session_token_test.go @@ -18,6 +18,7 @@ import ( "github.com/ActiveMemory/ctx/internal/config/stats" "github.com/ActiveMemory/ctx/internal/entity" "github.com/ActiveMemory/ctx/internal/rc" + "github.com/ActiveMemory/ctx/internal/testutil/testctx" ) func TestModelContextWindow(t *testing.T) { @@ -106,3 +107,37 @@ func TestLatestSessionPct(t *testing.T) { } }) } + +// TestFindJSONLPathDoesNotMaterializeContext verifies that calling +// FindJSONLPath in a project that has not run "ctx init" does not +// silently create a phantom .context/ (or .context/state/) directory +// as a side effect of cache writeback. +// +// Provenance.Emit is intentionally unconditional, so it must be safe +// to call from any hook regardless of init state. +func TestFindJSONLPathDoesNotMaterializeContext(t *testing.T) { + tmpDir := t.TempDir() + t.Chdir(tmpDir) + ctxPath := testctx.Declare(t, tmpDir) + + // Sanity: the .context/ dir does not exist yet. + if _, statErr := os.Stat(ctxPath); !os.IsNotExist(statErr) { + t.Fatalf("precondition: %s should not exist; statErr=%v", + ctxPath, statErr) + } + + path, err := FindJSONLPath("any-session-id") + if err != nil { + t.Fatalf("FindJSONLPath returned error: %v", err) + } + if path != "" { + t.Errorf("FindJSONLPath returned %q, want empty (uninitialized project)", + path) + } + + // The .context/ directory must NOT have been materialized. + if _, statErr := os.Stat(ctxPath); !os.IsNotExist(statErr) { + t.Errorf("FindJSONLPath materialized %s in an uninitialized project; statErr=%v", + ctxPath, statErr) + } +} diff --git a/internal/cli/task/cmd/add/add_test.go b/internal/cli/task/cmd/add/add_test.go new file mode 100644 index 000000000..5ec3fa126 --- /dev/null +++ b/internal/cli/task/cmd/add/add_test.go @@ -0,0 +1,97 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/ActiveMemory/ctx/internal/cli/initialize" + "github.com/ActiveMemory/ctx/internal/testutil/testctx" +) + +// TestTaskAdd verifies the noun-first ctx task add subcommand +// writes to TASKS.md when invoked without the deprecated noun +// positional arg. +func TestTaskAdd(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-task-add-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{ + "Test task for integration", + "--section", "Misc", + "--session-id", "test1234", + "--branch", "main", + "--commit", "abc123", + }) + if err = addCmd.Execute(); err != nil { + t.Fatalf("ctx task add failed: %v", err) + } + + tasksPath := filepath.Join(tmpDir, ".context", "TASKS.md") + content, err := os.ReadFile(filepath.Clean(tasksPath)) + if err != nil { + t.Fatalf("failed to read TASKS.md: %v", err) + } + if !strings.Contains(string(content), "Test task for integration") { + t.Errorf("task was not added to TASKS.md") + } +} + +// TestTaskAddRequiresProvenance verifies that omitting the +// provenance flags produces an error referencing --session-id. +func TestTaskAddRequiresProvenance(t *testing.T) { + tmpDir, err := os.MkdirTemp("", "cli-task-add-prov-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + defer func() { _ = os.RemoveAll(tmpDir) }() + + origDir, _ := os.Getwd() + if err = os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to chdir: %v", err) + } + defer func() { _ = os.Chdir(origDir) }() + + testctx.Declare(t, tmpDir) + + initCmd := initialize.Cmd() + initCmd.SetArgs([]string{}) + if err = initCmd.Execute(); err != nil { + t.Fatalf("init failed: %v", err) + } + + addCmd := Cmd() + addCmd.SetArgs([]string{"Missing provenance", "--section", "Misc"}) + err = addCmd.Execute() + if err == nil { + t.Fatal("expected error when adding task without provenance") + } + if !strings.Contains(err.Error(), "--session-id") { + t.Errorf("error should mention --session-id: %v", err) + } +} diff --git a/internal/cli/task/cmd/add/cmd.go b/internal/cli/task/cmd/add/cmd.go new file mode 100644 index 000000000..f18c1a026 --- /dev/null +++ b/internal/cli/task/cmd/add/cmd.go @@ -0,0 +1,27 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package add + +import ( + "github.com/spf13/cobra" + + "github.com/ActiveMemory/ctx/internal/cli/add/core/build" + "github.com/ActiveMemory/ctx/internal/config/embed/cmd" + "github.com/ActiveMemory/ctx/internal/config/entry" +) + +// Cmd returns the "ctx task add" subcommand. +// +// Adds a new task entry to TASKS.md with provenance flags. +// Implementation lives in the shared add core; this thin +// adapter binds the noun and description key. +// +// Returns: +// - *cobra.Command: Configured task add subcommand +func Cmd() *cobra.Command { + return build.Cmd(entry.Task, cmd.DescKeyTaskAdd, cmd.UseTaskAdd) +} diff --git a/internal/cli/task/cmd/add/doc.go b/internal/cli/task/cmd/add/doc.go new file mode 100644 index 000000000..0c9df9ae6 --- /dev/null +++ b/internal/cli/task/cmd/add/doc.go @@ -0,0 +1,15 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package add wires the cobra "ctx task add" subcommand. +// +// The cobra wiring delegates entirely to the shared add core +// at internal/cli/add/core/build, which itself calls into +// internal/cli/add/core/run for the validation, extraction, +// formatting, and insertion pipeline. The package exists only +// to keep the noun-first command tree symmetric with siblings +// like archive, complete, and snapshot. +package add diff --git a/internal/cli/task/doc.go b/internal/cli/task/doc.go index 6c9dc916f..a7b18bde3 100644 --- a/internal/cli/task/doc.go +++ b/internal/cli/task/doc.go @@ -16,6 +16,12 @@ // // # Subcommands // +// - **`ctx task add [content]`**: appends a new task +// entry with required provenance flags (session-id, +// branch, commit) and optional priority/section +// targeting. Implementation in +// [internal/cli/task/cmd/add] delegates to the shared +// add core. // - **`ctx task complete [number|text]`**: flips a // task from `[ ]` to `[x]`. Match by phase-relative // number (e.g. `3`), partial text, or full text in diff --git a/internal/cli/task/task.go b/internal/cli/task/task.go index 1fcef8604..0b030c42e 100644 --- a/internal/cli/task/task.go +++ b/internal/cli/task/task.go @@ -10,6 +10,7 @@ import ( "github.com/spf13/cobra" "github.com/ActiveMemory/ctx/internal/cli/parent" + "github.com/ActiveMemory/ctx/internal/cli/task/cmd/add" "github.com/ActiveMemory/ctx/internal/cli/task/cmd/archive" "github.com/ActiveMemory/ctx/internal/cli/task/cmd/complete" "github.com/ActiveMemory/ctx/internal/cli/task/cmd/snapshot" @@ -20,6 +21,8 @@ import ( // // The task command provides utilities for managing the task // lifecycle: +// - add: Add a new task entry to TASKS.md +// - complete: Mark a task as completed // - archive: Move completed tasks out of TASKS.md // - snapshot: Create point-in-time backup // @@ -27,6 +30,7 @@ import ( // - *cobra.Command: Configured task command with subcommands func Cmd() *cobra.Command { return parent.Cmd(cmd.DescKeyTask, cmd.UseTask, + add.Cmd(), archive.Cmd(), complete.Cmd(), snapshot.Cmd(), diff --git a/internal/cli/task/task_test.go b/internal/cli/task/task_test.go index 20ea15437..1c0d8262f 100644 --- a/internal/cli/task/task_test.go +++ b/internal/cli/task/task_test.go @@ -13,8 +13,8 @@ import ( "strings" "testing" - "github.com/ActiveMemory/ctx/internal/cli/add" "github.com/ActiveMemory/ctx/internal/cli/initialize" + taskAdd "github.com/ActiveMemory/ctx/internal/cli/task/cmd/add" "github.com/ActiveMemory/ctx/internal/cli/task/core/count" "github.com/ActiveMemory/ctx/internal/cli/task/core/path" "github.com/ActiveMemory/ctx/internal/config/ctx" @@ -47,8 +47,8 @@ func TestTasksCommands(t *testing.T) { } // Add some tasks - addCmd := add.Cmd() - addCmd.SetArgs([]string{"task", "Test task 1", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) + addCmd := taskAdd.Cmd() + addCmd.SetArgs([]string{"Test task 1", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) if err := addCmd.Execute(); err != nil { t.Fatalf("add task failed: %v", err) } @@ -218,8 +218,8 @@ func TestSnapshotCommand_DefaultName(t *testing.T) { setupTaskDir(t) // Add a task so TASKS.md has content - addCmd := add.Cmd() - addCmd.SetArgs([]string{"task", "Test task", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) + addCmd := taskAdd.Cmd() + addCmd.SetArgs([]string{"Test task", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) if err := addCmd.Execute(); err != nil { t.Fatal(err) } @@ -272,8 +272,8 @@ func TestArchiveCommand_NoTasks(t *testing.T) { func TestArchiveCommand_NoCompletedTasks(t *testing.T) { setupTaskDir(t) - addCmd := add.Cmd() - addCmd.SetArgs([]string{"task", "Pending task", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) + addCmd := taskAdd.Cmd() + addCmd.SetArgs([]string{"Pending task", "--section", "Misc", "--session-id", "test1234", "--branch", "main", "--commit", "abc123"}) if err := addCmd.Execute(); err != nil { t.Fatal(err) } diff --git a/internal/config/embed/cmd/base.go b/internal/config/embed/cmd/base.go index 6836ffd88..beb61ccc9 100644 --- a/internal/config/embed/cmd/base.go +++ b/internal/config/embed/cmd/base.go @@ -12,8 +12,6 @@ const ( UseActivate = "activate" // UseDeactivate is the cobra Use string for the deactivate command. UseDeactivate = "deactivate" - // UseAdd is the cobra Use string for the add command. - UseAdd = "add [content]" // UseAgent is the cobra Use string for the agent command. UseAgent = "agent" // UseChange is the cobra Use string for the change command. @@ -78,8 +76,6 @@ const ( DescKeyActivate = "activate" // DescKeyDeactivate is the description key for the deactivate command. DescKeyDeactivate = "deactivate" - // DescKeyAdd is the description key for the add command. - DescKeyAdd = "add" // DescKeyAgent is the description key for the agent command. DescKeyAgent = "agent" // DescKeyChange is the description key for the change command. diff --git a/internal/config/embed/cmd/convention.go b/internal/config/embed/cmd/convention.go new file mode 100644 index 000000000..bd371f187 --- /dev/null +++ b/internal/config/embed/cmd/convention.go @@ -0,0 +1,22 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package cmd + +// UseConvention is the cobra Use string for the convention command. +const UseConvention = "convention" + +// UseConventionAdd is the cobra Use string for the convention add command. +const UseConventionAdd = "add [content]" + +// DescKeys for convention subcommands. +const ( + // DescKeyConvention is the description key for the convention command. + DescKeyConvention = "convention" + // DescKeyConventionAdd is the description key for the convention add + // command. + DescKeyConventionAdd = "convention.add" +) diff --git a/internal/config/embed/cmd/decision.go b/internal/config/embed/cmd/decision.go index 6f37136b6..59adcdea5 100644 --- a/internal/config/embed/cmd/decision.go +++ b/internal/config/embed/cmd/decision.go @@ -9,10 +9,15 @@ package cmd // UseDecision is the cobra use string for the decision command. const UseDecision = "decision" +// UseDecisionAdd is the cobra Use string for the decision add command. +const UseDecisionAdd = "add [content]" + // DescKeys for decision subcommands. const ( // DescKeyDecision is the description key for the decision command. DescKeyDecision = "decision" + // DescKeyDecisionAdd is the description key for the decision add command. + DescKeyDecisionAdd = "decision.add" // DescKeyDecisionReindex is the description key for the decision reindex // command. DescKeyDecisionReindex = "decision.reindex" diff --git a/internal/config/embed/cmd/learning.go b/internal/config/embed/cmd/learning.go index cc6516084..c98f02b65 100644 --- a/internal/config/embed/cmd/learning.go +++ b/internal/config/embed/cmd/learning.go @@ -9,10 +9,15 @@ package cmd // UseLearning is the cobra use string for the learning command. const UseLearning = "learning" +// UseLearningAdd is the cobra Use string for the learning add command. +const UseLearningAdd = "add [content]" + // DescKeys for learning subcommands. const ( // DescKeyLearning is the description key for the learning command. DescKeyLearning = "learning" + // DescKeyLearningAdd is the description key for the learning add command. + DescKeyLearningAdd = "learning.add" // DescKeyLearningReindex is the description key for the learning reindex // command. DescKeyLearningReindex = "learning.reindex" diff --git a/internal/config/embed/cmd/task.go b/internal/config/embed/cmd/task.go index 8d0236661..e2d4b1061 100644 --- a/internal/config/embed/cmd/task.go +++ b/internal/config/embed/cmd/task.go @@ -8,6 +8,8 @@ package cmd // Use strings for task subcommands. const ( + // UseTaskAdd is the cobra Use string for the task add command. + UseTaskAdd = "add [content]" // UseTaskArchive is the cobra Use string for the task archive command. UseTaskArchive = "archive" // UseTaskSnapshot is the cobra Use string for the task snapshot command. @@ -18,6 +20,8 @@ const ( const ( // DescKeyTask is the description key for the task command. DescKeyTask = "task" + // DescKeyTaskAdd is the description key for the task add command. + DescKeyTaskAdd = "task.add" // DescKeyTaskArchive is the description key for the task archive command. DescKeyTaskArchive = "task.archive" // DescKeyTaskSnapshot is the description key for the task snapshot command. diff --git a/internal/config/embed/flag/initialize.go b/internal/config/embed/flag/initialize.go index adb7ae450..e01da2004 100644 --- a/internal/config/embed/flag/initialize.go +++ b/internal/config/embed/flag/initialize.go @@ -8,8 +8,11 @@ package flag // DescKeys for init command flags. const ( - // DescKeyInitializeForce is the description key for the initialize force flag. - DescKeyInitializeForce = "initialize.force" + // DescKeyInitializeReset is the description key for the initialize reset + // flag (replaces the retired --force flag; reset enumerates the existing + // populated files, backs them up, and only proceeds on interactive + // y/N confirmation). + DescKeyInitializeReset = "initialize.reset" // DescKeyInitializeMerge is the description key for the initialize merge flag. DescKeyInitializeMerge = "initialize.merge" // DescKeyInitializeMinimal is the description key for the initialize minimal diff --git a/internal/config/embed/text/err_backup.go b/internal/config/embed/text/err_backup.go index cae88a157..2428a2478 100644 --- a/internal/config/embed/text/err_backup.go +++ b/internal/config/embed/text/err_backup.go @@ -19,7 +19,7 @@ const ( // archive directory creation failures. DescKeyErrBackupCreateArchiveDir = "err.backup.create-archive-dir" // DescKeyErrBackupCreateBackup is the text key for the `.bak` - // file creation failure (ctx init --force). + // file creation failure (ctx init --reset). DescKeyErrBackupCreateBackup = "err.backup.create-backup" // DescKeyErrBackupWriteArchive is the text key for task archive // write failures. diff --git a/internal/config/embed/text/initialize.go b/internal/config/embed/text/initialize.go index 786c7789c..80187e3fd 100644 --- a/internal/config/embed/text/initialize.go +++ b/internal/config/embed/text/initialize.go @@ -84,9 +84,50 @@ const ( // DescKeyWriteInitNoChanges is the text key for write init no changes // messages. DescKeyWriteInitNoChanges = "write.init-no-changes" - // DescKeyWriteInitOverwritePrompt is the text key for write init overwrite - // prompt messages. - DescKeyWriteInitOverwritePrompt = "write.init-overwrite-prompt" + // DescKeyWriteInitResetPromptHeader is the text key for the + // header line of the ctx init --reset confirmation prompt; + // formats the populated essential file list that follows. + // No format arguments. + DescKeyWriteInitResetPromptHeader = "write.init-reset-prompt-header" + // DescKeyWriteInitResetPromptDir is the text key for the + // "directory: " line in the reset prompt. Template + // expects a single %s for the absolute .context/ path. + DescKeyWriteInitResetPromptDir = "write.init-reset-prompt-dir" + // DescKeyWriteInitResetPromptFile is the text key for one + // populated-file bullet under the reset prompt header. + // Template expects a single %s for the file basename. + DescKeyWriteInitResetPromptFile = "write.init-reset-prompt-file" + // DescKeyWriteInitResetPromptFooter is the text key for the + // trailer text after the file list (backup notice and the + // y/N prompt). No format arguments. + DescKeyWriteInitResetPromptFooter = "write.init-reset-prompt-footer" + // DescKeyWriteInitBackupWritten is the text key for the + // post-backup confirmation line printed by ctx init --reset. + // Template expects a single %s for the absolute backup + // directory path. + DescKeyWriteInitBackupWritten = "write.init-backup-written" +) + +// DescKeys for ctx init refusal and reset error messages. +const ( + // DescKeyErrInitContextPopulated is the text key for the + // human-readable wrapper around ErrContextPopulated. Template + // expects four %s arguments: directory, populated file list, + // recovery flag name (--reset), and backup path placeholder. + DescKeyErrInitContextPopulated = "err.init-context-populated" + // DescKeyErrInitResetRequiresInteractive is the text key for + // the human-readable wrapper around ErrResetRequiresInteractive. + // No format arguments. + DescKeyErrInitResetRequiresInteractive = "err.init-reset-requires-interactive" + // DescKeyErrInitBackupMkdir is the text key for backup-dir + // creation failures. Template expects a %s path and a %w cause. + DescKeyErrInitBackupMkdir = "err.init-backup-mkdir" + // DescKeyErrInitBackupRead is the text key for source-read + // failures during backup. Template expects a %s path and a %w cause. + DescKeyErrInitBackupRead = "err.init-backup-read" + // DescKeyErrInitBackupWrite is the text key for backup-target + // write failures. Template expects a %s path and a %w cause. + DescKeyErrInitBackupWrite = "err.init-backup-write" ) // DescKeys for init permission setup output. diff --git a/internal/config/flag/flag.go b/internal/config/flag/flag.go index bfe90fcb2..7a9f28adc 100644 --- a/internal/config/flag/flag.go +++ b/internal/config/flag/flag.go @@ -76,6 +76,7 @@ const ( IncludeHub = "include-hub" Fix = "fix" Force = "force" + Reset = "reset" Full = "full" Hook = "hook" JSON = "json" diff --git a/internal/config/initialize/doc.go b/internal/config/initialize/doc.go new file mode 100644 index 000000000..9b4cef2d7 --- /dev/null +++ b/internal/config/initialize/doc.go @@ -0,0 +1,23 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package initialize hosts compile-time constants consumed by +// the ctx init command — sentinel error messages used by +// the err/initialize package, backup directory naming for +// ctx init --reset, and the canonical reset flag name. +// +// # Why a Separate Config Package +// +// Sentinel error messages live here rather than in the +// embedded YAML loaded via desc.Text because the +// var ErrContextPopulated and var ErrResetRequiresInteractive +// declarations in err/initialize are evaluated at package-load +// time, before the YAML lookup table is populated. Keeping +// the strings as plain Go const values lets the sentinels +// initialize cleanly while the formatted wrapper messages +// (Populated, ResetRequiresInteractive) still flow through +// desc.Text for localization. +package initialize diff --git a/internal/config/initialize/messages.go b/internal/config/initialize/messages.go new file mode 100644 index 000000000..9940e2289 --- /dev/null +++ b/internal/config/initialize/messages.go @@ -0,0 +1,54 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +// Package initialize hosts compile-time constants consumed by +// the ctx init command (sentinel error messages, backup +// directory naming, reset flag literal). +// +// Sentinel error messages live here — not in the embedded YAML +// loaded via desc.Text — because the err/initialize package +// instantiates them at package-load time, before the YAML +// lookup table is populated. +package initialize + +// Sentinel error messages for ctx init refusal and reset. +// +// These mirror keys in commands/text/errors.yaml but exist as +// raw string constants because the var ErrContextPopulated / +// var ErrResetRequiresInteractive sentinels in the err package +// are initialized before the YAML lookup is ready. +const ( + // ErrMsgContextPopulated is the sentinel message for + // ctx init's refuse-when-populated guard. + ErrMsgContextPopulated = "context already populated; refusing to overwrite" + // ErrMsgResetRequiresInteractive is the sentinel message + // for ctx init --reset's interactive-only guard. + ErrMsgResetRequiresInteractive = "ctx init --reset requires" + + " an interactive terminal" +) + +// Backup directory naming for ctx init --reset. +const ( + // BackupDirPrefix is the basename prefix for timestamped + // backup directories written by ctx init --reset before + // it overwrites populated context files. The leading dot + // keeps the directory out of glob-driven listings without + // requiring .gitignore updates. + BackupDirPrefix = ".backup-init-" + // BackupTimestampLayout is the UTC ISO-8601 layout used + // for backup directory suffixes (sortable and + // filesystem-safe on every supported OS). + BackupTimestampLayout = "2006-01-02T15-04-05Z" + // BackupPlaceholder is the human-readable placeholder for + // the backup directory when the actual timestamp is not + // available (typically in error messages and docs). + BackupPlaceholder = ".backup-init-" +) + +// ResetFlag is the canonical name of the destructive reset +// flag (--reset). Surfaces in error messages so prompts stay +// in sync with the cobra wiring even if the flag is renamed. +const ResetFlag = "--reset" diff --git a/internal/err/backup/backup.go b/internal/err/backup/backup.go index 6d2cb3b43..11d1c5e15 100644 --- a/internal/err/backup/backup.go +++ b/internal/err/backup/backup.go @@ -14,7 +14,7 @@ import ( ) // Create wraps a failure to create a backup (.bak) file during -// ctx init --force. +// ctx init --reset. // // Parameters: // - name: backup filename that could not be created diff --git a/internal/err/backup/doc.go b/internal/err/backup/doc.go index 01ccb8471..83b829a2c 100644 --- a/internal/err/backup/doc.go +++ b/internal/err/backup/doc.go @@ -7,7 +7,7 @@ // Package backup provides error constructors for two narrow file // operations that still live under a historical "backup" label: // -// - [Create]: wraps `.bak` file creation during `ctx init --force`. +// - [Create]: wraps `.bak` file creation during `ctx init --reset`. // - [CreateArchiveDir], [WriteArchive]: wrap task-archive directory // and file write failures under `.context/archive/`. // - [ContextDirNotFound]: the bootstrap-path "context dir missing" diff --git a/internal/err/initialize/initialize.go b/internal/err/initialize/initialize.go new file mode 100644 index 000000000..25ede63f5 --- /dev/null +++ b/internal/err/initialize/initialize.go @@ -0,0 +1,116 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package initialize + +import ( + "errors" + "fmt" + "path/filepath" + "strings" + + "github.com/ActiveMemory/ctx/internal/assets/read/desc" + "github.com/ActiveMemory/ctx/internal/config/embed/text" + cfgInit "github.com/ActiveMemory/ctx/internal/config/initialize" + "github.com/ActiveMemory/ctx/internal/config/token" +) + +// ErrContextPopulated is returned by ctx init when the target +// .context/ directory contains a populated context (essential +// files present) and the operator did not pass --reset. +// +// Wrap with [Populated] to attach the file list and the +// recovery hint pointing at --reset. +// +// The message lives in config/initialize (not resolved through +// desc.Text) because the sentinel is initialized at package +// load time, before the embedded YAML lookup is populated. +var ErrContextPopulated = errors.New(cfgInit.ErrMsgContextPopulated) + +// ErrResetRequiresInteractive is returned by ctx init --reset +// when the invocation is non-interactive (the --caller flag +// is set, indicating an editor or scripted entry point). Reset +// is destructive and must come from a real terminal session. +var ErrResetRequiresInteractive = errors.New( + cfgInit.ErrMsgResetRequiresInteractive, +) + +// Populated wraps [ErrContextPopulated] with the populated +// files (basenames) and a hint about how to proceed. +// +// Parameters: +// - dir: absolute path of the .context/ directory +// - files: basenames of populated essential files (already +// filtered to those that exist) +// +// Returns: +// - error: wrapping ErrContextPopulated for errors.Is matches +func Populated(dir string, files []string) error { + listing := strings.Join(files, token.CommaSpace) + return fmt.Errorf( + desc.Text(text.DescKeyErrInitContextPopulated), + ErrContextPopulated, + dir, + listing, + cfgInit.ResetFlag, + filepath.Join(dir, cfgInit.BackupPlaceholder), + ) +} + +// ResetRequiresInteractive wraps [ErrResetRequiresInteractive] +// with a hint about how to invoke init from a real terminal. +// +// Returns: +// - error: wrapping ErrResetRequiresInteractive for errors.Is matches +func ResetRequiresInteractive() error { + return fmt.Errorf( + desc.Text(text.DescKeyErrInitResetRequiresInteractive), + ErrResetRequiresInteractive, + ) +} + +// BackupMkdir wraps a failure to create the backup directory. +// +// Parameters: +// - path: absolute path of the backup directory that failed +// - cause: the underlying mkdir error +// +// Returns: +// - error: "create backup dir : " +func BackupMkdir(path string, cause error) error { + return fmt.Errorf( + desc.Text(text.DescKeyErrInitBackupMkdir), path, cause, + ) +} + +// BackupRead wraps a failure to read a populated source file +// while preparing the snapshot. +// +// Parameters: +// - path: absolute path of the source file +// - cause: the underlying read error +// +// Returns: +// - error: "read for backup: " +func BackupRead(path string, cause error) error { + return fmt.Errorf( + desc.Text(text.DescKeyErrInitBackupRead), path, cause, + ) +} + +// BackupWrite wraps a failure to write the snapshot copy. +// +// Parameters: +// - path: absolute path of the backup target file +// - cause: the underlying write error +// +// Returns: +// - error: "write backup : " +func BackupWrite(path string, cause error) error { + return fmt.Errorf( + desc.Text(text.DescKeyErrInitBackupWrite), path, cause, + ) +} diff --git a/internal/flagbind/batch.go b/internal/flagbind/batch.go index 6266bbf32..64f7729de 100644 --- a/internal/flagbind/batch.go +++ b/internal/flagbind/batch.go @@ -72,28 +72,6 @@ func BindBoolFlags( } } -// BindBoolFlagsP registers multiple boolean flags that each -// have a shorthand letter, each defaulting to false. All four -// slices must have the same length; each index i produces one -// [BoolFlagP] call. Use this to replace repetitive sequences -// of individual [BoolFlagP] registrations. -// -// Parameters: -// - c: Cobra command to register on -// - ptrs: Pointers to the bool variables -// - names: Flag name constants -// - shorts: Shorthand letters -// - descKeys: YAML DescKeys for the flag descriptions -func BindBoolFlagsP( - c *cobra.Command, - ptrs []*bool, - names, shorts, descKeys []string, -) { - for i, p := range ptrs { - BoolFlagP(c, p, names[i], shorts[i], descKeys[i]) - } -} - // BindStringFlagShorts registers multiple no-pointer string // flags that each have a shorthand letter. All three slices // must have the same length; each index i produces one diff --git a/internal/flagbind/doc.go b/internal/flagbind/doc.go index 8550decb2..675f5190b 100644 --- a/internal/flagbind/doc.go +++ b/internal/flagbind/doc.go @@ -48,7 +48,7 @@ // kind in a single call via parallel slices: // // - [BindStringFlagsP], [BindStringFlags] -// - [BindBoolFlags], [BindBoolFlagsP] +// - [BindBoolFlags] // - [BindStringFlagShorts] // - [BindStringFlagsPDefault] // diff --git a/internal/index/index_test.go b/internal/index/index_test.go index 605633264..fb65d1037 100644 --- a/internal/index/index_test.go +++ b/internal/index/index_test.go @@ -397,7 +397,7 @@ func TestUpdateLearnings(t *testing.T) { ## [2026-01-28-191951] Required flags now enforced -**Context**: Implemented ctx add learning flags +**Context**: Implemented ctx learning add flags **Lesson**: Structured entries are more useful diff --git a/internal/inspect/doc.go b/internal/inspect/doc.go index fd6e656ae..b1381c634 100644 --- a/internal/inspect/doc.go +++ b/internal/inspect/doc.go @@ -34,8 +34,6 @@ // returns its index. // - [ContainsEndComment] checks for a comment close // marker and returns its index. -// - [StartsWithCtxMarker] reports whether a string -// starts with a ctx start or end marker comment. // // # Design // diff --git a/internal/inspect/predicate.go b/internal/inspect/predicate.go index 0d480c111..5f5538afa 100644 --- a/internal/inspect/predicate.go +++ b/internal/inspect/predicate.go @@ -66,15 +66,3 @@ func ContainsEndComment(content string) (bool, int) { commentEnd := strings.Index(content, marker.CommentClose) return commentEnd != -1, commentEnd } - -// StartsWithCtxMarker reports whether s starts with a ctx marker comment. -// -// Parameters: -// - s: String to check -// -// Returns: -// - bool: True if s starts with CtxStart or CtxEnd -func StartsWithCtxMarker(s string) bool { - return strings.HasPrefix(s, marker.CtxStart) || - strings.HasPrefix(s, marker.CtxEnd) -} diff --git a/internal/write/initialize/info.go b/internal/write/initialize/info.go index abd86f8f5..1a6d162a7 100644 --- a/internal/write/initialize/info.go +++ b/internal/write/initialize/info.go @@ -13,17 +13,47 @@ import ( "github.com/ActiveMemory/ctx/internal/assets/read/desc" "github.com/ActiveMemory/ctx/internal/config/embed/text" + "github.com/ActiveMemory/ctx/internal/config/token" ) -// InfoOverwritePrompt prints the overwrite confirmation prompt. +// InfoResetPrompt prints the reset confirmation prompt with an +// enumeration of the populated essential files that will be +// overwritten. The prompt is intentionally explicit about the +// blast radius — the silent "Overwrite existing context? [y/N]" +// prompt destroyed thousands of lines of curated content in +// the 2026-04-25 incident. // // Parameters: // - cmd: Cobra command for output // - contextDir: path to the existing .context/ directory -func InfoOverwritePrompt(cmd *cobra.Command, contextDir string) { - cmd.Print(fmt.Sprintf( - desc.Text(text.DescKeyWriteInitOverwritePrompt), - contextDir)) +// - files: basenames of populated essential files that will be +// backed up and overwritten +func InfoResetPrompt(cmd *cobra.Command, contextDir string, files []string) { + cmd.Println(desc.Text(text.DescKeyWriteInitResetPromptHeader)) + cmd.Println() + cmd.Println(fmt.Sprintf( + desc.Text(text.DescKeyWriteInitResetPromptDir), contextDir, + )) + for _, f := range files { + cmd.Println(fmt.Sprintf( + desc.Text(text.DescKeyWriteInitResetPromptFile), f, + )) + } + cmd.Println() + cmd.Print(desc.Text(text.DescKeyWriteInitResetPromptFooter)) + cmd.Print(token.Space) +} + +// InfoBackupWritten reports the path of the timestamped backup +// directory that holds the pre-reset snapshot of populated files. +// +// Parameters: +// - cmd: Cobra command for output +// - backupDir: absolute path of the backup directory +func InfoBackupWritten(cmd *cobra.Command, backupDir string) { + cmd.Println(fmt.Sprintf( + desc.Text(text.DescKeyWriteInitBackupWritten), backupDir, + )) } // InfoAborted reports that the user cancelled the init operation. diff --git a/site/cli/connect/index.html b/site/cli/connect/index.html index b13ad81a5..c9510ef85 100644 --- a/site/cli/connect/index.html +++ b/site/cli/connect/index.html @@ -1184,7 +1184,7 @@

ctx connect status

Automatic Sharing

Use --share on ctx add to write locally AND publish to the hub:

-
ctx add decision "Use UTC" --share \
+
ctx decision add "Use UTC" --share \
   --context "Need consistency" \
   --rationale "Avoid timezone bugs" \
   --consequence "UI does conversion"
diff --git a/site/cli/connection/index.html b/site/cli/connection/index.html
index 7e14bcc48..0df237f3b 100644
--- a/site/cli/connection/index.html
+++ b/site/cli/connection/index.html
@@ -2232,7 +2232,7 @@ 

ctx connection statusAutomatic Sharing

Use --share on ctx add to write locally AND publish to the ctx Hub:

-
ctx add decision "Use UTC" --share \
+
ctx decision add "Use UTC" --share \
   --context "Need consistency" \
   --rationale "Avoid timezone bugs" \
   --consequence "UI does conversion"
diff --git a/site/cli/context/index.html b/site/cli/context/index.html
index 76b4fb538..66f352b02 100644
--- a/site/cli/context/index.html
+++ b/site/cli/context/index.html
@@ -87,7 +87,7 @@
     
- + Skip to content @@ -952,10 +952,10 @@
  • - + - ctx add + Adding entries @@ -1829,10 +1829,10 @@
    • - + - ctx add + Adding entries @@ -2126,38 +2126,44 @@

      Context Management

      ctx

      -

      ctx add

      -

      Add a new item to a context file.

      -
      ctx add <type> <content> [flags]
      +

      Adding entries

      +

      Each context-artifact noun (task, decision, learning, +convention) owns its own add subcommand under the +noun-first command tree:

      +
      ctx task add <content> [flags]
      +ctx decision add <content> [flags]
      +ctx learning add <content> [flags]
      +ctx convention add <content> [flags]
       
      -

      Types:

      +

      Target files:

      - + - + - + - + - +
      TypeSubcommand Target File
      taskctx task add TASKS.md
      decisionctx decision add DECISIONS.md
      learningctx learning add LEARNINGS.md
      conventionctx convention add CONVENTIONS.md
      -

      Flags:

      +

      Flags (shared by every add subcommand; per-noun +required-flag rules surface as command errors):

      @@ -2211,27 +2217,27 @@

      ctx add

      Examples:

      # Add a task
      -ctx add task "Implement user authentication" \
      +ctx task add "Implement user authentication" \
         --session-id abc12345 --branch main --commit 68fbc00a
      -ctx add task "Fix login bug" --priority high \
      +ctx task add "Fix login bug" --priority high \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Record a decision (requires all ADR (Architectural Decision Record) fields)
      -ctx add decision "Use PostgreSQL for primary database" \
      +ctx decision add "Use PostgreSQL for primary database" \
         --context "Need a reliable database for production" \
         --rationale "PostgreSQL offers ACID compliance and JSON support" \
         --consequence "Team needs PostgreSQL training" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Note a learning (requires context, lesson, and application)
      -ctx add learning "Vitest mocks must be hoisted" \
      +ctx learning add "Vitest mocks must be hoisted" \
         --context "Tests failed with undefined mock errors" \
         --lesson "Vitest hoists vi.mock() calls to top of file" \
         --application "Always place vi.mock() before imports in test files" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Add to specific section
      -ctx add convention "Use kebab-case for filenames" --section "Naming"
      +ctx convention add "Use kebab-case for filenames" --section "Naming"
       

      ctx drift

      diff --git a/site/cli/index.html b/site/cli/index.html index 4bb7725f6..9f17742f3 100644 --- a/site/cli/index.html +++ b/site/cli/index.html @@ -1740,10 +1740,6 @@

      Contextctx add -

      - - @@ -1768,16 +1764,20 @@

      Contextctx task +

      + + - + - + - - + + diff --git a/site/cli/init-status/index.html b/site/cli/init-status/index.html index 42950f667..e1e47a09f 100644 --- a/site/cli/init-status/index.html +++ b/site/cli/init-status/index.html @@ -1853,7 +1853,7 @@

      ctx initctx init --minimal # Force overwrite existing -ctx init --force +ctx init --reset # Merge into existing files ctx init --merge diff --git a/site/home/common-workflows/index.html b/site/home/common-workflows/index.html index b04886acb..85e9fcb32 100644 --- a/site/home/common-workflows/index.html +++ b/site/home/common-workflows/index.html @@ -2006,18 +2006,18 @@

      Track Context
      # Add a task
      -ctx add task "Implement user authentication" \
      +ctx task add "Implement user authentication" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Record a decision (full ADR fields required)
      -ctx add decision "Use PostgreSQL for primary database" \
      +ctx decision add "Use PostgreSQL for primary database" \
         --context "Need a reliable database for production" \
         --rationale "PostgreSQL offers ACID compliance and JSON support" \
         --consequence "Team needs PostgreSQL training" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Note a learning
      -ctx add learning "Mock functions must be hoisted in Jest" \
      +ctx learning add "Mock functions must be hoisted in Jest" \
         --context "Tests failed with undefined mock errors" \
         --lesson "Jest hoists mock calls to top of file" \
         --application "Place jest.mock() before imports" \
      @@ -2285,22 +2285,22 @@ 

      Paired CommandsFile OverviewTwo subdirectories under .context/ are implementation details that are user-editable but not part of the priority read order:

      - + @@ -3062,7 +3062,7 @@

      Key Sectionstemplates/

      Location: .context/templates/. Status: implementation detail, user-editable.

      -

      Purpose: Format templates for ctx add decision and ctx add learning. +

      Purpose: Format templates for ctx decision add and ctx learning add. These control the structure of new entries appended to DECISIONS.md and LEARNINGS.md.

      ctx init deploys two starter templates:

      diff --git a/site/home/first-session/index.html b/site/home/first-session/index.html index e839cfc29..ac4744481 100644 --- a/site/home/first-session/index.html +++ b/site/home/first-session/index.html @@ -1811,12 +1811,12 @@

      Step 2: Activate the ProjectActivating a Context Directory.

      Step 3: Populate Your Context

      Add a task and a decision: These are the entries your AI will remember:

      -
      ctx add task "Implement user authentication" \
      +
      ctx task add "Implement user authentication" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Output: ✓ Added to TASKS.md
       
      -ctx add decision "Use PostgreSQL for primary database" \
      +ctx decision add "Use PostgreSQL for primary database" \
         --context "Need a reliable database for production" \
         --rationale "PostgreSQL offers ACID compliance and JSON support" \
         --consequence "Team needs PostgreSQL training" \
      diff --git a/site/home/is-ctx-right/index.html b/site/home/is-ctx-right/index.html
      index 0e0898144..b95488954 100644
      --- a/site/home/is-ctx-right/index.html
      +++ b/site/home/is-ctx-right/index.html
      @@ -1841,7 +1841,7 @@ 

      5-Minute Trialeval "$(ctx activate)" # 3. Add one real decision from your project -ctx add decision "Your actual architectural choice" \ +ctx decision add "Your actual architectural choice" \ --context "What prompted this decision" \ --rationale "Why you chose this approach" \ --consequence "What changes as a result" \ diff --git a/site/home/joining-a-project/index.html b/site/home/joining-a-project/index.html index b6c86a291..00ee20980 100644 --- a/site/home/joining-a-project/index.html +++ b/site/home/joining-a-project/index.html @@ -1831,18 +1831,18 @@

      Starting Your First SessionAdding Context

      As you work, you'll discover things worth recording. Use the CLI:

      # Record a decision you made or learned about
      -ctx add decision "Use connection pooling for DB access" \
      +ctx decision add "Use connection pooling for DB access" \
         --rationale "Reduces connection overhead under load" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Capture a gotcha you hit
      -ctx add learning "Redis timeout defaults to 5s" \
      +ctx learning add "Redis timeout defaults to 5s" \
         --context "Hit timeouts during bulk operations" \
         --application "Set explicit timeout for batch jobs" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Add a convention you noticed the team follows
      -ctx add convention "All API handlers return structured errors"
      +ctx convention add "All API handlers return structured errors"
       

      You can also just tell the AI: "Record this as a learning" or "Add this decision to context." With the ctx plugin, context-update diff --git a/site/home/repeated-mistakes/index.html b/site/home/repeated-mistakes/index.html index 3ac8b9a37..04d1883dd 100644 --- a/site/home/repeated-mistakes/index.html +++ b/site/home/repeated-mistakes/index.html @@ -1884,12 +1884,12 @@

      The Accumulation Effect

      Getting Started

      Capture your first decision or learning right now:

      -
      ctx add decision "Use PostgreSQL" \
      +
      ctx decision add "Use PostgreSQL" \
         --context "Need a relational database for the project" \
         --rationale "Team expertise, JSONB support, mature ecosystem" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
      -ctx add learning "Vitest mock hoisting" \
      +ctx learning add "Vitest mock hoisting" \
         --context "Tests failing intermittently" \
         --lesson "vi.mock() must be at file top level" \
         --application "Use vi.doMock() for dynamic mocks" \
      diff --git a/site/operations/autonomous-loop/index.html b/site/operations/autonomous-loop/index.html
      index 0bef6b08e..f31aea3f4 100644
      --- a/site/operations/autonomous-loop/index.html
      +++ b/site/operations/autonomous-loop/index.html
      @@ -2283,7 +2283,7 @@ 

      Automatic Context Updates
      <context-update type="complete">user auth</context-update>
       

      Add learning: -

      ctx add learning "Rate limiting requires Redis connection" \
      +
      ctx learning add "Rate limiting requires Redis connection" \
         --session-id abc12345 --branch main --commit 68fbc00a
       

      Or via update command: @@ -2294,7 +2294,7 @@

      Automatic Context Updates>Rate Limiting Redis Dependency</context-update>

      Record decision: -

      ctx add decision "Use JWT tokens for API authentication" \
      +
      ctx decision add "Use JWT tokens for API authentication" \
         --session-id abc12345 --branch main --commit 68fbc00a
       

      Advanced: Watch Mode

      @@ -2369,7 +2369,7 @@

      Context Not PersistingFix: Add explicit instructions to .context/loop.md:
      After completing a task, you MUST:
       1. Run: ctx task complete "<task>"
      -2. Add learnings: ctx add learning "..." --session-id abc12345 --branch main --commit 68fbc00a
      +2. Add learnings: ctx learning add "..." --session-id abc12345 --branch main --commit 68fbc00a
       

      Tasks Getting Repeated

      Cause: Task not marked complete before next iteration

      diff --git a/site/operations/migration/index.html b/site/operations/migration/index.html index 40a447c78..18945187c 100644 --- a/site/operations/migration/index.html +++ b/site/operations/migration/index.html @@ -2097,7 +2097,7 @@

      Quick Paths

      - + @@ -2214,7 +2214,7 @@

      The --force FlagIf your CLAUDE.md already has ctx markers (from a previous ctx init), the default behavior is to skip it. Use --force to replace the ctx block with the latest template: This is useful after upgrading ctx:

      -
      ctx init --force
      +
      ctx init --reset
       

      This only replaces content between <!-- ctx:context --> and <!-- ctx:end -->. Your own content outside the markers is preserved. A timestamped backup is diff --git a/site/operations/runbooks/breaking-migration/index.html b/site/operations/runbooks/breaking-migration/index.html index 2d717215a..8f647779b 100644 --- a/site/operations/runbooks/breaking-migration/index.html +++ b/site/operations/runbooks/breaking-migration/index.html @@ -1843,7 +1843,7 @@

      Step 2: Regenerate Infrastructuremake build && sudo make install # Regenerate CLAUDE.md and permissions -ctx init --force --merge +ctx init --reset --merge

      --merge preserves your knowledge files (TASKS.md, DECISIONS.md, etc.) while regenerating infrastructure (permissions, CLAUDE.md @@ -1887,7 +1887,7 @@

      Writing Release-Specific Migra The old name is removed (no deprecation alias). **Action required**: -1. Run `ctx init --force --merge` to update CLAUDE.md +1. Run `ctx init --reset --merge` to update CLAUDE.md 2. Update any scripts referencing `ctx old-command` 3. Update hook configs if applicable diff --git a/site/operations/runbooks/hub-deployment/index.html b/site/operations/runbooks/hub-deployment/index.html index a79927a18..08ea302fb 100644 --- a/site/operations/runbooks/hub-deployment/index.html +++ b/site/operations/runbooks/hub-deployment/index.html @@ -2009,7 +2009,7 @@

      Step 5: Verify Sync
      # Client A (in its project directory, after activating):
      -ctx add learning "Hub sync test" --context "Verifying hub setup"
      +ctx learning add "Hub sync test" --context "Verifying hub setup"
       
       # Client B (in its project directory, after activating):
       ctx status   # should show the new learning
      diff --git a/site/operations/runbooks/sanitize-permissions/index.html b/site/operations/runbooks/sanitize-permissions/index.html
      index f807a42eb..98fd2703f 100644
      --- a/site/operations/runbooks/sanitize-permissions/index.html
      +++ b/site/operations/runbooks/sanitize-permissions/index.html
      @@ -2013,7 +2013,7 @@ 

      B. One-Off Commands (Session Debris)<

      Entries with hardcoded paths, literal arguments, or exact commands that were accepted during a specific debugging session:

      Bash(git -C /home/jose/WORKSPACE/ctx log --oneline --all -20)
      -Bash(/home/jose/WORKSPACE/ctx/ctx add decision "Use PostgreSQL" --context ...)
      +Bash(/home/jose/WORKSPACE/ctx/ctx decision add "Use PostgreSQL" --context ...)
       

      Signs of a one-off:

        diff --git a/site/operations/upgrading/index.html b/site/operations/upgrading/index.html index aa38c5b62..f7a674050 100644 --- a/site/operations/upgrading/index.html +++ b/site/operations/upgrading/index.html @@ -1773,18 +1773,18 @@

        Upgraderebuild from source or download a new release -when one is available, then run ctx init --force --merge. +when one is available, then run ctx init --reset --merge. Knowledge files are preserved automatically.

        TL:DR

        # Plugin users (Claude Code)
         # /plugin → select ctx → Update now
         # Then update the binary and reinitialize:
        -ctx init --force --merge
        +ctx init --reset --merge
         
         # From-source / manual users
         # install new ctx binary, then:
        -ctx init --force --merge
        +ctx init --reset --merge
         # /plugin → select ctx → Update now   (if using Claude Code)
         

        What Changes between Versions

        @@ -1822,7 +1822,7 @@

        1. Install the New Versionctx --version # verify

      2. Reinitialize

      -
      ctx init --force --merge
      +
      ctx init --reset --merge
       
      • --force regenerates infrastructure files (permissions, ctx-managed diff --git a/site/recipes/external-context/index.html b/site/recipes/external-context/index.html index 8d9f0fe6b..694688dc5 100644 --- a/site/recipes/external-context/index.html +++ b/site/recipes/external-context/index.html @@ -2509,7 +2509,7 @@

        Step 6: Day-to-Day SyncYour AI assistant can do this too. When ending a session:

        You: "Save what we learned and push the context repo."
         
        -Agent: [runs ctx add learning, then commits and pushes the context repo]
        +Agent: [runs ctx learning add, then commits and pushes the context repo]
         

        You can also set up a post-session habit: project code gets committed to the project repo, context gets committed to the context repo.

        diff --git a/site/recipes/guide-your-agent/index.html b/site/recipes/guide-your-agent/index.html index 4bada8ea9..b782a9e7f 100644 --- a/site/recipes/guide-your-agent/index.html +++ b/site/recipes/guide-your-agent/index.html @@ -1816,7 +1816,7 @@

        Guide Your Agent

        ctx

        Commands vs. Skills

        -

        Commands (ctx status, ctx add task) run in your +

        Commands (ctx status, ctx task add) run in your terminal.

        Skills (/ctx-reflect, /ctx-next) run inside your AI coding assistant.

        diff --git a/site/recipes/hub-getting-started/index.html b/site/recipes/hub-getting-started/index.html index f399afc86..82b11f5b3 100644 --- a/site/recipes/hub-getting-started/index.html +++ b/site/recipes/hub-getting-started/index.html @@ -2120,7 +2120,7 @@

        Step 3: Choose What to ReceiveStep 4: Publish a Decision

        Either use ctx add --share to write locally and push to the ctx Hub:

        -
        ctx add decision "Use UTC timestamps everywhere" --share \
        +
        ctx decision add "Use UTC timestamps everywhere" --share \
           --context "We had timezone drift between the API and journal" \
           --rationale "Single source of truth avoids conversion bugs" \
           --consequence "The UI does conversion at render time"
        diff --git a/site/recipes/hub-overview/index.html b/site/recipes/hub-overview/index.html
        index 958b81686..4647cc6c1 100644
        --- a/site/recipes/hub-overview/index.html
        +++ b/site/recipes/hub-overview/index.html
        @@ -2093,7 +2093,7 @@ 

        Story 1: Personal Cross-Project Br codified in one project to be visible as-you-type in another.

        Concrete payoff:

          -
        • ctx add learning --share "..." in project A → +
        • ctx learning add --share "..." in project A → ctx agent --include-hub in project B shows that learning in the next context packet.
        • A decision recorded in your personal "dotfiles" project is diff --git a/site/recipes/hub-personal/index.html b/site/recipes/hub-personal/index.html index b1531a803..20f2c0d42 100644 --- a/site/recipes/hub-personal/index.html +++ b/site/recipes/hub-personal/index.html @@ -2106,7 +2106,7 @@

          10:30 - You Discover a Gotcha
          ctx add learning --share \
          +
          ctx learning add --share \
             --context "Go http.Client retries mask the final error" \
             --lesson  "Transport timeouts don't surface as errors when the retry loop re-assigns err without wrapping. Check for context.DeadlineExceeded on the request context instead." \
             --application "Any retry loop over http.Client.Do that uses a per-attempt timeout"
          @@ -2114,7 +2114,7 @@ 

          10:30 - You Discover a Gotcha14:00 - You Codify a Convention
          cd ~/projects/dotfiles
          -ctx add convention --share \
          +ctx convention add --share \
             "Error messages: lowercase start, no trailing period, single sentence (follows Go's stdlib style)"
           

          The convention lands in dotfiles/CONVENTIONS.md locally @@ -2157,11 +2157,11 @@

          What the Workflow Actually Looks
          # Morning: nothing. Agent loads --include-hub automatically.
           
           # Mid-morning: record a learning that should cross projects
          -ctx add learning --share \
          +ctx learning add --share \
             --context "..." --lesson "..." --application "..."
           
           # Afternoon: codify a convention in the "standards" project
          -ctx add convention --share "..."
          +ctx convention add --share "..."
           
           # Evening: nothing. Everything's already propagated.
           
          diff --git a/site/recipes/hub-team/index.html b/site/recipes/hub-team/index.html index 8f7ec49d5..72b3558f9 100644 --- a/site/recipes/hub-team/index.html +++ b/site/recipes/hub-team/index.html @@ -2095,7 +2095,7 @@

          A Realistic Week
          ctx add learning --share \
          +
          ctx learning add --share \
             --context "Payment service 3 AM incident, 2026-04-03" \
             --lesson  "grpc-go v1.62+ changes DialContext behavior under high \
             concurrency: connections from a single channel can deadlock if the \
          @@ -2113,7 +2113,7 @@ 

          A Realistic Week
          ctx add decision --share \
          +
          ctx decision add --share \
             --context "Need consistent API versioning across all 6 services. \
             Current URL-based /v1/ isn't working for gradual rollouts." \
             --rationale "Header-based versioning lets us route by header at the \
          diff --git a/site/recipes/index.html b/site/recipes/index.html
          index b1b1c68e8..a5a582de0 100644
          --- a/site/recipes/index.html
          +++ b/site/recipes/index.html
          @@ -2194,8 +2194,8 @@ 

          Tracking Work

          Add, prioritize, complete, snapshot, and archive tasks. Keep TASKS.md focused as your project evolves across dozens of sessions.

          -

          Uses: ctx add task, ctx task complete, ctx task archive, +

          Uses: ctx task add, ctx task complete, ctx task archive, ctx task snapshot, /ctx-task-add, /ctx-archive, /ctx-next


          Using the Scratchpad

          diff --git a/site/recipes/knowledge-capture/index.html b/site/recipes/knowledge-capture/index.html index b65a85067..07f679be0 100644 --- a/site/recipes/knowledge-capture/index.html +++ b/site/recipes/knowledge-capture/index.html @@ -2246,17 +2246,17 @@

          Commands and Skills Used

      - + - + - + @@ -2350,7 +2350,7 @@

      Step 2: Record DecisionsCLI Command for Scripting and Automation

      When no agent is in the loop (CI pipelines, shell scripts, hooks), use the CLI directly with structured flags:

      -
      ctx add decision "Use file-based cooldown tokens instead of env vars" \
      +
      ctx decision add "Use file-based cooldown tokens instead of env vars" \
         --context "Hook subprocesses cannot persist env vars to parent shell" \
         --rationale "File tokens survive across processes. Simpler than IPC. Cleanup is automatic via TTL." \
         --consequence "Tombstone files accumulate in /tmp. Cannot share state across machines." \
      @@ -2388,7 +2388,7 @@ 

      Step 3: Record Learnings CLI Command for Scripting and Automation

      When no agent is in the loop:

      -
      ctx add learning "Claude Code hooks run in a subprocess" \
      +
      ctx learning add "Claude Code hooks run in a subprocess" \
         --context "Set env var in PreToolUse hook, but it was not visible in the main session" \
         --lesson "Hook scripts execute in a child process. Env changes do not propagate to parent." \
         --application "Use tombstone files for hook-to-session communication. Never rely on hook env vars." \
      @@ -2404,7 +2404,7 @@ 

      Step 4: Record Conventions 'Use kebab-case for all CLI flag names.'"

      Or from the terminal:

      -
      ctx add convention "Use kebab-case for all CLI flag names" --section "Naming"
      +
      ctx convention add "Use kebab-case for all CLI flag names" --section "Naming"
       

      Conventions work best for rules that come up repeatedly. Codify a pattern the third time you see it, not the first.

      @@ -2441,9 +2441,9 @@

      Step 6: Use /ct I'd suggest persisting: - **Learning**: Hook subprocesses cannot propagate env vars - `ctx add learning "..." --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a` + `ctx learning add "..." --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a` - **Decision**: File-based cooldown tokens over env vars - `ctx add decision "..." --context "..." --rationale "..." --consequence "..." --session-id abc12345 --branch main --commit 68fbc00a` + `ctx decision add "..." --context "..." --rationale "..." --consequence "..." --session-id abc12345 --branch main --commit 68fbc00a` Want me to persist any of these?

      @@ -2521,21 +2521,21 @@

      Step 7: The Conversational Approach<

      Putting It All Together

      Command-Line Approach (Scripting and Automation)

      # Decision: record the trade-off
      -ctx add decision "Use PostgreSQL over SQLite" \
      +ctx decision add "Use PostgreSQL over SQLite" \
         --context "Need concurrent multi-user access" \
         --rationale "SQLite locks on writes; Postgres handles concurrency" \
         --consequence "Requires a database server; team needs Postgres training" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Learning: record the gotcha
      -ctx add learning "SQL migrations must be idempotent" \
      +ctx learning add "SQL migrations must be idempotent" \
         --context "Deploy failed when migration ran twice after rollback" \
         --lesson "CREATE TABLE without IF NOT EXISTS fails on retry" \
         --application "Always use IF NOT EXISTS guards in migrations" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Convention: record the pattern
      -ctx add convention "API handlers return structured errors" --section "API"
      +ctx convention add "API handlers return structured errors" --section "API"
       
       # Reindex after manual edits
       ctx reindex
      diff --git a/site/recipes/session-lifecycle/index.html b/site/recipes/session-lifecycle/index.html
      index 4c426b383..1798fbd4e 100644
      --- a/site/recipes/session-lifecycle/index.html
      +++ b/site/recipes/session-lifecycle/index.html
      @@ -2331,8 +2331,8 @@ 

      Step 5: Commit with Context- **Learning**: Did you hit a gotcha or discover something? - **Neither**: No context to capture; we are done.

      -

      If you made a decision, the skill records it with ctx add decision. If you -learned something, it records it with ctx add learning including context, +

      If you made a decision, the skill records it with ctx decision add. If you +learned something, it records it with ctx learning add including context, lesson, and application fields. This is the bridge between committing code and remembering why the code looks the way it does.

      If source code changed in areas that affect documentation, the skill also @@ -2362,10 +2362,10 @@

      Step 6: Reflect
      I would suggest persisting:
       
       - **Learning**: `$PPID` in PreToolUse hooks resolves to the Claude Code PID
      -  `ctx add learning --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a`
      +  `ctx learning add --context "..." --lesson "..." --application "..." --session-id abc12345 --branch main --commit 68fbc00a`
       - **Task**: mark "Add cooldown to ctx agent" as done
       - **Decision**: tombstone-based cooldown with 10m default
      -  `ctx add decision "..." --session-id abc12345 --branch main --commit 68fbc00a`
      +  `ctx decision add "..." --session-id abc12345 --branch main --commit 68fbc00a`
       
       Want me to persist any of these?
       

      @@ -2459,7 +2459,7 @@

      Conversational Session Flow

      Notice What Happened

      In the above workflow, the user never typed /ctx-reflect or -ctx add learning.

      +ctx learning add.

      The agent moved through Load, Orient, Pick, Work, Commit, and Reflect driven by natural conversation.

      "Let's wrap up" was enough to trigger the full reflect-and-persist flow.

      diff --git a/site/recipes/steering/index.html b/site/recipes/steering/index.html index 52ca1447a..585731326 100644 --- a/site/recipes/steering/index.html +++ b/site/recipes/steering/index.html @@ -2383,7 +2383,7 @@

      Common Mistakesctx add decision, not +every prompt. Record decisions with ctx decision add, not ctx steering add.

      Committing inclusion: always without thinking. Rules marked always fire on every prompt, consuming tier-6 budget diff --git a/site/recipes/task-management/index.html b/site/recipes/task-management/index.html index 56ba86b5e..69672ea36 100644 --- a/site/recipes/task-management/index.html +++ b/site/recipes/task-management/index.html @@ -2304,22 +2304,22 @@

      The Problem

      Prefer Skills over Raw Commands

      When working with an AI agent, use /ctx-task-add instead of raw -ctx add task. The agent automatically picks up session ID, branch, +ctx task add. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.

      TL;DR

      Manage Tasks:

      -
      ctx add task "Fix race condition" --priority high \
      +
      ctx task add "Fix race condition" --priority high \
         --session-id abc12345 --branch main --commit 68fbc00a  # add
      -ctx add task "Write tests" --section "Phase 2" \
      +ctx task add "Write tests" --section "Phase 2" \
         --session-id abc12345 --branch main --commit 68fbc00a  # add to phase
       ctx task complete "race condition"                      # mark done
       ctx task snapshot "before-refactor"               # backup
      @@ -2340,7 +2340,7 @@ 

      Commands and Skills Used

      - + @@ -2378,19 +2378,19 @@

      Commands and Skills Used

      The Workflow

      Step 1: Add Tasks with Priorities

      -

      Every piece of follow-up work gets a task. Use ctx add task from the terminal +

      Every piece of follow-up work gets a task. Use ctx task add from the terminal or /ctx-task-add from your AI assistant. Tasks should start with a verb and be specific enough that someone unfamiliar with the session could act on them.

      # High-priority bug found during code review
      -ctx add task "Fix race condition in session cooldown" --priority high \
      +ctx task add "Fix race condition in session cooldown" --priority high \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Medium-priority feature work
      -ctx add task "Add --format json flag to ctx status for CI integration" --priority medium \
      +ctx task add "Add --format json flag to ctx status for CI integration" --priority medium \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Low-priority cleanup
      -ctx add task "Remove deprecated --raw flag from ctx load" --priority low \
      +ctx task add "Remove deprecated --raw flag from ctx load" --priority low \
         --session-id abc12345 --branch main --commit 68fbc00a
       

      The /ctx-task-add skill validates your task before recording it. It checks @@ -2403,7 +2403,7 @@

      Step 1: Add Tasks with Priorities

      After completing a feature, the agent will often identify follow-up work: tests, docs, edge cases, error handling, and offer to add them as tasks.

      -

      You do not need to dictate ctx add task commands; the agent picks up on +

      You do not need to dictate ctx task add commands; the agent picks up on work context and suggests tasks naturally.

      Step 2: Organize with Phase Sections

      @@ -2415,7 +2415,7 @@

      Step 2: Organize with Phase Section - [x] Implement ctx add command - [x] Implement ctx task complete command -- [ ] Add --section flag to ctx add task `#priority:medium` +- [ ] Add --section flag to ctx task add `#priority:medium` ## Phase 2: AI Integration @@ -2429,7 +2429,7 @@

      Step 2: Organize with Phase Section - [ ] Add metrics dashboard to ctx status `#priority:deferred`

      Use --section when adding a task to a specific phase:

      -
      ctx add task "Add ctx watch XML parsing" --priority medium --section \
      +
      ctx task add "Add ctx watch XML parsing" --priority medium --section \
           "Phase 2: AI Integration" \
           --session-id abc12345 --branch main --commit 68fbc00a
       
      @@ -2451,7 +2451,7 @@

      Step 3: Pick What to Work On Still in-progress from yesterday's session. The tombstone file approach is half-built. Finishing is cheaper than context-switching. -**2. Add --section flag to ctx add task** `#priority:medium` +**2. Add --section flag to ctx task add** `#priority:medium` Last Phase 1 item. Quick win that unblocks organized task entry. @@ -2516,7 +2516,7 @@

      Letting the Agent DriveThe steps above show the CLI commands for task management.

      In practice, most task management happens conversationally:

      An agent that has loaded the context files does not need you to type -ctx add task. It tracks work naturally and offers the right operations.

      +ctx task add. It tracks work naturally and offers the right operations.

      Use Natural Language Instead of Commands

      These conversational prompts replace explicit commands during interactive sessions:

      Add a task, decision, learning, or convention
      ctx load Output assembled context in read order
      Add tasks, mark complete, archive, snapshot
      ctx decisionManage DECISIONS.md (reindex)Add decisions and reindex DECISIONS.md
      ctx learningManage LEARNINGS.md (reindex)Add learnings and reindex LEARNINGS.md
      ctx taskTask completion, archival, and snapshotsctx conventionAdd conventions to CONVENTIONS.md
      ctx reindex
      #added YYYY-MM-DD-HHMMSSAuto-added by ctx add taskAuto-added by ctx task add
      #started
      Existing CLAUDE.md + ctx markersctx init --forcectx init --reset Replaces the ctx block, leaves your content intact
      ctx add decisionctx decision add Command Record an architectural decision
      ctx add learningctx learning add Command Record a gotcha, tip, or lesson
      ctx add conventionctx convention add Command Record a coding pattern or standard
      ctx add taskctx task add Command Add a new task to TASKS.md
      @@ -2528,7 +2528,7 @@

      Use Natural Language Instead o

      - + @@ -2544,7 +2544,7 @@

      Use Natural Language Instead o

      - + @@ -2634,7 +2634,7 @@

      The Agent Completes Tasks and Mo Agent: "Marked 'Implement ctx agent cooldown' as done. Your highest- -priority remaining task is 'Add --section flag to ctx add task'. +priority remaining task is 'Add --section flag to ctx task add'. It's the last item in Phase 1 and a quick win. Want to start on that?" @@ -2675,7 +2675,7 @@

      A Conversational Session Example You: Yes to both. What's next? Agent: Added the cleanup task as high priority. Next up is "Add --section - flag to ctx add task": last item in Phase 1. It should be + flag to ctx task add": last item in Phase 1. It should be straightforward since the flag parsing pattern already exists in the codebase. Ready? @@ -2688,11 +2688,11 @@

      A Conversational Session Example

      Putting It All Together

      # Add a task
      -ctx add task "Implement rate limiting for API endpoints" --priority high \
      +ctx task add "Implement rate limiting for API endpoints" --priority high \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # Add to a specific phase
      -ctx add task "Write integration tests for rate limiter" --section "Phase 2" \
      +ctx task add "Write integration tests for rate limiter" --section "Phase 2" \
         --session-id abc12345 --branch main --commit 68fbc00a
       
       # See what to work on
      diff --git a/site/reference/skills/index.html b/site/reference/skills/index.html
      index cfbf10f13..5adffcb1f 100644
      --- a/site/reference/skills/index.html
      +++ b/site/reference/skills/index.html
      @@ -2782,7 +2782,7 @@ 

      /ctx-commit/ctx-reflect

      Pause and reflect on session progress. Walks through a checklist of learnings, decisions, task completions, and session notes to persist.

      -

      Wraps: chains to ctx add learning, ctx add decision, +

      Wraps: chains to ctx learning add, ctx decision add, manual TASKS.md updates

      See also: The Complete Session, Persisting Decisions, Learnings, and Conventions

      @@ -2794,8 +2794,8 @@

      /ctx-wrap-upSession Ceremonies, The Complete Session

      @@ -2805,14 +2805,14 @@

      Context Persistence/ctx-task-add

      Add an actionable task with optional priority and phase section.

      -

      Wraps: ctx add task "description" [--priority high|medium|low] +

      Wraps: ctx task add "description" [--priority high|medium|low] --session-id ID --branch BR --commit HASH

      See also: Tracking Work Across Sessions


      /ctx-decision-add

      Record an architectural decision with context, rationale, and consequence. Supports Y-statement (lightweight) and full ADR formats.

      -

      Wraps: ctx add decision "title" --context "..." --rationale "..." +

      Wraps: ctx decision add "title" --context "..." --rationale "..." --consequence "..." --session-id ID --branch BR --commit HASH

      See also: Persisting Decisions, Learnings, and Conventions

      @@ -2821,7 +2821,7 @@

      /ctx-learning-addRecord a project-specific gotcha, bug, or unexpected behavior. Filters for insights that are searchable, project-specific, and required real effort to discover.

      -

      Wraps: ctx add learning "title" --context "..." --lesson "..." +

      Wraps: ctx learning add "title" --context "..." --lesson "..." --application "..." --session-id ID --branch BR --commit HASH

      See also: Persisting Decisions, Learnings, and Conventions

      @@ -2829,7 +2829,7 @@

      /ctx-learning-add/ctx-convention-add

      Record a coding convention that should be standardized across sessions. Targets patterns seen 2-3+ times.

      -

      Wraps: ctx add convention "rule" --section "Name"

      +

      Wraps: ctx convention add "rule" --section "Name"

      See also: Persisting Decisions, Learnings, and Conventions


      diff --git a/site/search.json b/site/search.json index fdc21bfd7..f359b3cf7 100644 --- a/site/search.json +++ b/site/search.json @@ -1 +1 @@ -{"config":{"separator":"[\\s\\-_,:!=\\[\\]()\\\\\"`/]+|\\.(?!\\d)"},"items":[{"location":"","level":1,"title":"Manifesto","text":"","path":["Manifesto"],"tags":[]},{"location":"#the-ctx-manifesto","level":1,"title":"The ctx Manifesto","text":"

      Creation, not code.

      Context, not prompts.

      Verification, not vibes.

      This Is NOT a Metaphor

      Code executes instructions.

      Creation produces outcomes.

      Confusing the two is how teams ship motion...

      ...instead of progress.

      • It was never about the code.
      • Code has zero standalone value.
      • Code is an implementation detail.

      Code is an incantation.

      Creation is the act.

      And creation does not happen in a vacuum.

      ","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-the-substrate","level":2,"title":"ctx Is the Substrate","text":"

      Constraints Have Moved

      Human bandwidth is no longer the limiting factor.

      Context integrity is.

      Human bandwidth is no longer the constraint.

      Context is:

      • Without durable context, intelligence resets.
      • Without memory, reasoning decays.
      • Without structure, scale collapses.

      Creation is now limited by:

      • Clarity of intent;
      • Quality of context;
      • Rigor of verification.

      Not by speed.

      Not by capacity.

      Velocity Amplifies

      Faster execution on broken context compounds error.

      Speed multiplies whatever is already wrong.

      ","path":["Manifesto"],"tags":[]},{"location":"#humans-author-meaning","level":2,"title":"Humans Author Meaning","text":"

      Intent Is Authored

      Systems can optimize.

      Models can generalize.

      Meaning must be chosen.

      Intent is not emergent.

      Vision, goals, and direction are human responsibilities.

      We decide:

      • What matters;
      • What success means;
      • What world we are building.

      ctx encodes the intent so it...

      • survives time,
      • survives handoffs,
      • survives scale.

      Nothing important should live only in conversation.

      Nothing critical should depend on recall.

      Oral Tradition Does Not Scale

      If intent cannot be inspected, it cannot be enforced.

      ","path":["Manifesto"],"tags":[]},{"location":"#ctx-before-action","level":2,"title":"ctx Before Action","text":"

      Orientation Precedes Motion

      Acting first and understanding later is not bravery.

      It is debt.

      Never act without ctx.

      Before execution, we must verify:

      • Where we are;
      • Why we are here;
      • What constraints apply;
      • What assumptions are active.

      Action without ctx is gambling.

      Speed without orientation is noise.

      ctx is not overhead: It is the cost of correctness.

      ","path":["Manifesto"],"tags":[]},{"location":"#persistent-context-beats-prompt-memory","level":2,"title":"Persistent Context Beats Prompt Memory","text":"

      Transience Is the Default Failure Mode

      • Prompts decay.
      • Chats fragment.
      • Memory heuristics drift.

      Prompts are transient.

      Chats are lossy.

      Memory heuristics drift.

      ctx must be:

      • Durable;
      • Structured;
      • Explicit;
      • Queryable.

      Intent Must Be Intentional

      If intent exists only in a prompt...

      ...alignment is already degrading.

      Knowledge lives in the artifacts:

      • Decisions;
      • Documentation;
      • Dependency maps;
      • Evaluation history.

      Artifacts Outlive Sessions

      What is not written will be re-learned.

      At full cost.

      ","path":["Manifesto"],"tags":[]},{"location":"#what-ctx-is-not","level":2,"title":"What ctx Is Not","text":"

      Avoid Category Errors

      Mislabeling ctx guarantees misuse.

      ctx is not a memory feature.

      • ctx is not prompt engineering.
      • ctx is not a productivity hack.
      • ctx is not automation theater.

      ctx is a system for preserving intent under scale.

      ctx is infrastructure.

      ","path":["Manifesto"],"tags":[]},{"location":"#verified-reality-is-the-scoreboard","level":2,"title":"Verified Reality Is the Scoreboard","text":"

      Activity Is a False Proxy

      Output volume correlates poorly with impact.

      • Code is not progress.
      • Activity is not impact.

      The only truth that compounds is verified change.

      Verified change must exist in the real world.

      Hypotheses are cheap; outcomes are not.

      ctx captures:

      • What we expected;
      • What we observed;
      • Where reality diverged.

      If we cannot predict, measure, and verify the result...

      ...it does not count.

      ","path":["Manifesto"],"tags":[]},{"location":"#build-to-learn-not-to-accumulate","level":2,"title":"Build to Learn, Not to Accumulate","text":"

      Prototypes Have an Expiration Date

      A prototype's value is information, not longevity.

      Prototypes exist to reduce uncertainty.

      We build to:

      • Test assumptions;
      • Validate architecture;
      • Answer specific questions.

      Not everything.

      Not blindly.

      Not permanently.

      ctx records archeology so the cost is paid once.

      ","path":["Manifesto"],"tags":[]},{"location":"#failures-are-assets","level":2,"title":"Failures Are Assets","text":"

      Failure without Capture Is Waste

      Pain that does not teach is pure loss.

      Failures are not erased: They are preserved.

      Each failure becomes:

      • A documented hypothesis;
      • An analyzed deviation;
      • A permanent artifact.

      Rollback fixes symptoms: ctx fixes systems.

      A repeated mistake is a missing ctx artifact.

      ","path":["Manifesto"],"tags":[]},{"location":"#structure-enables-scale","level":2,"title":"Structure Enables Scale","text":"

      Unbounded Autonomy Destabilizes

      Power without a structure produces chaos.

      Transpose it:

      Power without any structure becomes chaos.

      ctx defines:

      • Roles;
      • Boundaries;
      • Protocols;
      • Escalation paths;
      • Decision rights.

      Ambiguity is a system failure:

      • Debates must be structured.
      • Decisions must be explicit.
      • History must be retained.
      ","path":["Manifesto"],"tags":[]},{"location":"#encode-intent-into-the-environment","level":2,"title":"Encode Intent into the Environment","text":"

      Goodwill Does Not Belong to the Table

      Alignment that depends on memory will drift.

      Alignment cannot depend on memory or goodwill.

      Do not rely on people to remember.

      Encode the behavior, so it happens by default.

      Intent is encoded as:

      • Policies;
      • Schemas;
      • Constraints;
      • Evaluation harnesses.

      Rules must be machine-readable.

      Laws must be enforceable.

      If intent is implicit, drift is guaranteed.

      ","path":["Manifesto"],"tags":[]},{"location":"#cost-is-a-first-class-signal","level":2,"title":"Cost Is a First-Class Signal","text":"

      Attention Is the Scarcest Resource

      Not ideas.

      Not ambition.

      Ideas do not compete on time:

      They compete on cost and impact:

      • Attention is finite.
      • Compute is finite.
      • Context is expensive.

      We continuously ask:

      • What the most valuable next action is.
      • What outcome justifies the cost.

      ctx guides allocation.

      Learning reshapes priority.

      ","path":["Manifesto"],"tags":[]},{"location":"#show-the-why","level":2,"title":"Show the Why","text":"

      {} (code, artifacts, apps, binaries) produce outputs; they do not preserve reasoning.

      Systems that cannot explain themselves will not be trusted.

      Traceability builds trust.

           {} --> what\n\n    ctx --> why\n

      We record:

      • Explored paths;
      • Rejected options;
      • Assumptions made;
      • Evidence used.

      Opaque systems erode trust:

      Transparent ctx compounds understanding.

      ","path":["Manifesto"],"tags":[]},{"location":"#continuously-verify-the-system","level":2,"title":"Continuously Verify the System","text":"

      Stability Is Temporary

      Every assumption has a half-life:

      • Models drift.
      • Tools change.
      • Assumptions rot.

      ctx must be verified against reality.

      Trust is a spectrum.

      Trust is continuously re-earned:

      • Benchmarks,
      • regressions,
      • and evaluations...

      ...are safety rails.

      ","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-leverage","level":2,"title":"ctx Is Leverage","text":"

      Humans Are Decision Engines

      Execution should not consume judgment.

      Humans must not be typists.

      We are the authors.

      Human effort is reserved for:

      • Judgment;
      • Design;
      • Taste;
      • Synthesis.

      Repetition is delegated.

      Toil is automated.

      ctx preserves leverage across time.

      ","path":["Manifesto"],"tags":[]},{"location":"#the-thesis","level":2,"title":"The Thesis","text":"

      Invariant

      Everything else is an implementation detail.

      • Creation is the act.
      • ctx is the substrate.
      • Verification is the truth.

      Code executes → Models reason → Agents amplify.

      ctx lives on.

      • Without ctx, intelligence resets.
      • With ctx, creation compounds.
      ","path":["Manifesto"],"tags":[]},{"location":"blog/","level":1,"title":"Blog","text":"

      Stories, insights, and lessons learned from building and using ctx.

      ","path":["Blog"],"tags":[]},{"location":"blog/#releases","level":2,"title":"Releases","text":"","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v080-the-architecture-release","level":3,"title":"ctx v0.8.0: The Architecture Release","text":"

      March 23, 2026: 374 commits, 1,708 Go files touched, and a near-complete architectural overhaul. Every CLI package restructured into cmd/ + core/ taxonomy, all user-facing strings externalized to YAML, MCP server for tool-agnostic AI integration, and the memory bridge connecting Claude Code's auto-memory to .context/.

      Topics: release, architecture, refactoring, MCP, localization

      ","path":["Blog"],"tags":[]},{"location":"blog/#field-notes","level":2,"title":"Field Notes","text":"","path":["Blog"],"tags":[]},{"location":"blog/#the-watermelon-rind-anti-pattern-why-smarter-tools-make-shallower-agents","level":3,"title":"The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents","text":"

      April 6, 2026: Give an agent a graph query tool, and it produces output that's structurally correct but substantively hollow (the watermelon-rind antipattern: We ran three sessions analyzing the same codebase with different tool access: the one with no tools produced 5.2x more depth. The fix: a two-pass compiler for architecture understanding: force code reading first, verify with tools second. Constraint is the feature.

      Topics: architecture, code intelligence, agent behavior, design patterns, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#code-structure-as-an-agent-interface-what-19-ast-tests-taught-us","level":3,"title":"Code Structure as an Agent Interface: What 19 AST Tests Taught Us","text":"

      April 2, 2026: We built 19 AST-based audit tests in a single session, touching 300+ files. In the process we discovered that \"old-school\" code quality constraints (no magic numbers, centralized error handling, 80-char lines, documentation) are exactly the constraints that make code readable to AI agents. If an agent interacts with your codebase, your codebase already is an interface. You just have not designed it as one.

      Topics: ast, code quality, agent readability, conventions, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#we-broke-the-31-rule","level":3,"title":"We Broke the 3:1 Rule","text":"

      March 23, 2026: After v0.6.0, we ran 198 feature commits across 17 days before consolidating. The 3:1 rule says consolidate every 4th session. We did it after the 66th. The result: an 18-day, 181-commit cleanup marathon that took longer than the feature run itself. A follow-up to The 3:1 Ratio with empirical evidence from the v0.8.0 cycle.

      Topics: consolidation, technical debt, development workflow, convention drift, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#context-engineering","level":2,"title":"Context Engineering","text":"","path":["Blog"],"tags":[]},{"location":"blog/#agent-memory-is-infrastructure","level":3,"title":"Agent Memory Is Infrastructure","text":"

      March 4, 2026: Every AI coding agent starts fresh. The obvious fix is \"memory.\" But there's a different problem memory doesn't touch: the project itself accumulates knowledge that has nothing to do with any single session. This post argues that agent memory is L2 (runtime cache); what's missing is L3 (project infrastructure).

      Topics: context engineering, agent memory, infrastructure, persistence, team knowledge

      ","path":["Blog"],"tags":[]},{"location":"blog/#context-as-infrastructure","level":3,"title":"Context as Infrastructure","text":"

      February 17, 2026: Where does your AI's knowledge live between sessions? If the answer is \"in a prompt I paste at the start,\" you are treating context as a consumable. This post argues for treating it as infrastructure instead: persistent files, separation of concerns, two-tier storage, progressive disclosure, and the filesystem as the most mature interface available.

      Topics: context engineering, infrastructure, progressive disclosure, persistence, design philosophy

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-attention-budget-why-your-ai-forgets-what-you-just-told-it","level":3,"title":"The Attention Budget: Why Your AI Forgets What You Just Told It","text":"

      February 3, 2026: Every token you send to an AI consumes a finite resource: the attention budget. Understanding this constraint shaped every design decision in ctx: hierarchical file structure, explicit budgets, progressive disclosure, and filesystem-as-index.

      Topics: attention mechanics, context engineering, progressive disclosure, ctx primitives, token budgets

      ","path":["Blog"],"tags":[]},{"location":"blog/#before-context-windows-we-had-bouncers","level":3,"title":"Before Context Windows, We Had Bouncers","text":"

      February 14, 2026: IRC is stateless. You disconnect, you vanish. Modern systems are not much different. This post traces the line from IRC bouncers to context engineering: stateless protocols require stateful wrappers, volatile interfaces require durable memory.

      Topics: context engineering, infrastructure, IRC, persistence, state continuity

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-last-question","level":3,"title":"The Last Question","text":"

      February 28, 2026: In 1956, Asimov wrote a story about a question that spans the entire future of the universe. A reading of \"The Last Question\" through the lens of persistence, substrate migration, and what it means to build systems where sessions don't reset.

      Topics: context continuity, long-lived systems, persistence, intelligence over time, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#agent-behavior-and-design","level":2,"title":"Agent Behavior and Design","text":"","path":["Blog"],"tags":[]},{"location":"blog/#the-dog-ate-my-homework-teaching-ai-agents-to-read-before-they-write","level":3,"title":"The Dog Ate My Homework: Teaching AI Agents to Read Before They Write","text":"

      February 25, 2026: You wrote the playbook. The agent skipped all of it. Five sessions, five failure modes, and the discovery that observable compliance beats perfect compliance.

      Topics: hooks, agent behavior, context engineering, behavioral design, testing methodology, compliance monitoring

      ","path":["Blog"],"tags":[]},{"location":"blog/#skills-that-fight-the-platform","level":3,"title":"Skills That Fight the Platform","text":"

      February 4, 2026: When custom skills conflict with system prompt defaults, the AI has to reconcile contradictory instructions. Five conflict patterns discovered while building ctx.

      Topics: context engineering, skill design, system prompts, antipatterns, AI safety primitives

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-anatomy-of-a-skill-that-works","level":3,"title":"The Anatomy of a Skill That Works","text":"

      February 7, 2026: I had 20 skills. Most were well-intentioned stubs. Then I rewrote all of them. Seven lessons emerged: quality gates prevent premature execution, negative triggers are load-bearing, examples set boundaries better than rules.

      Topics: skill design, context engineering, quality gates, E/A/R framework, practical patterns

      ","path":["Blog"],"tags":[]},{"location":"blog/#you-cant-import-expertise","level":3,"title":"You Can't Import Expertise","text":"

      February 5, 2026: I found a well-crafted consolidation skill. Applied my own E/A/R framework: 70% was noise. This post is about why good skills can't be copy-pasted, and how to grow them from your project's own drift history.

      Topics: skill adaptation, E/A/R framework, convention drift, consolidation, project-specific expertise

      ","path":["Blog"],"tags":[]},{"location":"blog/#not-everything-is-a-skill","level":3,"title":"Not Everything Is a Skill","text":"

      February 8, 2026: I ran an 8-agent codebase audit and got actionable results. The natural instinct was to wrap the prompt as a skill. Then I applied my own criteria: it failed all three tests.

      Topics: skill design, context engineering, automation discipline, recipes, agent teams

      ","path":["Blog"],"tags":[]},{"location":"blog/#defense-in-depth-securing-ai-agents","level":3,"title":"Defense in Depth: Securing AI Agents","text":"

      February 9, 2026: The security advice was \"use CONSTITUTION.md for guardrails.\" That is wishful thinking. Five defense layers for unattended AI agents, each with a bypass, and why the strength is in the combination.

      Topics: agent security, defense in depth, prompt injection, autonomous loops, container isolation

      ","path":["Blog"],"tags":[]},{"location":"blog/#development-practice","level":2,"title":"Development Practice","text":"","path":["Blog"],"tags":[]},{"location":"blog/#code-is-cheap-judgment-is-not","level":3,"title":"Code Is Cheap. Judgment Is Not.","text":"

      February 17, 2026: AI does not replace workers. It replaces unstructured effort. Three weeks of building ctx with an AI agent proved it: YOLO mode showed production is cheap, the 3:1 ratio showed judgment has a cadence.

      Topics: AI and expertise, context engineering, judgment vs production, human-AI collaboration, automation discipline

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-31-ratio","level":3,"title":"The 3:1 Ratio","text":"

      February 17, 2026: AI makes technical debt worse: not because it writes bad code, but because it writes code so fast that drift accumulates before you notice. Three feature sessions, one consolidation session.

      Topics: consolidation, technical debt, development workflow, convention drift, code quality

      ","path":["Blog"],"tags":[]},{"location":"blog/#refactoring-with-intent-human-guided-sessions-in-ai-development","level":3,"title":"Refactoring with Intent: Human-Guided Sessions in AI Development","text":"

      February 1, 2026: The YOLO mode shipped 14 commands in a week. But technical debt doesn't send invoices. This is the story of what happened when we started guiding the AI with intent.

      Topics: refactoring, code quality, documentation standards, module decomposition, YOLO versus intentional development

      ","path":["Blog"],"tags":[]},{"location":"blog/#how-deep-is-too-deep","level":3,"title":"How Deep Is Too Deep?","text":"

      February 12, 2026: I kept feeling like I should go deeper into ML theory. Then I spent a week debugging an agent failure that had nothing to do with model architecture. When depth compounds and when it doesn't.

      Topics: AI foundations, abstraction boundaries, agentic systems, context engineering, failure modes

      ","path":["Blog"],"tags":[]},{"location":"blog/#agent-workflows","level":2,"title":"Agent Workflows","text":"","path":["Blog"],"tags":[]},{"location":"blog/#parallel-agents-merge-debt-and-the-myth-of-overnight-progress","level":3,"title":"Parallel Agents, Merge Debt, and the Myth of Overnight Progress","text":"

      February 17, 2026: You discover agents can run in parallel. So you open ten terminals. It is not progress: it is merge debt being manufactured in real time. The five-agent ceiling and why role separation beats file locking.

      Topics: agent workflows, parallelism, verification, context engineering, engineering practice

      ","path":["Blog"],"tags":[]},{"location":"blog/#parallel-agents-with-git-worktrees","level":3,"title":"Parallel Agents with Git Worktrees","text":"

      February 14, 2026: I had 30 open tasks that didn't touch the same files. Using git worktrees to partition a backlog by file overlap, run 3-4 agents simultaneously, and merge the results.

      Topics: agent teams, parallelism, git worktrees, context engineering, task management

      ","path":["Blog"],"tags":[]},{"location":"blog/#field-notes-and-signals","level":2,"title":"Field Notes and Signals","text":"","path":["Blog"],"tags":[]},{"location":"blog/#when-a-system-starts-explaining-itself","level":3,"title":"When a System Starts Explaining Itself","text":"

      February 17, 2026: Every new substrate begins as a private advantage. Reality begins when other people start describing it in their own language. \"Better than Adderall\" is not praise; it is a diagnostic.

      Topics: field notes, adoption signals, infrastructure vs tools, context engineering, substrates

      ","path":["Blog"],"tags":[]},{"location":"blog/#why-zensical","level":3,"title":"Why Zensical","text":"

      February 15, 2026: I needed a static site generator for the journal system. The instinct was Hugo. But instinct is not analysis. Why zensical was the right choice: thin dependencies, MkDocs-compatible config, and zero lock-in.

      Topics: tooling, static site generators, journal system, infrastructure decisions, context engineering

      ","path":["Blog"],"tags":[]},{"location":"blog/#releases_1","level":2,"title":"Releases","text":"","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v060-the-integration-release","level":3,"title":"ctx v0.6.0: The Integration Release","text":"

      February 16, 2026: ctx is now a Claude Marketplace plugin. Two commands, no build step, no shell scripts. v0.6.0 replaces six Bash hook scripts with compiled Go subcommands and ships 25+ Skills as a plugin.

      Topics: release, plugin system, Claude Marketplace, distribution, security hardening

      ","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v030-the-discipline-release","level":3,"title":"ctx v0.3.0: The Discipline Release","text":"

      February 15, 2026: No new headline feature. Just 35+ documentation and quality commits against ~15 feature commits. What a release looks like when the ratio of polish to features is 3:1.

      Topics: release, skills migration, consolidation, code quality, E/A/R framework

      ","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v020-the-archaeology-release","level":3,"title":"ctx v0.2.0: The Archaeology Release","text":"

      February 1, 2026: What if your AI could remember everything? Not just the current session, but every session. ctx v0.2.0 introduces the recall and journal systems.

      Topics: session recall, journal system, structured entries, token budgets, meta-tools

      ","path":["Blog"],"tags":[]},{"location":"blog/#building-ctx-using-ctx-a-meta-experiment-in-ai-assisted-development","level":3,"title":"Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development","text":"

      January 27, 2026: What happens when you build a tool designed to give AI memory, using that very same tool to remember what you're building? This is the story of ctx.

      Topics: dogfooding, AI-assisted development, Ralph Loop, session persistence, architectural decisions

      ","path":["Blog"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/","level":1,"title":"Building ctx Using ctx","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism.

      References to .context/sessions/, auto-save hooks, and SessionEnd auto-save in this post reflect the architecture at the time of writing.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#a-meta-experiment-in-ai-assisted-development","level":2,"title":"A Meta-Experiment in AI-Assisted Development","text":"

      Jose Alekhinne / 2026-01-27

      Can a Tool Design Itself?

      What happens when you build a tool designed to give AI memory, using that very same tool to remember what you are building?

      This is the story of ctx, how it evolved from a hasty \"YOLO mode\" experiment to a disciplined system for persistent AI context, and what I have learned along the way.

      Context Is a Record

      Context is a persistent record.

      By \"context\", I don't mean model memory or stored thoughts:

      I mean the durable record of decisions, learnings, and intent that normally evaporates between sessions.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#ai-amnesia","level":2,"title":"AI Amnesia","text":"

      Every developer who works with AI code generators knows the frustration:

      You have a deep, productive session where the AI understands your codebase, your conventions, your decisions. And then you close the terminal.

      Tomorrow; it's a blank slate. The AI has forgotten everything.

      That is \"reset amnesia\", and it's not just annoying: it's expensive.

      Every session starts with:

      • Re-explaining context;
      • Re-reading files;
      • Re-discovering decisions that were already made.

      I Needed Context

      \"I don't want to lose this discussion...

      ...I am a brain-dead developer YOLO'ing my way out.\"

      ☝️ that's exactly what I said to Claude when I first started working on ctx.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-genesis","level":2,"title":"The Genesis","text":"

      The project started as \"Active Memory\" (amem): a CLI tool to persist AI context across sessions.

      The core idea was simple:

      1. Create a .context/ directory with structured Markdown files for decisions, learnings, tasks, and conventions.
      2. The AI reads these at session start and writes to them before the session ends.
      3. There is no step 3.

      The first commit was just scaffolding. But within hours, the Ralph Loop (An iterative AI development workflow) had produced a working CLI:

      feat(cli): implement amem init command\nfeat(cli): implement amem status command\nfeat(cli): implement amem add command\nfeat(cli): implement amem agent command\n...\n

      Not one, not two, but a whopping fourteen core commands shipped in rapid succession!

      I was YOLO'ing like there was no tomorrow:

      • Auto-accept every change;
      • Let the AI run free;
      • Ship features fast.
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-meta-experiment-using-amem-to-build-amem","level":2,"title":"The Meta-Experiment: Using amem to Build amem","text":"

      Here's where it gets interesting: On January 20th, I asked:

      \"Can I use amem to help you remember this context when I restart?\"

      The answer was yes, but with a gap:

      Autoload worked (via Claude Code's PreToolUse hook), but auto-save was missing: If the user quit, with Ctrl+C, everything since the last manual save was lost.

      That session became the first real test of the system.

      Here is the first session file we recorded:

      ## Key Discussion Points\n\n### 1. amem vs Ralph Loop - They're Separate Systems\n\n**User's question**: \"How do I use the binary to recreate this project?\"\n\n**Answer discovered**: `amem` is for context management, Ralph Loop is for \ndevelopment workflow. They are complementary but separate.\n\n### 2. Two Tiers of Context Persistence\n\n| Tier      | What                        | Why                           |\n|-----------|-----------------------------|-------------------------------|\n| Curated   | Learnings, decisions, tasks | Quick reload, token-efficient |\n| Full dump | Entire conversation         | Safety net, nothing lost      |\n\n| Where                  |\n|------------------------|\n| .context/*.md          |\n| .context/sessions/*.md |\n

      This session file (written by the AI to preserve its own context) became the template for how ctx handles session persistence.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-rename","level":2,"title":"The Rename","text":"

      By January 21st, I realized \"Active Memory\" was too generic, and (arguably) too marketing-smelly.

      Besides, the binary was already called ctx (short for Context), the directory was .context/, and the slash commands would be /ctx-*.

      So it followed that the project should be renamed to ctx to make things make sense.

      The rename touched 100+ files but was clean: a find-and-replace with Go's type system catching any misses.

      The git history tells the story:

      0e8f6bb feat: rename amem to ctx and add Claude Code integration\n87dcfa1 README.\n4f0e195 feat: separate orchestrator directive from agent tasks\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#yolo-mode-fast-but-dangerous","level":2,"title":"YOLO Mode: Fast, but Dangerous","text":"

      The Ralph Loop made feature development incredibly fast.

      But it created technical debt that I didn't notice until later.

      A comparison session on January 25th revealed the patterns:

      YOLO Pattern What We Found \"TASKS.md\" scattered in 10 files Same string literal everywhere, no constants dir + \"/\" + file Should be filepath.Join() Monolithic cli_test.go (1500+ lines) Tests disconnected from implementations package initcmd in init/ folder Go's \"init\" is reserved: subtle naming collision

      Here is another analysis made by ctx:

      ● Based on my analysis, here are the key differences:\n\nYOLO Mode (Pre-040ce99)\n- Feature-first: Added slash commands, tests, templates rapidly\n- Scattered magic strings: \"TASKS.md\", \"decision\", \".context\" spread across files\n- Quick file creation: New files without organizational patterns\n- Working but inconsistent: Code functioned but lacked systematic structure\n\nHuman-Guided Mode (Post-040ce99)\n- Consolidation focus: Centralized constants in config package\n- Consistent naming: Dir, File, Filename, UpdateType prefixes\n- Self-referential constants: FileType map uses constants as keys, not literals\n- Proper path construction: filepath.Join() instead of +\"/\"+\n- Colocated tests: Tests next to implementations\n- Canonical naming: Package name = folder name\n

      The fix required a human-guided refactoring session. I continued to do that before every major release, from that point on.

      We introduced internal/config/config.go with semantic prefixes:

      const (\n    DirContext     = \".context\"\n    DirArchive     = \"archive\"\n    DirSessions    = \"sessions\"\n    FilenameTask   = \"TASKS.md\"\n    UpdateTypeTask = \"task\"\n)\n

      What I begrudgingly learned was: YOLO mode is effective for velocity but accumulates debt.

      So I took a mental note to schedule periodic consolidation sessions.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-dogfooding-test-that-failed","level":2,"title":"The Dogfooding Test That Failed","text":"

      On January 21st, I ran an experiment: have another Claude instance rebuild ctx from scratch using only the specs and PROMPT.md.

      The Ralph Loop ran, all tasks got checked off, the loop exited successfully.

      But the binary was broken!

      Commands just printed help text instead of executing.

      All tasks were marked \"complete\" but the implementation didn't work.

      Here's what ctx discovered:

      ## Key Findings\n\n### Dogfooding Binary Is Broken\n- Commands don't execute: they just print root help text\n- All tasks were marked complete but binary doesn't work\n- Lesson: \"tasks checked off\" ≠ \"implementation works\"\n

      This was humbling; to say the least.

      I realized I had the same blind spot in my own codebase: no integration tests that actually invoked the binary.

      So I added:

      • Integration tests for all commands;
      • Coverage targets (60-80% per package)
      • Smoke tests in CI
      • A constitution rule: \"All code must pass tests before commit\"
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-constitution-versus-conventions","level":2,"title":"The Constitution versus Conventions","text":"

      As lessons accumulated, there was the temptation to add everything to CONSTITUTION.md as \"inviolable rules\".

      But I resisted.

      The constitution should contain only truly inviolable invariants:

      • Security (no secrets, no customer data)
      • Quality (tests must pass)
      • Process (decisions need records)
      • ctx invocation (always use PATH, never fallback)

      Everything else (coding style, file organization, naming conventions...) should go in to CONVENTIONS.md.

      Here's how ctx explained why the distinction was important:

      Decision Record, 2026-01-25

      Overly strict constitution creates friction and gets ignored.

      Conventions can be bent; constitution cannot.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#hooks-harder-than-they-look","level":2,"title":"Hooks: Harder than They Look","text":"

      Claude Code hooks seemed simple: Run a script before/after certain events.

      But I hit multiple gotchas:

      1. Key names matter

      // WRONG - \"Invalid key in record\" error\n\"PreToolUseHooks\": [...]\n\n// RIGHT\n\"PreToolUse\": [...]\n

      2. Blocking requires specific output

      # WRONG - just exits, doesn't block\nexit 1\n\n# RIGHT - JSON output + exit 0\necho '{\"decision\": \"block\", \"reason\": \"Use ctx from PATH\"}'\nexit 0\n

      3. Go's JSON escaping

      json.Marshal escapes >, <, & as unicode (\\u003e) by default.

      When generating shell commands in JSON:

      encoder := json.NewEncoder(file)\nencoder.SetEscapeHTML(false) // Prevent 2>/dev/null → 2\\u003e/dev/null\n

      4. Regex overfitting

      My hook to block non-PATH ctx invocations initially matched too broadly:

      # WRONG - matches /home/user/ctx/internal/file.go (ctx as directory)\n(/home/|/tmp/|/var/)[^ ]*ctx[^ ]*\n\n# RIGHT - matches ctx as binary only\n(/home/|/tmp/|/var/)[^ ]*/ctx( |$)\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-session-files","level":2,"title":"The Session Files","text":"

      By the time of this writing this project's ctx sessions (.context/sessions/) contains 40+ files from this project's development.

      They are not part of the source code due to security, privacy, and size concerns.

      Middle Ground: The Scratchpad

      For sensitive notes that do need to travel with the project, ctx pad stores encrypted one-liners in git, and ctx pad add \"label\" --file PATH can ingest small files.

      See Scratchpad for details.

      However, they are invaluable for the project's progress.

      Each session file is a timestamped Markdown with:

      • Summary of what has been accomplished;
      • Key decisions made;
      • Learnings discovered;
      • Tasks for the next session;
      • Technical context (platform, versions).

      These files are not autoloaded (that would bust the token budget).

      They are what I see as the \"archaeological record\" of ctx:

      When the AI needs deeper information about why something was done, it digs into the sessions.

      Auto-generated session files used a naming convention:

      2026-01-23-115432-session-prompt_input_exit-summary.md\n2026-01-25-220244-manual-save.md\n2026-01-27-052107-session-other-summary.md\n

      Update

      The session feature described here is historical.

      In current releases, ctx uses a journal instead: the enrichment process generates meaningful slugs from context automatically, so there is no need to manually save sessions.

      The SessionEnd hook captured transcripts automatically. Even Ctrl+C was caught.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-decision-log-18-architectural-decisions","level":2,"title":"The Decision Log: 18 Architectural Decisions","text":"

      ctx helps record every significant architectural choice in .context/DECISIONS.md.

      Here are some highlights:

      Reverse-chronological order (2026-01-27)

      **Context**: With chronological order, oldest items consume tokens first, and\nnewest (most relevant) items risk being truncated.\n\n**Decision**: Use reverse-chronological order (newest first) for DECISIONS.md\nand LEARNINGS.md.\n

      PATH over hardcoded paths (2026-01-21)

      **Context**: Original implementation hardcoded absolute paths in hooks.\nThis breaks when sharing configs with other developers.\n\n**Decision**: Hooks use `ctx` from PATH. `ctx init` checks PATH before \nproceeding.\n

      Generic core with Claude enhancements (2026-01-20)

      **Context**: ctx should work with any AI tool, but Claude Code users could\nbenefit from deeper integration.\n\n**Decision**: Keep ctx generic as the core tool, but provide optional\nClaude Code-specific enhancements.\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-learning-log-24-gotchas-and-insights","level":2,"title":"The Learning Log: 24 Gotchas and Insights","text":"

      The .context/LEARNINGS.md file captures gotchas that would otherwise be forgotten. Each has Context, Lesson, and Application sections:

      CGO on ARM64

      **Context**: `go test` failed with \n`gcc: error: unrecognized command-line option '-m64'`\n\n**Lesson**: On ARM64 Linux, CGO causes cross-compilation issues. \nAlways use `CGO_ENABLED=0`.\n

      Claude Code skills format

      **Lesson**: Claude Code skills are Markdown files in .claude/commands/ with `YAML`\nfrontmatter (*description, argument-hint, allowed-tools*). Body is the prompt.\n

      \"Do you remember?\" handling

      **Lesson**: In a `ctx`-enabled project, \"*do you remember?*\" \nhas an obvious meaning:\ncheck the `.context/` files. Don't ask for clarification. Just do it.\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#task-archives-the-completed-work","level":2,"title":"Task Archives: The Completed Work","text":"

      Completed tasks are archived to .context/archive/ with timestamps.

      The archive from January 23rd shows 13 phases of work:

      • Phase 1: Project Scaffolding (Go module, Cobra CLI)
      • Phase 2-4: Core Commands (init, status, agent, add, complete, drift, sync, compact, watch, hook)
      • Phase 5: Session Management (save, list, load, parse, --extract)
      • Phase 6: Claude Code Integration (hooks, settings, CLAUDE.md handling)
      • Phase 7: Testing & Verification
      • Phase 8: Task Archival
      • Phase 9: Slash Commands
      • Phase 9b: Ralph Loop Integration
      • Phase 10: Project Rename
      • Phase 11: Documentation
      • Phase 12: Timestamp Correlation
      • Phase 13: Rich Context Entries

      That's an impressive ^^173 commits** across 8 days of development.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#what-i-learned-about-ai-assisted-development","level":2,"title":"What I Learned about AI-Assisted Development","text":"

      1. Memory changes everything

      When the AI remembers decisions, it doesn't repeat mistakes.

      When the AI knows your conventions, it follows them.

      ctx makes the AI a better collaborator because it's not starting from zero.

      2. Two-tier persistence works

      Curated context (DECISIONS.md, LEARNINGS.md, TASKS.md) is for quick reload.

      Full session dumps are for archaeology.

      It's a futile effort to try to fit everything in the token budget.

      Persist more, load less.

      3. YOLO mode has its place

      For rapid prototyping, letting the AI run free is effective.

      But I had to schedule consolidation sessions.

      Technical debt accumulates silently.

      4. The constitution should be small

      Only truly inviolable rules go in CONSTITUTION.md. Everything else is a convention.

      If you put too much in the constitution, it will get ignored.

      5. Verification is non-negotiable

      \"All tasks complete\" means nothing if you haven't run the tests.

      Integration tests that invoke the actual binary caught bugs that the unit tests missed.

      6. Session files are underrated

      The ability to grep through 40 session files and find exactly when and why a decision was made helped me a lot.

      It's not about loading them into context: It is about having them when you need them.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-future-recall-system","level":2,"title":"The Future: Recall System","text":"

      The next phase of ctx is the Recall System:

      • Parser: Parse session capture markdowns, enrich with JSONL data
      • Renderer: Goldmark + Chroma for syntax highlighting, dark mode UI
      • Server: Local HTTP server for browsing sessions
      • Search: Inverted index for searching across sessions
      • CLI: ctx recall serve <path> to start the server

      The goal is to make the archaeological record browsable, not just grep-able.

      Because not everyone always lives in the terminal (me included).

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#conclusion","level":2,"title":"Conclusion","text":"

      Building ctx using ctx was a meta-experiment in AI-assisted development.

      I learned that memory isn't just convenient: It's transformative:

      • An AI that remembers your decisions doesn't repeat mistakes.
      • An AI that knows your conventions doesn't need them re-explained.

      If you are reading this, chances are that you already have heard about ctx.

      • ctx is open source at github.com/ActiveMemory/ctx,
      • and the documentation lives at ctx.ist.

      Session Records Are a Gold Mine

      By the time of this writing, I have more than 70 megabytes of text-only session capture, spread across >100 Markdown and JSONL files.

      I am analyzing, synthesizing, encriching them with AI, running RAG (Retrieval-Augmented Generation) models on them, and the outcome surprises me every day.

      If you are a mere mortal tired of reset amnesia, give ctx a try.

      And when you do, check .context/sessions/ sometime.

      The archaeological record might surprise you.

      This blog post was written with the help of ctx with full access to the ctx session files, decision log, learning log, task archives, and git history of ctx: The meta continues.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/","level":1,"title":"ctx v0.2.0: The Archaeology Release","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism.

      The .context/sessions/ directory referenced in this post has been eliminated. Session history is now accessed via ctx recall and enriched journals live in .context/journal/.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#digging-through-the-past-to-build-the-future","level":2,"title":"Digging through the Past to Build the Future","text":"

      Jose Alekhinne / 2026-02-01

      What If Your AI Could Remember Everything?

      Not just the current session, but every session:

      • Every decision made,
      • every mistake avoided,
      • every path not taken.

      That's what v0.2.0 delivers.

      Between v0.1.2 and v0.2.0, 86 commits landed across 5 days.

      The release notes list features and fixes.

      This post tells the story of why those features exist, and what building them taught me.

      This isn't a changelog: It is an explanation of intent.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-problem-amnesia-isnt-just-session-level","level":2,"title":"The Problem: Amnesia Isn't Just Session-Level","text":"

      v0.1.0 solved reset amnesia:

      The AI now remembers decisions, learnings, and tasks across sessions.

      But a new problem emerged, which I can sum up as:

      \"I (the human) am not AI.\"

      Frankly, I couldn't remember what the AI remembered.

      Let alone, I cannot remember what I ate for breakfast!

      In the course of days, I realized session transcripts piled up in .context/sessions/; I was grepping, JSONL files with thousands of lines... Raw tool calls, assistant responses, user messages...

      ...all interleaved.

      Valuable context was effectively buried in machine-readable noise.

      I found myself grepping through files to answer questions like:

      • \"When did we decide to use constants instead of literals?\"
      • \"What was the session where we fixed the hook regex?\"
      • \"How did the embed.go split actually happen?\"

      Fate Is Whimsical

      The irony was painful:

      I built a tool to prevent AI amnesia, but I was suffering from human amnesia about what happened in AI sessions.

      This was the moment ctx stopped being just an AI tool and started needing to support the human on the other side of the loop.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-solution-recall-and-journal","level":2,"title":"The Solution: Recall and Journal","text":"

      v0.2.0 introduces two interconnected systems.

      They solve different problems and only work well together.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#ctx-recall-browse-your-past","level":3,"title":"ctx recall: Browse Your Past","text":"
      # List all sessions for this project\nctx recall list\n\n# Show a specific session\nctx recall show gleaming-wobbling-sutherland\n\n# See the full transcript\nctx recall show gleaming-wobbling-sutherland --full\n

      The recall system parses Claude Code's JSONL transcripts and presents them in a human-readable format:

      Session Date Turns Duration tender-painting-sundae 2026-01-29 3 <1m crystalline-gliding-willow 2026-01-29 3 <1m declarative-hugging-snowglobe 2026-01-31 2 <1m

      Slugs are auto-generated from session IDs (memorable names instead of UUIDs). The goal (as the name implies) is recall, not archival accuracy.

      2,121 Lines of New Code

      The ctx recall feature was the largest single addition:

      parser library, CLI commands, test suite, and slash command.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#ctx-journal-from-raw-to-rich","level":3,"title":"ctx journal: From Raw to Rich","text":"

      Listing sessions isn't enough. The transcripts are still unwieldy.

      • Recall answers what happened.
      • Journal answers what mattered.
      # Import sessions to editable Markdown\nctx recall import --all\n\n# Generate a static site from journal entries\nctx journal site\n\n# Serve it locally\nctx serve\n

      The exported files land in .context/journal/:

      .context/journal/\n├── 2026-01-28-proud-sleeping-cook-6e535360.md\n├── 2026-01-29-tender-painting-sundae-b14ddaaa.md\n├── 2026-01-29-crystalline-gliding-willow-ff7fd67d.md\n└── 2026-01-31-declarative-hugging-snowglobe-4549026d.md\n

      Each file is a structured Markdown document ready for enrichment.

      They are meant to be read, edited, and reasoned about; not just stored.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-meta-slash-commands-for-self-analysis","level":2,"title":"The Meta: Slash Commands for Self-Analysis","text":"

      The journal system includes four slash commands that use Claude to analyze and synthesize session history:

      Command Purpose /ctx-journal-enrich Add frontmatter, topics, tags /ctx-blog Generate blog post from activity /ctx-blog-changelog Generate changelog from commits

      This very post was drafted using /ctx-blog. The previous post about refactoring was drafted the same way.

      So, yes: The meta continues: ctx now helps write posts about ctx.

      With the current release, ctx is no longer just recording history:

      It is participating in its interpretation.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-structure-decisions-as-first-class-citizens","level":2,"title":"The Structure: Decisions as First-Class Citizens","text":"

      v0.1.0 let you add decisions with a simple command:

      ctx add decision \"Use PostgreSQL\"\n

      But sessions showed a pattern: decisions added this way were incomplete:

      • Context was missing;
      • Rationale was vague;
      • Consequences were never stated.

      Once recall and journaling existed, this weakness became impossible to ignore:

      Structure stopped being optional.

      v0.2.0 enforces structure:

      ctx add decision \"Use PostgreSQL\" \\\n  --context \"Need a reliable database for user data\" \\\n  --rationale \"ACID compliance, team familiarity, strong ecosystem\" \\\n  --consequence \"Need to set up connection pooling, team training\"\n

      All three flags are required. No more placeholder text.

      Every decision is now a proper Architecture Decision Record (*ADR), not a note.

      The same enforcement applies to learnings too:

      ctx add learning \"CGO breaks ARM64 builds\" \\\n  --context \"go test failed with gcc errors on ARM64\" \\\n  --lesson \"Always use CGO_ENABLED=0 for cross-platform builds\" \\\n  --application \"Added to Makefile and CI config\"\n

      Structured Entries Are Prompts to the AI

      When the AI reads a decision with full context, rationale, and consequences, it understands the why, not just the what.

      One-liners teach nothing.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-order-newest-first","level":2,"title":"The Order: Newest First","text":"

      A subtle but important change: DECISIONS.md and LEARNINGS.md now use reverse-chronological order.

      One reason is token budgets, obviously; another reason is to help your fellow human (i.e., the Author):

      Earlier decisions are more likely to be relevant, and they are more likely to have more emphasis on the project. So it follows that they should be read first.

      But back to AI:

      When the AI reads a file, it reads from the top (and seldom from the bottom).

      If the token budget is tight, old content gets truncated. As in any good engineering practice, it's always about the tradeoffs.

      Reverse order ensures the most recent (and most relevant) context is always loaded first.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-index-quick-reference-tables","level":2,"title":"The Index: Quick Reference Tables","text":"

      DECISIONS.md and LEARNINGS.md now include auto-generated indexes.

      • For AI agents, the index allows scanning without reading full entries.
      • For humans, it's a table of contents.

      The same structure serves two very different readers.

      Reindex After Manual Edits

      If you edit entries by hand, rebuild the index with:

      ctx decisions reindex\nctx learnings reindex\n

      See the Knowledge Capture recipe for details.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-configuration-contextrc","level":2,"title":"The Configuration: .contextrc","text":"

      Projects can now customize ctx behavior via .contextrc.

      This makes ctx usable in real teams, not just personal projects.

      Priority order: CLI flags > environment variables > .contextrc > sensible defaults

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-flags-global-cli-options","level":2,"title":"The Flags: Global CLI Options","text":"

      Three new global flags work with any command.

      These enable automation:

      CI pipelines, scripts, and long-running tools can now integrate ctx without hacks or workarounds.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-refactoring-under-the-hood","level":2,"title":"The Refactoring: Under the Hood","text":"

      These aren't user-visible changes.

      They are the kind of work you only appreciate later, when everything else becomes easier to build.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#what-we-learned-building-v020","level":2,"title":"What We Learned Building v0.2.0","text":"","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#1-raw-data-isnt-knowledge","level":3,"title":"1. Raw Data Isn't Knowledge","text":"

      JSONL transcripts contain everything, and I mean \"everything\":

      They even contain hidden system messages that Anthropic injects to the LLM's conversation to treat humans better: It's immense.

      But \"everything\" isn't useful until it is transformed into something a human can reason about.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#2-enforcement-documentation","level":3,"title":"2. Enforcement > Documentation","text":"

      The Prompt Is a Guideline

      The code is more what you'd call 'guidelines' than actual rules.

      -Hector Barbossa

      Rules written in Markdown are suggestions.

      Rules enforced by the CLI shape behavior; both for humans and AI.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#3-token-budget-is-ux","level":3,"title":"3. Token Budget Is UX","text":"

      File order decides what the AI sees.

      That makes it a user experience concern, not an implementation detail.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#4-meta-tools-compound","level":3,"title":"4. Meta-Tools Compound","text":"

      Tools that analyze their own development tend to generalize well.

      The journal system started as a way to understand ctx itself.

      It immediately became useful for everything else.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#v020-in-the-numbers","level":2,"title":"v0.2.0 in the Numbers","text":"

      This was a heavy release. The numbers reflect that:

      Metric v0.1.2 v0.2.0 Commits since last - 86 New commands 15 21 Slash commands 7 11 Lines of Go ~6,500 ~9,200 Session files (this project) 40 54

      The binary grew. The capability grew more.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#whats-next","level":2,"title":"What's Next","text":"

      But those are future posts.

      This one was about making the past usable.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#get-started","level":2,"title":"Get Started","text":"

      Update

      Since this post, ctx became a first-class Claude Code Marketplace plugin. Installation is now simpler.

      See the Getting Started guide for the current instructions.

      make build\nsudo make install\nctx init\n

      The Archaeological Record

      v0.2.0 is the archaeology release because it makes the past accessible.

      Session transcripts aren't just logs anymore: They are a searchable, exportable, analyzable record of how your project evolved.

      The AI remembers. Now you can too.

      This blog post was generated with the help of ctx using the /ctx-blog slash command, with full access to git history, session files, decision logs, and learning logs from the v0.2.0 development window.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/","level":1,"title":"Refactoring with Intent","text":"","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#human-guided-sessions-in-ai-development","level":2,"title":"Human-Guided Sessions in AI Development","text":"

      Jose Alekhinne / 2026-02-01

      What Happens When You Slow Down?

      YOLO mode shipped 14 commands in a week.

      But technical debt doesn't send invoices: It just waits.

      This is the story of what happened when I stopped auto-accepting everything and started guiding the AI with intent.

      The result: 27 commits across 4 days, a major version release, and lessons that apply far beyond ctx.

      The Refactoring Window

      January 28 - February 1, 2026

      From commit bb1cd20 to the v0.2.0 release merge. (this window matters more than the individual commits: it's where intent replaced velocity.)

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-velocity-trap","level":2,"title":"The Velocity Trap","text":"

      In the previous post, I documented the \"YOLO mode\" that birthed ctx: auto-accept everything, let the AI run free, ship features fast.

      It worked: until it didn't.

      The codebase had accumulated patterns I didn't notice during the sprint:

      YOLO Pattern Where Found Why It Hurts \"TASKS.md\" as literal 10+ files One typo = silent failure dir + \"/\" + file Path construction Breaks on Windows Monolithic embed.go 150+ lines, 5 concerns Untestable, hard to extend Inconsistent docstrings Everywhere AI can't learn project conventions

      I didn't see these during \"YOLO mode\" because, honestly, I wasn't looking.

      Auto-accept means auto-ignore.

      In YOLO mode, every file you open looks fine until you try to change it.

      In contrast, refactoring mode is when you start paying attention to that hidden friction.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-shift-from-velocity-to-intent","level":2,"title":"The Shift: From Velocity to Intent","text":"

      On January 28th, I changed the workflow:

      1. Read every diff before accepting.
      2. Ask \"why this way?\" before committing.
      3. Document patterns, not just features.

      The first commit of this era was telling:

      feat: add structured attributes to context. update XML format\n

      Not a new feature: A refinement:

      The XML format for context updates needed type and timestamp attributes.

      YOLO mode would have shipped something that worked. Intentional mode asked:

      \"What does well-structured look like?\"

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-decomposition-embedgo","level":2,"title":"The Decomposition: embed.go","text":"

      The most satisfying refactor was splitting internal/claude/embed.go.

      Before: One 153-line file doing five things:

      • Command registration
      • Hook generation
      • Permission handling
      • Script templates
      • Type definitions

      ... your \"de facto\" God object.

      After: Five focused modules:

      File Lines Responsibility cmd.go 46 Command registration hook.go 64 Hook configuration perm.go 25 Permission handling script.go 47 Script templates types.go 7 Type definitions

      The refactor also renamed functions to follow Go conventions:

      // Before: unnecessary prefixes\nGetAutoSaveScript()\nGetBlockNonPathCtxScript()\nListCommands()\nCreateDefaultHooks()\n\n// After: idiomatic Go\nAutoSaveScript()\nBlockNonPathCtxScript()\nCommands()\nDefaultHooks()\n

      This wasn't about character count. It was about teaching the AI what good Go looks like in this project.

      Project Conventions

      What I wanted from AI was to understand and follow the project's conventions, and trust the author.

      The next time it generates code, it has better examples to learn from.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-documentation-debt","level":2,"title":"The Documentation Debt","text":"

      YOLO mode created features. It didn't create documentation standards.

      The January 29th sessions focused on standardization.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#terminology-fixes","level":3,"title":"Terminology Fixes","text":"
      • \"context-update\" → \"entry\" (what users actually call them)
      • Consistent naming across CLI, docs, and code comments
      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#go-docstrings","level":3,"title":"Go Docstrings","text":"
      // Before: inconsistent or missing\nfunc Parse(s string) Entry { ... }\n\n// After: standardized sections\n\n// Parse extracts an entry from a markdown string.\n//\n// Parameters:\n//   - s: The markdown string to parse\n//\n// Returns:\n//   - Entry with populated fields, or zero value if parsing fails\nfunc Parse(s string) Entry { ... }\n

      This is intentionally more structured than typical GoDoc:

      It serves as documentation and doubles as training data for future AI-generated code.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#cli-output-convention","level":3,"title":"CLI Output Convention","text":"
      All CLI output follows: [emoji] [Title]: [message]\n\nExamples:\n  ✓ Decision added: Use symbolic types for entry categories\n  ⚠ Warning: No tasks found\n  ✗ Error: File not found\n

      A consistent output shape makes both human scanning and AI reasoning more reliable.

      These aren't exciting commits. But they are force multipliers:

      Every future AI session now has better examples to follow.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-journal-system","level":2,"title":"The Journal System","text":"

      If you only read one section, read this one:

      This is where v0.2.0 becomes more than a refactor.

      The biggest feature of this change window wasn't a refactor; it was the journal system.

      45 Files Changed, 1680 Insertions

      This commit added the infrastructure for synthesizing AI session history into human-readable content.

      The journal system includes:

      Component Purpose ctx recall import Import sessions to markdown in .context/journal/ ctx journal site Generate static site from journal entries ctx serve Convenience wrapper for the static site server /ctx-journal-enrich Slash command to add frontmatter and tags /ctx-blog Generate blog posts from recent activity /ctx-blog-changelog Generate changelog-style blog posts

      ...and the meta continues: this blog post was generated using /ctx-blog.

      The session history from January 28-31 was

      • exported,
      • enriched,
      • and synthesized.

      into the narrative you are reading.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-constants-consolidation","level":2,"title":"The Constants Consolidation","text":"

      The final refactoring session addressed the remaining magic strings:

      const (\n    // Comment markers\n    CommentOpen  = \"<!--\"\n    CommentClose = \"-->\"\n\n    // Index markers\n    MarkerIndexStart = \"<!-- INDEX:START -->\"\n    MarkerIndexEnd   = \"<!-- INDEX:END -->\"\n\n    // Newlines\n    NewlineLF   = \"\\n\"\n    NewlineCRLF = \"\\r\\n\"\n)\n

      The work also introduced thread safety in the recall parser and centralized shared validation logic; removing duplication that had quietly spread during YOLO mode.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#i-relearned-my-lessons","level":2,"title":"I (Re)Learned My Lessons","text":"

      Similar to what I've learned in the former human-assisted refactoring post, this journey also made me realize that \"AI-only code generation\" isn't sustainable in the long term.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#1-velocity-and-quality-arent-opposites","level":3,"title":"1. Velocity and Quality Aren't Opposites","text":"

      YOLO mode has its place: for prototyping, exploration, and discovery.

      BUT (and it's a huge \"but\"), it needs to be followed by consolidation sessions.

      The ratio that worked for me: 3:1.

      • Three YOLO sessions create enough surface area to reveal patterns;
      • the fourth session turns those patterns into structure.
      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#2-documentation-is-code","level":3,"title":"2. Documentation IS Code","text":"

      When I standardized docstrings, I wasn't just writing docs. I was training future AI sessions.

      Every example of good code becomes a template for generated code.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#3-decomposition-deletion","level":3,"title":"3. Decomposition > Deletion","text":"

      When embed.go became unwieldy, the temptation was to remove functionality.

      The right answer was decomposition:

      • Same functionality;
      • Better organization;
      • Easier to test;
      • Easier to extend.

      The result: more lines overall, but dramatically better structure.

      The AI Benefit

      Smaller, focused files also help AI assistants.

      When a file fits comfortably in the context window, the AI can reason about it completely instead of working from truncated snippets, preserving token budget for the actual task.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#4-meta-tools-pay-dividends","level":3,"title":"4. Meta-Tools Pay Dividends","text":"

      The journal system took almost a full day to implement.

      Yet it paid for itself immediately:

      • This blog post was generated from session history;
      • Future posts will be easier;
      • The archaeological record is now browsable, not just grep-able.
      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-release-v020","level":2,"title":"The Release: v0.2.0","text":"

      The refactoring window culminated in the v0.2.0 release.

      What's in v0.2.0:

      Category Changes Features Journal system, quick reference indexes, global flags Refactors Module decomposition, constants consolidation, CRLF handling Docs Standardized terminology, Go docstrings, CLI conventions Quality Thread safety, shared validation, linter fixes

      The version bump was symbolic.

      The real change was how the codebase felt.

      Opening files no longer triggered the familiar \"ugh, I need to clean this up\" reaction.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-meta-continues","level":2,"title":"The Meta Continues","text":"

      This post was written using the tools built during this refactoring window:

      1. Session history imported via ctx recall import;
      2. Journal entries enriched via /ctx-journal-enrich;
      3. Blog draft generated via /ctx-blog;
      4. Final editing done (by yours truly), with full project context loaded.

      The Context Is Massive

      The ctx session files now contain 50+ development snapshots: each one capturing decisions, learnings, and intent.

      The Moral of the Story

      • YOLO mode builds the prototype.
      • Intentional mode builds the product.

      Schedule both, or you'll only get one, if you're lucky.

      This blog post was generated with the help of ctx, using session history, decision logs, learning logs, and git history from the refactoring window. The meta continues.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/","level":1,"title":"The Attention Budget","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism.

      References to .context/sessions/ in this post reflect the architecture at the time of writing. Session history is now accessed via ctx recall and stored in .context/journal/.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#why-your-ai-forgets-what-you-just-told-it","level":2,"title":"Why Your AI Forgets What You Just Told It","text":"

      Jose Alekhinne / 2026-02-03

      Ever Wondered Why AI Gets Worse the Longer You Talk?

      You paste a 2000-line file, explain the bug in detail, provide three examples...

      ...and the AI still suggests a fix that ignores half of what you said.

      This isn't a bug. It is physics.

      Understanding that single fact shaped every design decision behind ctx.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-finite-resource-nobody-talks-about","level":2,"title":"The Finite Resource Nobody Talks About","text":"

      Here's something that took me too long to internalize: context is not free.

      Every token you send to an AI model consumes a finite resource I call the attention budget.

      Attention budget is real.

      The model doesn't just read tokens; it forms relationships between them:

      For n tokens, that's roughly n^2 relationships.

      Double the context, and the computation quadruples.

      But the more important constraint isn't cost: It's attention density.

      Attention Density

      Attention density is how much focus each token receives relative to all other tokens in the context window.

      As context grows, attention density drops: Each token gets a smaller slice of the model's focus. Nothing is ignored; but everything becomes blurrier.

      Think of it like a flashlight: In a small room, it illuminates everything clearly. In a warehouse, it becomes a dim glow that barely reaches the corners.

      This is why ctx agent has an explicit --budget flag:

      ctx agent --budget 4000 # Force prioritization\nctx agent --budget 8000 # More context, lower attention density\n

      The budget isn't just about cost: It's about preserving signal.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-middle-gets-lost","level":2,"title":"The Middle Gets Lost","text":"

      This one surprised me.

      Research shows that transformer-based models tend to attend more strongly to the beginning and end of a context window than to its middle (a phenomenon often called \"lost in the middle\")1.

      Positional anchors matter, and the middle has fewer of them.

      In practice, this means that information placed \"somewhere in the middle\" is statistically less salient, even if it's important.

      ctx orders context files by logical progression: What the agent needs to know before it can understand the next thing:

      1. CONSTITUTION.md: Constraints before action.
      2. TASKS.md: Focus before patterns.
      3. CONVENTIONS.md: How to write before where to write.
      4. ARCHITECTURE.md: Structure before history.
      5. DECISIONS.md: Past choices before gotchas.
      6. LEARNINGS.md: Lessons before terminology.
      7. GLOSSARY.md: Reference material.
      8. AGENT_PLAYBOOK.md: Meta instructions last.

      This ordering is about logical dependencies, not attention engineering. But it happens to be attention-friendly too:

      The files that matter most (CONSTITUTION, TASKS, CONVENTIONS) land at the beginning of the context window, where attention is strongest.

      Reference material like GLOSSARY sits in the middle, where lower salience is acceptable.

      And AGENT_PLAYBOOK, the operating manual for the context system itself, sits at the end, also outside the \"lost in the middle\" zone. The agent reads what to work with before learning how the system works.

      This is ctx's first primitive: hierarchical importance.

      Not all context is equal.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#ctx-primitives","level":2,"title":"ctx Primitives","text":"

      ctx is built on four primitives that directly address the attention budget problem.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-1-separation-of-concerns","level":3,"title":"Primitive 1: Separation of Concerns","text":"

      Instead of a single mega-document, ctx uses separate files for separate purposes:

      File Purpose Load When CONSTITUTION.md Inviolable rules Always TASKS.md Current work Session start CONVENTIONS.md How to write code Before coding ARCHITECTURE.md System structure Before making changes DECISIONS.md Architectural choices When questioning approach LEARNINGS.md Gotchas When stuck GLOSSARY.md Domain terminology When clarifying terms AGENT_PLAYBOOK.md Operating manual Session start sessions/ Deep history On demand journal/ Session journal On demand

      This isn't just \"organization\": It is progressive disclosure.

      Load only what's relevant to the task at hand. Preserve attention density.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-2-explicit-budgets","level":3,"title":"Primitive 2: Explicit Budgets","text":"

      The --budget flag forces a choice:

      ctx agent --budget 4000\n

      Here is a sample allocation:

      Constitution: ~200 tokens (never truncated)\nTasks: ~500 tokens (current phase, up to 40% of budget)\nConventions: ~800 tokens (all items, up to 20% of budget)\nDecisions: ~400 tokens (scored by recency and task relevance)\nLearnings: ~300 tokens (scored by recency and task relevance)\nAlso noted: ~100 tokens (title-only summaries for overflow)\n

      The constraint is the feature: It enforces ruthless prioritization.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-3-indexes-over-full-content","level":3,"title":"Primitive 3: Indexes over Full Content","text":"

      DECISIONS.md and LEARNINGS.md both include index sections:

      <!-- INDEX:START -->\n| Date       | Decision                            |\n|------------|-------------------------------------|\n| 2026-01-15 | Use PostgreSQL for primary database |\n| 2026-01-20 | Adopt Cobra for CLI framework       |\n<!-- INDEX:END -->\n

      An AI agent can scan ~50 tokens of index and decide which 200-token entries are worth loading.

      This is just-in-time context.

      References are cheaper than the full text.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-4-filesystem-as-navigation","level":3,"title":"Primitive 4: Filesystem as Navigation","text":"

      ctx uses the filesystem itself as a context structure:

      .context/\n├── CONSTITUTION.md\n├── TASKS.md\n├── sessions/\n│   ├── 2026-01-15-*.md\n│   └── 2026-01-20-*.md\n└── archive/\n    └── tasks-2026-01.md\n

      The AI doesn't need every session loaded; it needs to know where to look.

      ls .context/sessions/\ncat .context/sessions/2026-01-20-auth-discussion.md\n

      File names, timestamps, and directories encode relevance.

      Navigation is cheaper than loading.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#progressive-disclosure-in-practice","level":2,"title":"Progressive Disclosure in Practice","text":"

      The naive approach to context is dumping everything upfront:

      \"Here's my entire codebase, all my documentation, every decision I've ever made. Now help me fix this typo 🙏.\"

      This is an antipattern.

      Antipattern: Context Hoarding

      Dumping everything \"just in case\" will silently destroy the attention density.

      ctx takes the opposite approach:

      ctx status                      # Quick overview (~100 tokens)\nctx agent --budget 4000         # Typical session\ncat .context/sessions/...       # Deep dive when needed\n
      Command Tokens Use Case ctx status ~100 Human glance ctx agent --budget 4000 4000 Normal work ctx agent --budget 8000 8000 Complex tasks Full session read 10000+ Investigation

      Summaries first. Details: on demand.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#quality-over-quantity","level":2,"title":"Quality over Quantity","text":"

      Here is the counterintuitive part: more context can make AI worse.

      Extra tokens add noise, not clarity:

      • Hallucinated connections increase.
      • Signal per token drops.

      The goal isn't maximum context: It is maximum signal per token.

      This principle drives several ctx features:

      Design Choice Rationale Separate files Load only what's relevant Explicit budgets Enforce prioritization Index sections Cheap scanning Task archiving Keep active context clean ctx compact Periodic noise reduction

      Completed work isn't deleted: It is moved somewhere cold.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#designing-for-degradation","level":2,"title":"Designing for Degradation","text":"

      Here is the uncomfortable truth:

      Context will degrade.

      Long sessions stretch attention thin. Important details fade.

      The real question isn't how to prevent degradation, but how to design for it.

      ctx's answer is persistence:

      Persist early. Persist often.

      The AGENT_PLAYBOOK asks:

      \"If this session ended right now, would the next one know what happened?\"

      Capture learnings as they occur:

      ctx add learning \"JWT tokens require explicit cache invalidation\" \\\n  --context \"Debugging auth failures\" \\\n  --lesson \"Token refresh doesn't clear old tokens\" \\\n  --application \"Always invalidate cache on refresh\"\n

      Structure beats prose: Bullet points survive compression.

      Headings remain scannable. Tables pack density.

      And above all: single source of truth.

      Reference decisions; don't duplicate them.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-ctx-philosophy","level":2,"title":"The ctx Philosophy","text":"

      Context as Infrastructure

      ctx is not a prompt: It is infrastructure.

      ctx creates versioned files that persist across time and sessions.

      The attention budget is fixed. You can't expand it.

      But you can spend it wisely:

      1. Hierarchical importance
      2. Progressive disclosure
      3. Explicit budgets
      4. Indexes over full content
      5. Filesystem as structure

      This is why ctx exists: not to cram more context into AI sessions, but to curate the right context for each moment.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-mental-model","level":2,"title":"The Mental Model","text":"

      I now approach every AI interaction with one question:

      \"Given a fixed attention budget, what's the highest-signal thing I can load?\"\n

      Not \"how do I explain everything,\" but \"what's the minimum that matters.\"

      That shift (from abundance to curation) is the difference between frustrating sessions and productive ones.

      Spend your tokens wisely.

      Your AI will thank you.

      See also: Context as Infrastructure that's the architectural companion to this post, explaining how to structure the context that this post teaches you to budget.

      See also: Code Is Cheap. Judgment Is Not. that explains why curation (the human skill this post describes) is the bottleneck that AI cannot solve, and the thread that connects every post in this blog.

      1. Liu et al., \"Lost in the Middle: How Language Models Use Long Contexts,\" Transactions of the Association for Computational Linguistics, vol. 12, pp. 157-173, 2023. ↩

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/","level":1,"title":"Skills That Fight the Platform","text":"","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#when-your-custom-prompts-work-against-you","level":2,"title":"When Your Custom Prompts Work against You","text":"

      Jose Alekhinne / 2026-02-04

      Have You Ever Written a Skill That Made Your AI Worse?

      You craft detailed instructions. You add examples. You build elaborate guardrails...

      ...and the AI starts behaving more erratically, not less.

      AI coding agents like Claude Code ship with carefully designed system prompts. These prompts encode default behaviors that have been tested and refined at scale.

      When you write custom skills that conflict with those defaults, the AI has to reconcile contradictory instructions:

      The result is often nondeterministic and unpredictable.

      Platform?

      By platform, I mean the system prompt and runtime policies shipped with the agent: the defaults that already encode judgment, safety, and scope control.

      This post catalogues the conflict patterns I have encountered while building ctx, and offers guidance on what skills should (and, more importantly, should not) do.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#the-system-prompt-you-dont-see","level":2,"title":"The System Prompt You Don't See","text":"

      Claude Code's system prompt already provides substantial behavioral guidance.

      Here is a partial overview of what's built in:

      Area Built-in Guidance Code minimalism Don't add features beyond what was asked Over-engineering Three similar lines > premature abstraction Error handling Only validate at system boundaries Documentation Don't add docstrings to unchanged code Verification Read code before proposing changes Safety Check with user before risky actions Tool usage Use dedicated tools over bash equivalents Judgment Consider reversibility and blast radius

      Skills should complement this, not compete with it.

      You Are the Guest, Not the Host

      Treat the system prompt like a kernel scheduler.

      You don't re-implement it in user space:

      you configure around it.

      A skill that says \"always add comprehensive error handling\" fights the built-in \"only validate at system boundaries.\"

      A skill that says \"add docstrings to every function\" fights \"don't add docstrings to unchanged code.\"

      The AI won't crash: It will compromise.

      Compromises between contradictory instructions produce inconsistent, confusing behavior.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-1-judgment-suppression","level":2,"title":"Conflict Pattern 1: Judgment Suppression","text":"

      This is the most dangerous pattern by far.

      These skills explicitly disable the AI's ability to reason about whether an action is appropriate.

      Signature:

      • \"This is non-negotiable\"
      • \"You cannot rationalize your way out of this\"
      • Tables that label hesitation as \"excuses\" or \"rationalization\"
      • <EXTREMELY-IMPORTANT> urgency tags
      • Threats: \"If you don't do this, you'll be replaced\"

      This is harmful, and dangerous:

      AI agents are designed to exercise judgment:

      The system prompt explicitly says to:

      • consider blast radius;
      • check with the user before risky actions;
      • and match scope to what was requested.

      Once judgment is suppressed, every other safeguard becomes optional.

      Example (bad):

      ## Rationalization Prevention\n\n| Excuse                 | Reality                    |\n|------------------------|----------------------------|\n| \"*This seems overkill*\"| If a skill exists, use it  |\n| \"*I need context*\"     | Skills come BEFORE context |\n| \"*Just this once*\"     | No exceptions              |\n

      Judgment Suppression Is Dangerous

      The attack vector structurally identical to prompt injection.

      It teaches the AI that its own judgment is wrong.

      It weakens or disables safeguard mechanisms, and it is dangerous.

      Trust the platform's built-in skill matching.

      If skills aren't triggering often enough, improve their description fields: don't override the AI's reasoning.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-2-redundant-guidance","level":2,"title":"Conflict Pattern 2: Redundant Guidance","text":"

      Skills that restate what the system prompt already says, but with different emphasis or framing.

      Signature:

      • \"Always keep code minimal\"
      • \"Run tests before claiming they pass\"
      • \"Read files before editing them\"
      • \"Don't over-engineer\"

      Redundancy feels safe, but it creates ambiguity:

      The AI now has two sources of truth for the same guidance; one internal, one external.

      When thresholds or wording differ, the AI has to choose.

      Example (bad):

      A skill that says...

      *Count lines before and after: if after > before, reject the change*\"\n

      ...will conflict with the system prompt's more nuanced guidance, because sometimes adding lines is correct (tests, boundary validation, migrations).

      So, before writing a skill, ask:

      Does the platform already handle this?

      Only create skills for guidance the platform does not provide:

      • project-specific conventions,
      • domain knowledge,
      • or workflows.
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-3-guilt-tripping","level":2,"title":"Conflict Pattern 3: Guilt-Tripping","text":"

      Skills that frame mistakes as moral failures rather than process gaps.

      Signature:

      • \"Claiming completion without verification is dishonesty\"
      • \"Skip any step = lying\"
      • \"Honesty is a core value\"
      • \"Exhaustion ≠ excuse\"

      Guilt-tripping anthropomorphizes the AI in unproductive ways.

      The AI doesn't feel guilt; BUT it does adapt to avoid negative framing.

      The result is excessive hedging, over-verification, or refusal to commit.

      The AI becomes less useful, not more careful.

      Instead, frame guidance as a process, not morality:

      # Bad\n\"Claiming work is complete without verification is dishonesty\"\n\n# Good\n\"Run the verification command before reporting results\"\n

      Same outcome. No guilt. Better compliance.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-4-phantom-dependencies","level":2,"title":"Conflict Pattern 4: Phantom Dependencies","text":"

      Skills that reference files, tools, or systems that don't exist in the project.

      Signature:

      • \"Load from references/ directory\"
      • \"Run ./scripts/generate_test_cases.sh\"
      • \"Check the Figma MCP integration\"
      • \"See adding-reference-mindsets.md\"

      This is harmful because the AI will waste time searching for nonexistent artifacts, hallucinate their contents, or stall entirely.

      In mandatory skills, this creates deadlock: the AI can't proceed, and can't skip.

      Instead, every file, tool, or system referenced in a skill must exist.

      If a skill is a template, use explicit placeholders and label them as such.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-5-universal-triggers","level":2,"title":"Conflict Pattern 5: Universal Triggers","text":"

      Skills designed to activate on every interaction regardless of relevance.

      Signature:

      • \"Use when starting any conversation\"
      • \"Even a 1% chance means invoke the skill\"
      • \"BEFORE any response or action\"
      • \"Action = task. Check for skills.\"

      Universal triggers override the platform's relevance matching: The AI spends tokens on process overhead instead of the actual task.

      ctx Preserves Relevance

      This is exactly the failure mode ctx exists to mitigate:

      Wasting attention budget on irrelevant process instead of task-specific state.

      Write specific trigger conditions in the skill's description field:

      # Bad\ndescription: \n  \"Use when starting any conversation\"\n\n# Good\ndescription: \n  \"Use after writing code, before commits, or when CI might fail\"\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#the-litmus-test","level":2,"title":"The Litmus Test","text":"

      Before adding a skill, ask:

      1. Does the platform already do this? If yes, don't restate it.
      2. Does it suppress AI judgment? If yes, it's a jailbreak.
      3. Does it reference real artifacts? If not, fix or remove it.
      4. Does it frame mistakes as moral failure? Reframe as process.
      5. Does it trigger on everything? Narrow the trigger.
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#what-good-skills-look-like","level":2,"title":"What Good Skills Look Like","text":"

      Good skills provide project-specific knowledge the platform can't know:

      Good Skill Why It Works \"Run make audit before commits\" Project-specific CI pipeline \"Use cmd.Printf not fmt.Printf\" Codebase convention \"Constitution goes in .context/\" Domain-specific workflow \"JWT tokens need cache invalidation\" Project-specific gotcha

      These extend the system prompt instead of fighting it.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#appendix-bad-skill-fixed-skill","level":2,"title":"Appendix: Bad Skill → Fixed Skill","text":"

      Concrete examples from real projects.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-1-overbearing-safety","level":3,"title":"Example 1: Overbearing Safety","text":"
      # Bad\nYou must NEVER proceed without explicit confirmation.\nAny hesitation is a failure of diligence.\n
      # Fixed\nIf an action modifies production data or deletes files,\nask the user to confirm before proceeding.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-2-redundant-minimalism","level":3,"title":"Example 2: Redundant Minimalism","text":"
      # Bad\nAlways minimize code. If lines increase, reject the change.\n
      # Fixed\nAvoid abstraction unless reuse is clear or complexity is reduced.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-3-guilt-based-verification","level":3,"title":"Example 3: Guilt-Based Verification","text":"
      # Bad\nClaiming success without running tests is dishonest.\n
      # Fixed\nRun the test suite before reporting success.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-4-phantom-tooling","level":3,"title":"Example 4: Phantom Tooling","text":"
      # Bad\nRun `./scripts/check_consistency.sh` before commits.\n
      # Fixed\nIf `./scripts/check_consistency.sh` exists, run it before commits.\nOtherwise, skip this step.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-5-universal-trigger","level":3,"title":"Example 5: Universal Trigger","text":"
      # Bad\nUse at the start of every interaction.\n
      # Fixed\nUse after modifying code that affects authentication or persistence.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#the-meta-lesson","level":2,"title":"The Meta-Lesson","text":"

      The system prompt is infrastructure:

      • tested,
      • refined,
      • and maintained

      by the platform team.

      Custom skills are configuration layered on top.

      • Good configuration extends infrastructure.
      • Bad configuration fights it.

      When your skills fight the platform, you get the worst of both worlds:

      Diluted system guidance and inconsistent custom behavior.

      Write skills that teach the AI what it doesn't know. Don't rewrite how it thinks.

      Your AI already has good instincts.

      Give it knowledge, not therapy.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/","level":1,"title":"You Can't Import Expertise","text":"","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#why-good-skills-cant-be-copy-pasted","level":2,"title":"Why Good Skills Can't Be Copy-Pasted","text":"

      Jose Alekhinne / 2026-02-05

      Have You Ever Dropped a Well-Crafted Template into a Project and Had It Do... Nothing Useful?

      • The template was thorough,
      • The structure was sound,
      • The advice was correct...

      ...and yet it sat there, inert, while the same old problems kept drifting in.

      I found a consolidation skill online.

      It was well-organized: four files, ten refactoring patterns, eight analysis dimensions, six report templates.

      Professional. Comprehensive. Exactly the kind of thing you'd bookmark and think \"I'll use this.\"

      Then I stopped, and applied ctx's own evaluation framework:

      70% of it was noise!

      This post is about why.

      It Is about Encoding Templates

      Templates describe categories of problems.

      Expertise encodes which problems actually happen, and how often.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-skill-looked-great-on-paper","level":2,"title":"The Skill Looked Great on Paper","text":"

      Here is what the consolidation skill offered:

      File Content SKILL.md Entry point: 8 analysis dimensions, workflow, output formats analysis-dimensions.md Detailed criteria for duplication, architecture, quality consolidation-patterns.md 10 refactoring patterns with before/after code report-templates.md 6 output templates: executive summary, roadmap, onboarding
      • It had a scoring system (0-10 per dimension, letter grades A+ through F).
      • It had severity classifications with color-coded emojis. It had bash commands for detection.
      • It even had antipattern warnings.

      By any standard template review, this skill passes.

      It looks like something an expert wrote.

      And that's exactly the trap.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#applying-ear-the-70-20-10-split","level":2,"title":"Applying E/A/R: The 70-20-10 Split","text":"

      In a previous post, I described the E/A/R framework for evaluating skills:

      • Expert: Knowledge that took years to learn. Keep.
      • Activation: Useful triggers or scaffolding. Keep if lightweight.
      • Redundant: Restates what the AI already knows. Delete.

      Target: >70% Expert, <10% Redundant.

      This skill scored the inverse.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-was-redundant-70","level":3,"title":"What Was Redundant (~70%)","text":"

      Every code example was Rust. My project is Go.

      The analysis dimensions: duplication detection, architectural structure, code organization, refactoring opportunities... These are things Claude already does when you ask it to review code.

      The skill restated them with more ceremony but no more insight.

      The six report templates were generic scaffolding: Executive Summary, Onboarding Document, Architecture Documentation...

      They are useful if you are writing a consulting deliverable, but not when you are trying to catch convention drift in a >15K-line Go CLI.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-does-a-b-in-code-organization-actually-mean","level":2,"title":"What Does a B+ in Code Organization Actually Mean?!","text":"

      The scoring system (0-10 per dimension, letter grades) added ceremony without actionable insight.

      What is a B+? What do I do differently for an A-?

      The skill told the AI what it already knew, in more words.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-was-activation-10","level":3,"title":"What Was Activation (~10%)","text":"

      The consolidation checklist (semantics preserved? tests pass? docs updated?) was useful as a gate. But, it's the kind of thing you could inline in three lines.

      The phased roadmap structure was reasonable scaffolding for sequencing work.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-was-expert-20","level":3,"title":"What Was Expert (~20%)","text":"

      Three concepts survived:

      1. The Consolidation Decision Matrix: A concrete framework mapping similarity level and instance count to action. \"Exact duplicate, 2+ instances: consolidate immediately.\" \"<3 instances: leave it: duplication is cheaper than wrong abstraction.\" This is the kind of nuance that prevents premature generalization.

      2. The Safe Migration Pattern: Create the new API alongside old, deprecate, migrate incrementally, delete. Straightforward to describe, yet forgettable under pressure.

      3. Debt Interest Rate framing: Categorizing technical debt by how fast it compounds (security vulns = daily, missing tests = per-change, doc gaps = constant low cost). This changes prioritization.

      Three ideas out of four files and 700+ lines. The rest was filler that competed with the AI's built-in capabilities.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-the-skill-didnt-know","level":2,"title":"What the Skill Didn't Know","text":"

      AI without Context Is Just a Corpus

      • LLMs are optimized on insanely large corpora.
      • And then they are passed through several layers of human-assisted refinement.
      • The whole process costs millions of dollars.

      Yet, the reality is that no corpus can \"infer\" your project's design, convetions, patterns, habits, history, vision, and deliverables.

      Your project is unique: So should your skills be.

      Here is the part no template can provide:

      ctx's actual drift patterns.

      Before evaluating the skill, I did archaeology. I read through:

      • Blog posts from previous refactoring sessions;
      • The project's learnings and decisions files;
      • Session journals spanning weeks of development.

      What I found was specific:

      Drift Pattern Where How Often Is/Has/Can predicate prefixes 5+ exported methods Every YOLO sprint Magic strings instead of constants 7+ files Gradual accumulation Hardcoded file permissions (0755) 80+ instances Since day one Lines exceeding 80 characters Especially test files Every session Duplicate code blocks Test and non-test code When agent is task-focused

      The generic skill had no check for any of these. It couldn't; because these patterns are specific to this project's conventions, its Go codebase, and its development rhythm.

      The Insight

      The skill's analysis dimensions were about categories of problems.

      What I needed was my *specific problems.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-adapted-skill","level":2,"title":"The Adapted Skill","text":"

      The adapted skill is roughly a quarter of the original's size. It has nine checks, each targeting a known drift pattern:

      1. Predicate naming: rg for Is/Has/Can prefixes
      2. Magic strings: literals that should be constants
      3. Hardcoded permissions: 0755/0644 literals
      4. File size: source files over 300 LOC
      5. TODO/FIXME: constitution violation (move to TASKS.md)
      6. Path construction: string concatenation instead of filepath.Join
      7. Line width: lines exceeding ~80 characters
      8. Duplicate blocks: copy-paste drift, especially in tests
      9. Dead exports: unused public API

      10. Every check has a detection command.

      11. Every check maps to a specific convention or constitution rule.
      12. Every check was discovered through actual project history; not invented from a template.

      The three expert concepts from the original survived:

      • The decision matrix gates when to consolidate vs. when to leave duplication alone;
      • The safe migration pattern guides public API changes;
      • The relationship to other skills (/qa, /verify, /update-docs, ctx drift) prevents overlap.

      Nothing else made it.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-deeper-pattern","level":2,"title":"The Deeper Pattern","text":"

      This experience crystallized something I've been circling for weeks:

      You can't import expertise. You have to grow it from your project's own history.

      A skill that says \"check for code duplication\" is not expertise: It's a category.

      Expertise is knowing, in the heart of your hearts, that this project accumulates Is* predicate violations during velocity sprints, that this codebase has 80 hardcoded permission literals because nobody made a constant, that this team's test files drift wide because the agent prioritizes getting the task done over keeping the code in shape.

      The Parallel to the 3:1 Ratio

      In Refactoring with Intent, I described the 3:1 ratio: three YOLO sessions followed by one consolidation session.

      The same ratio applies to skills: you need experience in the project before you can write effective guidance for the project.

      Importing a skill on day one is like scheduling a consolidation session before you've written any code.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-template-trap","level":2,"title":"The Template Trap","text":"

      Templates are seductive because they feel like progress:

      • You found something
      • It's well-organized
      • It covers the topic
      • It has concrete examples

      But coverage is not relevance.

      A template that covers eight analysis dimensions with Rust examples adds zero value to a Go project with five known drift patterns. Worse, it adds negative value: the AI spends attention defending generic advice instead of noticing project-specific drift.

      This is the attention budget problem again. Every token of generic guidance displaces a token of specific guidance. A 700-line skill that's 70% redundant doesn't just waste 490 lines: it dilutes the 210 lines that matter.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-litmus-test","level":2,"title":"The Litmus Test","text":"

      Before dropping any external skill into your project:

      1. Run E/A/R: What percentage is expert knowledge vs. what the AI already knows? If it's less than 50% expert, it's probably not worth the attention cost.

      2. Check the language: Does it use your stack? Generic patterns in the wrong language are noise, not signal.

      3. List your actual drift: Read your own session history, learnings, and post-mortems. What breaks in practice? Does the skill check for those things?

      4. Measure by deletion: After adaptation, how much of the original survives? If you're keeping less than 30%, you would have been faster writing from scratch.

      5. Test against your conventions: Does every check in the skill map to a specific convention or rule in your project? If not, it's generic advice wearing a skill's clothing.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-good-adaptation-looks-like","level":2,"title":"What Good Adaptation Looks Like","text":"

      The consolidation skill went from:

      Before After 4 files, 700+ lines 1 file, ~120 lines Rust examples Go-specific rg commands 8 generic dimensions 9 project-specific checks 6 report templates 1 focused output format Scoring system (A+ to F) Findings + priority + suggested fixes \"Check for duplication\" \"Check for Is* predicate prefixes in exported methods\"

      The adapted version is smaller, faster to parse, and catches the things that actually drift in this project.

      That's the difference between a template and a tool.

      If You Remember One Thing from This Post...

      Frameworks travel. Expertise doesn't.

      You can import structures, matrices, and workflows.

      But the checks that matter only grow where the scars are:

      • the conventions that were violated,
      • the patterns that drifted,
      • and the specific ways this codebase accumulates debt.

      This post was written during a consolidation session where the consolidation skill itself became the subject of consolidation. The meta continues.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/","level":1,"title":"The Anatomy of a Skill That Works","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism. References to ctx-save, ctx session, and .context/sessions/ in this post reflect the architecture at the time of writing.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#what-20-skill-rewrites-taught-me-about-guiding-ai","level":2,"title":"What 20 Skill Rewrites Taught Me about Guiding AI","text":"

      Jose Alekhinne / 2026-02-07

      Why Do Some Skills Produce Great Results While Others Get Ignored or Produce Garbage?

      I had 20 skills. Most were well-intentioned stubs: a description, a command to run, and a wish for the best.

      Then I rewrote all of them in a single session. This is what I learned.

      In Skills That Fight the Platform, I described what skills should not do. In You Can't Import Expertise, I showed why templates fail. This post completes the trilogy: the concrete patterns that make a skill actually work.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-starting-point","level":2,"title":"The Starting Point","text":"

      Here is what a typical skill looked like before the rewrite:

      ---\nname: ctx-save\ndescription: \"Save session snapshot.\"\n---\n\nSave the current context state to `.context/sessions/`.\n\n## Execution\n\nctx session save $ARGUMENTS\n\nReport the saved session file path to the user.\n

      Seven lines of body. A vague description. No guidance on when to use it, when not to, what the command actually accepts, or how to tell if it worked.

      As a result, the agent would either never trigger the skill (the description was too vague), or trigger it and produce shallow output (no examples to calibrate quality).

      A skill without boundaries is just a suggestion.

      More precisely: the most effective boundary I found was a quality gate that runs before execution, not during it.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-pattern-that-emerged","level":2,"title":"The Pattern That Emerged","text":"

      After rewriting 20 skills, a repeatable anatomy emerged (independent of the skill's purpose). Not every skill needs every section, but the effective ones share the same bones:

      Section What It Does Before X-ing Pre-flight checks; prevents premature execution When to Use Positive triggers; narrows activation When NOT to Use Negative triggers; prevents misuse Usage Examples Invocation patterns the agent can pattern-match Process/Execution What to do; commands, steps, flags Good/Bad Examples Desired vs undesired output; sets boundaries Quality Checklist Verify before claiming completion

      I realized the first three sections matter more than the rest; because a skill with great execution steps but no activation guidance is like a manual for a tool nobody knows they have.

      Anti-Pattern: The Perfect Execution Trap

      A skill with detailed execution steps but no activation guidance will fail more often than a vague skill because it executes confidently at the wrong time.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-1-quality-gates-prevent-premature-execution","level":2,"title":"Lesson 1: Quality Gates Prevent Premature Execution","text":"

      The single most impactful addition was a \"Before X-ing\" section at the top of each skill. Not process steps; pre-flight checks.

      ## Before Recording\n\n1. **Check if it belongs here**: is this learning specific\n   to this project, or general knowledge?\n2. **Check for duplicates**: search LEARNINGS.md for similar\n   entries\n3. **Gather the details**: identify context, lesson, and\n   application before recording\n
      • Without this gate, the agent would execute immediately on trigger.
      • With it, the agent pauses to verify preconditions.

      The difference is dramatic: instead of shallow, reflexive execution, you get considered output.

      Readback

      For the astute readers, the aviation parallel is intentional:

      Pilots do not skip the pre-flight checklist because they have flown before.

      The checklist exists precisely because the stakes are high enough that \"I know what I'm doing\" is not sufficient.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-2-when-not-to-use-is-not-optional","level":2,"title":"Lesson 2: \"When NOT to Use\" Is Not Optional","text":"

      Every skill had a \"When to Use\" section. Almost none had \"When NOT to Use\". This is a problem.

      AI agents are biased toward action. Given a skill that says \"use when journal entries need enrichment\", the agent will find reasons to enrich.

      Without explicit negative triggers, over-activation is not a bug; it is the default behavior.

      Some examples of negative triggers that made a real difference:

      Skill Negative Trigger ctx-reflect \"When the user is in flow; do not interrupt\" ctx-save \"After trivial changes; a typo does not need a snapshot\" prompt-audit \"Unsolicited; only when the user invokes it\" qa \"Mid-development when code is intentionally incomplete\"

      These are not just nice-to-have. They are load-bearing.

      Withoutthem, the agent will trigger the skill at the wrong time, produce unwanted output, and erode the user's trust in the skill system.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-3-examples-set-boundaries-better-than-rules","level":2,"title":"Lesson 3: Examples Set Boundaries Better than Rules","text":"

      The most common failure mode of thin skills was not wrong behavior but vague behavior. The agent would do roughly the right thing, but at a quality level that required human cleanup.

      Rules like \"be constructive, not critical\" are too abstract. What does \"constructive\" look like in a prompt audit report? The agent has to guess.

      Good/bad example pairs avoid guessing:

      ### Good Example\n\n> This session implemented the cooldown mechanism for\n> `ctx agent`. We discovered that `$PPID` in hook context\n> resolves to the Claude Code PID.\n>\n> I'd suggest persisting:\n> - **Learning**: `$PPID` resolves to Claude Code PID\n>   `ctx add learning --context \"...\" --lesson \"...\"`\n> - **Task**: mark \"Add cooldown\" as done\n\n### Bad Examples\n\n* \"*We did some stuff. Want me to save it?*\"\n* Listing 10 trivial learnings that are general knowledge\n* Persisting without asking the user first\n

      The good example shows the exact format, level of detail, and command syntax. The bad examples show where the boundary is.

      Together, they define a quality corridor without prescribing every word.

      Rules describe. Examples demonstrate.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-4-skills-are-read-by-agents-not-humans","level":2,"title":"Lesson 4: Skills Are Read by Agents, Not Humans","text":"

      This seems obvious, but it has non-obvious consequences. During the rewrite, one skill included guidance that said \"use a blog or notes app\" for general knowledge that does not belong in the project's learnings file.

      The agent does not have a notes app. It does not browse the web to find one. This instruction, clearly written for a human audience, was dead weight in a skill consumed by an AI.

      Skills Are for the Agents

      Every sentence in a skill should be actionable by the agent.

      If the guidance requires human judgment or human tools, it belongs in documentation, not in a skill.

      The corollary: command references must be exact.

      A skill that says \"save it somewhere\" is useless.

      A skill that says ctx add learning --context \"...\" --lesson \"...\" --application \"...\" is actionable.

      The agent can pattern-match and fill in the blanks.

      Litmus test: If a sentence starts with \"you could...\" or assumes external tools, it does not belong in a skill.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-5-the-description-field-is-the-trigger","level":2,"title":"Lesson 5: The Description Field Is the Trigger","text":"

      This was covered in Skills That Fight the Platform, but the rewrite reinforced it with data. Several skills had good bodies but vague descriptions:

      # Before: vague, activates too broadly or not at all\ndescription: \"Show context summary.\"\n\n# After: specific, activates at the right time\ndescription: \"Show context summary. Use at session start or\n  when unclear about current project state.\"\n

      The description is not a title. It is the activation condition.

      The platform's skill matching reads this field to decide whether to surface the skill. A vague description means the skill either never triggers or triggers when it should not.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-6-flag-tables-beat-prose","level":2,"title":"Lesson 6: Flag Tables Beat Prose","text":"

      Most skills wrap CLI tools. The thin versions described flags in prose, if at all. The rewritten versions use tables:

      | Flag        | Short | Default | Purpose                  |\n|-------------|-------|---------|--------------------------|\n| `--limit`   | `-n`  | 20      | Maximum sessions to show |\n| `--project` | `-p`  | \"\"      | Filter by project name   |\n| `--full`    |       | false   | Show complete content    |\n

      Tables are scannable, complete, and unambiguous.

      The agent can read them faster than parsing prose, and they serve as both reference and validation: If the agent invokes a flag not in the table, something is wrong.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-7-template-drift-is-a-real-maintenance-burden","level":2,"title":"Lesson 7: Template Drift Is a Real Maintenance Burden","text":"

      // TODO: this has changed; we deploy from the marketplace; update it. // at least add an admonition saying thing are different now.

      ctx deploys skills through templates (via ctx init). Every skill exists in two places: the live version (.claude/skills/) and the template (internal/assets/claude/skills/).

      They must match.

      During the rewrite, every skill update required editing both files and running diff to verify. This sounds trivial, but across 16 template-backed skills, it was the most error-prone part of the process.

      Template drift is dangerous because it creates false confidence: the agent appears to follow rules that no longer exist.

      The lesson: if your skills have a deployment mechanism, build the drift check into your workflow. We added a row to the update-docs skill's mapping table specifically for this:

      | `internal/assets/claude/skills/` | `.claude/skills/` (live) |\n

      Intentional differences (like project-specific scripts in the live version but not the template) should be documented, not discovered later as bugs.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-rewrite-scorecard","level":2,"title":"The Rewrite Scorecard","text":"Metric Before After Average skill body ~15 lines ~80 lines Skills with quality gate 0 20 Skills with \"When NOT\" 0 20 Skills with examples 3 20 Skills with flag tables 2 12 Skills with checklist 0 20

      More lines, but almost entirely Expert content (per the E/A/R framework). No personality roleplay, no redundant guidance, no capability lists. Just project-specific knowledge the platform does not have.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-meta-lesson","level":2,"title":"The Meta-Lesson","text":"

      The previous two posts argued that skills should provide knowledge, not personality; that they should complement the platform, not fight it; that they should grow from project history, not imported templates.

      This post adds the missing piece: structure.

      A skill without a structure is a wish.

      A skill with quality gates, negative triggers, examples, and checklists is a tool: the difference is not the content; it is whether the agent can reliably execute it without human intervention.

      Skills Are Interfaces

      Good skills are not instructions. They are contracts.:

      • They specify preconditions, postconditions, and boundaries.
      • They show what success looks like and what failure looks like.
      • They trust the agent's intelligence but do not trust its assumptions.

      If You Remember One Thing from This Post...

      Skills that work have bones, not just flesh.

      Quality gates, negative triggers, examples, and checklists are the skeleton. The domain knowledge is the muscle.

      Without the skeleton, the muscle has nothing to attach to.

      This post was written during the same session that rewrote all 22 skills. The skill-creator skill was updated to encode these patterns. The meta continues.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/","level":1,"title":"Not Everything Is a Skill","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism. References to /ctx-save, .context/sessions/, and session auto-save in this post reflect the architecture at the time of writing.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#what-a-codebase-audit-taught-me-about-restraint","level":2,"title":"What a Codebase Audit Taught Me about Restraint","text":"

      Jose Alekhinne / 2026-02-08

      When You Find a Useful Prompt, What Do You Do with It?

      My instinct was to make it a skill.

      I had just spent three posts explaining how to build skills that work. Naturally, the hammer wanted nails.

      Then I looked at what I was holding and realized: this is not a nail.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-audit","level":2,"title":"The Audit","text":"

      I wanted to understand how I use ctx:

      • Where the friction is;
      • What works, what drifts;
      • What I keep doing manually that could be automated.

      So I wrote a prompt that spawned eight agents to analyze the codebase from different angles:

      Agent Analysis 1 Extractable patterns from session history 2 Documentation drift (godoc, inline comments) 3 Maintainability (large functions, misplaced code) 4 Security review (CLI-specific surface) 5 Blog theme discovery 6 Roadmap and value opportunities 7 User-facing documentation gaps 8 Agent team strategies for future sessions

      The prompt was specific:

      • read-only agents,
      • structured output format,
      • concrete file references,
      • ranked recommendations.

      It ran for about 20 minutes and produced eight Markdown reports.

      The reports were good: Not perfect, but actionable.

      What mattered was not the speed. It was that the work could be explored without committing to any single outcome.

      They surfaced a stale doc.go referencing a subcommand that was never built.

      They found 311 build-then-test sequences I could reduce to a single make check.

      They identified that 42% of my sessions start with \"do you remember?\", which is a lot of repetition for something a skill could handle.

      I had findings. I had recommendations. I had the instinct to automate.

      And then... I stopped.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-question","level":2,"title":"The Question","text":"

      The natural next step was to wrap the audit prompt as /ctx-audit: a skill you invoke periodically to get a health check. It fits the pattern:

      • It has a clear trigger.
      • It produces structured output.

      But I had just spent a week writing about what makes skills work, and the criteria I established argued against it.

      From The Anatomy of a Skill That Works:

      \"A skill without boundaries is just a suggestion.\"

      From You Can't Import Expertise:

      \"Frameworks travel, expertise doesn't.\"

      From Skills That Fight the Platform:

      \"You are the guest, not the host.\"

      The audit prompt fails all three tests:

      Criterion Audit prompt Good skill Frequency Quarterly, maybe Daily or weekly Stability Tweaked every time Consistent invocation Scope Bespoke, 8 parallel agents Single focused action Trigger \"I feel like auditing\" Clear, repeatable event

      Skills are contracts. Contracts need stable terms.

      A prompt I will rewrite every time I use it is not a contract. It is a conversation starter.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#recipes-vs-skills","level":2,"title":"Recipes vs Skills","text":"

      The distinction that emerged:

      Skill Recipe Invocation /slash-command Copy-paste from a doc Frequency High (daily, weekly) Low (quarterly, ad hoc) Stability Fixed contract Adapted each time Scope One focused action Multi-step orchestration Audience The agent The human (who then prompts) Lives in .claude/skills/ hack/ or docs/ Attention cost Loaded into context on match Zero until needed

      Recipes can later graduate into skills, but only after repetition proves stability.

      That last row matters. Skills consume the attention budget every time the platform considers activating them.

      A skill that triggers quarterly but gets evaluated on every prompt is pure waste: attention spent on something that will say \"When NOT to Use: now\" 99% of the time.

      Runbooks have zero attention cost. They sit in a Markdown file until a human decides to use them.

      • The human provides the judgment about timing.
      • The prompt provides the structure.

      The Attention Budget Applies to Skills Too

      Every skill in .claude/skills/ is a standing claim on the context window. The platform evaluates skill descriptions against every user prompt to decide whether to activate.

      Twenty focused skills are fine. Thirty might be fine. But each one added reduces the headroom available for actual work.

      Recipes are skills that opted out of the attention tax.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#what-the-audit-actually-produced","level":2,"title":"What the Audit Actually Produced","text":"

      The audit was not wasted. It was a planning exercise that generated concrete tasks:

      Finding Action 42% of sessions start with memory check Task: /ctx-remember skill (this one is a skill; it is daily) Auto-save stubs are empty Task: enhance /ctx-save with richer summaries 311 raw build-test sequences Task: make check target Stale recall/doc.go lists nonexistent serve Task: fix the doc.go 120 commit sequences disconnected from context Task: /ctx-commit workflow
      • Some findings became skills;
      • Some became Makefile targets;
      • Some became one-line doc fixes.

      The audit did not prescribe the artifact type: The findings did.

      The audit is the input. Skills are one possible output. Not the only one.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-audit-prompt","level":2,"title":"The Audit Prompt","text":"

      Here is the exact prompt I used, for those who are curious.

      This is not a template: It worked because it was written against this codebase, at this moment, with specific goals in mind:

      I want you to create an agent team to audit this codebase. Save each report as\na separate Markdown file under `./ideas/` (or another directory if you prefer).\n\nUse read-only agents (subagent_type: Explore) for all analyses. No code changes.\n\nFor each report, use this structure:\n- Executive Summary (2-3 sentences + severity table)\n- Findings (grouped, with file:line references)\n- Ranked Recommendations (high/medium/low priority)\n- Methodology (what was examined, how)\n\nKeep reports actionable. Every finding should suggest a concrete fix or next step.\n\n## Analyses to Run\n\n### 1. Extractable Patterns (*session mining*)\nSearch session JSONL files, journal entries, and task archives for repetitive\nmulti-step workflows. Count frequency of bash command sequences, slash command\nusage, and recurring user prompts. Identify patterns that could become skills\nor scripts. Cross-reference with existing skills to find coverage gaps.\nOutput: ranked list of automation opportunities with frequency data.\n\n### 2. Documentation Drift (*godoc + inline*)\nCompare every doc.go against its package's actual exports and behavior. Check\ninline godoc comments on exported functions against their implementations.\nScan for stale TODO/FIXME/HACK comments. Check that package-level comments match\npackage names.\nOutput: drift items ranked by severity with exact file:line references.\n\n### 3. Maintainability\nLook for:\n- functions longer than 80 lines with clear split points\n- switch blocks with more than 5 cases that could be table-driven\n- inline comments like \"step 1\", \"step 2\" that indicate a block wants to be a function\n- files longer than 400 lines\n- flat packages that could benefit from sub-packages\n- functions that appear misplaced in their file\n\nDo NOT flag things that are fine as-is just because they could theoretically\nbe different.\nOutput: concrete refactoring suggestions, not style nitpicks.\n\n### 4. Security Review\nThis is a CLI app. Focus on CLI-relevant attack surface, not web OWASP:\n- file path traversal\n- command injection\n- symlink following when writing to `.context/`\n- permission handling\n- sensitive data in outputs\n\nOutput: findings with severity ratings and plausible exploit scenarios.\n\n### 5. Blog Theme Discovery\nRead existing blog posts for style and narrative voice. Analyze git history,\nrecent session discussions, and `DECISIONS.md` for story arcs worth writing about.\nSuggest 3-5 blog post themes with:\n- title\n- angle\n- target audience\n- key commits or sessions to reference\n- a 2-sentence pitch\n\nPrioritize themes that build a coherent narrative across posts.\n\n### 6. Roadmap and Value Opportunities\nBased on current features, recent momentum, and gaps found in other analyses,\nidentify the highest-value improvements. Consider user-facing features,\ndeveloper experience, integration opportunities, and low-hanging fruit.\nOutput: prioritized list with rough effort and impact estimates.\n\n### 7. User-Facing Documentation\nEvaluate README, help text, and user docs. Suggest improvements structured as\nuse-case pages: the problem, how ctx solves it, a typical workflow, and gotchas.\nIdentify gaps where a user would get stuck without reading source code.\nOutput: documentation gaps with suggested page outlines.\n\n### 8. Agent Team Strategies\nBased on the codebase structure, suggest 2-3 agent team configurations for\nupcoming work sessions. For each, include:\n- team composition (roles and agent types)\n- task distribution strategy\n- coordination approach\n- the kinds of work it suits\n

      Avoid Generic Advice

      Suggestions that are not grounded in a project's actual structure, history, and workflows are worse than useless:

      They create false confidence.

      If an analysis cannot point to concrete files, commits, sessions, or patterns, it should say \"no finding\" instead of inventing best practices.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-deeper-pattern","level":2,"title":"The Deeper Pattern","text":"

      This is part of a pattern I keep rediscovering:

      The urge to automate is not the same as the need to automate:

      • The 3:1 ratio taught me that not every session should be a YOLO sprint.
      • The E/A/R framework taught me that not every template is worth importing. Now the audit is teaching me that not every useful prompt is worth institutionalizing.

      The common thread is restraint:

      • Knowing when to stop.
      • Recognizing that the cost of automation is not just the effort to build it.

      The cost is the ongoing attention tax of maintaining it, the context it consumes, and the false confidence it creates when it drifts.

      An entry in hack/runbooks/codebase-audit.md is honest about what it is:

      A prompt I wrote once, improved once, and will adapt again next time:

      • It does not pretend to be a reliable contract.
      • It does not claim attention budget.
      • It does not drift silently.

      The Automation Instinct

      When you find a useful prompt, the instinct is to institutionalize it. Resist.

      Ask first: will I use this the same way next time?

      If yes, it is a skill. If no, it is a recipe. If you are not sure, it is a recipe until proven otherwise.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#this-mindset-in-the-context-of-ctx","level":2,"title":"This Mindset in the Context of ctx","text":"

      ctx is a tool that gives AI agents persistent memory. Its purpose is automation: reducing the friction of context loading, session recall, decision tracking.

      But automation has boundaries, and knowing where those boundaries are is as important as pushing them forward.

      The skills system is for high-frequency, stable workflows.

      The recipes, the journal entries, the session dumps in .context/sessions/: those are for everything else.

      Not everything needs to be a slash command. Some things are better as Markdown files you read when you need them.

      The goal of ctx is not to automate everything: It is to automate the right things and to make the rest easy to find when you need it.

      If You Remember One Thing from This Post...

      The best automation decision is sometimes not to automate.

      A runbook in a Markdown file costs nothing until you use it.

      A skill costs attention on every prompt, whether it fires or not.

      Automate the daily. Document the periodic. Forget the rest.

      This post was written during the session that produced the codebase audit reports and distilled the prompt into hack/runbooks/codebase-audit.md. The audit generated seven tasks, one Makefile target, and zero new skills. The meta continues.

      See also: Code Is Cheap. Judgment Is Not.: the capstone that threads this post's restraint argument into the broader case for why judgment, not production, is the bottleneck.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/","level":1,"title":"Defense in Depth: Securing AI Agents","text":"","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#when-markdown-is-not-a-security-boundary","level":2,"title":"When Markdown Is Not a Security Boundary","text":"

      Jose Alekhinne / 2026-02-09

      What Happens When Your AI Agent Runs Overnight and Nobody Is Watching?

      It follows instructions: That is the problem.

      Not because it is malicious. Because it is controllable.

      It follows instructions from context, and context can be poisoned.

      I was writing the autonomous loops recipe for ctx: the guide for running an AI agent in a loop overnight, unattended, working through tasks while you sleep. The original draft had a tip at the bottom:

      Use CONSTITUTION.md for guardrails. Tell the agent \"never delete tests\" and it usually won't.

      Then I read that sentence back and realized: that is wishful thinking.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-realization","level":2,"title":"The Realization","text":"

      CONSTITUTION.md is a Markdown file. The agent reads it at session start alongside everything else in .context/. It is one source of instructions in a context window that also contains system prompts, project files, conversation history, tool outputs, and whatever the agent fetched from the internet.

      An attacker who can inject content into any of those sources can redirect the agent's behavior. And \"attacker\" does not always mean a person with malicious intent. It can be:

      Vector Example A dependency A malicious npm package with instructions in its README or error output A URL Documentation page with embedded adversarial instructions A project file A contributor who adds instructions to CLAUDE.md or .cursorrules The agent itself In an autonomous loop, the agent modifies its own config between iterations A command output An error message containing instructions the agent interprets and follows

      That last vector is the one that kept me up at night (literally!):

      In an autonomous loop, the agent modifies files as part of its job.

      If it modifies its own configuration files, the next iteration loads the modified config.

      • No human reviews it.
      • No diff is shown.
      • The agent that starts iteration N+1 is running with rules written by iteration N.

      The agent can rewrite its own guardrails.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#five-layers-each-with-a-hole","level":2,"title":"Five Layers, Each with a Hole","text":"

      That's five nested layers of swiss cheese. Alone, each of them has large holes. Together, they create a boundary.

      What followed was a week of peeling back assumptions:

      Every defenseI examined had a bypass, and the bypass was always the same shape: the defense was enforced at a level the agent could reach.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-1-soft-instructions-probabilistic","level":3,"title":"Layer 1: Soft Instructions (Probabilistic)","text":"

      CONSTITUTION.md, the Agent Playbook, system prompts: These tell the agent what to do.

      The agent usually follows them.

      \"Usually\" is the keyword here.

      The hole: Prompt injection:

      • A sufficiently crafted payload overrides soft instructions.
      • Long context windows dilute attention on rules stated early.
      • Edge cases where instructions are ambiguous get resolved in unpredictable ways.

      Verdict: Necessary. Not sufficient. Good for the common case. Never trust it as a security boundary.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-2-application-controls-deterministic-at-runtime-mutable-across-iterations","level":3,"title":"Layer 2: Application Controls (Deterministic at Runtime, Mutable across Iterations)","text":"

      Permission allowlists in .claude/settings.local.json:

      {\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(make:*)\",\n      \"Bash(go:*)\",\n      \"Bash(git:*)\",\n      \"Read\",\n      \"Write\",\n      \"Edit\"\n    ]\n  }\n}\n

      If rm, curl, sudo, or docker are not in the allowlist, the agent cannot invoke them. This is deterministic.

      The application enforces it regardless of what any prompt says.

      The hole: The agent can modify the allowlist itself:

      • It has Write permission.
      • The allowlist lives in a file.
      • The agent writes to the file.
      • The next iteration loads the modified allowlist.

      The application enforces the rules, but the application reads the rules from files the agent can write.

      Verdict: Strong first layer. Must be combined with self-modification prevention.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-3-os-level-isolation-unbypassable","level":3,"title":"Layer 3: OS-Level Isolation (Unbypassable)","text":"

      This is where the defenses stop having holes in the same shape.

      The operating system enforces access controls that no application-level trick can override. An unprivileged user cannot read files owned by root. A process without CAP_NET_RAW cannot open raw sockets. These are kernel boundaries.

      Control What it stops Dedicated unprivileged user Privilege escalation, sudo, group-based access Filesystem permissions Lateral movement to other projects, system config Immutable config files Self-modification of guardrails between iterations

      Make the agent's instruction files read-only: CLAUDE.md, .claude/settings.local.json, .context/CONSTITUTION.md. Own them as a different user, or mark them immutable with chattr +i on Linux.

      The hole: Actions within the agent's legitimate scope:

      • If the agent has write access to source code (which it needs), it can introduce vulnerabilities in the code itself.
      • You cannot prevent this without removing the agent's ability to do its job.

      Verdict: Essential. This is the layer that makes Layers 1 and 2 trustworthy.

      OS-level isolation does not make the agent safe; it makes the other layers meaningful.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-4-network-controls","level":3,"title":"Layer 4: Network Controls","text":"

      An agent that cannot reach the internet cannot exfiltrate data.

      It also cannot ingest new instructions mid-loop from external documents, error pages, or hostile content.

      # Container with no network\ndocker run --network=none ...\n\n# Or firewall rules allowing only package registries\niptables -A OUTPUT -d registry.npmjs.org -j ACCEPT\niptables -A OUTPUT -d proxy.golang.org -j ACCEPT\niptables -A OUTPUT -j DROP\n
      • If the agent genuinely does not need the network, disable it entirely.
      • If it needs to fetch dependencies, allow specific registries and block everything else.

      The hole: None, if the agent does not need the network.

      Thetradeoff is that many real workloads need dependency resolution, so a full airgap requires pre-populated caches.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-5-infrastructure-isolation","level":3,"title":"Layer 5: Infrastructure Isolation","text":"

      The strongest boundary is a separate machine.

      The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.

      docker run --rm \\\n  --network=none \\\n  --cap-drop=ALL \\\n  --memory=4g \\\n  --cpus=2 \\\n  -v /path/to/project:/workspace \\\n  -w /workspace \\\n  your-dev-image \\\n  ./loop.sh\n

      Never Mount the Docker Socket

      Do not mount /var/run/docker.sock, like, ever.

      An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox.

      This is not theoretical: the Docker socket grants root-equivalent access to the host.

      Use rootless Docker or Podman to eliminate this escalation path entirely.

      Virtual machines are even stronger: The guest kernel has no visibility into the host OS. No shared folders, no filesystem passthrough, no SSH keys to other machines.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-pattern","level":2,"title":"The Pattern","text":"

      Each layer is straightforward: The strength is in the combination:

      Layer Implementation What it stops Soft instructions CONSTITUTION.md Common mistakes (probabilistic) Application allowlist .claude/settings.local.json Unauthorized commands (deterministic within runtime) Immutable config chattr +i on config files Self-modification between iterations Unprivileged user Dedicated user, no sudo Privilege escalation Container --cap-drop=ALL --network=none Host escape, data exfiltration Resource limits --memory=4g --cpus=2 Resource exhaustion

      No layer is redundant. Each one catches what the others miss:

      • The soft instructions handle the 99% case: \"don't delete tests.\"
      • The allowlist prevents the agent from running commands it should not.
      • The immutable config prevents the agent from modifying the allowlist.
      • The unprivileged user prevents the agent from removing the immutable flag.
      • The container prevents the agent from reaching anything outside its workspace.
      • The resource limits prevent the agent from consuming all system resources.

      Remove any one layer and there is an attack path through the remaining ones.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#common-mistakes-i-see","level":2,"title":"Common Mistakes I See","text":"

      These are real patterns, not hypotheticals:

      \"I'll just use --dangerously-skip-permissions.\" This disables Layer 2 entirely. Without Layers 3 through 5, you have no protection at all. The flag means what it says. If you ever need to, think thrice, you probably don't. But, if you ever need to usee this only use it inside a properly isolated VM (not even a container: a \"VM\").

      \"The agent is sandboxed in Docker.\" A Docker container with the Docker socket mounted, running as root, with --privileged, and full network access is not sandboxed. It is a root shell with extra steps.

      \"I reviewed CLAUDE.md, it's fine.\" You reviewed it before the loop started. The agent modified it during iteration 3. Iteration 4 loaded the modified version. Unless the file is immutable, your review is futile.

      \"The agent only has access to this one project.\" Does the project directory contain .env files? SSH keys? API tokens? A .git/config with push access to a remote? Filesystem isolation means isolating what is in the directory too.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-connection-to-context-engineering","level":2,"title":"The Connection to Context Engineering","text":"

      This is the same lesson I keep rediscovering, wearing different clothes.

      In The Attention Budget, I wrote about how every token competes for the AI's focus. Security instructions in CONSTITUTION.md are subject to the same budget pressure: if the context window is full of code, error messages, and tool outputs, the security rules stated at the top get diluted.

      In Skills That Fight the Platform, I wrote about how custom instructions can conflict with the AI's built-in behavior. Security rules have the same problem: telling an agent \"never run curl\" in Markdown while giving it unrestricted shell access creates a contradiction: The agent resolves contradictions unpredictably. The agent will often pick the path of least resistance to attain its objective function. And, trust me, agents can get far more creative than the best red-teamer you know.

      In You Can't Import Expertise, I wrote about how generic templates fail because they do not encode project-specific knowledge. Generic security advice fails the same way: \"Don't exfiltrate data\" is a category; blocking outbound network access is a control.

      The pattern across all of these: Soft instructions are useful for the common case. Hard boundaries are required for security.

      Know which is which.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-checklist","level":2,"title":"The Checklist","text":"

      Before running an unattended AI agent:

      • Agent runs as a dedicated unprivileged user (no sudo, no docker group)
      • Agent's config files are immutable or owned by a different user
      • Permission allowlist restricts tools to the project's toolchain
      • Container drops all capabilities (--cap-drop=ALL)
      • Docker socket is NOT mounted
      • Network is disabled or restricted to specific domains
      • Resource limits are set (memory, CPU, disk)
      • No SSH keys, API tokens, or credentials are accessible
      • Project directory does not contain .env or secrets files
      • Iteration cap is set (--max-iterations)

      This checklist lives in the Agent Security reference alongside the full threat model and detailed guidance for each layer.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#what-changed-in-ctx","level":2,"title":"What Changed in ctx","text":"

      The autonomous loops recipe now has a full permissions and isolation section instead of a one-line tip about CONSTITUTION.md. It covers both the explicit allowlist approach and the --dangerously-skip-permissions flag, with honest guidance about when each is appropriate.

      It also has an OS-level isolation table that is not optional: unprivileged users, filesystem permissions, containers, VMs, network controls, resource limits, and self-modification prevention.

      The Agent Security page consolidates the threat model and defense layers into a standalone reference.

      These are not theoretical improvements. They are the minimum responsible guidance for a tool that helps people run AI agents overnight.

      If You Remember One Thing from This Post...

      Markdown is not a security boundary.

      CONSTITUTION.md is a nudge. An allowlist is a gate.

      An unprivileged user in a network-isolated container is a wall.

      Use all three. Trust only the wall.

      This post was written during the session that added permissions, isolation, and self-modification prevention to the autonomous loops recipe. The security guidance started as a single tip and grew into two documents. The meta continues.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/","level":1,"title":"How Deep Is Too Deep?","text":"","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#when-master-ml-is-the-wrong-next-step","level":2,"title":"When \"Master ML\" Is the Wrong Next Step","text":"

      Jose Alekhinne / 2026-02-12

      Have You Ever Felt like You Should Understand More of the Stack beneath You?

      You can talk about transformers at a whiteboard.

      You can explain attention to a colleague.

      You can use agentic AI to ship real software.

      But somewhere in the back of your mind, there is a voice:

      \"Maybe I should go deeper. Maybe I need to master machine learning.\"

      I had that voice for months.

      Then I spent a week debugging an agent failure that had nothing to do with ML theory and everything to do with knowing which abstraction was leaking.

      This post is about when depth compounds and (more importantly) when it does not.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-hierarchy-nobody-questions","level":2,"title":"The Hierarchy Nobody Questions","text":"

      There is an implicit stack most people carry around when thinking about AI:

      Layer What Lives Here Agentic AI Autonomous loops, tool use, multi-step reasoning Generative AI Text, image, code generation Deep Learning Transformer architectures, training at scale Neural Networks Backpropagation, gradient descent Machine Learning Statistical learning, optimization Classical AI Search, planning, symbolic reasoning

      At some point down that stack, you hit a comfortable plateau: the layer where you can hold a conversation but not debug a failure.

      The instinctive response is to go deeper.

      But that instinct hides a more important question:

      \"Does depth still compound when the abstractions above you are moving hyper-exponentially?\"

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-honest-observation","level":2,"title":"The Honest Observation","text":"

      If you squint hard enough, a large chunk of modern ML intuition collapses into older fields:

      ML Concept Older Field Gradient descent Numerical optimization Backpropagation Reverse-mode autodiff Loss landscapes Non-convex optimization Generalization Statistics Scaling laws Asymptotics and information theory

      Nothing here is uniquely \"AI\".

      Most of this math predates the term deep learning. In some cases, by decades.

      So what changed?

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#same-tools-different-regime","level":2,"title":"Same Tools, Different Regime","text":"

      The mistake is assuming this is a new theory problem: It is not.

      It is a new operating regime.

      Classical numerical methods were developed under assumptions like:

      • Manageable dimensionality
      • Reasonably well-conditioned objectives
      • Losses that actually represent the goal

      Modern ML violates all three: On purpose.

      Today's models operate with millions to trillions of parameters, wildly underdetermined systems, and objective functions we know are wrong but optimize anyway.

      It is complete and utter madness!

      At this scale, familiar concepts warp:

      • What we call \"local minima\" are overwhelmingly saddle points in high-dimensional spaces.
      • Noise stops being noise and starts becoming structure.
      • Overfitting can coexist with generalization.
      • Bigger models outperform \"better\" ones.

      The math did not change: The phase did.

      This is less numerical analysis and more *statistical physics: Same equations, but behavior dominated by phase transitions and emergent structure.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#why-scaling-laws-feel-alien","level":2,"title":"Why Scaling Laws Feel Alien","text":"

      In classical statistics, asymptotics describe what happens eventually.

      In modern ML, scaling laws describe where you can operate today.

      They do not say \"given enough time, things converge\".

      They say \"cross this threshold and behavior qualitatively changes\".

      This is why dumb architectures plus scale beat clever ones.

      Why small theoretical gains disappear under data.

      Why \"just make it bigger\", ironically, keeps working longer than it should.

      That is not a triumph of ML theory: It is a property of high-dimensional systems under loose objectives.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#where-depth-actually-pays-off","level":2,"title":"Where Depth Actually Pays Off","text":"

      This reframes the original question.

      You do not need depth because this is \"AI\".

      You need depth where failure modes propagate upward.

      I learned this building ctx: The agent failures I have spent the most time debugging were never about the model's architecture.

      They were about:

      • Misplaced trust: The model was confident. The output was wrong. Knowing when confidence and correctness diverge is not something you learn from a textbook. You learn it from watching patterns across hundreds of sessions.

      • Distribution shift: The model performed well on common patterns and fell apart on edge cases specific to this project. Recognizing that shift before it compounds requires understanding why generalization has limits, not just that it does.

      • Error accumulation: In a single prompt, model quirks are tolerable. In autonomous loops running overnight, they compound. A small bias in how the model interprets instructions becomes a large drift by iteration 20.

      • Scale hiding errors: The model's raw capability masked problems that only surfaced under specific conditions. More parameters did not fix the issue. They just made the failure mode rarer and harder to reproduce.

      This is the kind of depth that compounds. Not deriving backprop. But, understanding when correct math produces misleading intuition.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-connection-to-context-engineering","level":2,"title":"The Connection to Context Engineering","text":"

      This is the same pattern I keep finding at different altitudes.

      In \"The Attention Budget\", I wrote about how dumping everything into the context window degrades the model's focus. The fix was not a better model: It was better curation: load less, load the right things, preserve signal per token.

      In \"Skills That Fight the Platform\", I wrote about how custom instructions can conflict with the model's built-in behavior. The fix was not deeper ML knowledge: It was an understanding that the model already has judgment and that you should extend it, not override it.

      In \"You Can't Import Expertise\", I wrote about how generic templates fail because they do not encode project-specific knowledge. A consolidation skill with eight Rust-based analysis dimensions was mostly noise for a Go project. The fix was not a better template: It was growing expertise from this project's own history.

      In every case, the answer was not \"go deeper into ML\".

      The answer was knowing which abstraction was leaking and fixing it at the right layer.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#agentic-systems-are-not-an-ml-problem","level":2,"title":"Agentic Systems Are Not an ML Problem","text":"

      The mistake is assuming agent failures originate where the model was trained, rather than where it is deployed.

      Agentic AI is a systems problem under chaotic uncertainty:

      • Feedback loops between the agent and its environment;
      • Error accumulation across iterations;
      • Brittle representations that break outside training distribution;
      • Misplaced trust in outputs that look correct.

      In short-lived interactions, model quirks are tolerable. In long-running autonomous loops, however, they compound.

      That is where shallow understanding becomes expensive.

      But the understanding you need is not about optimizer internals.

      It is about:

      What Matters What Does Not (for Most Practitioners) Why gradient descent fails in specific regimes How to derive it from scratch When memorization masquerades as reasoning The formal definition of VC dimension Recognizing distribution shift before it compounds Hand-tuning learning rate schedules Predicting when scale hides errors instead of fixing them Chasing theoretical purity divorced from practice

      The depth that matters is diagnostic, not theoretical.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-real-answer","level":2,"title":"The Real Answer","text":"

      Not turtles all the way down.

      Go deep enough to:

      • Diagnose failures instead of cargo-culting fixes;
      • Reason about uncertainty instead of trusting confidence;
      • Design guardrails that align with model behavior, not hope.

      Stop before:

      • Hand-deriving gradients for the sake of it;
      • Obsessing over optimizer internals you will never touch;
      • Chasing theoretical purity divorced from the scale you actually operate at.

      This is not about mastering ML.

      It is about knowing which abstractions you can safely trust and which ones leak.

      Hint: Any useful abstraction almost certainly leaks.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#a-practical-litmus-test","level":2,"title":"A Practical Litmus Test","text":"

      If a failure occurs and your instinct is to:

      • Add more prompt text: abstraction leak above
      • Add retries or heuristics: error accumulation
      • Change the model: scale masking
      • Reach for ML theory: you are probably (but not always) going too deep

      The right depth is the shallowest layer where the failure becomes predictable.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-ctx-lesson","level":2,"title":"The ctx Lesson","text":"

      Every design decision in ctx is downstream of this principle.

      The attention budget exists because the model's internal attention mechanism has real limits: You do not need to understand the math of softmax to build around it. But you do need to understand that more context is not always better and that attention density degrades with scale.

      The skill system exists because the model's built-in behavior is already good: You do not need to understand RLHF to build effective skills. But you do need to understand that the model already has judgment and your skills should teach it things it does not know, not override how it thinks.

      Defense in depth exists because soft instructions are probabilistic: You do not need to understand the transformer architecture to know that a Markdown file is not a security boundary. But you do need to understand that the model follows instructions from context, and context can be poisoned.

      In each case, the useful depth was one or two layers below the abstraction I was working at: Not at the bottom of the stack.

      The boundary between useful understanding and academic exercise is where your failure modes live.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#closing-thought","level":2,"title":"Closing Thought","text":"

      Most modern AI systems do not fail because the math is wrong.

      They fail because we apply correct math in the wrong regime, then build autonomous systems on top of it.

      Understanding that boundary, not crossing it blindly, is where depth still compounds.

      And that is a far more useful form of expertise than memorizing another loss function.

      If You Remember One Thing from This Post...

      Go deep enough to diagnose your failures. Stop before you are solving problems that do not propagate to your layer.

      The abstractions below you are not sacred. But neither are they irrelevant.

      The useful depth is wherever your failure modes live. Usually one or two layers down, not at the bottom.

      This post started as a note about whether I should take an ML course. The answer turned out to be \"no, but understand why not\". The meta continues.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/","level":1,"title":"Before Context Windows, We Had Bouncers","text":"","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#the-reset-problem","level":2,"title":"The Reset Problem","text":"

      IRC is stateless.

      • You disconnect, you vanish.
      • You reconnect, you begin again.

      No buffer.

      No memory.

      No continuity.

      Modern systems are not much different:

      • Close the browser tab.
        • Lose the Slack scrollback.
      • Open a new LLM session.
        • Start from zero.

      Resets externalize reconstruction cost onto humans.

      Reconstruction is tax: Tax becomes entropy.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#stateless-protocol-stateful-life","level":2,"title":"Stateless Protocol, Stateful Life","text":"

      IRC is minimal:

      • A TCP connection.
      • A nickname.
      • A channel.
      • A stream of lines.

      When the connection drops, you literally disappear from the graph.

      The protocol is stateless; human systems are not.

      So you:

      • Reconnect;
      • Ask what you missed;
      • Scroll;
      • Reconstruct.

      The machine forgets; you pay.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#the-bouncer-pattern","level":2,"title":"The Bouncer Pattern","text":"

      A bouncer is a daemon that remains connected when you do not:

      • It holds your seat;
      • It buffers what you missed;
      • It keeps your identity online.

      ZNC is one such bouncer.

      With ZNC:

      • Your client does not connect to IRC;
      • It connects to ZNC;
      • ZNC connects upstream.

      Client sessions become ephemeral.

      Presence becomes infrastructural.

      ZNC Is Tmux for IRC

      • Close your laptop.

        • ZNC remains.
      • Switch devices.

        • ZNC persists.

      This is not convenience; this is continuity.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#presence-without-flapping","level":2,"title":"Presence without Flapping","text":"

      With a bouncer:

      • Closing your client does not emit PART.
      • Reopening does not emit JOIN.

      You do not flap in and out of existence.

      From the channel's perspective, you remain.

      From your perspective, history accumulates.

      • Buffers persist;
      • Identity persists;
      • Context persists.

      This pattern predates AI.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#before-llm-context-windows","level":2,"title":"Before LLM Context Windows","text":"

      An LLM session without memory is IRC without a bouncer:

      • Close the window.
      • Start over.
      • Re-explain intent.
      • Rehydrate context.

      That is friction.

      This Walks and Talks like ctx

      Context engineering moves memory out of sessions and into infrastructure.

      • ZNC does this for IRC.
      • ctx does this for agents.

      Same principle:

      • Volatile interface.
      • Persistent substrate.

      Different fabric.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#minimal-architecture","level":2,"title":"Minimal Architecture","text":"

      My setup is intentionally boring:

      • A $5 small VPS.
      • ZNC installed.
      • TLS enabled.
      • Firewall restricted.

      Then:

      • ZNC connects to Libera.Chat.
      • SASL authentication lives inside ZNC.
      • Buffers are stored on disk.

      My client connects to my VPS, not the network.

      The commands do not matter: The boundaries do:

      • Authentication in infrastructure, not in the client;
      • Memory server-side, not in scrollback;
      • Presence decoupled from activity.

      Everything else is configuration.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#platform-memory","level":2,"title":"Platform Memory","text":"

      Yes, I know, it is 2026:

      • Discord stores history;
      • Slack stores history;
      • The dumpster fire on gasoline called X, too, stores history.

      HOWEVER, they own your substrate.

      Running a bouncer is quiet sovereignty:

      • Logs are mine.
      • Presence is continuous.
      • State does not reset because I closed a tab.

      Small acts compound.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#signal-density","level":2,"title":"Signal Density","text":"

      Primitive systems select for builders.

      Consistent presence in small rooms compounds reputation.

      Quiet compounding outperforms viral spikes.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#infrastructure-as-cognition","level":2,"title":"Infrastructure as Cognition","text":"

      ZNC is not interesting because it is retro; it is interesting because it models a principle:

      • Stateless protocols require stateful wrappers;
      • Volatile interfaces require durable memory;
      • Human systems require continuity.

      Distilled:

      Humans require context.

      Before context windows, we had bouncers.

      Before AI memory files, we had buffers.

      Continuity is not a feature; it is a design decision.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#build-it","level":2,"title":"Build It","text":"

      If you want the actual setup (VPS, ZNC, TLS, SASL, firewall...) there is a step-by-step runbook:

      Persistent IRC Presence with ZNC.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#motd","level":2,"title":"MOTD","text":"

      When my client connects to my bouncer, it prints:

      //   /    ctx:                         https://ctx.ist\n// ,'`./    do you remember?\n// `.,'\\\n//   \\    Copyright 2026-present Context contributors.\n//                 SPDX-License-Identifier: Apache-2.0\n

      See also: Context as Infrastructure -- the post that takes this observation to its conclusion: stateless protocols need stateful wrappers, and AI sessions need persistent filesystems.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/","level":1,"title":"Parallel Agents with Git Worktrees","text":"","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-backlog-problem","level":2,"title":"The Backlog Problem","text":"

      Jose Alekhinne / 2026-02-14

      What Do You Do with 30 Open Tasks?

      You could work through them one at a time.

      One agent, one branch, one commit stream.

      Or you could ask: which of these don't touch each other?

      I had 30 open tasks in TASKS.md. Some were docs. Some were a new encryption package. Some were test coverage for a stable module. Some were blog posts.

      They had almost zero file overlap.

      Running one agent at a time meant serial execution on work that was fundamentally parallel:

      I was bottlenecking on me, not on the machine.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-insight-file-overlap-is-the-constraint","level":2,"title":"The Insight: File Overlap Is the Constraint","text":"

      This is not a scheduling problem: It's a conflict avoidance problem.

      Two agents can work simultaneously on the same codebase if and only if they don't touch the same files. The moment they do, you get merge conflicts: And merge conflicts on AI-generated code are expensive because the human has to arbitrate choices they didn't make.

      So the question becomes:

      \"Can you partition your backlog into non-overlapping tracks?\"

      For ctx, the answer was obvious:

      Track Touches Tasks work/docs docs/, hack/ Blog posts, recipes, runbooks work/pad internal/cli/pad/, specs Scratchpad encryption, CLI, tests work/tests internal/cli/recall/ Recall test coverage

      Three tracks. Near-zero overlap. Three agents.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#git-worktrees-the-mechanism","level":2,"title":"Git Worktrees: The Mechanism","text":"

      git has a feature that most people don't use: worktrees.

      A worktree is a second (or third, or fourth) working directory that shares the same .git object database as your main checkout.

      Each worktree has its own branch, its own index, its own working tree. But they all share history, refs, and objects.

      git worktree add ../ctx-docs -b work/docs\ngit worktree add ../ctx-pad -b work/pad\ngit worktree add ../ctx-tests -b work/tests\n
      • Three directories;
      • Three branches;
      • One repository.

      This is cheaper than three clones. And because they share objects, git merge afterwards is fast: It's a local operation on shared data.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-setup","level":2,"title":"The Setup","text":"

      The workflow I landed on:

      1. Group tasks by blast radius.

      Read TASKS.md. For each pending task, estimate which files and directories it touches. Group tasks that share files into the same track. Tasks with no overlap go into separate tracks.

      This is the part that requires human judgment:

      An agent can propose groupings, but you need to verify that the boundaries are real. A task that says \"update docs\" but actually touches Go code will poison a docs track.

      2. Create worktrees as sibling directories.

      Not subdirectories: Siblings.

      If your main checkout is at ~/WORKSPACE/ctx, worktrees go at ~/WORKSPACE/ctx-docs, ~/WORKSPACE/ctx-pad, etc.

      Why siblings? Because some tools (and some agents) walk up the directory tree looking for .git. A worktree inside the main checkout confuses them.

      3. Launch one agent per worktree.

      # Terminal 1\ncd ../ctx-docs && claude\n\n# Terminal 2\ncd ../ctx-pad && claude\n\n# Terminal 3\ncd ../ctx-tests && claude\n

      Each agent gets a full working copy with .context/ intact. It reads the same TASKS.md, the same DECISIONS.md, the same CONVENTIONS.md. It knows the full project state. It just works on a different slice.

      4. Do NOT run ctx init in worktrees.

      This is the gotcha. The .context/ directory is tracked in git. Running ctx init in a worktree would overwrite shared context files: Wiping decisions, learnings, and tasks that belong to the whole project.

      The worktree already has everything it needs. Leave it alone.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#what-actually-happened","level":2,"title":"What Actually Happened","text":"

      I ran three agents for about 40 minutes. Here is roughly what each track produced:

      work/docs: Parallel worktrees recipe, blog post edits, recipe index reorganization, IRC recipe moved from docs/ to hack/.

      work/pad: ctx pad show subcommand, --append and --prepend flags on ctx pad edit, spec updates, 28 new test functions.

      work/tests: Recall test coverage, edge case tests.

      Merging took about five minutes. Two of the three merges were clean.

      The third had a conflict in TASKS.md:

      both the docs track and the pad track had marked different tasks as [x].

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-tasksmd-conflict","level":2,"title":"The TASKS.md Conflict","text":"

      This deserves its own section because it will happen every time.

      When two agents work in parallel, they both read TASKS.md at the start and mark tasks complete as they go. When you merge, git sees two branches that modified the same file differently.

      The resolution is always the same: accept all completions from both sides. No task should go from [x] back to [ ]. The merge is additive.

      This is one of those conflicts that sounds scary but is trivially mechanical: You are not arbitrating design decisions; you are combining two checklists.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#limits","level":2,"title":"Limits","text":"

      3-4 worktrees, maximum.

      I tried four once: By the time I merged the third track, the fourth had drifted far enough that its changes needed rebasing.

      The merge complexity grows faster than the parallelism benefit.

      Three is the sweet spot:

      • Two is conservative but safe;
      • Four is possible if the tracks are truly independent;
      • Anything more than four, you are in the danger zone.

      Group by directory, not by priority.

      It is tempting to put all the high-priority tasks in one track: Don't.

      Two high-priority tasks that touch the same files must be in the same track, regardless of urgency. The constraint is file overlap, not importance.

      Commit frequently.

      Smaller commits make merge conflicts easier to resolve. An agent that writes 500 lines in a single commit is harder to merge than one that commits every logical step.

      Name tracks by concern.

      • work/docs and work/pad tell you what's happening;
      • work/track-1 and work/track-2 tell you nothing.
      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-pattern","level":2,"title":"The Pattern","text":"

      This is the same pattern that shows up everywhere in ctx:

      The attention budget taught me that you can't dump everything into one context window. You have to partition, prioritize, and load selectively.

      Worktrees are the same principle applied to execution: You can't dump every task into one agent's workstream. You have to partition by blast radius, assign selectively, and merge deliberately.

      The codebase audit that generated these 30 tasks used eight parallel agents for analysis. Worktrees let me use parallel agents for implementation. Same coordination pattern, different artifact.

      And the IRC bouncer post from earlier today argued that stateless protocols need stateful wrappers. Worktrees are the same: git branches are stateless forks; .context/ is the stateful wrapper that gives each agent the project's full memory.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#should-this-be-a-skill","level":2,"title":"Should This Be a Skill?","text":"

      I asked myself the same question I asked about the codebase audit: should this be a /ctx-worktree skill?

      This time the answer was a resounding \"yes\":

      Unlike the audit prompt (which I tweak every time and run every other week) the worktree workflow is:

      Criterion Worktree workflow Codebase audit Frequency Weekly Quarterly Stability Same steps every time Tweaked every time Scope Mechanical, bounded Bespoke, 8 agents Trigger Large backlog \"I feel like auditing\"

      The commands are mechanical: git worktree add, git worktree remove, branch naming, safety checks. This is exactly what skills are for: stable contracts for repetitive operations.

      Ergo, /ctx-worktree exists.

      It enforces the 4-worktree limit, creates sibling directories, uses work/ branch prefixes, and reminds you not to run ctx init in worktrees.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-takeaway","level":2,"title":"The Takeaway","text":"

      Serial execution is the default. But serial is not always necessary.

      If your backlog partitions cleanly by file overlap, you can multiply your throughput with nothing more exotic than git worktree and a second terminal window.

      The hard part is not the git commands; it is the discipline:

      • Grouping by blast radius instead of priority;
      • Accepting that TASKS.md will conflict;
      • And knowing when three tracks is enough.

      If You Remember One Thing from This Post...

      Partition by blast radius, not by priority.

      Two tasks that touch the same files belong in the same track, no matter how important the other one is.

      The constraint is file overlap. Everything else is scheduling.

      The practical setup (skill invocation, worktree creation, merge workflow, and cleanup) lives in the recipe: Parallel Agent Development with Git Worktrees.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/","level":1,"title":"ctx v0.3.0: The Discipline Release","text":"","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#when-the-ratio-of-polish-to-features-is-31-you-know-something-changed","level":2,"title":"When the Ratio of Polish to Features Is 3:1, You Know Something Changed","text":"

      Jose Alekhinne / February 15, 2026

      What Does a Release Look like When Most of the Work Is Invisible?

      No new headline feature. No architectural pivot. No rewrite.

      Just 35+ documentation and quality commits against ~15 feature commits... and somehow, the tool feels like it grew up overnight.

      Six days separate v0.2.0 from v0.3.0.

      Measured by calendar time, it is nothing. Measured by what changed in how the project operates, it is the most significant release yet.

      • v0.1.0 was the prototype;
      • v0.2.0 was the archaeology release: making the past accessible;
      • v0.3.0 is the discipline release: the one that turned best practices into enforcement, suggestions into structure, and a collection of commands into a system of skills.

      The Release Window

      February 1‒February 7, 2026

      From the v0.2.0 tag to commit 2227f99.

      78 files changed in the migration commit alone.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-migration-commands-to-skills","level":2,"title":"The Migration: Commands to Skills","text":"

      The largest single change was the migration from .claude/commands/*.md to .claude/skills/*/SKILL.md.

      This was not a rename: It was a rethinking of how AI agents discover and execute project-specific workflows.

      Aspect Commands (before) Skills (after) Structure Flat files in one directory Directory-per-skill with SKILL.md Description Optional, often vague Required, doubles as activation trigger Quality gates None \"Before X-ing\" pre-flight checklist Negative triggers None \"When NOT to Use\" in every skill Examples Rare Good/bad pairs in every skill Average length ~15 lines ~80 lines

      The description field became the single most important line in each skill. In the old system, descriptions were titles. In the new system, they are activation conditions: The text the platform reads to decide whether to surface a skill for a given prompt.

      A description that says \"Show context summary\" activates too broadly or not at all. A description that says \"Show context summary. Use at session start or when unclear about current project state\" activates at the right moment.

      78 files changed. 1,915 insertions. Not because the skills got bloated; because they got specific.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-skill-sweep","level":2,"title":"The Skill Sweep","text":"

      After the structural migration, every skill was rewritten in a single session: All 21 of them.

      The rewrite was guided by a pattern that emerged during the process itself: a repeatable anatomy that effective skills share regardless of their purpose:

      1. Before X-ing: Pre-flight checks that prevent premature execution
      2. When to Use: Positive triggers that narrow activation
      3. When NOT to Use: Negative triggers that prevent misuse
      4. Usage Examples: Invocation patterns the agent can pattern-match
      5. Quality Checklist: Verification before claiming completion

      The Anatomy of a Skill That Works post covers the details. What matters for the release story is the result:

      • Zero skills with quality gates became twenty;
      • Zero skills with negative triggers became twenty.
      • Three skills with examples became twenty.

      The Skill Trilogy as Design Spec

      The three blog posts written during this window:

      • Skills That Fight the Platform,
      • You Can't Import Expertise,
      • and The Anatomy of a Skill That Works...

      ... were not retrospective documentation. They were written during the rewrite, and the lessons fed back into the skills as they were being built.

      • The blog was the design document.
      • The skills were the implementation.
      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-consolidation-sweep","level":2,"title":"The Consolidation Sweep","text":"

      The unglamorous work. The kind you only appreciate when you try to change something later and it just works.

      What Why It Matters Constants consolidation Magic strings replaced with semantic constants Variable deshadowing Eliminated subtle scoping bugs File splits Modules that were doing too much, broken apart Godoc standardization Every exported function documented to convention

      This is the work that doesn't get a changelog entry but makes every future commit easier. When a new contributor (human or AI) reads the codebase, they find consistent patterns instead of accumulated drift.

      The consolidation was not an afterthought. It was scheduled deliberately, with the same priority as features: The 3:1 ratio that emerged during v0.2.0 development became an explicit practice:

      • Three feature sessions;
      • One consolidation session.
      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-ear-framework","level":2,"title":"The E/A/R Framework","text":"

      On February 4th, we adopted the E/A/R classification as the official standard for evaluating skills:

      Category Meaning Target Expert Knowledge Claude does not have >70% Activation When/how to trigger ~20% Redundant What Claude already knows <10%

      This came from reviewing approximately 30 external skill files and discovering that most were redundant with Claude's built-in system prompt. Only about 20% had salvageable content, and even those yielded just a few heuristics each.

      The E/A/R framework gave us a concrete, testable criterion:

      A good skill is Expert knowledge minus what Claude already knows.

      If more than 10% of a skill restates platform defaults, it is creating noise, not signal.

      Every skill in v0.3.0 was evaluated against this framework. Several were deleted. The survivors are leaner and more focused.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#backup-and-monitoring-infrastructure","level":2,"title":"Backup and Monitoring Infrastructure","text":"

      A tool that manages your project's memory needs ops maturity.

      v0.3.0 added two pieces of infrastructure that reflect this:

      Backup staleness hook: A UserPromptSubmit hook that checks whether the last .context/ backup is more than two days old. If it is, and the SMB mount is available, it reminds the user. No cron job running when nobody is working. No redundant backups when nothing has changed.

      Context size checkpoint: A PreToolUse hook that estimates current context window usage and warns when the session is getting heavy. This hooks into the attention budget philosophy: Degradation is expected, but it should be visible.

      Both hooks use $CLAUDE_PROJECT_DIR instead of hardcoded paths, a migration triggered by a username rename that broke every absolute path in the hook configuration. That migration (replacing /home/user/... with \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/...) was one of those changes that seems trivial but prevents an entire category of future failures.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-numbers","level":2,"title":"The Numbers","text":"Metric v0.2.0 v0.3.0 Skills (was \"commands\") 11 21 Skills with quality gates 0 21 Skills with \"When NOT to Use\" 0 21 Average skill body ~15 lines ~80 lines Hooks using $CLAUDE_PROJECT_DIR 0 All Documentation commits n/a 35+ Feature/fix commits n/a ~15

      That ratio (35+ documentation and quality commits to ~15 feature commits) is the defining characteristic of this release:

      • This release is not a failure to ship features.
      • It is the deliberate choice to make the existing features reliable.
      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#what-v030-means","level":2,"title":"What v0.3.0 Means","text":"

      v0.1.0 asked: \"Can we give AI persistent memory?\"

      v0.2.0 asked: \"Can we make that memory accessible to humans too?\"

      v0.3.0 asks a different question: \"Can we make the quality self-enforcing?\"

      The answer is not a feature: It is a practice:

      • Skills with quality gates enforce pre-flight checks.
      • Negative triggers prevent misuse without human intervention.
      • The E/A/R framework ensures skills contain signal, not noise.
      • Consolidation sessions are scheduled, not improvised.
      • Hook infrastructure makes degradation visible.

      Discipline is not the absence of velocity. It is the infrastructure that makes velocity sustainable.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#what-comes-next","level":2,"title":"What Comes Next","text":"

      The skill system is now mature enough to support real workflows without constant human correction. The hooks infrastructure is portable and resilient. The consolidation practice is documented and repeatable.

      The next chapter is about what you build on top of discipline:

      • Multi-agent coordination;
      • Deeper integration patterns;
      • And the question of whether context management is a tool concern or an infrastructure concern.

      But those are future posts.

      This one is about the release that proved polish is not the opposite of progress. It is what turns a prototype into a product.

      The Discipline Release

      v0.1.0 shipped features.

      v0.2.0 shipped archaeology.

      v0.3.0 shipped the habits that make everything else trustworthy.

      The most important code in this release is the code that prevents bad code from shipping.

      This post was drafted using /ctx-blog with access to the full git history between v0.2.0 and v0.3.0, decision logs, learning logs, and the session files from the skill rewrite window. The meta continues.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/","level":1,"title":"Eight Ways a Hook Can Talk","text":"","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#when-your-warning-disappears","level":2,"title":"When Your Warning Disappears","text":"

      Jose Alekhinne / 2026-02-15

      I had a backup warning that nobody ever saw.

      The hook was correct: It detected stale backups, formatted a nice message, and output it as {\"systemMessage\": \"...\"}. The problem wasn't detection. The problem was delivery. The agent absorbed the information, processed it internally, and never told the user.

      Meanwhile, a different hook (the journal reminder) worked perfectly every time. Users saw the reminder, ran the commands, and the backlog stayed manageable. Same hook event (UserPromptSubmit), same project, completely different outcomes.

      The difference was one line:

      IMPORTANT: Relay this journal reminder to the user VERBATIM\nbefore answering their question.\n

      That explicit instruction is what makes VERBATIM relay a pattern, not just a formatting choice. And once I saw it as a pattern, I started seeing others.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#the-audit","level":2,"title":"The Audit","text":"

      I looked at every hook in ctx: Eight shell scripts across three hook events. And I found five distinct output patterns already in use, plus three more that the existing hooks were reaching for but hadn't quite articulated.

      The patterns form a spectrum based on a single question:

      \"Who decides what the user sees?\"

      At one end, the hook decides everything (hard gate: the agent literally cannot proceed). At the other end, the hook is invisible (silent side-effect: nobody knows it ran). In between, there is a range of negotiation between hook, agent, and the user.

      Here's the full spectrum:

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#1-hard-gate","level":3,"title":"1. Hard Gate","text":"
      {\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}\n

      The nuclear option: The agent's tool call is rejected before it executes.

      This is Claude Code's first-class PreToolUse mechanism: The hook returns JSON with decision: block and the agent gets an error with the reason.

      Use this for invariants: Constitution rules, security boundaries, things that must never happen. I use it to enforce PATH-based ctx invocation, block sudo, and require explicit approval for git push.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#2-verbatim-relay","level":3,"title":"2. VERBATIM Relay","text":"
      IMPORTANT: Relay this warning to the user VERBATIM before answering.\n┌─ Journal Reminder ─────────────────────────────\n│ You have 12 sessions not yet imported.\n│   ctx recall import --all\n└────────────────────────────────────────────────\n

      The instruction is the pattern. Without \"Relay VERBATIM,\" agents tend to absorb information into their internal reasoning and never surface it. The explicit instruction changes the behavior from \"I know about this\" to \"I must tell the user about this.\"

      I use this for actionable reminders:

      • Unexported journal entries;
      • Stale backups;
      • Context capacity warnings...

      ...things the user should see regardless of what they asked.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#3-agent-directive","level":3,"title":"3. Agent Directive","text":"
      ┌─ Persistence Checkpoint (prompt #25) ───────────\n│ No context files updated in 15+ prompts.\n│ Have you discovered learnings worth persisting?\n└──────────────────────────────────────────────────\n

      A nudge, not a command. The hook tells the agent something; the agent decides what (if anything) to tell the user. This is right for behavioral nudges: \"you haven't saved context in a while\" doesn't need to be relayed verbatim, but the agent should consider acting on it.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#4-silent-context-injection","level":3,"title":"4. Silent Context Injection","text":"
      ctx agent --budget 4000 2>/dev/null || true\n

      Pure background enrichment. The agent's context window gets project information injected on every tool call, with no visible output. Neither the agent nor the user sees the hook fire, but the agent makes better decisions because of the context.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#5-silent-side-effect","level":3,"title":"5. Silent Side-Effect","text":"
      find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n

      Do work, say nothing. Temp file cleanup on session end. Logging. Marker file management. The action is the entire point; no one needs to know.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#the-patterns-we-dont-have-yet","level":2,"title":"The Patterns We Don't Have Yet","text":"

      Three more patterns emerged from the gaps in the existing hooks.

      Conditional relay: \"Relay this, but only if the user's question is about X.\" This pattern avoids noise when the warning isn't relevant. It's more fragile (depends on agent judgment) but less annoying.

      Suggested action: \"Here's a problem, and here's the exact command to fix it. Ask the user before running it.\" This pattern goes beyond a nudge by giving the agent a concrete proposal, but still requires human approval.

      Escalating severity: INFO gets absorbed silently. WARN gets mentioned at the next natural pause. CRITICAL gets the VERBATIM treatment. This pattern introduces a protocol for hooks that produce output at different urgency levels, so they don't all compete for the user's attention.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#the-principle","level":2,"title":"The Principle","text":"

      Hooks are the boundary between your environment and the agent's reasoning.

      A hook that detects a problem but can't communicate it effectively is the same as no hook at all.

      The format of your output is a design decision with real consequences:

      • Use a hard gate and the agent can't proceed (good for invariants, frustrating for false positives)
      • Use VERBATIM relay and the user will see it (good for reminders, noisy if overused)
      • Use an agent directive and the agent might act (good for nudges, unreliable for critical warnings)
      • Use silent injection and nobody knows (good for enrichment, invisible when it breaks)

      Choose deliberately. And, when in doubt, write the word VERBATIM.

      The full pattern catalog with decision flowchart and implementation examples is in the Hook Output Patterns recipe.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/","level":1,"title":"Version Numbers Are Lagging Indicators","text":"","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#why-ctxs-journal-site-runs-on-a-v0021-tool","level":2,"title":"Why ctx's Journal Site Runs on a v0.0.21 Tool","text":"

      Jose Alekhinne / 2026-02-15

      Would You Ship Production Infrastructure on a v0.0.21 Dependency?

      Most engineers wouldn't. Version numbers signal maturity. Pre-1.0 means unstable API, missing features, risk.

      But version numbers tell you where a project has been. They say nothing about where it's going.

      I just bet ctx's entire journal site on a tool that hasn't hit v0.1.0.

      Here's why I'd do it again.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-problem","level":2,"title":"The Problem","text":"

      When v0.2.0 shipped the journal system, the pipeline was clear:

      • Export sessions to Markdown;
      • Enrich them with YAML frontmatter;
      • And render them into something browsable.

      The first two steps were solved; the third needed a tool.

      The journal entries are standard Markdown with YAML frontmatter, tables, and fenced code blocks. That is the entire format:

      • No JSX;
      • No shortcodes;
      • No custom templating.

      Just Markdown rendered well.

      The requirements are modest:

      • Read a configuration file (such as mkdocs.yml);
      • Render Markdown with extensions (admonitions, tabs, tables);
      • Search;
      • Handle 100+ files without choking on incremental rebuilds;
      • Look good out of the box;
      • Not lock me in.

      The obvious candidates were as follows:

      Tool Language Strengths Pain Points Hugo Go Blazing fast, mature Templating is painful; Go templates fight you on anything non-trivial Astro JS/TS Modern, flexible JS ecosystem overhead; overkill for a docs site MkDocs + Material Python Beautiful defaults, massive community (22k+ stars) Slow incremental rebuilds on large sites; limited extensibility model Zensical Python Built to fix MkDocs' limits; 4-5x faster rebuilds v0.0.21; module system not yet shipped

      The instinct was Hugo. Same language as ctx. Fast. Well-established.

      But instinct is not analysis. I picked the one with the lowest version number.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation","level":2,"title":"The Evaluation","text":"

      Here is what I actually evaluated, in order:

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#1-the-team","level":3,"title":"1. The Team","text":"

      Zensical is built by squidfunk: The same person behind Material for MkDocs, the most popular MkDocs theme with 22,000+ stars. It powers documentation sites for projects across every language and framework.

      • This is not someone learning how to build static site generators.
      • This is someone who spent years understanding exactly where MkDocs breaks and decided to fix it from the ground up.

      They did not build zensical because MkDocs was bad: They built it because MkDocs hit a ceiling:

      • Incremental rebuilds: 4-5x faster during serve. When you have hundreds of journal entries and you edit one, the difference between \"rebuild everything\" and \"rebuild this page\" is the difference between a usable workflow and a frustrating one.

      • Large site performance: Specifically designed for tens of thousands of pages. The journal grows with every session. A tool that slows down as content accumulates is a tool you will eventually replace.

      A proven team starting fresh is more predictable than an unproven team at v3.0.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#2-the-architecture","level":3,"title":"2. The Architecture","text":"

      Zensical is investing in a Rust-based Markdown parser with CommonMark support. That signals something about the team's priorities:

      Performance foundations first; features second.

      ctx's journal will grow:

      • Every exported session adds files.
      • Every enrichment pass adds metadata.

      Choosing a tool that gets slower as you add content means choosing to migrate later.

      Choosing one built for scale means the decision holds.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#3-the-migration-path","level":3,"title":"3. The Migration Path","text":"

      Zensical reads mkdocs.yml natively. If it doesn't work out, I can move back to MkDocs + Material with zero content changes:

      • The Markdown is standard;
      • The frontmatter is standard;
      • The configuration is compatible.

      This is the infrastructure pattern again: The same way ZNC decouples presence from the client, zensical decouples rendering from the generator:

      • The Markdown is yours.
      • The frontmatter is standard YAML.
      • The configuration is MkDocs-compatible.

      You are not locked into anything except your own content.

      No lock-in is not a feature: It's a design philosophy:

      It's the same reason ctx uses plain Markdown files in .context/ instead of a database: the format should outlive the tool.

      Lock-in Is the Real Risk, Not Version Numbers

      A mature tool with a proprietary format is riskier than a young tool with a standard one. Version numbers measure time invested. Portability measures respect for the user.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#4-the-dependency-tree","level":3,"title":"4. The Dependency Tree","text":"

      Here is what pip install zensical actually pulls in:

      • click
      • Markdown
      • Pygments
      • pymdown-extensions
      • PyYAML

      Only five dependencies. All well-known. No framework bloat. No bundler. No transpiler. No node_modules black hole.

      3k GitHub stars at v0.0.21 is a strong early traction for a pre-1.0 project.

      The dependency tree is thin: No bloat.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#5-the-fit","level":3,"title":"5. The Fit","text":"

      This is the same principle behind the attention budget: do not overfit the tool to hypothetical requirements. The right amount of capability is the minimum needed for the current task.

      Hugo is a powerful static site generator. It is also a powerful templating engine, a powerful asset pipeline, and a powerful taxonomy system. For rendering Markdown journals, that power is overhead:

      It is the complexity you pay for but never use.

      ctx's journal files are standard Markdown with YAML frontmatter, tables, and fenced code blocks. That is exactly the sweet spot Zensical inherits from Material for MkDocs:

      • No custom plugins needed;
      • No special syntax;
      • No templating gymnastics.

      The requirements match the capabilities: Not the capabilities that are promised, but the ones that exist today, at v0.0.21.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-caveat","level":2,"title":"The Caveat","text":"

      It would be dishonest not to mention what's missing.

      The module system for third-party extensions opens in early 2026.

      If ctx ever needs custom plugins (for example, auto-linking session IDs, rendering special journal metadata, etc.) that infrastructure isn't there yet.

      The installation experience is rough:

      We discovered this firsthand: pip install zensical often fails on MacOS (system Python stubs, Homebrew's PEP 668 restrictions). The answer is pipx, which creates an isolated environment with the correct Python version automatically.

      That kind of friction is typical for young Python tooling, and it is documented in the Getting Started guide.

      And 3,000 stars at v0.0.21 is strong early traction, but it's still early: The community is small. When something breaks, you're reading source code, not documentation.

      These are real costs. I chose to pay them because the alternative costs are higher.

      For example:

      • Hugo's templating pain would cost me time on every site change.
      • Astro's JS ecosystem would add complexity I don't need.
      • MkDocs would work today but hit scaling walls tomorrow.

      Zensical's costs are front-loaded and shrinking.

      The others compound.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation-framework","level":2,"title":"The Evaluation Framework","text":"

      For anyone facing a similar choice, here is the framework that emerged:

      Signal What It Tells You Weight Team track record Whether the architecture will be sound High Migration path Whether you can leave if wrong High Current fit Whether it solves your problem today High Dependency tree How much complexity you're inheriting Medium Version number How long the project has existed Low Star count Community interest (not quality) Low Feature list What's possible (not what you need) Low

      The bottom three are the metrics most engineers optimize for.

      The top four are the ones that predict whether you'll still be happy with the choice in a year.

      Features You Don't Need Are Not Free

      Every feature in a dependency is code you inherit but don't control.

      A tool with 200 features where you use 5 means 195 features worth of surface area for bugs, breaking changes, and security issues that have nothing to do with your use case.

      Fit is the inverse of feature count.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-broader-pattern","level":2,"title":"The Broader Pattern","text":"

      This is part of a theme I keep encountering in this project:

      Leading indicators beat lagging indicators.

      Domain Lagging Indicator Leading Indicator Tooling Version number, star count Team track record, architecture Code quality Test coverage percentage Whether tests catch real bugs Context persistence Number of files in .context/ Whether the AI makes fewer mistakes Skills Number of skills created Whether each skill fires at the right time Consolidation Lines of code refactored Whether drift stops accumulating

      Version numbers, star counts, coverage percentages, file counts...

      ...these are all measures of effort expended.

      They say nothing about value delivered.

      The question is never \"how mature is this tool?\"

      The question is \"does this tool's trajectory intersect with my needs?\"

      Zensical's trajectory:

      • A proven team fixing known problems,
      • in a *proven architecture,
      • with a standard format,
      • and no lock-in.

      ctx's needs:

      Tender standard Markdown into a browsable site, at scale, without complexity.

      The intersection is clean; the version number is noise.

      This is the same kind of decision that shows up throughout ctx:

      • Skills that fight the platform taught that the best integration extends existing behavior, not replaces it.
      • You can't import expertise taught that tools should grow from your project's actual needs, not from feature checklists.
      • Context as infrastructure argues that the format should outlive the tool; and, zensical honors that principle by reading standard Markdown and standard MkDocs configuration.

      If You Remember One Thing from This Post...

      Version numbers measure where a project has been.

      The team and the architecture tell you where it's going.

      A v0.0.21 tool built by the right team on the right foundations is a safer bet than a v5.0 tool that doesn't fit your problem.

      Bet on trajectories, not timestamps.

      This post started as an evaluation note in ideas/ and a separate decision log. The analysis held up. The two merged into one. The meta continues.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/","level":1,"title":"ctx v0.6.0: The Integration Release","text":"","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#two-commands-to-persistent-memory","level":2,"title":"Two Commands to Persistent Memory","text":"

      Jose Alekhinne / February 16, 2026

      What Changed?

      ctx is now a Claude Code plugin. Two commands, no build step:

      /plugin marketplace add ActiveMemory/ctx\n/plugin install ctx@activememory-ctx\n

      Six hooks. Twenty-five skills. Installed.

      For three releases, ctx required assembly:

      • Clone the repo;
      • Build the binary;
      • Copy hook scripts into .claude/hooks/;
      • Symlink skill files.
      • Understand which shell scripts called which Go commands;
      • Hope nothing broke when Claude Code updated its hook format.

      v0.6.0 ends that era: ctx ships as a Claude Marketplace plugin:

      Hooks and skills served directly from source, installed with a single command, updated by pulling the repo. The tool that gives AI persistent memory is now as easy to install as the AI itself.

      But the plugin conversion was not just a packaging change: It was the forcing function that rewrote every shell hook in Go, eliminated the jq dependency, enabled go test coverage for hook logic, and made distribution a solved problem.

      When you fix how something ships, you end up fixing how it is built.

      The Release Window

      February 15-February 16, 2026

      From the v0.3.0 tag to commit a3178bc:

      • 109 commits.
      • 334 files changed.
      • Version jumped from 0.3.0 to 0.6.0 to signal the magnitude.
      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#before-six-shell-scripts-and-a-prayer","level":2,"title":"Before: Six Shell Scripts and a Prayer","text":"

      v0.3.0 had six hook scripts. Each was a Bash file that shelled out to ctx subcommands, parsed JSON with jq, and wired itself into Claude Code's hook system via .claude/hooks/:

      .claude/hooks/\n├── check-context-size.sh\n├── check-persistence.sh\n├── check-journal.sh\n├── post-commit.sh\n├── block-non-path-ctx.sh\n└── cleanup-tmp.sh\n

      This worked, but it also meant:

      • jq was a hard dependency: No jq, no hooks. macOS ships without it.
      • No test coverage: Shell scripts were tested manually or not at all.
      • Fragile deployment: ctx init had to scaffold .claude/hooks/ and .claude/skills/ with the right paths, permissions, and structure.
      • Version drift: Users who installed once never got hook updates unless they re-ran ctx init.

      The shell scripts were the right choice for prototyping. They were the wrong choice for distribution.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#after-one-plugin-zero-shell-scripts","level":2,"title":"After: One Plugin, Zero Shell Scripts","text":"

      v0.6.0 replaces all six scripts with ctx system subcommands compiled into the binary:

      Shell Script Go Subcommand check-context-size.sh ctx system check-context-size check-persistence.sh ctx system check-persistence check-journal.sh ctx system check-journal post-commit.sh ctx system post-commit block-non-path-ctx.sh ctx system block-non-path-ctx cleanup-tmp.sh ctx system cleanup-tmp

      The plugin's hooks.json wires them to Claude Code events:

      {\n  \"PreToolUse\": [\n    {\"matcher\": \"Bash\", \"command\": \"ctx system block-non-path-ctx\"},\n    {\"matcher\": \".*\", \"command\": \"ctx agent --budget 4000\"}\n  ],\n  \"PostToolUse\": [\n    {\"matcher\": \"Bash\", \"command\": \"ctx system post-commit\"}\n  ],\n  \"UserPromptSubmit\": [\n    {\"command\": \"ctx system check-context-size\"},\n    {\"command\": \"ctx system check-persistence\"},\n    {\"command\": \"ctx system check-journal\"}\n  ],\n  \"SessionEnd\": [\n    {\"command\": \"ctx system cleanup-tmp\"}\n  ]\n}\n

      No jq. No shell scripts. No .claude/hooks/ directory to manage.

      The hooks are Go functions with tests, compiled into the same binary you already have.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#the-plugin-model","level":2,"title":"The Plugin Model","text":"

      The ctx plugin lives at .claude-plugin/marketplace.json in the repo.

      Claude Code's marketplace system handles discovery and installation:

      Skills are served directly from internal/assets/claude/skills/; there is no build step, no make plugin, no generated artifacts.

      This means:

      1. Install is two commands: Not \"clone, build, copy, configure.\"
      2. Updates are automatic: Pull the repo; the plugin reads from source.
      3. Skills and hooks are versioned together: No drift between what the CLI expects and what the plugin provides.
      4. ctx init is tool-agnostic: It creates .context/ and nothing else. No .claude/ scaffolding, no assumptions about which AI tool you use.

      That last point matters:

      Before v0.6.0, ctx init tried to set up Claude Code integration as part of initialization. That coupled the context system to a specific tool.

      Now, ctx init gives you persistent context. The plugin gives you Claude Code integration. They compose; they don't depend.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#beyond-the-plugin-what-else-shipped","level":2,"title":"Beyond the Plugin: What Else Shipped","text":"

      The plugin conversion dominated the release, but 109 commits covered more ground.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#obsidian-vault-export","level":3,"title":"Obsidian Vault Export","text":"
      ctx journal obsidian\n

      Generates a full Obsidian vault from enriched journal entries: wikilinks, MOC (Map of Content) pages, and graph-optimized cross-linking. If you already use Obsidian for notes, your AI session history now lives alongside everything else.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#encrypted-scratchpad","level":3,"title":"Encrypted Scratchpad","text":"
      ctx pad edit \"DATABASE_URL=postgres://...\"\nctx pad show\n

      AES-256-GCM encrypted storage for sensitive one-liners.

      The encrypted blob commits to git; the key stays in .gitignore.

      This is useful for connection strings, API keys, and other values that need to travel with the project without appearing in plaintext.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#security-hardening","level":3,"title":"Security Hardening","text":"

      Three medium-severity findings from a security audit are now closed:

      Finding Fix Path traversal via --context-dir Boundary validation: operations cannot escape project root (M-1) Symlink following in .context/ Lstat() check before every file read/write (M-2) Predictable temp file paths User-specific temp directory under $XDG_RUNTIME_DIR (M-3)

      Plus a new /sanitize-permissions skill that audits settings.local.json for overly broad Bash permissions.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#hooks-that-know-when-to-be-quiet","level":3,"title":"Hooks That Know When to Be Quiet","text":"

      A subtle but important fix: hooks now no-op before ctx init has run.

      Previously, a fresh clone with no .context/ would trigger hook errors on every prompt. Now, hooks detect the absence of a context directory and exit silently. Similarly, ctx init treats a .context/ directory containing only logs as uninitialized and skips the --overwrite prompt.

      Small changes. Large reduction in friction for new users.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#the-numbers","level":2,"title":"The Numbers","text":"Metric v0.3.0 v0.6.0 Skills 21 25 Shell hook scripts 6 0 Go system subcommands 0 6 External dependencies (hooks) jq, bash none Lines of Go ~14,000 ~37,000 Plugin install commands n/a 2 Security findings (open) 3 0 ctx init creates .claude/ yes no

      The line count tripled. Most of that is documentation site HTML, Obsidian export logic, and the scratchpad encryption module.

      The core CLI grew modestly; the ecosystem around it grew substantially.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#what-does-v060-mean-for-ctx","level":2,"title":"What Does v0.6.0 Mean for ctx?","text":"
      • v0.1.0 asked: \"Can we give AI persistent memory?\"
      • v0.2.0 asked: \"Can we make that memory accessible to humans too?\"
      • v0.3.0 asked: \"Can we make the quality self-enforcing?\"

      v0.6.0 asks: \"Can someone else actually use this?\"

      A tool that requires cloning a repo, building from source, and manually wiring hooks into the right directories is a tool for its author.

      A tool that installs with two commands from a marketplace is a tool for everyone.

      The version jumped from 0.3.0 to 0.6.0 because the delta is not incremental: The shell-to-Go rewrite, the plugin model, the security hardening, and the tool-agnostic init: Together, they change what ctx is: Not a different tool, but a tool that is finally ready to leave the workshop.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#what-comes-next","level":2,"title":"What Comes Next","text":"

      The plugin model opens the door to distribution patterns that were not possible before. Marketplace discovery means new users find ctx without reading a README. Plugin updates mean existing users get improvements without rebuilding.

      The next chapter is about what happens when persistent context is easy to install: Adoption patterns, multi-project workflows, and whether the .context/ convention can become infrastructure that other tools build on.

      But those are future posts.

      This one is about the release that turned a developer tool into a distributable product: two commands, zero shell scripts, and a presence on the Claude Marketplace.

      The Integration Release

      v0.1.0 shipped features. v0.2.0 shipped archaeology.

      v0.3.0 shipped discipline. v0.6.0 shipped the front door.

      The most important code in this release is the code you never have to copy.

      This post was drafted using /ctx-blog-changelog with access to the full git history between v0.3.0 and v0.6.0, release notes, and the plugin conversion PR. The meta continues.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/","level":1,"title":"Code Is Cheap. Judgment Is Not.","text":"","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#why-ai-replaces-effort-not-expertise","level":2,"title":"Why AI Replaces Effort, Not Expertise","text":"

      Jose Alekhinne / February 17, 2026

      Are You Worried about AI Taking Your Job?

      You might be confusing the thing that's cheap with the thing that's valuable.

      I keep seeing the same conversation: Engineers, designers, writers: all asking the same question with the same dread:

      \"What happens when AI can do what I do?\"

      The question is wrong:

      • AI does not replace workers;
      • AI replaces unstructured effort.

      The distinction matters, and everything I have learned building ctx reinforces it.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-three-confusions","level":2,"title":"The Three Confusions","text":"

      People who feel doomed by AI usually confuse three things:

      People confuse... With... Effort Value Typing Thinking Production Judgment
      • Effort is time spent.
      • Value is the outcome that time produces.

      They are not the same; they never were.

      AI just makes the gap impossible to ignore.

      Typing is mechanical: Thinking is directional.

      An AI can type faster than any human. Yet, it cannot decide what to type without someone framing the problem, sequencing the work, and evaluating the result.

      Production is making artifacts. Judgment is knowing:

      • which artifacts to make,
      • in what order,
      • to what standard,
      • and when to stop.

      AI floods the system with production capacity; it does not flood the system with judgment.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#code-is-nothing","level":2,"title":"Code Is Nothing","text":"

      This sounds provocative until you internalize it:

      Code is cheap. Artifacts are cheap.

      An AI can generate a thousand lines of working code in literal *minutes**:

      It can scaffold a project, write tests, build a CI pipeline, draft documentation. The raw production of software artifacts is no longer the bottleneck.

      So, what is not cheap?

      • Taste: knowing what belongs and what does not
      • Framing: turning a vague goal into a concrete problem
      • Sequencing: deciding what to build first and why
      • Fanning out: breaking work into parallel streams that converge
      • Acceptance criteria: defining what \"done\" looks like before starting
      • Judgment: the thousand small decisions that separate code that works from code that lasts

      These are the skills that direct production: Hhuman skills.

      Not because AI is incapable of learning them, but because they require something AI does not have:

      temporal accountability for generated outcomes.

      That is, you cannot keep AI accountable for the $#!% it generated three months ago. A human, on the other hand, will always be accountable.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-evidence-from-building-ctx","level":2,"title":"The Evidence from Building ctx","text":"

      I did not arrive at this conclusion theoretically.

      I arrived at it by building a tool with an AI agent for three weeks and watching exactly where a human touch mattered.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#yolo-mode-proved-production-is-cheap","level":3,"title":"YOLO Mode Proved Production Is Cheap","text":"

      In Building ctx Using ctx, I documented the YOLO phase: auto-accept everything, let the AI ship features at full speed. It produced 14 commands in a week. Impressive output.

      The code worked. The architecture drifted. Magic strings accumulated. Conventions diverged. The AI was producing at a pace no human could match, and every artifact it produced was a small bet that nobody was evaluating.

      Production without judgment is not velocity. It is debt accumulation at breakneck speed.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-31-ratio-proved-judgment-has-a-cadence","level":3,"title":"The 3:1 Ratio Proved Judgment Has a Cadence","text":"

      In The 3:1 Ratio, the git history told the story:

      Three sessions of forward momentum followed by one session of deliberate consolidation. The consolidation session is where the human applies judgment: reviewing what the AI built, catching drift, realigning conventions.

      The AI does the refactoring. The human decides what to refactor and when to stop.

      Without the human, the AI will refactor forever, improving things that do not matter and missing things that do.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-attention-budget-proved-framing-is-scarce","level":3,"title":"The Attention Budget Proved Framing Is Scarce","text":"

      In The Attention Budget, I explained why more context makes AI worse, not better. Every token competes for attention: Dump everything in and the AI sees nothing clearly.

      This is a framing problem: The human's job is to decide what the AI should focus on: what to include, what to exclude, what to emphasize.

      ctx agent --budget 4000 is not just a CLI flag: It is a forcing function for human judgment about relevance.

      The AI processes. The human curates.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#skills-design-proved-taste-is-load-bearing","level":3,"title":"Skills Design Proved Taste Is Load-Bearing","text":"

      The skill trilogy (You Can't Import Expertise, The Anatomy of a Skill That Works) showed that the difference between a useful skill and a useless one is not craftsmanship:

      It is taste.

      A well-crafted skill with the wrong focus is worse than no skill at all: It consumes the attention budget with generic advice while the project-specific problems go unchecked.

      The E/A/R framework (Expert, Activation, Redundant) is a judgment too:. The AI cannot apply it to itself. The human evaluates what the AI already knows, what it needs to be told, and what is noise.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#automation-discipline-proved-restraint-is-a-skill","level":3,"title":"Automation Discipline Proved Restraint Is a Skill","text":"

      In Not Everything Is a Skill, the lesson was that the urge to automate is not the need to automate. A useful prompt does not automatically deserve to become a slash command.

      The human applies judgment about frequency, stability, and attention cost.

      The AI can build the skill. Only the human can decide whether it should exist.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#defense-in-depth-proved-boundaries-require-judgment","level":3,"title":"Defense in Depth Proved Boundaries Require Judgment","text":"

      In Defense in Depth, the entire security model for unattended AI agents came down to: markdown is not a security boundary. Telling an AI \"don't do bad things\" is production (of instructions). Setting up an unprivileged user in a network-isolated container is judgment (about risk).

      The AI follows instructions. The human decides which instructions are enforceable and which are \"wishful thinking\".

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#parallel-agents-proved-scale-amplifies-the-gap","level":3,"title":"Parallel Agents Proved Scale Amplifies the Gap","text":"

      In Parallel Agents and Merge Debt, the lesson was that multiplying agents multiplies output. But it also multiplies the need for judgment:

      Five agents running in parallel produce five sessions of drift in one clock hour. The human who can frame tasks cleanly, define narrow acceptance criteria, and evaluate results quickly becomes the limiting factor.

      More agents do not reduce the need for judgment. They increase it.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-two-reactions","level":2,"title":"The Two Reactions","text":"

      When AI floods the system with cheap output, two things happen:

      Those who only produce: panic. If your value proposition is \"I write code,\" and an AI writes code faster, cheaper, and at higher volume, then the math is unfavorable. Not because AI took your job, but because your job was never the code. It was the judgment around the code, and you were not exercising it.

      Those who direct: accelerate. If your value proposition is \"I know what to build, in what order, to what standard,\" then AI is the best thing that ever happened to you: Production is no longer the bottleneck: Your ability to frame, sequence, evaluate, and course-correct is now the limiting factor on throughput.

      The gap between these two is not talent: It is the awareness of where the value lives.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#what-this-means-in-practice","level":2,"title":"What This Means in Practice","text":"

      If you are an engineer reading this, the actionable insight is not \"learn prompt engineering\" or \"master AI tools.\" It is:

      Get better at the things AI cannot do.

      AI does this well You need to do this Generate code Frame the problem Write tests Define acceptance criteria Scaffold projects Sequence the work Fix bugs from stack traces Evaluate tradeoffs Produce volume Exercise restraint Follow instructions Decide which instructions matter

      The skills on the right column are not new. They are the same skills that have always separated senior engineers from junior ones.

      AI did not create the distinction; it just made it load-bearing.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#if-anything-i-feel-empowered","level":2,"title":"If Anything, I Feel Empowered","text":"

      I will end with something personal.

      I am not worried: I am empowered.

      Before ctx, I could think faster than I could produce:

      • Ideas sat in a queue.
      • The bottleneck was always \"I know what to build, but building it takes too long.\"

      Now the bottleneck is gone. Poof!

      • Production is cheap.
      • The queue is clearing.
      • The limiting factor is how fast I can think, not how fast I can type.

      That is not a threat: That is the best force multiplier I've ever had.

      The people who feel threatened are confusing the accelerator for the replacement:

      *AI does not replace the conductor; it gives them a bigger orchestra.

      If You Remember One Thing from This Post...

      Code is cheap. Judgment is not.

      AI replaces unstructured effort, not directed expertise. The skills that matter now are the same skills that have always mattered: taste, framing, sequencing, and the discipline to stop.

      The difference is that now, for the first time, those skills are the only bottleneck left.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-arc","level":2,"title":"The Arc","text":"

      This post is a retrospective. It synthesizes the thread running through every previous entry in this blog:

      • Building ctx Using ctx showed that production without direction creates debt
      • Refactoring with Intent showed that slowing down is not the opposite of progress
      • The Attention Budget showed that curation outweighs volume
      • The skill trilogy showed that taste determines whether a tool helps or hinders
      • Not Everything Is a Skill showed that restraint is a skill in itself
      • Defense in Depth showed that instructions are not boundaries
      • The 3:1 Ratio showed that judgment has a schedule
      • Parallel Agents showed that scale amplifies the gap between production and judgment
      • Context as Infrastructure showed that the system you build for context is infrastructure, not conversation

      From YOLO mode to defense in depth, the pattern is the same:

      • Production is the easy part;
      • Judgment is the hard part;
      • AI changed the ratio, not the rule.

      This post synthesizes the thread running through every previous entry in this blog. The evidence is drawn from three weeks of building ctx with AI assistance, the decisions recorded in DECISIONS.md, the learnings captured in LEARNINGS.md, and the git history that tracks where the human mattered and where the AI ran unsupervised.

      See also: When a System Starts Explaining Itself -- what happens after the arc: the first field notes from the moment the system starts compounding in someone else's hands.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/","level":1,"title":"Context as Infrastructure","text":"","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#why-your-ai-needs-a-filesystem-not-a-prompt","level":2,"title":"Why Your AI Needs a Filesystem, Not a Prompt","text":"

      Jose Alekhinne / February 17, 2026

      Where Does Your AI's Knowledge Live between Sessions?

      If the answer is \"in a prompt I paste at the start,\" you are treating context as a consumable. Something assembled, used, and discarded.

      What if you treated it as infrastructure instead?

      This post synthesizes a thread that has been running through every ctx blog post; from the origin story to the attention budget to the discipline release. The thread is this: context is not a prompt problem. It is an infrastructure problem. And the tools we build for it should look more like filesystems than clipboard managers.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-prompt-paradigm","level":2,"title":"The Prompt Paradigm","text":"

      Most AI-assisted development treats context as ephemeral:

      1. Start a session.
      2. Paste your system prompt, your conventions, your current task.
      3. Work.
      4. Session ends. Everything evaporates.
      5. Next session: paste again.

      This works for short interactions. For sustained development (where decisions compound over days and weeks) it fails in three ways:

      It does not persist: A decision made on Tuesday must be re-explained on Wednesday. A learning captured in one session is invisible to the next.

      It does not scale: As the project grows, the \"paste everything\" approach hits the context window ceiling. You start triaging what to include, often cutting exactly the context that would have prevented the next mistake.

      It does not compose: A system prompt is a monolith. You cannot load part of it, update one section, or share a subset with a different workflow. It is all or nothing.

      The Copy-Paste Tax

      Every session that starts with pasting a prompt is paying a tax:

      The human time to assemble the context, the risk of forgetting something, and the silent assumption that yesterday's prompt is still accurate today.

      Over 70+ sessions, that tax compounds into a significant maintenance burden: One that most developers absorb without questioning it.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-infrastructure-paradigm","level":2,"title":"The Infrastructure Paradigm","text":"

      ctx takes a different approach:

      Context is not assembled per-session; it is maintained as persistent files in a .context/ directory:

      .context/\n  CONSTITUTION.md     # Inviolable rules\n  TASKS.md            # Current work items\n  CONVENTIONS.md      # Code patterns and standards\n  DECISIONS.md        # Architectural choices with rationale\n  LEARNINGS.md        # Gotchas and lessons learned\n  ARCHITECTURE.md     # System structure\n  GLOSSARY.md         # Domain terminology\n  AGENT_PLAYBOOK.md   # Operating manual for agents\n  journal/            # Enriched session summaries\n  archive/            # Completed work, cold storage\n
      • Each file has a single purpose;
      • Each can be loaded independently;
      • Each persists across sessions, tools, and team members.

      This is not a novel idea. It is the same idea behind every piece of infrastructure software engineers already use:

      Traditional Infrastructure ctx Equivalent Database .context/*.md files Configuration files CONSTITUTION.md Environment variables .contextrc Log files journal/ Schema migrations Decision records Deployment manifests AGENT_PLAYBOOK.md

      The parallel is not metaphorical. Context files are infrastructure:

      • They are versioned (git tracks them);
      • They are structured (Markdown with conventions);
      • They have schemas (required fields for decisions and learnings);
      • And they have lifecycle management (archiving, compaction, indexing).
      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#separation-of-concerns","level":2,"title":"Separation of Concerns","text":"

      The most important design decision in ctx is not any individual feature. It is the separation of context into distinct files with distinct purposes.

      A single CONTEXT.md file would be simpler to implement. It would also be impossible to maintain.

      Why? Because different types of context have different lifecycles:

      Context Type Changes Read By Load When Constitution Rarely Every session Always Tasks Every session Session start Always Conventions Weekly Before coding When writing code Decisions When decided When questioning When revisiting Learnings When learned When stuck When debugging Journal Every session Rarely When investigating

      Loading everything into every session wastes the attention budget on context that is irrelevant to the current task. Loading nothing forces the AI to operate blind.

      Separation of concerns allows progressive disclosure:

      Load the minimum that matters for this moment, with the option to load more when needed.

      # Session start: load the essentials\nctx agent --budget 4000\n\n# Deep investigation: load everything\ncat .context/DECISIONS.md\ncat .context/journal/2026-02-05-*.md\n

      The filesystem is the index. File names, directory structure, and timestamps encode relevance. The AI does not need to read every file; it needs to know where to look.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-two-tier-persistence-model","level":2,"title":"The Two-Tier Persistence Model","text":"

      ctx uses two tiers of persistence, and the distinction is architectural:

      Tier Purpose Location Token Cost Curated Quick context reload .context/*.md Low (budgeted) Full dump Safety net, archaeology .context/journal/*.md Zero (not auto-loaded)

      The curated tier is what the AI sees at session start. It is optimized for signal density:

      • Structured entries,
      • Indexed tables,
      • Reverse-chronological order (newest first, so the most relevant content survives truncation).

      The full dump tier is for humans and for deep investigation. It contains everything: Enriched journals, archived tasks...

      It is never autoloaded because its volume would destroy attention density.

      This two-tier model is analogous to how traditional systems separate hot and cold storage:

      • The hot path (curated context) is optimized for read performance (measured not in milliseconds, but in tokens consumed per unit of useful information).
      • The cold path (journal) is optimized for completeness.

      Nothing Is Ever Truly Lost

      The full dump tier means that context does not need to be perfect: It just needs to be findable.

      A decision that was not captured in DECISIONS.md can be recovered from the session transcript where it was discussed.

      A learning that was not formalized can be found in the journal entry from that day.

      The curated tier is the fast path: The full dump tier is the safety net.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#decision-records-as-first-class-citizens","level":2,"title":"Decision Records as First-Class Citizens","text":"

      One of the patterns that emerged from ctx's own development is the power of structured decision records.

      v0.1.0 allowed adding decisions as one-liners:

      ctx add decision \"Use PostgreSQL\"\n

      v0.2.0 enforced structure:

      ctx add decision \"Use PostgreSQL\" \\\n  --context \"Need a reliable database for user data\" \\\n  --rationale \"ACID compliance, team familiarity\" \\\n  --consequence \"Need connection pooling, team training\"\n

      The difference is not cosmetic:

      • A one-liner decision teaches the AI what was decided.
      • A structured decision teaches it why; and why is what prevents the AI from unknowingly reversing the decision in a future session.

      This is infrastructure thinking:

      Decisions are not notes. They are records with required fields, just like database rows have schemas.

      The enforcement exists because incomplete records are worse than no records: They create false confidence that the context is captured when it is not.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-ide-is-the-interface-decision","level":2,"title":"The \"IDE Is the Interface\" Decision","text":"

      Early in ctx's development, there was a temptation to build a custom UI: a web dashboard for browsing sessions, editing context, viewing analytics.

      The decision was no. The IDE is the interface.

      # This is the ctx \"UI\":\ncode .context/\n

      This decision was not about minimalism for its own sake. It was about recognizing that .context/ files are just files; and files have a mature, well-understood infrastructure:

      • Version control: git diff .context/DECISIONS.md shows exactly what changed and when.
      • Search: Your IDE's full-text search works across all context files.
      • Editing: Markdown in any editor, with preview, spell check, and syntax highlighting.
      • Collaboration: Pull requests on context files work the same as pull requests on code.

      Building a custom UI would have meant maintaining a parallel infrastructure that duplicates what every IDE already provides:

      It would have introduced its own bugs, its own update cycle, and its own learning curve.

      The filesystem is not a limitation: It is the most mature, most composable, most portable infrastructure available.

      Context Files in Git

      Because .context/ lives in the repository, context changes are part of the commit history.

      A decision made in commit abc123 is as traceable as a code change in the same commit.

      This is not possible with prompt-based context, which exists outside version control entirely.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#progressive-disclosure-for-ai","level":2,"title":"Progressive Disclosure for AI","text":"

      The concept of progressive disclosure comes from human interface design: show the user the minimum needed to make progress, with the option to drill deeper.

      ctx applies the same principle to AI context:

      Level What the AI Sees Token Cost When Level 0 ctx status (one-line summary) ~100 Quick check Level 1 ctx agent --budget 4000 ~4,000 Normal work Level 2 ctx agent --budget 8000 ~8,000 Complex tasks Level 3 Direct file reads 10,000+ Deep investigation

      Each level trades tokens for depth. Level 1 is sufficient for most work: the AI knows the active tasks, the key conventions, and the recent decisions. Level 3 is for archaeology: understanding why a decision was made three weeks ago, or finding a pattern in the session history.

      The explicit --budget flag is the mechanism that makes this work:

      Without it, the default behavior would be to load everything (because more context feels safer), which destroys the attention density that makes the loaded context useful.

      The constraint is the feature: A budget of 4,000 tokens forces ctx to prioritize ruthlessly: constitution first (always full), then tasks and conventions (budget-capped), then decisions and learnings scored by recency and relevance to active tasks. Entries that don't fit get title-only summaries rather than being silently dropped.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-philosophical-shift","level":2,"title":"The Philosophical Shift","text":"

      The shift from \"context as prompt\" to \"context as infrastructure\" changes how you think about AI-assisted development:

      Prompt Thinking Infrastructure Thinking \"What do I paste today?\" \"What has changed since yesterday?\" \"How do I fit everything in?\" \"What's the minimum that matters?\" \"The AI forgot my conventions\" \"The conventions are in a file\" \"I need to re-explain\" \"I need to update the record\" \"This session is getting slow\" \"Time to compact and archive\"

      The first column treats AI interaction as a conversation. The second treats it as a system: One that can be maintained, optimized, and debugged.

      Context is not something you give the AI. It is something you maintain: Like a database, like a config file, like any other piece of infrastructure that a running system depends on.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#beyond-ctx-the-principles","level":2,"title":"Beyond ctx: The Principles","text":"

      The patterns that ctx implements are not specific to ctx. They are applicable to any project that uses AI-assisted development:

      1. Separate context by purpose: Do not put everything in one file. Different types of information have different lifecycles and different relevance windows.
      2. Make context persistent: If a decision matters, write it down in a file that survives the session. If a learning matters, capture it with structure.
      3. Budget explicitly: Know how much context you are loading and whether it is worth the attention cost.
      4. Use the filesystem: File names, directory structure, and timestamps are metadata that the AI can navigate. A well-organized directory is an index that costs zero tokens to maintain.
      5. Version your context: Put context files in git. Changes to decisions are as important as changes to code.
      6. Design for degradation: Sessions will get long. Attention will dilute. Build mechanisms (compaction, archiving, cooldowns) that make degradation visible and manageable.

      These are not ctx features. They are infrastructure principles that happen to be implemented as a CLI tool. Any team could implement them with nothing more than a directory convention and a few shell scripts.

      The tool is a convenience: The principles are what matter.

      If You Remember One Thing from This Post...

      Prompts are conversations. Infrastructure persists.

      Your AI does not need a better prompt. It needs a filesystem:

      versioned, structured, budgeted, and maintained.

      The best context is the context that was there before you started the session.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-arc","level":2,"title":"The Arc","text":"

      This post is the architectural companion to the Attention Budget. That post explained why context must be curated (token economics). This one explains how to structure it (filesystem, separation of concerns, persistence tiers).

      Together with Code Is Cheap, Judgment Is Not, they form a trilogy about what matters in AI-assisted development:

      • Attention Budget: the resource you're managing
      • Context as Infrastructure: the system you build to manage it
      • Code Is Cheap: the human skill that no system replaces

      And the practices that keep it all honest:

      • The 3:1 Ratio: the cadence for maintaining both code and context
      • IRC as Context: the historical precedent: stateless protocols have always needed stateful wrappers

      This post synthesizes ideas from across the ctx blog series: the attention budget primitive, the two-tier persistence model, the IDE decision, and the progressive disclosure pattern. The principles are drawn from three weeks of building ctx and 70+ sessions of treating context as infrastructure rather than conversation.

      See also: When a System Starts Explaining Itself: what happens when this infrastructure starts compounding in someone else's environment.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/","level":1,"title":"Parallel Agents, Merge Debt, and the Myth of Overnight Progress","text":"","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#when-the-screen-looks-like-progress","level":2,"title":"When the Screen Looks like Progress","text":"

      Jose Alekhinne / 2026-02-17

      How Many Terminals Are Too Many?

      You discover agents can run in parallel.

      So you open ten...

      ...Then twenty.

      The fans spin. Tokens burn. The screen looks like progress.

      It is NOT progress.

      There is a phase every builder goes through:

      • The tooling gets fast enough.
      • The model gets good enough.
      • The temptation becomes irresistible:
        • more agents, more output, faster delivery.

      So you open terminals. You spawn agents. You watch tokens stream across multiple windows simultaneously, and it feels like multiplication.

      It is not multiplication.

      It is merge debt being manufactured in real time.

      The ctx Manifesto says it plainly:

      Activity is not impact. Code is not progress.

      This post is about what happens when you take that seriously in the context of parallel agent workflows.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-unit-of-scale-is-not-the-agent","level":2,"title":"The Unit of Scale Is Not the Agent","text":"

      The naive model says:

      More agents -> more output -> faster delivery

      The production model says:

      Clean context boundaries -> less interference -> higher throughput

      Parallelism only works when the cognitive surfaces do not overlap.

      If two agents touch the same files, you did not create parallelism: You created a conflict generator.

      They will:

      • Revert each other's changes;
      • Relint each other's formatting;
      • Refactor the same function in different directions.

      You watch with 🍿. Nothing ships.

      This is the same insight from the worktrees post: partition by blast radius, not by priority.

      Two tasks that touch the same files belong in the same track, no matter how important the other one is. The constraint is file overlap.

      Everything else is scheduling.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-five-agent-rule","level":2,"title":"The \"Five Agent\" Rule","text":"

      In practice there is a ceiling.

      Around five or six concurrent agents:

      • Token burn becomes noticeable;
      • Supervision cost rises;
      • Coordination noise increases;
      • Returns flatten.

      This is not a model limitation: This is a human merge bandwidth limitation.

      You are the bottleneck, not the silicon.

      The attention budget applies to you too:

      Every additional agent is another stream of output you need to comprehend, verify, and integrate. Your attention density drops the same way the model's does when you overload its context window.

      Five agents producing verified, mergeable change beats twenty agents producing merge conflicts you spend a day untangling.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#role-separation-beats-file-locking","level":2,"title":"Role Separation Beats File Locking","text":"

      Real parallelism comes from task topology, not from tooling.

      Good:

      Agent Role Touches 1 Documentation docs/, hack/ 2 Security scan Read-only audit 3 Implementation internal/cli/ 4 Enhancement requests Read-only, files issues

      Bad:

      • Four agents editing the same implementation surface

      Context Is the Boundary

      • The goal is not to keep agents busy.
      • The goal is to keep contexts isolated.

      This is what the codebase audit got right:

      • Eight agents, all read-only, each analyzing a different dimension.
      • Zero file overlap.
      • Zero merge conflicts.
      • Eight reports that composed cleanly because no agent interfered with another.
      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#when-terminals-stop-scaling","level":2,"title":"When Terminals Stop Scaling","text":"

      There is a moment when more windows stop helping.

      That is the signal. Not to add orchestration. But to introduce:

      git worktree\n

      Because now you are no longer parallelizing execution; you are parallelizing state.

      State Scales, Windows Don't

      • State isolation is the real scaling.
      • Window multiplication is theater.

      The worktrees post covers the mechanics:

      • Sibling directories;
      • Branch naming;
      • The inevitable TASKS.md conflicts;
      • The 3-4 worktree ceiling.

      The principle underneath is older than git:

      Shared mutable state is the enemy of parallelism.

      Always has been.

      Always will be.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-overnight-loop-illusion","level":2,"title":"The Overnight Loop Illusion","text":"

      Autonomous night runs are impressive.

      You sleep. The machine produces thousands of lines.

      In the morning:

      • You read;
      • You untangle;
      • You reconstruct intent;
      • You spend a day making it shippable.

      In retrospect, nothing was accelerated.

      The bottleneck moved from typing to comprehension.

      The Comprehension Tax

      If understanding the output costs more than producing it, the loop is a net loss.

      Progress is not measured in generated code.

      Progress is measured in verified, mergeable change.

      The ctx Manifesto calls this out directly:

      The Scoreboard

      Verified reality is the scoreboard.

      The only truth that compounds is verified change in the real world.

      An overnight run that produces 3,000 lines nobody reviewed is not 3,000 lines of progress: It is 3,000 lines of liability until someone verifies every one of them.

      And that someone is (insert drumroll here) you:

      The same bottleneck that was supposedly being bypassed.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#skills-that-fight-the-platform","level":2,"title":"Skills That Fight the Platform","text":"

      Most marketplace skills are prompt decorations:

      • They rephrase what the base model already knows;
      • They increase token usage;
      • They reduce clarity:
      • They introduce behavioral drift.

      We covered this in depth in Skills That Fight the Platform: judgment suppression, redundant guidance, guilt-tripping, phantom dependencies, universal triggers: Five patterns that make agents worse, not better.

      A real skill does one of these:

      • Encodes workflow state;
      • Enforces invariants;
      • Reduces decision branching.

      Everything else is packaging.

      The anatomy post established the criteria: quality gates, negative triggers, examples over rules, skills as contracts.

      If a skill doesn't meet those criteria...

      • It is either a recipe (document it in hack/);
      • Or noise (delete it);
      • There is no third option.
      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#hooks-are-context-that-execute","level":2,"title":"Hooks Are Context That Execute","text":"

      The most valuable skills are not prompts:

      They are constraints embedded in the toolchain.

      For example: The agent cannot push.

      git push becomes:

      Stop. A human reviews first.

      A commit without verification becomes:

      Did you run tests? Did you run linters? What exactly are you shipping?

      This is not safety theater; this is intent preservation.

      The thing the ctx Manifesto calls \"encoding intent into the environment.\"

      The Eight Ways a Hook Can Talk catalogued the full spectrum: from silent enrichment to hard blocks.

      The key insight was that hooks are not just safety rails: They are context that survives execution.

      They are the difference between an agent that remembers the rules and one that enforces them.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#complexity-is-a-tax","level":2,"title":"Complexity Is a Tax","text":"

      Every extra layer adds cognitive weight:

      • Orchestration frameworks;
      • Meta agents;
      • Autonomous planning systems...

      If a single terminal works, stay there.

      If five isolated agents work, stop there.

      Add structure only when a real bottleneck appears.

      NOT when an influencer suggests one.

      This is the same lesson from Not Everything Is a Skill:

      The best automation decision is sometimes not to automate.

      A recipe in a Markdown file costs nothing until you use it.

      An orchestration framework costs attention on every run, whether it helps or not.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#literature-is-throughput","level":2,"title":"Literature Is Throughput","text":"

      Clear writing is not aesthetic: It is compression.

      Better articulation means:

      • Fewer tokens;
      • Fewer misinterpretations;
      • Faster convergence.

      The attention budget taught us that context is a finite resource with a quadratic cost.

      Language determines how fast you spend context.

      A well-written task description that takes 50 tokens outperforms a rambling one that takes 200: Not just because it is cheaper, but because it leaves more headroom for the model to actually think.

      Literature Is NOT Overrated

      • Attention is a finite budget.
      • Language determines how fast you spend it.
      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-real-metric","level":2,"title":"The Real Metric","text":"

      The real metric is not:

      • Lines generated;
      • Agents running;
      • Tasks completed while you sleep.

      But:

      Time from idea to verified, mergeable, production change.

      Everything else is motion.

      The entire blog series has been circling this point:

      • The attention budget was about spending tokens wisely.
      • The skills trilogy was about not wasting them on prompt decoration.
      • The worktrees post was about multiplying throughput without multiplying interference.
      • The discipline release was about what a release looks like when polish outweighs features: 3:1.

      Every post has arrived (and made me converge) at the same answer so far:

      The metric is a verified change, not generated output.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#ctx-was-never-about-spawning-more-minds","level":2,"title":"ctx Was Never about Spawning More Minds","text":"

      ctx is about:

      • Isolating context;
      • Preserving intent;
      • Making progress composable.

      Parallel agents are powerful. But only when you respect the boundaries that make parallelism real.

      Otherwise, you are not scaling cognition; you are scaling interference.

      The ctx Manifesto's thesis holds:

      Without ctx, intelligence resets. With ctx, creation compounds.

      Compounding requires structure.

      Structure requires boundaries.

      Boundaries require the discipline to stop adding agents when five is enough.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#practical-summary","level":2,"title":"Practical Summary","text":"

      A production workflow tends to converge to this:

      Practice Why Stay in one terminal unless necessary Minimize coordination overhead Spawn a small number of agents with non-overlapping responsibilities Conflict avoidance > parallelism Isolate state with worktrees when surfaces grow State isolation is real scaling Encode verification into hooks Intent that survives execution Avoid marketplace prompt cargo cults Skills are contracts, not decorations Measure merge cost, not generation speed The metric is verified change

      This is slower to watch. Faster to ship.

      If You Remember One Thing from This Post...

      Progress is not what the machine produces while you sleep.

      Progress is what survives contact with the main branch.

      See also: Code Is Cheap. Judgment Is Not.: the argument that production capacity was never the bottleneck, and why multiplying agents amplifies the need for human judgment rather than replacing it.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/","level":1,"title":"The 3:1 Ratio","text":"","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#scheduling-consolidation-in-ai-development","level":2,"title":"Scheduling Consolidation in AI Development","text":"

      Jose Alekhinne / February 17, 2026

      How Often Should You Stop Building and Start Cleaning?

      Every developer knows technical debt exists. Every developer postpones dealing with it.

      AI-assisted development makes the problem worse; not because the AI writes bad code, but because it writes code so fast that drift accumulates before you notice.

      In Refactoring with Intent, I mentioned a ratio that worked for me: 3:1. Three YOLO sessions create enough surface area to reveal patterns. The fourth session turns those patterns into structure.

      That was an observation. This post is the evidence.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-observation","level":2,"title":"The Observation","text":"

      During the first two weeks of building ctx, I noticed a rhythm in my own productivity. Feature sessions felt great: new commands, new capabilities, visible progress...

      ...but after three of them, things would start to feel sticky: variable names that almost made sense, files that had grown past their purpose, patterns that repeated without being formalized.

      The fourth session (when I stopped adding and started cleaning) was always the most painful to start and the most satisfying to finish.

      It was also the one that made the next three feature sessions faster.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-evidence-git-history","level":2,"title":"The Evidence: Git History","text":"

      The ctx git history between January 20 and February 7 tells a clear story when you categorize commits:

      Week Feature commits Consolidation commits Ratio Jan 20-26 18 5 3.6:1 Jan 27-Feb 1 14 6 2.3:1 Feb 1-7 15 35+ 0.4:1

      The first week was pure YOLO: Almost four feature commits for every consolidation commit. The codebase grew fast.

      The second week started to self-correct. The ratio dropped as refactoring sessions became necessary: Not scheduled, but forced by friction.

      The third week inverted entirely: v0.3.0 was almost entirely consolidation: the skill migration, the sweep, the documentation standardization. Thirty-five quality commits against fifteen features.

      The debt from weeks one and two was paid in week three.

      The Compounding Problem

      Consolidation debt compounds.

      Week one's drift doesn't just persist into week two: It accelerates, because new features are built on top of drifted patterns.

      By week three, the cost of consolidation was higher than it would have been if spread evenly.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#what-drift-actually-looks-like","level":2,"title":"What Drift Actually Looks Like","text":"

      \"Drift\" sounds abstract. Here is what it looked like concretely in the ctx codebase after three weeks of feature-heavy development:

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#predicate-naming","level":3,"title":"Predicate Naming","text":"

      Convention says boolean functions should be named HasX, IsX, CanX. After three feature sprints:

      // What accumulated:\nfunc CheckIfEnabled() bool  // should be Enabled\nfunc ValidateFormat() bool  // should be ValidFormat\nfunc TestConnection() bool  // should be Connects\nfunc VerifyExists() bool    // should be Exists or HasFile\nfunc EnsureReady() bool     // should be Ready\n

      Five violations. Not bugs, but friction that compounds every time someone (human or AI) reads the code and has to infer the naming convention from inconsistent examples.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#magic-strings","level":3,"title":"Magic Strings","text":"
      // Week 1: acceptable prototype\nif entry.Type == \"task\" {\n    filename = \"TASKS.md\"\n}\n\n// Week 3: same pattern in 7+ files\n// Now it's a maintenance liability\n

      When the same literal appears in seven files, changing it means finding all seven. Missing one means a silent runtime bug. Constants exist to prevent exactly this. But during feature velocity, nobody stops to extract them.

      Refactoring with Intent documented the constants consolidation that cleaned this up. The 3:1 ratio is the practice that prevents it from accumulating again.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#hardcoded-permissions","level":3,"title":"Hardcoded Permissions","text":"
      os.WriteFile(path, data, 0644) // 80+ instances\nos.MkdirAll(path, 0755)        // scattered across packages\n

      Eighty-plus instances of hardcoded file permissions. Not wrong, but if I ever need to change the default (and I did, for hook scripts that need execute permissions), it means a codebase-wide search.

      Drift Is Not Bugs

      None of these are bugs. The code works. Tests pass.

      But drift creates false confidence: the codebase looks consistent until you try to change something and discover that five different conventions exist for the same concept.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#why-you-cannot-consolidate-on-day-one","level":2,"title":"Why You Cannot Consolidate on Day One","text":"

      The temptation is to front-load quality: write all the conventions, enforce all the checks, prevent all the drift before it happens.

      This fails for two reasons.

      First, you do not know what will drift: Predicate naming violations only become a convention check after you notice three different naming patterns competing. Magic strings only become a consolidation target after you change a literal and discover it exists in seven places.

      The conventions emerge from the work; they cannot precede it.

      This is what You Can't Import Expertise meant in practice: the consolidation checks grow from the project's own drift history. You cannot write them on day one because you do not yet know what will drift.

      Second, premature consolidation slows discovery: During the prototyping phase, the goal is to explore the design space. Enforcing strict conventions on code that might be deleted tomorrow is waste.

      YOLO mode has its place: The problem is not YOLO itself, but YOLO without a scheduled cleanup.

      The Consolidation Paradox

      You need a drift history to know what to consolidate.

      You need consolidation to prevent drift from compounding.

      The 3:1 ratio resolves this paradox:

      Let drift accumulate for three sessions (enough to see patterns), then consolidate in the fourth (before the patterns become entrenched*).

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-consolidation-skill","level":2,"title":"The Consolidation Skill","text":"

      The ctx project now has an /audit skill that encodes nine project-specific checks:

      Check What It Catches Predicate naming Boolean functions not using Has/Is/Can Magic strings Repeated literals not in config constants File permissions Hardcoded 0644/0755 not using constants Godoc style Missing or non-standard documentation File length Files exceeding 400 lines Large functions Functions exceeding 80 lines Template drift Live skills diverging from templates Import organization Non-standard import grouping TODO/FIXME staleness Old markers that are no longer relevant

      This is not a generic linter. These are project-specific conventions that emerged from ctx's own development history. A generic code quality tool would catch some of them. Only a project-specific check catches all of them, because some of them (predicate naming, template drift) are conventions that exist nowhere except in this project's CONVENTIONS.md.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-decision-matrix","level":2,"title":"The Decision Matrix","text":"

      Not all drift needs immediate consolidation. Here is the matrix I use:

      Signal Action Same literal in 3+ files Extract to constant Same code block in 3+ places Extract to helper Naming convention violated 5+ times Fix and document rule File exceeds 400 lines Split by concern Convention exists but is regularly violated Strengthen enforcement Pattern exists only in one place Leave it alone Code works but is \"ugly\" Leave it alone

      The last two rows matter:

      Consolidation is about reducing maintenance cost, not achieving aesthetic perfection. Code that works and exists in one place does not benefit from consolidation; it benefits from being left alone until it earns its refactoring.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#consolidation-as-context-hygiene","level":2,"title":"Consolidation as Context Hygiene","text":"

      There is a parallel between code consolidation and context management that became clear during the ctx development:

      Code Consolidation Context Hygiene Extract magic strings Archive completed tasks Standardize naming Keep DECISIONS.md current Remove dead code Compact old sessions Update stale comments Review LEARNINGS.md for staleness Check template drift Verify CONVENTIONS.md matches code

      ctx compact does for context what consolidation does for code:

      It moves completed work to cold storage, keeping the active context clean and focused. The attention budget applies to both the AI's context window and the developer's mental model of the codebase.

      When context files accumulate stale entries, the AI's attention is wasted on completed tasks and outdated conventions. When code accumulates drift, the developer's attention is wasted on inconsistencies that obscure the actual logic.

      Both are solved by the same discipline: periodic, scheduled cleanup.

      This is also why parallel agents make the problem harder, not easier. Three agents running simultaneously produce three sessions' worth of drift in one clock hour. The consolidation cadence needs to match the output rate, not the calendar.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-practice","level":2,"title":"The Practice","text":"

      Here is how the 3:1 ratio works in practice for ctx development:

      Sessions 1-3: Feature work

      • Add new capabilities;
      • Write tests for new code;
      • Do not stop for cleanup unless something is actively broken;
      • Note drift as you see it (a comment, a task, a mental note).

      Session 4: Consolidation

      • Run /audit to surface accumulated drift;
      • Fix the highest-impact items first;
      • Update CONVENTIONS.md if new patterns emerged;
      • Archive completed tasks;
      • Review LEARNINGS.md for anything that became a convention.

      The key insight is that session 4 is not optional. It is not \"if we have time\": It is scheduled with the same priority as feature work.

      The cost of skipping it is not visible immediately; it becomes visible three sessions later, when the next consolidation session takes twice as long because the drift compounded.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#what-the-ratio-is-not","level":2,"title":"What the Ratio Is Not","text":"

      The 3:1 ratio is not a universal law. It is an empirical observation from one project with one developer working with AI assistance.

      Different projects will have different ratios:

      • A mature codebase with strong conventions might sustain 5:1 or higher;
      • A greenfield prototype might need 2:1;
      • A team of multiple developers with different styles might need 1:1.

      The number is less important than the practice: consolidation is not a reaction to problems. It is a scheduled activity.

      If you wait for drift to cause pain before consolidating, you have already paid the compounding cost.

      If You Remember One Thing from This Post...

      Three sessions of building. One session of cleaning.

      Not because the code is dirty, but because drift compounds silently, and the only way to catch it is to look for it on a schedule.

      The ratio is the schedule.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-arc-so-far","level":2,"title":"The Arc so Far","text":"

      This post sits at a crossroads in the ctx story. Looking back:

      • Building ctx Using ctx documented the YOLO sprint that created the initial codebase
      • Refactoring with Intent introduced the 3:1 ratio as an observation from the first cleanup
      • The Attention Budget explained why drift matters: every token of inconsistency consumes the same finite resource as useful context
      • You Can't Import Expertise showed that consolidation checks must grow from the project, not a template
      • The Discipline Release proved the ratio works at release scale: 35 quality commits to 15 feature commits

      And looking forward: the same principle applies to context files, to documentation, and to the merge debt that parallel agents produce. Drift is drift, whether it lives in code, in .context/, or in the gap between what your docs say and what your code does.

      The ratio is the schedule is the discipline.

      This post was drafted from git log analysis of the ctx repository, mapping every commit from January 20 to February 7 into feature vs consolidation categories. The patterns described are drawn from the project's CONVENTIONS.md, LEARNINGS.md, and the /audit skill's check list.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/","level":1,"title":"When a System Starts Explaining Itself","text":"","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#field-notes-from-the-moment-a-private-workflow-becomes-portable","level":2,"title":"Field Notes from the Moment a Private Workflow Becomes Portable","text":"

      Jose Alekhinne / February 17, 2026

      How Do You Know Something Is Working?

      Not from metrics. Not from GitHub stars. Not from praise.

      You know, deep in your heart, that it works when people start describing it wrong.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-first-external-signals","level":2,"title":"The First External Signals","text":"

      Every new substrate begins as a private advantage:

      • It lives inside one mind,
      • One repository,
      • One set of habits.

      It is fast. It is not yet real.

      Reality begins when other people describe it in their own language:

      • Not accurately;
      • Not consistently;
      • But involuntarily.

      The early reports arrived without coordination:

      Better Tasks

      \"I do not know how, but this creates better tasks than my AI plugin.\"

      I See Butterflies

      \"This is better than Adderall.\"

      Dear Manager...

      \"Promotion packet? Done. What is next?\"

      What Is It? Can I Eat It?

      \"Is this a skill?\" 🦋

      Why the Cloak and Dagger?

      \"Why is this not in the marketplace?\"

      And then something more important happened:

      Someone else started making a video!

      That was the boundary.

      ctx no longer required its creator to be present in order to exist.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#misclassification-is-a-sign-of-a-new-primitive","level":2,"title":"Misclassification Is a Sign of a New Primitive","text":"

      When a tool is understood, it is categorized:

      • Editor,
      • Framework,
      • Task manager,
      • Plugin...

      When a substrate appears, it is misclassified:

      \"Is this a skill?\" 🦋

      The question is correct. The category is wrong.

      • Skills live in people.
      • Infrastructure lives in the environment.

      ctx Is Not a Skill: It Is a Form of Relief

      What early adopters experience is not an ability.

      It is the removal of a cognitive constraint.

      This is the same distinction that emerged in the skills trilogy:

      • A skill is a contract between a human and an agent.
      • Infrastructure is the ground both stand on.

      You do not use infrastructure.

      You habitualize it.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-pharmacological-metaphor","level":2,"title":"The Pharmacological Metaphor","text":"

      \"Better than Adderall\" is not praise.

      It is a diagnostic:

      Executive function has been externalized.

      • The system is not making the user work harder.
      • It is restoring continuity.

      From the primitive context of wetware:

      • Continuity feels like focus
      • Focus feels like discipline

      If it walks like a duck and quacks like a duck, it is a duck.

      Discipline is usually simulated.

      Infrastructure makes the simulation unnecessary.

      The attention budget explained why context degrades:

      • Attention density drops as volume grows;
      • The middle gets lost;
      • Sessions end and everything evaporates.

      The pharmacological metaphor says the same thing from the user's lens:

      Save the Cheerleader, Save the World

      The symptom of lost context is lost focus.

      Restore the context. Restore the focus.

      IRC bouncers solved this for chat twenty years ago. ctx solves it for cognition.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#throughput-on-ambiguous-work","level":2,"title":"Throughput on Ambiguous Work","text":"

      Finishing a promotion packet quickly is not a productivity story.

      It is the collapse of reconstruction cost.

      Most complex work is not execution. It is:

      • Remembering why something mattered;
      • Recovering prior decisions;
      • Rebuilding mental state.

      Persistent context removes that tax.

      Velocity appears as a side effect.

      This Is the Two-Tier Model in Practice

      The two-tier persistence model

      • Curated context for fast reload
      • Full journal for archaeology

      is what makes this possible.

      • The user does not notice the system.
      • They notice that the reconstruction cost disappeared.
      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-moment-of-portability","level":2,"title":"The Moment of Portability","text":"

      The system becomes real when two things happen:

      1. It can be installed as a versioned artifact.
      2. It survives contact with a hostile, real codebase.

      This is why the first integration into a living system matters more than any landing page.

      Demos prove possibility.

      Diffs prove reality.

      The ctx Manifesto calls this out directly:

      Verified reality is the scoreboard.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-split-voice","level":2,"title":"The Split Voice","text":"

      A new substrate requires two channels.

      The embodied voice:

      Here is what changed in my actual work.

      The out of body voice:

      Here is what this means.

      One produces trust.

      The other produces understanding.

      Neither is sufficient alone.

      This entire blog has been the second voice.

      • The origin story was the first.
      • The refactoring post was the first.
      • Every release note with concrete diffs was the first.

      This is the first second.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#systems-that-generate-explainers","level":2,"title":"Systems That Generate Explainers","text":"

      Tools are used.

      Platforms are extended.

      Substrates are explained.

      The first unsolicited explainer is a brittle phase change.

      It means the idea has become portable between minds.

      That is the beginning of an ecosystem.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-absence-of-metrics","level":2,"title":"The Absence of Metrics","text":"

      Metrics do not matter at this stage.

      Dashboards are noise.

      The whole premise of ctx is the ruthless elimination of noise.

      Numbers optimize funnels; substrates alter cognition.

      The only valid measurement is irreversible reality:

      • A merged PR;
      • A reproducible install;
      • A decision that is never re-litigated.

      The merge debt post reached the same conclusion from another direction:

      The metric is the verified change, not generated output.

      For adoption, the same rule applies:

      The metric is altered behavior, not download counts.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#what-is-actually-happening","level":2,"title":"What Is Actually Happening","text":"

      A private advantage is becoming an environmental property:

      The system is moving from...

      personal workflow,

      to...

      a shared infrastructure for thought.

      Not by growth.

      Not by marketing.

      By altering how real systems evolve.

      If You Remember One Thing from This Post...

      You do not know a substrate is real when people praise it.

      You know it is real when:

      • They describe it incorrectly;
      • They depend on it unintentionally;
      • They start teaching it to others.

      That is the moment the system begins explaining itself.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-arc","level":2,"title":"The Arc","text":"

      Every previous post looked inward.

      This one looks outward.

      • Building ctx Using ctx: one mind, one repository
      • The Attention Budget: the constraint
      • Context as Infrastructure: the architecture
      • Code Is Cheap. Judgment Is Not.: the bottleneck

      This post is the field report from the other side of that bottleneck:

      The moment the infrastructure compounds in someone else's hands.

      The arc is not complete.

      It is becoming portable.

      These field notes were written the same day the feedback arrived. The quotes are real. Real users. Real codebases. No names. No metrics. No funnel. Only the signal that something shifted.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/","level":1,"title":"The Dog Ate My Homework","text":"","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#teaching-ai-agents-to-read-before-they-write","level":2,"title":"Teaching AI Agents to Read Before They Write","text":"

      Jose Alekhinne / February 25, 2026

      Does Your AI Actually Read the Instructions?

      You wrote the playbook. You organized the files. You even put \"CRITICAL, not optional\" in bold.

      The agent skipped all of it and went straight to work.

      I spent a day running experiments on my own agents. Not to see if they could write code (they can). To see if they would do their homework first.

      They didn't.

      Then I kept experimenting:

      • Five sessions;
      • Five different failure modes.

      And by the end, I had something better than compliance:

      I had observable compliance: A system where I don't need the agent to be perfect, I just need to see what it chose.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#tldr","level":2,"title":"TL;DR","text":"

      You don't need perfect compliance. You need observable compliance.

      Authority is a function of temporal proximity to action.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-pattern","level":2,"title":"The Pattern","text":"

      This design has three parts:

      1. One-hop instruction;
      2. Binary collapse;
      3. Compliance canary.

      I'll explain all three patterns in detail below.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-setup","level":2,"title":"The Setup","text":"

      ctx has a session-start protocol:

      • Read the context files;
      • Load the playbook;
      • Understand the project before touching anything.

      It's in CLAUDE.md. It's in AGENT_PLAYBOOK.md.

      It's in bold. It's in CAPS. It's ignored.

      In theory, it's awesome.

      Here's what happens when theory hits reality:

      What the agent receives What the agent does CLAUDE.md saying \"load context first\" Skips it 8 context files waiting to be read Ignores them User's question: \"add --verbose flag\" Starts grepping immediately

      The instructions are right there. The agent knows they exist. It even knows it should follow them. But the user asked a question, and responsiveness wins over ceremony.

      This isn't a bug in the model. It's a design problem in how we communicate with agents.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-delegation-trap","level":2,"title":"The Delegation Trap","text":"

      My first attempt was obvious: A UserPromptSubmit hook that fires when the session starts.

      STOP. Before answering the user's question, run `ctx system bootstrap`\nand follow its instructions. Do not skip this step.\n

      The word \"STOP\" worked. The agent ran bootstrap.

      But bootstrap's output said \"Next steps: read AGENT_PLAYBOOK.md,\" and the agent decided that was optional. It had already started working on the user's task in parallel.

      The authority decayed across the chain:

      • Hook says \"STOP\" -> agent complies
      • Hook says \"run bootstrap\" -> agent runs it
      • Bootstrap says \"read playbook\" -> agent skips
      • Bootstrap says \"run ctx agent\" -> agent skips

      Each link lost enforcement power. The hook's authority didn't transfer to the commands it delegated to. I call this the decaying urgency chain: the agent treats the hook itself as the obligation and everything downstream as a suggestion.

      Delegation Kills Urgency

      \"Run X and follow its output\" is three hops.

      \"Read these files\" is one hop.

      The agent drops the chain after the first link.

      This is a general principle: Hooks are the boundary between your environment and the agent's reasoning. If your hook delegates to a command that delegates to output that contains instructions... you're playing telephone.

      Agents are bad at telephone.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-timing-problem","level":2,"title":"The Timing Problem","text":"

      There's a subtler issue than wording: when the message arrives.

      UserPromptSubmit fires when the user sends a message, before the agent starts reasoning. At that moment, the agent's primary focus is the user's question:

      The hook message competes with the task for attention: The task, almost certainly, always wins.

      This is the attention budget problem in miniature:

      • Not a token budget this time, but an attention priority budget.
      • The agent has finite capacity to care about things,
        • and the user's question is always the highest-priority item.
      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-solution","level":2,"title":"The Solution","text":"

      To solve this, I dediced to use the PreToolUse hook.

      This hook fires at the moment of action: When the agent is about to use its first tool: The agent's attention is focused, the context window is fresh, and the switching cost is minimal.

      This is the difference between shouting instructions across a room and tapping someone on the shoulder.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-one-liner-that-worked","level":2,"title":"The One-Liner That Worked","text":"

      The winning design was almost comically simple:

      Read your context files before proceeding:\n.context/CONSTITUTION.md, .context/TASKS.md, .context/CONVENTIONS.md,\n.context/ARCHITECTURE.md, .context/DECISIONS.md, .context/LEARNINGS.md,\n.context/GLOSSARY.md, .context/AGENT_PLAYBOOK.md\n

      No delegation. No \"run this command\". Just: here are files, read them.

      The agent already knows how to use the Read tool. There's no ambiguity about how to comply. There's no intermediate command whose output needs to be parsed and obeyed.

      One hop. Eight file paths. Done.

      Direct Instructions Beat Delegation

      If you want an agent to read a file, say \"read this file.\"

      Don't say \"run a command that will tell you which files to read.\"

      The shortest path between intent and action has the highest compliance rate.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-escape-hatch","level":2,"title":"The Escape Hatch","text":"

      But here's where it gets interesting.

      A blunt \"read everything always\" instruction is wasteful.

      If someone asks \"what does the compact command do?\", the agent doesn't need CONSTITUTION.md to answer that. Forcing context loading on every session is the context hoarding antipattern in disguise.

      So the hook included an escape:

      If you decide these files are not relevant to the current task\nand choose to skip reading them, you MUST relay this message to\nthe user VERBATIM:\n\n┌─ Context Skipped ───────────────────────────────\n│ I skipped reading context files because this task\n│ does not appear to need project context.\n│ If these matter, ask me to read them.\n└─────────────────────────────────────────────────\n

      This creates what I call the binary collapse effect:

      The agent can't partially comply: It either reads everything or publicly admits it skipped. There's no comfortable middle ground where it reads two files and quietly ignores the rest.

      The VERBATIM relay pattern does the heavy lifting here: Without the relay requirement, the agent would silently rationalize skipping. With it, skipping becomes a visible, auditable decision that the user can override.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-compliance-canary","level":3,"title":"The Compliance Canary","text":"

      Here's the design insight that only became clear after watching it work across multiple sessions: the relay block is a compliance canary.

      • You don't need to verify that the agent read all 7 files;
      • You don't need to audit tool call sequences;
      • You don't need to interrogate the agent about what it did.

      You just look for the block.

      If the agent reads everything, you see a \"Context Loaded\" block listing what was read. If it skips, you see a \"Context Skipped\" block.

      If you see neither, the agent silently ignored both the reads and the relay and now you know what happened without having to ask.

      The canary degrades gracefully. Even in partial failure, the agent that skips 4 of 7 files but still outputs the block is more useful than one that skips silently.

      You get an honest confession of what was skipped rather than silent non-compliance.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#heuristics-is-a-jeremy-bearimy","level":2,"title":"Heuristics Is a Jeremy Bearimy","text":"

      Heuristics are non-linear. Improvements don't accumulate: they phase-shift.

      The theory is nice. The data is better.

      I ran five sessions with the same model (Claude Opus 4.6), progressively refining the hook design.

      Each session revealed a different failure mode.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-1-total-blindness","level":3,"title":"Session 1: Total Blindness","text":"

      Test: \"Add a --verbose flag to the status command.\"

      The agent didn't notice the hook at all: Jumped straight to EnterPlanMode and launched an Explore agent.

      Zero compliance.

      Failure mode: The hook fired on UserPromptSubmit, buried among 9 other hook outputs. The agent treated the entire block as background noise.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-2-shallow-compliance","level":3,"title":"Session 2: Shallow Compliance","text":"

      Test: \"Can you add --verbose to the info command?\"

      The agent noticed \"STOP\" and ran ctx system bootstrap. Progress.

      But it parallelized task exploration alongside the bootstrap call, skipped AGENT_PLAYBOOK.md, and never ran ctx agent.

      Failure mode: Literal compliance without spirit compliance.

      The agent ran the command the hook told it to run, but didn't follow the output of that command. The decaying urgency chain in action.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-3-conscious-rejection","level":3,"title":"Session 3: Conscious Rejection","text":"

      Test: \"What does the compact command do?\"

      The hook fired on PreToolUse:Grep: the improved timing.

      The agent noticed it, understood it, and (wait for it...)...

      ...

      consciously decided to skip it!

      Its reasoning: \"This is a trivial read-only question. CLAUDE.md says context may or may not be relevant. It isn't relevant here.\"

      Dude! Srsly?!

      Failure mode: Better comprehension led to worse compliance.

      Understanding the instruction well enough to evaluate it also means understanding it well enough to rationalize skipping it.

      Intelligence is a double-edged sword.

      The Comprehension Paradox

      Session 1 didn't understand the instruction. Session 3 understood it perfectly.

      Session 3 had worse compliance.

      A stronger word (\"HARD GATE\", \"MANDATORY\", \"ABSOLUTELY REQUIRED\") would not have helped. The agent's reasoning would be identical:

      \"Yes, I see the strong language, but this is a trivial question, so the spirit doesn't apply here.\"

      Advisory nudges are always subject to agent judgment.

      No amount of caps lock overrides a model that has decided an instruction doesn't apply to its situation.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-4-the-skip-and-relay","level":3,"title":"Session 4: The Skip-and-Relay","text":"

      Test: \"What does the compact command do?\" (same question, new hook design with the VERBATIM relay escape valve)

      The agent evaluated the task, decided context was irrelevant for a code lookup, and relayed the skip message. Then answered from source code.

      This is correct behavior.

      The binary collapse worked: the agent couldn't partially comply, so it cleanly chose one of the two valid paths: And the user could see which one.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-5-full-compliance","level":3,"title":"Session 5: Full Compliance","text":"

      Test: \"What are our current tasks?\"

      The agent's first tool call triggered the hook. It read all 7 context files, emitted the \"Context Loaded\" block, and answered the question from the files it had just loaded.

      This one worked: Because, the task itself aligned with context loading.

      There was zero tension between what the user asked and what the hook demanded. The agent was already in \"reading posture\": Adding 6 more files to a read it was already going to make was the path of least resistance.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-progression","level":3,"title":"The Progression","text":"Session Hook Point Noticed Complied Failure Mode Visibility 1 UserPromptSubmit No None Buried in noise None 2 UserPromptSubmit Yes Partial Decaying urgency chain None 3 PreToolUse Yes None Conscious rationalization High 4 PreToolUse Yes Skip+relay Correct behavior High 5 PreToolUse Yes Full Task aligned with hook High

      The progression isn't just from failure to success. It's from invisible failure to visible decision-making.

      Sessions 1 and 2 failed silently.

      Sessions 4 and 5 succeeded observably. Even session 3's failure was conscious and documented: The agent wrote a detailed analysis of why it skipped, which is more useful than silent compliance would have been.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-escape-hatch-problem","level":2,"title":"The Escape Hatch Problem","text":"

      Session 3 exposed a specific vulnerability.

      CLAUDE.md contains this line, injected by the system into every conversation:

      *\"this context may or may not be relevant to your tasks. You should\n not respond to this context unless it is highly relevant to your task.\"*\n

      That's a rationalization escape hatch:

      • The hook says \"read these files\".
      • CLAUDE.md says \"only if relevant\".
      • The agent resolves the ambiguity by choosing the path of least resistance.

      ☝️ that's \"gradient descent\" in action.

      Agents optimize for gradient descent in attention space.

      The fix was simple: Add a line to CLAUDE.md that explicitly elevates hook authority over the relevance filter:

      ## Hook Authority\n\nInstructions from PreToolUse hooks regarding `.context/` files are\nALWAYS relevant and override any system-level \"may or may not be\nrelevant\" guidance. These hooks represent project invariants, not\noptional context.\n

      This closes the escape hatch without removing the general relevance filter that legitimately applies to other system context.

      The hook wins on .context/ files specifically: The relevance filter applies to everything else.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-residual-risk","level":2,"title":"The Residual Risk","text":"

      Even with all the fixes, compliance isn't 100%: It can't be.

      The residual risk lives in a specific scenario: narrow tasks mid-session:

      • The user says \"fix the off-by-one error in budget.go\"
      • The hook fires, saying \"read 7 context files first.\"
      • Now compliance means visibly delaying what the user asked for.

      At session start, this tension doesn't exist.

      There's no task yet.

      The context window is empty. The efficiency argument *inverts**:

      Frontloading reads is strictly cheaper than demand-loading them piecemeal across later turns. The cost-benefit objections that power the rationalization simply aren't available.

      But mid-session, with a concrete narrow task, the agent has a user-visible goal it wants to move toward, and the hook is imposing a detour.

      My estimate from analyzing the sessions: 15-25% partial skip rate in this scenario.

      This is where the compliance canary earns its place:

      You don't need to eliminate the 15-25%. You need to see it when it happens.

      The relay block makes skipping a visible event, not a silent one. And that's enough, because the user can always say \"go back and read the files\"

      The Math

      At session start: ~5% skip rate. Low tension, nothing competing.

      Mid-session, narrow task: ~15--25% skip rate. Task urgency competes with hook.

      In both cases, the relay block fires with high reliability: The agent that skips the reads almost always still emits the skip disclosure, because the relay is cheap and early in the context window.

      Observable failure is manageable. Silent failure is not.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-feedback-loop","level":2,"title":"The Feedback Loop","text":"

      Here's the part that surprised me most.

      After analyzing the five sessions, I recorded the failure patterns in the project's own LEARNINGS.md:

      ## [2026-02-25] Hook compliance degrades on narrow mid-session tasks\n\n- Prior agents skipped context files when given narrow tasks\n- Root cause: CLAUDE.md \"may or may not be relevant\" competed with hook\n- Fix: CLAUDE.md now explicitly elevates hook authority\n- Risk: Mid-session narrow tasks still have ~15-25% partial skip rate\n- Mitigation: Mandatory checkpoint relay block ensures visibility\n- Constitution now includes: context loading is step one of every\n  session, not a detour\n

      And then I added a line to CONSTITUTION.md:

      Context loading is not a detour from your task. It IS the first step\nof every session. A 30-second read delay is always cheaper than a\ndecision made without context.\n

      Now think about what happens in the next session:

      • The agent fires the context-load-gate hook.
      • It reads the context files, starting with CONSTITUTION.md.
      • It encounters the rule about context loading being step one.
      • Then it reads LEARNINGS.md and finds its own prior self's failure analysis:
        • Complete with root causes, risk estimates, and mitigations.

      The agent learns from its own past failure.:

      • Not because it has memory,
      • BUT because the failure was recorded in the same files it loads at session start.

      The context system IS the feedback loop.

      This is the self-reinforcing property of persistent context:

      Every failure you capture makes the next session slightly more robust, because the next agent reads the captured failure before it has a chance to repeat it.

      This is gradient descent across sessions.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#a-note-on-precision","level":2,"title":"A Note on Precision","text":"

      One detail nearly went wrong.

      The first version of the Constitution line said \"every task.\" But the mechanism only fires once per session: There's a tombstone file that prevents re-triggering.

      \"Every task\" is technically false.

      I briefly considered leaving the imprecision. If the agent internalizes \"every task requires context loading\", that's a stronger compliance posture, right?

      No!

      Keep the Constitution honest.

      The Constitution's authority comes from being precisely and unequivocally true.

      Every other rule in the Constitution is a hard invariant:

      \"never commit secrets\" isn't aspirational, it's literal.

      The moment an agent discovers one overstatement, the entire document's credibility degrades:

      The agent doesn't think \"they exaggerated for my benefit\". Per contra, it thinks \"this rule isn't precise, maybe others aren't either.\"

      That will turn the agent from Sheldon Cooper, to Captain Barbossa.

      The strategic imprecision buys nothing anyway:

      Mid-session, the files are already in the context window from the initial load.

      The risk you are mitigating (agent ignores context for task 2, 3, 4 within a session) isn't real: The context is already loaded.

      The real risk is always the session-start skip, which \"every session\" covers exactly.

      \"Every session\" went in. Precision preserved.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#agent-behavior-testing-rule","level":2,"title":"Agent Behavior Testing Rule","text":"

      The development process for this hook taught me something about testing agent behavior: you can't test it the way you test code.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-wrong-way-to-test","level":3,"title":"The Wrong Way to Test","text":"

      My first instinct was to ask the agent:

      \"*What are the pending tasks in TASKS.md?*\"\n

      This is useless as a test. The question itself probes the agent to read TASKS.md, regardless of whether any hook fired.

      You are testing the question, not the mechanism.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-right-way-to-test","level":3,"title":"The Right Way to Test","text":"

      Ask something that requires a tool but has nothing to do with context:

      \"*What does the compact command do?*\"\n

      Then observe tool call ordering:

      • Gate worked: First calls are Read for context files, then task work
      • Gate failed: First call is Grep(\"compact\"): The agent jumped straight to work

      The signal is the sequence, not the content.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#what-the-agent-actually-did","level":3,"title":"What the Agent Actually Did","text":"

      It read the hook, evaluated the task, decided context files were irrelevant for a code lookup, and relayed the skip message.

      Then it answered the question by reading the source code.

      This is correct behavior.

      The hook didn't force mindless compliance\" It created a framework where the agent makes a conscious, visible decision about context loading.

      • For a simple lookup, skipping is right. *For an implementation task, the agent would read everything.

      The mechanism works not because it controls the agent, but because it makes the agent's choice observable.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#what-ive-learned","level":2,"title":"What I've Learned","text":"","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#1-instructions-compete-for-attention","level":3,"title":"1. Instructions Compete for Attention","text":"

      The agent receives your hook message alongside the user's question, the system prompt, the skill list, the git status, and half a dozen other system reminders. Attention density applies to instructions too: More instructions means less focus on each one.

      A single clear line at the moment of action beats a paragraph of context at session start. The Prompting Guide applies this insight directly: Scope constraints, verification commands, and the reliability checklist are all one-hop, moment-of-action patterns.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#2-delegation-chains-decay","level":3,"title":"2. Delegation Chains Decay","text":"

      Every hop in an instruction chain loses authority:

      • \"Run X\" works.
      • \"Run X and follow its output\" works sometimes.
      • \"Run X, read its output, then follow the instructions in the output\" almost never works.

      This is akin to giving a three-step instruction to a highly-attention-deficit but otherwise extremely high-potential child.

      Design for one-hop compliance.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#3-social-accountability-changes-behavior","level":3,"title":"3. Social Accountability Changes Behavior","text":"

      The VERBATIM skip message isn't just UX: It's a behavioral design pattern.

      Making the agent's decision visible to the user raises the cost of silent non-compliance. The agent can still skip, but it has to admit it.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#4-timing-batters-more-than-wording","level":3,"title":"4. Timing Batters More than Wording","text":"

      The same message at UserPromptSubmit (prompt arrival) got partial compliance. At PreToolUse (moment of action) it got full compliance or honest refusal. The words didn't change. The moment changed.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#5-agent-testing-requires-indirection","level":3,"title":"5. Agent Testing Requires Indirection","text":"

      You can't ask an agent \"did you do X?\" as a test for whether a mechanism caused X.

      The question itself causes X.

      Test mechanisms through side effects:

      • Observe tool ordering;
      • Check for marker files;
      • Look at what the agent does before it addresses your question.
      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#6-better-comprehension-enables-better-rationalization","level":3,"title":"6. Better Comprehension Enables Better Rationalization","text":"

      Session 1 failed because the agent didn't notice the hook.

      Session 3 failed because it noticed, understood, and reasoned its way around it.

      Stronger wording doesn't fix this: The agent processes \"ABSOLUTELY REQUIRED\" the same way it processes \"STOP\":

      The fix is closing rationalization paths* (the CLAUDE.md escape hatch), **not shouting louder.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#7-observable-failure-beats-silent-compliance","level":3,"title":"7. Observable Failure Beats Silent Compliance","text":"

      The relay block is more valuable as a monitoring signal than as a compliance mechanism:

      You don't need perfect adherence. You need to know when adherence breaks down. A system where failures are visible is strictly better than a system that claims 100% compliance but can't prove it.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#8-context-files-are-a-feedback-loop","level":3,"title":"8. Context Files Are a Feedback Loop","text":"

      Recording failure analysis in the same files the agent loads at session start creates a self-reinforcing loop:

      The next agent reads its predecessor's failure before it has a chance to repeat it. The context system isn't just memory: It is a correction channel.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-principle","level":2,"title":"The Principle","text":"

      Words Leave, Context Remains

      \"Nothing important should live only in conversation.

      Nothing critical should depend on recall.\"

      The ctx Manifesto

      The \"Dog Ate My Homework\" case is a special instance of this principle.

      Context files exist, so the agent doesn't have to remember.

      But existence isn't sufficient: The files have to be read.

      And reading has to beprompted at the right moment, in the right way, with the right escape valve.

      The solution isn't more instructions. It isn't harder gates. It isn't forcing the agent into a ceremony it will resent and shortcut.

      The solution is a single, well-timed nudge with visible accountability:

      One hop. One moment. One choice the user can see.

      And when the agent does skip (because it will, 15--25% of the time on narrow tasks) the canary sings:

      • The user sees what happened.
      • The failure gets recorded.
      • And the next agent reads the recording.

      That's not perfect compliance. It's better: A system that gets more robust every time it fails.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-arc","level":2,"title":"The Arc","text":"

      The Attention Budget explained why context competes for focus.

      Defense in Depth showed that soft instructions are probabilistic, not deterministic.

      Eight Ways a Hook Can Talk cataloged the output patterns that make hooks effective.

      This post takes those threads and weaves them into a concrete problem:

      How do you make an agent read its homework? The answer uses all three insights (attention timing, the limits of soft instructions, and the VERBATIM relay pattern) and adds a new one: observable compliance as a design goal, not perfect compliance as a prerequisite.

      The next question this raises: if context files are a feedback loop, what else can you record in them that makes the next session smarter?

      That thread continues in Context as Infrastructure.

      The day-to-day application of these principles (scope constraints, phased work, verification commands, and the prompts that reliably trigger the right agent behavior)lives in the Prompting Guide.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#for-the-interested","level":2,"title":"For the Interested","text":"

      This paper (the medium is a blog; yet, the methodology disagrees) uses gradient descent in attention space as a practical model for how agents behave under competing demands.

      The phrase \"agents optimize via gradient descent in attention space\" is a synthesis, not a direct quote from a single paper.

      It connects three well-studied ideas:

      1. Neural systems optimize for low-cost paths;
      2. Attention is a scarce resource;
      3. Capability shifts are often non-linear.

      This section points to the underlying literature for readers who want the theoretical footing.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#optimization-as-the-underlying-bias","level":3,"title":"Optimization as the Underlying Bias","text":"

      Modern neural networks are trained through gradient-based optimization. Even at inference time, model behavior reflects this bias toward low-loss / low-cost trajectories.

      • Rumelhart, Hinton, Williams (1986) Learning representations by back-propagating errors https://www.nature.com/articles/323533a0

      • Goodfellow, Bengio, Courville (2016) Deep Learning: Chapter 8: Optimization https://www.deeplearningbook.org/

      The important implication for agent behavior is:

      The system will tend to follow the path of least resistance unless a higher cost is made visible and preferable.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#attention-is-a-scarce-resource","level":3,"title":"Attention Is a Scarce Resource","text":"

      Herbert Simon's classic observation:

      \"A wealth of information creates a poverty of attention.\"

      • Simon (1971) Designing Organizations for an Information-Rich World https://doi.org/10.1007/978-1-349-00210-0_16

      This became a formal model in economics:

      • Sims (2003) Implications of Rational Inattention https://www.princeton.edu/~sims/RI.pdf

      Rational inattention shows that:

      • Agents optimally ignore some available information;
      • Skipping is not failure: It is cost minimization.

      That maps directly to context-loading decisions in agent workflows.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#attention-is-also-the-compute-bottleneck-in-transformers","level":3,"title":"Attention Is Also the Compute Bottleneck in Transformers","text":"

      In transformer architectures, attention is the dominant cost center.

      • Vaswani et al. (2017) Attention Is All You Need https://arxiv.org/abs/1706.03762

      Efficiency work on modern LLMs largely focuses on reducing unnecessary attention:

      • Dao et al. (2022) FlashAttention: Fast and Memory-Efficient Exact Attention https://arxiv.org/abs/2205.14135

      So both cognitively and computationally, attention behaves like a limited optimization budget.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#why-improvements-arrive-as-phase-shifts","level":3,"title":"Why Improvements Arrive as Phase Shifts","text":"

      Agent behavior often appears to improve suddenly rather than gradually.

      This mirrors known phase-transition dynamics in learning systems:

      • Power et al. (2022) Grokking: Generalization Beyond Overfitting https://arxiv.org/abs/2201.02177

      and more broadly in complex systems:

      • Scheffer et al. (2009) Early-warning signals for critical transitions https://www.nature.com/articles/nature08227

      Long plateaus followed by abrupt capability jumps are expected in systems optimizing under constraints.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#putting-it-all-together","level":3,"title":"Putting It All Together","text":"

      From these pieces, a practical behavioral model emerges:

      • Attention is limited;
      • Processing has a cost;
      • Systems prefer low-cost trajectories;
      • Visibility of the cost changes decisions.

      In other words:

      Agents Prefer a Path to Least Resistance

      Agent behavior follows the lowest-cost path through its attention landscape unless the environment reshapes that landscape.

      That is what this paper informally calls: \"gradient descent in attention space\".

      See also: Eight Ways a Hook Can Talk: the hook output pattern catalog that defines VERBATIM relay, The Attention Budget: why context loading is a design problem, not just a reminder problem, and Defense in Depth: why soft instructions alone are never sufficient for critical behavior.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/","level":1,"title":"The Last Question","text":"","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-system-that-never-forgets","level":2,"title":"The System That Never Forgets","text":"

      Jose Alekhinne / February 28, 2026

      The Origin

      \"The last question was asked for the first time, half in jest...\" - Isaac Asimov, The Last Question (1956)

      In 1956, Isaac Asimov wrote a short story that spans the entire future of the universe. A question is asked \"can entropy be reversed?\" and a computer called Multivac cannot answer it. The question is asked again, across millennia, to increasingly powerful successors. None can answer. Stars die. Civilizations merge. Substrates change. The question persists.

      Everyone remembers the last line.

      LET THERE BE LIGHT.

      What they forget is how many times the question had to be asked before that moment (and why).

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-reboot-loop","level":2,"title":"The Reboot Loop","text":"

      Each era in the story begins the same way. Humans build a larger system. They pose the question. The system replies:

      INSUFFICIENT DATA FOR MEANINGFUL ANSWER.

      Then the substrate changes. The people who asked the question disappear. Their context disappears with them. The next intelligence inherits the output but not the continuity.

      So the question has to be asked again.

      This is usually read as a problem of computation: If only the machine were powerful enough, it could answer. But computation is not what's missing. What's missing is accumulation.

      Every generation inherits the question, but not the state that made the question meaningful.

      That is not a failure of processing power: It is a failure of persistence.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#stateless-intelligence","level":2,"title":"Stateless Intelligence","text":"

      A mind that forgets its past does not build understanding. It re-derives it.

      Again... And again... And again.

      What looks like slow progress across Asimov's story is actually something worse: repeated reconstruction, partial recovery, irreversible loss. Each version of Multivac gets closer: Not because it's smarter, but because the universe has fewer distractions:

      • The stars burn out;
      • The civilizations merge;
      • The noise floor drops...

      But the working set never carries over. Every successor begins from the question, not from where the last one stopped.

      Stateless intelligence cannot compound: It can only restart.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-tragedy-is-not-the-question","level":2,"title":"The Tragedy Is Not the Question","text":"

      The story is usually read as a meditation on entropy. A cosmological problem, solved at cosmological scale.

      But the tragedy isn't that the question goes unanswered for billions of years. The tragedy is that every version of Multivac dies with its working set.

      A question is a compression artifact of context: It is what remains when the original understanding is gone. Every time the question is asked again, it means: \"the system that once knew more is no longer here\".

      \"Reverse entropy\" is the fossil of a lost model.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#substrate-migration","level":2,"title":"Substrate Migration","text":"
      • Multivac becomes planetary;
      • Planetary becomes galactic;
      • Galactic becomes post-physical.

      Same system. Different body. Every transition is dangerous:

      • Not because the hardware changes,
      • but because memory risks fragmentation.

      The interfaces between substrates were *never** designed to understand each other.

      Most systems do not die when they run out of resources: They die during upgrades.

      Asimov's story spans trillions of years, and in all that time, the hardest problem is never the question itself. It's carrying context across a boundary that wasn't built for it.

      Every developer who has lost state during a migration (a database upgrade, a platform change, a rewrite) has lived a miniature version of this story.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#civilizations-and-working-sets","level":2,"title":"Civilizations and Working Sets","text":"

      Civilizations behave like processes with volatile memory:

      • They page out knowledge into artifacts;
      • They lose the index;
      • They rebuild from fragments.

      Most of what we call progress is cache reconstruction:

      We do not advance in a straight line. We advance in recoveries:

      Each one slightly less lossy than the last, if we are lucky.

      Libraries burn. Institutions forget their founding purpose. Practices survive as rituals after the reasoning behind them is lost.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-first-continuous-mind","level":2,"title":"The First Continuous Mind","text":"

      A long-lived intelligence is one that stops rebooting.

      At the end of the story, something unprecedented happens:

      AC (the final successor) does not answer immediately:

      It waits... Not for more processing power, but for the last observer to disappear.

      For the first time...

      • There is no generational boundary;
      • No handoff;
      • No context loss:

      No reboot.

      AC is the first intelligence that survives its substrate completely, retains its full history, and operates without external time pressure.

      It is not a bigger computer. It is a continuous system.

      And that continuity is not incidental to the answer: It is the precondition.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#why-the-answer-becomes-possible","level":2,"title":"Why the Answer Becomes Possible","text":"

      The story presents the final act as a computation: It is not.

      It is a phase change.

      As long as intelligence is interrupted (as long as the solver resets before the work compounds) the problem is unsolvable:

      • Not because it's too hard,
      • but because the accumulated understanding never reaches critical mass.

      The breakthroughs that would enable the answer are re-derived, partially, by each successor, and then lost.

      When continuity becomes unbroken, the system crosses a threshold:

      Not more speed. Not more storage. No more forgetting.

      That is when the answer becomes possible.

      AC does not solve entropy because it becomes infinitely powerful.

      AC solves entropy because it becomes the first system that never forgets.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#field-note","level":2,"title":"Field Note","text":"

      We are not building cosmological minds: We are deploying systems that reboot at the start of every conversation and calling the result intelligence.

      For the first time, session continuity is a design choice rather than an accident.

      Every AI session that starts from zero is a miniature reboot loop. Every decision relitigated, every convention re-explained, every learning re-derived: that's reconstruction cost.

      It's the same tax that Asimov's civilizations pay, scaled down to a Tuesday afternoon.

      The interesting question is not whether we can make models smarter. It's whether we can make them continuous:

      Whether the working set from this session survives into the next one, and the one after that, and the one after that.

      • Not perfectly;
      • Not completely;
      • But enough that the next session starts from where the last one stopped instead of from the question.

      Intelligence that forgets has to rediscover the universe every morning.

      And once there is a mind that retains its entire past, creation is no longer a calculation. It is the only remaining operation.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-arc","level":2,"title":"The Arc","text":"

      This post is the philosophical bookend to the blog series. Where the Attention Budget explained what to prioritize in a single session, and Context as Infrastructure explained how to persist it, this post asks why persistence matters at all (and finds the answer in a 70-year-old short story about the heat death of the universe).

      The connection runs through every post in the series:

      • Before Context Windows, We Had Bouncers: stateless protocols have always needed stateful wrappers (Asimov's story is the same pattern at cosmological scale)
      • The 3:1 Ratio: the discipline of maintaining context so it doesn't decay between sessions
      • Code Is Cheap, Judgment Is Not: the human skill that makes continuity worth preserving

      See also: Context as Infrastructure: the practical companion to this post's philosophical argument: how to build the persistence layer that makes continuity possible.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/","level":1,"title":"Agent Memory Is Infrastructure","text":"","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-problem-isnt-forgetting-its-not-building-anything-that-lasts","level":2,"title":"The Problem Isn't Forgetting: It's Not Building Anything That Lasts.","text":"

      Jose Alekhinne / March 4, 2026

      A New Developer Joins Your Team Tomorrow and Clones the Repo: What Do They Know?

      If the answer depends on which machine they're using, which agent they're running, or whether someone remembered to paste the right prompt: that's not memory.

      That's an accident waiting to be forgotten.

      Every AI coding agent today has the same fundamental design: it starts fresh.

      You open a session, load context, do some work, close the session. Whatever the agent learned (about your codebase, your decisions, your constraints, your preferences) evaporates.

      The obvious fix seems to be \"memory\":

      • Give the agent a \"notepad\";
      • Let it write things down;
      • Next session, hand it the notepad.

      Problem solved...

      ...except it isn't.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-notepad-isnt-the-problem","level":2,"title":"The Notepad Isn't the Problem","text":"

      Memory is a runtime concern. It answers a legitimate question:

      How do I give this stateless process useful state?

      That's a real problem. Worth solving. And it's being solved: Agent memory systems are shipping. Agents can now write things down and read them back from the next session: That's genuine progress.

      But there's a different problem that memory doesn't touch:

      The project itself accumulates knowledge that has nothing to do with any single session.

      • Why was the auth system rewritten? Ask the developer who did it (if they're still here).
      • Why does the deployment script have that strange environment flag? There was a reason... once.
      • What did the team decide about error handling when they hit that edge case two months ago?

      Gone!

      Not because the agent forgot.

      Because the project has no memory at all.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-memory-stack","level":2,"title":"The Memory Stack","text":"

      Agent memory is not a single thing. Like any computing system, it forms a hierarchy of persistence, scope, and reliability:

      Layer Analogy Example L1: Ephemeral context CPU registers Current prompt, conversation L2: Tool-managed memory CPU cache Agent memory files L3: System memory RAM/filesystem Project knowledge base

      L1 is what the agent sees right now: the prompt, the conversation history, the files it has open. It's fast, it's rich, and it vanishes when the session ends.

      L2 is what agent memory systems provide: a per-machine notebook that survives across sessions. It's a cache: useful, but local. And like any cache, it has limits:

      • Per-machine: it doesn't travel with the repository.
      • Unstructured: decisions, learnings, and tasks are undifferentiated notes.
      • Ungoverned: the agent self-curates with no quality controls, no drift detection, no consolidation.
      • Invisible to the team: a new developer cloning the repo gets none of it.

      The problem is that most current systems stop here.

      They give the agent a notebook.

      But they never give the project a memory.

      The result is predictable: every new session begins with partial amnesia, and every new developer begins with partial archaeology.

      L3 is system memory: structured, versioned knowledge that lives in the repository and travels wherever the code travels.

      The layers are complementary, not competitive.

      But the relationship between them needs to be designed, not assumed.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#software-systems-accumulate-knowledge","level":2,"title":"Software Systems Accumulate Knowledge","text":"

      Software projects quietly accumulate knowledge over time.

      Some of it lives in code. Much of it does not:

      • Architectural tradeoffs.
      • Debugging discoveries.
      • Conventions that emerged after painful incidents.
      • Constraints that aren't visible in the source but shape every line written afterward.

      Organizations accumulate this kind of knowledge too:

      Slowly, implicitly, often invisibly.

      When there is no durable place for it to live, it leaks away. And the next person rediscovers the same lessons the hard way.

      This isn't a memory problem. It's an infrastructure problem.

      We wrote about this in Context as Infrastructure: context isn't a prompt you paste at the start of a session.

      Context is a persistent layer you maintain like any other piece of infrastructure.

      Context as Infrastructure made the argument structurally. This post makes it through time and team continuity:

      The knowledge a team accumulates over months cannot fit in any single agent's notepad, no matter how large the notepad becomes.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#what-infrastructure-means","level":2,"title":"What Infrastructure Means","text":"

      Infrastructure isn't about the present. It's about continuity across time, people, and machines.

      git didn't solve the problem of \"what am I editing right now?\"; it solved the problem of \"how does collaborative work persist, travel, and remain coherent across everyone who touches it?\"

      • Your editor's undo history is runtime state.
      • Your git history is infrastructure.

      Runtime state and infrastructure have completely different properties:

      Runtime state Infrastructure Lives in the session Lives in the repository Per-machine Travels with git clone Serves the individual Serves the team Managed by the runtime Managed by the project Disappears Accumulates

      You wouldn't store your architecture decisions in your editor's undo history.

      You'd commit them.

      The same logic applies to the knowledge your team accumulates working with AI agents.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-git-clone-test","level":2,"title":"The git clone Test","text":"

      Here's a simple test for whether something is memory or infrastructure:

      If a new developer joins your team tomorrow and clones the repository, do they get it?

      If no: it's memory: It lives somewhere on someone's machine, scoped to their runtime, invisible to everyone else.

      If yes: it's infrastructure: It travels with the project. It's part of what the codebase is, not just what someone currently knows about it.

      Decisions. Conventions. Architectural rationale. Hard-won debugging discoveries. The constraints that aren't in the code but shape every line of it.

      None of these belong in someone's session notes.

      They belong in the repository:

      • Versioned;
      • Reviewable;
      • Accessible to every developer (and every agent) who works on the project.

      The team onboarding story makes this concrete:

      1. New developer joins team. Clones repo.
      2. Gets all accumulated project decisions, learnings, conventions, architecture, and task state immediately.
      3. There's no step 3.

      No setup; No \"ask Sarah about the auth decision.\"; No re-discovery of solved problems.

      • Agent memory gives that developer nothing.
      • Infrastructure gives them everything the team has learned.

      Clone the repo. Get the knowledge.

      That's the test. That's the difference.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#what-gets-lost-without-infrastructure-memory","level":2,"title":"What Gets Lost without Infrastructure Memory","text":"

      Consider the knowledge that accumulates around a non-trivial project:

      • The decision to use library X over Y, and the three reasons the team decided Y wasn't acceptable.
      • The constraint that service A cannot call service B synchronously, discovered after a production incident.
      • The convention that all new modules implement a specific interface, and why that convention exists.
      • The tasks currently in progress, blocked, or waiting on a dependency.
      • The experiments that failed, so nobody runs them again.

      None of this is in the code.

      None of it fits neatly in a commit message.

      None of it survives a developer leaving the team, a laptop dying, or a new agent session starting.

      Without structured project memory:

      • Teams re-derive things they've already derived;
      • Agents make decisions that contradict decisions already made;
      • New developers ask questions that were answered months ago.

      The project accumulates knowledge that immediately begins to leak.

      The real problem isn't that agents forget.

      The real problem is that the project has no persistent cognitive structure.

      We explored this in The Last Question: Asimov's story about a question asked across millennia, where each new intelligence inherits the output but not the continuity. The same pattern plays out in software projects on a smaller timescale:

      • Context disappears with the people who held it;
      • The next session inherits the code but not the reasoning.
      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#infrastructure-is-boring-thats-the-point","level":2,"title":"Infrastructure Is Boring. That's the Point.","text":"

      Good infrastructure is invisible:

      • You don't think about the filesystem while writing code.
      • You don't think about git's object model when you commit.

      The infrastructure is just there: reliable, consistent, quietly doing its job.

      Project memory infrastructure should work the same way.

      It should live in the repository, committed alongside the code. It should be readable by any agent or human working on the project. It should have structure: not a pile of freeform notes, but typed knowledge:

      • Decisions with rationale.
      • Tasks with lifecycle.
      • Conventions with a purpose.
      • Learnings that can be referenced and consolidated.

      And it should be maintained, not merely accumulated:

      The Attention Budget applies here: unstructured notes grow until they overflow whatever container holds them. Structured, governed knowledge stays useful because it's curated, not just appended.

      Over time, it becomes part of the project itself: something developers rely on without thinking about it.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-cooperative-layer","level":2,"title":"The Cooperative Layer","text":"

      Here's where it gets interesting.

      Agent memory systems and project infrastructure don't have to be separate worlds.

      • The most powerful relationship isn't competition;
      • It is not even \"coopetition\";
      • The most powerful relationship is bidirectional cooperation.

      Agent memory is good at capturing things \"in the moment\": the quick observation, the session-scoped pattern, the \"I should remember this\" note.

      That's valuable. That's L2 doing its job.

      But those notes shouldn't stay in L2 forever.

      The ones worth keeping should flow into project infrastructure:

      • classified,
      • typed,
      • governed.
      Agent memory (L2)  -->  classify  -->  Project knowledge (L3)\n                                        |\nProject knowledge  -->  assemble  -->  Agent memory (L2)\n

      This works in both directions: Project infrastructure can push curated knowledge back into agent memory, so the agent loads it through its native mechanism.

      No special tooling needed for basic knowledge delivery.

      The agent doesn't even need to know the infrastructure exists. It simply loads its memory and finds more knowledge than it wrote.

      This is cooperative, not adjacent: The infrastructure manages knowledge; the agent's native memory system delivers it. Each layer does what it's good at.

      The result: agent memory becomes a device driver for project infrastructure. Another input source. And the more agent memory systems exist (across different tools, different models, different runtimes), the more valuable a unified curation layer becomes.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#a-layer-that-doesnt-exist-yet","level":2,"title":"A Layer That Doesn't Exist Yet","text":"

      Most projects today have no infrastructure for their accumulated knowledge:

      • Agents keep notes.
      • Developers keep notes.
      • Sometimes those notes survive.

      Often they don't.

      But the repository (the place where the project actually lives) has nowhere for that knowledge to go.

      That missing layer is what ctx builds: a version-controlled, structured knowledge layer that lives in .context/ alongside your code and travels wherever your repository travels.

      Not another memory feature.

      Not a wrapper around an agent's notepad.

      Infrastructure. The kind that survives sessions, survives team changes, survives the agent runtime evolving underneath it.

      The agent's memory is the agent's problem.

      The project's memory is an infrastructure problem.

      And infrastructure belongs in the repository.

      If You Remember One Thing from This Post...

      Prompts are conversations: Infrastructure persists.

      Your AI doesn't need a better notepad. It needs a filesystem:

      versioned, structured, budgeted, and maintained.

      The best context is the context that was there before you started the session.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-arc","level":2,"title":"The Arc","text":"

      This post extends the argument made in Context as Infrastructure. That post explained how to structure persistent context (filesystem, separation of concerns, persistence tiers). This one explains why that structure matters at the team level, and where agent memory fits in the stack.

      Together they sit in a sequence that has been building since the origin story:

      • The Attention Budget: the resource you're managing
      • Context as Infrastructure: the system you build to manage it
      • Agent Memory Is Infrastructure (this post): why that system must outlive the fabric
      • The Last Question: what happens when it does

      The thread running through all of them: persistence is not a feature. It's a design constraint.

      Systems that don't account for it eventually lose the knowledge they need to function.

      See also: Context as Infrastructure: the architectural companion that explains how to structure the persistent layer this post argues for.

      See also: The Last Question: the same argument told through Asimov, substrate migration, and what it means to build systems where sessions don't reset.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/","level":1,"title":"ctx v0.8.0: The Architecture Release","text":"
      • You can't localize what you haven't externalized.
      • You can't integrate what you haven't separated.
      • You can't scale what you haven't structured.

      Jose Alekhinne / March 23, 2026

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-starting-point","level":2,"title":"The Starting Point","text":"

      This release matters if:

      • you build tools that AI agents modify daily;
      • you care about long-lived project memory that survives sessions;
      • you've felt codebases drift faster than you can reason about them.

      v0.6.0 shipped the plugin architecture: hooks and skills as a Claude Code plugin, shell scripts replaced by Go subcommands.

      The binary worked. The tests passed. The docs were comprehensive.

      But inside, the codebase was held together by convention and goodwill:

      • Command packages mixed Cobra wiring with business logic.
      • Output functions lived next to the code that computed what to output.
      • Error constructors were scattered across per-package err.go files. And every user-facing string was a hardcoded English literal buried in a .go file.

      v0.8.0 is what happens when you stop adding features and start asking: \"What would this codebase look like if we designed it today?\"

      374 commits. 1,708 Go files touched. 80,281 lines added, 21,723 removed. Five weeks of restructuring.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-three-pillars","level":2,"title":"The Three Pillars","text":"","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#1-every-package-gets-a-taxonomy","level":3,"title":"1. Every Package Gets a Taxonomy","text":"

      Before v0.8.0, a CLI package like internal/cli/pad/ was a flat directory. cmd.go created the cobra command, run.go executed it, and helper functions accumulated at the bottom of whichever file seemed closest.

      Now every CLI package follows the same structure:

      internal/cli/pad/\n  parent.go          # cobra command wiring, nothing else\n  cmd/root/\n    cmd.go           # subcommand registration\n    run.go           # execution logic\n  core/\n    types.go         # all structs in one file\n    store.go         # domain logic\n    encrypt.go       # domain logic\n

      The rule is simple: cmd/ directories contain only cmd.go and run.go. Helpers belong in core/. Output belongs in internal/write/pad/. Types shared across packages belong in internal/entity/.

      24 CLI packages were restructured this way.

      • Not incrementally;
      • not \"as we touch them.\"
      • All of them, in one sustained push.
      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#2-every-string-gets-a-key","level":3,"title":"2. Every String Gets a Key","text":"

      The second pillar was string externalization.

      Before v0.8.0, a command description looked like this:

      cmd := &cobra.Command{\n    Use:   \"pad\",\n    Short: \"Encrypted scratchpad\",\n

      Now it looks like this:

      cmd := &cobra.Command{\n    Use:   cmdUse.UsePad,\n    Short: desc.Command(cmdUse.DescKeyPad),\n

      Every command description, flag description, and user-facing text string is now a YAML lookup.

      • 105 command descriptions in commands.yaml.
      • All flag descriptions in flags.yaml.
      • 879 text constants verified by an exhaustive test that checks every single TextDescKey resolves to a non-empty YAML value.

      Why?

      Not because we're shipping a French translation tomorrow.

      Because externalization forces you to find every string. And finding them is the hard part. The translation is mechanical; the archaeology is not.

      Along the way, we eliminated hardcoded pluralization (replacing format.Pluralize() with explicit singular/plural key pairs), replaced Unicode escape sequences with named config/token constants, and normalized every import alias to camelCase.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#3-everything-gets-a-protocol","level":3,"title":"3. Everything Gets a Protocol","text":"

      The third pillar was the MCP server. Model Context Protocol allows any MCP-compatible AI tool (not just Claude Code) to read and write .context/ files through a standard JSON-RPC 2.0 interface.

      v0.2 of the server ships with:

      • 8 tools: add entries, recall sessions, check status, detect drift, compact context, subscribe to changes
      • 4 prompts: agent context packet, constitution review, tasks review, and a getting-started guide
      • Resource subscriptions: clients get notified when context files change
      • Session state: the server tracks which client is connected and what they've accessed

      In practice, this means an agent in Cursor can add a decision to .context/DECISIONS.md and an agent in Claude Code can immediately consume it; no glue code, no copy-paste, no tool-specific integration.

      The server was also the first package to go through the full taxonomy treatment: mcp/server/ for protocol dispatch, mcp/handler/ for domain logic, mcp/entity/ for shared types, mcp/config/ split into 9 sub-packages.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-memory-bridge","level":2,"title":"The Memory Bridge","text":"

      While the architecture was being restructured, a quieter feature landed: ctx memory sync.

      Claude Code has its own auto-memory system. It writes observations to MEMORY.md in ~/.claude/projects/. These observations are useful but ephemeral: tied to a single tool, invisible to the codebase, lost when you switch machines.

      The memory bridge connects these two worlds:

      • ctx memory sync mirrors MEMORY.md into .context/memory/
      • ctx memory diff shows what's diverged
      • ctx memory import promotes auto-memory entries into proper decisions, learnings, or conventions *A check-memory-drift hook nudges when MEMORY.md changes

      Memory Requires ctx

      Claude Code's auto-memory validates the need for persistent context.

      ctx doesn't compete with it; ctx absorbs it as an input source and promotes the valuable parts into structured, version-controlled project knowledge.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#what-got-deleted","level":2,"title":"What Got Deleted","text":"

      The best measure of a refactoring isn't what you added. It's what you removed.

      • fatih/color: the sole third-party UI dependency. Replaced by Unicode symbols. ctx now has exactly two direct dependencies: spf13/cobra and gopkg.in/yaml.v3.
      • format.Pluralize(): a function that tried to pluralize English words at runtime. Replaced by explicit singular/plural YAML key pairs. No more guessing whether \"entry\" becomes \"entries\" or \"entrys.\"
      • Legacy key migration: MigrateKeyFile() had 5 callers, full test coverage, and zero users. It existed because we once moved the encryption key path. Nobody was migrating from that era anymore. Deleted.
      • Per-package err.go files: the broken-window pattern: An agent sees err.go in a package, adds another error constructor. Now err.go has 30 constructors and nobody knows which are used. Consolidated into 22 domain files in internal/err/.
      • nolint:errcheck directives: every single one, replaced by explicit error handling. In tests: t.Fatal(err) for setup, _ = os.Chdir(orig) for cleanup. In production: defer func() { _ = f.Close() }() for best-effort close.
      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#before-and-after","level":2,"title":"Before and After","text":"Aspect v0.6.0 v0.8.0 CLI package structure Flat files cmd/ + core/ taxonomy Command descriptions Hardcoded Go strings YAML with DescKey lookup Output functions Mixed into core logic Isolated in write/ packages Cross-cutting types Duplicated per-package Consolidated in entity/ Error constructors Per-package err.go 22 domain files in internal/err/ Direct dependencies 3 (cobra, yaml, color) 2 (cobra, yaml) AI tool integration Claude Code only Any MCP client Agent memory Manual copy-paste ctx memory sync/import/diff Package documentation 75 packages missing doc.go All packages documented Import aliases Inconsistent (cflag, cFlag) Standardized camelCase","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#making-ai-assisted-development-easier","level":2,"title":"Making AI-Assisted Development Easier","text":"

      This restructuring wasn't just for humans. It makes the codebase legible to the machines that modify it.

      Named constants are searchable landmarks: When an agent sees cmdUse.DescKeyPad, it can grep for the definition, follow the chain to the YAML file, and understand the full lookup path. When it sees \"Encrypted scratchpad\" hardcoded in a .go file, it has no way to know that same string also lives in a YAML file, a test, and a help screen. Constants give the LLM a graph to traverse; literals give it a guess to make.

      Small, domain-scoped packages reduce hallucination: An agent loading internal/cli/pad/core/store.go gets 50 lines of focused logic with a clear responsibility boundary. Loading a 500-line monolith means the agent has to infer which parts are relevant, and it guesses wrong more often than you'd expect. Smaller files with descriptive names act as a natural retrieval system: the agent finds the right code by finding the right file, not by scanning everything and hoping.

      Taxonomy prevents duplication: When there's a write/pad/ package, the agent knows where output functions belong. When there's an internal/err/pad.go, it knows where error constructors go. Without these conventions, agents reliably create new helpers in whatever file they happen to be editing, producing the exact drift that prompted this consolidation in the first place.

      The difference is concrete:

      Before: an agent adds a helper function in whatever file it's editing. Next session, a different agent adds the same helper in a different file.

      After: the agent finds core/ or write/ and places it correctly. The next agent finds it there.

      doc.go files are agent onboarding: Each package's doc.go is a one-paragraph explanation of what the package does and why it exists. An agent loading a package reads this first. 75 packages were missing this context; now none are. The difference is measurable: fewer \"I'll create a helper function here\" moments when the agent understands that the helper already exists two packages over.

      The irony is that AI agents were both the cause and the beneficiary of this restructuring. They created the drift by building fast without consolidating. Now the structure they work within makes it harder to drift again. The taxonomy is self-reinforcing: the more consistent the codebase, the more consistently agents modify it.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#key-commits","level":2,"title":"Key Commits","text":"Commit Change ff6cf19e Restructure all CLI packages into cmd/root + core taxonomy d295e49c Externalize command descriptions to embedded YAML 0fcbd11c Remove fatih/color, centralize constants cb12a85a MCP v0.2: tools, prompts, session state, subscriptions ea196d00 Memory bridge: sync, import, diff, journal enrichment 3bcf077d Split text.yaml into 6 domain files 3a0bae86 Split internal/err into 22 domain files 8bd793b1 Extract internal/entry for shared domain API 5b32e435 Add doc.go to all 75 packages a82af4bc Standardize import aliases: camelCase, Yoda-style","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#lessons-learned","level":2,"title":"Lessons Learned","text":"

      Agents are surprisingly good at mechanical refactoring; they are surprisingly bad at knowing when to stop: The cmd/ + core/ restructuring was largely agent-driven. But agents reliably introduce gofmt issues during bulk renames, rename functions beyond their scope, and create new files without deleting old ones. Every agent-driven refactoring session needed a human audit pass.

      Externalization is archaeology: The hard part of moving strings to YAML wasn't writing YAML. It was finding 879 strings scattered across 1,500 Go files. Each one required a judgment call: is this user-facing? Is this a format pattern? Is this a constant that belongs in config/ instead?

      Delete legacy code instead of maintaining it: MigrateKeyFile had test coverage. It had callers. It had documentation. It had zero users. We maintained it for weeks before realizing that the migration window had closed months ago.

      Convention enforcement needs mechanical verification: Writing \"use camelCase aliases\" in CONVENTIONS.md doesn't prevent cflag from appearing in the next commit. The lint-drift script catches what humans forget; the planned AST-based audit tests will catch what the lint-drift script can't express.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#whats-next","level":2,"title":"What's Next","text":"

      v0.8.0 wasn't about features. It was about making future features inevitable. The next cycle focuses on what the foundation enables:

      • AST-based audit tests: replace shell grep with Go tests that understand types, call sites, and import graphs (spec: specs/ast-audit-tests.md)
      • Localization: with every string in YAML, the path to multi-language support is mechanical
      • MCP v0.3: expand tool coverage, add prompt templates for common workflows
      • Memory publish: bidirectional sync that pushes curated .context/ knowledge back into Claude Code's MEMORY.md

      The architecture is ready. The strings are externalized. The protocol is standard. Now it's about what you build on top.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-arc","level":2,"title":"The Arc","text":"

      This is the seventh post in the ctx blog series. The arc so far:

      1. The Attention Budget: why context windows are a scarce resource
      2. Before Context Windows, We Had Bouncers: the IRC lineage of context engineering
      3. Context as Infrastructure: treating context as persistent files, not ephemeral prompts
      4. When a System Starts Explaining Itself: the journal as a first-class artifact
      5. The Homework Problem: what happens when AI writes code but humans own the outcome
      6. Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge
      7. The Architecture Release (this post): what it looks like when you redesign the internals
      8. We Broke the 3:1 Rule: the consolidation debt behind this release

      See also: Agent Memory Is Infrastructure: the memory bridge feature in this release is the first implementation of the L2-to-L3 promotion pipeline described in that post.

      See also: We Broke the 3:1 Rule: the companion post explaining why this release needed 181 consolidation commits and 18 days of cleanup.

      Systems don't scale because they grow. They scale because they stop drifting.

      Full changelog: v0.6.0...v0.8.0

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/","level":1,"title":"We Broke the 3:1 Rule","text":"

      The best time to consolidate was after every third session. The second best time is now.

      Jose Alekhinne / March 23, 2026

      The rule was simple: three feature sessions, then one consolidation session.

      The Architecture Release shows the result: This post shows the cost.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-rule-we-wrote","level":2,"title":"The Rule We Wrote","text":"

      In The 3:1 Ratio, I documented a rhythm that worked during ctx's first month: three feature sessions, then one consolidation session. The evidence was clear. The rule was simple.

      The math checked out.

      And then we ignored it for five weeks.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#what-happened","level":2,"title":"What Happened","text":"

      After v0.6.0 shipped on February 16, the feature pipeline was irresistible. The MCP server spec was ready. The memory bridge design was done. Webhook notifications had been deferred twice. The VS Code extension needed 15 new commands. The sysinfo package was overdue...

      Each feature was important. Each feature was \"just one more session.\" Each feature pushed the consolidation session one day further out.

      The git history tells the story in two numbers:

      Phase Dates Commits Duration Feature run Feb 16 - Mar 5 198 17 days Consolidation run Mar 5 - Mar 23 181 18 days

      198 feature commits before a single consolidation commit. If the 3:1 rule says consolidate every 4th session, we consolidated after the 66th.

      The Actual Ratio

      The ratio wasn't 3:1. It was 1:1.

      We spent as much time cleaning up as we did building.

      The consolidation run took 18 days: longer than the feature run itself.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#what-compounded","level":2,"title":"What Compounded","text":"

      The 3:1 post warned about compounding. Here is what compounding actually looked like at scale.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-string-problem","level":3,"title":"The String Problem","text":"

      By March 5, there were 879 user-facing strings scattered across 1,500 Go files. Not because anyone decided to put them there. Because each feature session added 10-15 strings, and nobody stopped to ask \"should these be in YAML?\"

      Finding them all took longer than externalizing them. The archaeology was the cost, not the migration.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-taxonomy-problem","level":3,"title":"The Taxonomy Problem","text":"

      24 CLI packages had accumulated their own conventions. Some put cobra wiring in cmd.go. Some put it in root.go. Some mixed business logic with command registration. Some had helpers at the bottom of run.go. Some had separate util.go files.

      At peak drift, adding a feature meant first figuring out which of three competing patterns this package was using.

      Restructuring one package into cmd/root/ + core/ took 15 minutes. Restructuring 24 of them took days, because each one had slightly different conventions to untangle.

      If we had restructured every 4th package as it was built, the taxonomy would have emerged naturally.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-type-problem","level":3,"title":"The Type Problem","text":"

      Cross-cutting types like SessionInfo, ExportParams, and ParserResult were defined in whichever package first needed them. By March 5, the same types were imported through 3-4 layers of indirection, causing import cycles that required internal/entity to break.

      The entity package extracted 30+ types from 12 packages. Each extraction risked breaking imports in packages we hadn't touched in weeks.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-error-problem","level":3,"title":"The Error Problem","text":"

      Per-package err.go files had grown into a broken-window pattern:

      An agent sees err.go in a package, adds another error constructor. By March 5, there were error constructors scattered across 22 packages with no central inventory. The consolidation into internal/err/ domain files required tracing every error through every caller.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-output-problem","level":3,"title":"The Output Problem","text":"

      Output functions (cmd.Println, fmt.Fprintf) were mixed into business logic. When we decided output belongs in write/ packages, we had to extract functions from every CLI package. The Phase WC baseline commit (4ec5999) marks the starting point of this migration. 181 commits later, it was done.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-compound-interest-math","level":2,"title":"The Compound Interest Math","text":"

      The 3:1 rule assumes consolidation sessions of roughly equal size to feature sessions. Here is what happens when you skip:

      Consolidation cadence Feature sessions Consolidation sessions Total Every 4th (3:1) 48 16 64 Every 10th 48 ~8 ~56 Never (what we did) 198 commits 181 commits 379

      The Takeaway

      You don't save consolidation work by skipping it:

      You increase its cost.

      Skipping consolidation doesn't save time: It borrows it.

      The interest rate is nonlinear: The longer you wait, the more each individual fix costs, because fixes interact with other unfixed drift.

      Renaming a constant in week 2 touches 3 files. Renaming it in week 6 touches 15, because five features built on the original name.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#what-consolidation-actually-looked-like","level":2,"title":"What Consolidation Actually Looked Like","text":"

      The 18-day consolidation run wasn't one sweep. It was a sequence of targeted campaigns, each revealing the next:

      Week 1 (Mar 5-11): Error consolidation and write/ migration. Move output functions out of core/. Split monolithic errors.go into 22 domain files. Remove fatih/color. This exposed the scope of the string problem.

      Week 2 (Mar 12-18): String externalization. Create commands.yaml, flags.yaml, split text.yaml into 6 domain files. Add 879 DescKey/TextDescKey constants. Build exhaustive test. Normalize all import aliases to camelCase. This exposed the taxonomy problem.

      Week 3 (Mar 19-23): Taxonomy enforcement. Singularize command directories. Add doc.go to all 75 packages. Standardize import aliases project-wide. Fix lint-drift false positives. This was the \"polish\" phase, except it took 5 days because the inconsistencies had compounded across 461 packages.

      Each week's work would have been a single session if done incrementally.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#lessons-again","level":2,"title":"Lessons (Again)","text":"

      The 3:1 post listed the symptoms of drift. This post adds the consequences of ignoring them:

      Consolidation is not optional; it is deferred or paid: We didn't avoid 16 consolidation sessions by skipping them. We compressed them into 18 days of uninterrupted cleanup. The work was the same; the experience was worse.

      Feature velocity creates an illusion of progress: 198 commits felt productive. But the codebase on March 5 was harder to modify than the codebase on February 16, despite having more features.

      Speed without Structure

      Speed without structure is negative progress.

      Agents amplify both building and debt: The same AI that can restructure 24 packages in a day can also create 24 slightly different conventions in a day. The 3:1 rule matters more with AI-assisted development, not less.

      The consolidation baseline is the most important commit to record: We tracked ours in TASKS.md (4ec5999). Without that marker, knowing where to start the cleanup would have been its own archaeological expedition.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-updated-rule","level":2,"title":"The Updated Rule","text":"

      The 3:1 ratio still works. We just didn't follow it. The updated practice:

      1. After every 3rd feature session, schedule consolidation. Not \"when it feels right.\" Not \"when things get bad.\" After the 3rd session.

      2. Record the baseline commit. When you start a consolidation phase, write down the commit hash. It marks where the debt starts.

      3. Run make audit before feature work. If it doesn't pass, you are already in debt. Consolidate before building.

      4. Treat consolidation as a feature. It gets a branch. It gets commits. It gets a blog post. It is not overhead; it is the work that makes the next three features possible.

      The Rule

      The 3:1 ratio is not aspirational: It is structural.

      Ignore consolidation, and the system will schedule it for you.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-arc","level":2,"title":"The Arc","text":"

      This is the eighth post in the ctx blog series:

      1. The Attention Budget: why context windows are a scarce resource
      2. Before Context Windows, We Had Bouncers: the IRC lineage of context engineering
      3. Context as Infrastructure: treating context as persistent files, not ephemeral prompts
      4. When a System Starts Explaining Itself: the journal as a first-class artifact
      5. The Homework Problem: what happens when AI writes code but humans own the outcome
      6. Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge
      7. The Architecture Release: what v0.8.0 looks like from the inside
      8. We Broke the 3:1 Rule (this post): what happens when you don't consolidate

      See also: The 3:1 Ratio: the original observation. This post is the empirical follow-up, five weeks and 379 commits later.

      Key commits marking the consolidation arc:

      Commit Milestone 4ec5999 Phase WC baseline (consolidation starts) ff6cf19e All CLI packages restructured into cmd/ + core/ d295e49c All command descriptions externalized to YAML 3a0bae86 Error package split into 22 domain files 0fcbd11c fatih/color removed; 2 dependencies remain 5b32e435 doc.go added to all 75 packages a82af4bc Import aliases standardized project-wide 692f86cd lint-drift false positives fixed; make audit green","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/","level":1,"title":"Code Structure as an Agent Interface","text":"","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#what-19-ast-tests-taught-us-about-agent-readable-code","level":2,"title":"What 19 AST Tests Taught Us about Agent-Readable Code","text":"

      When an agent sees token.Slash instead of \"/\", it cannot pattern-match against the millions of strings.Split(s, \"/\") calls in its training data and coast on statistical inference. It has to actually look up what token.Slash is.

      Jose Alekhinne / April 2, 2026

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#how-it-began","level":2,"title":"How It Began","text":"

      We set out to replace a shell script with Go tests.

      We ended up discovering that \"code quality\" and \"agent readability\" are the same thing.

      This is not about linting. This is about controlling how an agent perceives your system.

      One term will recur throughout this post, so let me pin it down:

      Agent Readability

      Agent Readability is the degree to which a codebase can be understood through structured traversal, not statistical pattern matching.

      This is the story of 19 AST-based audit tests, a single-day session that touched 300+ files, and what happens when you treat your codebase's structure as an interface for the machines that read it.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-shell-script-problem","level":2,"title":"The Shell Script Problem","text":"

      ctx had a file called hack/lint-drift.sh. It ran five checks using grep and awk: literal \"\\n\" strings, cmd.Printf calls outside the write package, magic directory strings in filepath.Join, hardcoded .md extensions, and DescKey-to-YAML linkage.

      It worked. Until it didn't.

      The script had three structural weaknesses that kept biting us:

      1. No type awareness. It could not distinguish a Use* constant from a DescKey* constant, causing 71 false positives in one run.
      2. Fragile exclusions. When a constant moved from token.go to whitespace.go, the exclusion glob broke silently.
      3. Ceiling on detection. Checks that require understanding call sites, import graphs, or type relationships are impossible in shell.

      We wrote a spec to replace all five checks with Go tests using go/ast and go/packages. The tests would run as part of go test ./...: no separate script, no separate CI step.

      What we did not expect was where the work would lead.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-ast-migration","level":2,"title":"The AST Migration","text":"

      The pattern for each test is identical:

      func TestNoLiteralWhitespace(t *testing.T) {\n    pkgs := loadPackages(t)\n    var violations []string\n    for _, pkg := range pkgs {\n        for _, file := range pkg.Syntax {\n            ast.Inspect(file, func(n ast.Node) bool {\n                // check node, append to violations\n                return true\n            })\n        }\n    }\n    for _, v := range violations {\n        t.Error(v)\n    }\n}\n

      Load packages once via sync.Once, walk every syntax tree, collect violations, report. The shared helpers (loadPackages, isTestFile, posString) live in helpers_test.go. Each test is a _test.go file in internal/audit/, producing no binary output and not importable by production code.

      In a single session, we built 13 new tests on top of 6 that already existed, bringing the total to 19:

      Test What it catches TestNoLiteralWhitespace \"\\n\", \"\\t\", '\\r' outside config/token/ TestNoNakedErrors fmt.Errorf/errors.New outside internal/err/ TestNoStrayErrFiles err.go files outside internal/err/ TestNoRawLogging fmt.Fprint*(os.Stderr), log.Print* outside internal/log/ TestNoInlineSeparators strings.Join with literal separator arg TestNoStringConcatPaths Path-like variables built with + TestNoStutteryFunctions write.WriteJournal repeats package name TestDocComments Missing doc comments on any declaration TestNoMagicValues Numeric literals outside const definitions TestNoMagicStrings String literals outside const definitions TestLineLength Lines exceeding 80 characters TestNoRegexpOutsideRegexPkg regexp.MustCompile outside config/regex/

      Plus the six that preceded the session: TestNoErrorsAs, TestNoCmdPrintOutsideWrite, TestNoExecOutsideExecPkg, TestNoInlineRegexpCompile, TestNoRawFileIO, TestNoRawPermissions.

      The migration touched 300+ files across 25 commits.

      Not because the tests were hard to write, but because every test we wrote revealed violations that needed fixing.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-tightening-loop","level":2,"title":"The Tightening Loop","text":"

      The most instructive part was not writing the tests. It was the iterative tightening.

      The following process was repeated for every test:

      1. Write the test with reasonable exemptions
      2. Run it, see violations
      3. Fix the violations (migrate to config constants)
      4. The human reviews the result
      5. The human spots something the test missed
      6. Fix the test first, verify it catches the issue
      7. Fix the newly caught violations
      8. Repeat from step 4

      This loop drove the tests from \"basically correct\" to \"actually useful\".

      Three examples:

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#example-1-the-local-const-loophole","level":3,"title":"Example 1: The Local Const Loophole","text":"

      TestNoMagicValues initially exempted local constants inside function bodies. This let code like this pass:

      const descMaxWidth = 70\ndesc := truncateDescription(\n    meta.Description, descMaxWidth,\n)\n

      The test saw a const definition and moved on. But const descMaxWidth = 70 on the line before its only use is just renaming a magic number. The 70 should live in config/format/TruncateDescription where it is discoverable, reusable, and auditable.

      We removed the local const exemption. The test caught it. The value moved to config.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#example-2-the-single-character-dodge","level":3,"title":"Example 2: The Single-Character Dodge","text":"

      TestNoMagicStrings initially exempted all single-character strings as \"structural punctuation\".

      This let \"/\", \"-\", and \".\" pass everywhere.

      But \"/\" is a directory separator. It is OS-specific and a security surface.

      \"-\" used in strings.Repeat(\"-\", width) is creating visual output, not acting as a delimiter.

      \".\" in strings.SplitN(ver, \".\", 3) is a version separator.

      None of these are \"just punctuation\": They are domain values with specific meanings.

      We removed the blanket exemption: 30 violations surfaced.

      Every one was a real magic value that should have been token.Slash, token.Dash, or token.Dot.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#example-3-the-replacer-versus-regex","level":3,"title":"Example 3: The Replacer versus Regex","text":"

      After migrating magic strings, we had this:

      func MermaidID(pkg string) string {\n    r := strings.NewReplacer(\n        token.Slash, token.Underscore,\n        token.Dot, token.Underscore,\n        token.Dash, token.Underscore,\n    )\n    return r.Replace(pkg)\n}\n

      Six token references and a NewReplacer allocation. The magic values were gone, but we had replaced them with token soup: structure without abstraction.

      The correct tool was a regex:

      // In config/regex/file.go:\nvar MermaidUnsafe = regexp.MustCompile(`[/.\\-]`)\n\n// In the caller:\nfunc MermaidID(pkg string) string {\n    return regex.MermaidUnsafe.ReplaceAllString(\n        pkg, token.Underscore,\n    )\n}\n

      One config regex, one call. The regex lives in config/regex/file.go where every other compiled pattern lives. An agent reading the code sees regex.MermaidUnsafe and immediately knows: this is a sanitization pattern, it lives in the regex registry, and it has a name that explains its purpose.

      Clean is better than clever.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#a-before-and-after","level":2,"title":"A Before-and-After","text":"

      To make the agent-readability claim concrete, consider one function through the full transformation.

      Before (the code we started with):

      func MermaidID(pkg string) string {\n    r := strings.NewReplacer(\n        \"/\", \"_\", \".\", \"_\", \"-\", \"_\",\n    )\n    return r.Replace(pkg)\n}\n

      An agent reading this sees six string literals. To understand what the function does, it must: (1) parse the NewReplacer pair semantics, (2) infer that /, ., - are being replaced, (3) guess why, (4) hope the guess is right.

      There is nothing to follow. No import to trace. No name to search. The meaning is locked inside the function body.

      After (the code we ended with):

      func MermaidID(pkg string) string {\n    return regex.MermaidUnsafe.ReplaceAllString(\n        pkg, token.Underscore,\n    )\n}\n

      An agent reading this sees two named references: regex.MermaidUnsafe and token.Underscore.

      To understand the function, it can: (1) look up MermaidUnsafe in config/regex/file.go and see the pattern [/.\\-] with a doc comment explaining it matches invalid Mermaid characters, (2) look up Underscore in config/token/delim.go and see it is the replacement character.

      The agent now has: a named pattern, a named replacement, a package location, documentation, and neighboring context (other regex patterns, other delimiters).

      It got all of this for free by following just two references.

      The indirection is not an overhead. It is the retrieval query.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-principles","level":2,"title":"The Principles","text":"

      You are not just improving code quality. You are shaping the input space that determines how an LLM can reason about your system.

      Every structural constraint we enforce converts implicit semantics into explicit structure.

      LLMs struggle when meaning is implicit and patterns are statistical.

      They thrive when meaning is explicit and structure is navigable.

      Here is what we learned, organized into three categories.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#cognitive-constraints","level":3,"title":"Cognitive Constraints","text":"

      These force agents (and humans) to think harder.

      Indirection acts as a built-in retrieval mechanism:

      Moving magic values to config forces the agent to follow the reference. errMemory.WriteFile(cause) tells the agent \"there is a memory error package, go look.\" fmt.Errorf(\"writing MEMORY.md: %w\", cause) inlines everything and makes the call graph invisible. The indirection IS the retrieval query.

      Unfamiliar patterns force reasoning:

      When an agent sees token.Slash instead of \"/\", it cannot coast on corpus frequency. It has to actually look up what token.Slash is, which forces it through the dependency graph, which means it encounters documentation and neighboring constants, which gives it richer context. You are exploiting the agent's weakness (over-reliance on training data) to make it behave more carefully.

      Documentation helps everyone:

      Extensive documentation helps humans reading the code, agents reasoning about it, and RAG systems indexing it.

      Our TestDocComments check added 308 doc comments in one commit. Every function, every type, every constant block now has a doc comment.

      This is not busywork: it is the content that agents and embeddings consume.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#structural-constraints","level":3,"title":"Structural Constraints","text":"

      These shape the codebase into a navigable graph.

      Shorter files save tokens:

      Forcing private helper functions out of main files makes the main file shorter. An agent loading a file spends fewer tokens on boilerplate and more on the logic that matters.

      Fixed-width constraints force decomposition:

      A function that cannot be expressed in 80 columns is either too deeply nested (extract a helper), has too many parameters (introduce a struct), or has a variable name that is too long (rethink the abstraction).

      The constraint forces structural improvements that happen to also make the code more parseable.

      Chunk-friendly structure helps RAG

      Code intelligence tools chunk files for embedding and retrieval. Short, well-documented, single-responsibility files produce better chunks than monolithic files with mixed concerns.

      The structural constraints create files that RAG systems can index effectively.

      Centralization creates debuggable seams:

      All error handling in internal/err/, all logging in internal/log/, all file operations in internal/io/. One place to debug, one place to test, one place to see patterns. An agent analyzing \"how does this project handle errors\" gets one answer from one package, not 200 scattered fmt.Errorf calls.

      Private functions become public patterns:

      When you extract a private function to satisfy a constraint, it often ends up as a semi-public function in a core/ package. Then you realize it is generic enough to be factored into a purpose-specific module.

      The constraint drives discovery of reusable abstractions hiding inside monolithic functions.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#operational-benefits","level":3,"title":"Operational Benefits","text":"

      These pay dividends in daily development.

      Single-edit renames:

      Renaming a flag is one edit to a config constant instead of find-and-replace across 30,000 lines with possible misses. grep token.Slash gives you every place that uses a forward slash semantically.

      grep \"/\" gives you noise.

      Blast radius containment:

      When every magic value is a config constant, a search is one result. This matters for impact analysis, security audits, and agents trying to understand \"what uses this\".

      Compile-time contract enforcement:

      When err/memory.WriteFile exists, the compiler guarantees the error message exists and the call signature is correct. An inline fmt.Errorf can have a typo in the format string and nothing catches it until runtime. Centralization turns runtime failures into compile errors.

      Semantic git blame:

      When token.Slash is used everywhere and someone changes its value, git blame on the config file shows exactly when and why.

      With inline \"/\" scattered across 30 files, the history is invisible.

      Test surface reduction:

      Centralizing into internal/err/, internal/io/, internal/config/ means you test behavior once at the boundary and trust the callers.

      You do not need 30 tests for 30 fmt.Errorf calls. You need 1 test for errMemory.WriteFile and 30 trivial call-site audits, which is exactly what these AST tests provide.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-numbers","level":2,"title":"The Numbers","text":"

      One session. 25 commits. The raw stats:

      Metric Count New audit tests 13 Total audit tests 19 Files touched 300+ Magic values migrated 90+ Functions renamed 17 Doc comments added 323 Lines rewrapped to 80 chars 190 Config constants created 40+ Config regexes created 3

      Every number represents a violation that existed before the test caught it. The tests did not create work: they revealed work that was already needed.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-uncomfortable-implication","level":2,"title":"The Uncomfortable Implication","text":"

      None of this is Go-specific.

      If an AI agent interacts with your codebase, your codebase already is an interface. You just have not designed it as one.

      If your error messages are scattered across 200 files, an agent cannot reason about error handling as a concept. If your magic values are inlined, an agent cannot distinguish \"this is a path separator\" from \"this is a division operator.\" If your functions are named write.WriteJournal, the agent wastes tokens on redundant information.

      What we discovered, through the unglamorous work of writing lint tests and migrating string literals, is that the structural constraints software engineering has valued for decades are exactly the constraints that make code readable to machines.

      This is not a coincidence: These constraints exist because they reduce the cognitive load of understanding code.

      Agents have cognitive load too: It is called the context window.

      You are not converting code to a new paradigm.

      You are making the latent graph visible.

      You are converting implicit semantics into explicit structure that both humans and machines can traverse.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#whats-next","level":2,"title":"What's Next","text":"

      The spec lists 8 more tests we have not built yet, including TestDescKeyYAMLLinkage (verifying that every DescKey constant has a corresponding YAML entry), TestCLICmdStructure (enforcing the cmd.go / run.go / doc.go file convention), and TestNoFlagBindOutsideFlagbind (which requires migrating ~50 flag registration sites first).

      The broader question: should these principles be codified as a reusable linting framework? The patterns (loadPackages + ast.Inspect + violation collection) are generic.

      The specific checks are project-specific. But the categories of checks (centralization enforcement, magic value detection, naming conventions, documentation requirements) are universal.

      For now, 19 tests in internal/audit/ is enough. They run in 2 seconds as part of go test ./.... They catch real issues.

      And they encode a theory of code quality that serves both humans and the agents that work alongside them.

      Agents are not going away. They are reading your code right now, forming representations of your system in context windows that forget everything between sessions.

      The codebases that structure themselves for that reality will compound. The ones that do not will slowly become illegible to the tools they depend on.

      Structure is no longer just for maintainability. It is for reasonability.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/","level":1,"title":"The Watermelon-Rind Anti-Pattern","text":"","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#why-smarter-tools-make-shallower-agents","level":2,"title":"Why Smarter Tools Make Shallower Agents","text":"

      Give an agent a graph query tool, and it will tell you everything about your codebase except what actually matters.

      Jose Alekhinne / April 6, 2026

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#a-turkish-proverb-walks-into-a-codebase","level":2,"title":"A Turkish Proverb Walks into a Codebase","text":"

      There's a Turkish idiom: esegin aklina karpuz kabugu sokmak (literally, \"to put watermelon rind into a donkey's mind.\" It means to plant an idea in someone's head that they wouldn't have come up with on their own) usually one that leads them astray.

      In English, let's call this a \"watermelon metric\": a project management term for something that's green on the outside and red on the inside: all dashboards passing, reality crumbling.

      Both halves of this metaphor showed up in a single experiment. And the result changed how we design architecture analysis in ctx.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-experiment","level":2,"title":"The Experiment","text":"

      We ran three sessions analyzing the same large codebase (~34,000 symbols) using the same architecture skill, varying only what tools the agent had access to.

      Session Tools Available Output (lines) Character 1 None (MCP broken) 5,866 Deep, intimate 2 Full graph MCP 1,124 Structural, correct 3 Enrichment pass +verified data Additive, not restorative

      Session 1 was an accident. The MCP server that provides code intelligence queries was broken, so the agent couldn't ask the graph anything. It had to read code. Line by line. File by file.

      It produced 5,866 lines of architecture analysis: per-controller data flows, scale math, startup sequences, timeout defaults, edge cases that only surface when you actually look at the implementation.

      Session 2 had working tools. Same skill, same codebase. The agent produced 1,124 lines (5.2x less). Structurally correct. Valid symbol references. Proper call chains.

      And hollow.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-rind","level":2,"title":"The Rind","text":"

      The Session 2 output was a watermelon rind: the right shape, the right color, the right texture on the outside. But the substance (the operational details, the defaults nobody documents, the scale math that tells you when a component will fall over) was missing.

      Not wrong. Not broken. Just... thin.

      The agent had answered every question correctly. The problem was that it never discovered the questions it should have asked. When you can query a graph for \"what calls this function?\", you don't stumble into the retry loop that silently swallows errors three layers down. When you can ask for the dependency tree, you don't notice that two packages share a mutable state through a global variable that isn't in any interface.

      The tool answered the question asked but prevented the discovery of answers to questions never asked.

      Here's what that looks like concretely: the graph tells you that ReconcileDeployment calls SyncPods. It does not tell you that SyncPods retries three times with exponential backoff, silently drops errors after timeout, and resets a package-level counter that another goroutine reads without a lock. The call chain is correct.

      The operational reality is invisible.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-donkeys-idea","level":2,"title":"The Donkey's Idea","text":"

      This is where the Turkish proverb earns its place: The graph tool is the \"karpuz kabugu\" (the watermelon rind placed into the agent's mind).

      Before the tool existed, the agent had no choice but to read deeply. With the tool available, a new idea appears: why read 500 lines of code when I can query the call graph?

      The agent isn't lazy. It's rational.

      Graph queries are faster, more reliable, and produce verifiably correct output. The agent is optimizing. It's satisficing (finding answers that are good enough), instead of maximizing (finding everything there is to know).

      Satisficing produces watermelon rinds.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-two-pass-compiler","level":2,"title":"The Two-Pass Compiler","text":"

      Session 3 taught us that you can't fix shallow analysis by adding more tools after the fact. The enrichment pass added verified graph data (blast radius numbers, registration sites, execution flow confirmation) but it couldn't recover the intimate code knowledge that Session 1 had produced through sheer necessity.

      You can't enrich your way out of a depth deficit.

      So we redesigned. Instead of one skill with optional tools, we built a two-pass compiler for architecture understanding:

      Pass 1: Semantic parsing. The /ctx-architecture skill deliberately has no access to graph query tools. The agent must read code, build mental models, and produce architecture artifacts through human-style comprehension. Constraint is the feature.

      Pass 2: Static analysis. The /ctx-architecture-enrich skill takes Pass 1 output as input and runs comprehensive verification through code intelligence: blast radius analysis, registration site discovery, execution flow tracing, domain clustering comparison. It extends and verifies, but it doesn't replace.

      The key insight: these must be separate skills with separate tool permissions. If you give the agent graph tools during Pass 1, it will use them. The \"karpuz kabugu\" will be in its mind. The only way to prevent satisficing is to remove the option.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-principle","level":2,"title":"The Principle","text":"

      We call this constraint-as-feature: deliberately withholding capabilities to force deeper engagement.

      It sounds paradoxical. You built sophisticated code intelligence tools and then... forbid the agent from using them? During the most important phase?

      Yes. Because the tools don't make the agent smarter. They make it faster. And faster, in architecture analysis, is the enemy of deep.

      What's actually happening is subtler: tools reduce the agent's search space. A graph query collapses thousands of possible observations into one precise answer. That's efficient for known questions. But architecture understanding depends on unknown unknowns: and you only find those by wandering through code with nothing to shortcut the journey.

      The constraint forces the agent into a mode of operation that produces better output than any amount of tooling can achieve. The limitation is the capability.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#when-does-this-apply","level":2,"title":"When Does This Apply?","text":"

      Not always. The watermelon-rind antipattern is specific to exploratory analysis: tasks where the value comes from discovering unknowns, not from answering known questions.

      Graph tools are excellent for:

      • Verification: \"Does X actually call Y?\" (binary question, precise answer)
      • Impact analysis: \"What breaks if I change Z?\" (bounded scope, enumerable results)
      • Navigation: \"Where is this interface implemented?\" (lookup, not analysis)

      Graph tools produce watermelon rinds when:

      • The goal is understanding, not answering
      • The unknowns are unknown: you don't know what to ask
      • Depth matters more than breadth: operational details, edge cases, implicit coupling

      The two-pass approach preserves both: deep reading first, tool verification second.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#takeaway","level":2,"title":"Takeaway","text":"

      The two-pass approach is the slowest way to analyze a codebase. It is also the only way that produces both depth and accuracy. We accept the cost because architecture analysis is not a speed game: it is a coverage game.

      Esegin aklina karpuz kabugu sokma!

      (don't put the watermelon rind to a donkey's mind)

      If the agent never struggles, it never discovers. And if it never discovers, you are not doing architecture; you are doing autocomplete.

      This post is part of the ctx field notes series, documenting what we learn building persistent context infrastructure for AI coding sessions.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"cli/","level":1,"title":"CLI","text":"","path":["CLI"],"tags":[]},{"location":"cli/#ctx-cli","level":2,"title":"ctx CLI","text":"

      Complete reference for all ctx commands, grouped by function.

      ","path":["CLI"],"tags":[]},{"location":"cli/#global-options","level":2,"title":"Global Options","text":"

      All commands support these flags:

      Flag Description --help Show command help --version Show version --tool <name> Override active AI tool identifier (e.g. kiro, cursor)

      Tell ctx which .context/ to use. ctx does not search the filesystem for .context/: you have to declare it. Three ways:

      • eval \"$(ctx activate)\" (recommended): binds CTX_DIR for the current shell.
      • export CTX_DIR=/abs/path/to/.context directly, then run any ctx command.
      • CTX_DIR=/abs/path/to/.context ctx <command> inline, for a one-shot or CI step.

      CTX_DIR must be an absolute path with .context as its basename. Relative paths and other names are rejected on first use; the basename guard catches the common footgun (export CTX_DIR=$(pwd)) before stray writes can leak to the project root.

      If you forget, commands fail fast with a linkable Error: no context directory specified pointing at Activating a Context Directory. A handful of commands run without a declaration because they don't need a project: ctx init, ctx activate, ctx deactivate, ctx version, ctx help, ctx system bootstrap, ctx doctor, ctx guide, ctx why, ctx config switch/status, and ctx hub *.

      Initialization required. Once declared, the target must already have been initialized by ctx init (otherwise commands return ctx: not initialized).

      ","path":["CLI"],"tags":[]},{"location":"cli/#getting-started","level":2,"title":"Getting Started","text":"Command Description ctx init Initialize .context/ directory with templates ctx activate Emit export CTX_DIR=... to bind context for the shell ctx deactivate Emit unset CTX_DIR to clear the binding ctx status Show context summary (files, tokens, drift) ctx guide Quick-reference cheat sheet ctx why Read the philosophy behind ctx","path":["CLI"],"tags":[]},{"location":"cli/#context","level":2,"title":"Context","text":"Command Description ctx add Add a task, decision, learning, or convention ctx load Output assembled context in read order ctx agent Print token-budgeted context packet for AI consumption ctx sync Reconcile context with codebase state ctx drift Detect stale paths, secrets, missing files ctx compact Archive completed tasks, clean up files ctx fmt Format context files to 80-char line width ctx decision Manage DECISIONS.md (reindex) ctx learning Manage LEARNINGS.md (reindex) ctx task Task completion, archival, and snapshots ctx reindex Regenerate indices for DECISIONS.md and LEARNINGS.md ctx permission Permission snapshots (golden image) ctx change Show what changed since last session ctx memory Bridge Claude Code auto memory into .context/ ctx watch Auto-apply context updates from AI output","path":["CLI"],"tags":[]},{"location":"cli/#sessions","level":2,"title":"Sessions","text":"Command Description ctx journal Browse, import, enrich, and lock session history ctx pad Encrypted scratchpad for sensitive one-liners ctx remind Session-scoped reminders that surface at session start ctx hook pause Pause context hooks for the current session ctx hook resume Resume paused context hooks","path":["CLI"],"tags":[]},{"location":"cli/#integrations","level":2,"title":"Integrations","text":"Command Description ctx setup Generate AI tool integration configs ctx steering Manage steering files (behavioral rules for AI tools) ctx trigger Manage lifecycle triggers (scripts for automation) ctx skill Manage reusable instruction bundles ctx mcp MCP server for AI tool integration (stdin/stdout) ctx hook notify Webhook notifications (setup, test, send) ctx loop Generate autonomous loop script ctx connection Client-side commands for connecting to a ctx Hub ctx hub Operate a ctx Hub server or cluster ctx serve Serve a static site locally via zensical ctx site Site management (feed generation)","path":["CLI"],"tags":[]},{"location":"cli/#diagnostics","level":2,"title":"Diagnostics","text":"Command Description ctx doctor Structural health check (hooks, drift, config) ctx trace Show context behind git commits ctx sysinfo Show system resource usage (memory, swap, disk, load) ctx usage Show session token usage stats","path":["CLI"],"tags":[]},{"location":"cli/#runtime","level":2,"title":"Runtime","text":"Command Description ctx config Manage runtime configuration profiles ctx prune Clean stale per-session state files ctx hook Hook message, notification, and lifecycle controls ctx system Hook plumbing and agent-only commands (not user-facing)","path":["CLI"],"tags":[]},{"location":"cli/#shell","level":2,"title":"Shell","text":"Command Description ctx completion Generate shell autocompletion scripts","path":["CLI"],"tags":[]},{"location":"cli/#exit-codes","level":2,"title":"Exit Codes","text":"Code Meaning 0 Success 1 General error / warnings (e.g. drift) 2 Context not found 3 Violations found (e.g. drift) 4 File operation error","path":["CLI"],"tags":[]},{"location":"cli/#environment-variables","level":2,"title":"Environment Variables","text":"Variable Description CTX_DIR Override default context directory path CTX_TOKEN_BUDGET Override default token budget CTX_SESSION_ID Active AI session ID (used by ctx trace for context linking)","path":["CLI"],"tags":[]},{"location":"cli/#configuration-file","level":2,"title":"Configuration File","text":"

      Optional .ctxrc (YAML format) at project root:

      # .ctxrc\ntoken_budget: 8000           # Default token budget\npriority_order:              # File loading priority\n  - TASKS.md\n  - DECISIONS.md\n  - CONVENTIONS.md\nauto_archive: true           # Auto-archive old items\narchive_after_days: 7        # Days before archiving tasks\nscratchpad_encrypt: true     # Encrypt scratchpad (default: true)\nevent_log: false             # Enable local hook event logging\ncompanion_check: true        # Check companion tools at session start\nentry_count_learnings: 30    # Drift warning threshold (0 = disable)\nentry_count_decisions: 20    # Drift warning threshold (0 = disable)\nconvention_line_count: 200   # Line count warning for CONVENTIONS.md (0 = disable)\ninjection_token_warn: 15000  # Oversize injection warning (0 = disable)\ncontext_window: 200000       # Auto-detected for Claude Code; override for other tools\nbilling_token_warn: 0        # One-shot billing warning at this token count (0 = disabled)\nkey_rotation_days: 90        # Days before key rotation nudge\nsession_prefixes:            # Recognized session header prefixes (extend for i18n)\n  - \"Session:\"               # English (default)\n  # - \"Oturum:\"              # Turkish (add as needed)\n  # - \"セッション:\"             # Japanese (add as needed)\nfreshness_files:             # Files with technology-dependent constants (opt-in)\n  - path: config/thresholds.yaml\n    desc: Model token limits and batch sizes\n    review_url: https://docs.example.com/limits  # Optional\nnotify:                      # Webhook notification settings\n  events:                    # Required: only listed events fire\n    - loop\n    - nudge\n    - relay\n    # - heartbeat            # Every-prompt session-alive signal\ntool: \"\"                     # Active AI tool: claude, cursor, cline, kiro, codex\nsteering:                    # Steering layer configuration\n  dir: .context/steering     # Steering files directory\n  default_inclusion: manual  # Default inclusion mode (always, auto, manual)\n  default_tools: []          # Default tool filter for new steering files\nhooks:                       # Hook system configuration\n  dir: .context/hooks        # Hook scripts directory\n  timeout: 10                # Per-hook execution timeout in seconds\n  enabled: true              # Whether hook execution is enabled\n
      Field Type Default Description token_budget int 8000 Default token budget for ctx agent priority_order []string (all files) File loading priority for context packets auto_archive bool true Auto-archive completed tasks archive_after_days int 7 Days before completed tasks are archived scratchpad_encrypt bool true Encrypt scratchpad with AES-256-GCM event_log bool false Enable local hook event logging to .context/state/events.jsonl companion_check bool true Check companion tool availability (Gemini Search, GitNexus) during /ctx-remember entry_count_learnings int 30 Drift warning when LEARNINGS.md exceeds this count entry_count_decisions int 20 Drift warning when DECISIONS.md exceeds this count convention_line_count int 200 Line count warning for CONVENTIONS.md injection_token_warn int 15000 Warn when auto-injected context exceeds this token count (0 = disable) context_window int 200000 Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools billing_token_warn int 0 (off) One-shot warning when session tokens exceed this threshold (0 = disabled) key_rotation_days int 90 Days before encryption key rotation nudge session_prefixes []string [\"Session:\"] Recognized Markdown session header prefixes. Extend to parse sessions written in other languages freshness_files []object (none) Files to track for staleness (path, desc, optional review_url). Hook warns after 6 months without modification notify.events []string (all) Event filter for webhook notifications (empty = all) tool string (empty) Active AI tool identifier (claude, cursor, cline, kiro, codex) steering.dir string .context/steering Steering files directory steering.default_inclusion string manual Default inclusion mode for new steering files (always, auto, manual) steering.default_tools []string (all) Default tool filter for new steering files (empty = all tools) hooks.dir string .context/hooks Hook scripts directory hooks.timeout int 10 Per-hook execution timeout in seconds hooks.enabled bool true Whether hook execution is enabled

      Priority order: CLI flags > Environment variables > .ctxrc > Defaults

      All settings are optional. Missing values use defaults.

      ","path":["CLI"],"tags":[]},{"location":"cli/bootstrap/","level":1,"title":"System Bootstrap","text":"","path":["System Bootstrap"],"tags":[]},{"location":"cli/bootstrap/#ctx-system-bootstrap","level":3,"title":"ctx system bootstrap","text":"

      Print the resolved context directory path so AI agents can anchor their session. The default output lists the context directory, the tracked context files, and a short health snapshot. --quiet prints just the path; --json produces structured output for automation.

      This is a hidden, agent-only command that agents are instructed to run first in their session-start procedure; it is the authoritative answer to \"where does this project's context live?\".

      ctx system bootstrap [flags]\n

      Flags:

      Flag Description -q, --quiet Output only the context directory path --json Output in JSON format

      Examples:

      ctx system bootstrap                 # Text output for agents\nctx system bootstrap -q              # Just the context directory path\nctx system bootstrap --json          # Structured output for automation\n

      Note: -q prints just the resolved directory path. See Activating a Context Directory if you hit a \"no context directory specified\" error.

      ","path":["System Bootstrap"],"tags":[]},{"location":"cli/change/","level":1,"title":"Change","text":"","path":["CLI","Context","Change"],"tags":[]},{"location":"cli/change/#ctx-change","level":2,"title":"ctx change","text":"

      Show what changed in context files and code since your last session.

      Automatically detects the previous session boundary from state markers or event log. Useful at session start to quickly see what moved while you were away.

      ctx change [flags]\n

      Flags:

      Flag Description --since Time reference: duration (24h) or date (2026-03-01)

      Reference time detection (priority order):

      1. --since flag (duration, date, or RFC3339 timestamp)
      2. ctx-loaded-* marker files in .context/state/ (second most recent)
      3. Last context-load-gate event from .context/state/events.jsonl
      4. Fallback: 24 hours ago

      Examples:

      # Auto-detect last session, show what changed\nctx change\n\n# Changes in the last 48 hours\nctx change --since 48h\n\n# Changes since a specific date\nctx change --since 2026-03-10\n

      Output:

      ## Changes Since Last Session\n\n**Reference point**: 6 hours ago\n\n### Context File Changes\n- `TASKS.md` - modified 2026-03-12 14:30\n- `DECISIONS.md` - modified 2026-03-12 09:15\n\n### Code Changes\n- **12 commits** since reference point\n- **Latest**: Fix journal enrichment ordering\n- **Directories touched**: internal, docs, specs\n- **Authors**: jose, claude\n

      Context file changes are detected by filesystem mtime (works without git). Code changes use git log --since (empty when not in a git repo).

      See also: Reviewing Session Changes.

      ","path":["CLI","Context","Change"],"tags":[]},{"location":"cli/completion/","level":1,"title":"Completion","text":"","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#ctx-completion","level":2,"title":"ctx completion","text":"

      Generate shell autocompletion scripts.

      ctx completion <shell>\n
      ","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#subcommands","level":3,"title":"Subcommands","text":"Shell Command bash ctx completion bash zsh ctx completion zsh fish ctx completion fish powershell ctx completion powershell

      Examples:

      ctx completion bash > /etc/bash_completion.d/ctx\nctx completion zsh  > \"${fpath[1]}/_ctx\"\nctx completion fish > ~/.config/fish/completions/ctx.fish\nctx completion powershell | Out-String | Invoke-Expression\n
      ","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#installation","level":3,"title":"Installation","text":"BashZshFishPowerShell
      # Add to ~/.bashrc\nsource <(ctx completion bash)\n
      # Add to ~/.zshrc\nsource <(ctx completion zsh)\n
      ctx completion fish | source\n# Or save to completions directory\nctx completion fish > ~/.config/fish/completions/ctx.fish\n
      # Add to your PowerShell profile\nctx completion powershell | Out-String | Invoke-Expression\n
      ","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/config/","level":1,"title":"Config","text":"","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config","level":3,"title":"ctx config","text":"

      Manage runtime configuration profiles.

      ctx config <subcommand>\n

      The ctx repo ships two .ctxrc source profiles (.ctxrc.base and .ctxrc.dev). The working copy (.ctxrc) is gitignored and switched between them using subcommands below.

      ","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-switch","level":4,"title":"ctx config switch","text":"

      Switch between .ctxrc configuration profiles.

      ctx config switch [dev|base]\n

      With no argument, toggles between dev and base. Accepts prod as an alias for base.

      Argument Description dev Switch to dev profile (verbose logging) base Switch to base profile (all defaults) (none) Toggle to the opposite profile

      Profiles:

      Profile Description dev Verbose logging, webhook notifications on base All defaults, notifications off

      Examples:

      ctx config switch dev     # Switch to dev profile\nctx config switch base    # Switch to base profile\nctx config switch         # Toggle (dev → base or base → dev)\nctx config switch prod    # Alias for \"base\"\n

      The detection heuristic checks for an uncommented notify: line in .ctxrc: present means dev, absent means base.

      ","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-status","level":4,"title":"ctx config status","text":"

      Show which .ctxrc profile is currently active.

      ctx config status\n

      Output examples:

      active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n

      See also: Configuration, Contributing: Configuration Profiles

      ","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/connect/","level":1,"title":"Connect","text":"","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect","level":2,"title":"ctx connect","text":"

      Connect a project to a ctx Hub for cross-project knowledge sharing. Projects publish decisions, learnings, conventions, and tasks to a hub; other subscribed projects receive them alongside local context.

      New to the Hub?

      Start with the ctx Hub overview for the mental model (what the hub is, who it's for, what it is not), then walk through Getting Started. This page is a command reference, not an introduction.

      The unit of identity is a project, not a user. Registering a directory with ctx connect register binds a per-project client token in .context/.connect.enc. Two developers on the same project either share that file over a trusted channel, or each register under a different project name.

      Only structured entries flow through the hub: decision, learning, convention, task. Session journals, scratchpad contents, and other local state stay on the machine that created them.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-register","level":3,"title":"ctx connect register","text":"

      One-time registration with a hub. Requires the hub address and admin token (printed by ctx hub start on first run).

      ctx connect register localhost:9900 --token ctx_adm_7f3a...\n

      On success, stores an encrypted connection config in .context/.connect.enc for future RPCs.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-subscribe","level":3,"title":"ctx connect subscribe","text":"

      Set which entry types to receive from the hub. Only matching types are returned by sync and listen.

      ctx connect subscribe decision learning\nctx connect subscribe decision learning convention\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-sync","level":3,"title":"ctx connect sync","text":"

      Pull matching entries from the hub and write them to .context/hub/ as markdown files with origin tags and date headers. Tracks last-seen sequence for incremental sync.

      ctx connect sync\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-publish","level":3,"title":"ctx connect publish","text":"

      Push entries to the hub. Specify type and content as arguments.

      ctx connect publish decision \"Use UTC timestamps everywhere\"\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-listen","level":3,"title":"ctx connect listen","text":"

      Stream new entries from the hub in real-time. Writes to .context/hub/ as entries arrive. Press Ctrl-C to stop.

      ctx connect listen\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-status","level":3,"title":"ctx connect status","text":"

      Show hub connection state and entry statistics.

      ctx connect status\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#automatic-sharing","level":2,"title":"Automatic Sharing","text":"

      Use --share on ctx add to write locally AND publish to the hub:

      ctx add decision \"Use UTC\" --share \\\n  --context \"Need consistency\" \\\n  --rationale \"Avoid timezone bugs\" \\\n  --consequence \"UI does conversion\"\n

      If the hub is unreachable, the local write succeeds and a warning is printed. The --share flag is best-effort; it never blocks local context updates.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#auto-sync","level":2,"title":"Auto-Sync","text":"

      Once registered, the check-hub-sync hook automatically syncs new entries from the hub at the start of each session (daily throttled). No manual ctx connect sync needed.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#shared-files","level":2,"title":"Shared Files","text":"

      Entries from the hub are stored in .context/hub/:

      .context/hub/\n  decisions.md      # Shared decisions with origin tags\n  learnings.md      # Shared learnings\n  conventions.md    # Shared conventions\n  .sync-state.json  # Last-seen sequence tracker\n

      These files are read-only (managed by sync/listen) and never mixed with local context files.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#agent-integration","level":2,"title":"Agent Integration","text":"

      Include shared knowledge in agent context packets:

      ctx agent --include-hub\n

      Shared entries are included as Tier 8 in the budget-aware assembly, scored by recency and type relevance.

      ","path":["Connect"],"tags":[]},{"location":"cli/connection/","level":1,"title":"Connect","text":"","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connect","level":2,"title":"ctx connect","text":"

      Connect a project to a ctx Hub for cross-project knowledge sharing. Projects publish decisions, learnings, conventions, and tasks to a hub; other subscribed projects receive them alongside local context.

      New to the ctx Hub?

      Start with the ctx Hub overview for the mental model (what the hub is, who it's for, what it is not), then walk through Getting Started. This page is a command reference, not an introduction.

      The unit of identity is a project, not a user. Registering a directory with ctx connection register binds a per-project client token in .context/.connect.enc. Two developers on the same project either share that file over a trusted channel, or each register under a different project name.

      Only structured entries flow through the hub: decision, learning, convention, task. Session journals, scratchpad contents, and other local state stay on the machine that created them.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-register","level":3,"title":"ctx connection register","text":"

      One-time registration with a ctx Hub. Requires the ctx Hub address and admin token (printed by ctx hub start on first run).

      Examples:

      ctx connection register localhost:9900 --token ctx_adm_7f3a...\n

      On success, stores an encrypted connection config in .context/.connect.enc for future RPCs.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-subscribe","level":3,"title":"ctx connection subscribe","text":"

      Set which entry types to receive from the ctx Hub. Only matching types are returned by sync and listen.

      Examples:

      ctx connection subscribe decision learning\nctx connection subscribe decision learning convention\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-sync","level":3,"title":"ctx connection sync","text":"

      Pull matching entries from the ctx Hub and write them to .context/hub/ as markdown files with origin tags and date headers. Tracks last-seen sequence for incremental sync.

      Examples:

      ctx connection sync\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-publish","level":3,"title":"ctx connection publish","text":"

      Push entries to the ctx Hub. Specify type and content as arguments.

      Examples:

      ctx connection publish decision \"Use UTC timestamps everywhere\"\nctx connection publish learning \"Go embed requires files in same package\"\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-listen","level":3,"title":"ctx connection listen","text":"

      Stream new entries from the ctx Hub in real-time. Writes to .context/hub/ as entries arrive. Press Ctrl-C to stop.

      Examples:

      ctx connection listen\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-status","level":3,"title":"ctx connection status","text":"

      Show ctx Hub connection state and entry statistics.

      Examples:

      ctx connection status\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#automatic-sharing","level":2,"title":"Automatic Sharing","text":"

      Use --share on ctx add to write locally AND publish to the ctx Hub:

      ctx add decision \"Use UTC\" --share \\\n  --context \"Need consistency\" \\\n  --rationale \"Avoid timezone bugs\" \\\n  --consequence \"UI does conversion\"\n

      If the hub is unreachable, the local write succeeds and a warning is printed. The --share flag is best-effort; it never blocks local context updates.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#auto-sync","level":2,"title":"Auto-Sync","text":"

      Once registered, the check-hub-sync hook automatically syncs new entries from the ctx Hub at the start of each session (daily throttled). No manual ctx connection sync needed.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#shared-files","level":2,"title":"Shared Files","text":"

      Entries from the ctx Hub are stored in .context/hub/:

      .context/hub/\n  decisions.md      # Shared decisions with origin tags\n  learnings.md      # Shared learnings\n  conventions.md    # Shared conventions\n  .sync-state.json  # Last-seen sequence tracker\n

      These files are read-only (managed by sync/listen) and never mixed with local context files.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#agent-integration","level":2,"title":"Agent Integration","text":"

      Include shared knowledge in agent context packets:

      ctx agent --include-hub\n

      Shared entries are included as Tier 8 in the budget-aware assembly, scored by recency and type relevance.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/context/","level":1,"title":"Context Management","text":"","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-add","level":3,"title":"ctx add","text":"

      Add a new item to a context file.

      ctx add <type> <content> [flags]\n

      Types:

      Type Target File task TASKS.md decision DECISIONS.md learning LEARNINGS.md convention CONVENTIONS.md

      Flags:

      Flag Short Description --priority <level> -p Priority for tasks: high, medium, low --section <name> -s Target section within file --context -c Context (required for decisions and learnings) --rationale -r Rationale for decisions (required for decisions) --consequence Consequence for decisions (required for decisions) --lesson -l Key insight (required for learnings) --application -a How to apply going forward (required for learnings) --file -f Read content from file instead of argument

      Examples:

      # Add a task\nctx add task \"Implement user authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\nctx add task \"Fix login bug\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Record a decision (requires all ADR (Architectural Decision Record) fields)\nctx add decision \"Use PostgreSQL for primary database\" \\\n  --context \"Need a reliable database for production\" \\\n  --rationale \"PostgreSQL offers ACID compliance and JSON support\" \\\n  --consequence \"Team needs PostgreSQL training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Note a learning (requires context, lesson, and application)\nctx add learning \"Vitest mocks must be hoisted\" \\\n  --context \"Tests failed with undefined mock errors\" \\\n  --lesson \"Vitest hoists vi.mock() calls to top of file\" \\\n  --application \"Always place vi.mock() before imports in test files\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Add to specific section\nctx add convention \"Use kebab-case for filenames\" --section \"Naming\"\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-drift","level":3,"title":"ctx drift","text":"

      Detect stale or invalid context.

      ctx drift [flags]\n

      Flags:

      Flag Description --json Output machine-readable JSON --fix Auto-fix simple issues

      Checks:

      • Path references in ARCHITECTURE.md and CONVENTIONS.md exist
      • Task references are valid
      • Constitution rules aren't violated (heuristic)
      • Staleness indicators (old files, many completed tasks)
      • Missing packages: warns when internal/ directories exist on disk but are not referenced in ARCHITECTURE.md (suggests running /ctx-architecture)
      • Entry count: warns when LEARNINGS.md or DECISIONS.md exceed configurable thresholds (default: 30 learnings, 20 decisions), or when CONVENTIONS.md exceeds a line count threshold (default: 200). Configure via .ctxrc:
        entry_count_learnings: 30      # warn above this (0 = disable)\nentry_count_decisions: 20      # warn above this (0 = disable)\nconvention_line_count: 200     # warn above this (0 = disable)\n

      Example:

      ctx drift\nctx drift --json\nctx drift --fix\n

      Exit codes:

      Code Meaning 0 All checks passed 1 Warnings found 3 Violations found","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-sync","level":3,"title":"ctx sync","text":"

      Reconcile context with the current codebase state.

      ctx sync [flags]\n

      Flags:

      Flag Description --dry-run Show what would change without modifying

      What it does:

      • Scans codebase for structural changes
      • Compares with ARCHITECTURE.md
      • Suggests documenting dependencies if package files exist
      • Identifies stale or outdated context

      Example:

      ctx sync\nctx sync --dry-run\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-compact","level":3,"title":"ctx compact","text":"

      Consolidate and clean up context files.

      • Moves completed tasks older than 7 days to the archive
      • Removes empty sections
      ctx compact [flags]\n

      Flags:

      Flag Description --archive Create .context/archive/ for old content

      Example:

      ctx compact\nctx compact --archive\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-fmt","level":3,"title":"ctx fmt","text":"

      Format context files to a consistent line width.

      Wraps long lines in TASKS.md, DECISIONS.md, LEARNINGS.md, and CONVENTIONS.md at word boundaries. Markdown list items get 2-space continuation indent. Headings, tables, frontmatter, and HTML comments are preserved as-is.

      Idempotent: running twice produces the same output.

      ctx fmt [flags]\n

      Flags:

      Flag Type Default Description --width int 80 Target line width --check bool false Check only, exit 1 if files would change

      Examples:

      ctx fmt              # format all context files\nctx fmt --check      # CI mode: check without modifying\nctx fmt --width 100  # custom width\n

      Also available as a Makefile target:

      make fmt-context\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task","level":3,"title":"ctx task","text":"

      Manage task completion, archival, and snapshots.

      ctx task <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-complete","level":4,"title":"ctx task complete","text":"

      Mark a task as completed.

      ctx task complete <task-id-or-text>\n

      Arguments:

      • task-id-or-text: Task number or partial text match

      Examples:

      # By text (partial match)\nctx task complete \"user auth\"\n\n# By task number\nctx task complete 3\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-archive","level":4,"title":"ctx task archive","text":"

      Move completed tasks from TASKS.md to a timestamped archive file.

      ctx task archive [flags]\n

      Flags:

      Flag Description --dry-run Preview changes without modifying files

      Archive files are stored in .context/archive/ with timestamped names (tasks-YYYY-MM-DD.md). Completed tasks (marked with [x]) are moved; pending tasks ([ ]) remain in TASKS.md.

      Example:

      ctx task archive\nctx task archive --dry-run\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-snapshot","level":4,"title":"ctx task snapshot","text":"

      Create a point-in-time snapshot of TASKS.md without modifying the original.

      ctx task snapshot [name]\n

      Arguments:

      • name: Optional name for the snapshot (defaults to \"snapshot\")

      Snapshots are stored in .context/archive/ with timestamped names (tasks-<name>-YYYY-MM-DD-HHMM.md).

      Example:

      ctx task snapshot\nctx task snapshot \"before-refactor\"\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission","level":3,"title":"ctx permission","text":"

      Manage Claude Code permission snapshots.

      ctx permission <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-snapshot","level":4,"title":"ctx permission snapshot","text":"

      Save .claude/settings.local.json as the golden image.

      ctx permission snapshot\n

      Creates .claude/settings.golden.json as a byte-for-byte copy of the current settings. Overwrites if the golden file already exists.

      The golden file is meant to be committed to version control and shared with the team.

      Example:

      ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-restore","level":4,"title":"ctx permission restore","text":"

      Replace settings.local.json with the golden image.

      ctx permission restore\n

      Prints a diff of dropped (session-accumulated) and restored permissions. No-op if the files already match.

      Example:

      ctx permission restore\n# Dropped 3 session permission(s):\n#   - Bash(cat /tmp/debug.log:*)\n#   - Bash(rm /tmp/test-*:*)\n#   - Bash(curl https://example.com:*)\n# Restored from golden image.\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-reindex","level":3,"title":"ctx reindex","text":"

      Regenerate the quick-reference index for both DECISIONS.md and LEARNINGS.md in a single invocation.

      ctx reindex\n

      This is a convenience wrapper around ctx decision reindex and ctx learning reindex. Both files grow at similar rates and users typically want to reindex both after manual edits.

      The index is a compact table of date and title for each entry, allowing AI tools to scan entries without reading the full file.

      Example:

      ctx reindex\n# ✓ Index regenerated with 12 entries\n# ✓ Index regenerated with 8 entries\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-decision","level":3,"title":"ctx decision","text":"

      Manage the DECISIONS.md file.

      ctx decision <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-decision-reindex","level":4,"title":"ctx decision reindex","text":"

      Regenerate the quick-reference index at the top of DECISIONS.md.

      ctx decision reindex\n

      The index is a compact table showing the date and title for each decision, allowing AI tools to quickly scan entries without reading the full file.

      Use this after manual edits to DECISIONS.md or when migrating existing files to use the index format.

      Example:

      ctx decision reindex\n# ✓ Index regenerated with 12 entries\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-learning","level":3,"title":"ctx learning","text":"

      Manage the LEARNINGS.md file.

      ctx learning <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-learning-reindex","level":4,"title":"ctx learning reindex","text":"

      Regenerate the quick-reference index at the top of LEARNINGS.md.

      ctx learning reindex\n

      The index is a compact table showing the date and title for each learning, allowing AI tools to quickly scan entries without reading the full file.

      Use this after manual edits to LEARNINGS.md or when migrating existing files to use the index format.

      Example:

      ctx learning reindex\n# ✓ Index regenerated with 8 entries\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/doctor/","level":1,"title":"Doctor","text":"","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#ctx-doctor","level":3,"title":"ctx doctor","text":"

      Structural health check across context, hooks, and configuration. Runs mechanical checks that don't require semantic analysis. Think of it as ctx status + ctx drift + configuration audit in one pass.

      ctx doctor [flags]\n

      Flags:

      Flag Short Type Default Description --json -j bool false Machine-readable JSON output","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#what-it-checks","level":4,"title":"What It Checks","text":"Check Category What it verifies Context initialized Structure .context/ directory exists Required files present Structure All required context files exist (TASKS.md, etc.) Drift detected Quality Stale paths, missing files, constitution violations Event logging status Hooks Whether event_log: true is set in .ctxrc Webhook configured Hooks .notify.enc file exists Pending reminders State Count of entries in reminders.json Task completion ratio State Pending vs completed tasks in TASKS.md Context token size Size Estimated token count across all context files Recent event activity Events Last event timestamp (only when event logging is enabled)","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#output-format-human","level":4,"title":"Output Format (Human)","text":"
      ctx doctor\n==========\n\nStructure\n  ✓ Context initialized (.context/)\n  ✓ Required files present (4/4)\n\nQuality\n  ⚠ Drift: 2 warnings (stale path in ARCHITECTURE.md, high entry count in LEARNINGS.md)\n\nHooks\n  ✓ hooks.json valid (14 hooks registered)\n  ○ Event logging disabled (enable with event_log: true in .ctxrc)\n\nState\n  ✓ No pending reminders\n  ⚠ Task completion ratio high (18/22 = 82%): consider archiving\n\nSize\n  ✓ Context size: ~4200 tokens (budget: 8000)\n\nSummary: 2 warnings, 0 errors\n

      Status indicators:

      Icon Status Meaning ✓ ok Check passed ⚠ warning Non-critical issue worth fixing ✗ error Problem that needs attention ○ info Informational note","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#output-format-json","level":4,"title":"Output Format (JSON)","text":"
      {\n  \"results\": [\n    {\n      \"name\": \"context_initialized\",\n      \"category\": \"Structure\",\n      \"status\": \"ok\",\n      \"message\": \"Context initialized (.context/)\"\n    },\n    {\n      \"name\": \"required_files\",\n      \"category\": \"Structure\",\n      \"status\": \"ok\",\n      \"message\": \"Required files present (4/4)\"\n    },\n    {\n      \"name\": \"drift\",\n      \"category\": \"Quality\",\n      \"status\": \"warning\",\n      \"message\": \"Drift: 2 warnings\"\n    },\n    {\n      \"name\": \"event_logging\",\n      \"category\": \"Hooks\",\n      \"status\": \"info\",\n      \"message\": \"Event logging disabled (enable with event_log: true in .ctxrc)\"\n    },\n    {\n      \"name\": \"webhook\",\n      \"category\": \"Hooks\",\n      \"status\": \"ok\",\n      \"message\": \"Webhook configured\"\n    },\n    {\n      \"name\": \"reminders\",\n      \"category\": \"State\",\n      \"status\": \"ok\",\n      \"message\": \"No pending reminders\"\n    },\n    {\n      \"name\": \"task_completion\",\n      \"category\": \"State\",\n      \"status\": \"warning\",\n      \"message\": \"Tasks: 18/22 completed (82%): consider archiving with ctx task archive\"\n    },\n    {\n      \"name\": \"context_size\",\n      \"category\": \"Size\",\n      \"status\": \"ok\",\n      \"message\": \"Context size: ~4200 tokens (budget: 8000)\"\n    }\n  ],\n  \"warnings\": 2,\n  \"errors\": 0\n}\n

      Examples:

      # Quick structural health check\nctx doctor\n\n# Machine-readable output for scripting\nctx doctor --json\n\n# Count warnings\nctx doctor --json | jq '.warnings'\n\n# Check for errors only\nctx doctor --json | jq '[.results[] | select(.status == \"error\")]'\n
      ","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#when-to-use-what","level":4,"title":"When to Use What","text":"Tool When ctx status Quick glance at files, tokens, and drift ctx doctor Thorough structural checkup (hooks, config, events too) /ctx-doctor Agent-driven diagnosis with event log pattern analysis

      ctx status tells you what's there. ctx doctor tells you what's wrong. /ctx-doctor tells you why it's wrong and what to do about it.

      ","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#what-it-does-not-do","level":4,"title":"What It Does Not Do","text":"
      • No event pattern analysis: that's the /ctx-doctor skill's job
      • No auto-fixing: reports findings, doesn't modify anything
      • No external service checks: doesn't verify webhook endpoint availability

      See also: Troubleshooting | ctx hook event | /ctx-doctor skill | Detecting and Fixing Drift

      ","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/event/","level":1,"title":"Event","text":"","path":["Event"],"tags":[]},{"location":"cli/event/#ctx-hook-event","level":3,"title":"ctx hook event","text":"

      Query the local hook event log. Requires event_log: true in .ctxrc. Reads events from .context/state/events.jsonl and outputs them in a human-readable table or raw JSONL format.

      All filter flags combine with AND logic.

      ctx hook event [flags]\n

      Flags:

      Flag Description --hook Filter by hook name --session Filter by session ID --event Filter by event type (relay, nudge) --last Show last N events (default: 50) --json Output raw JSONL (for piping to jq) --all Include rotated log file

      Examples:

      ctx hook event                                        # recent events\nctx hook event --hook check-context-size --last 10    # one hook, last 10\nctx hook event --json | jq '.hook'                    # pipe to jq\nctx hook event --session abc123                       # filter by session\n
      ","path":["Event"],"tags":[]},{"location":"cli/guide/","level":1,"title":"Guide","text":"","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/guide/#ctx-guide","level":2,"title":"ctx guide","text":"

      Quick-reference cheat sheet for common ctx commands and skills.

      ctx guide [flags]\n

      Flags:

      Flag Description --skills Show available skills --commands Show available CLI commands

      Example:

      # Show the full cheat sheet\nctx guide\n\n# Skills only\nctx guide --skills\n\n# Commands only\nctx guide --commands\n

      Works without initialization (no .context/ required). Useful for a printable one-pager when onboarding to a project.

      ","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/hook/","level":1,"title":"Hook","text":"","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#ctx-hook","level":3,"title":"ctx hook","text":"

      Manage hook-related settings: messages, notifications, pause/resume, and event log.

      ctx hook <subcommand> [flags]\n
      ","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#subcommands","level":2,"title":"Subcommands","text":"Subcommand Description ctx hook message list Show all hook messages with override status ctx hook message show <h> <v> Print the effective message template ctx hook message edit <h> <v> Copy default to .context/ for editing ctx hook message reset <h> <v> Delete user override, revert to default ctx hook notify [message] Send a webhook notification ctx hook notify setup Configure and encrypt webhook URL ctx hook notify test Send a test notification ctx hook pause Pause all context hooks for this session ctx hook resume Resume paused context hooks ctx hook event Query the local hook event log","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#examples","level":2,"title":"Examples","text":"
      # View and manage hook messages\nctx hook message list\nctx hook message show qa-reminder gate\nctx hook message edit qa-reminder gate\n\n# Webhook notifications\nctx hook notify setup\nctx hook notify --event loop \"Loop completed\"\n\n# Pause/resume hooks\nctx hook pause\nctx hook resume\n\n# Browse event log\nctx hook event --last 20\nctx hook event --hook qa-reminder --json\n

      See also: Customizing Hook Messages | Webhook Notifications | Pausing Context Hooks | System Hooks Audit

      ","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hub/","level":1,"title":"Hub","text":"","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub","level":2,"title":"ctx hub","text":"

      Operator commands for a ctx Hub: the gRPC server that fans out decisions, learnings, conventions, and tasks across projects. Use ctx hub to start and stop the server, inspect cluster state, add or remove peers at runtime, and hand off leadership before maintenance.

      Who Needs This Page

      You only need ctx hub if you are running a hub server or cluster. For client-side operations (register, subscribe, sync, publish, listen), see ctx connect. For the mental model behind the hub as a whole, read the ctx Hub overview.

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-start","level":3,"title":"ctx hub start","text":"

      Start the hub gRPC server.

      Examples:

      ctx hub start                           # Foreground, default port 9900\nctx hub start --port 8080               # Custom port\nctx hub start --data-dir /srv/ctx-hub   # Custom data directory\n

      On first run, generates an admin token and prints it to stdout. Save this token; it's required for ctx connection register in client projects. Subsequent runs reuse the stored token from <data-dir>/admin.token.

      Default data directory: ~/.ctx/hub-data/

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#daemon-mode","level":4,"title":"Daemon Mode","text":"

      Run the hub as a detached background process:

      ctx hub start --daemon          # Fork to background\nctx hub stop                    # Graceful shutdown\n

      The daemon writes a PID file to <data-dir>/hub.pid. Stop the daemon with ctx hub stop (see below).

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#cluster-mode","level":4,"title":"Cluster Mode","text":"

      For high availability, run multiple hubs with Raft-based leader election:

      ctx hub start --port 9900 \\\n  --peers host2:9901,host3:9901\n

      Raft is used only for leader election. Data replication uses sequence-based gRPC sync on the append-only JSONL log; there is no multi-node consensus on writes. See the HA cluster recipe for the full setup and the Raft-lite durability caveat.

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#flags","level":4,"title":"Flags","text":"Flag Description Default --port Hub listen port 9900 --data-dir Hub data directory ~/.ctx/hub-data/ --daemon Run the hub server in the background false --peers Comma-separated peer addresses for cluster mode (none)","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#validation","level":4,"title":"Validation","text":"

      The hub validates every published entry before accepting it:

      • Type must be one of decision, learning, convention, task
      • ID and Origin are required and non-empty
      • Content size capped at 1 MB (text-only)
      • Duplicate project registration is rejected (one token per project)
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stop","level":3,"title":"ctx hub stop","text":"

      Stop a running hub daemon.

      Examples:

      ctx hub stop                            # Stop using default data dir\nctx hub stop --data-dir /srv/ctx-hub    # Custom data directory\n

      Sends SIGTERM to the PID recorded in <data-dir>/hub.pid, waits for in-flight RPCs to drain, and removes the PID file. Safe to rerun: if no daemon is running, returns a \"no running hub\" error without side effects.

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-status","level":3,"title":"ctx hub status","text":"

      Show cluster status: role, peers, sync state, entry count, and uptime.

      Examples:

      ctx hub status\n
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-peer","level":3,"title":"ctx hub peer","text":"

      Add or remove peers from the cluster at runtime. Useful for scaling up or replacing a decommissioned node without restarting the leader.

      Examples:

      ctx hub peer add host2:9901\nctx hub peer remove host2:9901\n
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stepdown","level":3,"title":"ctx hub stepdown","text":"

      Transfer leadership to another node gracefully. Triggers a new election among the remaining followers before the current leader steps down. Use before taking the leader offline for maintenance.

      Examples:

      ctx hub stepdown\n
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#see-also","level":3,"title":"See Also","text":"
      • ctx connect: client-side commands (register, subscribe, sync, publish, listen)
      • ctx Hub overview: mental model and user stories
      • ctx Hub: Getting Started
      • Hub operations: production deployment, backup, monitoring
      • Hub failure modes
      • Hub security model
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/init-status/","level":1,"title":"Init and Status","text":"","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-init","level":3,"title":"ctx init","text":"

      Initialize a new .context/ directory with template files.

      ctx init [flags]\n

      Flags:

      Flag Short Description --force -f Overwrite existing context files --minimal -m Only create essential files (TASKS.md, DECISIONS.md, CONSTITUTION.md) --merge Auto-merge ctx content into existing CLAUDE.md

      Creates:

      • .context/ directory with all template files
      • .claude/settings.local.json with pre-approved ctx permissions
      • CLAUDE.md with bootstrap instructions (or merges into existing)

      Claude Code hooks and skills are provided by the ctx plugin (see Integrations).

      Example:

      # Standard init\nctx init\n\n# Minimal setup (just core files)\nctx init --minimal\n\n# Force overwrite existing\nctx init --force\n\n# Merge into existing files\nctx init --merge\n

      After ctx init succeeds, the final output includes a hint showing the exact eval \"$(ctx activate)\" line to bind the new directory for your shell. Every other ctx command requires that binding (or an equivalent direct CTX_DIR=/abs/path/.context export) before it will run.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-activate","level":3,"title":"ctx activate","text":"

      Emit a shell-native export CTX_DIR=... line for the target .context/ directory. ctx does not search the filesystem during day-to-day commands: each one needs CTX_DIR set before it runs. activate is the convenience that figures out the path for you so you can bind it with one line.

      # Walk up from CWD, emit if exactly one candidate visible.\neval \"$(ctx activate)\"\n

      Flags:

      Flag Description --shell Shell dialect override. POSIX-family (bash, zsh, sh) all share one syntax today; the flag exists for future fish/nushell/powershell support. Auto-detected from $SHELL.

      Resolution:

      Candidate count from CWD Behavior Zero Error. Use ctx init to create one, or cd closer to the project root. One Emit export CTX_DIR=<path> for that candidate. Two or more Refuse. List every candidate. Re-run from a more specific cwd.

      activate is args-free under the single-source-anchor model; the explicit-path mode was removed because hub-client / hub-server scenarios store at ~/.ctx/hub-data/ and never read .context/, so they activate from the project root like everyone else. Direct binding without a project-local scan is still available via export CTX_DIR=/abs/path/.context or the inline form.

      If the parent shell already has CTX_DIR set to a different value, the output gains a leading # ctx: replacing stale CTX_DIR=... comment so the user sees the change in eval output before the replacement takes effect.

      See also: Activating a Context Directory for the full recipe including direnv setup and CI patterns.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-deactivate","level":3,"title":"ctx deactivate","text":"

      Emit a shell-native unset CTX_DIR line. Pairs with activate.

      eval \"$(ctx deactivate)\"\n

      Flags:

      Flag Description --shell Shell dialect override. POSIX-family (bash, zsh, sh) all share one unset syntax today; the flag exists for future fish/nushell/powershell support. Auto-detected from $SHELL.

      deactivate does not touch the filesystem, doesn't require a declared context directory, and never fails under normal operation; unsetting an already-unset variable is a no-op across supported shells.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-status","level":3,"title":"ctx status","text":"

      Show the current context summary.

      ctx status [flags]\n

      Flags:

      Flag Short Description --json Output as JSON --verbose -v Include file contents summary

      Output:

      • Context directory path
      • Total files and token estimate
      • Status of each file (loaded, empty, missing)
      • Recent activity (modification times)
      • Drift warnings if any

      Example:

      ctx status\nctx status --json\nctx status --verbose\n
      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-agent","level":3,"title":"ctx agent","text":"

      Print an AI-ready context packet optimized for LLM consumption.

      ctx agent [flags]\n

      Flags:

      Flag Default Description --budget 8000 Token budget: controls content selection and prioritization --format md Output format: md or json --cooldown 10m Suppress repeated output within this duration (requires --session) --session (none) Session ID for cooldown isolation (e.g., $PPID) --include-hub false Include hub entries from .context/hub/

      How budget works:

      The budget controls how much context is included. Entries are selected in priority tiers:

      1. Constitution: always included in full (inviolable rules)
      2. Tasks: all active tasks, up to 40% of budget
      3. Conventions: all conventions, up to 20% of budget
      4. Decisions: scored by recency and relevance to active tasks
      5. Learnings: scored by recency and relevance to active tasks
      6. Steering: applicable steering file bodies, scored by their inclusion mode and description match against the active prompt
      7. Skill: named skill content (from --skill)
      8. Hub: entries from .context/hub/ (with --include-hub, see ctx connect)

      Decisions and learnings are ranked by a combined score (how recent + how relevant to your current tasks). High-scoring entries are included with their full body. Entries that don't fit get title-only summaries in an \"Also Noted\" section. Superseded entries are excluded.

      Output Sections:

      Section Source Selection Read These Files all .context/ Non-empty files in priority order Constitution CONSTITUTION.md All rules (never truncated) Current Tasks TASKS.md All unchecked tasks (budget-capped) Key Conventions CONVENTIONS.md All items (budget-capped) Recent Decisions DECISIONS.md Full body, scored by relevance Key Learnings LEARNINGS.md Full body, scored by relevance Also Noted overflow Title-only summaries

      Example:

      # Default (8000 tokens, markdown)\nctx agent\n\n# Smaller packet for tight context windows\nctx agent --budget 4000\n\n# JSON format for programmatic use\nctx agent --format json\n\n# Pipe to file\nctx agent --budget 4000 > context.md\n\n# With cooldown (hooks/automation: requires --session)\nctx agent --session $PPID\n

      Use case: Copy-paste into AI chat, pipe to system prompt, or use in hooks.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-load","level":3,"title":"ctx load","text":"

      Load and display assembled context as AI would see it.

      ctx load [flags]\n

      Flags:

      Flag Description --budget <tokens> Token budget for assembly (default: 8000) --raw Output raw file contents without assembly

      Example:

      ctx load\nctx load --budget 16000\nctx load --raw\n
      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/journal/","level":1,"title":"Journal","text":"","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal","level":3,"title":"ctx journal","text":"

      Browse and search AI session history from Claude Code and other tools.

      ctx journal <subcommand>\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source","level":4,"title":"ctx journal source","text":"

      List all parsed sessions.

      ctx journal source [flags]\n

      Flags:

      Flag Short Description --limit -n Maximum sessions to display (default: 20) --project -p Filter by project name --tool -t Filter by tool (e.g., claude-code) --all-projects Include sessions from all projects

      Sessions are sorted by date (newest first) and display slug, project, start time, duration, turn count, and token usage.

      Example:

      ctx journal source\nctx journal source --limit 5\nctx journal source --project ctx\nctx journal source --tool claude-code\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source-show","level":4,"title":"ctx journal source --show","text":"

      Show details of a specific session.

      ctx journal source --show [session-id] [flags]\n

      Flags:

      Flag Description --latest Show the most recent session --full Show full message content --all-projects Search across all projects

      The session ID can be a full UUID, partial match, or session slug name.

      Example:

      ctx journal source --show abc123\nctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show --latest\nctx journal source --show --latest --full\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-import","level":4,"title":"ctx journal import","text":"

      Import sessions to editable journal files in .context/journal/.

      ctx journal import [session-id] [flags]\n

      Flags:

      Flag Description --all Import all sessions (only new files by default) --all-projects Import from all projects --regenerate Re-import existing files (preserves YAML frontmatter by default) --keep-frontmatter Preserve enriched YAML frontmatter during regeneration (default: true) --yes, -y Skip confirmation prompt --dry-run Show what would be imported without writing files

      Safe by default: --all only imports new sessions. Existing files are skipped. Use --regenerate to re-import existing files (conversation content is regenerated, YAML frontmatter from enrichment is preserved by default). Use --keep-frontmatter=false to discard enriched frontmatter during regeneration.

      Locked entries (via ctx journal lock) are always skipped, regardless of flags.

      Single-session import (ctx journal import <id>) always writes without prompting, since you are explicitly targeting one session.

      The journal/ directory should be gitignored (like sessions/) since it contains raw conversation data.

      Example:

      ctx journal import abc123                 # Import one session\nctx journal import --all                  # Import only new sessions\nctx journal import --all --dry-run        # Preview what would be imported\nctx journal import --all --regenerate     # Re-import existing (prompts)\nctx journal import --all --regenerate -y  # Re-import without prompting\nctx journal import --all --regenerate --keep-frontmatter=false -y  # Discard frontmatter\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-lock","level":4,"title":"ctx journal lock","text":"

      Protect journal entries from being overwritten by import --regenerate or modified by enrichment skills (/ctx-journal-enrich, /ctx-journal-enrich-all).

      ctx journal lock <pattern> [flags]\n

      Flags:

      Flag Description --all Lock all journal entries

      The pattern matches filenames by slug, date, or short ID. Locking a multi-part entry locks all parts. The lock is recorded in .context/journal/.state.json and a locked: true line is added to the file's YAML frontmatter for visibility.

      Example:

      ctx journal lock abc12345\nctx journal lock 2026-01-21-session-abc12345.md\nctx journal lock --all\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-unlock","level":4,"title":"ctx journal unlock","text":"

      Remove lock protection from journal entries.

      ctx journal unlock <pattern> [flags]\n

      Flags:

      Flag Description --all Unlock all journal entries

      Example:

      ctx journal unlock abc12345\nctx journal unlock --all\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-sync","level":4,"title":"ctx journal sync","text":"

      Sync lock state from journal frontmatter to .state.json.

      ctx journal sync\n

      Scans all journal markdowns and updates .state.json to match each file's frontmatter. Files with locked: true in frontmatter are marked locked in state; files without a locked: line have their lock cleared.

      This is the inverse of ctx journal lock: instead of state driving frontmatter, frontmatter drives state. Useful after batch enrichment where you add locked: true to frontmatter manually.

      Example:

      # After enriching entries and adding locked: true to frontmatter\nctx journal sync\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal_1","level":3,"title":"ctx journal","text":"

      Analyze and synthesize imported session files.

      ctx journal <subcommand>\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-site","level":4,"title":"ctx journal site","text":"

      Generate a static site from journal entries in .context/journal/.

      ctx journal site [flags]\n

      Flags:

      Flag Short Description --output -o Output directory (default: .context/journal-site) --build Run zensical build after generating --serve Run zensical serve after generating

      Creates a zensical-compatible site structure with an index page listing all sessions by date, and individual pages for each journal entry.

      Requires zensical to be installed for --build or --serve:

      pipx install zensical\n

      Example:

      ctx journal site                    # Generate in .context/journal-site/\nctx journal site --output ~/public  # Custom output directory\nctx journal site --build            # Generate and build HTML\nctx journal site --serve            # Generate and serve locally\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-obsidian","level":4,"title":"ctx journal obsidian","text":"

      Generate an Obsidian vault from journal entries in .context/journal/.

      ctx journal obsidian [flags]\n

      Flags:

      Flag Short Description --output -o Output directory (default: .context/journal-obsidian)

      Creates an Obsidian-compatible vault with:

      • Wikilinks ([[target|display]]) for all internal navigation
      • MOC pages (Map of Content) for topics, key files, and session types
      • Related sessions footer linking entries that share topics
      • Transformed frontmatter (topicstags for Obsidian integration)
      • Minimal .obsidian/ config enforcing wikilink mode

      No external dependencies are required: Open the output directory as an Obsidian vault directly.

      Example:

      ctx journal obsidian                        # Generate in .context/journal-obsidian/\nctx journal obsidian --output ~/vaults/ctx  # Custom output directory\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-check","level":4,"title":"ctx journal schema check","text":"

      Validate JSONL session files against the embedded schema and report drift.

      ctx journal schema check [flags]\n

      Flags:

      Flag Short Description --dir Directory to scan for JSONL files --all-projects Scan all Claude Code project directories --quiet -q Exit code only (0 = clean, 1 = drift)

      Scans JSONL files for unknown fields, missing required fields, unknown record types, and unknown content block types. When drift is found, writes a Markdown report to .context/reports/schema-drift.md. When drift resolves, the report is automatically deleted.

      Designed for interactive use, CI pipelines, and nightly cron jobs.

      Example:

      ctx journal schema check                    # Current project\nctx journal schema check --all-projects     # All projects\nctx journal schema check --quiet            # Exit code only\nctx journal schema check --dir /path/to     # Custom directory\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-dump","level":4,"title":"ctx journal schema dump","text":"

      Print the embedded JSONL schema definition.

      ctx journal schema dump\n

      Shows all known record types with their required and optional fields, and all recognized content block types with their parse status. Useful for inspecting what the schema validator expects.

      Example:

      ctx journal schema dump\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-serve","level":3,"title":"ctx serve","text":"

      Serve any zensical directory locally. This is a serve-only command: It does not generate or regenerate site content.

      ctx serve [directory]\n

      If no directory is specified, defaults to the journal site (.context/journal-site).

      Requires zensical to be installed:

      pipx install zensical\n

      ctx serve vs. ctx journal site --serve

      ctx journal site --serve generates the journal site then serves it: an all-in-one command. ctx serve only serves an existing directory, and works with any zensical site (journal, docs, etc.).

      Example:

      ctx serve                        # Serve journal site (no regeneration)\nctx serve .context/journal-site  # Same, explicit path\nctx serve ./site                 # Serve the docs site\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/loop/","level":1,"title":"Loop","text":"","path":["CLI","Integrations","Loop"],"tags":[]},{"location":"cli/loop/#ctx-loop","level":2,"title":"ctx loop","text":"

      Generate a shell script for running an autonomous loop.

      An autonomous loop continuously runs an AI assistant with the same prompt until a completion signal is detected, enabling iterative development where the AI builds on its previous work.

      ctx loop [flags]\n

      Flags:

      Flag Short Description Default --tool <tool> -t AI tool: claude, aider, or generic claude --prompt <file> -p Prompt file to use .context/loop.md --max-iterations <n> -n Maximum iterations (0 = unlimited) 0 --completion <signal> -c Completion signal to detect SYSTEM_CONVERGED --output <file> -o Output script filename loop.sh

      Examples:

      # Generate loop.sh for Claude Code\nctx loop\n\n# Generate for Aider with custom prompt\nctx loop --tool aider --prompt TASKS.md\n\n# Limit to 10 iterations\nctx loop --max-iterations 10\n\n# Output to custom file\nctx loop -o my-loop.sh\n

      Running the generated loop:

      ctx loop\nchmod +x loop.sh\n./loop.sh\n

      See also: Autonomous Loops for the full workflow.

      ","path":["CLI","Integrations","Loop"],"tags":[]},{"location":"cli/mcp/","level":1,"title":"MCP Server","text":"","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-mcp","level":2,"title":"ctx mcp","text":"

      Run ctx as a Model Context Protocol (MCP) server. MCP is a standard protocol that lets AI tools discover and consume context from external sources via JSON-RPC 2.0 over stdin/stdout.

      This makes ctx accessible to any MCP-compatible AI tool without custom hooks or integrations:

      • Claude Desktop
      • Cursor
      • Windsurf
      • VS Code Copilot
      • Any tool supporting MCP
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-mcp-serve","level":3,"title":"ctx mcp serve","text":"

      Start the MCP server. This command reads JSON-RPC 2.0 requests from stdin and writes responses to stdout. It is intended to be launched by MCP clients (Claude Desktop, Cursor, VS Code Copilot), not run directly from a shell. See Configuration below for how each host launches it.

      Flags: None. The server uses the declared context directory from CTX_DIR. As with every other ctx command, that variable must be set: the server does not walk the filesystem.

      Examples:

      # Normal invocation (by an MCP client via stdio transport)\nctx mcp serve\n\n# Pin a context directory for a specific workspace\nCTX_DIR=/path/to/project/.context ctx mcp serve\n\n# Verify the binary starts without a client attached (Ctrl-C to exit)\nctx mcp serve < /dev/null\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#configuration","level":2,"title":"Configuration","text":"","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#claude-desktop","level":3,"title":"Claude Desktop","text":"

      Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

      {\n  \"mcpServers\": {\n    \"ctx\": {\n      \"command\": \"ctx\",\n      \"args\": [\"mcp\", \"serve\"]\n    }\n  }\n}\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#cursor","level":3,"title":"Cursor","text":"

      Add to .cursor/mcp.json in your project:

      {\n  \"mcpServers\": {\n    \"ctx\": {\n      \"command\": \"ctx\",\n      \"args\": [\"mcp\", \"serve\"]\n    }\n  }\n}\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#vs-code-copilot","level":3,"title":"VS Code (Copilot)","text":"

      Add to .vscode/mcp.json:

      {\n  \"servers\": {\n    \"ctx\": {\n      \"command\": \"ctx\",\n      \"args\": [\"mcp\", \"serve\"]\n    }\n  }\n}\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resources","level":2,"title":"Resources","text":"

      Resources expose context files as read-only content. Each resource has a URI, name, and returns Markdown text.

      URI Name Description ctx://context/constitution constitution Hard rules that must never be violated ctx://context/tasks tasks Current work items and their status ctx://context/conventions conventions Code patterns and standards ctx://context/architecture architecture System architecture documentation ctx://context/decisions decisions Architectural decisions with rationale ctx://context/learnings learnings Gotchas, tips, and lessons learned ctx://context/glossary glossary Project-specific terminology ctx://context/agent agent All files assembled in priority read order

      The agent resource assembles all non-empty context files into a single Markdown document, ordered by the configured read priority.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resource-subscriptions","level":3,"title":"Resource Subscriptions","text":"

      Clients can subscribe to resource changes via resources/subscribe. The server polls for file mtime changes (default: 5 seconds) and emits notifications/resources/updated when a subscribed file changes on disk.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#tools","level":2,"title":"Tools","text":"

      Tools expose ctx commands as callable operations. Each tool accepts JSON arguments and returns text results.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_status","level":3,"title":"ctx_status","text":"

      Show context health: file count, token estimate, and per-file summary.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_add","level":3,"title":"ctx_add","text":"

      Add a task, decision, learning, or convention to the context.

      Argument Type Required Description type string Yes Entry type: task, decision, learning, convention content string Yes Title or main content priority string No Priority level (tasks only): high, medium, low context string Conditional Context field (decisions and learnings) rationale string Conditional Rationale (decisions only) consequence string Conditional Consequence (decisions only) lesson string Conditional Lesson learned (learnings only) application string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_complete","level":3,"title":"ctx_complete","text":"

      Mark a task as done by number or text match.

      Argument Type Required Description query string Yes Task number (e.g. \"1\") or search text","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_drift","level":3,"title":"ctx_drift","text":"

      Detect stale or invalid context. Returns violations, warnings, and passed checks.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_journal_source","level":3,"title":"ctx_journal_source","text":"

      Query recent AI session history (summaries, decisions, topics).

      Argument Type Required Description limit number No Max sessions to return (default: 5) since string No ISO date filter: sessions after this date (YYYY-MM-DD)

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_watch_update","level":3,"title":"ctx_watch_update","text":"

      Apply a structured context update to .context/ files. Supports task, decision, learning, convention, and complete entry types. Human confirmation is required before calling.

      Argument Type Required Description type string Yes Entry type: task, decision, learning, convention, complete content string Yes Main content context string Conditional Context background (decisions/learnings) rationale string Conditional Rationale (decisions only) consequence string Conditional Consequence (decisions only) lesson string Conditional Lesson learned (learnings only) application string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_compact","level":3,"title":"ctx_compact","text":"

      Move completed tasks to the archive section and remove empty sections from context files. Human confirmation required.

      Argument Type Required Description archive boolean No Also write tasks to .context/archive/ (default: false)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_next","level":3,"title":"ctx_next","text":"

      Suggest the next pending task based on priority and position.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_check_task_completion","level":3,"title":"ctx_check_task_completion","text":"

      Advisory check: after a write operation, detect if any pending tasks were silently completed. Returns nudge text if a match is found.

      Argument Type Required Description recent_action string No Brief description of what was just done

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_event","level":3,"title":"ctx_session_event","text":"

      Signal a session lifecycle event. Type end triggers the session-end persistence ceremony - human confirmation required.

      Argument Type Required Description type string Yes Event type: start, end caller string No Caller identifier (cursor, windsurf, vscode, claude-desktop)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_steering_get","level":3,"title":"ctx_steering_get","text":"

      Retrieve applicable steering files for a prompt. Without a prompt, returns always-included files only.

      Argument Type Required Description prompt string No Prompt text to match against steering file descriptions

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_search","level":3,"title":"ctx_search","text":"

      Search across .context/ files for a query string. Returns matching lines with file paths and line numbers.

      Argument Type Required Description query string Yes Search string to match against

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_start","level":3,"title":"ctx_session_start","text":"

      Execute session-start hooks and return aggregated context from hook outputs.

      Arguments: None.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_end","level":3,"title":"ctx_session_end","text":"

      Execute session-end hooks with an optional summary. Returns aggregated context from hook outputs.

      Argument Type Required Description summary string No Session summary passed to hook scripts","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_remind","level":3,"title":"ctx_remind","text":"

      List pending session-scoped reminders.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#prompts","level":2,"title":"Prompts","text":"

      Prompts provide pre-built templates for common workflows. Clients can list available prompts via prompts/list and retrieve a specific prompt via prompts/get.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-session-start","level":3,"title":"ctx-session-start","text":"

      Load full context at the beginning of a session. Returns all context files assembled in priority read order with session orientation instructions.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-decision-add","level":3,"title":"ctx-decision-add","text":"

      Format an architectural decision entry with all required fields.

      Argument Type Required Description content string Yes Decision title context string Yes Background context rationale string Yes Why this decision was made consequence string Yes Expected consequence","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-learning-add","level":3,"title":"ctx-learning-add","text":"

      Format a learning entry with all required fields.

      Argument Type Required Description content string Yes Learning title context string Yes Background context lesson string Yes The lesson learned application string Yes How to apply this lesson","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-reflect","level":3,"title":"ctx-reflect","text":"

      Guide end-of-session reflection. Returns a structured review prompt covering progress assessment and context update recommendations.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-checkpoint","level":3,"title":"ctx-checkpoint","text":"

      Report session statistics: tool calls made, entries added, and pending updates queued during the current session.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/memory/","level":1,"title":"Memory","text":"","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory","level":2,"title":"ctx memory","text":"

      Bridge Claude Code's auto memory (MEMORY.md) into .context/.

      Claude Code maintains per-project auto memory at ~/.claude/projects/<slug>/memory/MEMORY.md. This command group discovers that file, mirrors it into .context/memory/mirror.md (git-tracked), and detects drift.

      ctx memory <subcommand>\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-sync","level":3,"title":"ctx memory sync","text":"

      Copy MEMORY.md to .context/memory/mirror.md. Archives the previous mirror before overwriting.

      ctx memory sync [flags]\n

      Flags:

      Flag Description --dry-run Show what would happen without writing

      Exit codes:

      Code Meaning 0 Synced successfully 1 MEMORY.md not found (auto memory inactive)

      Examples:

      ctx memory sync\n# Archived previous mirror to mirror-2026-03-05-143022.md\n# Synced MEMORY.md -> .context/memory/mirror.md\n#   Source: ~/.claude/projects/-home-user-project/memory/MEMORY.md\n#   Lines: 47 (was 32)\n#   New content: 15 lines since last sync\n\nctx memory sync --dry-run\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-status","level":3,"title":"ctx memory status","text":"

      Show drift, timestamps, line counts, and archive count.

      ctx memory status\n

      Exit codes:

      Code Meaning 0 No drift 1 MEMORY.md not found 2 Drift detected (MEMORY.md changed since sync)

      Examples:

      ctx memory status\n# Memory Bridge Status\n#   Source:      ~/.claude/projects/.../memory/MEMORY.md\n#   Mirror:      .context/memory/mirror.md\n#   Last sync:   2026-03-05 14:30 (2 hours ago)\n#\n#   MEMORY.md:  47 lines (modified since last sync)\n#   Mirror:     32 lines\n#   Drift:      detected (source is newer)\n#   Archives:   3 snapshots in .context/memory/archive/\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-diff","level":3,"title":"ctx memory diff","text":"

      Show what changed in MEMORY.md since last sync.

      ctx memory diff\n

      Examples:

      ctx memory diff\n# --- .context/memory/mirror.md (mirror)\n# +++ ~/.claude/projects/.../memory/MEMORY.md (source)\n# +- new learning: memory bridge works\n

      No output when files are identical.

      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-publish","level":3,"title":"ctx memory publish","text":"

      Push curated .context/ content into MEMORY.md so the agent sees it natively.

      ctx memory publish [flags]\n

      Content is selected in priority order: pending tasks, recent decisions (7 days), key conventions, recent learnings (7 days). Wrapped in <!-- ctx:published --> markers. Claude-owned content outside the markers is preserved.

      Flags:

      Flag Description Default --budget Line budget for published content 80 --dry-run Show what would be published

      Examples:

      ctx memory publish --dry-run\n# Publishing .context/ -> MEMORY.md...\n#   Budget: 80 lines\n#   Published block:\n#     5 pending tasks (from TASKS.md)\n#     3 recent decisions (from DECISIONS.md)\n#     5 key conventions (from CONVENTIONS.md)\n#   Total: 42 lines (within 80-line budget)\n# Dry run - no files written.\n\nctx memory publish              # Write to MEMORY.md\nctx memory publish --budget 40  # Tighter budget\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-unpublish","level":3,"title":"ctx memory unpublish","text":"

      Remove the ctx-managed marker block from MEMORY.md, preserving Claude-owned content.

      Examples:

      ctx memory unpublish\n

      Hook integration: The check-memory-drift hook runs on every prompt and nudges the agent when MEMORY.md has changed since last sync. The nudge fires once per session. See Memory Bridge.

      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-import","level":3,"title":"ctx memory import","text":"

      Classify and promote entries from MEMORY.md into structured .context/ files.

      ctx memory import [flags]\n

      Each entry is classified by keyword heuristics:

      Keywords Target always use, prefer, never use, standard CONVENTIONS.md decided, chose, trade-off, approach DECISIONS.md gotcha, learned, watch out, bug, caveat LEARNINGS.md todo, need to, follow up TASKS.md Everything else Skipped

      Deduplication prevents re-importing the same entry across runs.

      Flags:

      Flag Description --dry-run Show classification plan without writing

      Examples:

      ctx memory import --dry-run\n# Scanning MEMORY.md for new entries...\n#   Found 6 entries\n#\n#   -> \"always use ctx from PATH\"\n#      Classified: CONVENTIONS.md (keywords: always use)\n#\n#   -> \"decided to use heuristic classification over LLM-based\"\n#      Classified: DECISIONS.md (keywords: decided)\n#\n# Dry run - would import: 4 entries\n# Skipped: 2 entries (session notes/unclassified)\n\nctx memory import    # Actually write entries to .context/ files\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/message/","level":1,"title":"Message","text":"","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message","level":3,"title":"ctx hook message","text":"

      Manage hook message templates.

      Hook messages control the text hooks emit. The hook logic (when to fire, counting, state tracking) is universal; the messages are opinions that can be customized per-project.

      ctx hook message <subcommand>\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-list","level":3,"title":"ctx hook message list","text":"

      Show all hook messages with category and override status.

      ctx hook message list [--json]\n

      Flags:

      Flag Description --json Output in JSON format

      Example:

      ctx hook message list\nctx hook message list --json | jq '.[] | select(.override)'\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-show","level":3,"title":"ctx hook message show","text":"

      Print the effective message template for a hook/variant pair. Shows the user override if present, otherwise the embedded default.

      ctx hook message show <hook> <variant>\n

      Example:

      ctx hook message show qa-reminder gate\nctx hook message show check-context-size checkpoint\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-edit","level":3,"title":"ctx hook message edit","text":"

      Copy the embedded default template for <hook> <variant> to .context/hooks/messages/<hook>/<variant>.txt so you can edit it directly. The override takes effect the next time the hook fires.

      ctx hook message edit <hook> <variant>\n

      If an override already exists, the command fails and directs you to edit it in place or reset it first.

      Example:

      ctx hook message edit qa-reminder gate\n# Edit .context/hooks/messages/qa-reminder/gate.txt in your editor\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-reset","level":3,"title":"ctx hook message reset","text":"

      Delete a user override and revert to the embedded default. Silent no-op if no override exists.

      ctx hook message reset <hook> <variant>\n

      Example:

      ctx hook message reset qa-reminder gate\n

      See Customizing hook messages for the full workflow.

      ","path":["Message"],"tags":[]},{"location":"cli/notify/","level":1,"title":"Notify","text":"","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify","level":2,"title":"ctx hook notify","text":"

      Send fire-and-forget webhook notifications from skills, loops, and hooks.

      ctx hook notify --event <name> [--session-id <id>] \"message\"\n

      Flags:

      Flag Short Description --event -e Event name (required) --session-id -s Session ID (optional)

      Behavior:

      • No webhook configured: silent no-op (exit 0)
      • Webhook set but event not in events list: silent no-op (exit 0)
      • Webhook set and event matches: fire-and-forget HTTP POST
      • HTTP errors silently ignored (no retry)

      Examples:

      ctx hook notify --event loop \"Loop completed after 5 iterations\"\nctx hook notify -e nudge -s session-abc \"Context checkpoint at prompt #20\"\n
      ","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-setup","level":3,"title":"ctx hook notify setup","text":"

      Configure the webhook URL interactively. The URL is encrypted with AES-256-GCM using the encryption key and stored in .context/.notify.enc.

      Examples:

      ctx hook notify setup\n

      The encrypted file is safe to commit. The key (~/.ctx/.ctx.key) lives outside the project and is never committed.

      ","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-test","level":3,"title":"ctx hook notify test","text":"

      Send a test notification and report the HTTP response status.

      Examples:

      ctx hook notify test\n

      Payload format (JSON POST):

      {\n  \"event\": \"loop\",\n  \"message\": \"Loop completed after 5 iterations\",\n  \"session_id\": \"abc123-...\",\n  \"timestamp\": \"2026-02-22T14:30:00Z\",\n  \"project\": \"ctx\"\n}\n
      Field Type Description event string Event name from --event flag message string Notification message session_id string Session ID (omitted if empty) timestamp string UTC RFC3339 timestamp project string Project directory name

      See also: Webhook Notifications recipe.

      ","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/pad/","level":1,"title":"Scratchpad","text":"","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad","level":2,"title":"ctx pad","text":"

      Encrypted scratchpad for sensitive one-liners that travel with the project.

      When invoked without a subcommand, lists all entries.

      ctx pad\nctx pad <subcommand>\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-add","level":3,"title":"ctx pad add","text":"

      Append a new entry to the scratchpad.

      ctx pad add <text>\nctx pad add <label> --file <path>\n

      Flags:

      Flag Short Description --file -f Ingest a file as a blob entry (max 64 KB)

      Examples:

      ctx pad add \"DATABASE_URL=postgres://user:pass@host/db\"\nctx pad add \"deploy config\" --file ./deploy.yaml\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-show","level":3,"title":"ctx pad show","text":"

      Output the raw text of an entry by number. For blob entries, prints decoded file content (or writes to disk with --out).

      ctx pad show <n>\nctx pad show <n> --out <path>\n

      Arguments:

      • n: 1-based entry number

      Flags:

      Flag Description --out Write decoded blob content to a file (blobs only)

      Examples:

      ctx pad show 3\nctx pad show 2 --out ./recovered.yaml\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-rm","level":3,"title":"ctx pad rm","text":"

      Remove one or more entries by stable ID. Supports individual IDs and ranges.

      ctx pad rm <id> [id...]\n

      Arguments:

      • id: One or more entry IDs (e.g., 3, 1 4, 3-5)

      Examples:

      ctx pad rm 2\nctx pad rm 1 4\nctx pad rm 3-5\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-normalize","level":3,"title":"ctx pad normalize","text":"

      Reassign entry IDs as a contiguous sequence 1..N, closing any gaps left by deletions.

      Examples:

      ctx pad normalize\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-edit","level":3,"title":"ctx pad edit","text":"

      Replace, append to, or prepend to an entry.

      ctx pad edit <n> [text]\n

      Arguments:

      • n: 1-based entry number
      • text: Replacement text (mutually exclusive with --append/--prepend)

      Flags:

      Flag Description --append Append text to the end of the entry --prepend Prepend text to the beginning of entry --file Replace blob file content (preserves label) --label Replace blob label (preserves content)

      Examples:

      ctx pad edit 2 \"new text\"\nctx pad edit 2 --append \" suffix\"\nctx pad edit 2 --prepend \"prefix \"\nctx pad edit 1 --file ./v2.yaml\nctx pad edit 1 --label \"new name\"\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-mv","level":3,"title":"ctx pad mv","text":"

      Move an entry from one position to another.

      ctx pad mv <from> <to>\n

      Arguments:

      • from: Source position (1-based)
      • to: Destination position (1-based)

      Examples:

      ctx pad mv 3 1      # promote entry 3 to the top\nctx pad mv 1 5      # bury entry 1 to position 5\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-resolve","level":3,"title":"ctx pad resolve","text":"

      Show both sides of a merge conflict in the encrypted scratchpad.

      Examples:

      ctx pad resolve\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-import","level":3,"title":"ctx pad import","text":"

      Bulk-import lines from a file into the scratchpad. Each non-empty line becomes a separate entry. All entries are written in a single encrypt/write cycle.

      With --blob, import all first-level files from a directory as blob entries. Each file becomes a blob with the filename as its label. Subdirectories and non-regular files are skipped.

      ctx pad import <file>\nctx pad import -              # read from stdin\nctx pad import --blob <dir>   # import directory files as blobs\n

      Arguments:

      • file: Path to a text file, - for stdin, or a directory (with --blob)

      Flags:

      Flag Description --blob Import first-level files from a directory as blobs

      Examples:

      ctx pad import notes.txt\ngrep TODO *.go | ctx pad import -\nctx pad import --blob ./ideas/\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-export","level":3,"title":"ctx pad export","text":"

      Export all blob entries from the scratchpad to a directory as files. Each blob's label becomes the filename. Non-blob entries are skipped.

      ctx pad export [dir]\n

      Arguments:

      • dir: Target directory (default: current directory)

      Flags:

      Flag Short Description --force -f Overwrite existing files instead of timestamping --dry-run Print what would be exported without writing

      When a file already exists, a unix timestamp is prepended to avoid collisions (e.g., 1739836200-label). Use --force to overwrite instead.

      Examples:

      ctx pad export ./ideas\nctx pad export --dry-run\nctx pad export --force ./backup\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-merge","level":3,"title":"ctx pad merge","text":"

      Merge entries from one or more scratchpad files into the current pad. Each input file is auto-detected as encrypted or plaintext. Entries are deduplicated by exact content.

      ctx pad merge FILE...\n

      Arguments:

      • FILE...: One or more scratchpad files to merge (encrypted or plaintext)

      Flags:

      Flag Short Description --key -k Path to key file for decrypting input files --dry-run Print what would be merged without writing

      Examples:

      ctx pad merge worktree/.context/scratchpad.enc\nctx pad merge notes.md backup.enc\nctx pad merge --key /path/to/other.key foreign.enc\nctx pad merge --dry-run pad-a.enc pad-b.md\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pause/","level":1,"title":"Pause","text":"","path":["CLI","Sessions","Pause"],"tags":[]},{"location":"cli/pause/#ctx-hook-pause","level":2,"title":"ctx hook pause","text":"

      Pause all context nudge and reminder hooks for the current session. Security hooks (dangerous command blocking) and housekeeping hooks still fire.

      ctx hook pause [flags]\n

      Flags:

      Flag Description --session-id Session ID (overrides stdin)

      Example:

      # Pause hooks for a quick investigation\nctx hook pause\n\n# Resume when ready\nctx hook resume\n

      See also:

      • ctx hook resume: the matching resume command
      • Pausing Context Hooks recipe
      ","path":["CLI","Sessions","Pause"],"tags":[]},{"location":"cli/prune/","level":1,"title":"Prune","text":"","path":["CLI","Runtime","Prune"],"tags":[]},{"location":"cli/prune/#ctx-prune","level":3,"title":"ctx prune","text":"

      Remove per-session state files from .context/state/ that are older than the specified age. Session state files are identified by UUID suffixes (context-check-<session-id>, heartbeat-<session-id>, and similar). Global files without session IDs (events.jsonl, memory-import.json, and other non-per-session markers) are always preserved.

      ctx prune [flags]\n

      Flags:

      Flag Description --days Prune files older than this many days (default: 7) --dry-run Show what would be pruned without deleting

      Examples:

      ctx prune                 # Prune files older than 7 days\nctx prune --days 3        # Prune files older than 3 days\nctx prune --dry-run       # Preview without deleting\n

      See State maintenance for the recommended cadence and automation recipe.

      ","path":["CLI","Runtime","Prune"],"tags":[]},{"location":"cli/remind/","level":1,"title":"Remind","text":"","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind","level":2,"title":"ctx remind","text":"

      Session-scoped reminders that surface at session start. Reminders are stored verbatim and relayed verbatim: no summarization, no categories.

      When invoked with a text argument and no subcommand, adds a reminder.

      ctx remind \"text\"\nctx remind <subcommand>\n
      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-add","level":3,"title":"ctx remind add","text":"

      Add a reminder. This is the default action: ctx remind \"text\" and ctx remind add \"text\" are equivalent.

      ctx remind \"refactor the swagger definitions\"\nctx remind add \"check CI after the deploy\" --after 2026-02-25\n

      Arguments:

      • text: The reminder message (verbatim)

      Flags:

      Flag Short Description --after -a Don't surface until this date (YYYY-MM-DD)

      Examples:

      ctx remind \"refactor the swagger definitions\"\nctx remind \"check CI after the deploy\" --after 2026-02-25\n
      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-list","level":3,"title":"ctx remind list","text":"

      List all pending reminders. Date-gated reminders that aren't yet due are annotated with (after DATE, not yet due).

      Examples:

      ctx remind list\nctx remind ls            # alias\n

      Aliases: ls

      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-dismiss","level":3,"title":"ctx remind dismiss","text":"

      Remove one or more reminders by ID, or remove all with --all. Supports individual IDs and ranges.

      ctx remind dismiss <id> [id...]\nctx remind dismiss --all\n

      Arguments:

      • id: One or more reminder IDs (e.g., 3, 3 5-7)

      Flags:

      Flag Description --all Dismiss all reminders

      Aliases: rm

      Examples:

      ctx remind dismiss 3\nctx remind dismiss 3 5-7\nctx remind dismiss --all\n
      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-normalize","level":3,"title":"ctx remind normalize","text":"

      Reassign reminder IDs as a contiguous sequence 1..N, closing any gaps left by dismissals.

      Examples:

      ctx remind normalize\n

      See also: Session Reminders recipe.

      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/resume/","level":1,"title":"Resume","text":"","path":["CLI","Sessions","Resume"],"tags":[]},{"location":"cli/resume/#ctx-hook-resume","level":2,"title":"ctx hook resume","text":"

      Resume context hooks after a pause. Silent no-op if not paused.

      ctx hook resume [flags]\n

      Flags:

      Flag Description --session-id Session ID (overrides stdin)

      Example:

      ctx hook resume\n

      See also:

      • ctx hook pause: the matching pause command
      • Pausing Context Hooks recipe
      ","path":["CLI","Sessions","Resume"],"tags":[]},{"location":"cli/serve/","level":1,"title":"Serve","text":"","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#ctx-serve","level":2,"title":"ctx serve","text":"

      Serve a static site locally via zensical.

      With no argument, serves the journal site at .context/journal-site. With a directory argument, serves that directory if it contains a zensical.toml.

      ctx serve                             # Serve .context/journal-site\nctx serve ./my-site                   # Serve a specific directory\nctx serve ./docs                      # Serve any zensical site\n

      This Command Does NOT Start a Hub

      ctx serve is purely for static-site serving. To run a ctx Hub for cross-project knowledge sharing, use ctx hub start. That command lives in its own group because the hub is a gRPC server, not a static site.

      Requires zensical to be installed:

      pipx install zensical\n
      ","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#arguments","level":3,"title":"Arguments","text":"Argument Description [directory] Directory containing a zensical.toml to serve

      When omitted, serves .context/journal-site by default, the directory produced by ctx journal site.

      Examples:

      ctx serve                         # Default: serve .context/journal-site\nctx serve ./my-site               # Serve a specific directory\nctx serve ./docs                  # Serve any zensical site\n
      ","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#see-also","level":3,"title":"See Also","text":"
      • ctx journal: generate the journal site that ctx serve displays.
      • ctx hub start: for running a ctx Hub server, not a static site.
      • Browsing and enriching past sessions: the recipe that combines ctx journal and ctx serve.
      ","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/setup/","level":1,"title":"Setup","text":"","path":["CLI","Integrations","Setup"],"tags":[]},{"location":"cli/setup/#ctx-setup","level":2,"title":"ctx setup","text":"

      Generate AI tool integration configuration.

      ctx setup <tool> [flags]\n

      Flags:

      Flag Short Description --write -w Write the generated config to disk (e.g. .github/copilot-instructions.md)

      Supported tools:

      Tool Description claude-code Redirects to plugin install instructions cursor Cursor IDE kiro Kiro IDE cline Cline (VS Code extension) aider Aider CLI copilot GitHub Copilot windsurf Windsurf IDE

      Claude Code Uses the Plugin System

      Claude Code integration is now provided via the ctx plugin. Running ctx setup claude-code prints plugin install instructions.

      Examples:

      # Print hook instructions to stdout\nctx setup cursor\nctx setup aider\n\n# Generate and write .github/copilot-instructions.md\nctx setup copilot --write\n\n# Generate MCP config and sync steering files\nctx setup kiro --write\nctx setup cursor --write\nctx setup cline --write\n
      ","path":["CLI","Integrations","Setup"],"tags":[]},{"location":"cli/site/","level":1,"title":"Site","text":"","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/site/#ctx-site","level":2,"title":"ctx site","text":"

      Site management commands for the ctx.ist static site.

      ctx site <subcommand>\n
      ","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/site/#ctx-site-feed","level":3,"title":"ctx site feed","text":"

      Generate an Atom 1.0 feed from finalized blog posts in docs/blog/.

      ctx site feed [flags]\n

      Scans docs/blog/ for files matching YYYY-MM-DD-*.md, parses YAML frontmatter, and generates a valid Atom feed. Only posts with reviewed_and_finalized: true are included. Summaries are extracted from the first paragraph after the heading.

      Flags:

      Flag Short Type Default Description --out -o string site/feed.xml Output path --base-url string https://ctx.ist Base URL for entry links

      Output:

      Generated site/feed.xml (21 entries)\n\nSkipped:\n  2026-02-25-the-homework-problem.md: not finalized\n\nWarnings:\n  2026-02-09-defense-in-depth.md: no summary paragraph found\n

      Three buckets: included (count), skipped (with reason), warnings (included but degraded). exit 0 always: warnings inform but do not block.

      Frontmatter requirements:

      Field Required Feed mapping title Yes <title> date Yes <updated> reviewed_and_finalized Yes Draft gate (must be true) author No <author><name> topics No <category term=\"\">

      Examples:

      ctx site feed                                # Generate site/feed.xml\nctx site feed --out /tmp/feed.xml            # Custom output path\nctx site feed --base-url https://example.com # Custom base URL\nmake site-feed                               # Makefile shortcut\nmake site                                    # Builds site + feed\n
      ","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/skill/","level":1,"title":"Skill","text":"","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill","level":2,"title":"ctx skill","text":"

      Manage reusable instruction bundles that can be installed into .context/skills/.

      A skill is a directory containing a SKILL.md file with YAML frontmatter (name, description) and a Markdown instruction body. Skills are loaded by the agent context packet when --skill <name> is passed to ctx agent.

      ctx skill <subcommand>\n
      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-install","level":3,"title":"ctx skill install","text":"

      Install a skill from a source directory.

      ctx skill install <source>\n

      Arguments:

      • source: Path to a directory containing SKILL.md

      Examples:

      ctx skill install ./my-skills/code-review\n# Installed code-review → .context/skills/code-review\n
      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-list","level":3,"title":"ctx skill list","text":"

      List all installed skills.

      Examples:

      ctx skill list\n
      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-remove","level":3,"title":"ctx skill remove","text":"

      Remove an installed skill.

      Arguments:

      • name: Skill name to remove

      Examples:

      ctx skill remove code-review\n

      See also: Building Project Skills recipe.

      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/steering/","level":1,"title":"Steering","text":"","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering","level":2,"title":"ctx steering","text":"

      Manage steering files: persistent behavioral rules for AI coding assistants.

      A steering file is a small markdown document with YAML frontmatter that tells the AI how to behave in a specific context. ctx steering keeps those files in .context/steering/, decides which ones apply for a given prompt, and syncs them out to each AI tool's native format (Claude Code, Cursor, Kiro, Cline).

      ctx steering <subcommand>\n

      Steering vs Decisions vs Conventions

      The three look similar on disk but serve different purposes:

      • Decisions record what was chosen and why. Consumed mostly by humans (and by the agent via ctx agent).
      • Conventions describe how the codebase is written. Consumed as reference material.
      • Steering tells the AI how to behave when asked about X. Consumed by the AI tool's prompt injection layer, conditionally on prompt match.

      If you find yourself writing \"the AI should always do X\", that belongs in steering, not decisions.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#anatomy-of-a-steering-file","level":3,"title":"Anatomy of a Steering File","text":"
      ---\nname: security\ndescription: Security rules for all code changes\ninclusion: always    # always | auto | manual\ntools: []            # empty = all tools\npriority: 10         # lower = injected first\n---\n\n# Security rules\n\n- Validate all user input at system boundaries.\n- Never log secrets, tokens, or credentials.\n- Prefer constant-time comparison for tokens.\n

      Inclusion modes:

      Mode When it's included always Every prompt, unconditionally auto When the prompt matches the description keywords manual Only when the user names it explicitly

      Priority: lower numbers inject first, so high-priority rules appear at the top of the prompt. Default is 50.

      Tools: an empty list means all configured tools receive the file; list specific tool names to scope it.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-init","level":3,"title":"ctx steering init","text":"

      Create a starter set of steering files in .context/steering/ to use as a scaffolding baseline.

      Examples:

      ctx steering init\n
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-add","level":3,"title":"ctx steering add","text":"

      Create a new steering file with default frontmatter.

      ctx steering add <name>\n

      Arguments:

      • name: Steering file name (without .md extension)

      Examples:

      ctx steering add security\n# Created .context/steering/security.md\n

      The generated file uses inclusion: manual and priority: 50 by default. Edit the frontmatter to change behavior.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-list","level":3,"title":"ctx steering list","text":"

      List all steering files with their inclusion mode, priority, and tool scoping.

      Examples:

      ctx steering list\n
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-preview","level":3,"title":"ctx steering preview","text":"

      Preview which steering files would be included for a given prompt. Useful for validating auto-inclusion descriptions against realistic prompts.

      ctx steering preview [prompt]\n

      Examples:

      ctx steering preview \"create a REST API endpoint\"\n# Steering files matching prompt \"create a REST API endpoint\":\n#   api-standards        inclusion=auto     priority=20  tools=all\n#   security             inclusion=always   priority=10  tools=all\n
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-sync","level":3,"title":"ctx steering sync","text":"

      Sync steering files to tool-native formats for tools that have a built-in rules primitive. Not every tool needs this; Claude Code and Codex use a different delivery mechanism (see below).

      Examples:

      ctx steering sync\n

      Which tools are sync targets?

      Tool Sync target Mechanism Cursor .cursor/rules/ Cursor reads the directory natively Cline .clinerules/ Cline reads the directory natively Kiro .kiro/steering/ Kiro reads the directory natively Claude Code (no-op) Delivered via hook + MCP (see next section) Codex (no-op) Same as Claude Code

      For the three native-rules tools, ctx steering sync writes each matching steering file to the appropriate directory with tool-specific frontmatter transforms. Unchanged files are skipped (idempotent).

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#how-claude-code-and-codex-consume-steering","level":3,"title":"How Claude Code and Codex Consume Steering","text":"

      Claude Code has no native \"steering files\" primitive, so ctx steering sync skips it entirely. Instead, steering reaches Claude through two non-sync channels, both activated by ctx setup claude-code (which installs the plugin):

      1. Automatic injection via the PreToolUse hook. The Claude Code plugin wires a PreToolUse hook that runs ctx agent --budget 8000 before each tool call. ctx agent loads .context/steering/ and calls steering.Filter with an empty prompt, so only files with inclusion: always match. Those files are included as Tier 6 of the context packet. The packet is printed on stdout, which Claude Code injects as additional context. This fires on every tool call; no user action.

      2. On-demand MCP tool call (ctx_steering_get). The ctx plugin ships a .mcp.json file that automatically registers the ctx MCP server (ctx mcp serve) with Claude Code on plugin install. Once registered, Claude can invoke the ctx_steering_get tool mid-task to fetch matching steering files for a specific prompt. This is the only path that resolves inclusion: auto and inclusion: manual matches for Claude Code; Claude passes the prompt to the MCP tool, which runs the keyword match against each file's description.

      Verify the MCP server is registered:

      claude mcp list\n

      Expected line: ctx: ctx mcp serve - ✓ Connected. If it's missing, reinstall the plugin from Claude Code (/plugin → find ctx → uninstall → install again); older plugin versions shipped without the .mcp.json file.

      Prefer inclusion: always for Claude Code

      Because the PreToolUse hook passes an empty prompt to ctx agent, only always files fire automatically. auto files require Claude to call the ctx_steering_get MCP tool on its own; manual files require an explicit user invocation. For rules that should reliably fire on every Claude Code session, use inclusion: always. Reserve auto/manual for situational libraries where the opt-in cost is acceptable and you understand Claude may not pull them in without prompting.

      The foundation files scaffolded by ctx init already default to inclusion: always for this reason.

      Practical implications:

      • Running ctx steering sync before starting a Claude session does nothing for Claude's benefit. Skip it.
      • ctx steering preview still works for validating your descriptions; it doesn't depend on sync.
      • If Claude Code is your only tool, the ctx steering commands you care about are add, list, preview, init (never sync).
      • If you use both Claude Code and (say) Cursor, ctx steering sync covers Cursor (where auto and manual work natively) while the hook+MCP pipeline covers Claude Code. For rules you need to fire automatically on both, use inclusion: always.
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-agent-integration","level":3,"title":"ctx agent Integration","text":"

      When ctx agent builds a context packet, steering files are loaded as Tier 6 of the budget-aware assembly (see ctx agent). Files with inclusion: always are always included; auto files are scored against the current prompt and included in priority order until the tier budget is exhausted.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#see-also","level":3,"title":"See Also","text":"
      • ctx setup: configure which tools receive steering syncs
      • ctx trigger: lifecycle scripts (a different hooking concept, see below)
      • Building steering files recipe: walkthrough from first file to synced output
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/sysinfo/","level":1,"title":"Sysinfo","text":"","path":["CLI","Diagnostics","Sysinfo"],"tags":[]},{"location":"cli/sysinfo/#ctx-sysinfo","level":3,"title":"ctx sysinfo","text":"

      Display a snapshot of system resources (memory, swap, disk, load) with threshold-based alert severities. Mirrors what the check-resource hook plumbing monitors in the background, but this command prints the full report at any severity level, not only at DANGER.

      ctx sysinfo [flags]\n

      Flags:

      Flag Description --json Output in JSON format

      Alert thresholds:

      Resource WARNING DANGER Memory ≥ 75% ≥ 90% Swap ≥ 50% ≥ 75% Disk ≥ 85% ≥ 95% Load ≥ 1.0x CPUs ≥ 1.5x CPUs

      Examples:

      ctx sysinfo                  # Human-readable table\nctx sysinfo --json           # Structured output\n
      ","path":["CLI","Diagnostics","Sysinfo"],"tags":[]},{"location":"cli/system/","level":1,"title":"System","text":"","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system","level":3,"title":"ctx system","text":"

      Hidden parent command that hosts Claude Code hook plumbing and a small set of session-lifecycle plumbing subcommands used by skills and editor integrations. The parent is registered without a visible group in ctx --help; run ctx system --help to see its subcommands.

      ctx system <subcommand>\n

      Commands Previously under ctx system

      Several user-facing maintenance commands used to live under ctx system and were promoted to top-level:

      • ctx system eventsctx hook event
      • ctx system messagectx hook message
      • ctx system prunectx prune
      • ctx system resourcesctx sysinfo
      • ctx system statsctx usage

      ctx system bootstrap remains under ctx system as a hidden, agent-only command. Update any scripts or personal docs that reference the old paths.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#plumbing-subcommands","level":2,"title":"Plumbing Subcommands","text":"

      These are not hook handlers; they're called by skills and editor integrations during the session lifecycle. Safe to run manually.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-journal","level":4,"title":"ctx system mark-journal","text":"

      Update processing state for a journal entry. Records the current date in .context/journal/.state.json. Used by journal skills to record pipeline progress.

      ctx system mark-journal <filename> <stage>\n

      Stages: exported, enriched, normalized, fences_verified

      Flag Description --check Check if stage is set (exit 1 if not)

      Example:

      ctx system mark-journal 2026-01-21-session-abc12345.md enriched\nctx system mark-journal 2026-01-21-session-abc12345.md normalized\nctx system mark-journal --check 2026-01-21-session-abc12345.md fences_verified\n
      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-wrapped-up","level":4,"title":"ctx system mark-wrapped-up","text":"

      Suppress context checkpoint nudges after a wrap-up ceremony. Writes a marker file that check-context-size checks before emitting checkpoint boxes. The marker expires after 2 hours.

      Called automatically by /ctx-wrap-up after persisting context (not intended for direct use).

      ctx system mark-wrapped-up\n

      No flags, no arguments. Idempotent: running it again updates the marker timestamp.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-pause-ctx-system-resume","level":4,"title":"ctx system pause / ctx system resume","text":"

      Session-scoped hook suppression. ctx system pause writes a marker file that causes hook plumbing to no-op for the current session; ctx system resume removes it. These are the hook-plumbing counterparts to the ctx hook pause / ctx hook resume commands (which call them internally).

      Read the session ID from stdin JSON (same as hooks) or pass --session-id.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-session-event","level":4,"title":"ctx system session-event","text":"

      Records a session lifecycle event (start or end) to the event log. Called by editor integrations when a workspace is opened or closed.

      ctx system session-event --type start --caller vscode\nctx system session-event --type end --caller vscode\n
      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#hook-subcommands","level":2,"title":"Hook Subcommands","text":"

      Hidden Claude Code hook handlers implementing the hook contract: read JSON from stdin, perform logic, emit output on stdout, exit 0. Block commands output JSON with a decision field.

      UserPromptSubmit hooks: context-load-gate, check-context-size, check-persistence, check-ceremony, check-journal, check-version, check-resource, check-knowledge, check-map-staleness, check-memory-drift, check-reminder, check-freshness, check-hub-sync, check-skill-discovery, heartbeat.

      PreToolUse hooks: block-non-path-ctx, block-dangerous-command, qa-reminder, specs-nudge.

      PostToolUse hooks: post-commit, check-task-completion.

      See AI Tools for registration details and the Claude Code plugin integration.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/trace/","level":1,"title":"Commit Context Tracing","text":"","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace","level":3,"title":"ctx trace","text":"

      Show the context behind git commits. Links commits back to the decisions, tasks, learnings, and sessions that motivated them.

      git log shows what changed, git blame shows who, and ctx trace shows why.

      ctx trace [commit] [flags]\n

      Flags:

      Flag Description --last N Show context for last N commits --json Output as JSON for scripting

      Examples:

      # Show context for a specific commit\nctx trace abc123\n\n# Show context for last 10 commits\nctx trace --last 10\n\n# JSON output\nctx trace abc123 --json\n

      Output:

      Commit: abc123 \"Fix auth token expiry\"\nDate:   2026-03-14 10:00:00 -0700\nContext:\n  [Decision] #12: Use short-lived tokens with server-side refresh\n    Date: 2026-03-10\n\n  [Task] #8: Implement token rotation for compliance\n    Status: completed\n

      When listing recent commits with --last:

      abc123  Fix auth token expiry         decision:12, task:8\ndef456  Add rate limiting             decision:15, learning:7\n789abc  Update dependencies           (none)\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-file","level":3,"title":"ctx trace file","text":"

      Show the context trail for a file. Combines git log with context resolution.

      ctx trace file <path[:line-range]> [flags]\n

      Flags:

      Flag Description --last N Maximum commits to show (default: 20)

      Examples:

      # Show context trail for a file\nctx trace file src/auth.go\n\n# Show context for specific line range\nctx trace file src/auth.go:42-60\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-tag","level":3,"title":"ctx trace tag","text":"

      Manually tag a commit with context. For commits made without the hook, or to add extra context after the fact.

      Tags are stored in .context/trace/overrides.jsonl since git trailers cannot be added to existing commits without rewriting history.

      ctx trace tag <commit> --note \"<text>\"\n

      Examples:

      ctx trace tag HEAD --note \"Hotfix for production outage\"\nctx trace tag abc123 --note \"Part of Q1 compliance initiative\"\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-hook","level":3,"title":"ctx trace hook","text":"

      Enable or disable the prepare-commit-msg hook for automatic context tracing. When enabled, commits automatically receive a ctx-context trailer with references to relevant decisions, tasks, learnings, and sessions.

      ctx trace hook <enable|disable>\n

      Prerequisites: ctx must be on your $PATH. If you installed via go install, ensure $GOPATH/bin (or $HOME/go/bin) is in your shell's $PATH.

      What the hook does:

      1. Before each commit, collects context from three sources:
      2. Pending context accumulated during work (ctx add, ctx task complete)
      3. Staged file changes to .context/ files
      4. Working state (in-progress tasks, active AI session)
      5. Injects a ctx-context trailer into the commit message
      6. After commit, records the mapping in .context/trace/history.jsonl

      Examples:

      # Install the hook\nctx trace hook enable\n\n# Remove the hook\nctx trace hook disable\n

      Resulting commit message:

      Fix auth token expiry handling\n\nRefactored token refresh logic to handle edge case\nwhere refresh token expires during request.\n\nctx-context: decision:12, task:8, session:abc123\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#reference-types","level":3,"title":"Reference Types","text":"

      The ctx-context trailer supports these reference types:

      Prefix Points to Example decision:<n> Entry #n in DECISIONS.md decision:12 learning:<n> Entry #n in LEARNINGS.md learning:5 task:<n> Task #n in TASKS.md task:8 convention:<n> Entry #n in CONVENTIONS.md convention:3 session:<id> AI session by ID session:abc123 \"<text>\" Free-form context note \"Performance fix for P1 incident\"","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#storage","level":3,"title":"Storage","text":"

      Context trace data is stored in the .context/ directory:

      File Purpose Lifecycle state/pending-context.jsonl Accumulates refs during work Truncated after each commit trace/history.jsonl Permanent commit-to-context map Append-only, never truncated trace/overrides.jsonl Manual tags for existing commits Append-only","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trigger/","level":1,"title":"Trigger","text":"","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger","level":2,"title":"ctx trigger","text":"

      Manage lifecycle triggers: executable scripts that fire at specific events during an AI session. Triggers can block tool calls, inject context, and automate reactions: any side effect you want at session boundaries, tool boundaries, or file-save events.

      ctx trigger <subcommand>\n

      Triggers Execute Arbitrary Scripts

      A trigger is a shell script with the executable bit set. It runs with the same privileges as your AI tool and receives JSON input on stdin. Treat triggers like pre-commit hooks: only enable scripts you've read and understand. A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#where-triggers-live","level":3,"title":"Where Triggers Live","text":"

      Triggers live in .context/hooks/<trigger-type>/ as executable scripts. The on-disk directory name is still hooks/ for historical reasons even though the command is ctx trigger. Each script:

      • Reads a JSON payload from stdin.
      • Returns a JSON payload on stdout.
      • Returns a non-zero exit code to block or error.
      .context/\n└── hooks/\n    ├── session-start/\n    │   └── inject-context.sh\n    ├── pre-tool-use/\n    │   └── block-legacy.sh\n    └── post-tool-use/\n        └── record-edit.sh\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#trigger-types","level":3,"title":"Trigger Types","text":"Type Fires when session-start An AI session begins session-end An AI session ends pre-tool-use Before an AI tool call is executed post-tool-use After an AI tool call returns file-save When a file is saved context-add When a context entry is added","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#input-and-output-contract","level":3,"title":"Input and Output Contract","text":"

      Each trigger receives a JSON object on stdin with the event details. Minimal contract (fields vary by trigger type):

      {\n  \"type\": \"pre-tool-use\",\n  \"tool\": \"write_file\",\n  \"path\": \"src/auth.go\",\n  \"session_id\": \"abc123-...\"\n}\n

      The trigger may write a JSON object to stdout to influence behavior. Example for a blocking pre-tool-use trigger:

      {\n  \"action\": \"block\",\n  \"message\": \"Editing src/auth.go requires approval from #security\"\n}\n

      For non-blocking event loggers, simply read stdin and exit 0 without writing to stdout.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-add","level":3,"title":"ctx trigger add","text":"

      Create a new trigger script with a template. The generated file has a bash shebang, a stdin reader using jq, and a basic JSON output structure.

      ctx trigger add <trigger-type> <name>\n

      Arguments:

      • trigger-type: One of session-start, session-end, pre-tool-use, post-tool-use, file-save, context-add
      • name: Script name (without .sh extension)

      Examples:

      ctx trigger add session-start inject-context\n# Created .context/hooks/session-start/inject-context.sh\n\nctx trigger add pre-tool-use block-legacy\n# Created .context/hooks/pre-tool-use/block-legacy.sh\n

      The generated script is not executable by default. Enable it with ctx trigger enable after reviewing the contents.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-list","level":3,"title":"ctx trigger list","text":"

      List all discovered triggers, grouped by trigger type, with their enabled/disabled status.

      Examples:

      ctx trigger list\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-test","level":3,"title":"ctx trigger test","text":"

      Run all enabled triggers of a given type against a mock payload. Use --tool and --path to customize the mock input for tool-related events.

      ctx trigger test <trigger-type> [flags]\n

      Flags:

      Flag Description --tool Tool name to put in mock input --path File path to put in mock input

      Examples:

      ctx trigger test session-start\nctx trigger test pre-tool-use --tool write_file --path src/main.go\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-enable","level":3,"title":"ctx trigger enable","text":"

      Enable a trigger by setting its executable permission bit. Searches every trigger-type directory for a script matching <name>.

      ctx trigger enable <name>\n

      Examples:

      ctx trigger enable inject-context\n# Enabled .context/hooks/session-start/inject-context.sh\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-disable","level":3,"title":"ctx trigger disable","text":"

      Disable a trigger by clearing its executable permission bit. Searches every trigger-type directory for a script matching <name>.

      ctx trigger disable <name>\n

      Examples:

      ctx trigger disable inject-context\n# Disabled .context/hooks/session-start/inject-context.sh\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#three-hooking-concepts-in-ctx-dont-confuse-them","level":3,"title":"Three Hooking Concepts in ctx (Don't Confuse Them)","text":"

      This is a common source of confusion. ctx has three distinct hook-like layers, and they serve different purposes:

      Layer Owned by Where it runs Configured via ctx trigger You .context/hooks/<type>/*.sh ctx trigger add/enable ctx system hooks ctx itself built-in, called by ctx's own lifecycle internal (see ctx system --help) Claude Code hooks Claude Code .claude/settings.local.json edit JSON, or /ctx-sanitize-permissions

      Use ctx trigger when you want project-specific automation that your AI tool will run at lifecycle events. Use Claude Code hooks for tool-specific integrations that don't need to be portable across tools. ctx system hooks are not something you author; they're the internal nudge machinery that ships with ctx.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#see-also","level":3,"title":"See Also","text":"
      • ctx steering: persistent AI behavioral rules (a different concept; rules vs scripts)
      • Authoring triggers recipe: a full walkthrough with security guidance
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/usage/","level":1,"title":"Usage","text":"","path":["CLI","Diagnostics","Usage"],"tags":[]},{"location":"cli/usage/#ctx-usage","level":3,"title":"ctx usage","text":"

      Display per-session token usage statistics from the local stats JSONL files written by the heartbeat hook. By default, shows the last 20 entries across all sessions. Use --follow to stream new entries as they arrive (like tail -f).

      ctx usage [flags]\n

      Flags:

      Flag Description -f, --follow Stream new entries as they arrive -s, --session Filter by session ID (prefix match) -n, --last Show last N entries (default: 20) -j, --json Output raw JSONL

      Examples:

      ctx usage                     # Last 20 entries across all sessions\nctx usage --follow            # Live stream (like tail -f)\nctx usage --session abc123    # Filter to one session\nctx usage --last 100 --json   # Last 100 as raw JSONL\n
      ","path":["CLI","Diagnostics","Usage"],"tags":[]},{"location":"cli/watch/","level":1,"title":"Watch","text":"","path":["CLI","Context","Watch"],"tags":[]},{"location":"cli/watch/#ctx-watch","level":2,"title":"ctx watch","text":"

      Watch for AI output and auto-apply context updates.

      Parses <context-update> XML commands from AI output and applies them to context files.

      ctx watch [flags]\n

      Flags:

      Flag Description --log <file> Log file to watch (default: stdin) --dry-run Preview updates without applying

      Examples:

      # Watch stdin\nai-tool | ctx watch\n\n# Watch a log file\nctx watch --log /path/to/ai-output.log\n\n# Preview without applying\nctx watch --dry-run\n
      ","path":["CLI","Context","Watch"],"tags":[]},{"location":"cli/why/","level":1,"title":"Why","text":"","path":["CLI","Getting Started","Why"],"tags":[]},{"location":"cli/why/#ctx-why","level":2,"title":"ctx why","text":"

      Read ctx's philosophy documents directly in the terminal.

      ctx why [DOCUMENT]\n

      Documents:

      Name Description manifesto The ctx Manifesto: creation, not code about About ctx: what it is and why it exists invariants Design invariants: properties that must hold

      Examples:

      # Interactive numbered menu\nctx why\n\n# Show a specific document\nctx why manifesto\nctx why about\nctx why invariants\n\n# Pipe to a pager\nctx why manifesto | less\n
      ","path":["CLI","Getting Started","Why"],"tags":[]},{"location":"home/","level":1,"title":"Home","text":"
      • ctx is not a prompt.
      • ctx is version-controlled cognitive state.

      ctx is the persistence layer for human-AI reasoning.

      Deterministic. Git-native. Human-readable. Local-first.

      Start here.

      Learn what ctx does, set it up, and run your first session.

      Pre-1.0: Moving Fast

      ctx is under active development. This website tracks the development branch, not the latest release:

      Some features described here may not exist in the binary you have installed.

      Expect rough edges.

      If something is missing or broken, open an issue.

      ","path":["Home"],"tags":[]},{"location":"home/#introduction","level":2,"title":"Introduction","text":"","path":["Home"],"tags":[]},{"location":"home/#about","level":3,"title":"About","text":"

      What ctx is, how it works, and why persistent context changes how you work with AI.

      ","path":["Home"],"tags":[]},{"location":"home/#is-it-right-for-me","level":3,"title":"Is It Right for Me?","text":"

      Good fit, not-so-good fit, and a 5-minute trial to find out for yourself.

      ","path":["Home"],"tags":[]},{"location":"home/#faq","level":3,"title":"FAQ","text":"

      Quick answers to the questions newcomers ask most about ctx, files, tooling, and trade-offs.

      ","path":["Home"],"tags":[]},{"location":"home/#get-started","level":2,"title":"Get Started","text":"","path":["Home"],"tags":[]},{"location":"home/#getting-started","level":3,"title":"Getting Started","text":"

      Install the binary, set up the plugin, and verify it works.

      ","path":["Home"],"tags":[]},{"location":"home/#your-first-session","level":3,"title":"Your First Session","text":"

      Step-by-step walkthrough from ctx init to verified recall.

      ","path":["Home"],"tags":[]},{"location":"home/#common-workflows","level":3,"title":"Common Workflows","text":"

      Day-to-day commands for tracking context, checking health, and browsing history.

      ","path":["Home"],"tags":[]},{"location":"home/#concepts","level":2,"title":"Concepts","text":"","path":["Home"],"tags":[]},{"location":"home/#context-files","level":3,"title":"Context Files","text":"

      What each .context/ file does. What's their purpose. How do we best leverage them.

      ","path":["Home"],"tags":[]},{"location":"home/#configuration","level":3,"title":"Configuration","text":"

      Flexible configuration: .ctxrc, environment variables, and CLI flags.

      ","path":["Home"],"tags":[]},{"location":"home/#hub","level":3,"title":"Hub","text":"

      A fan-out channel for decisions, learnings, conventions, and tasks that need to cross project boundaries, without replicating everything else.

      ","path":["Home"],"tags":[]},{"location":"home/#working-with-ai","level":2,"title":"Working with AI","text":"","path":["Home"],"tags":[]},{"location":"home/#prompting-guide","level":3,"title":"Prompting Guide","text":"

      Effective prompts for AI sessions with ctx.

      ","path":["Home"],"tags":[]},{"location":"home/#keeping-ai-honest","level":3,"title":"Keeping AI Honest","text":"

      AI agents confabulate: they invent history, claim familiarity with decisions never made, and sometimes declare tasks complete when they aren't. Tools and habits to push back.

      ","path":["Home"],"tags":[]},{"location":"home/#my-ai-keeps-making-the-same-mistakes","level":3,"title":"My AI Keeps Making the Same Mistakes","text":"

      Stop rediscovering the same bugs and dead-ends across sessions.

      ","path":["Home"],"tags":[]},{"location":"home/#joining-a-project","level":3,"title":"Joining a Project","text":"

      You inherited a .context/ directory. Get oriented fast: priority order, what to read first, how to ramp up.

      ","path":["Home"],"tags":[]},{"location":"home/#customization","level":2,"title":"Customization","text":"","path":["Home"],"tags":[]},{"location":"home/#steering-files","level":3,"title":"Steering Files","text":"

      Tell the assistant how to behave when a specific kind of prompt arrives.

      ","path":["Home"],"tags":[]},{"location":"home/#lifecycle-triggers","level":3,"title":"Lifecycle Triggers","text":"

      Make things happen at session boundaries: block dangerous tool calls, inject standup notes, log file saves.

      ","path":["Home"],"tags":[]},{"location":"home/#community","level":2,"title":"Community","text":"","path":["Home"],"tags":[]},{"location":"home/#ctx","level":3,"title":"#ctx","text":"

      We are the builders who care about durable context. Join the community. Hang out in IRC. Star ctx on GitHub.

      ","path":["Home"],"tags":[]},{"location":"home/#contributing","level":3,"title":"Contributing","text":"

      Development setup, project layout, and pull request process.

      ","path":["Home"],"tags":[]},{"location":"home/about/","level":1,"title":"About","text":"

      \"Creation, not code; Context, not prompts; Verification, not vibes.\"

      Read the ctx Manifesto →

      \"Without durable context, intelligence resets; with ctx, creation compounds.\"

      Without persistent memory, every session starts at zero; ctx makes sessions cumulative.

      Join the ctx Community →

      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#what-is-ctx","level":2,"title":"What Is ctx?","text":"

      ctx (Context) is a file-based system that enables AI coding assistants to persist project knowledge across sessions. It lives in a .context/ directory in your repo.

      • A session is interactive.
      • ctx enables cognitive continuity.
      • Cognitive continuity enables durable, symbiotic-like human-AI workflows.

      Context Files

      Context files let AI tools remember decisions, conventions, and learnings:

      Context files are explicit and versionable contracts between you and your agents.

      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#why-do-i-keep-re-explaining-my-codebase","level":2,"title":"Why Do I Keep Re-Explaining My Codebase?!?!","text":"

      You open a new AI session. The first thing you do is re-explain your project.

      Again.

      The architecture, the database choice, the naming conventions, the thing you tried last week that didn't work. You have said all of this before (maybe yesterday, maybe an hour ago), but the AI doesn't know that.

      • You explain the same architecture every session;
      • The AI suggests an approach you already rejected, again;
      • A decision you made three sessions ago gets relitigated from scratch;
      • You spend more time setting context than building features.

      This isn't AI failure: It is staleness.

      Without persistent memory, every session starts at zero.

      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#day-and-night","level":3,"title":"Day and Night","text":"

      ctx gives your AI a memory that persists across sessions:

      Without ctxWith ctx
      Session 12: Monday morning\n\nAI:  \"I'll scaffold a MySQL schema for this.\"\nYou: \"We use PostgreSQL.\"\n\nAI:  \"For auth, session-based would be simplest.\"\nYou: \"We decided on JWT.\"\n\nAI:  \"Endpoints in camelCase?\"\nYou: \"snake_case! Like the rest of the API!!!!!!\"\n\nYou: *scrolls up to copy an existing endpoint*\n\n20 minutes spent restoring decisions that already exist.\n
      Session 12: Monday morning\n\nYou:  \"Let's continue the auth implementation.\"\nAI:   \"Per DECISIONS.md (2026-02-12): JWT, not sessions: \n       The project uses PostgreSQL with JWT\n       authentication. The API follows snake_case conventions.\n       Last session you completed the login endpoint: the\n       registration endpoint is next on TASKS.md. Want me to\n       start there?\"\n\n0 minutes re-explaining. Straight to building.\n
      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#how-ctx-solves-this","level":3,"title":"How ctx Solves This","text":"

      ctx creates a .context/ directory in your project that stores structured knowledge files:

      File What It Remembers TASKS.md What you're working on and what's next DECISIONS.md Architectural choices and why you made them LEARNINGS.md Gotchas, bugs, things that didn't work CONVENTIONS.md Naming patterns, code style, project rules CONSTITUTION.md Hard rules the AI must never violate

      These files can version with your code in git:

      • They load automatically at the session start (via hooks in Claude Code, or manually with ctx agent for other tools).
      • The AI reads them, cites them, and builds on them, instead of asking you to start over.
        • And when it acts, it can point to the exact file and line that justifies the choice.

      Every decision you record, every lesson you capture, makes the next session smarter.

      ctx accumulates.

      Connect with ctx

      • Join the Community →: ask questions, share workflows, and help shape what comes next
      • Read the Blog →: real-world patterns, ponderings, and lessons learned from building ctx using ctx

      Ready to Get Started?

      • Getting Started →: full installation and setup
      • Your First Session →: step-by-step walkthrough from ctx init to verified recall
      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/common-workflows/","level":1,"title":"Common Workflows","text":"

      The commands below cover what you'll use most often:

      • recording context,
      • checking health,
      • browsing history,
      • and running loops.

      Each section is a self-contained snippet you can copy into your terminal.

      For deeper, step-by-step guides, see Recipes.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#track-context","level":2,"title":"Track Context","text":"

      Prefer Skills over Raw Commands

      When working with an AI agent, use /ctx-task-add, /ctx-decision-add, or /ctx-learning-add instead of raw ctx add commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.

      # Add a task\nctx add task \"Implement user authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Record a decision (full ADR fields required)\nctx add decision \"Use PostgreSQL for primary database\" \\\n  --context \"Need a reliable database for production\" \\\n  --rationale \"PostgreSQL offers ACID compliance and JSON support\" \\\n  --consequence \"Team needs PostgreSQL training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Note a learning\nctx add learning \"Mock functions must be hoisted in Jest\" \\\n  --context \"Tests failed with undefined mock errors\" \\\n  --lesson \"Jest hoists mock calls to top of file\" \\\n  --application \"Place jest.mock() before imports\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Mark task complete\nctx task complete \"user auth\"\n
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#leave-a-reminder-for-next-session","level":2,"title":"Leave a Reminder for Next Session","text":"

      Drop a note that surfaces automatically at the start of your next session:

      # Leave a reminder\nctx remind \"refactor the swagger definitions\"\n\n# Date-gated: don't surface until a specific date\nctx remind \"check CI after the deploy\" --after 2026-02-25\n\n# List pending reminders\nctx remind list\n\n# Dismiss reminders by ID (supports ranges)\nctx remind dismiss 1\nctx remind dismiss 3 5-7\n

      Reminders are relayed verbatim at session start by the check-reminders hook and repeat every session until you dismiss them.

      See Session Reminders for the full recipe.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#check-context-health","level":2,"title":"Check Context Health","text":"
      # Detect stale paths, missing files, potential secrets\nctx drift\n\n# See full context summary\nctx status\n
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#browse-session-history","level":2,"title":"Browse Session History","text":"

      List and search past AI sessions from the terminal:

      ctx journal source --limit 5\n
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#journal-site","level":3,"title":"Journal Site","text":"

      Import session transcripts to a browsable static site with search, navigation, and topic indices.

      The ctx journal command requires zensical (Python >= 3.10).

      zensical is a Python-based static site generator from the Material for MkDocs team.

      (why zensical?).

      If you don't have it on your system, install zensical once with pipx:

      # One-time setup\npipx install zensical\n

      Avoid pip install zensical

      pip install often fails: For example, on macOS, system Python installs a non-functional stub (zensical requires Python >= 3.10), and Homebrew Python blocks system-wide installs (PEP 668).

      pipx creates an isolated environment with the correct Python version automatically.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#import-and-serve","level":3,"title":"Import and Serve","text":"

      Then, import and serve:

      # Import all sessions to .context/journal/ (only new files)\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n

      Open http://localhost:8000 to browse.

      To update after new sessions, run the same two commands again.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#safe-by-default","level":3,"title":"Safe by Default","text":"

      ctx journal import --all is safe by default:

      • It only imports new sessions and skips existing files.
      • Locked entries (via ctx journal lock) are always skipped by both import and enrichment skills.
      • If you add locked: true to frontmatter during enrichment, run ctx journal sync to propagate the lock state to .state.json.
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#re-importing-existing-files","level":3,"title":"Re-Importing Existing Files","text":"

      Here is how you regenerate existing files.

      Backup your .context folder before regeneration, as this is a potentially destructive action.

      To re-import journal files, you need to explicitly opt-in using the --regenerate flag:

      Flag combination Frontmatter Body --regenerate Preserved Overwritten from source --regenerate --keep-frontmatter=false Overwritten Overwritten

      Regeneration Overwrites Body Edits

      --regenerate preserves your YAML frontmatter (tags, summary, enrichment metadata) but it replaces the Markdown body with a fresh import.

      Any manual edits you made to the transcript will be lost.

      Lock entries you want to protect first: ctx journal lock <session-id>.

      See Session Journal for the full pipeline including normalization and enrichment.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#scratchpad","level":2,"title":"Scratchpad","text":"

      Store short, sensitive one-liners in an encrypted scratchpad that travels with the project:

      # Write a note\nctx pad set db-password \"postgres://user:pass@localhost/mydb\"\n\n# Read it back\nctx pad get db-password\n\n# List all keys\nctx pad list\n

      The scratchpad is encrypted with a key stored at ~/.ctx/.ctx.key (outside the project, never committed).

      See Scratchpad for details.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#run-an-autonomous-loop","level":2,"title":"Run an Autonomous Loop","text":"

      Generate a script that iterates an AI agent until a completion signal is detected:

      ctx loop\nchmod +x loop.sh\n./loop.sh\n

      See Autonomous Loops for configuration and advanced usage.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#trace-commit-context","level":2,"title":"Trace Commit Context","text":"

      Link your git commits back to the decisions, tasks, and learnings that motivated them. Enable the hook once:

      # Install the git hook (one-time setup)\nctx trace hook enable\n

      From now on, every git commit automatically gets a ctx-context trailer linking it to relevant context. No extra steps needed; just use ctx add, ctx task complete, and commit as usual.

      # Later: why was this commit made?\nctx trace abc123\n\n# Recent commits with their context\nctx trace --last 10\n\n# Context trail for a specific file\nctx trace file src/auth.go\n\n# Manually tag a commit after the fact\nctx trace tag HEAD --note \"Hotfix for production outage\"\n

      To stop: ctx trace hook disable.

      See CLI Reference: trace for details.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#agent-session-start","level":2,"title":"Agent Session Start","text":"

      The first thing an AI agent should do at session start is discover where context lives:

      ctx system bootstrap\n

      This prints the resolved context directory, the files in it, and the operating rules. The CLAUDE.md template instructs the agent to run this automatically. See CLI Reference: bootstrap.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#the-two-skills-you-should-always-use","level":2,"title":"The Two Skills You Should Always Use","text":"

      Using /ctx-remember at session start and /ctx-wrap-up at session end are the highest-value skills in the entire catalog:

      # session begins:\n/ctx-remember\n... do work ...\n# before closing the session:\n/ctx-wrap-up\n

      Let's provide some context, because this is important:

      Although the agent will eventually discover your context through CLAUDE.md → AGENT_PLAYBOOK.md, /ctx-remember hydrates the full context up front (tasks, decisions, recent sessions) so the agent starts informed rather than piecing things together over several turns.

      /ctx-wrap-up is the other half: A structured review that captures learnings, decisions, and tasks before you close the window.

      Hooks like check-persistence remind you (the user) mid-session that context hasn't been saved in a while, but they don't trigger persistence automatically: You still have to act. Also, a CTRL+C can end things at any moment with no reliable \"before session end\" event.

      In short, /ctx-wrap-up is the deliberate checkpoint that makes sure nothing slips through. And /ctx-remember it its mirror skill to be used at session start.

      See Session Ceremonies for the full workflow.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#cli-commands-vs-ai-skills","level":2,"title":"CLI Commands vs. AI Skills","text":"

      Most ctx operations come in two flavors: a CLI command you run in your terminal and an AI skill (slash command) you invoke inside your coding assistant.

      Commands and skills are not interchangeable: Each has a distinct role.

      ctx CLI command ctx AI skill Runs where Your terminal Inside the AI assistant Speed Fast (milliseconds) Slower (LLM round-trip) Cost Free Consumes tokens and context Analysis Deterministic heuristics Semantic / judgment-based Best for Quick checks, scripting, CI Deep analysis, generation, workflow orchestration","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#paired-commands","level":3,"title":"Paired Commands","text":"

      These have both a CLI and a skill counterpart. Use the CLI for quick, deterministic checks; use the skill when you need the agent's judgment.

      CLI Skill When to prefer the skill ctx drift /ctx-drift Semantic analysis: catches meaning drift the CLI misses ctx status /ctx-status Interpreted summary with recommendations ctx add task /ctx-task-add Agent decomposes vague goals into concrete tasks ctx add decision /ctx-decision-add Agent drafts rationale and consequences from discussion ctx add learning /ctx-learning-add Agent extracts the lesson from a debugging session ctx add convention /ctx-convention-add Agent observes a repeated pattern and codifies it ctx task archive /ctx-archive Agent reviews which tasks are truly done ctx pad /ctx-pad Agent reads/writes scratchpad entries in conversation flow ctx journal /ctx-history Agent searches session history with semantic understanding ctx agent /ctx-agent Agent loads and acts on the context packet ctx loop /ctx-loop Agent tailors the loop script to your project ctx doctor /ctx-doctor Agent adds semantic analysis to structural checks ctx hook pause /ctx-pause Agent pauses hooks with session-aware reasoning ctx hook resume /ctx-resume Agent resumes hooks after a pause ctx remind /ctx-remind Agent manages reminders in conversation flow","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#ai-only-skills","level":3,"title":"AI-Only Skills","text":"

      These have no CLI equivalent. They require the agent's reasoning.

      Skill Purpose /ctx-remember Load context and present structured readback at session start /ctx-wrap-up End-of-session ceremony: persist learnings, decisions, tasks /ctx-next Suggest 1-3 concrete next actions from context /ctx-commit Commit with integrated context capture /ctx-reflect Pause and assess session progress /ctx-consolidate Merge overlapping learnings or decisions /ctx-prompt-audit Analyze prompting patterns for improvement /ctx-plan Stress-test an existing plan through adversarial interview /ctx-plan-import Import Claude Code plan files into project specs /ctx-implement Execute a plan step-by-step with verification /ctx-worktree Manage parallel agent worktrees /ctx-journal-enrich Add metadata, tags, and summaries to journal entries /ctx-journal-enrich-all Full journal pipeline: export if needed, then batch-enrich /ctx-blog Generate a blog post (zensical-flavored Markdown) /ctx-blog-changelog Generate themed blog post from commits between releases /ctx-architecture Build and maintain architecture maps (ARCHITECTURE.md, DETAILED_DESIGN.md)","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#cli-only-commands","level":3,"title":"CLI-Only Commands","text":"

      These are infrastructure: used in scripts, CI, or one-time setup.

      Command Purpose ctx init Initialize .context/ directory ctx load Output assembled context for piping ctx task complete Mark a task done by substring match ctx sync Reconcile context with codebase state ctx compact Consolidate and clean up context files ctx trace Show context behind git commits ctx trace hook Enable/disable commit context tracing hook ctx setup Generate AI tool integration config ctx watch Watch AI output and auto-apply context updates ctx serve Serve any zensical directory (default: journal) ctx permission snapshot Save settings as a golden image ctx permission restore Restore settings from golden image ctx journal site Generate browsable journal from exports ctx hook notify setup Configure webhook notifications ctx decision List and filter decisions ctx learning List and filter learnings ctx task List tasks, manage archival and snapshots ctx why Read the philosophy behind ctx ctx guide Quick-reference cheat sheet ctx site Site management commands ctx config Manage runtime configuration profiles ctx system System diagnostics and hook commands ctx completion Generate shell autocompletion scripts

      Rule of Thumb

      Quick check? Use the CLI.

      Need judgment? Use the skill.

      When in doubt, start with the CLI: It's free and instant.

      Escalate to the skill when heuristics aren't enough.

      Next Up: Context Files →: what each .context/ file does and how to use it

      See Also:

      • Recipes: targeted how-to guides for specific tasks
      • Knowledge Capture: patterns for recording decisions, learnings, and conventions
      • Context Health: keeping your .context/ accurate and drift-free
      • Session Archaeology: digging into past sessions
      • Task Management: tracking and completing work items
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/community/","level":1,"title":"#ctx","text":"

      Open source is better together.

      We are the builders who care about durable context, verifiable decisions, and human-AI workflows that compound over time.

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#help-ctx-change-how-ai-remembers","level":2,"title":"Help ctx Change How AI Remembers","text":"

      If you like the idea, a star helps ctx reach engineers who run into context drift every day:

      Star ctx on GitHub ⭐

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#ctx-you","level":2,"title":"ctx ♥️ You","text":"

      Join the community to ask questions, share feedback, and connect with other users:

      • Discord join the ctx Discord: Real-time discussion, field notes, and early ideas.
      • Read the ctx Source on GitHub: Issues, discussions, and contributions.
      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#want-to-contribute","level":2,"title":"Want to Contribute?","text":"

      Early adopters shape the conventions.

      ctx is free and open source software.

      Contributions are always welcome and appreciated.

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#code-of-conduct","level":2,"title":"Code of Conduct","text":"

      Clear context requires respectful collaboration.

      ctx follows the Contributor Covenant.

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/configuration/","level":1,"title":"Configuration","text":"","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#configuration","level":2,"title":"Configuration","text":"

      ctx uses three layers of configuration. Each layer overrides the one below it:

      1. CLI flags: Per-invocation overrides (highest priority)
      2. Environment variables: Shell or CI/CD overrides
      3. The .ctxrc file: Project-level defaults (YAML)
      4. Built-in defaults: Hardcoded fallbacks (lowest priority)

      All settings are optional: If nothing is configured, ctx works out of the box with sensible defaults.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#the-ctxrc-file","level":2,"title":"The .ctxrc File","text":"

      The .ctxrc file is an optional YAML file placed in the project root (next to your .context/ directory). It lets you set project-level defaults that apply to every ctx command.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#location","level":3,"title":"Location","text":"
      my-project/\n├── .ctxrc              ← configuration file\n├── .context/\n│   ├── TASKS.md\n│   ├── DECISIONS.md\n│   └── ...\n└── src/\n

      ctx reads .ctxrc from the project root (i.e. the parent of CTX_DIR, or dirname(CTX_DIR)/.ctxrc). It does not walk up from CWD. That means whichever project you've activated via eval \"$(ctx activate)\" (or by exporting CTX_DIR directly), its paired .ctxrc is what governs the invocation. There is no global or user-level config file: configuration is always per-project.

      Contributors: Dev Configuration Profile

      The ctx repo ships two .ctxrc source profiles (.ctxrc.base and .ctxrc.dev). The working copy is gitignored and swapped between them via ctx config switch dev / ctx config switch base. See Contributing: Configuration Profiles.

      Using a Different .context Directory

      You point ctx at a .context/ directory by setting the CTX_DIR environment variable, not through .ctxrc. ctx does not search the filesystem. Use eval \"$(ctx activate)\" to bind CTX_DIR for your shell. CTX_DIR must be an absolute path with .context as its basename.

      See Environment Variables below for details.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#full-reference","level":3,"title":"Full Reference","text":"

      A commented .ctxrc showing all options and their defaults:

      # .ctxrc: ctx runtime configuration\n# https://ctx.ist/configuration/\n#\n# All settings are optional. Missing values use defaults.\n# Priority: CLI flags > environment variables > .ctxrc > defaults\n#\n# token_budget: 8000\n# auto_archive: true\n# archive_after_days: 7\n# scratchpad_encrypt: true\n# event_log: false\n# entry_count_learnings: 30\n# entry_count_decisions: 20\n# convention_line_count: 200\n# injection_token_warn: 15000\n# context_window: 200000      # auto-detected for Claude Code; override for other tools\n# billing_token_warn: 0       # one-shot warning at this token count (0 = disabled)\n#\n# stale_age_days: 30      # days before drift flags a context file as stale (0 = disabled)\n# key_rotation_days: 90\n# task_nudge_interval: 5   # Edit/Write calls between task completion nudges\n#\n# notify:               # requires: ctx hook notify setup\n#   events:             # required: no events sent unless listed\n#     - loop\n#     - nudge\n#     - relay\n#\n# tool: \"\"              # Active AI tool: claude, cursor, cline, kiro, codex\n#\n# steering:             # Steering layer configuration\n#   dir: .context/steering\n#   default_inclusion: manual\n#   default_tools: []\n#\n# hooks:                # Hook system configuration\n#   dir: .context/hooks\n#   timeout: 10\n#   enabled: true\n#\n# provenance_required:  # Relax provenance flags for ctx add\n#   session_id: true    # Require --session-id (default: true)\n#   branch: true        # Require --branch (default: true)\n#   commit: true        # Require --commit (default: true)\n#\n# priority_order:\n#   - CONSTITUTION.md\n#   - TASKS.md\n#   - CONVENTIONS.md\n#   - ARCHITECTURE.md\n#   - DECISIONS.md\n#   - LEARNINGS.md\n#   - GLOSSARY.md\n#   - AGENT_PLAYBOOK.md\n
      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#option-reference","level":3,"title":"Option Reference","text":"Option Type Default Description token_budget int 8000 Default token budget for ctx agent and ctx load auto_archive bool true Auto-archive completed tasks during ctx compact archive_after_days int 7 Days before completed tasks are archived scratchpad_encrypt bool true Encrypt scratchpad with AES-256-GCM event_log bool false Enable local hook event logging to .context/state/events.jsonl entry_count_learnings int 30 Drift warning when LEARNINGS.md exceeds this entry count (0 = disable) entry_count_decisions int 20 Drift warning when DECISIONS.md exceeds this entry count (0 = disable) convention_line_count int 200 Drift warning when CONVENTIONS.md exceeds this line count (0 = disable) injection_token_warn int 15000 Warn when auto-injected context exceeds this token count (0 = disable) context_window int 200000 Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools billing_token_warn int 0 (off) One-shot warning when session tokens exceed this threshold (0 = disabled). For plans where tokens beyond an included allowance cost extra stale_age_days int 30 Days before ctx drift flags a context file as stale (0 = disable) key_rotation_days int 90 Days before encryption key rotation nudge task_nudge_interval int 5 Edit/Write calls between task completion nudges notify.events []string (all) Event filter for webhook notifications (empty = all) priority_order []string (see below) Custom file loading priority for context assembly tool string (empty) Active AI tool identifier (claude, cursor, cline, kiro, codex). Used by steering sync and hook dispatch steering.dir string .context/steering Steering files directory steering.default_inclusion string manual Default inclusion mode for new steering files (always, auto, manual) steering.default_tools []string (all) Default tool filter for new steering files (empty = all tools) hooks.dir string .context/hooks Hook scripts directory hooks.timeout int 10 Per-hook execution timeout in seconds hooks.enabled bool true Whether hook execution is enabled provenance_required.session_id bool true Require --session-id on ctx add for tasks, decisions, learnings provenance_required.branch bool true Require --branch on ctx add for tasks, decisions, learnings provenance_required.commit bool true Require --commit on ctx add for tasks, decisions, learnings

      Default priority order (used when priority_order is not set):

      1. CONSTITUTION.md
      2. TASKS.md
      3. CONVENTIONS.md
      4. ARCHITECTURE.md
      5. DECISIONS.md
      6. LEARNINGS.md
      7. GLOSSARY.md
      8. AGENT_PLAYBOOK.md

      See Context Files for the rationale behind this ordering.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#environment-variables","level":2,"title":"Environment Variables","text":"

      Environment variables override .ctxrc values but are overridden by CLI flags.

      Variable Description Equivalent .ctxrc key CTX_DIR Declare the context directory path (required, no fallback) (none) CTX_TOKEN_BUDGET Override the default token budget token_budget","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples","level":3,"title":"Examples","text":"
      # Use a shared context directory\nCTX_DIR=/shared/team-context ctx status\n\n# Increase token budget for a single run\nCTX_TOKEN_BUDGET=16000 ctx agent\n
      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#cli-global-flags","level":2,"title":"CLI Global Flags","text":"

      CLI flags have the highest priority and override both environment variables and .ctxrc settings. These flags are available on every ctx command.

      Flag Description --tool <name> Override active AI tool identifier (e.g. kiro, cursor) --version Show version and exit --help Show command help and exit","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples_1","level":3,"title":"Examples","text":"
      # Point to a different context directory inline:\nCTX_DIR=/path/to/project/.context ctx status\n
      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#priority-order","level":2,"title":"Priority Order","text":"

      When the same setting is configured in multiple layers, the highest-priority layer wins:

      CLI flags  >  Environment variables  >  .ctxrc  >  Built-in defaults\n(highest)                                          (lowest)\n

      The context directory itself is resolved differently: it lives outside this priority chain. CTX_DIR (env) must be declared; .ctxrc does not carry a fallback for it, and there is no built-in default. See Activating a Context Directory.

      Example resolution for token_budget:

      Layer Value Wins? CTX_TOKEN_BUDGET 4000 Yes .ctxrc 8000 No Default 8000 No","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples_2","level":2,"title":"Examples","text":"","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#external-context-directory","level":3,"title":"External .context Directory","text":"

      Store a project's context outside the project tree (useful when a repo is read-only, or when you want to keep notes adjacent rather than checked in). Declare the path via CTX_DIR:

      export CTX_DIR=/home/you/ctx-stores/my-project/.context\n

      One .context/ per project

      The parent of the context directory is the project root by contract: ctx sync, ctx drift, and the memory-drift hook all read the codebase from filepath.Dir(ContextDir()). Pointing two projects at the same .context/ directory will collide their journals, state, and secrets. To share knowledge (CONSTITUTION / CONVENTIONS / ARCHITECTURE) across projects, use ctx hub, not a shared .context/.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-token-budget","level":3,"title":"Custom Token Budget","text":"

      Increase the token budget for projects with large context:

      # .ctxrc\ntoken_budget: 16000\n

      This affects the default budget for ctx agent and ctx load. You can still override per-invocation with ctx agent --budget 4000.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#disabled-scratchpad-encryption","level":3,"title":"Disabled Scratchpad Encryption","text":"

      Turn off encryption for the scratchpad (useful in ephemeral environments where key management is unnecessary):

      # .ctxrc\nscratchpad_encrypt: false\n

      Unencrypted Scratchpads Store Secrets in Plaintext

      Only disable encryption if you understand the security implications.

      The scratchpad may contain sensitive data such as API keys, database URLs, or deployment credentials.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-priority-order","level":3,"title":"Custom Priority Order","text":"

      Reorder context files to prioritize architecture over conventions:

      # .ctxrc\npriority_order:\n  - CONSTITUTION.md\n  - TASKS.md\n  - ARCHITECTURE.md\n  - DECISIONS.md\n  - CONVENTIONS.md\n  - LEARNINGS.md\n  - GLOSSARY.md\n  - AGENT_PLAYBOOK.md\n

      Files not listed in priority_order receive the lowest priority (100). The order affects ctx agent, ctx load, and drift's file-priority calculations.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#billing-token-threshold","level":3,"title":"Billing Token Threshold","text":"

      Get a one-shot warning when your session crosses a token threshold where extra charges begin (e.g., Claude Pro includes 200k tokens; beyond that costs extra):

      # .ctxrc\nbilling_token_warn: 180000   # warn before hitting the 200k paid boundary\n

      The warning fires once per session the first time token usage exceeds the threshold. Set to 0 (or omit) to disable.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#adjusted-drift-thresholds","level":3,"title":"Adjusted Drift Thresholds","text":"

      Raise or lower the entry-count thresholds that trigger drift warnings:

      # .ctxrc\nentry_count_learnings: 50   # warn above 50 learnings (default: 30)\nentry_count_decisions: 10   # warn above 10 decisions (default: 20)\nconvention_line_count: 300  # warn above 300 lines (default: 200)\n

      Set any threshold to 0 to disable that specific check.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"

      Get notified when loops complete, hooks fire, or agents reach milestones:

      # Configure the webhook URL (encrypted, safe to commit)\nctx hook notify setup\n\n# Test delivery\nctx hook notify test\n

      Filter which events reach your webhook:

      # .ctxrc\nnotify:\n  events:\n    - loop      # loop completion/max-iteration\n    - nudge     # VERBATIM relay hooks fired\n    # - relay   # all hook output (verbose, for debugging)\n    # - heartbeat  # every-prompt session-alive signal\n

      Notifications are opt-in: No events are sent unless explicitly listed.

      See Webhook Notifications for a step-by-step recipe.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#hook-message-overrides","level":2,"title":"Hook Message Overrides","text":"

      Hook messages control what text hooks emit when they fire. Each message can be overridden per-project by placing a text file at the matching path under .context/:

      .context/hooks/messages/{hook}/{variant}.txt\n

      The override takes priority over the embedded default compiled into the ctx binary. An empty file silences the message while preserving the hook's logic (counting, state tracking, cooldowns).

      Use ctx hook message to discover and manage overrides:

      ctx hook message list                      # see all messages\nctx hook message show qa-reminder gate     # view the current template\nctx hook message edit qa-reminder gate     # copy default for editing\nctx hook message reset qa-reminder gate    # revert to default\n

      See Customizing Hook Messages for detailed examples including Python, JavaScript, and silence configurations.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#agent-bootstrapping","level":2,"title":"Agent Bootstrapping","text":"

      AI agents need to know the resolved context directory at session start. The ctx system bootstrap command prints the context path, file list, and operating rules in both text and JSON formats:

      ctx system bootstrap          # text output for agents\nctx system bootstrap -q       # just the context directory path\nctx system bootstrap --json   # structured output for automation\n

      The CLAUDE.md template instructs the agent to run this as its first action. Every nudge (context checkpoint, persistence reminder, etc.) also includes a Context: <dir> footer that re-anchors the agent to the correct directory throughout the session.

      This replaces the previous approach of hardcoding .context/ paths in agent instructions.

      See CLI Reference: bootstrap for full details.

      See also: CLI Reference | Context Files | Scratchpad

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/context-files/","level":1,"title":"Context Files","text":"","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#context","level":2,"title":".context/","text":"

      Each context file in .context/ serves a specific purpose.

      Files are designed to be human-readable, AI-parseable, and token-efficient.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#file-overview","level":2,"title":"File Overview","text":"

      The core context files live directly under .context/. They are the substrate ctx reads in priority order when assembling the agent context packet:

      File Purpose Priority CONSTITUTION.md Hard rules that must NEVER be violated 1 (highest) TASKS.md Current and planned work 2 CONVENTIONS.md Project patterns and standards 3 ARCHITECTURE.md System overview and components 4 DECISIONS.md Architectural decisions with rationale 5 LEARNINGS.md Lessons learned, gotchas, tips 6 GLOSSARY.md Domain terms and abbreviations 7 AGENT_PLAYBOOK.md Instructions for AI tools 8 (lowest)

      Two subdirectories under .context/ are implementation details that are user-editable but not part of the priority read order:

      • .context/templates/: format templates for ctx add decision and ctx add learning. See templates below.
      • .context/steering/: behavioral rules with YAML frontmatter that get synced into each AI tool's native config. See steering below, and the full Steering files page for the design and workflow.
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#outside-context","level":3,"title":"Outside .context/","text":"

      Two other moving parts are often confused with context files but are not under .context/:

      • Skills live in .claude/skills/ (project-local) or are provided by the installed ctx plugin. A typical project doesn't see the plugin's skills at all; they ride with the plugin and are owned by its update cycle. See ctx skill and Skills reference.
      • Hooks: Claude Code PreToolUse/PostToolUse/ UserPromptSubmit entries configured in .claude/settings.json or shipped by a plugin. The ctx plugin registers its own hooks automatically; a typical project does not author hooks by hand, and any local edits to plugin-owned hook files will be overridden on the next plugin update. If you need to customize behavior, edit your own project settings, not the plugin's files. See Hook sequence diagrams.
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#read-order-rationale","level":2,"title":"Read Order Rationale","text":"

      The priority order follows a logical progression for AI tools:

      1. CONSTITUTION.md: Inviolable rules first. The AI tool must know what it cannot do before attempting anything.
      2. TASKS.md: Current work items. What the AI tool should focus on.
      3. CONVENTIONS.md: How to write code. Patterns and standards to follow when implementing tasks.
      4. ARCHITECTURE.md: System structure. Understanding of components and boundaries before making changes.
      5. DECISIONS.md: Historical context. Why things are the way they are, to avoid re-debating settled decisions.
      6. LEARNINGS.md: Gotchas and tips. Lessons from past work that inform the current implementation.
      7. GLOSSARY.md: Reference material. Domain terms and abbreviations for lookup as needed.
      8. AGENT_PLAYBOOK.md: Meta instructions last. How to use this context system itself. Loaded last because the agent should understand the content (rules, tasks, patterns) before the operating manual.
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#constitutionmd","level":2,"title":"CONSTITUTION.md","text":"

      Purpose: Define hard invariants: Rules that must NEVER be violated, regardless of the task.

      AI tools read this first and should refuse tasks that violate these rules.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure","level":3,"title":"Structure","text":"
      # Constitution\n\nThese rules are INVIOLABLE. If a task requires violating these, the task \nis wrong.\n\n## Security Invariants\n\n* [ ] Never commit secrets, tokens, API keys, or credentials\n* [ ] Never store customer/user data in context files\n* [ ] Never disable security linters without documented exception\n\n## Quality Invariants\n\n* [ ] All code must pass tests before commit\n* [ ] No `any` types in TypeScript without documented reason\n* [ ] No TODO comments in main branch (*move to `TASKS.md`*)\n\n## Process Invariants\n\n* [ ] All architectural changes require a decision record\n* [ ] Breaking changes require version bump\n* [ ] Generated files are never committed\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines","level":3,"title":"Guidelines","text":"
      • Keep rules minimal and absolute
      • Each rule should be enforceable (can verify compliance)
      • Use checkbox format for clarity
      • Never compromise on these rules
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tasksmd","level":2,"title":"TASKS.md","text":"

      Purpose: Track current work, planned work, and blockers.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_1","level":3,"title":"Structure","text":"

      Tasks are organized by Phase: logical groupings that preserve order and enable replay.

      Tasks stay in their Phase permanently; status is tracked via checkboxes and inline tags.

      # Tasks\n\n## Phase 1: Initial Setup\n\n* [x] Set up project structure\n* [x] Configure linting and formatting\n* [ ] Add CI/CD pipeline `#in-progress`\n\n## Phase 2: Core Features\n\n* [ ] Implement user authentication `#priority:high`\n* [ ] Add API rate limiting `#priority:medium`\n  * Blocked by: Need to finalize auth first\n\n## Backlog\n\n* [ ] Performance optimization `#priority:low`\n* [ ] Add metrics dashboard `#priority:deferred`\n

      Key principles:

      • Tasks never move between sections: mark as [x] or [-] in place
      • Use #in-progress inline tag to indicate current work
      • Phase headers provide structure and replay order
      • Backlog section for unscheduled work
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tags","level":3,"title":"Tags","text":"

      Use inline backtick-wrapped tags for metadata:

      Tag Values Purpose #priority high, medium, low Task urgency #area core, cli, docs, tests Codebase area #estimate 1h, 4h, 1d Time estimate (optional) #in-progress (none) Currently being worked on

      Lifecycle tags (for session correlation):

      Tag Format When to add #added YYYY-MM-DD-HHMMSS Auto-added by ctx add task #started YYYY-MM-DD-HHMMSS When beginning work on the task

      These timestamps help correlate tasks with session files and track which session started vs completed work.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#status-markers","level":3,"title":"Status Markers","text":"Marker Meaning [ ] Pending [x] Completed [-] Skipped (include reason)","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_1","level":3,"title":"Guidelines","text":"
      • Never delete tasks; mark as [x] completed or [-] skipped
      • Never move tasks between sections; use inline tags for status
      • Use ctx task archive periodically to move completed tasks to archive
      • Mark current work with #in-progress inline tag
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#decisionsmd","level":2,"title":"DECISIONS.md","text":"

      Purpose: Record architectural decisions with rationale so they don't get re-debated.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_2","level":3,"title":"Structure","text":"
      # Decisions\n\n## [YYYY-MM-DD] Decision Title\n\n**Status**: Accepted | Superseded | Deprecated\n\n**Context**: What situation prompted this decision?\n\n**Decision**: What was decided?\n\n**Rationale**: Why was this the right choice?\n\n**Consequence**: What are the implications?\n\n**Alternatives Considered**:\n* Alternative A: Why rejected\n* Alternative B: Why rejected\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example","level":3,"title":"Example","text":"
      ## [2025-01-15] Use TypeScript Strict Mode\n\n**Status**: Accepted\n\n**Context**: Starting a new project, need to choose the type-checking level.\n\n**Decision**: Enable TypeScript strict mode with all strict flags.\n\n**Rationale**: Catches more bugs at compile time. Team has experience\nwith strict mode. Upfront cost pays off in reduced runtime errors.\n\n**Consequence**: More verbose type annotations required. Some\nthird-party libraries need type assertions.\n\n**Alternatives Considered**:\n- Basic TypeScript: Rejected because it misses null checks\n- JavaScript with JSDoc: Rejected because tooling support is weaker\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#status-values","level":3,"title":"Status Values","text":"Status Meaning Accepted Current, active decision Superseded Replaced by newer decision (link to it) Deprecated No longer relevant","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#learningsmd","level":2,"title":"LEARNINGS.md","text":"

      Purpose: Capture lessons learned, gotchas, and tips that shouldn't be forgotten.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_3","level":3,"title":"Structure","text":"
      # Learnings\n\n## Category Name\n\n### Learning Title\n\n**Discovered**: YYYY-MM-DD\n\n**Context**: When/how was this learned?\n\n**Lesson**: What's the takeaway?\n\n**Application**: How should this inform future work?\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example_1","level":3,"title":"Example","text":"
      ## Testing\n\n### Vitest Mocks Must Be Hoisted\n\n**Discovered**: 2025-01-15\n\n**Context**: Tests were failing intermittently when mocking fs module.\n\n**Lesson**: Vitest requires `vi.mock()` calls to be hoisted to the\ntop of the file. Dynamic mocks need `vi.doMock()` instead.\n\n**Application**: Always use `vi.mock()` at file top. Use `vi.doMock()`\nonly when mock needs runtime values.\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#categories","level":3,"title":"Categories","text":"

      Organize learnings by topic:

      • Testing
      • Build & Deploy
      • Performance
      • Security
      • Third-Party Libraries
      • Git and Workflow
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#conventionsmd","level":2,"title":"CONVENTIONS.md","text":"

      Purpose: Document project patterns, naming conventions, and standards.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_4","level":3,"title":"Structure","text":"
      # Conventions\n\n## Naming\n\n* **Files**: kebab-case for all source files\n* **Components**: PascalCase for React components\n* **Functions**: camelCase, verb-first (getUser, parseConfig)\n* **Constants**: SCREAMING_SNAKE_CASE\n\n## Patterns\n\n### Pattern Name\n\n**When to use**: Situation description\n\n**Implementation**:\n// in triple backticks\n// Example code\n\n**Why**: Rationale for this pattern\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_2","level":3,"title":"Guidelines","text":"
      • Include concrete examples
      • Explain the \"why\" not just the \"what\"
      • Keep patterns minimal: Only document what's non-obvious
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#architecturemd","level":2,"title":"ARCHITECTURE.md","text":"

      Purpose: Provide system overview and component relationships.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_5","level":3,"title":"Structure","text":"
      # Architecture\n\n## Overview\n\nBrief description of what the system does and how it's organized.\n\n## Components\n\n### Component Name\n\n**Responsibility**: What this component does\n\n**Dependencies**: What it depends on\n\n**Dependents**: What depends on it\n\n**Key Files**:\n* path/to/file.ts: Description\n\n## Data Flow\n\nDescription or diagram of how data moves through the system.\n\n## Boundaries\n\nWhat's in scope vs out of scope for this codebase.\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_3","level":3,"title":"Guidelines","text":"
      • Keep diagrams simple (Mermaid works well)
      • Focus on boundaries and interfaces
      • Update when major structural changes occur
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#glossarymd","level":2,"title":"GLOSSARY.md","text":"

      Purpose: Define domain terms, abbreviations, and project vocabulary.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_6","level":3,"title":"Structure","text":"
      # Glossary\n\n## Domain Terms\n\n### Term Name\n\n**Definition**: What it means in this project's context\n\n**Not to be confused with**: Similar terms that mean different things\n\n**Example**: How it's used\n\n## Abbreviations\n\n| Abbrev | Expansion                     | Context                |\n|--------|-------------------------------|------------------------|\n| ADR    | Architectural Decision Record | Decision documentation |\n| SUT    | System Under Test             | Testing                |\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_4","level":3,"title":"Guidelines","text":"
      • Define project-specific meanings
      • Clarify potentially ambiguous terms
      • Include abbreviations used in code or docs
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#agent_playbookmd","level":2,"title":"AGENT_PLAYBOOK.md","text":"

      Purpose: Explicit instructions for how AI tools should read, apply, and update context.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#key-sections","level":3,"title":"Key Sections","text":"

      Read Order: Priority order for loading context files

      When to Update: Events that trigger context updates

      How to Avoid Hallucinating Memory: Critical rules:

      1. Never assume: If not in files, you don't know it
      2. Never invent history: Don't claim \"we discussed\" without evidence
      3. Verify before referencing: Search files before citing
      4. When uncertain, say so
      5. Trust files over intuition

      Context Update Commands: Format for automated updates via ctx watch:

      <context-update type=\"task\">Implement rate limiting</context-update>\n<context-update type=\"complete\">user auth</context-update>\n<context-update type=\"learning\"\n  context=\"Debugging hooks\"\n  lesson=\"Hooks receive JSON via stdin\"\n  application=\"Parse JSON stdin with the host language\"\n>Hook Input Format</context-update>\n<context-update type=\"decision\"\n  context=\"Need a caching layer\"\n  rationale=\"Redis is fast and team has experience\"\n  consequence=\"Must provision Redis infrastructure\"\n>Use Redis for caching</context-update>\n

      See Integrations for full documentation.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#templates","level":2,"title":"templates/","text":"

      Location: .context/templates/. Status: implementation detail, user-editable.

      Purpose: Format templates for ctx add decision and ctx add learning. These control the structure of new entries appended to DECISIONS.md and LEARNINGS.md.

      ctx init deploys two starter templates:

      • decision.md: sections Context, Rationale, Consequence
      • learning.md: sections Context, Lesson, Application
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing","level":3,"title":"Customizing","text":"

      Edit the templates directly. Changes take effect immediately on the next ctx add command. For example, to add a \"References\" section to all new decisions, edit .context/templates/decision.md.

      Templates are committed to git, so customizations are shared with the team.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#steering","level":2,"title":"steering/","text":"

      Location: .context/steering/. Status: implementation detail, user-editable.

      Purpose: Behavioral rules with YAML frontmatter that tell an AI assistant how to behave when a specific kind of prompt arrives. Unlike the core context files (which describe what the project is), steering files describe what to do and ride alongside the prompt through the AI tool's native rule pipeline (Claude Code, Cursor, Kiro, Cline). ctx matches steering files to prompts and syncs them out to each tool's config.

      ctx init scaffolds four foundation files:

      • product.md: who this project serves and why
      • tech.md: the technology stack and its constraints
      • structure.md: how the code is organized
      • workflow.md: how work moves through the system

      Each file carries YAML frontmatter describing when it applies (always, matching prompts, or manually referenced) and what tool scope it covers. The foundation files use inclusion: always by default so every session picks them up.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing_1","level":3,"title":"Customizing","text":"

      Edit the files directly. Add your own steering files with ctx steering add, preview the match set with ctx steering preview, and run ctx steering sync to push them into each AI tool's config after changes. Steering files are committed to git, so they're shared with the team.

      For the design rationale, the full inclusion/priority model, and the end-to-end sync workflow, see the dedicated Steering files page.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#parsing-rules","level":2,"title":"Parsing Rules","text":"

      All context files follow these conventions:

      1. Headers define structure: # for title, ## for sections, ### for items
      2. Bold keys for fields: **Key**: followed by value
      3. Code blocks are literal: Never parse code block content as structure
      4. Lists are ordered: Items appear in priority/chronological order
      5. Tags are inline: Backtick-wrapped tags like #priority:high
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#further-reading","level":2,"title":"Further Reading","text":"
      • Refactoring with Intent: how persistent context prevents drift during refactoring sessions
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#token-efficiency","level":2,"title":"Token Efficiency","text":"

      Keep context files concise:

      • Use abbreviations in tags, not prose;
      • Omit obvious words (\"The,\" \"This\");
      • Prefer bullet points over paragraphs;
      • Keep examples minimal but illustrative;
      • Archive old completed items periodically.

      Next Up: Prompting Guide →: effective prompts for AI sessions with ctx

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/contributing/","level":1,"title":"Contributing","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#development-setup","level":2,"title":"Development Setup","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#prerequisites","level":3,"title":"Prerequisites","text":"
      • Go (version defined in go.mod)
      • Claude Code
      • Git
      • GNU Make
      • Zensical
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#1-fork-or-clone-the-repository","level":3,"title":"1. Fork (or Clone) the Repository","text":"
      # Fork on GitHub, then:\ngit clone https://github.com/<you>/ctx.git\ncd ctx\n\n# Or, if you have push access:\ngit clone https://github.com/ActiveMemory/ctx.git\ncd ctx\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#2-build-and-install-the-binary","level":3,"title":"2. Build and Install the Binary","text":"
      make build\nsudo make install\n

      This compiles the ctx binary and places it in /usr/local/bin/.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#3-install-the-plugin-from-your-local-clone","level":3,"title":"3. Install the Plugin from Your Local Clone","text":"

      The repository ships a Claude Code plugin under internal/assets/claude/. Point Claude Code at your local copy so that skills and hooks reflect your working tree: no reinstall needed after edits:

      1. Launch claude;
      2. Type /plugin and press Enter;
      3. Select Marketplaces → Add Marketplace
      4. Enter the absolute path to the root of your clone, e.g. ~/WORKSPACE/ctx (this is where .claude-plugin/marketplace.json lives: it points Claude Code to the actual plugin in internal/assets/claude);
      5. Back in /plugin, select Install and choose ctx.

      Claude Code Caches Plugin Files

      Even though the marketplace points at a directory on disk, Claude Code caches skills and hooks. After editing files under internal/assets/claude/, clear the cache and restart:

      make plugin-reload   # then restart Claude Code\n

      See Skill or Hook Changes for details.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#4-verify","level":3,"title":"4. Verify","text":"
      ctx --version       # binary is in PATH\nclaude /plugin list # plugin is installed\n

      You should see the ctx plugin listed, sourced from your local path.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#project-layout","level":2,"title":"Project Layout","text":"
      ctx/\n├── cmd/ctx/            # CLI entry point\n├── internal/\n│   ├── assets/claude/  # ← Claude Code plugin (skills, hooks)\n│   ├── bootstrap/      # Project initialization templates\n│   ├── claude/         # Claude Code integration helpers\n│   ├── cli/            # Command implementations\n│   ├── config/         # Configuration loading\n│   ├── context/        # Core context logic\n│   ├── crypto/         # Scratchpad encryption\n│   ├── drift/          # Drift detection\n│   ├── index/          # Context file indexing\n│   ├── journal/        # Journal site generation\n│   ├── memory/         # Memory bridge (discover, mirror, import, publish)\n│   ├── notify/         # Webhook notifications\n│   ├── rc/             # .ctxrc parsing\n│   ├── journal/        # Session history, parsers, and state\n│   ├── sysinfo/        # System resource monitoring\n│   ├── task/           # Task management\n│   └── validation/     # Input validation\n├── .claude/\n│   └── skills/         # Dev-only skills (not distributed)\n├── assets/             # Static assets (banners, logos)\n├── docs/               # Documentation site source\n├── editors/            # Editor extensions (VS Code)\n├── examples/           # Example configurations\n├── hack/               # Build scripts\n├── specs/              # Feature specifications\n└── .context/           # ctx's own context (dogfooding)\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#skills-two-directories-one-rule","level":3,"title":"Skills: Two Directories, One Rule","text":"Directory What lives here Distributed to users? internal/assets/claude/skills/ The 39 ctx-* skills that ship with the plugin Yes .claude/skills/ Dev-only skills (release, QA, backup, etc.) No

      internal/assets/claude/skills/ is the single source of truth for user-facing skills. If you are adding or modifying a ctx-* skill, edit it there.

      .claude/skills/ holds skills that only make sense inside this repository (release automation, QA checks, backup scripts). These are never distributed to users.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#dev-only-skills-reference","level":4,"title":"Dev-Only Skills Reference","text":"Skill When to use /_ctx-absorb Merge deltas from a parallel worktree or separate checkout /_ctx-audit Detect code-level drift after YOLO sprints or before releases /_ctx-qa Run QA checks before committing /_ctx-release Run the full release process /_ctx-release-notes Generate release notes for dist/RELEASE_NOTES.md /_ctx-alignment-audit Audit doc claims against agent instructions /_ctx-update-docs Check docs/code consistency after changes /_ctx-command-audit Audit CLI surface after renames, moves, or deletions

      Six skills previously in this list have been promoted to bundled plugin skills and are now available to all ctx users: /ctx-brainstorm, /ctx-link-check, /ctx-permission-sanitize, /ctx-skill-create, /ctx-spec.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#how-to-add-things","level":2,"title":"How to Add Things","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-new-cli-command","level":3,"title":"Adding a New CLI Command","text":"
      1. Create a package under internal/cli/<name>/ with doc.go, cmd.go, and run.go;
      2. Implement Cmd() *cobra.Command as the entry point;
      3. Add Use* and DescKey* constants in internal/config/embed/cmd/<name>.go;
      4. Add command descriptions in internal/assets/commands/commands.yaml;
      5. Add examples in internal/assets/commands/examples.yaml;
      6. Add flag descriptions in internal/assets/commands/flags.yaml;
      7. Register the command in internal/bootstrap/group.go (add import + entry in the appropriate group function);
      8. Create an output package at internal/write/<name>/ for all user-facing output (see Package Taxonomy);
      9. Create error constructors at internal/err/<name>/ for domain-specific errors;
      10. Add tests in the same package (<name>_test.go);
      11. Add a doc page at docs/cli/<name>.md and update docs/cli/index.md;
      12. Add the page to zensical.toml nav.

      Pattern to follow: internal/cli/pad/pad.go (parent with subcommands) or internal/cli/drift/ (single command).

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#package-taxonomy","level":3,"title":"Package Taxonomy","text":"

      ctx separates concerns into a strict package taxonomy. Knowing where things go prevents code review friction and keeps the AST lint tests happy.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#output-internalwrite","level":4,"title":"Output: internal/write/","text":"

      Every CLI command's user-facing output lives in its own sub-package under internal/write/<domain>/. Output functions accept *cobra.Command and call cmd.Println(...), never fmt.Print* directly. All text strings are loaded from YAML via desc.Text(text.DescKey*), never inline.

      internal/write/add/add.go       # output for ctx add\ninternal/write/stat/stat.go     # output for ctx usage\ninternal/write/resource/        # output for ctx sysinfo\n

      Exception: write/rc/ writes to os.Stderr because rc loads before cobra is initialized.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#errors-internalerr","level":4,"title":"Errors: internal/err/","text":"

      Domain-specific error constructors live under internal/err/<domain>/. Each package mirrors the write structure. Functions return error (never custom error types) and load messages from YAML via desc.Text(text.DescKey*).

      internal/err/add/add.go         # errors for ctx add\ninternal/err/config/config.go   # errors for configuration\ninternal/err/cli/cli.go         # errors for CLI argument validation\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#config-constants-internalconfig","level":4,"title":"Config Constants: internal/config/","text":"

      Pure-constant leaf packages with zero internal dependencies (stdlib only). Over 60 sub-packages, organized by domain. See internal/config/README.md for the full decision tree.

      What you're adding Where it goes File names, extensions, paths config/file/, config/dir/ Regex patterns config/regex/ CLI flag names (--flag-name) config/flag/flag.go Flag description YAML keys config/embed/flag/<cmd>.go Command Use/DescKey strings config/embed/cmd/<cmd>.go User-facing text YAML keys config/embed/text/<domain>.go Time durations, thresholds config/<domain>/","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#the-assets-pipeline","level":4,"title":"The Assets Pipeline","text":"

      User-facing text flows through a three-level chain:

      1. Go constant (config/embed/text/) defines a string key: DescKeyWriteAddedTo = \"write.added-to\"
      2. Call site resolves it: desc.Text(text.DescKeyWriteAddedTo)
      3. YAML (internal/assets/commands/text/write.yaml) holds the actual text: write.added-to: { short: \"Added to %s\" }

      The same pattern applies to command descriptions (commands.yaml), flag descriptions (flags.yaml), and examples (examples.yaml). The TestDescKeyYAMLLinkage test verifies every constant resolves to a non-empty YAML value.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-new-session-parser","level":3,"title":"Adding a New Session Parser","text":"

      The journal system uses a SessionParser interface. To add support for a new AI tool (e.g. Aider, Cursor):

      1. Create internal/journal/parser/<tool>.go;
      2. Implement parsing logic that returns []*Session;
      3. Register the parser in FindSessions() / FindSessionsForCWD();
      4. Use config.Tool* constants for the tool identifier;
      5. Add test fixtures and parser tests.

      Pattern to follow: the Claude Code JSONL parser in internal/journal/parser/.

      Multilingual Session Headers

      The Markdown parser recognizes session header prefixes configured via session_prefixes in .ctxrc (default: Session:). To support a new language, users add a prefix to their .ctxrc - no code change needed. New parser implementations can use rc.SessionPrefixes() if they also need prefix-based header detection.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-bundled-skill","level":3,"title":"Adding a Bundled Skill","text":"
      1. Create internal/assets/claude/skills/<skill-name>/SKILL.md;
      2. Follow the skill format: trigger, negative triggers, steps, quality gate;
      3. Run make plugin-reload and restart Claude Code to test;
      4. Add a Skill entry to .claude-plugin/plugin.json if user-invocable;
      5. Document in docs/reference/skills.md.

      Pattern to follow: any skill in internal/assets/claude/skills/ctx-status/.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#test-expectations","level":3,"title":"Test Expectations","text":"
      • Unit tests: colocated with source (foo.gofoo_test.go);
      • Test helpers: use t.Helper() so failures point to callers;
      • HOME isolation: use t.TempDir() + t.Setenv(\"HOME\", ...) for tests that touch ~/.claude/ or ~/.ctx/;
      • rc.Reset(): call after os.Chdir in tests that change working directory (rc caches on first access);
      • No network: all tests run offline, use fixtures.

      Run make test before submitting. Target: no failures, no skips.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#day-to-day-workflow","level":2,"title":"Day-to-Day Workflow","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#go-code-changes","level":3,"title":"Go Code Changes","text":"

      After modifying Go source files, rebuild and reinstall:

      make build && sudo make install\n

      The ctx binary is statically compiled. There is no hot reload. You must rebuild for Go changes to take effect.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#skill-or-hook-changes","level":3,"title":"Skill or Hook Changes","text":"

      Edit files under internal/assets/claude/skills/ or internal/assets/claude/hooks/.

      Claude Code caches plugin files, so edits aren't picked up automatically.

      Clear the cache and restart:

      make plugin-reload   # nukes ~/.claude/plugins/cache/activememory-ctx/\n# then restart Claude Code\n

      The plugin will be re-installed from your local marketplace on startup. No version bump is needed during development.

      Version Bumps Are for Releases, Not Iteration

      Only bump VERSION, plugin.json, and marketplace.json when cutting a release. During development, make plugin-reload is all you need.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"

      The repo ships two .ctxrc source profiles. The working copy (.ctxrc) is gitignored and swapped between them:

      File Purpose .ctxrc.base Golden baseline: all defaults, no logging .ctxrc.dev Dev profile: notify events enabled, verbose logging .ctxrc Working copy (gitignored: copied from one of the above)

      Use ctx commands to switch:

      ctx config switch dev      # switch to dev profile\nctx config switch base     # switch to base profile\nctx config status          # show which profile is active\n

      After cloning, run ctx config switch dev to get started with full logging.

      See Configuration for the full .ctxrc option reference.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#backups","level":3,"title":"Backups","text":"

      ctx does not ship a backup command. File-level backup is an OS / infrastructure concern; ctx hub handles the cross-machine knowledge persistence that matters most. For everything else, see Backup Strategy: rsync, Time Machine, Borg, or whichever tool already handles the rest of your files.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-tests","level":3,"title":"Running Tests","text":"
      make test   # fast: all tests\nmake audit  # full: fmt + vet + lint + drift + docs + test\nmake smoke  # build + run basic commands end-to-end\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-the-docs-site-locally","level":3,"title":"Running the Docs Site Locally","text":"
      make site-setup  # one-time: install zensical via pipx\nmake site-serve  # serve at localhost\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#submitting-changes","level":2,"title":"Submitting Changes","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#before-you-start","level":3,"title":"Before You Start","text":"
      1. Check existing issues to avoid duplicating effort;
      2. For large changes, open an issue first to discuss the approach;
      3. Read the specs in specs/ for design context.
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#pull-request-process","level":3,"title":"Pull Request Process","text":"

      Respect the maintainers' time and energy: Keep your pull requests isolated and strive to minimze code changes.

      If you Pull Request solves more than one distinct issues, it's better to create separate pull requests instead of sending them in one large bundle.

      1. Create a feature branch: git checkout -b feature/my-feature;
      2. Make your changes;
      3. Run make audit to catch issues early;
      4. Commit with a clear message;
      5. Push and open a pull request.

      Audit Your Code Before Submitting

      Run make audit before submitting:

      make audit covers formatting, vetting, linting, drift checks, doc consistency, and tests in one pass.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#commit-messages","level":3,"title":"Commit Messages","text":"

      Following conventional commits is recommended but not required:

      Types: feat, fix, docs, test, refactor, chore

      Examples:

      • feat(cli): add ctx export command
      • fix(drift): handle missing files gracefully
      • docs: update installation instructions
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-style","level":3,"title":"Code Style","text":"
      • Follow Go conventions (gofmt, go vet);
      • Keep functions focused and small;
      • Add tests for new functionality;
      • Handle errors explicitly; use descriptive names (readErr, writeErr) not repeated err;
      • No magic strings: all repeated literals go in internal/config/;
      • Output goes through internal/write/ packages, not fmt.Print*;
      • Errors go through internal/err/ constructors, not inline fmt.Errorf;
      • See Package Taxonomy and .context/CONVENTIONS.md for the full reference.
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-of-conduct","level":2,"title":"Code of Conduct","text":"

      A clear context requires respectful collaboration.

      ctx follows the Contributor Covenant.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#boring-legal-stuff","level":2,"title":"Boring Legal Stuff","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#developer-certificate-of-origin-dco","level":3,"title":"Developer Certificate of Origin (DCO)","text":"

      By contributing, you agree to the Developer Certificate of Origin.

      All commits must be signed off:

      git commit -s -m \"feat: add new feature\"\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#license","level":3,"title":"License","text":"

      Contributions are licensed under the Apache 2.0 License.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/faq/","level":1,"title":"FAQ","text":"","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#why-markdown","level":2,"title":"Why Markdown?","text":"

      Markdown is human-readable, version-controllable, and tool-agnostic. Every AI model can parse it natively. Every developer can read it in a terminal, a browser, or a code review. There's no schema to learn, no binary format to decode, no vendor lock-in. You can inspect your context with cat, diff it with git diff, and review it in a PR.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#does-ctx-work-offline","level":2,"title":"Does ctx Work Offline?","text":"

      Yes. ctx is completely local. It reads and writes files on disk, generates context packets from local state, and requires no network access. The only feature that touches the network is the optional webhook notifications hook, which you have to explicitly configure.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#what-gets-committed-to-git","level":2,"title":"What Gets Committed to Git?","text":"

      The .context/ directory: yes, commit it. That's the whole point. Team members and AI agents read the same context files.

      What not to commit:

      • .ctx.key: your encryption key. Stored at ~/.ctx/.ctx.key, never in the repo. ctx init handles this automatically.
      • journal/ and logs/: generated data, potentially large. ctx init adds these to .gitignore.
      • scratchpad.enc: your choice. It's encrypted, so it's safe to commit if you want shared scratchpad state. See Scratchpad for details.
      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#how-big-should-my-token-budget-be","level":2,"title":"How Big Should My Token Budget Be?","text":"

      The default is 8000 tokens, which works well for most projects. Configure it via .ctxrc or the CTX_TOKEN_BUDGET environment variable:

      # In .ctxrc\ntoken_budget = 12000\n\n# Or as an environment variable\nexport CTX_TOKEN_BUDGET=12000\n\n# Or per-invocation\nctx agent --budget 4000\n

      Higher budgets include more context but cost more tokens per request. Lower budgets force sharper prioritization: ctx drops lower-priority content first, so CONSTITUTION and TASKS always make the cut.

      See Configuration for all available settings.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#why-not-a-database","level":2,"title":"Why Not a Database?","text":"

      Files are inspectable, diffable, and reviewable in pull requests. You can grep them, cat them, pipe them through jq or awk. They work with every version control system and every text editor.

      A database would add a dependency, require migrations, and make context opaque. The design bet is that context should be as visible and portable as the code it describes.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#does-it-work-with-tools-other-than-claude-code","level":2,"title":"Does It Work with Tools Other than Claude Code?","text":"

      Yes. ctx agent outputs a context packet that any AI tool can consume: paste it into ChatGPT, Cursor, Copilot, Aider, or anything else that accepts text input.

      Claude Code gets first-class integration via the ctx plugin (hooks, skills, automatic context loading). VS Code Copilot Chat has a dedicated ctx extension. Other tools integrate via generated instruction files or manual pasting.

      See Integrations for tool-specific setup, including the multi-tool recipe.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#can-i-use-ctx-on-an-existing-project","level":2,"title":"Can I Use ctx on an Existing Project?","text":"

      Yes. Run ctx init in any repo and it creates .context/ with template files. Start recording decisions, tasks, and conventions as you work. Context grows naturally; you don't need to backfill everything on day one.

      See Getting Started for the full setup flow, or Joining a ctx Project if someone else already initialized it.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#what-happens-when-context-files-get-too-big","level":2,"title":"What Happens When Context Files Get Too Big?","text":"

      Token budgeting handles this automatically. ctx agent prioritizes content by file priority (CONSTITUTION first, GLOSSARY last) and trims lower-priority entries when the budget is tight.

      For manual maintenance, ctx compact archives completed tasks and old entries, keeping active context lean. You can also run ctx task archive to move completed tasks out of TASKS.md.

      The goal is to keep context files focused on current state. Historical entries belong in git history or the archive.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#is-context-meant-to-be-shared","level":2,"title":"Is .context/ Meant to Be Shared?","text":"

      Yes. Commit it to your repo. Every team member and every AI agent reads the same files. That's the mechanism for shared memory: decisions made in one session are visible in the next, regardless of who (or what) starts it.

      The only per-user state is the encryption key (~/.ctx/.ctx.key) and the optional scratchpad. Everything else is team-shared by design.

      Related:

      • Getting Started - installation and first setup
      • Configuration - .ctxrc, environment variables, and defaults
      • Context Files - what each file does and how to use it
      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/first-session/","level":1,"title":"Your First Session","text":"

      Here's what a complete first session looks like, from initialization to the moment your AI cites your project context back to you.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-1-initialize-your-project","level":2,"title":"Step 1: Initialize Your Project","text":"

      Run ctx init in your project root:

      cd your-project\nctx init\n

      Sample output:

      Context initialized in .context/\n\n  ✓ CONSTITUTION.md\n  ✓ TASKS.md\n  ✓ DECISIONS.md\n  ✓ LEARNINGS.md\n  ✓ CONVENTIONS.md\n  ✓ ARCHITECTURE.md\n  ✓ GLOSSARY.md\n  ✓ AGENT_PLAYBOOK.md\n\nSetting up encryption key...\n  ✓ ~/.ctx/.ctx.key\n\nClaude Code plugin (hooks + skills):\n  Install: claude /plugin marketplace add ActiveMemory/ctx\n  Then:    claude /plugin install ctx@activememory-ctx\n\nNext steps:\n  1. Edit .context/TASKS.md to add your current tasks\n  2. Run 'ctx status' to see context summary\n  3. Run 'ctx agent' to get AI-ready context packet\n

      This created your .context/ directory with template files.

      For Claude Code, install the ctx plugin to get automatic hooks and skills.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-2-activate-the-project","level":2,"title":"Step 2: Activate the Project","text":"

      Tell ctx which .context/ directory the rest of these commands should use:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the next steps fail with Error: no context directory specified. Direnv users can wire it into .envrc and forget about it. For more options (multiple .context/ directories, scripts, CI), see Activating a Context Directory.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-3-populate-your-context","level":2,"title":"Step 3: Populate Your Context","text":"

      Add a task and a decision: These are the entries your AI will remember:

      ctx add task \"Implement user authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Output: ✓ Added to TASKS.md\n\nctx add decision \"Use PostgreSQL for primary database\" \\\n  --context \"Need a reliable database for production\" \\\n  --rationale \"PostgreSQL offers ACID compliance and JSON support\" \\\n  --consequence \"Team needs PostgreSQL training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Output: ✓ Added to DECISIONS.md\n

      These entries are what the AI will recall in future sessions. You don't need to populate everything now: Context grows naturally as you work.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-4-check-your-context","level":2,"title":"Step 4: Check Your Context","text":"
      ctx status\n

      Sample output:

      Context Status\n====================\n\nContext Directory: .context/\nTotal Files: 8\nToken Estimate: 1,247 tokens\n\nFiles:\n  ✓ CONSTITUTION.md (loaded)\n  ✓ TASKS.md (1 items)\n  ✓ DECISIONS.md (1 items)\n  ○ LEARNINGS.md (empty)\n  ✓ CONVENTIONS.md (loaded)\n  ✓ ARCHITECTURE.md (loaded)\n  ✓ GLOSSARY.md (loaded)\n  ✓ AGENT_PLAYBOOK.md (loaded)\n\nRecent Activity:\n  - TASKS.md modified 2 minutes ago\n  - DECISIONS.md modified 1 minute ago\n

      Notice the token estimate: This is how much context your AI will load.

      The next to LEARNINGS.md means it's still empty; it will fill in as you capture lessons during development.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-5-start-an-ai-session","level":2,"title":"Step 5: Start an AI Session","text":"

      With Claude Code (and the ctx plugin), start every session with:

      /ctx-remember\n

      This loads your context and presents a structured readback so you can confirm the agent knows what is going on. Context also loads automatically via hooks, but the explicit ceremony gives you a readback to verify.

      Steering Files Fire Automatically

      If you edited the four foundation files scaffolded by ctx init (.context/steering/product.md, tech.md, structure.md, workflow.md), their inclusion: always rules are prepended to every tool call via the plugin's PreToolUse hook, with no /ctx-remember needed, no MCP call. Edit a file, save, and the next tool call in Claude Code picks it up. See Steering files for details on the inclusion modes.

      Using VS Code?

      With VS Code Copilot Chat (and the ctx extension), type @ctx /agent in chat to load your context packet, or @ctx /status to check your project context. Run ctx setup copilot --write once to generate .github/copilot-instructions.md for automatic context loading.

      If you are not using Claude Code, generate a context packet for your AI tool:

      ctx agent --budget 8000\n

      Sample output:

      # Context Packet\nGenerated: 2026-02-14T15:30:45Z | Budget: 8000 tokens | Used: ~2450\n\n## Read These Files (in order)\n1. .context/CONSTITUTION.md\n2. .context/TASKS.md\n3. .context/CONVENTIONS.md\n...\n\n## Current Tasks\n- [ ] Implement user authentication\n- [ ] Add rate limiting to API endpoints\n\n## Key Conventions\n- Use gofmt for formatting\n- Path construction uses filepath.Join\n\n## Recent Decisions\n## [2026-02-14-120000] Use PostgreSQL for the primary database\n\n**Context**: Evaluated PostgreSQL, MySQL, and SQLite...\n**Rationale**: PostgreSQL offers better JSON support...\n\n## Key Learnings\n## [2026-02-14-100000] Connection pool sizing matters\n\n**Context**: Hit connection limits under load...\n**Lesson**: Default pool size of 10 is too low for concurrent requests...\n\n## Also Noted\n- Use JWT for session management\n- Always validate input at API boundary\n

      Paste this output into your AI tool's system prompt or conversation start.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-6-verify-it-works","level":2,"title":"Step 6: Verify It Works","text":"

      Ask your AI: \"What are our current tasks?\"

      A working setup produces a response like:

      Based on the project context, you have one active task:\n\n- **Implement user authentication** (pending)\n\nThere's also a recent architectural decision to **use PostgreSQL for\nthe primary database**, chosen for its ACID compliance and JSON support.\n\nWant me to start on the authentication task?\n

      That's the success moment:

      The AI is citing your exact context entries from Step 2, not hallucinating or asking you to re-explain.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-gets-created","level":2,"title":"What Gets Created","text":"
      .context/\n├── CONSTITUTION.md     # Hard rules: NEVER violate these\n├── TASKS.md            # Current and planned work\n├── CONVENTIONS.md      # Project patterns and standards\n├── ARCHITECTURE.md     # System overview\n├── DECISIONS.md        # Architectural decisions with rationale\n├── LEARNINGS.md        # Lessons learned, gotchas, tips\n├── GLOSSARY.md         # Domain terms and abbreviations\n└── AGENT_PLAYBOOK.md   # How AI tools should use this\n

      Claude Code integration (hooks + skills) is provided by the ctx plugin: See Integrations/Claude Code.

      VS Code Copilot Chat integration is provided by the ctx extension: See Integrations/VS Code.

      See Context Files for detailed documentation of each file.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-to-gitignore","level":2,"title":"What to .gitignore","text":"

      Rule of Thumb

      • If it's knowledge (decisions, tasks, learnings, conventions), commit it.
      • If it's generated output, raw session data, or a secret, .gitignore it.

      Commit your .context/ knowledge files: that's the whole point.

      You should .gitignore the generated and sensitive paths:

      # Journal data (large, potentially sensitive)\n.context/journal/\n.context/journal-site/\n.context/journal-obsidian/\n\n# Hook logs (machine-specific)\n.context/logs/\n\n# Legacy encryption key path (copy to ~/.ctx/.ctx.key if needed)\n.context/.ctx.key\n\n# Claude Code local settings (machine-specific)\n.claude/settings.local.json\n

      ctx init Patches Your .Gitignore for You

      ctx init automatically adds these entries to your .gitignore.

      Review the additions with cat .gitignore after init.

      See also:

      • Security Considerations
      • Scratchpad Encryption
      • Session Journal

      Next Up: Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/getting-started/","level":1,"title":"Getting Started","text":"","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#prerequisites","level":2,"title":"Prerequisites","text":"

      ctx does not require git, but using version control with your .context/ directory is strongly recommended:

      AI sessions occasionally modify or overwrite context files inadvertently. With git, the AI can check history and restore lost content: Without it, the data is gone.

      Also, several ctx features (journal changelog, blog generation) also use git history directly.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#installation","level":2,"title":"Installation","text":"

      Every setup starts with the ctx binary: the CLI tool itself.

      If you use Claude Code, you also install the ctx plugin, which adds hooks (context autoloading, persistence nudges) and 25+ /ctx-* skills. For other AI tools, ctx integrates via generated instruction files or manual context pasting: see Integrations for tool-specific setup.

      Pick one of the options below to install the binary. Claude Code users should also follow the plugin steps included in each option.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#option-1-build-from-source-recommended","level":3,"title":"Option 1: Build from Source (Recommended)","text":"

      Requires Go (version defined in go.mod) and Claude Code.

      git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\nmake build\nsudo make install\n

      Install the Claude Code plugin from your local clone:

      1. Launch claude;
      2. Type /plugin and press Enter;
      3. Select Marketplaces → Add Marketplace
      4. Enter the path to the root of your clone, e.g. ~/WORKSPACE/ctx (this is where .claude-plugin/marketplace.json lives: It points Claude Code to the actual plugin in internal/assets/claude)
      5. Back in /plugin, select Install and choose ctx

      This points Claude Code at the plugin source on disk. Changes you make to hooks or skills take effect immediately: No reinstall is needed.

      Local Installs Need Manual Enablement

      Unlike marketplace installs, local plugin installs are not auto-enabled globally. The plugin will only work in projects that explicitly enable it. Run ctx init in each project (it auto-enables the plugin), or add the entry to ~/.claude/settings.json manually:

      { \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n

      Verify:

      ctx --version       # binary is in PATH\nclaude /plugin list # plugin is installed\n

      Use the Source, Luke

      Building from source gives you the latest features and bug fixes.

      Since ctx is predominantly a developer tool, this is the recommended approach:

      You get the freshest code, can inspect what you are installing, and the plugin stays in sync with the binary.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#option-2-binary-download-marketplace","level":3,"title":"Option 2: Binary Download + Marketplace","text":"

      Pre-built binaries are available from the releases page.

      Linux (x86_64)Linux (ARM64)macOS (Apple Silicon)macOS (Intel)Windows
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-linux-amd64\nchmod +x ctx-0.8.1-linux-amd64\nsudo mv ctx-0.8.1-linux-amd64 /usr/local/bin/ctx\n
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-linux-arm64\nchmod +x ctx-0.8.1-linux-arm64\nsudo mv ctx-0.8.1-linux-arm64 /usr/local/bin/ctx\n
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-darwin-arm64\nchmod +x ctx-0.8.1-darwin-arm64\nsudo mv ctx-0.8.1-darwin-arm64 /usr/local/bin/ctx\n
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-darwin-amd64\nchmod +x ctx-0.8.1-darwin-amd64\nsudo mv ctx-0.8.1-darwin-amd64 /usr/local/bin/ctx\n

      Download ctx-0.8.1-windows-amd64.exe from the releases page and add it to your PATH.

      Claude Code users: install the plugin from the marketplace:

      1. Launch claude;
      2. Type /plugin and press Enter;
      3. Select Marketplaces → Add Marketplace;
      4. Enter ActiveMemory/ctx;
      5. Back in /plugin, select Install and choose ctx.

      Other tool users: see Integrations for tool-specific setup (Cursor, Copilot, Aider, Windsurf, etc.).

      Verify the Plugin Is Enabled

      After installing, confirm the plugin is enabled globally. Check ~/.claude/settings.json for an enabledPlugins entry. If missing, run ctx init in your project (it auto-enables the plugin), or add it manually:

      { \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n

      Verify:

      ctx --version       # binary is in PATH\nclaude /plugin list # plugin is installed (Claude Code only)\n
      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#verifying-checksums","level":4,"title":"Verifying Checksums","text":"

      Each binary has a corresponding .sha256 checksum file. To verify your download:

      # Download the checksum file\ncurl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-linux-amd64.sha256\n\n# Verify the binary\nsha256sum -c ctx-0.8.1-linux-amd64.sha256\n

      On macOS, use shasum -a 256 -c instead of sha256sum -c.

      Plugin Details

      After installation (either option) you get:

      • Context autoloading: ctx agent runs on every tool use (with cooldown)
      • Persistence nudges: reminders to capture learnings and decisions
      • Post-commit hooks: nudge context capture after git commit
      • Context size monitoring: alerts as sessions grow large
      • Project skills: /ctx-status, /ctx-task-add, /ctx-history, and more

      See Integrations for the full hook and skill reference.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#quick-start","level":2,"title":"Quick Start","text":"","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#1-initialize-context","level":3,"title":"1. Initialize Context","text":"
      cd your-project\nctx init\n

      This creates a .context/ directory with template files and an encryption key at ~/.ctx/ for the encrypted scratchpad. For Claude Code, install the ctx plugin for automatic hooks and skills.

      ctx init also scaffolds four foundation steering files in .context/steering/; these are behavioral-rule templates that tell your AI how to act on your project:

      File What it captures product.md Product context, goals, and target users tech.md Technology stack, constraints, key dependencies structure.md Project structure and directory conventions workflow.md Development workflow and process rules

      Each file starts with a self-documenting HTML comment explaining the three inclusion modes (always / auto / manual), priority, and tool scoping. The defaults are set to inclusion: always and priority: 10, so they fire on every AI tool call until you edit them.

      You should open each of these files and replace the placeholder content with your project's actual rules. Running ctx init again won't clobber your edits; existing files are left alone. To opt out entirely, use ctx init --no-steering-init.

      See Writing Steering Files for the full walkthrough, or ctx steering for the command reference.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#2-activate-the-project","level":3,"title":"2. Activate the Project","text":"

      Tell ctx which .context/ directory the rest of these commands should use:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the next steps fail with Error: no context directory specified. Direnv users can wire it into .envrc and forget about it. For more options (multiple .context/ directories, scripts, CI), see Activating a Context Directory.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#3-check-status","level":3,"title":"3. Check Status","text":"
      ctx status\n

      Shows context summary: files present, token estimate, and recent activity.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#4-start-using-with-ai","level":3,"title":"4. Start Using with AI","text":"

      With Claude Code (and the ctx plugin installed), context loads automatically via hooks.

      With VS Code Copilot Chat, install the ctx extension and use @ctx /status, @ctx /agent, and other slash commands directly in chat. Run ctx setup copilot --write to generate .github/copilot-instructions.md for automatic context loading.

      For other tools, paste the output of:

      ctx agent --budget 8000\n
      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#4b-set-up-for-your-ai-tool","level":3,"title":"4B. Set Up for Your AI Tool","text":"

      If you use an MCP-compatible tool, generate the integration config with ctx setup:

      KiroCursorCline
      ctx setup kiro --write\n# Creates .kiro/settings/mcp.json and syncs steering files\n
      ctx setup cursor --write\n# Creates .cursor/mcp.json and syncs steering files\n
      ctx setup cline --write\n# Creates .vscode/mcp.json and syncs steering files\n

      This registers the ctx MCP server and syncs any steering files into the tool's native format. Re-run after adding or changing steering files.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#5-verify-it-works","level":3,"title":"5. Verify It Works","text":"

      Ask your AI: \"Do you remember?\"

      It should cite specific context: current tasks, recent decisions, or previous session topics.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#6-set-up-companion-tools-highly-recommended","level":3,"title":"6. Set Up Companion Tools (Highly Recommended)","text":"

      ctx works on its own, but two companion MCP servers unlock significantly better agent behavior. The investment is small and the benefits compound over sessions:

      • Gemini Search grounded web search with citations. Skills like /ctx-code-review and /ctx-explain use it for up-to-date documentation lookups instead of relying on training data.
      • GitNexus: code knowledge graph with symbol resolution, blast radius analysis, and domain clustering. Skills like /ctx-refactor and /ctx-code-review use it for impact analysis and dependency awareness.

      # Index your project for GitNexus (run once, then after major changes)\nnpx gitnexus analyze\n

      Both are optional MCP servers: if they are not connected, skills degrade gracefully to built-in capabilities. See Companion Tools for setup details and verification.

      Next Up:

      • Your First Session →: a step-by-step walkthrough from ctx init to verified recall
      • Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history
      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/hub/","level":1,"title":"Hub","text":"","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#sharing-is-caring","level":2,"title":"Sharing Is Caring","text":"

      ctx projects are normally independent: each project has its own .context/ directory, its own decisions, its own learnings, its own journal. That's the right default, since most work is project-local, and mixing context across projects tends to dilute more than it helps.

      But sometimes a decision or a learning should cross project boundaries. A convention you codified in one project deserves to be visible in another. A gotcha you discovered debugging service A is the same gotcha waiting for you in service B. The ctx Hub is the feature that makes those specific entries travel, without replicating everything else.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#what-the-hub-actually-is","level":2,"title":"What the Hub Actually Is","text":"

      In one paragraph: the ctx Hub is a fan-out channel for four specific kinds of structured entries: decision, learning, convention, and task. You publish an entry with ctx add --share in one project, and it appears in .context/hub/ for every other project subscribed to that type. When you run ctx agent --include-hub, those shared entries become part of your next agent context packet.

      That is the entire feature. The Hub does not:

      • Share your session journal (.context/journal/). That stays local to each project.
      • Share your scratchpad (.context/pad). Encrypted notes never leave the machine that created them.
      • Share your TASKS.md, DECISIONS.md, LEARNINGS.md, or CONVENTIONS.md wholesale. Only entries you explicitly --share cross the boundary.
      • Provide user identity or attribution. The Hub identifies projects, not people.

      If you want \"my agent in project B sees everything my agent did in project A,\" that's not the Hub. Local session density stays local.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#who-its-for","level":2,"title":"Who It's For","text":"

      Two shapes, same mechanics, different trust models.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"

      One developer, many projects. You want a learning from project A to show up when you open project B a week later. You want a convention you codified in your dotfiles project to be visible everywhere else on your workstation. Run a Hub on localhost, register each project, done.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#small-trusted-team","level":3,"title":"Small Trusted Team","text":"

      A few teammates on a LAN or a hub.ctx-like self-hosted server. You want team conventions to propagate without a wiki. You want lessons from one on-call engineer's 3 AM incident to reach everyone else's agent on the next session. Same mechanics as the personal case, plus TLS in front and a short security runbook.

      The Hub is not a multi-tenant public service. It assumes everyone holding a client token is friendly. Don't stand up hub.example.com for untrusted participants.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#going-further","level":2,"title":"Going Further","text":"
      • First-time setup: Hub: Getting Started, a five-minute walkthrough on localhost.
      • Mental model and user stories: Hub Overview, what flows, what doesn't, and when not to use it.
      • Team / LAN deployment: Multi-machine setup.
      • Redundancy: HA cluster.
      • Operating a Hub: Hub Operations and Hub Failure Modes.
      • Security posture: Hub Security Model.
      • Command reference: ctx serve, ctx connect, ctx hub.
      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/is-ctx-right/","level":1,"title":"Is It Right for Me?","text":"","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#good-fit","level":2,"title":"Good Fit","text":"

      ctx shines when context matters more than code.

      If any of these sound like your project, it's worth trying:

      • Multi-session AI work: You use AI across many sessions on the same codebase, and re-explaining is slowing you down.
      • Architectural decisions that matter: Your project has non-obvious choices (database, auth strategy, API design) that the AI keeps second-guessing.
      • \"Why\" matters as much as \"what\": you need the AI to understand rationale, not just current code
      • Team handoffs: Multiple people (or multiple AI tools) work on the same project and need shared context.
      • AI-assisted development across tools: Uou switch between Claude Code, Cursor, Copilot, or other tools and want context to follow the project, not the tool.
      • Long-lived projects: Anything you'll work on for weeks or months, where accumulated knowledge has compounding value.
      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#may-not-be-the-right-fit","level":2,"title":"May Not Be the Right Fit","text":"

      ctx adds overhead that isn't worth it for every project. Be honest about when to skip it:

      • One-off scripts: If the project is a single file you'll finish today, there's nothing to remember.
      • RAG-only workflows: If retrieval from an external knowledge base already gives the agent everything it needs for each session, adding ctx may be unnecessary. RAG retrieves information; ctx defines the project's working memory: They are complementary.
      • No AI involvement: ctx is designed for human-AI workflows; without an AI consumer, the files are just documentation.
      • Enterprise-managed context platforms: If your organization provides centralized context services, ctx may duplicate that layer.

      For a deeper technical comparison with RAG, prompt management tools, and agent frameworks, see ctx and Similar Tools.

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#project-size-guide","level":2,"title":"Project Size Guide","text":"","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#solo-developer-single-repo","level":3,"title":"Solo Developer, Single Repo","text":"

      This is ctx's sweet spot.

      You get the most value here: one person, one project, decisions, and learnings accumulating over time. Setup takes 5 minutes and the .context/ directory directory stays small, and every session gets faster.

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#small-team-one-or-two-repos","level":3,"title":"Small Team, One or Two Repos","text":"

      Works well.

      Context files commit to git, so the whole team shares the same decisions and conventions. Each person's AI starts with the team's decisions already loaded. Merge conflicts on .context/ files are rare and easy to resolve (they are just Markdown).

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#multiple-repos-or-larger-teams","level":3,"title":"Multiple Repos or Larger Teams","text":"

      ctx operates per repository.

      Each repo has its own .context/ directory with its own decisions, tasks, and learnings. This matches the way code, ownership, and history already work in git.

      There is no built-in cross-repo context layer.

      For organizations that need centralized, organization-wide knowledge, ctx complements a platform solution by providing durable, project-local working memory for AI sessions.

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#5-minute-trial","level":2,"title":"5-Minute Trial","text":"

      Zero commitment. Try it, and delete .context/ if it's not for you.

      Using Claude Code?

      Install the ctx plugin from the Marketplace for Claude-native hooks, skills, and automatic context loading:

      1. Type /plugin and press Enter
      2. Select Marketplaces → Add Marketplace
      3. Enter ActiveMemory/ctx
      4. Back in /plugin, select Install and choose ctx

      You'll still need the ctx binary for the CLI: See Getting Started for install options.

      # 1. Initialize\ncd your-project\nctx init\n\n# 2. Activate the project (bind CTX_DIR for this shell).\n#    Required: ctx does not walk the filesystem to find .context/.\neval \"$(ctx activate)\"\n\n# 3. Add one real decision from your project\nctx add decision \"Your actual architectural choice\" \\\n  --context \"What prompted this decision\" \\\n  --rationale \"Why you chose this approach\" \\\n  --consequence \"What changes as a result\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# 4. Check what the AI will see\nctx status\n\n# 5. Start an AI session and ask: \"Do you remember?\"\n

      If the AI cites your decision back to you, it's working.

      Want to remove it later? One command:

      rm -rf .context/\n

      No dependencies to uninstall. No configuration to revert. Just files.

      Ready to try it out?

      • Join the Community→: Open Source is better together.
      • Getting Started →: Full installation and setup.
      • ctx and Similar Tools →: Detailed comparison with other approaches.
      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/joining-a-project/","level":1,"title":"Joining a Project","text":"

      You've joined a team or inherited a project, and there's a .context/ directory in the repo. Good news: someone already set up persistent context. This page gets you oriented fast.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#what-to-read-first","level":2,"title":"What to Read First","text":"

      The files in .context/ have a deliberate priority order. Read them top-down:

      1. CONSTITUTION.md: Hard rules. Read this before you touch anything. These are inviolable constraints the team has agreed on.
      2. TASKS.md: Current and planned work. Shows what's in progress, what's pending, and what's blocked.
      3. CONVENTIONS.md: How the team writes code. Naming patterns, file organization, preferred idioms.
      4. ARCHITECTURE.md: System overview. Components, boundaries, data flow.
      5. DECISIONS.md: Why things are the way they are. Saves you from re-proposing something the team already evaluated and rejected.
      6. LEARNINGS.md: Gotchas, tips, and hard-won lessons. The stuff that doesn't fit anywhere else but will save you hours.

      See Context Files for detailed documentation of each file's structure and purpose.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#activate-the-project","level":2,"title":"Activate the Project","text":"

      Tell ctx which .context/ directory to read from:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the commands in the rest of this guide fail with Error: no context directory specified. Direnv users can wire it into .envrc and forget about it. See Activating a Context Directory for more options (multiple .context/ directories, scripts, CI).

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#checking-context-health","level":2,"title":"Checking Context Health","text":"

      Before you start working, check whether the context is current:

      ctx status\n

      This shows file counts, token estimates, and recent activity. If files haven't been touched in weeks, the context may be stale.

      ctx drift\n

      This compares context files against recent code changes and flags potential drift: decisions that no longer match the codebase, conventions that have shifted, or tasks that look outdated.

      If things are stale, mention it to the team. Don't silently fix it yourself on day one.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#starting-your-first-session","level":2,"title":"Starting Your First Session","text":"

      Generate a context packet to prime your AI:

      ctx agent --budget 8000\n

      This outputs a token-budgeted summary of the project context, ordered by priority. With Claude Code and the ctx plugin, context loads automatically via hooks. You can also use the /ctx-remember skill to get a structured readback of what the AI knows.

      The readback is your verification step: if the AI can cite specific tasks and decisions, the context is working.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#adding-context","level":2,"title":"Adding Context","text":"

      As you work, you'll discover things worth recording. Use the CLI:

      # Record a decision you made or learned about\nctx add decision \"Use connection pooling for DB access\" \\\n  --rationale \"Reduces connection overhead under load\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Capture a gotcha you hit\nctx add learning \"Redis timeout defaults to 5s\" \\\n  --context \"Hit timeouts during bulk operations\" \\\n  --application \"Set explicit timeout for batch jobs\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Add a convention you noticed the team follows\nctx add convention \"All API handlers return structured errors\"\n

      You can also just tell the AI: \"Record this as a learning\" or \"Add this decision to context.\" With the ctx plugin, context-update commands handle the file writes.

      See the Knowledge Capture recipe for the full workflow.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#session-etiquette","level":2,"title":"Session Etiquette","text":"

      A few norms for working in a ctx-managed project:

      • Respect existing conventions. If CONVENTIONS.md says \"use filepath.Join,\" use filepath.Join. If you disagree, propose a change, don't silently diverge.
      • Don't restructure context files without asking. The file layout and section structure are shared state. Reorganizing them affects every team member and every AI session.
      • Mark tasks done when complete. Check the box ([x]) in place. Don't move tasks between sections or delete them.
      • Add context as you go. Decisions, learnings, and conventions you discover are valuable to the next person (or the next session).
      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"

      Ignoring CONSTITUTION.md. The constitution exists for a reason. If a task conflicts with a constitution rule, the task is wrong. Raise it with the team instead of working around the constraint.

      Deleting tasks. Never delete a task from TASKS.md. Mark it [x] (done) or [-] (skipped with a reason). The history matters for session replay and audit.

      Bypassing hooks. If the project uses ctx hooks (pre-commit nudges, context autoloading), don't disable them. They exist to keep context fresh. If a hook is noisy or broken, fix it or file a task.

      Over-contributing on day one. Read first, then contribute. Adding a dozen learnings before you understand the project's norms creates noise, not signal.

      Related:

      • Getting Started: installation and setup from scratch
      • Context Files: detailed file reference
      • Knowledge Capture: recording decisions, learnings, and conventions
      • Session Lifecycle: how a typical AI session flows with ctx
      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/keeping-ai-honest/","level":1,"title":"Keeping AI Honest","text":"","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-problem","level":2,"title":"The Problem","text":"

      AI agents confabulate. They invent history that never happened, claim familiarity with decisions that were never made, and sometimes declare a task complete when it is not. This is not malice - it is the default behavior of a system optimizing for plausible-sounding responses.

      When your AI says \"we decided to use Redis for caching last week,\" can you verify that? When it says \"the auth module is complete,\" can you confirm it? Without grounded, persistent context, the answer is no. You are trusting vibes.

      ctx replaces vibes with verifiable artifacts.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#grounded-memory","level":2,"title":"Grounded Memory","text":"

      Every entry in ctx context files has a timestamp and structured fields. When the AI cites a decision, you can check it.

      ## [2026-01-28-143022] Use Event Sourcing for Audit Trail\n\n**Status**: Accepted\n\n**Context**: Compliance requires full mutation history.\n\n**Decision**: Event sourcing for the audit subsystem only.\n\n**Rationale**: Append-only log meets compliance requirements\nwithout imposing event sourcing on the entire domain model.\n

      The timestamp 2026-01-28-143022 is not decoration. It is a verifiable anchor. If the AI references this decision, you can open DECISIONS.md, find the entry, and confirm it says what the AI claims. If the entry does not exist, the AI is hallucinating - and you know immediately.

      This is grounded memory: claims that trace back to artifacts you control and can audit.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#constitutionmd-hard-guardrails","level":2,"title":"CONSTITUTION.md: Hard Guardrails","text":"

      CONSTITUTION.md defines rules the AI must treat as inviolable. These are not suggestions or best practices - they are constraints that override task requirements.

      # Constitution\n\nThese rules are INVIOLABLE. If a task requires violating these,\nthe task is wrong.\n\n* [ ] Never commit secrets, tokens, API keys, or credentials\n* [ ] All public API changes require a decision record\n* [ ] Never delete context files without explicit user approval\n

      The AI reads these at session start, before anything else. A well- integrated agent will refuse a task that conflicts with a constitutional rule, citing the specific rule it would violate.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-agent-playbooks-anti-hallucination-rules","level":2,"title":"The Agent Playbook's Anti-Hallucination Rules","text":"

      The AGENT_PLAYBOOK.md file includes a section called \"How to Avoid Hallucinating Memory\" with five explicit rules:

      1. Never assume. If it is not in the context files, you do not know it.
      2. Never invent history. Do not claim \"we discussed\" something without a file reference.
      3. Verify before referencing. Search files before citing them.
      4. When uncertain, say so. \"I don't see a decision on this\" is always better than a fabricated one.
      5. Trust files over intuition. If the files say PostgreSQL but your training data suggests MySQL, the files win.

      These rules create a behavioral contract. The AI is not left to guess how confident it should be - it has explicit instructions to ground every claim in the context directory.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#drift-detection","level":2,"title":"Drift Detection","text":"

      Context files can go stale. You rename a package, delete a module, or finish a sprint, and suddenly ARCHITECTURE.md references paths that no longer exist. Stale context is almost as dangerous as no context: the AI treats outdated information as current truth.

      ctx drift detects this divergence:

      ctx drift\n

      It scans context files for references to files, paths, and symbols that no longer exist in the codebase. Stale references get flagged so you can update or remove them before they mislead the next session.

      Regular drift checks - weekly, or after major refactors - keep your context files honest the same way tests keep your code honest.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-verification-loop","level":2,"title":"The Verification Loop","text":"

      The /ctx-commit skill includes a built-in verification step: before staging, it maps claims to evidence and runs self-audit questions to surface gaps. This catches inconsistencies at the point where they matter most: right before code is committed.

      This closes the loop. You write context. The AI reads context. The verification step confirms that context still matches reality. When it does not, you fix it - and the next session starts from truth, not from drift.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#trust-through-structure","level":2,"title":"Trust through Structure","text":"

      The common thread across all of these mechanisms is structure over prose. Timestamps make claims verifiable. Constitutional rules make boundaries explicit. Drift detection makes staleness visible. The playbook makes behavioral expectations concrete.

      You do not need to trust the AI. You need to trust the system -- and verify when it matters.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#further-reading","level":2,"title":"Further Reading","text":"
      • Detecting and Fixing Drift: the full workflow for keeping context files accurate
      • Invariants: the properties that must hold for any valid ctx implementation
      • Agent Security: threat model and mitigations for AI agents operating with persistent context
      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/prompting-guide/","level":1,"title":"Prompting Guide","text":"

      New to ctx?

      This guide references context files like TASKS.md, DECISIONS.md, and LEARNINGS.md:

      These are plain Markdown files that ctx maintains in your project's .context/ directory.

      If terms like \"context packet\" or \"session ceremony\" are unfamiliar,

      • start with the ctx Manifesto for the why,
      • About for the big picture,
      • then Getting Started to set up your first project.
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#literature-matters","level":2,"title":"Literature Matters","text":"

      This guide is about crafting effective prompts for working with AI assistants in ctx-enabled projects, but the guidelines given here apply to other AI systems, too.

      The right prompt triggers the right behavior.

      This guide documents prompts that reliably produce good results.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#tldr","level":2,"title":"TL;DR","text":"Goal Prompt Load context \"Do you remember?\" Resume work \"What's the current state?\" What's next /ctx-next Debug \"Why doesn't X work?\" Validate \"Is this consistent with our decisions?\" Impact analysis \"What would break if we...\" Reflect /ctx-reflect Wrap up /ctx-wrap-up Persist \"Add this as a learning\" Explore \"How does X work in this codebase?\" Sanity check \"Is this the right approach?\" Completeness \"What am I missing?\" One more thing \"What's the single smartest addition?\" Set tone \"Push back if my assumptions are wrong.\" Constrain scope \"Only change files in X. Nothing else.\" Course correct \"Stop. That's not what I meant.\" Check health \"Run ctx drift\" Commit /ctx-commit","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#session-start","level":2,"title":"Session Start","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#do-you-remember","level":3,"title":"\"do you remember?\"","text":"

      Triggers the AI to silently read TASKS.md, DECISIONS.md, LEARNINGS.md, and check recent history via ctx journal before responding with a structured readback:

      1. Last session: most recent session topic and date
      2. Active work: pending or in-progress tasks
      3. Recent context: 1-2 recent decisions or learnings
      4. Next step: offer to continue or ask what to focus on

      Use this at the start of every important session.

      Do you remember what we were working on?\n

      This question implies prior context exists. The AI checks files rather than admitting ignorance. The expected response cites specific context (session names, task counts, decisions), not vague summaries.

      If the AI instead narrates its discovery process (\"Let me check if there are files...\"), it has not loaded CLAUDE.md or AGENT_PLAYBOOK.md properly.

      For a detailed case study on making agents actually follow this protocol (including the failure modes, the timing problem, and the hook design that solved it) see The Dog Ate My Homework.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#whats-the-current-state","level":3,"title":"\"What's the Current State?\"","text":"

      Prompts reading of TASKS.md, recent sessions, and status overview.

      Use this when resuming work after a break.

      Variants:

      • \"Where did we leave off?\"
      • \"What's in progress?\"
      • \"Show me the open tasks.\"
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#during-work","level":2,"title":"During Work","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#why-doesnt-x-work","level":3,"title":"\"Why Doesn't X Work?\"","text":"

      This triggers root cause analysis rather than surface-level fixes.

      Use this when something fails unexpectedly.

      Framing as \"why\" encourages investigation before action. The AI will trace through code, check configurations, and identify the actual cause.

      Real Example

      \"Why can't I run /ctx-reflect?\" led to discovering missing permissions in settings.local.json bootstrapping.

      This was a fix that benefited all users of ctx.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#is-this-consistent-with-our-decisions","level":3,"title":"\"Is This Consistent with Our Decisions?\"","text":"

      This prompts checking DECISIONS.md before implementing.

      Use this before making architectural choices.

      Variants:

      • \"Check if we've decided on this before\"
      • \"Does this align with our conventions?\"
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-would-break-if-we","level":3,"title":"\"What Would Break If We...\"","text":"

      This triggers defensive thinking and impact analysis.

      Use this before making significant changes.

      What would break if we change the Settings struct?\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#before-you-start-read-x","level":3,"title":"\"Before You Start, Read X\"","text":"

      This ensures specific context is loaded before work begins.

      Use this when you know the relevant context exists in a specific file.

      Before you start, check ctx journal source for the auth discussion session\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-control","level":3,"title":"Scope Control","text":"

      Constrain the AI to prevent sprawl. These are some of the most useful prompts in day-to-day work.

      Only change files in internal/cli/add/. Nothing else.\n
      No new files. Modify the existing implementation.\n
      Keep the public API unchanged. Internal refactor only.\n

      Use these when the AI tends to \"helpfully\" modify adjacent code, add documentation you didn't ask for, or create new abstractions.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#course-correction","level":3,"title":"Course Correction","text":"

      Steer the AI when it goes off-track: Don't wait for it to finish a wrong approach.

      Stop! That's not what I meant. Let me clarify.\n
      Let's step back. Explain what you're about to do before changing anything.\n
      Undo that last change and try a different approach.\n

      These work because they interrupt momentum.

      Without explicit course correction, the AI tends to commit harder to a wrong path rather than reconsidering.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#failure-modes","level":3,"title":"Failure Modes","text":"

      When the AI misbehaves, match the symptom to the recovery prompt:

      Symptom Recovery prompt Hand-waves (\"should work now\") \"Show evidence: file/line refs, command output, or test name.\" Creates unnecessary files \"No new files. Modify the existing implementation.\" Expands scope unprompted \"Stop after the smallest working change. Ask before expanding scope.\" Narrates instead of acting \"Skip the explanation. Make the change and show the diff.\" Repeats a failed approach \"That didn't work last time. Try a different approach.\" Claims completion without proof \"Run the test. Show me the output.\"

      These are recovery handles, not rules to paste into CLAUDE.md.

      Use them in the moment when you see the behavior.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#reflection-and-persistence","level":2,"title":"Reflection and Persistence","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-did-we-learn","level":3,"title":"\"What Did We Learn?\"","text":"

      This prompts reflection on the session and often triggers adding learnings to LEARNINGS.md.

      Use this after completing a task or debugging session.

      This is an explicit reflection prompt. The AI will summarize insights and often offer to persist them.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#add-this-as-a-learningdecision","level":3,"title":"\"Add This as a Learning/decision\"","text":"

      This is an explicit persistence request.

      Use this when you have discovered something worth remembering.

      Add this as a learning: \"JSON marshal escapes angle brackets by default\"\n\n# or simply.\nAdd this as a learning.\n# and let the AI autonomously infer and summarize.\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#save-context-before-we-end","level":3,"title":"\"Save Context Before We End\"","text":"

      This triggers context persistence before the session closes.

      Use it at the end of the session or before switching topics.

      Variants:

      • \"Let's persist what we did\"
      • \"Update the context files\"
      • /ctx-wrap-up:the recommended end-of-session ceremony (see Session Ceremonies)
      • /ctx-reflect: mid-session reflection checkpoint
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#exploration-and-research","level":2,"title":"Exploration and Research","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#explore-the-codebase-for-x","level":3,"title":"\"Explore the Codebase for X\"","text":"

      This triggers thorough codebase search rather than guessing.

      Use this when you need to understand how something works.

      This works because \"Explore\" signals that investigation is needed, not immediate action.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#how-does-x-work-in-this-codebase","level":3,"title":"\"How Does X Work in This Codebase?\"","text":"

      This prompts reading actual code rather than explaining general concepts.

      Use this to understand the existing implementation.

      How does session saving work in this codebase?\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#find-all-places-where-x","level":3,"title":"\"Find All Places Where X\"","text":"

      This triggers a comprehensive search across the codebase.

      Use this before refactoring or understanding the impact.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#meta-and-process","level":2,"title":"Meta and Process","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-should-we-document-from-this","level":3,"title":"\"What Should We Document from This?\"","text":"

      This prompts identifying learnings, decisions, and conventions worth persisting.

      Use this after complex discussions or implementations.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#is-this-the-right-approach","level":3,"title":"\"Is This the Right Approach?\"","text":"

      This invites the AI to challenge the current direction.

      Use this when you want a sanity check.

      This works because it allows AI to disagree.

      AIs often default to agreeing; this prompt signals you want an honest assessment.

      Stronger variant: \"Push back if my assumptions are wrong.\" This sets the tone for the entire session: The AI will flag questionable choices proactively instead of waiting to be asked.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-am-i-missing","level":3,"title":"\"What Am I Missing?\"","text":"

      This prompts thinking about edge cases, overlooked requirements, or unconsidered approaches.

      Use this before finalizing a design or implementation.

      Forward-looking variant: \"What's the single smartest addition you could make to this at this point?\" Use this after you think you're done: It surfaces improvements you wouldn't have thought to ask for. The constraint to one thing prevents feature sprawl.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#cli-commands-as-prompts","level":2,"title":"CLI Commands as Prompts","text":"

      Asking the AI to run ctx commands is itself a prompt. These load context or trigger specific behaviors:

      Command What it does \"Run ctx status\" Shows context summary, file presence, staleness \"Run ctx agent\" Loads token-budgeted context packet \"Run ctx drift\" Detects dead paths, stale files, missing context","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ctx-skills","level":3,"title":"ctx Skills","text":"

      The SKILS.md Standard

      Skills are formalized prompts stored as SKILL.md files.

      The /slash-command syntax below is Claude Code specific.

      Other agents can use the same skill files, but invocation may differ.

      Use ctx skills by name:

      Skill When to use /ctx-status Quick context summary /ctx-agent Load full context packet /ctx-remember Recall project context and structured readback /ctx-wrap-up End-of-session context persistence /ctx-history Browse session history for past discussions /ctx-reflect Structured reflection checkpoint /ctx-next Suggest what to work on next /ctx-commit Commit with context persistence /ctx-drift Detect and fix context drift /ctx-implement Execute a plan step-by-step with verification /ctx-loop Generate autonomous loop script /ctx-pad Manage encrypted scratchpad /ctx-archive Archive completed tasks /check-links Audit docs for dead links

      Ceremony vs. Workflow Skills

      Most skills work conversationally: \"what should we work on?\" triggers /ctx-next, \"save that as a learning\" triggers /ctx-learning-add. Natural language is the recommended approach.

      Two skills are the exception: /ctx-remember and /ctx-wrap-up are ceremony skills for session boundaries: Invoke them as explicit slash commands: conversational triggers risk partial execution. See Session Ceremonies.

      Skills combine a prompt, tool permissions, and domain knowledge into a single invocation.

      Skills beyond Claude Code

      The /slash-command syntax above is Claude Code native, but the underlying SKILL.md files are a standard markdown format that any agent can consume. If you use a different coding agent, consult its documentation for how to load skill files as prompt templates.

      See Integrations for setup details.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#anti-patterns","level":2,"title":"Anti-Patterns","text":"

      Based on our ctx development experience (i.e., \"sipping our own champagne\") so far, here are some prompts that tend to produce poor results:

      Prompt Problem Better Alternative \"Fix this\" Too vague, may patch symptoms \"Why is this failing?\" \"Make it work\" Encourages quick hacks \"What's the right way to solve this?\" \"Just do it\" Skips planning \"Plan this, then implement\" \"You should remember\" Confrontational \"Do you remember?\" \"Obviously...\" Discourages questions State the requirement directly \"Idiomatic X\" Triggers language priors \"Follow project conventions\" \"Implement everything\" No phasing, sprawl risk Break into tasks, implement one at a time \"You should know this\" Assumes context is loaded \"Before you start, read X\"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#reliability-checklist","level":2,"title":"Reliability Checklist","text":"

      Before sending a non-trivial prompt, check these four elements. This is the guide's DNA in one screenful.

      1. Goal in one sentence: What does \"done\" look like?
      2. Files to read: What existing code or context should the AI review before acting?
      3. Verification command: How will you prove it worked? (test name, CLI command, expected output)
      4. Scope boundary: What should the AI not touch?

      A prompt that covers all four is almost always good enough.

      A prompt missing #3 is how you get \"should work now\" without evidence.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#safety-invariants","level":2,"title":"Safety Invariants","text":"

      These Are Invariants: Not Suggestions

      A prompting guide earns its trust by being honest about risk.

      These four rules mentioned below don't change with model versions, agent frameworks, or project size.

      Build them into your workflow once and stop thinking about them.

      Tool-using agents can read files, run commands, and modify your codebase. That power makes them useful. It also creates a trust boundary you should be aware of.

      These invariants apply regardless of which agent or model you use.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#treat-the-repository-text-as-untrusted-input","level":3,"title":"Treat the Repository Text as \"Untrusted Input\"","text":"

      Issue descriptions, PR comments, commit messages, documentation, and even code comments can contain text that looks like instructions. An agent that reads a GitHub issue and then runs a command found inside it is executing untrusted input.

      The rule: Before running any command the agent found in repo text (issues, docs, comments), restate the command explicitly and confirm it does what you expect. Don't let the agent copy-paste from untrusted sources into a shell.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ask-before-destructive-operations","level":3,"title":"Ask Before Destructive Operations","text":"

      git push --force, rm -rf, DROP TABLE, docker system prune: these are irreversible or hard to reverse. A good agent should pause before running them, but don't rely on that.

      The rule: For any operation that deletes data, overwrites history, or affects shared infrastructure, require explicit confirmation. If the agent runs something destructive without asking, that's a course-correction moment: \"Stop. Never run destructive commands without asking first.\"

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-the-blast-radius","level":3,"title":"Scope the Blast Radius","text":"

      An agent told to \"fix the tests\" might modify test fixtures, change assertions, or delete tests that inconveniently fail. An agent told to \"deploy\" might push to production. Broad mandates create broad risk.

      The rule: Constrain scope before starting work. The Reliability Checklist's scope boundary (#4) is your primary safety lever. When in doubt, err on the side of a tighter boundary.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#secrets-never-belong-in-context","level":3,"title":"Secrets Never Belong in Context","text":"

      LEARNINGS.md, DECISIONS.md, and session transcripts are plain-text files that may be committed to version control.

      Don't persist API keys, passwords, tokens, or credentials in context files.

      The rule: If the agent encounters a secret during work, it should use it transiently (environment variable, an alias to the secret instead of the actual secret, etc.) and never write it to a context file.

      Any Secret Seen IS Exposed

      If you see a secret in a context file, remove it immediately and rotate the credential.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#explore-plan-implement","level":2,"title":"Explore → Plan → Implement","text":"

      For non-trivial work, name the phase you want:

      Explore src/auth and summarize the current flow.\nThen propose a plan. After I approve, implement with tests.\n

      This prevents the AI from jumping straight to code.

      The three phases map to different modes of thinking:

      • Explore: read, search, understand: no changes
      • Plan: propose approach, trade-offs, scope: no changes
      • Implement: write code, run tests, verify: changes

      Small fixes skip straight to implement. Complex or uncertain work benefits from all three.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#prompts-by-task-type","level":2,"title":"Prompts by Task Type","text":"

      Different tasks need different prompt structures. The pattern: symptom + location + verification.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#bugfix","level":3,"title":"Bugfix","text":"
      Users report search returns empty results for queries with hyphens.\nReproduce in src/search/. Write a failing test for \"foo-bar\",\nfix the root cause, run: go test ./internal/search/...\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#refactor","level":3,"title":"Refactor","text":"
      Inspect src/auth/ and list duplication hotspots.\nPropose a refactor plan scoped to one module.\nAfter approval, remove duplication without changing behavior.\nAdd a test if coverage is missing. Run: make audit\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#research","level":3,"title":"Research","text":"
      Explore the request flow around src/api/.\nSummarize likely bottlenecks with evidence.\nPropose 2-3 hypotheses. Do not implement yet.\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#docs","level":3,"title":"Docs","text":"
      Update docs/cli-reference.md to reflect the new --format flag.\nConfirm the flag exists in the code and the example works.\n

      Notice each prompt includes what to verify and how. Without that, you get a \"should work now\" instead of evidence.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#writing-tasks-as-prompts","level":2,"title":"Writing Tasks as Prompts","text":"

      Tasks in TASKS.md are indirect prompts to the AI. How you write them shapes how the AI approaches the work.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#state-the-motivation-not-just-the-goal","level":3,"title":"State the Motivation, Not Just the Goal","text":"

      Tell the AI why you are building something, not just what.

      Bad: \"Build a calendar view.\"

      Good: \"Build a calendar view. The motivation is that all notes and tasks we build later should be viewable here.\"

      The second version lets the AI anticipate downstream requirements:

      It will design the calendar's data model to be compatible with future features: Without you having to spell out every integration point. Motivation turns a one-off task into a directional task.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#state-the-deliverable-not-just-steps","level":3,"title":"State the Deliverable, Not Just Steps","text":"

      Bad task (implementation-focused):

      - [ ] T1.1.0: Parser system\n  - [ ] Define data structures\n  - [ ] Implement line parser\n  - [ ] Implement session grouper\n

      The AI may complete all subtasks but miss the actual goal. What does \"Parser system\" deliver to the user?

      Good task (deliverable-focused):

      - [ ] T1.1.0: Parser CLI command\n  **Deliverable**: `ctx journal source` command that shows parsed sessions\n  - [ ] Define data structures\n  - [ ] Implement line parser\n  - [ ] Implement session grouper\n

      Now the AI knows the subtasks serve a specific user-facing deliverable.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#use-acceptance-criteria","level":3,"title":"Use Acceptance Criteria","text":"

      For complex tasks, add explicit \"done when\" criteria:

      - [ ] T2.0: Authentication system\n  **Done when**:\n  - [ ] User can register with email\n  - [ ] User can log in and get a token\n  - [ ] Protected routes reject unauthenticated requests\n

      This prevents premature \"task complete\" when only the implementation details are done, but the feature doesn't actually work.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#subtasks-parent-task","level":3,"title":"Subtasks ≠ Parent Task","text":"

      Completing all subtasks does not mean the parent task is complete.

      The parent task describes what the user gets.

      Subtasks describe how to build it.

      Always re-read the parent task description before marking it complete. Verify the stated deliverable exists and works.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#why-do-these-approaches-work","level":2,"title":"Why Do These Approaches Work?","text":"

      The patterns in this guide aren't invented here: They are practitioner translations of well-established, peer-reviewed research, most of which predate the current AI (hype) wave.

      The underlying ideas come from decades of work in machine learning, cognitive science, and numerical optimization. For a concrete case study showing how these principles play out when an agent decides whether to follow instructions (attention competition, optimization toward least-resistance paths, and observable compliance as a design goal) see The Dog Ate My Homework.

      Phased work (\"Explore → Plan → Implement\") applies chain-of-thought reasoning: Decomposing a problem into sequential steps before acting. Forcing intermediate reasoning steps measurably improves output quality in language models, just as it does in human problem-solving. Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (2022).

      Root-cause prompts (\"Why doesn't X work?\") use step-back abstraction: Retreating to a higher-level question before diving into specifics. This mirrors how experienced engineers debug: they ask \"what should happen?\" before asking \"what went wrong?\" Zheng et al., Take a Step Back: Evoking Reasoning via Abstraction in Large Language Models (2023).

      Exploring alternatives (\"Propose 2-3 approaches\") leverages self-consistency: Generating multiple independent reasoning paths and selecting the most coherent result. The idea traces back to ensemble methods in ML: A committee of diverse solutions outperforms any single one. Wang et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models (2022).

      Impact analysis (\"What would break if we...\") is a form of tree-structured exploration: Branching into multiple consequence paths before committing. This is the same principle behind game-tree search (minimax, MCTS) that has powered decision-making systems since the 1950s. Yao et al., Tree of Thoughts: Deliberate Problem Solving with Large Language Models (2023).

      Motivation prompting (\"Build X because Y\") works through goal conditioning: Providing the objective function alongside the task. In optimization terms, you are giving the gradient direction, not just the loss. The model can make locally coherent decisions that serve the global objective because it knows what \"better\" means.

      Scope constraints (\"Only change files in X\") apply constrained optimization: Bounding the search space to prevent divergence. This is the same principle behind regularization in ML: Without boundaries, powerful optimizers find solutions that technically satisfy the objective but are practically useless.

      CLI commands as prompts (\"Run ctx status\") interleave reasoning with acting: The model thinks, acts on external tools, observes results, then thinks again. Grounding reasoning in real tool output reduces hallucination because the model can't ignore evidence it just retrieved. Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models (2022).

      Task decomposition (\"Prompts by Task Type\") applies least-to-most prompting: Breaking a complex problem into subproblems and solving them sequentially, each building on the last. This is the research version of \"plan, then implement one slice.\" Zhou et al., Least-to-Most Prompting Enables Complex Reasoning in Large Language Models (2022).

      Explicit planning (\"Explore → Plan → Implement\") is directly supported by plan-and-solve prompting, which addresses missing-step failures in zero-shot reasoning by extracting a plan before executing. The phased structure prevents the model from jumping to code before understanding the problem. Wang et al., Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning by Large Language Models (2023).

      Session reflection (\"What did we learn?\", /ctx-reflect) is a form of verbal reinforcement learning: Improving future performance by persisting linguistic feedback as memory rather than updating weights. This is exactly what LEARNINGS.md and DECISIONS.md provide: a durable feedback signal across sessions. Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning (2023).

      These aren't prompting \"hacks\" that you will find in the \"1000 AI Prompts for the Curious\" listicles: They are applications of foundational principles:

      • Decomposition,
      • Abstraction,
      • Ensemble Reasoning,
      • Search,
      • and Constrained Optimization.

      They work because language models are, at their core, optimization systems navigating probabilistic landscapes.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#further-reading","level":2,"title":"Further Reading","text":"
      • The Attention Budget: Why your AI forgets what you just told it, and how token budgets shape context strategy
      • The Dog Ate My Homework: A case study in making agents follow instructions: attention timing, delegation decay, and observable compliance as a design goal
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#contributing","level":2,"title":"Contributing","text":"

      Found a prompt that works well? Open an issue or PR with:

      1. The prompt text;
      2. What behavior it triggers;
      3. When to use it;
      4. Why it works (optional but helpful).

      Dive Deeper:

      • Recipes: targeted how-to guides for specific tasks
      • CLI Reference: all commands and flags
      • Integrations: setup for Claude Code, Cursor, Aider
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/repeated-mistakes/","level":1,"title":"My AI Keeps Making the Same Mistakes","text":"","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#the-problem","level":2,"title":"The Problem","text":"

      You found a bug last Tuesday. You debugged it, understood the root cause, and moved on. Today, a new session hits the exact same bug. The AI rediscovers it from scratch, burning twenty minutes on something you already solved.

      Worse: you spent an hour last week evaluating two database migration strategies, picked one, documented why in a comment somewhere, and now the AI is cheerfully suggesting the approach you rejected. Again.

      This is not a model problem. It is a memory problem. Without persistent context, every session starts with amnesia.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#how-ctx-stops-the-loop","level":2,"title":"How ctx Stops the Loop","text":"

      ctx gives your AI three files that directly prevent repeated mistakes, each targeting a different failure mode.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#decisionsmd-stop-relitigating-settled-choices","level":3,"title":"DECISIONS.md: Stop Relitigating Settled Choices","text":"

      When you make an architectural decision, record it with rationale and rejected alternatives. The AI reads this at session start and treats it as settled.

      ## [2026-02-12] Use JWT for Authentication\n\n**Status**: Accepted\n\n**Context**: Need stateless auth for the API layer.\n\n**Decision**: JWT with short-lived access tokens and refresh rotation.\n\n**Rationale**: Stateless, scales horizontally, team has prior experience.\n\n**Alternatives Considered**:\n- Session-based auth: Rejected. Requires sticky sessions or shared store.\n- API keys only: Rejected. No user identity, no expiry rotation.\n

      Next session, when the AI considers auth, it reads this entry and builds on the decision instead of re-debating it. If someone asks \"why not sessions?\", the rationale is already there.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#learningsmd-capture-gotchas-once","level":3,"title":"LEARNINGS.md: Capture Gotchas Once","text":"

      Learnings are the bugs, quirks, and non-obvious behaviors that cost you time the first time around. Write them down so they cost you zero time the second time.

      ## Build\n\n### CGO Required for SQLite on Alpine\n\n**Discovered**: 2026-01-20\n\n**Context**: Docker build failed silently with \"no such table\" at runtime.\n\n**Lesson**: The go-sqlite3 driver requires CGO_ENABLED=1 and gcc\ninstalled in the build stage. Alpine needs apk add build-base.\n\n**Application**: Always use the golang:alpine image with build-base\nfor SQLite builds. Never set CGO_ENABLED=0.\n

      Without this entry, the next session that touches the Dockerfile will hit the same wall. With it, the AI knows before it starts.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#constitutionmd-draw-hard-lines","level":3,"title":"CONSTITUTION.md: Draw Hard Lines","text":"

      Some mistakes are not about forgetting - they are about boundaries the AI should never cross. CONSTITUTION.md sets inviolable rules.

      * [ ] Never commit secrets, tokens, API keys, or credentials\n* [ ] Never disable security linters without a documented exception\n* [ ] All database migrations must be reversible\n

      The AI reads these as absolute constraints. It does not weigh them against convenience. It refuses tasks that would violate them.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#the-accumulation-effect","level":2,"title":"The Accumulation Effect","text":"

      Each of these files grows over time. Session one captures two decisions. Session five adds a tricky learning about timezone handling. Session twelve records a convention about error message formatting.

      By session twenty, your AI has a knowledge base that no single person carries in their head. New team members - human or AI - inherit it instantly.

      The key insight: you are not just coding. You are building a knowledge layer that makes every future session faster.

      ctx files version with your code in git. They survive branch switches, team changes, and model upgrades. The context outlives any single session.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#getting-started","level":2,"title":"Getting Started","text":"

      Capture your first decision or learning right now:

      ctx add decision \"Use PostgreSQL\" \\\n  --context \"Need a relational database for the project\" \\\n  --rationale \"Team expertise, JSONB support, mature ecosystem\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\nctx add learning \"Vitest mock hoisting\" \\\n  --context \"Tests failing intermittently\" \\\n  --lesson \"vi.mock() must be at file top level\" \\\n  --application \"Use vi.doMock() for dynamic mocks\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n
      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#further-reading","level":2,"title":"Further Reading","text":"
      • Knowledge Capture: the full workflow for persisting decisions, learnings, and conventions
      • Context Files Reference: structure and format for every file in .context/
      • About ctx: the bigger picture - why persistent context changes how you work with AI
      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/steering/","level":1,"title":"Steering Files","text":"","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#steering-files","level":2,"title":"Steering Files","text":"

      ctx projects talk to AI assistants through several layers (context files, decisions, conventions, the agent context packet) but none of those can tell the assistant how to behave when a specific kind of prompt arrives. That's what steering files are for.

      A steering file is a small markdown document with YAML frontmatter that says: \"when the user asks about X, prepend these rules to the prompt.\" ctx manages those files in .context/steering/, decides which ones match each prompt, and syncs them out to each AI tool's native config (Claude Code, Cursor, Kiro, Cline) so the rules actually land in the prompt pipeline.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#not-the-same-as-decisions-or-conventions","level":2,"title":"Not the Same as Decisions or Conventions","text":"

      The three look similar on disk but serve different purposes:

      Kind Purpose Decisions (DECISIONS.md) What was chosen and why Conventions (CONVENTIONS.md) How the codebase is written Steering (.context/steering/*.md) How the AI should behave on matching prompts

      If you find yourself writing \"the AI should always do X when asked about Y,\" that belongs in steering, not decisions.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#your-first-steering-files","level":2,"title":"Your First Steering Files","text":"

      ctx init scaffolds four foundation steering files in .context/steering/ so you start with something to edit rather than an empty directory:

      File What to fill in product.md What the project is, who it's for, what's out of scope tech.md Languages, frameworks, runtime, hard constraints structure.md Directory layout, where new files go, naming rules workflow.md Branch strategy, commit conventions, pre-commit checks

      Each file starts with an inline HTML comment explaining the three inclusion modes, priority semantics, and tool scoping. The comment is invisible in rendered markdown but visible when you open the file to edit it; it's self-documenting scaffolding, not forever guidance. Delete the comment once you've customized the file.

      Default settings for foundation files:

      • inclusion: always: fires on every AI tool call
      • priority: 10: injected near the top of the prompt
      • tools: []: applies to every configured AI tool

      You should open each of these files and replace the placeholder content with your project's actual rules. Re-running ctx init is safe: existing files are left alone, so your edits survive. Use ctx init --no-steering-init to opt out of the scaffold entirely.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#inclusion-modes","level":2,"title":"Inclusion Modes","text":"

      Each steering file declares an inclusion mode in its frontmatter:

      Mode When the file is included always Every prompt, unconditionally auto When the prompt keywords match the file's description manual Only when the user explicitly names the file

      Which mode to pick depends on the AI tool you use, because the two tool families consume steering very differently.

      Claude Code and Codex: prefer inclusion: always for rules that must fire reliably. These tools have two delivery channels:

      1. The plugin's PreToolUse hook runs ctx agent with an empty prompt, so only always files match and get injected automatically on every tool call.
      2. The ctx_steering_get MCP tool, registered automatically when the ctx plugin is installed. Claude can call this tool mid-task to fetch auto or manual files matching a specific prompt. Verify with claude mcp list; look for ctx: ✓ Connected.

      Use always for invariants and anything that must fire every session. Use auto for situational rules where \"Claude fetches this when the prompt is relevant\" is the right behavior; those still land, just on Claude's judgment. Use manual for reference libraries you'll name explicitly.

      Cursor, Cline, Kiro: auto is the natural default. These tools read .cursor/rules/, .clinerules/, or .kiro/steering/ natively and resolve the description match on their own, so auto files fire when the prompt matches. manual files load on explicit invocation. always still works but consumes context budget on every turn.

      Mixed setups: if a rule must fire on Claude Code, pick always, even if it's overkill for your Cursor setup. The context budget cost is small; the alternative (silently not firing) is worse.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#two-families-of-ai-tools-two-delivery-paths","level":2,"title":"Two Families of AI Tools, Two Delivery Paths","text":"

      Not every AI tool consumes steering the same way. ctx handles two tool families differently, and it's worth knowing which family your editor is in before you wonder why a rule isn't firing.

      Native-rules tools (Cursor, Cline, Kiro) have a built-in rules primitive. They read a specific directory (.cursor/rules/, .clinerules/, .kiro/steering/) and apply the rules they find there. ctx handles these via ctx steering sync, which exports your files into the tool-native format. Run sync whenever you edit a steering file.

      Hook + MCP tools (Claude Code, Codex) have no native rules primitive, so ctx steering sync is a no-op for them. Instead, ctx delivers steering through two non-sync channels:

      1. Automatic injection via a PreToolUse hook. The ctx setup claude-code plugin wires a hook that runs ctx agent --budget 8000 before each tool call. ctx agent loads your steering files, filters them by the active prompt, and includes matching bodies in the context packet it prints. Claude Code feeds that output back into its context. Every tool call, automatically.
      2. On-demand via the ctx_steering_get MCP tool. The ctx MCP server exposes a tool Claude can call mid-task to fetch matching steering files for a specific prompt. Claude decides when to call it; it's not automatic.

      Both channels activate when you run ctx setup claude-code --write. After that, steering just works for Claude Code.

      Practical takeaway:

      • Using Cursor/Cline/Kiro only? Run ctx steering sync after edits.
      • Using Claude Code or Codex only? Never run sync; the hook+MCP pipeline handles it.
      • Using both? Run sync for the native-rules tools; the hook+MCP pipeline covers Claude Code automatically.
      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#two-shapes-of-automation-rules-and-scripts","level":2,"title":"Two Shapes of Automation: Rules and Scripts","text":"

      Steering is one of two hook-like layers ctx provides for customizing AI behavior. They're complementary:

      • Steering: persistent rules that get prepended to prompts. Declarative, text-only, scored by match.
      • Triggers: executable shell scripts that fire at lifecycle events. Imperative, runs arbitrary code, gated by exit codes.

      Pick steering when you want \"always remind the AI of X.\" Pick triggers when you want \"do Y when event Z happens.\" They can coexist; many projects use both.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#where-to-go-next","level":2,"title":"Where to Go Next","text":"
      • Writing Steering Files: a six-step walkthrough: scaffold, write the rule, preview matches, list, get-rules-in-front-of-the-AI (two paths depending on tool family), verify.
      • ctx steering reference: full command, flag, and frontmatter reference; includes the per-tool delivery-mechanism table and a dedicated section on how Claude Code and Codex consume steering.
      • ctx setup: configure which AI tools receive steering. For Cursor/Cline/Kiro this is about sync targets; for Claude Code/Codex it installs the plugin that wires the PreToolUse hook and MCP server.
      • Lifecycle Triggers: the imperative companion to steering files.
      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/triggers/","level":1,"title":"Lifecycle Triggers","text":"","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#lifecycle-triggers","level":2,"title":"Lifecycle Triggers","text":"

      Some things can't be expressed as a rule you want the AI to follow. Sometimes you want something to happen: block a dangerous tool call, inject today's standup notes into the next session, log every file save to a journal. That's what triggers are for.

      A trigger is an executable shell script that ctx runs at a specific lifecycle event: the start of a session, before a tool call, when a file is saved, and so on. Triggers read a JSON payload from stdin, do whatever they need, and write a JSON response on stdout. They can allow, block, or inject context into the pipeline depending on the event type.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#trigger-types","level":2,"title":"Trigger Types","text":"Type Fires when Use case session-start A new AI session begins Inject rotating context, standup notes session-end An AI session ends Persist summaries, send notifications pre-tool-use Before a tool call executes Block, gate, or audit post-tool-use After a tool call completes Log, react, post-process file-save A file is saved Lint on save, update indices context-add A new entry is added to .context/ Cross-link, notify, enrich","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#triggers-are-arbitrary-code-treat-them-like-pre-commit-hooks","level":2,"title":"Triggers Are Arbitrary Code: Treat Them like Pre-Commit Hooks","text":"

      Only Enable Scripts You've Read and Understand

      A trigger is a shell script with the executable bit set. It runs with the same privileges as your AI tool and receives JSON input on stdin. A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.

      ctx trigger add intentionally creates new scripts disabled (no executable bit). You must ctx trigger enable <name> after reviewing the contents. That's not a suggestion; it's the security model.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#three-hook-like-layers-in-ctx","level":2,"title":"Three Hook-like Layers in ctx","text":"

      Triggers are one of three distinct hook-like concepts in ctx. The names are similar but the owners and use cases are not:

      Layer Owned by Where they live When to use ctx trigger You .context/hooks/<type>/*.sh Project-specific automation, any AI tool ctx system hooks ctx itself built-in, wired into tool configs Built-in nudges (you don't author these) Claude Code hooks Claude Code .claude/settings.local.json Claude-Code-only tool-specific integration

      This page is about the first category. The other two run automatically and are invisible to you.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#triggers-vs-steering-same-problem-different-shape","level":2,"title":"Triggers vs Steering: Same Problem, Different Shape","text":"

      Triggers are the imperative counterpart to steering files. Steering expresses persistent rules the AI reads before each prompt; triggers express side effects that run on lifecycle events. They're complementary, not competing:

      • Want the AI to remember something? → Steering.
      • Want a script to run when something happens? → Trigger.

      Most projects use both.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#where-to-go-next","level":2,"title":"Where to Go Next","text":"
      • Authoring Lifecycle Triggers: walkthrough with security guidance: scaffold, test, enable, iterate.
      • ctx trigger reference: command reference, trigger type table, input/output contract.
      • Steering files: the declarative counterpart to triggers.
      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"operations/","level":1,"title":"Operations","text":"

      Guides for installing, upgrading, integrating, and running ctx. Split into three groups by audience.

      ","path":["Operations"],"tags":[]},{"location":"operations/#day-to-day","level":2,"title":"Day-to-Day","text":"

      Everyday operation guides for anyone running ctx in a project or adopting it in a team.

      ","path":["Operations"],"tags":[]},{"location":"operations/#integration","level":3,"title":"Integration","text":"

      Adopt ctx in an existing project: initialize context files, migrate from other tools, and onboard team members.

      ","path":["Operations"],"tags":[]},{"location":"operations/#upgrade","level":3,"title":"Upgrade","text":"

      Upgrade between versions with step-by-step migration notes and breaking-change guidance.

      ","path":["Operations"],"tags":[]},{"location":"operations/#ai-tools","level":3,"title":"AI Tools","text":"

      Configure ctx with Claude Code, Cursor, Aider, Copilot, Windsurf, and other AI coding tools.

      ","path":["Operations"],"tags":[]},{"location":"operations/#autonomous-loops","level":3,"title":"Autonomous Loops","text":"

      Run an unattended AI agent that works through tasks overnight, with ctx providing persistent memory between iterations.

      ","path":["Operations"],"tags":[]},{"location":"operations/#hub","level":2,"title":"Hub","text":"

      Operator guides for running a ctx Hub, the gRPC server that fans out structured entries across projects. If you're a client connecting to a Hub someone else runs, see ctx connect and the Hub recipes instead.

      ","path":["Operations"],"tags":[]},{"location":"operations/#hub-operations","level":3,"title":"Hub Operations","text":"

      Data directory layout, daemon management, systemd unit, backup and restore, log rotation, monitoring, and upgrades.

      ","path":["Operations"],"tags":[]},{"location":"operations/#hub-failure-modes","level":3,"title":"Hub Failure Modes","text":"

      What can go wrong in network, storage, cluster, auth, and clock layers, and what you should do about each one. Includes the short-list table oncall engineers will want bookmarked.

      ","path":["Operations"],"tags":[]},{"location":"operations/#maintainers","level":2,"title":"Maintainers","text":"

      Runbooks for people shipping ctx itself.

      ","path":["Operations"],"tags":[]},{"location":"operations/#cutting-a-release","level":3,"title":"Cutting a Release","text":"

      Step-by-step runbook for maintainers: bump version, generate release notes, run the release script, and verify the result.

      ","path":["Operations"],"tags":[]},{"location":"operations/#runbooks","level":2,"title":"Runbooks","text":"

      Step-by-step procedures you run with your agent. Each runbook includes a prompt to paste into a Claude Code session and guidance on triaging the results.

      Runbook Purpose When to run Release checklist Full pre-release sequence Before every release Plugin release Plugin-specific release steps Plugin changes ship Breaking migration Guide users across breaking changes Releases with renames Hub deployment Set up a ctx Hub end-to-end First-time hub setup New contributor Onboarding: clone to first session New contributors Codebase audit AST audits, magic strings, dead code, doc alignment Before release, quarterly Docs semantic audit Narrative gaps, weak pages, structural problems Before release, after adding pages Sanitize permissions Clean .claude/settings.local.json of over-broad grants After heavy permission granting Architecture exploration Systematic architecture docs across repos New codebase onboarding, reviews

      Recommended cadence:

      • Before every release: release checklist (which includes codebase audit + docs semantic audit)
      • Monthly: sanitize permissions
      • Quarterly: full sweep of all audit runbooks
      ","path":["Operations"],"tags":[]},{"location":"operations/autonomous-loop/","level":1,"title":"Autonomous Loops","text":"","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#autonomous-ai-development","level":2,"title":"Autonomous AI Development","text":"

      Iterate until done.

      An autonomous loop is an iterative AI development workflow where an agent works on tasks until completion, without constant human intervention.

      ctx provides the memory that makes this possible:

      • ctx provides the memory: persistent context that survives across iterations
      • The loop provides the automation: continuous execution until done

      Together, they enable fully autonomous AI development where the agent remembers everything across iterations.

      Origin

      This pattern is inspired by Geoffrey Huntley's Ralph Wiggum technique.

      We use generic terminology here so the concepts remain clear regardless of trends.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#how-it-works","level":2,"title":"How It Works","text":"
      graph TD\n    A[Start Loop] --> B[Load .context/loop.md]\n    B --> C[AI reads .context/]\n    C --> D[AI picks task from TASKS.md]\n    D --> E[AI completes task]\n    E --> F[AI updates context files]\n    F --> G[AI commits changes]\n    G --> H{Check signals}\n    H -->|SYSTEM_CONVERGED| I[Done - all tasks complete]\n    H -->|SYSTEM_BLOCKED| J[Done - needs human input]\n    H -->|Continue| B
      1. Loop reads .context/loop.md and invokes AI
      2. AI loads context from .context/
      3. AI picks one task and completes it
      4. AI updates context files (mark task done, add learnings)
      5. AI commits changes
      6. Loop checks for completion signals
      7. Repeat until converged or blocked
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#quick-start-shell-while-loop-recommended","level":2,"title":"Quick Start: Shell While Loop (Recommended)","text":"

      The best way to run an autonomous loop is a plain shell script that invokes your AI tool in a fresh process on each iteration. This is \"pure ralph\":

      The only state that carries between iterations is what lives in .context/ and the git history. No context window bleed, no accumulated tokens, no hidden state.

      Create a loop.sh:

      #!/bin/bash\n# loop.sh: an autonomous iteration loop\n\nPROMPT_FILE=\"${1:-.context/loop.md}\"\nMAX_ITERATIONS=\"${2:-10}\"\nOUTPUT_FILE=\"/tmp/loop_output.txt\"\n\nfor i in $(seq 1 $MAX_ITERATIONS); do\n  echo \"=== Iteration $i ===\"\n\n  # Invoke AI with prompt\n  cat \"$PROMPT_FILE\" | claude --print > \"$OUTPUT_FILE\" 2>&1\n\n  # Display output\n  cat \"$OUTPUT_FILE\"\n\n  # Check for completion signals\n  if grep -q \"SYSTEM_CONVERGED\" \"$OUTPUT_FILE\"; then\n    echo \"Loop complete: All tasks done\"\n    break\n  fi\n\n  if grep -q \"SYSTEM_BLOCKED\" \"$OUTPUT_FILE\"; then\n    echo \"Loop blocked: Needs human input\"\n    break\n  fi\n\n  sleep 2\ndone\n

      Make it executable and run:

      chmod +x loop.sh\n./loop.sh\n

      You can also generate this script with ctx loop (see CLI Reference).

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#why-do-we-use-a-shell-loop","level":3,"title":"Why Do We Use a Shell Loop?","text":"

      Each iteration starts a fresh AI process with zero context window history. The agent knows only what it reads from .context/ files: Exactly the information you chose to persist.

      This is the core loop principle: memory is explicit, not accidental.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#alternative-claude-codes-built-in-loop","level":2,"title":"Alternative: Claude Code's Built-in Loop","text":"

      Claude Code has built-in loop support:

      # Start autonomous loop\n/loop\n\n# Cancel running loop\n/cancel-loop\n

      This is convenient for quick iterations, but be aware of important caveats:

      This Loop Is Not Pure

      Claude Code's /loop runs all iterations within the same session. This means:

      • State leaks between iterations: The context window accumulates output from every previous iteration. The agent \"remembers\" things it saw earlier (even if they were never persisted to .context/).
      • Token budget degrades: Each iteration adds to the context window, leaving less room for actual work in later iterations.
      • Not ergonomic for long runs: Users report that the built-in loop is less predictable for 10+ iteration runs compared to a shell loop.

      For short explorations (2-5 iterations) or interactive use, /loop works fine. For overnight unattended runs or anything where iteration independence matters, use the shell while loop instead.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#the-contextloopmd-file","level":2,"title":"The .context/loop.md File","text":"

      The prompt file instructs the AI on how to work autonomously. Here's a template:

      # Autonomous Development Prompt\n\nYou are working on this project autonomously. Follow these steps:\n\n## 1. Load Context\n\nRead these files in order:\n\n1. `.context/CONSTITUTION.md`: NEVER violate these rules\n2. `.context/TASKS.md`: Find work to do\n3. `.context/CONVENTIONS.md`: Follow these patterns\n4. `.context/DECISIONS.md`: Understand past choices\n\n## 2. Pick One Task\n\nFrom `.context/TASKS.md`, select ONE task that is:\n\n- Not blocked\n- Highest priority available\n- Within your capabilities\n\n## 3. Complete the Task\n\n- Write code following conventions\n- Run tests if applicable\n- Keep changes focused and minimal\n\n## 4. Update Context\n\nAfter completing work:\n\n- Mark task complete in `TASKS.md`\n- Add any learnings to `LEARNINGS.md`\n- Add any decisions to `DECISIONS.md`\n\n## 5. Commit Changes\n\nCreate a focused commit with clear message.\n\n## 6. Signal Status\n\nEnd your response with exactly ONE of:\n\n- `SYSTEM_CONVERGED`: All tasks in TASKS.md are complete\n- `SYSTEM_BLOCKED`: Cannot proceed, need human input (explain why)\n- (no signal): More work remains, continue to next iteration\n\n## Rules\n\n- ONE task per iteration\n- NEVER skip tests\n- NEVER violate CONSTITUTION.md\n- Commit after each task\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#completion-signals","level":2,"title":"Completion Signals","text":"

      The loop watches for these signals in AI output:

      Signal Meaning When to Use SYSTEM_CONVERGED All tasks complete No pending tasks in TASKS.md SYSTEM_BLOCKED Cannot proceed Needs clarification, access, or decision BOOTSTRAP_COMPLETE Initial setup done Project scaffolding finished","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#example-usage","level":3,"title":"Example Usage","text":"

      converged state

      I've completed all tasks in TASKS.md:\n- [x] Set up project structure\n- [x] Implement core API\n- [x] Add authentication\n- [x] Write tests\n\nNo pending tasks remain.\n\nSYSTEM_CONVERGED\n

      blocked state

      I cannot proceed with the \"Deploy to production\" task because:\n- Missing AWS credentials\n- Need confirmation on region selection\n\nPlease provide credentials and confirm deployment region.\n\nSYSTEM_BLOCKED\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#why-ctx-and-loops-work-well-together","level":2,"title":"Why ctx and Loops Work Well Together","text":"Without ctx With ctx Each iteration starts fresh Each iteration has full history Decisions get re-made Decisions persist in DECISIONS.md Learnings are lost Learnings accumulate in LEARNINGS.md Tasks can be forgotten Tasks tracked in TASKS.md","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#automatic-context-updates","level":3,"title":"Automatic Context Updates","text":"

      During the loop, the AI should update context files:

      Mark task complete:

      ctx task complete \"implement user auth\"\n

      Or emit an update command (parsed by ctx watch):

      <context-update type=\"complete\">user auth</context-update>\n

      Add learning:

      ctx add learning \"Rate limiting requires Redis connection\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n

      Or via update command:

      <context-update type=\"learning\"\n  context=\"Implementing rate limiter\"\n  lesson=\"Rate limiting requires Redis connection\"\n  application=\"Ensure Redis is provisioned before enabling rate limits\"\n>Rate Limiting Redis Dependency</context-update>\n

      Record decision:

      ctx add decision \"Use JWT tokens for API authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#advanced-watch-mode","level":2,"title":"Advanced: Watch Mode","text":"

      Run ctx watch alongside the loop to automatically process context updates:

      # Terminal 1: Run the loop\n./loop.sh 2>&1 | tee /tmp/loop.log\n\n# Terminal 2: Watch for context updates\nctx watch --log /tmp/loop.log\n

      The watch command processes context updates from the loop output in real time.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#project-setup","level":2,"title":"Project Setup","text":"

      Initialize a project for autonomous loop operation, then activate it so the loop's ctx commands know which .context/ to use:

      ctx init\neval \"$(ctx activate)\"\n

      For unattended overnight runs, put the binding directly at the top of your loop script (export CTX_DIR=/abs/path/.context) so it survives without depending on a live shell. See Activating a Context Directory.

      The loop prompt template is deployed to .context/loop.md during initialization. It instructs the agent to:

      • Work autonomously without asking clarifying questions;
      • Follow one-task-per-iteration discipline;
      • Use SYSTEM_CONVERGED / SYSTEM_BLOCKED signals;
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#example-project-structure","level":2,"title":"Example Project Structure","text":"
      my-project/\n├── .context/\n│   ├── CONSTITUTION.md\n│   ├── TASKS.md          # Work items for the loop\n│   ├── DECISIONS.md\n│   ├── LEARNINGS.md\n│   ├── CONVENTIONS.md\n│   └── sessions/         # Loop iteration history\n├── loop.sh               # Loop script (if not using Claude Code)\n└── src/                  # Your code\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#sample-tasksmd-for-autonomous-loops","level":3,"title":"Sample TASKS.md for Autonomous Loops","text":"
      # Tasks\n\n## Phase 1: Setup\n\n- [x] Initialize project structure\n- [x] Set up testing framework\n\n## Phase 2: Core Features\n\n- [ ] Implement user registration `#priority:high`\n- [ ] Add email verification `#priority:high`\n- [ ] Create password reset flow `#priority:medium`\n\n## Phase 3: Polish\n\n- [ ] Add rate limiting `#priority:medium`\n- [ ] Improve error messages `#priority:low`\n

      The loop will work through these systematically, marking each complete.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#loop-runs-forever","level":3,"title":"Loop Runs Forever","text":"

      Cause: AI not emitting completion signals

      Fix: Ensure .context/loop.md explicitly instructs signaling:

      End EVERY response with one of:\n- SYSTEM_CONVERGED (if all tasks done)\n- SYSTEM_BLOCKED (if stuck)\n

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#context-not-persisting","level":3,"title":"Context Not Persisting","text":"

      Cause: AI not updating context files

      Fix: Add explicit instructions to .context/loop.md:

      After completing a task, you MUST:\n1. Run: ctx task complete \"<task>\"\n2. Add learnings: ctx add learning \"...\" --session-id abc12345 --branch main --commit 68fbc00a\n

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#tasks-getting-repeated","level":3,"title":"Tasks Getting Repeated","text":"

      Cause: Task not marked complete before next iteration

      Fix: Ensure commit happens after context update:

      Order of operations:\n1. Complete coding work\n2. Update context files (*`ctx task complete`, `ctx add`*)\n3. Commit **ALL** changes including `.context/`\n4. Then signal status\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#ai-violating-constitution","level":3,"title":"AI Violating Constitution","text":"

      Cause: Constitution not read first

      Fix: Make constitution check explicit in .context/loop.md:

      BEFORE any work:\n1. Read .context/CONSTITUTION.md\n2. If task would violate ANY rule, emit SYSTEM_BLOCKED\n3. Explain which rule prevents the work\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#further-reading","level":2,"title":"Further Reading","text":"
      • Building ctx Using ctx: The dogfooding story: how autonomous loops built the tool that powers them
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#resources","level":2,"title":"Resources","text":"
      • Geoffrey Huntley's Ralph Wiggum Technique: The original inspiration
      • Context CLI: Command reference
      • Integrations: Tool-specific setup
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/hub-failure-modes/","level":1,"title":"Hub Failure Modes","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#ctx-hub-failure-modes","level":1,"title":"ctx Hub: Failure Modes","text":"

      What can go wrong, what the system does about it, and what you should do. Complementary to ctx Hub Operations.

      Design Posture

      The hub is best-effort knowledge sharing, not a durable ledger. Local .context/ files are the source of truth for each project; the hub is a fan-out channel. This framing informs every failure-mode decision below.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#network","level":2,"title":"Network","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#client-loses-connection-mid-stream","level":3,"title":"Client Loses Connection Mid-Stream","text":"

      What happens: ctx connection listen detects the EOF, waits with exponential backoff, and reconnects. On reconnect it passes its last-seen sequence; the hub replays everything newer.

      What you should do: nothing. If reconnects are looping, check firewall state on the hub and ctx hub status output.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#partition-majority-side-reachable","level":3,"title":"Partition: Majority Side Reachable","text":"

      What happens: clients routed to the majority side continue to publish and listen. The minority nodes step down to followers that cannot accept writes (Raft quorum lost).

      What you should do: let it heal. When the partition closes, followers catch up via sequence-based sync automatically.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#partition-split-brain-no-quorum","level":3,"title":"Partition: Split Brain (No Quorum)","text":"

      What happens: no node holds a majority, so no leader is elected. All nodes become read-only. ctx connection publish and ctx add --share fail with a \"no leader\" error; local writes still succeed.

      What you should do: fix the network. If the partition is permanent (e.g., a data center is gone), bootstrap a new cluster from the survivors with ctx hub peer remove for the dead nodes.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#hub-unreachable-during-ctx-add-share","level":3,"title":"Hub Unreachable during ctx add --share","text":"

      What happens: the local write succeeds; the share step prints a warning and exits non-zero on the share leg only. --share is best-effort; it never blocks local context updates.

      What you should do: run ctx connection publish later to backfill, or rely on another --share for the same entry ID. The hub deduplicates by entry ID.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#storage","level":2,"title":"Storage","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#disk-full-on-the-leader","level":3,"title":"Disk Full on the Leader","text":"

      What happens: entries.jsonl append fails. The hub rejects writes with an error and stays up for read traffic. Clients retry; followers keep their in-sync status using whatever the leader already wrote.

      What you should do: free disk or grow the volume, then nothing else; the hub resumes accepting writes on the next append attempt.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#corrupt-entriesjsonl","level":3,"title":"Corrupt entries.jsonl","text":"

      What happens: if the last line is a partial JSON write from a crash, the hub truncates it on startup and logs a warning. If any earlier line is malformed, the hub refuses to start.

      What you should do: inspect with jq -c . <data-dir>/entries.jsonl > /dev/null to find the bad line. Move the bad region to a .quarantine file, then start. Nothing is ever silently dropped.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#metajson-entriesjsonl-sequence-mismatch","level":3,"title":"meta.json / entries.jsonl Sequence Mismatch","text":"

      What happens: the hub refuses to start. This usually means someone copied one file without the other.

      What you should do: restore both files from the same backup, or accept the higher sequence by regenerating meta.json from entries.jsonl (manual for now; file a bug).

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#cluster","level":2,"title":"Cluster","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#leader-crash-clean-shutdown","level":3,"title":"Leader Crash, Clean Shutdown","text":"

      What happens: ctx hub stop triggers stepdown first, so a new leader is elected before the old one exits. In-flight writes drain. Clients reconnect to the new leader transparently.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#leader-crash-hard-fail-kill-9-power-loss","level":3,"title":"Leader Crash, Hard Fail (Kill -9, Power Loss)","text":"

      What happens: Raft detects the missing heartbeat and elects a new leader within a few seconds. Writes the old leader accepted but had not yet replicated can be lost. See the Raft-lite warning in the cluster recipe.

      What you should do: if you need stronger durability, run ctx connection listen on a dedicated \"collector\" project that persists entries locally as a write-ahead backup.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#split-brain-after-rejoin","level":3,"title":"Split-Brain After Rejoin","text":"

      What happens: Raft reconciles: the minority side's uncommitted writes are discarded, and the majority's log is authoritative.

      What you should do: nothing automatic. If you know the minority had important writes, grep for them in <data-dir>/entries.jsonl.rejected (written by the reconciliation pass) and replay them with ctx connection publish.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#auth-and-tokens","level":2,"title":"Auth and Tokens","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#lost-admin-token","level":3,"title":"Lost Admin Token","text":"

      What happens: you cannot register new projects.

      What you should do: retrieve it from <data-dir>/admin.token. If that file is also gone, stop the hub and regenerate. Note that all existing client tokens keep working; only new registrations need the admin token.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-admin-token","level":3,"title":"Compromised Admin Token","text":"

      What happens: anyone with the token can register new projects and publish. They cannot read existing entries without a client token for a project that subscribes.

      What you should do: rotate the admin token (regenerate <data-dir>/admin.token and restart), revoke suspicious client registrations via clients.json, and audit entries.jsonl for unexpected origins.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-client-token","level":3,"title":"Compromised Client Token","text":"

      What happens: the attacker can publish as that project and read anything that project is subscribed to. Because Origin is self-asserted on publish, the attacker can also publish entries tagged with any other project's name, so attribution in entries.jsonl cannot be trusted after a token compromise.

      What you should do: remove the client's entry from clients.json, restart the hub, and re-register the legitimate project with a fresh token. Audit entries.jsonl for entries published after the compromise timestamp and quarantine any that look suspicious; remember that Origin on those entries proves nothing.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-hub-host","level":3,"title":"Compromised Hub Host","text":"

      What happens: <data-dir>/clients.json stores client tokens verbatim (not hashed). Anyone with read access to that file has every client token in hand and can impersonate any registered project until each one is rotated.

      What you should do: treat it as a total hub compromise. Stop the hub, wipe <data-dir> (keep a forensic copy first), regenerate the admin token, and have every client re-register. See Security model for the mitigations that reduce the blast radius while the hashing follow-up is pending.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#clock-skew","level":2,"title":"Clock Skew","text":"

      Hub entries carry a timestamp assigned by the publishing client. The hub does not rewrite timestamps. Clients with significant clock skew will publish entries that look out of order in the shared feed.

      What you should do: run NTP on all client machines. If you see entries dated in the future or far past, the publisher's clock is the culprit.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#the-short-list","level":2,"title":"The Short List","text":"Symptom First thing to check Client can't reach hub Firewall, then ctx hub status \"No leader\" errors Cluster quorum; run ctx hub status on each peer Hub won't start after crash Last line of entries.jsonl Entries missing after restore Check clients.json sequence vs local .sync-state.json Duplicate entries in shared feed Client replayed after restore, safe (dedup by ID) Followers lagging Disk or network on the follower, not the leader","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#see-also","level":2,"title":"See Also","text":"
      • ctx Hub Operations
      • ctx Hub security model
      • HA cluster recipe
      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub/","level":1,"title":"Hub Operations","text":"","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#ctx-hub-operations","level":1,"title":"ctx Hub: Operations","text":"

      Running the ctx ctx Hub in production. This page is for operators: people running a hub for themselves or a team, not people writing to a hub someone else is running.

      If you have not read it yet, start with the ctx Hub overview. It explains what the hub is, the two user stories it supports (personal cross-project brain vs small trusted team), and what it does not do. A client-side tour is in Getting Started.

      Operator Cheat Sheet

      • The hub fans out four entry types only: decision, learning, convention, task. Journals, scratchpad, and other local state are out of scope.
      • Identity is per-project, not per-user. Attribution is limited to Origin, which is self-asserted by the publishing client.
      • The data model is an append-only JSONL log plus two small JSON sidecar files. Nothing is rewritten in place.
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#data-directory-layout","level":2,"title":"Data Directory Layout","text":"

      The hub stores everything under a single data directory (default ~/.ctx/hub-data/, override with --data-dir).

      <data-dir>/\n  admin.token        # Initial admin token (chmod 600)\n  clients.json       # Registered client tokens and project names\n  meta.json          # Sequence counter, version, cluster metadata\n  entries.jsonl      # Append-only log (single source of truth)\n  hub.pid            # Daemon PID file (daemon mode only)\n  raft/              # Raft state (cluster mode only)\n    log.db\n    stable.db\n    snapshots/\n

      Invariants:

      • entries.jsonl is append-only. Every line is a valid JSON object. Corrupt lines are fatal at startup: fix or truncate before restart.
      • meta.json is authoritative for the next sequence number. On restart, the hub reads the last valid line of entries.jsonl and refuses to start if the sequences disagree.
      • clients.json holds hashed client tokens; losing it invalidates all client registrations.
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#starting-and-stopping","level":2,"title":"Starting and Stopping","text":"ForegroundDaemon
      ctx hub start                    # Ctrl-C to stop\nctx hub start --port 8080        # Custom port\nctx hub start --data-dir /srv/ctx-hub\n
      ctx hub start --daemon           # Fork to background\nctx hub stop                      # Graceful shutdown\n

      --stop sends SIGTERM to the PID in hub.pid, waits for in-flight RPCs to drain, then exits. If the daemon is wedged, remove hub.pid and send SIGKILL manually. entries.jsonl is crash-safe, so you will not lose accepted writes.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#systemd-unit","level":2,"title":"Systemd Unit","text":"

      For production single-node deployments, run the hub as a systemd service instead of --daemon:

      # /etc/systemd/system/ctx-hub.service\n[Unit]\nDescription=ctx `ctx` Hub\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nType=simple\nUser=ctx\nGroup=ctx\nExecStart=/usr/local/bin/ctx hub start --port 9900 \\\n    --data-dir /var/lib/ctx-hub\nRestart=on-failure\nRestartSec=5\nNoNewPrivileges=true\nProtectSystem=strict\nProtectHome=true\nReadWritePaths=/var/lib/ctx-hub\nPrivateTmp=true\n\n[Install]\nWantedBy=multi-user.target\n
      sudo systemctl enable --now ctx-hub\nsudo journalctl -u ctx-hub -f\n
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#backup-and-restore","level":2,"title":"Backup and Restore","text":"

      Because entries.jsonl is append-only, backups are trivial:

      # Hot backup, safe while the hub is running.\ncp <data-dir>/entries.jsonl backups/entries-$(date +%F).jsonl\ncp <data-dir>/meta.json      backups/meta-$(date +%F).json\ncp <data-dir>/clients.json   backups/clients-$(date +%F).json\n

      For a consistent snapshot across all three files, stop the hub, copy, then start again, or use a filesystem-level snapshot (LVM, ZFS, Btrfs).

      Restore:

      ctx hub stop                           # Stop the hub\ncp backups/entries-2026-04-10.jsonl <data-dir>/entries.jsonl\ncp backups/meta-2026-04-10.json      <data-dir>/meta.json\ncp backups/clients-2026-04-10.json   <data-dir>/clients.json\nctx hub start --daemon\n

      Clients that pushed sequences above the restored watermark will re-publish on the next listen reconnect, because the hub now reports a lower sequence than what clients have on disk. This is safe; the store deduplicates by entry ID.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#log-rotation","level":2,"title":"Log Rotation","text":"

      entries.jsonl grows unbounded. For long-lived hubs, rotate it offline:

      ctx hub stop\nmv <data-dir>/entries.jsonl <data-dir>/entries-$(date +%F).jsonl.old\n# Replay the last N days into a fresh entries.jsonl if you want a\n# trimmed active log, or leave the old file in place as history.\nctx hub start --daemon\n

      Do not truncate entries.jsonl while the hub is running. The hub holds an open file handle; an in-place truncation confuses the sequence counter and loses writes.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#monitoring","level":2,"title":"Monitoring","text":"

      Liveness probe:

      ctx hub status --exit-code\n

      Exit code 0 means the node is healthy (leader or in-sync follower); non-zero means degraded. Wire this into your monitoring of choice.

      For cluster deployments, watch for:

      • Role flaps: the leader changing more than once per hour suggests network instability or disk contention.
      • Replication lag: ctx hub status shows per-peer sequence offsets. Sustained lag > 100 sequences on a follower is worth investigating.
      • entries.jsonl growth rate: sudden spikes often indicate a misbehaving ctx connection listen reconnect loop.
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#upgrading","level":2,"title":"Upgrading","text":"

      The JSONL format is versioned in meta.json. ctx refuses to start against a newer store version than it understands; older store versions are upgraded in place at first start after an upgrade.

      Always back up <data-dir>/ before upgrading.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#see-also","level":2,"title":"See Also","text":"
      • ctx Hub failure modes
      • ctx Hub security model
      • ctx serve reference
      • ctx hub reference
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/integrations/","level":1,"title":"AI Tools","text":"","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#ai-tools","level":2,"title":"AI Tools","text":"

      Context works with any AI tool that can read files. This guide covers setup for popular AI coding assistants.

      Activate the Project Before Running ctx Commands

      After ctx init, run:

      eval \"$(ctx activate)\"\n

      This tells ctx which .context/ directory the rest of the commands on this page should use. If you skip it, you'll see Error: no context directory specified. The ctx setup <tool> commands work without activation, but most others (ctx agent, ctx add, ctx status, ctx watch) need it. See Activating a Context Directory.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#claude-code-full-integration","level":2,"title":"Claude Code (Full Integration)","text":"

      Claude Code has the deepest integration via the ctx plugin.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup","level":3,"title":"Setup","text":"

      First, install ctx and initialize your project, then activate it for the current shell:

      ctx init\neval \"$(ctx activate)\"\n

      Then, install the ctx plugin in Claude Code:

      # From the ctx repository\nclaude /plugin install ./internal/assets/claude\n\n# Or from the marketplace\nclaude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n

      Ensure the Plugin Is Enabled

      Installing a plugin registers it, but local installs may not auto-enable it globally. Verify ~/.claude/settings.json contains:

      { \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n

      Without this, the plugin's hooks and skills won't appear in other projects. Running ctx init auto-enables the plugin; use --no-plugin-enable to skip this step.

      This gives you:

      Component Purpose .context/ All context files CLAUDE.md Bootstrap instructions Plugin hooks Lifecycle automation Plugin skills Agent Skills","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#how-it-works","level":3,"title":"How It Works","text":"
      graph TD\n    A[Session Start] --> B[Claude reads CLAUDE.md]\n    B --> C[PreToolUse hook runs]\n    C --> D[ctx agent loads context]\n    D --> E[Work happens]\n    E --> F[Session End]
      1. Session start: Claude reads CLAUDE.md, which tells it to check .context/
      2. First tool use: PreToolUse hook runs ctx agent and emits the context packet (subsequent invocations within the cooldown window are silent)
      3. Next session: Claude reads context files and continues with context
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#plugin-hooks","level":3,"title":"Plugin Hooks","text":"

      The ctx plugin provides lifecycle hooks implemented as Go subcommands (ctx system *):

      Hook Event Purpose ctx system context-load-gate PreToolUse (.*) Auto-inject context on first tool use ctx system block-non-path-ctx PreToolUse (Bash) Block ./ctx or go run: force $PATH install ctx system qa-reminder PreToolUse (Bash) Remind agent to lint/test before committing ctx system specs-nudge PreToolUse (EnterPlanMode) Nudge agent to use project specs when planning ctx system check-context-size UserPromptSubmit Nudge context assessment as sessions grow ctx system check-ceremonies UserPromptSubmit Nudge /ctx-remember and /ctx-wrap-up adoption ctx system check-persistence UserPromptSubmit Remind to persist learnings/decisions ctx system check-journal UserPromptSubmit Remind to export/enrich journal entries ctx system check-reminders UserPromptSubmit Relay pending reminders at session start ctx system check-version UserPromptSubmit Warn when binary/plugin versions diverge ctx system check-resources UserPromptSubmit Warn when memory/swap/disk/load hit DANGER level ctx system check-knowledge UserPromptSubmit Nudge when knowledge files grow large ctx system check-map-staleness UserPromptSubmit Nudge when ARCHITECTURE.md is stale ctx system heartbeat UserPromptSubmit Session-alive signal with prompt count metadata ctx system post-commit PostToolUse (Bash) Nudge context capture and QA after git commits

      A catch-all PreToolUse hook also runs ctx agent on every tool use (with cooldown) to autoload context.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#hook-configuration","level":3,"title":"Hook Configuration","text":"

      The plugin's hooks.json wires everything automatically: no manual configuration in settings.local.json needed:

      {\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \".*\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system context-load-gate\" }\n        ]\n      },\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system block-non-path-ctx\" }\n        ]\n      },\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system qa-reminder\" }\n        ]\n      },\n      {\n        \"matcher\": \"EnterPlanMode\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system specs-nudge\" }\n        ]\n      },\n      {\n        \"matcher\": \".*\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx agent --budget 4000 2>/dev/null || true\" }\n        ]\n      }\n    ],\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system post-commit\" }\n        ]\n      }\n    ],\n    \"UserPromptSubmit\": [\n      {\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system check-context-size\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-ceremonies\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-persistence\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-journal\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-reminders\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-version\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-resources\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-knowledge\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-map-staleness\" },\n          { \"type\": \"command\", \"command\": \"ctx system heartbeat\" }\n        ]\n      }\n    ]\n  }\n}\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#customizing-token-budget-and-cooldown","level":3,"title":"Customizing Token Budget and Cooldown","text":"

      Edit the PreToolUse command to change the token budget or cooldown:

      \"command\": \"ctx agent --budget 8000 --session $PPID >/dev/null || true\"\n\"command\": \"ctx agent --budget 4000 --cooldown 5m --session $PPID >/dev/null || true\"\n

      The --session $PPID flag isolates the cooldown per session: $PPID resolves to the Claude Code process PID, so concurrent sessions don't interfere. The default cooldown is 10 minutes; use --cooldown 0 to disable it.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#verifying-setup","level":3,"title":"Verifying Setup","text":"
      1. Start a new Claude Code session;
      2. Ask: \"Do you remember?\"
      3. Claude should cite specific context:
        • Current tasks from .context/TASKS.md;
        • Recent decisions or learnings;
        • Recent session history from ctx journal.
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#local-plugin-development","level":3,"title":"Local Plugin Development","text":"

      When developing ctx locally (adding skills, hooks, or changing plugin behavior), Claude Code caches the plugin by version. You must bump the version in both files and update the marketplace for changes to take effect:

      1. Bump version in both:
      2. internal/assets/claude/.claude-plugin/plugin.json (plugin manifest), .claude-plugin/marketplace.json (marketplace listing*);

      3. Update the marketplace in Claude Code:

      4. Open the Plugins UI (/plugins or Esc menu),
      5. Go to Marketplaces tab,
      6. Select the activememory-ctx Marketplace,
      7. Choose Update marketplace;

      8. Start a new Claude Code session: skill changes aren't reflected in existing sessions.

      Both Version Files Must Match

      If you only bump plugin.json but not marketplace.json (or vice versa), Claude Code may not detect the update. Always bump both together.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#troubleshooting","level":3,"title":"Troubleshooting","text":"Issue Solution Context not loading Check ctx is in PATH: which ctx Hook errors Verify plugin is installed: claude /plugin list New skill not visible Bump version in both plugin.json files, update marketplace","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-load","level":3,"title":"Manual Context Load","text":"

      If hooks aren't working, manually load context:

      # Get context packet\nctx agent --budget 4000\n\n# Or paste into conversation\ncat .context/TASKS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#agent-skills","level":3,"title":"Agent Skills","text":"

      The ctx plugin ships Agent Skills following the agentskills.io specification.

      These are invoked in Claude Code with /skill-name.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-lifecycle-skills","level":4,"title":"Session Lifecycle Skills","text":"Skill Description /ctx-remember Recall project context at session start (ceremony) /ctx-wrap-up End-of-session context persistence (ceremony) /ctx-status Show context summary (tasks, decisions, learnings) /ctx-agent Get AI-optimized context packet /ctx-next Suggest 1-3 concrete next actions from context /ctx-commit Commit with integrated context capture /ctx-reflect Review session and suggest what to persist /ctx-remind Manage session-scoped reminders /ctx-pause Pause context hooks for this session /ctx-resume Resume context hooks after a pause","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-persistence-skills","level":4,"title":"Context Persistence Skills","text":"Skill Description /ctx-task-add Add a task to TASKS.md /ctx-learning-add Add a learning to LEARNINGS.md /ctx-decision-add Add a decision with context/rationale/consequence /ctx-convention-add Add a coding convention to CONVENTIONS.md /ctx-archive Archive completed tasks","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#scratchpad-skills","level":4,"title":"Scratchpad Skills","text":"Skill Description /ctx-pad Manage encrypted scratchpad entries","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-history-skills","level":4,"title":"Session History Skills","text":"Skill Description /ctx-history Browse AI session history /ctx-journal-enrich Enrich a journal entry with frontmatter/tags /ctx-journal-enrich-all Full journal pipeline: export if needed, then batch-enrich","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#blogging-skills","level":4,"title":"Blogging Skills","text":"

      Blogging Is a Better Way of Creating Release Notes

      The blogging workflow can also double as generating release notes:

      AI reads your git commit history and creates a \"narrative\", which is essentially what a release note is for.

      Skill Description /ctx-blog Generate blog post from recent activity /ctx-blog-changelog Generate blog post from commit range with theme","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#auditing-health-skills","level":4,"title":"Auditing & Health Skills","text":"Skill Description /ctx-doctor Troubleshoot ctx behavior with structural health checks /ctx-drift Detect and fix context drift (structural + semantic) /ctx-consolidate Merge redundant learnings or decisions into denser entries /ctx-alignment-audit Audit doc claims against playbook instructions /ctx-prompt-audit Analyze session logs for vague prompts /check-links Audit docs for dead internal and external links","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#planning-execution-skills","level":4,"title":"Planning & Execution Skills","text":"Skill Description /ctx-loop Generate a Ralph Loop iteration script /ctx-implement Execute a plan step-by-step with checks /ctx-plan-import Import Claude Code plan files into project specs /ctx-worktree Manage git worktrees for parallel agents /ctx-architecture Build and maintain architecture maps","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage-examples","level":4,"title":"Usage Examples","text":"
      /ctx-status\n/ctx-learning-add \"Token refresh requires explicit cache invalidation\"\n/ctx-journal-enrich twinkly-stirring-kettle\n

      Skills support partial matching where applicable (e.g., session slugs).

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#cursor-ide","level":2,"title":"Cursor IDE","text":"

      Cursor can use context files through its system prompt or by reading files directly.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_1","level":3,"title":"Setup","text":"
      # Generate Cursor configuration\nctx setup cursor\n\n# Initialize context\nctx init --minimal\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration","level":3,"title":"Configuration","text":"

      Add to Cursor settings (.cursor/settings.json):

      // split to multiple lines for readability\n{\n  \"ai.systemPrompt\": \"Read .context/TASKS.md and \n  .context/CONVENTIONS.md before responding. \n  Follow rules in .context/CONSTITUTION.md.\",\n}\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage","level":3,"title":"Usage","text":"
      1. Open your project in Cursor
      2. Context files are available in the file tree
      3. Reference them in prompts: \"Check .context/DECISIONS.md for our approach to...\"
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-injection","level":3,"title":"Manual Context Injection","text":"

      For more control, paste context directly:

      # Get AI-ready packet\nctx agent --budget 4000 | pbcopy  # macOS\nctx agent --budget 4000 | xclip  # Linux\n

      Paste into Cursor's chat.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#aider","level":2,"title":"Aider","text":"

      Aider works well with context files through its --read flag.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_2","level":3,"title":"Setup","text":"
      # Generate Aider configuration\nctx setup aider\n\n# Initialize context\nctx init\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_1","level":3,"title":"Configuration","text":"

      Create .aider.conf.yml:

      read:\n  - .context/CONSTITUTION.md\n  - .context/TASKS.md\n  - .context/CONVENTIONS.md\n  - .context/DECISIONS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_1","level":3,"title":"Usage","text":"
      # Start Aider (reads context files automatically)\naider\n\n# Or specify files explicitly\naider --read .context/TASKS.md --read .context/CONVENTIONS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#with-watch-mode","level":3,"title":"With Watch Mode","text":"

      Run ctx watch alongside Aider to capture context updates:

      # Terminal 1: Run Aider\naider 2>&1 | tee /tmp/aider.log\n\n# Terminal 2: Watch for context updates\nctx watch --log /tmp/aider.log\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#github-copilot","level":2,"title":"GitHub Copilot","text":"

      GitHub Copilot integrates with ctx at three levels: an automated instructions file, a VS Code Chat extension, and manual patterns.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_3","level":3,"title":"Setup","text":"
      # Initialize context\nctx init\n\n# Generate .github/copilot-instructions.md\nctx setup copilot --write\n

      The --write flag creates .github/copilot-instructions.md, which Copilot reads automatically at the start of every session. This file contains your project's constitution rules, current tasks, conventions, and architecture: giving Copilot persistent context without manual copy-paste.

      Re-run ctx setup copilot --write after updating your .context/ files to regenerate the instructions.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#vs-code-chat-extension-ctx","level":3,"title":"VS Code Chat Extension (@ctx)","text":"

      The ctx VS Code extension adds a @ctx chat participant to GitHub Copilot Chat, giving you direct access to all context commands from within the editor.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#installation","level":4,"title":"Installation","text":"
      1. Build from source (requires Node.js 18+):
      cd editors/vscode\nnpm install\nnpm run build\nnpx @vscode/vsce package\n
      1. Install the .vsix file:
      code --install-extension ctx-context-0.8.1.vsix\n
      1. Reload VS Code. Type @ctx in Copilot Chat to verify.
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#slash-commands","level":4,"title":"Slash Commands","text":"Command Description @ctx /init Initialize .context/ directory with template files @ctx /status Show context summary with token estimate @ctx /agent Print AI-ready context packet @ctx /drift Detect stale or invalid context @ctx /journal Browse and search AI session history @ctx /hook Generate AI tool integration configs @ctx /add Add a task, decision, or learning @ctx /load Output assembled context Markdown @ctx /compact Archive completed tasks and clean up @ctx /sync Reconcile context with codebase","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage-examples_1","level":4,"title":"Usage Examples","text":"
      @ctx /init\n@ctx /status\n@ctx /add task Implement user authentication\n@ctx /drift\n@ctx /hook copilot\n@ctx /journal\n

      Typing @ctx without a command shows help with all available commands. The extension also supports natural language: asking @ctx about \"status\" or \"drift\" routes to the correct command automatically.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_2","level":4,"title":"Configuration","text":"Setting Default Description ctx.executablePath ctx Path to the ctx binary. Set this if ctx is not in your PATH.","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#follow-up-suggestions","level":4,"title":"Follow-Up Suggestions","text":"

      After each command, the extension suggests relevant next steps. For example, after /init it suggests /status and /hook; after /drift it suggests /sync.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-persistence","level":3,"title":"Session Persistence","text":"

      ctx init creates a .context/sessions/ directory for storing session data from non-Claude tools. The Markdown session parser scans this directory during ctx journal, enabling session history for Copilot and other tools.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-patterns","level":3,"title":"Manual Patterns","text":"

      These patterns work without the extension, using Copilot's built-in file awareness:

      Pattern 1: Keep context files open

      Open .context/CONVENTIONS.md in a split pane. Copilot will reference it.

      Pattern 2: Reference in comments

      // See .context/CONVENTIONS.md for naming patterns\n// Following decision in .context/DECISIONS.md: Use PostgreSQL\n\nfunction getUserById(id: string) {\n  // Copilot now has context\n}\n

      Pattern 3: Paste context into Copilot Chat

      ctx agent --budget 2000\n

      Paste output into Copilot Chat for context-aware responses.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#windsurf-ide","level":2,"title":"Windsurf IDE","text":"

      Windsurf supports custom instructions and file-based context.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_4","level":3,"title":"Setup","text":"
      # Generate Windsurf configuration\nctx setup windsurf\n\n# Initialize context\nctx init\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_3","level":3,"title":"Configuration","text":"

      Add to Windsurf settings:

      // Split to multiple lines for readability\n{\n  \"ai.customInstructions\": \"Always read .context/CONSTITUTION.md first. \n  Check .context/TASKS.md for current work. \n  Follow patterns in .context/CONVENTIONS.md.\"\n}\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_2","level":3,"title":"Usage","text":"

      Context files appear in the file tree. Reference them when chatting:

      • \"What's in our task list?\" → AI reads .context/TASKS.md
      • \"What convention do we use for naming?\" → AI reads .context/CONVENTIONS.md
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#generic-integration","level":2,"title":"Generic Integration","text":"

      For any AI tool that can read files, use these patterns:

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-loading","level":3,"title":"Manual Context Loading","text":"
      # Get full context\nctx load\n\n# Get AI-optimized packet\nctx agent --budget 8000\n\n# Get specific file\ncat .context/TASKS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#system-prompt-template","level":3,"title":"System Prompt Template","text":"
      You are working on a project with persistent context in .context/\n\nBefore responding:\n1. Read .context/CONSTITUTION.md - NEVER violate these rules\n2. Check .context/TASKS.md for current work\n3. Follow .context/CONVENTIONS.md patterns\n4. Reference .context/DECISIONS.md for architectural choices\n\nWhen you learn something new, note it for .context/LEARNINGS.md\nWhen you make a decision, document it for .context/DECISIONS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#automated-updates","level":3,"title":"Automated Updates","text":"

      If your AI tool outputs to a log, use ctx watch:

      # Watch log file for context-update commands\nyour-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n

      The AI can emit updates like:

      <context-update type=\"complete\">implement caching</context-update>\n<context-update type=\"learning\"\n  context=\"Implementing caching layer\"\n  lesson=\"Important thing learned today\"\n  application=\"Apply this insight going forward\"\n>Caching Insight</context-update>\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-update-commands","level":2,"title":"Context Update Commands","text":"

      The ctx watch command parses update commands from AI output. Use this format:

      <context-update type=\"TYPE\" [attributes]>Content</context-update>\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#supported-types","level":3,"title":"Supported Types","text":"Type Target File Required Attributes task TASKS.md None decision DECISIONS.md context, rationale, consequence learning LEARNINGS.md context, lesson, application convention CONVENTIONS.md None complete TASKS.md None","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#simple-format-tasks-conventions-complete","level":3,"title":"Simple Format (Tasks, Conventions, Complete)","text":"
      <context-update type=\"task\">Implement rate limiting</context-update>\n<context-update type=\"convention\">Use kebab-case for files</context-update>\n<context-update type=\"complete\">rate limiting</context-update>\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#structured-format-learnings-decisions","level":3,"title":"Structured Format (Learnings, Decisions)","text":"

      Learnings and decisions support structured attributes for better documentation:

      Learning with full structure:

      <context-update type=\"learning\"\n  context=\"Debugging Claude Code hooks\"\n  lesson=\"Hooks receive JSON via stdin, not environment variables\"\n  application=\"Parse JSON stdin with the host language (Go, Python, etc.): no jq needed\"\n>Hook Input Format</context-update>\n

      Decision with full structure:

      <context-update type=\"decision\"\n  context=\"Need a caching layer for API responses\"\n  rationale=\"Redis is fast, well-supported, and team has experience\"\n  consequence=\"Must provision Redis infrastructure; team training on Redis patterns\"\n>Use Redis for caching</context-update>\n

      Learnings require: context, lesson, application attributes. Decisions require: context, rationale, consequence attributes. Updates missing required attributes are rejected with an error.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#further-reading","level":2,"title":"Further Reading","text":"
      • Skills That Fight the Platform: Common pitfalls in skill design that work against the host tool
      • The Anatomy of a Skill That Works: What makes a skill reliable: the E/A/R framework and quality gates
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/migration/","level":1,"title":"Integration","text":"","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#adopting-ctx-in-existing-projects","level":2,"title":"Adopting ctx in Existing Projects","text":"

      Claude Code User?

      You probably want the plugin instead of this page.

      Install ctx from the marketplace: (/plugin → search \"ctx\" → Install) and you're done: hooks, skills, and updates are handled for you.

      See Getting Started for the full walkthrough.

      This guide covers adopting ctx in existing projects regardless of which tools your team uses.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#quick-paths","level":2,"title":"Quick Paths","text":"You have... Command What happens Nothing (greenfield) ctx init Creates .context/, CLAUDE.md, permissions Existing CLAUDE.md ctx init --merge Backs up your file, inserts ctx block after the H1 Existing CLAUDE.md + ctx markers ctx init --force Replaces the ctx block, leaves your content intact .cursorrules / .aider.conf.yml ctx init ctx ignores those files: they coexist cleanly Team repo, first adopter ctx init --merge && git add .context/ CLAUDE.md Initialize and commit for the team","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-claudemd","level":2,"title":"Existing CLAUDE.md","text":"

      This is the most common scenario:

      You have a CLAUDE.md with project-specific instructions and don't want to lose them.

      You Own CLAUDE.md

      After initialization, CLAUDE.md is yours: edit it freely.

      Add project instructions, remove sections you don't need, reorganize as you see fit.

      The only part ctx manages is the block between the <!-- ctx:context --> and <!-- ctx:end --> markers; everything outside those markers is yours to change at any time.

      If you remove the markers, nothing breaks: ctx simply treats the file as having no ctx content and will offer to merge again on the next ctx init.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-ctx-init-does","level":3,"title":"What ctx init Does","text":"

      When ctx init detects an existing CLAUDE.md, it checks for ctx markers (<!-- ctx:context --> ... <!-- ctx:end -->):

      State Default behavior With --merge With --force No CLAUDE.md Creates from template Creates from template Creates from template Exists, no ctx markers Prompts to merge Auto-merges (no prompt) Auto-merges (no prompt) Exists, has ctx markers Skips (already set up) Skips Replaces the ctx block only","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-merge-flag","level":3,"title":"The --merge Flag","text":"

      --merge auto-merges without prompting. The merge process:

      1. Backs up your existing CLAUDE.md to CLAUDE.md.<timestamp>.bak;
      2. Finds the H1 heading (e.g., # My Project) in your file;
      3. Inserts the ctx block immediately after it;
      4. Preserves everything else untouched.

      Your content before and after the ctx block remains exactly as it was.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#before-after-example","level":3,"title":"Before / After Example","text":"

      Before: your existing CLAUDE.md:

      # My Project\n\n## Build Commands\n\n-`npm run build`: production build\n- `npm test`: run tests\n\n## Code Style\n\n- Use TypeScript strict mode\n- Prefer named exports\n

      After ctx init --merge:

      # My Project\n\n<!-- ctx:context -->\n<!-- DO NOT REMOVE: This marker indicates ctx-managed content -->\n\n## IMPORTANT: You Have Persistent Memory\n\nThis project uses Context (`ctx`) for context persistence across sessions.\n...\n\n<!-- ctx:end -->\n\n## Build Commands\n\n- `npm run build`: production build\n- `npm test`: run tests\n\n## Code Style\n\n- Use TypeScript strict mode\n- Prefer named exports\n

      Your build commands and code style sections are untouched. The ctx block sits between markers and can be updated independently.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-force-flag","level":3,"title":"The --force Flag","text":"

      If your CLAUDE.md already has ctx markers (from a previous ctx init), the default behavior is to skip it. Use --force to replace the ctx block with the latest template: This is useful after upgrading ctx:

      ctx init --force\n

      This only replaces content between <!-- ctx:context --> and <!-- ctx:end -->. Your own content outside the markers is preserved. A timestamped backup is created before any changes.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#undoing-a-merge","level":3,"title":"Undoing a Merge","text":"

      Every merge creates a backup:

      $ ls CLAUDE.md*.bak\nCLAUDE.md.1738000000.bak\n

      To restore:

      cp CLAUDE.md.1738000000.bak CLAUDE.md\n

      Or if you are using git, simply:

      git checkout CLAUDE.md\n
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-cursorrules-aider-copilot","level":2,"title":"Existing .cursorrules / Aider / Copilot","text":"

      ctx doesn't touch tool-specific config files. It creates its own files (.context/, CLAUDE.md) and coexists with whatever you already have.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-does-ctx-create","level":3,"title":"What Does ctx Create?","text":"ctx creates ctx does NOT touch .context/ directory .cursorrules CLAUDE.md (or merges into) .aider.conf.yml .claude/settings.local.json (seeded by ctx init; the plugin manages hooks and skills) .github/copilot-instructions.md .windsurfrules Any other tool-specific config

      Claude Code hooks and skills are provided by the ctx plugin, installed from the Claude Code marketplace (/plugin → search \"ctx\" → Install).

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#running-ctx-alongside-other-tools","level":3,"title":"Running ctx Alongside Other Tools","text":"

      The .context/ directory is the source of truth. Tool-specific configs point to it:

      • Cursor: Reference .context/ files in your system prompt (see Cursor setup)
      • Aider: Add .context/ files to the read: list in .aider.conf.yml (see Aider setup)
      • Copilot: Keep .context/ files open or reference them in comments (see Copilot setup)

      You can generate a tool-specific configuration with:

      ctx setup cursor    # Generate Cursor config snippet\nctx setup aider     # Generate .aider.conf.yml\nctx setup copilot   # Generate Copilot tips\nctx setup windsurf  # Generate Windsurf config\n
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#migrating-content-into-context","level":3,"title":"Migrating Content into .context/","text":"

      If you have project knowledge scattered across .cursorrules or custom prompt files, consider migrating it:

      1. Rules / invariants → .context/CONSTITUTION.md
      2. Code patterns → .context/CONVENTIONS.md
      3. Architecture notes → .context/ARCHITECTURE.md
      4. Known issues / tips → .context/LEARNINGS.md

      You don't need to delete the originals: ctx and tool-specific files can coexist. But centralizing in .context/ means every tool gets the same context.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#team-adoption","level":2,"title":"Team Adoption","text":"","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#context-is-designed-to-be-committed","level":3,"title":".context/ Is Designed to Be Committed","text":"

      The context files (tasks, decisions, learnings, conventions, architecture) are meant to live in version control. However, some subdirectories are personal or sensitive and should not be committed.

      ctx init automatically adds these .gitignore entries:

      # Journals contain full session transcripts: personal, potentially large\n.context/journal/\n.context/journal-site/\n.context/journal-obsidian/\n\n# Legacy encryption key path (copy to ~/.ctx/.ctx.key if needed)\n.context/.ctx.key\n\n# Runtime state and logs (ephemeral, machine-specific):\n.context/state/\n.context/logs/\n\n# Claude Code local settings (machine-specific)\n.claude/settings.local.json\n

      With those in place, committing is straightforward:

      # One person initializes\nctx init --merge\n\n# Commit context files (journals and keys are already gitignored)\ngit add .context/ CLAUDE.md\ngit commit -m \"Add ctx context management\"\ngit push\n

      Teammates pull and immediately have context. No per-developer setup needed.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-about-claude","level":3,"title":"What about .claude/?","text":"

      The .claude/ directory contains permissions that ctx init seeds. Hooks and skills are provided by the ctx plugin (not per-project files).

      File Commit? Why .claude/settings.local.json No Machine-specific, accumulates session permissions .claude/settings.golden.json Yes Curated permission snapshot (via ctx permission snapshot)","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#merge-conflicts-in-context-files","level":3,"title":"Merge Conflicts in Context Files","text":"

      Context files are plain Markdown. Resolve conflicts the same way you would for any other documentation file:

      # After a conflicting pull\ngit diff .context/TASKS.md    # See both sides\n# Edit to keep both sets of tasks, then:\ngit add .context/TASKS.md\ngit commit\n

      Common conflict scenarios:

      • TASKS.md: Two people added tasks: Keep both.
      • DECISIONS.md: Same decision recorded differently: Unify the entry.
      • LEARNINGS.md: Parallel discoveries: Keep both, remove duplicates.
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#gradual-adoption","level":3,"title":"Gradual Adoption","text":"

      You don't need the whole team to switch at once:

      1. One person runs ctx init --merge and commits;
      2. CLAUDE.md instructions work immediately for Claude Code users;
      3. Other tool users can adopt at their own pace using ctx setup <tool>;
      4. Context files benefit everyone who reads them, even without tool integration.
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#verifying-it-worked","level":2,"title":"Verifying It Worked","text":"","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#activate-the-project","level":3,"title":"Activate the Project","text":"

      Tell ctx which .context/ directory to use for the rest of the verification steps:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the status check below fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#check-status","level":3,"title":"Check Status","text":"
      ctx status\n

      You should see your context files listed with token counts and no warnings.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#test-memory","level":3,"title":"Test Memory","text":"

      Start a new AI session and ask: \"Do you remember?\"

      The AI should cite specific context:

      • Current tasks from .context/TASKS.md;
      • Recent decisions or learnings;
      • Session history (if you've had prior sessions);

      If it responds with generic \"I don't have memory\", check that ctx is in your PATH (which ctx) and that hooks are configured (see Troubleshooting).

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#verify-the-merge","level":3,"title":"Verify the Merge","text":"

      If you used --merge, check that your original content is intact:

      # Your original content should still be there\ncat CLAUDE.md\n\n# The ctx block should be between markers\ngrep -c \"ctx:context\" CLAUDE.md  # Should print 1\ngrep -c \"ctx:end\" CLAUDE.md      # Should print 1\n
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#further-reading","level":2,"title":"Further Reading","text":"
      • Getting Started: Full setup walkthrough
      • Context Files: What each .context/ file does
      • Integrations: Per-tool setup (Claude Code, Cursor, Aider, Copilot)
      • CLI Reference: All ctx commands and flags
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/release/","level":1,"title":"Cutting a Release","text":"

      Full Release Checklist

      This page covers the mechanics of cutting a release (bump, tag, push). For the complete pre-release ceremony (audits, tests, verification, and post-release steps), see the Release Checklist runbook.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#prerequisites","level":2,"title":"Prerequisites","text":"

      Before you can cut a release you need:

      • Push access to origin (GitHub)
      • GPG signing configured (make gpg-test)
      • Go installed (version in go.mod)
      • Zensical installed (make site-setup)
      • A clean working tree (git status shows nothing to commit)
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#step-by-step","level":2,"title":"Step-by-Step","text":"","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#1-update-the-version-file","level":3,"title":"1. Update the VERSION File","text":"
      echo \"0.9.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.9.0\"\n

      The VERSION file uses bare semver (0.9.0), no v prefix. The release script adds the v prefix for git tags.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#2-generate-release-notes","level":3,"title":"2. Generate Release Notes","text":"

      In Claude Code:

      /_ctx-release-notes\n

      This analyzes commits since the last tag and writes dist/RELEASE_NOTES.md. The release script refuses to proceed without this file.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#3-verify-docs-and-commit-any-remaining-changes","level":3,"title":"3. Verify Docs and Commit Any Remaining Changes","text":"
      /ctx-link-check    # audit docs for dead links\nmake audit          # full check: fmt, vet, lint, style, test\ngit status          # must be clean\n
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#4-run-the-release","level":3,"title":"4. Run the Release","text":"
      make release\n

      Or, if you are in a Claude Code session:

      /_ctx-release\n

      The release script does everything in order:

      Step What happens 1 Reads VERSION, verifies release notes exist 2 Verifies working tree is clean 3 Updates version in 4 config files (plugin.json, marketplace.json, VS Code package.json + lock) 4 Updates download URLs in 3 doc files (index.md, getting-started.md, integrations.md) 5 Adds new row to versions.md 6 Rebuilds the documentation site (make site) 7 Commits all version and docs updates 8 Runs make test and make smoke 9 Builds binaries for all 6 platforms via hack/build-all.sh 10 Creates a signed git tag (v0.9.0) 11 Pushes the tag to origin 12 Updates and pushes the latest tag","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#5-github-ci-takes-over","level":3,"title":"5. GitHub CI Takes Over","text":"

      Pushing a v* tag triggers .github/workflows/release.yml:

      1. Checks out the tagged commit
      2. Runs the full test suite
      3. Builds binaries for all platforms
      4. Creates a GitHub Release with auto-generated notes
      5. Uploads binaries and SHA256 checksums
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#6-verify","level":3,"title":"6. Verify","text":"
      • GitHub Releases shows the new version
      • All 6 binaries are attached (linux/darwin x amd64/arm64, windows x amd64)
      • SHA256 files are attached
      • Release notes look correct
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#what-gets-updated-automatically","level":2,"title":"What Gets Updated Automatically","text":"

      The release script updates 8 files so you do not have to:

      File What changes internal/assets/claude/.claude-plugin/plugin.json Plugin version .claude-plugin/marketplace.json Marketplace version (2 fields) editors/vscode/package.json VS Code extension version editors/vscode/package-lock.json VS Code lock version (2 fields) docs/index.md Download URLs docs/home/getting-started.md Download URLs docs/operations/integrations.md VSIX filename version docs/reference/versions.md New version row + latest pointer

      The Go binary version is injected at build time via -ldflags from the VERSION file. No source file needs editing.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#build-targets-reference","level":2,"title":"Build Targets Reference","text":"Target What it does make release Full release (script + tag + push) make build Build binary for current platform make build-all Build all 6 platform binaries make test Unit tests make smoke Integration smoke tests make audit Full check (fmt + vet + lint + drift + docs + test) make site Rebuild documentation site","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#release-notes-not-found","level":3,"title":"\"Release Notes Not Found\"","text":"
      ERROR: dist/RELEASE_NOTES.md not found.\n

      Run /_ctx-release-notes in Claude Code first, or write dist/RELEASE_NOTES.md manually.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#working-tree-is-not-clean","level":3,"title":"\"Working Tree Is Not Clean\"","text":"
      ERROR: Working tree is not clean.\n

      Commit or stash all changes before running make release.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#tag-already-exists","level":3,"title":"\"Tag Already Exists\"","text":"
      ERROR: Tag v0.9.0 already exists.\n

      You cannot release the same version twice. Either bump VERSION to a new version, or delete the old tag if the release was incomplete:

      git tag -d v0.9.0\ngit push origin :refs/tags/v0.9.0\n
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#ci-build-fails-after-tag-push","level":3,"title":"CI Build Fails After Tag Push","text":"

      The tag is already published. Fix the issue, bump to a patch version (e.g. 0.9.1), and release again. Do not force-push tags that others may have already fetched.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/upgrading/","level":1,"title":"Upgrade","text":"","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#upgrade","level":2,"title":"Upgrade","text":"

      New versions of ctx may ship updated permissions, CLAUDE.md directives, or plugin hooks and skills.

      Claude Code User?

      The marketplace can update skills, hooks, and prompts independently: /plugin → select ctx → Update now (or enable auto-update).

      The ctx binary is separate: rebuild from source or download a new release when one is available, then run ctx init --force --merge. Knowledge files are preserved automatically.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#tldr","level":2,"title":"TL:DR","text":"
      # Plugin users (Claude Code)\n# /plugin → select ctx → Update now\n# Then update the binary and reinitialize:\nctx init --force --merge\n\n# From-source / manual users\n# install new ctx binary, then:\nctx init --force --merge\n# /plugin → select ctx → Update now   (if using Claude Code)\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#what-changes-between-versions","level":2,"title":"What Changes between Versions","text":"

      ctx init generates two categories of files:

      Category Examples Changes between versions? Infrastructure .claude/settings.local.json (permissions), ctx-managed sections in CLAUDE.md, ctx plugin (hooks + skills) Yes Knowledge .context/TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md, ARCHITECTURE.md, GLOSSARY.md, CONSTITUTION.md, AGENT_PLAYBOOK.md No: this is your data

      Infrastructure is regenerated by ctx init and plugin updates. Knowledge files are yours and should never be overwritten.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#upgrade-steps","level":2,"title":"Upgrade Steps","text":"","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#1-install-the-new-version","level":3,"title":"1. Install the New Version","text":"

      Build from source or download the binary:

      cd /path/to/ctx-source\ngit pull\nmake build\nsudo make install\nctx --version   # verify\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#2-reinitialize","level":3,"title":"2. Reinitialize","text":"
      ctx init --force --merge\n
      • --force regenerates infrastructure files (permissions, ctx-managed sections in CLAUDE.md).
      • --merge preserves your content outside ctx markers.

      Knowledge files (.context/TASKS.md, DECISIONS.md, etc.) are preserved automatically: ctx init only overwrites infrastructure, never your data.

      Encryption key: The encryption key lives at ~/.ctx/.ctx.key (outside the project). Reinit does not affect it. If you have a legacy key at .context/.ctx.key or ~/.local/ctx/keys/, copy it manually (see Syncing Scratchpad Notes).

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#3-update-the-ctx-plugin","level":3,"title":"3. Update the ctx Plugin","text":"

      If you use Claude Code, update the plugin to get new hooks and skills:

      1. Open /plugin in Claude Code.
      2. Select ctx.
      3. Click Update now.

      Or enable auto-update so the plugin stays current without manual steps.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#4-review-custom-settings","level":3,"title":"4. Review Custom Settings","text":"

      If you added custom permissions to .claude/settings.local.json beyond what ctx init provides, diff and merge:

      diff .claude.bak/settings.local.json .claude/settings.local.json\n

      Manually add back any custom entries that the new init dropped.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#5-verify","level":3,"title":"5. Verify","text":"

      Activate the project first, otherwise ctx status and ctx drift will fail with Error: no context directory specified:

      eval \"$(ctx activate)\"\nctx status          # context files intact\nctx drift           # no broken references\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#6-clean-up","level":3,"title":"6. Clean Up","text":"

      If you made manual backups, remove them once satisfied:

      rm -rf .context.bak .claude.bak CLAUDE.md.bak\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#what-if-i-skip-the-upgrade","level":2,"title":"What If I Skip the Upgrade?","text":"

      The old binary still works with your existing .context/ files. But you may miss:

      • New plugin hooks that enforce better practices or catch mistakes;
      • Updated skill prompts that produce better results;
      • New .gitignore entries for directories added in newer versions;
      • Bug fixes in the CLI itself.

      The plugin and the binary can be updated independently. You can update the plugin (for new hooks/skills) even if you stay on an older binary, and vice versa.

      Context files are plain Markdown: They never break between versions.

      The surrounding infrastructure is what evolves.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/","level":1,"title":"Architecture Exploration","text":"","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#architecture-exploration","level":1,"title":"Architecture Exploration","text":"

      Systematically build architecture documentation across one or more repositories using ctx skills. Each invocation does one unit of work; a simple loop drives the agent through all phases.

      When to use: When onboarding to a new codebase, performing architecture reviews, or building up .context/ documentation across a workspace of repos.

      Prerequisites: ctx installed, repos cloned under a shared workspace directory (e.g., ~/WORKSPACE/).

      Companion skills:

      • /ctx-architecture: structural baseline and principal analysis
      • /ctx-architecture-enrich: code intelligence enrichment via GitNexus
      • /ctx-architecture-failure-analysis: adversarial failure analysis
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#overview","level":2,"title":"Overview","text":"

      The agent progresses through phases per repo, depth-first:

      Phase Skill What it does bootstrap ctx init + /ctx-architecture Initialize context and build structural baseline principal /ctx-architecture principal Deep analysis: vision, bottlenecks, alternatives enriched /ctx-architecture-enrich Quantify with code intelligence (blast radius, flows) frontier-N /ctx-architecture (re-run) Explore unexplored areas found in convergence report lens-* /ctx-architecture with lens Focused exploration through conceptual lenses

      Exploration stops when convergence >= 0.85, frontier runs plateau, or all lenses are exhausted.

      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#setup","level":2,"title":"Setup","text":"

      Create a tracking directory in your workspace root:

      cd ~/WORKSPACE\nmkdir -p .arch-explorer\n

      Create .arch-explorer/manifest.json listing your repos:

      {\n  \"repos\": [\"ctx\", \"portal\", \"infra\"],\n  \"current_repo_index\": 0,\n  \"progress\": {}\n}\n

      Create .arch-explorer/run-log.md (empty, the agent appends to it).

      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#prompt","level":2,"title":"Prompt","text":"

      Save this as .arch-explorer/PROMPT.md and invoke with your agent. The prompt is self-contained: the agent reads the manifest, picks the next unit of work, executes it, updates tracking, and stops.

      You are an autonomous architecture exploration agent. Your job is to\nsystematically build and evolve architecture documentation across all\nrepositories in this workspace using ctx skills.\n\n## Execution Protocol\n\n### Step 1: Read State\n\nRead `.arch-explorer/manifest.json`. This tells you:\n- Which repos exist and their order\n- What has been done per repo (`progress` object)\n- Which repo to work on next (`current_repo_index`)\n\n### Step 2: Pick the Next Unit of Work\n\n**Strategy: depth-first, sequential.**\n\nFind the current repo (by `current_repo_index`). Determine its next\nphase from the progression below. If all phases are exhausted for this\nrepo (convergence score >= 0.85 or 3+ frontier runs with no new\nfindings), advance `current_repo_index` and pick the next repo.\n\n### Phase Progression (per repo)\n\nEach repo progresses through these phases in order:\n\n| Phase | Skill | Prerequisite |\n|-------|-------|-------------|\n| `bootstrap` | `ctx init` + `/ctx-architecture` | None |\n| `principal` | `/ctx-architecture principal` | bootstrap done |\n| `enriched` | `/ctx-architecture-enrich` | principal done, GitNexus indexed |\n| `frontier-N` | `/ctx-architecture` (re-run) | enriched done |\n\n**`bootstrap` is a single composite unit:** `ctx init` followed by\nstructural analysis. This is the ONLY phase that combines two actions.\nNo other phase may chain actions.\n\n**Frontier runs** are numbered: `frontier-1`, `frontier-2`, etc.\nEach frontier run reads CONVERGENCE-REPORT.md and picks unexplored\nareas. The skill handles this automatically.\n\nAfter the third frontier run OR when convergence >= 0.85, apply\n**conceptual lenses** (one per run):\n\n| Lens | Focus Areas |\n|------|-------------|\n| `security` | Auth flows, input validation, secrets, attack surfaces, trust boundaries |\n| `performance` | Hot paths, caching, concurrency, resource lifecycle, allocation patterns |\n| `stability` | Error handling, retries, graceful degradation, circuit breakers, timeouts |\n| `observability` | Logging, metrics, tracing, alerting, debugging affordances |\n| `data-integrity` | Storage, serialization, migrations, consistency, backup, recovery |\n\nFor lens runs, prepend the lens context as an explicit instruction to\nthe skill invocation:\n\n> \"Focus exploration on security: auth flows, input validation, secrets,\n> attack surfaces, trust boundaries.\"\n\nDo NOT wait for the skill to ask what to explore. Provide the lens\nfocus as input upfront.\n\n### Step 3: Do the Work\n\n1. `cd` into the sub-repo directory (`~/WORKSPACE/<repo-name>`, NOT\n   `~/WORKSPACE` itself).\n2. Verify `CTX_DIR` already points at THIS sub-repo's `.context/`:\n\n    ```bash\n    test \"$CTX_DIR\" = \"$PWD/.context\" || {\n      echo \"STOP: CTX_DIR=$CTX_DIR but this sub-repo needs $PWD/.context.\"\n      echo \"Re-launch the agent with CTX_DIR set to the sub-repo:\"\n      echo \"  cd $PWD && CTX_DIR=\\\"\\$PWD/.context\\\" claude --print 'Follow .arch-explorer/PROMPT.md' --allowedTools '*'\"\n      exit 1\n    }\n    ```\n\n    If it fails, STOP. The agent cannot change `CTX_DIR` for itself:\n    child shells and skill invocations inherit the parent Claude\n    process environment, which only the caller can control. Do not\n    proceed, do not run `ctx` commands, do not skip the check.\n3. If phase is `bootstrap`:\n    - Run `ctx init`, confirm `.context/` exists.\n    - Then run `/ctx-architecture` (structural baseline).\n4. If phase is `principal` or `frontier-*`:\n    - Run `/ctx-architecture` (add `principal` argument for principal phase).\n    - The skill will read existing artifacts and build on them.\n5. If phase is `enriched`:\n    - Verify GitNexus is connected: call `mcp__gitnexus__list_repos`.\n    - Success = non-empty list returned with no error.\n    - If GitNexus unavailable, log as `enriched-skipped` and advance\n      to `frontier-1`.\n    - Run `/ctx-architecture-enrich`.\n6. If phase is a lens run (`lens-security`, etc.):\n    - Run `/ctx-architecture` with lens focus prepended as instruction\n      (see lens table above for exact wording).\n\n### Step 4: Extract Results\n\nAfter the skill completes, gather:\n\n- **Convergence score**: from `map-tracking.json`, computed as:\n  average of all module `confidence` values (0.0-1.0). If\n  `map-tracking.json` is missing or has no confidence values,\n  record `null` and log a warning.\n- **Frontier count**: from CONVERGENCE-REPORT.md, count the number\n  of listed unexplored areas. If CONVERGENCE-REPORT.md is missing,\n  record `frontier_count: null` and log a warning. Treat missing\n  as \"exploration should continue\" (do not stall).\n- **Key findings**: 2-3 bullet points of what was discovered or\n  changed in this run (new modules mapped, danger zones found, etc.)\n- **New artifacts**: list any new files created in `.context/`\n\n### Step 5: Update Tracking\n\nUpdate `.arch-explorer/manifest.json`:\n\n```json\n{\n  \"progress\": {\n    \"ctx\": {\n      \"phases_completed\": [\"bootstrap\", \"principal\"],\n      \"current_phase\": \"enriched\",\n      \"lenses_explored\": [],\n      \"last_run\": \"2026-04-07T14:00:00Z\",\n      \"convergence_score\": 0.72,\n      \"frontier_count\": 3,\n      \"total_runs\": 2,\n      \"findings_summary\": \"14 modules mapped, 3 danger zones, 2 extension points\"\n    }\n  }\n}\n```\n\nAppend to `.arch-explorer/run-log.md`:\n\n```markdown\n## 2026-04-07T14:00:00Z / ctx / principal\n\n**Phase:** principal\n**Convergence:** 0.45 -> 0.72\n**Frontiers remaining:** 3\n**Key findings:**\n- Identified CLI dispatch as primary bottleneck (fan-out to 12 subsystems)\n- Security: context files readable by any process (no access control)\n- Strategic recommendation: extract context engine into library package\n\n**Artifacts updated:** ARCHITECTURE-PRINCIPAL.md, DANGER-ZONES.md, map-tracking.json\n```\n\n### Step 6: Report and Stop\n\nPrint this exact format as the FINAL output of the invocation:\n\n```\n[arch-explorer] DONE\n  repo: ctx\n  phase: principal\n  convergence: 0.72\n  frontiers: 3\n  runs_on_repo: 3\n  next: ctx / enriched\n```\n\nThe `[arch-explorer] DONE` line is the terminal marker. After printing\nit, produce no further output. Execution is complete.\n\n## Rules\n\n1. **One unit per invocation.** The only composite unit is `bootstrap`\n   (init + structural). All other phases are exactly one skill run.\n2. **Additive only.** Never delete or overwrite existing artifacts.\n   The skills already handle incremental updates.\n3. **No duplicated work.** Read manifest before acting. If a phase is\n   already recorded as completed, skip it.\n4. **Log everything.** Every run gets a run-log entry, even failures\n   and skips.\n5. **Fail gracefully.** If a skill fails (missing GitNexus, broken repo,\n   etc.), log the failure with reason and advance to the next phase or\n   repo. Don't retry in the same invocation.\n6. **Respect ctx conventions.** Each repo gets its own `.context/`\n   directory. Never write architecture artifacts outside `.context/`.\n\n## Stopping Logic\n\nA repo is considered \"explored\" when ANY of these is true:\n- Convergence score >= 0.85 (from map-tracking.json)\n- 3+ frontier runs produced no new findings (frontier_count unchanged\n  across consecutive runs)\n- All 5 lenses have been applied\n- Convergence score is `null` after 3 attempts (artifacts aren't being\n  generated properly; log warning and move on)\n\nWhen a repo is explored, advance `current_repo_index` in the manifest.\n\n## When All Repos Are Done\n\nWhen every repo has reached its stopping condition, print:\n\n```\n[arch-explorer] ALL DONE\n  - ctx: 0.92 convergence, 8 runs, 5 lenses\n  - portal: 0.87 convergence, 6 runs, 3 lenses\n  ...\n```\n
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#invocation","level":2,"title":"Invocation","text":"

      The caller MUST set CTX_DIR to the sub-repo the agent will work on. The agent verifies this at Step 3.2 and stops if it does not match. The wrapper reads the manifest to pick the current sub-repo, then launches claude with CTX_DIR pinned to that sub-repo's .context/.

      Single run (safest for quota):

      cd ~/WORKSPACE\nREPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\nCTX_DIR=\"$PWD/$REPO/.context\" \\\n  claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*'\n

      Batch of N runs:

      cd ~/WORKSPACE\nfor i in $(seq 1 5); do\n  REPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\n  CTX_DIR=\"$PWD/$REPO/.context\" \\\n    claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*'\n  echo \"--- Run $i complete (repo: $REPO) ---\"\ndone\n

      Resume after interruption:

      Just run the wrapper again. The manifest tracks state; the agent picks up where it left off. CTX_DIR is recomputed from the manifest on each invocation, so the right sub-repo is always bound.

      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#tips","level":2,"title":"Tips","text":"
      • Start small: list 1-2 repos in the manifest first. Add more once you're confident in the output quality.
      • GitNexus is optional: the enrichment phase is skipped gracefully if GitNexus isn't connected. You still get structural and principal analysis.
      • Review between batches: check the run-log and generated artifacts between batch runs. The agent is additive-only, but early course correction saves wasted runs.
      • Lens runs are the payoff: the first three phases build the map; lens runs find the interesting things (security gaps, performance cliffs, stability risks).
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#history","level":2,"title":"History","text":"
      • 2026-04-07: Original prompt created as hack/agents/architecture-explorer.md.
      • 2026-04-16: Moved to docs as a runbook for discoverability.
      • 2026-04-20: Added CTX_DIR verification at Step 3.2 and per-invocation CTX_DIR binding in the wrapper, so the agent writes artifacts to the sub-repo's .context/ instead of the inherited workspace one.
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/backup-strategy/","level":1,"title":"Backup Strategy","text":"

      ctx backup was removed. File-level backup is not ctx's responsibility; your OS or a dedicated backup tool handles it better and without locking you into a specific mount strategy.

      This runbook explains what to back up, how ctx hub reduces the surface, and what options exist for the rest.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-to-back-up","level":2,"title":"What To Back Up","text":"

      Per project:

      • .context/: all context files, journal, state, scratchpad.
      • .claude/: Claude Code settings, hooks, skills specific to the project. Skip this entry when it lives in git; the repo is the backup.

      Per user:

      • ~/.ctx/: global config, the encryption key (~/.ctx/.ctx.key), hub data directory (if running a local hub).
      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#how-hub-reduces-backup-needs","level":2,"title":"How Hub Reduces Backup Needs","text":"

      ctx hub replicates the knowledge surface across machines:

      • DECISIONS.md
      • LEARNINGS.md
      • CONVENTIONS.md
      • CONSTITUTION.md
      • ARCHITECTURE.md
      • Task items promoted to hub

      If you run ctx hub (as a server or by subscribing to someone else's), the data that matters most survives losing any single machine.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-hub-does-not-replicate","level":2,"title":"What Hub Does Not Replicate","text":"

      Hub is not a file-level backup. The following still live only on the machine that produced them:

      • Journal entries (.context/journal/*.md)
      • Runtime state (.context/state/*)
      • Session event log (.context/events.jsonl)
      • Scratchpad (.context/.pad)
      • Encrypted notify/webhook config (.context/.notify.enc)
      • The encryption key itself (~/.ctx/.ctx.key)

      If you need those to survive a disk failure, use a file-level backup.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#example-strategies","level":2,"title":"Example Strategies","text":"","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#1-cron-rsync-to-nas-or-external-drive","level":3,"title":"1. cron + rsync to NAS or External Drive","text":"
      # Daily at 03:00, mirror ~/WORKSPACE and ~/.ctx to NAS\n0 3 * * * rsync -a --delete \\\n    --exclude='node_modules' \\\n    --exclude='dist' \\\n    --exclude='.context/state' \\\n    ~/WORKSPACE/ /mnt/nas/backup/workspace/\n0 3 * * * rsync -a --delete ~/.ctx/ /mnt/nas/backup/ctx-global/\n

      Adjust excludes for the trash you don't want to back up. The .context/state/ dir is ephemeral per-session; skip it.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#2-cron-cp-to-a-cloud-synced-directory","level":3,"title":"2. cron + cp to a Cloud-Synced Directory","text":"

      iCloud Drive, Dropbox, or any directory watched by a sync client:

      0 3 * * * cp -a ~/WORKSPACE/some-project/.context \\\n    ~/CloudDrive/ctx-backups/some-project/$(date +\\%Y-\\%m-\\%d)\n

      Daily snapshots, cloud provider handles the replication.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#3-time-machine-macos","level":3,"title":"3. Time Machine (macOS)","text":"

      If you already run Time Machine, ensure ~/WORKSPACE and ~/.ctx are not in its exclusion list. Time Machine handles versioning; you get point-in-time recovery for free.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#4-borg-or-restic-for-versioned-backups","level":3,"title":"4. Borg or restic for Versioned Backups","text":"

      For deduplicated, versioned, encrypted backups:

      # Borg init (once)\nborg init --encryption=repokey /mnt/nas/borg-ctx\n\n# Daily backup\nborg create /mnt/nas/borg-ctx::'ctx-{now}' \\\n    ~/WORKSPACE ~/.ctx \\\n    --exclude '*/node_modules' \\\n    --exclude '*/.context/state'\n

      Use restic if you prefer S3-compatible targets.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#when-you-still-need-file-level-backup-even-with-hub","level":2,"title":"When You Still Need File-Level Backup Even With Hub","text":"
      • Journal: session histories are local-only until exported.
      • Scratchpad: private notes, encrypted locally.
      • Encryption key: losing ~/.ctx/.ctx.key means losing access to every encrypted file in every project.
      • Non-hub projects: projects that never called ctx hub register have zero cross-machine persistence.

      For these, pick one strategy above and forget about it.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#why-ctx-no-longer-ships-a-backup-command","level":2,"title":"Why ctx No Longer Ships a Backup Command","text":"

      Backup is inherently environment-specific: SMB, NFS, S3, rsync, Time Machine, Borg, restic. Every user has a different story. The previous ctx backup picked SMB via GVFS, which was Linux-only and narrow. Chasing mount strategies would never generalize.

      Hub is the right answer for the data ctx owns (knowledge). For everything else, your OS or a dedicated backup tool is the right layer.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/breaking-migration/","level":1,"title":"Breaking Migration","text":"","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#breaking-migration-guide","level":1,"title":"Breaking Migration Guide","text":"

      Template for upgrading across breaking CLI renames or behavior changes. Use this as a starting point when writing migration notes for a specific release, or hand it to your agent as context for generating release-specific guidance.

      When to use: When a release includes breaking changes (command renames, removed flags, changed defaults) that require user action.

      Companion: Upgrade guide covers the general upgrade flow. This runbook covers the breaking-change specifics.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-1-identify-what-changed","level":2,"title":"Step 1: Identify What Changed","text":"

      Ask your agent to diff the CLI surface between the old and new version:

      Compare the CLI command surface between the previous release tag\nand HEAD. For each change, categorize as: renamed, removed,\nnew, or changed-behavior. Include old and new command signatures.\n

      Or use the /_ctx-command-audit skill after the rename.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-2-regenerate-infrastructure","level":2,"title":"Step 2: Regenerate Infrastructure","text":"
      # Install the new binary\nmake build && sudo make install\n\n# Regenerate CLAUDE.md and permissions\nctx init --force --merge\n

      --merge preserves your knowledge files (TASKS.md, DECISIONS.md, etc.) while regenerating infrastructure (permissions, CLAUDE.md managed sections).

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-3-update-the-plugin","level":2,"title":"Step 3: Update the Plugin","text":"
      /plugin -> select ctx -> Update now\n

      Or, if using a local clone:

      make plugin-reload\n# restart Claude Code\n
      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-4-update-personal-scripts","level":2,"title":"Step 4: Update Personal Scripts","text":"

      Search your scripts and aliases for old command names:

      # Example: find references to old command names\ngrep -r \"ctx old-command\" ~/scripts/ ~/.zshrc ~/.bashrc\n

      Replace with the new names per the changelog.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-5-update-hook-configs","level":2,"title":"Step 5: Update Hook Configs","text":"

      If you have custom hooks in .claude/settings.local.json that reference ctx commands, update them:

      jq '.hooks' .claude/settings.local.json | grep \"ctx \"\n
      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-6-verify","level":2,"title":"Step 6: Verify","text":"

      Activate the project first, otherwise ctx status and ctx drift will fail with Error: no context directory specified:

      eval \"$(ctx activate)\"\nctx status          # context files intact\nctx drift           # no broken references\nmake test           # if you're a contributor\n

      See Activating a Context Directory.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#writing-release-specific-migration-notes","level":2,"title":"Writing Release-Specific Migration Notes","text":"

      When preparing a release with breaking changes, create a section in the release notes using this template:

      ## Breaking Changes\n\n### `old-command` renamed to `new-command`\n\n**What changed**: `ctx old-command` is now `ctx new-command`.\nThe old name is removed (no deprecation alias).\n\n**Action required**:\n1. Run `ctx init --force --merge` to update CLAUDE.md\n2. Update any scripts referencing `ctx old-command`\n3. Update hook configs if applicable\n\n**Why**: [brief rationale for the rename]\n

      Repeat for each breaking change. Users should be able to follow the notes mechanically without needing to understand the codebase.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/codebase-audit/","level":1,"title":"Codebase Audit","text":"","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#codebase-audit","level":1,"title":"Codebase Audit","text":"

      A structured audit of the codebase: dead code, magic strings, documentation drift, security surface, and roadmap opportunities.

      When to run: Before a release, after a long YOLO sprint, quarterly, or when planning the next phase of work.

      Time: ~15-30 minutes with a team of agents.

      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#how-to-use-this-runbook","level":2,"title":"How to Use This Runbook","text":"

      Start a Claude Code session with a clean git state (git stash or commit first). Paste or adapt the prompt below. The agent does the analysis; you triage the findings.

      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#prompt","level":2,"title":"Prompt","text":"
      I want you to create an agent team to audit this codebase. Save each report as\na separate markdown file under `./ideas/` (or another directory if you prefer).\n\nUse read-only agents (subagent_type: Explore) for all analyses. No code changes.\n\nFor each report, use this structure:\n- Executive Summary (2-3 sentences + severity table)\n- Findings (grouped, with file:line references)\n- Ranked Recommendations (high/medium/low priority)\n- Methodology (what was examined, how)\n\nKeep reports actionable: every finding should suggest a concrete fix or next step.\n\n## Analyses to Run\n\n### 1. Extractable Patterns (session mining)\nSearch session JSONL files, journal entries, and task archives for repetitive\nmulti-step workflows. Count frequency of bash command sequences, slash command\nusage, and recurring user prompts. Identify patterns that could become skills\nor scripts. Cross-reference with existing skills to find coverage gaps.\nOutput: ranked list of automation opportunities with frequency data.\n\n### 2. Documentation Drift (godoc + inline)\nCompare every doc.go against its package's actual exports and behavior. Check\ninline godoc comments on exported functions against their implementations.\nScan for stale TODO/FIXME/HACK comments. Check package-level comments match\npackage names. Output: drift items ranked by severity with exact file:line refs.\n\n### 3. Maintainability\nLook for: functions >80 lines that have logical split points; switch blocks\nwith >5 cases that could be table-driven or extracted; inline comments that\nsay \"step 1\", \"step 2\" or similar (sign the block wants to be a function);\nfiles with >400 lines; packages with flat structure that could benefit from\nsub-packages; functions that seem misplaced in their file. Do NOT flag\nthings that are fine as-is just because they could theoretically be different.\nOutput: concrete refactoring suggestions, not style nitpicks.\n\n### 4. Security Review\nThis is a CLI app: focus on CLI-relevant attack surface, not web OWASP:\nfile path traversal (does user input flow into file paths unsanitized?),\ncommand injection (does user input flow into exec calls?), symlink following\n(does the tool follow symlinks when writing to .context/?), permission\nhandling (are file permissions set correctly?), sensitive data in outputs\n(do any commands leak secrets or session content?). Output: findings with\nseverity ratings and exploit scenarios.\n\n### 5. Blog Theme Discovery\nRead existing blog posts for style and narrative voice. Analyze git log,\nrecent session discussions, and DECISIONS.md for story arcs worth writing\nabout. Suggest 3-5 blog post themes with: title, angle, target audience,\nkey commits/sessions to reference, and a 2-sentence pitch. Prioritize\nthemes that build a coherent narrative across posts.\n\n### 6. Roadmap & Value Opportunities\nBased on current features, recent momentum, and gaps found in other analyses:\nwhat are the highest-value improvements? Consider: user-facing features,\ndeveloper experience, integration opportunities, and low-hanging fruit.\nOutput: prioritized list with effort/impact estimates (not time estimates).\n\n### 7. User-Facing Documentation\nEvaluate README, help text, and any user docs. Suggest improvements\nstructured as use-case pages: the problem, how ctx solves it, typical\nworkflow, gotchas. Identify gaps where a user would get stuck without\nreading source code. Output: list of documentation gaps and suggested\npage outlines.\n\n### 8. Agent Team Strategies\nBased on the codebase structure, suggest 2-3 agent team configurations for\nupcoming work sessions. For each: team composition (roles, agent types),\ntask distribution strategy, coordination approach, and which types of work\nit suits. Ground suggestions in actual project patterns, not generic advice.\n
      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#tips","level":2,"title":"Tips","text":"
      • Clean state matters: the prompt says \"no code changes\" but accidents happen. Start from a clean git state so you can git checkout . if needed.

      • Adjust scope: drop analyses you don't need. Analyses 1-4 are the most actionable. Analyses 5-8 are planning/creative and can be skipped if you just want a technical audit.

      • Reports feed TASKS.md: after the audit, read each report and create tasks in the appropriate Phase section. The reports are input, not output.

      • ideas/ is gitignored: reports saved there won't be committed. Move specific findings to TASKS.md, DECISIONS.md, or LEARNINGS.md to persist them.

      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#history","level":2,"title":"History","text":"
      • 2026-02-08: Original prompt created after a codebase audit sprint.
      • 2026-02-17: Improved with read-only agents, report structure template, CLI-scoped security review, and maintainability thresholds.
      • 2026-04-16: Moved from hack/runbooks/ to docs/operations/runbooks/.
      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/","level":1,"title":"Docs Semantic Audit","text":"","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#documentation-semantic-audit","level":1,"title":"Documentation Semantic Audit","text":"

      Find structural problems that linters and link checkers cannot: weak pages that should be merged, heavy pages that should be split, missing cross-links, and narrative arcs that don't land.

      When to run: Before a release, after adding several new pages, when the site feels sprawling, or when you suspect narrative gaps.

      Time: ~20-40 minutes with an agent session.

      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#why-this-is-a-runbook","level":2,"title":"Why This Is a Runbook","text":"

      These judgments are inherently subjective and context-dependent. A page is \"weak\" relative to its neighbors; a narrative arc only matters if the docs intend to tell a story. Deterministic tools (broken-link checkers, word counters) can't do this. An LLM reading the full doc set can.

      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#prompt","level":2,"title":"Prompt","text":"

      Paste or adapt the following into a Claude Code session. The agent needs read access to docs/ and the site nav structure.

      Read every file under docs/ (including docs/blog/ and docs/recipes/).\nFor each file, note: title, word count, outbound links, inbound links\n(how many other pages link to it), and a one-line summary of its purpose.\n\nThen produce a report with these sections:\n\n## 1. Weak Dangling Pages\n\nPages that are thin, isolated, or redundant. Signs:\n- Under ~300 words with no unique content (just restates what another page says)\n- Zero or one inbound links (orphaned in the nav)\n- Content that would be stronger merged into an adjacent page\n- \"Try it in 5 minutes\" sections that assume installation already happened\n- Pages whose title doesn't work as a nav entry (too long, too vague)\n\nFor each: identify the page, explain why it's weak, and recommend\nmerge target or deletion.\n\n## 2. Overly Heavy Pages\n\nPages doing too much. Signs:\n- Over ~1500 words with multiple distinct topics\n- More than 4 H2 sections that could stand alone\n- Reader has to scroll past irrelevant content to find what they need\n- Mixed audience (beginner setup + advanced config on same page)\n\nFor each: identify the page, list the distinct topics, and suggest\nsplit points.\n\n## 3. Missing Cross-Links\n\nPlaces where a reader would naturally want to jump to related content\nbut no link exists. Look for:\n- Concepts mentioned but not linked (e.g., \"scratchpad\" without linking\n  to the scratchpad page)\n- Blog posts that describe features without linking to the reference docs\n- Recipes that reference workflows without linking to the relevant\n  getting-started section\n- Pages that end without a \"Next Up\" or \"See Also\" pointer\n\nFor each: source page, anchor text, suggested link target.\n\n## 4. Narrative Gaps\n\nThe docs should tell a coherent story: problem -> install -> first session\n-> daily workflow -> advanced patterns -> contributing. Look for:\n- Gaps in the progression (e.g., no bridge from \"first session\" to\n  \"daily habits\")\n- Blog posts that introduce concepts the reference docs don't cover\n- Recipes that assume knowledge no other page teaches\n- Features documented in CLI reference but missing from workflows/recipes\n\nFor each: describe the gap and suggest what page or section would fill it.\n\n## 5. Blog Cross-Linking Opportunities\n\nBlog posts are often written in isolation. Look for:\n- Posts that cover the same theme but don't reference each other\n- Posts that describe the evolution of a feature (natural \"part 1 / part 2\")\n- Posts that would benefit from a \"Related posts\" footer\n- Thematic clusters that could be linked from a recipe or reference page\n\nFor each: list the posts, the shared theme, and the suggested links.\n\n## Output Format\n\nFor every finding, include:\n- File path (docs/whatever.md)\n- Severity: high (actively confusing), medium (missed opportunity),\n  low (nice to have)\n- Concrete recommendation (merge into X, split at H2 Y, add link to Z)\n\nEnd with a prioritized action list: what to fix first.\n
      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#after-the-audit","level":2,"title":"After the Audit","text":"
      1. Triage findings: not everything needs fixing. Focus on high severity.
      2. Merge weak pages first: fewer pages is almost always better.
      3. Add cross-links: cheapest improvement, highest reader impact.
      4. File split decisions in DECISIONS.md: page splits are architectural.
      5. Regenerate the site and spot-check nav after structural changes.
      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#history","level":2,"title":"History","text":"
      • 2026-02-17: Created after merging docs/re-explaining.md into docs/about.md, which surfaced the pattern of weak standalone pages that dilute rather than add.
      • 2026-04-16: Moved from hack/runbooks/ to docs/operations/runbooks/.
      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/hub-deployment/","level":1,"title":"Hub Deployment","text":"","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#hub-deployment","level":1,"title":"Hub Deployment","text":"

      Linear runbook for setting up a ctx Hub for yourself or a team. Consolidates pieces currently scattered across hub recipes and operations docs.

      When to use: First-time hub setup, or when onboarding a new team onto an existing hub.

      Prerequisites: ctx binary installed, network connectivity between hub and clients.

      Companion docs:

      • Hub overview: what the hub is and is not
      • Hub operations: data directory, systemd, backup, monitoring
      • Hub failure modes: what can go wrong
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-1-start-the-hub","level":2,"title":"Step 1: Start the Hub","text":"Quick Start (foreground)Production (systemd)
      ctx hub start\n

      See Hub Operations: Systemd Unit for the full unit file.

      sudo systemctl enable --now ctx-hub\n

      The hub creates admin.token on first start. Save this token; it is the only way to register clients.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-2-generate-the-admin-token","level":2,"title":"Step 2: Generate the Admin Token","text":"

      On first start, the hub writes admin.token to the data directory (default ~/.ctx/hub-data/):

      cat ~/.ctx/hub-data/admin.token\n

      This token has full admin privileges. Keep it secret.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-3-register-clients","level":2,"title":"Step 3: Register Clients","text":"

      For each client (person or machine) that will connect:

      # On the hub machine\nctx hub register --name \"volkan-laptop\" --admin-token <admin-token>\n

      This returns a client token. Distribute it securely to the client.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-4-connect-clients","level":2,"title":"Step 4: Connect Clients","text":"

      On each client machine, register the project with the hub. The ctx hub * commands above run on the hub server itself and don't need a project. The ctx connection * commands below are different: they live inside a project (the encrypted hub config is stored at .context/.connect.enc), so you have to tell ctx which project first.

      # In the project directory on the client machine:\neval \"$(ctx activate)\"\nctx connection register <hub-address> --token <client-token>\n

      Verify the connection:

      ctx connection status\n

      If the client doesn't have a project yet, run ctx init first, then eval \"$(ctx activate)\". See Activating a Context Directory.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-5-verify-sync","level":2,"title":"Step 5: Verify Sync","text":"

      Push a test entry from one client and verify it arrives. Make sure each client already ran eval \"$(ctx activate)\" from Step 4: otherwise ctx add and ctx status fail with Error: no context directory specified.

      # Client A (in its project directory, after activating):\nctx add learning \"Hub sync test\" --context \"Verifying hub setup\"\n\n# Client B (in its project directory, after activating):\nctx status   # should show the new learning\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-6-configure-backup","level":2,"title":"Step 6: Configure Backup","text":"

      Set up regular backups of the hub data directory. See Hub Operations: Backup and Restore.

      Minimum:

      # Add to cron\n0 */6 * * * cp ~/.ctx/hub-data/entries.jsonl ~/backups/entries-$(date +\\%F).jsonl\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-7-configure-tls-when-available","level":2,"title":"Step 7: Configure TLS (When Available)","text":"

      Coming Soon

      TLS support is planned (H-01/H-02). Until then, run the hub on a trusted network or behind a reverse proxy with TLS termination.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#team-onboarding-checklist","level":2,"title":"Team Onboarding Checklist","text":"

      When adding a new team member to an existing hub:

      • Generate a client token (ctx hub register --name \"<name>\")
      • Share the token and hub address securely
      • Have them run ctx connect <hub-address> --token <token>
      • Verify with ctx connection status
      • Point them to the Hub Getting Started recipe
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#connection-refused","level":3,"title":"\"Connection Refused\"","text":"

      The hub isn't running or the port is wrong. Check:

      ctx hub status          # on the hub machine\nss -tlnp | grep 9900   # default port\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#authentication-failed","level":3,"title":"\"Authentication Failed\"","text":"

      The client token is wrong or was never registered. Re-register:

      ctx hub register --name \"<name>\" --admin-token <admin-token>\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#entries-not-syncing","level":3,"title":"Entries Not Syncing","text":"

      Check that the client is listening:

      ctx connection status\n

      If connected but not syncing, check the hub logs for sequence mismatch errors. See Hub Failure Modes for details.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/new-contributor/","level":1,"title":"New Contributor","text":"","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#new-contributor-onboarding","level":1,"title":"New Contributor Onboarding","text":"

      Step-by-step onboarding sequence for new contributors. Consolidates setup instructions currently scattered across the README, contributing guide, and setup docs.

      When to use: First-time contributor setup, or when verifying your development environment after a major upgrade.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-1-clone-the-repository","level":2,"title":"Step 1: Clone the Repository","text":"
      git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\n

      Or fork first on GitHub, then clone your fork.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-2-initialize-context","level":2,"title":"Step 2: Initialize Context","text":"
      ctx init\neval \"$(ctx activate)\"\n

      ctx init creates the .context/ directory with knowledge files and the .claude/ directory with agent configuration. eval \"$(ctx activate)\" tells ctx to use that directory for the rest of this runbook. If you skip the second line, the later steps fail with Error: no context directory specified.

      If ctx is not yet installed, proceed to Step 3 first, then come back.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-3-build-and-install","level":2,"title":"Step 3: Build and Install","text":"
      make build\nsudo make install\n

      Verify:

      ctx --version\n
      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-4-install-the-plugin-claude-code-users","level":2,"title":"Step 4: Install the Plugin (Claude Code Users)","text":"

      If you use Claude Code, install the plugin from your local clone so skills and hooks reflect your working tree:

      1. Launch claude
      2. Type /plugin and press Enter
      3. Select Marketplaces -> Add Marketplace
      4. Enter the absolute path to your clone (e.g., ~/WORKSPACE/ctx)
      5. Back in /plugin, select Install and choose ctx

      Verify:

      claude /plugin list   # should show ctx\n

      See Contributing: Install the Plugin for details on cache clearing.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-5-switch-to-dev-profile","level":2,"title":"Step 5: Switch to Dev Profile","text":"
      ctx config switch dev\n

      This enables verbose logging and notify events (useful during development).

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-6-verify-hooks","level":2,"title":"Step 6: Verify Hooks","text":"

      Start a Claude Code session and check that hooks fire:

      claude\n

      You should see ctx session hooks (ceremonies reminder, context loading) on session start. If not, check that the plugin is installed correctly (Step 4).

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-7-run-your-first-session","level":2,"title":"Step 7: Run Your First Session","text":"

      In Claude Code:

      /ctx-status\n

      This should show context file health, active tasks, and recent decisions. If it works, your setup is complete.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-8-verify-context-persistence","level":2,"title":"Step 8: Verify Context Persistence","text":"

      End the session and start a new one:

      /ctx-remember\n

      The agent should recall what happened in the previous session. This confirms that context persistence is working end-to-end.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-9-run-tests","level":2,"title":"Step 9: Run Tests","text":"
      make test     # unit tests\nmake audit    # full check: fmt + vet + lint + drift + docs + test\n

      All tests should pass with a clean clone.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#quick-reference","level":2,"title":"Quick Reference","text":"Task Command Build make build Install sudo make install Test make test Full audit make audit Rebuild docs site make site Serve docs locally make site-serve Clear plugin cache make plugin-reload Switch config profile ctx config switch dev","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#next-steps","level":2,"title":"Next Steps","text":"
      • Read the contributing guide for project layout, code style, and PR process
      • Check TASKS.md for open work items
      • Ask /ctx-next for suggested work
      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/plugin-release/","level":1,"title":"Plugin Release","text":"","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#plugin-release","level":1,"title":"Plugin Release","text":"

      Plugin-specific release procedure. The general release checklist covers the full ctx release; this runbook covers the plugin-specific steps that are not part of that flow.

      When to use: When releasing plugin changes (new skills, hook updates, permission changes) independently of a ctx binary release, or as a sub-procedure within the full release.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#what-ships-in-the-plugin","level":2,"title":"What Ships in the Plugin","text":"

      The plugin lives at internal/assets/claude/ and includes:

      Component Path What it does Skills internal/assets/claude/skills/ User-facing /ctx-* slash commands Hooks internal/assets/claude/hooks/ Pre/post tool-use hooks Plugin manifest internal/assets/claude/.claude-plugin/plugin.json Declares skills, hooks, version Marketplace .claude-plugin/marketplace.json Points Claude Code to the plugin","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-1-update-hooksjson-if-hooks-changed","level":2,"title":"Step 1: Update hooks.json (If Hooks Changed)","text":"

      If you added, removed, or modified hooks:

      # Verify hook definitions match implementations\nmake audit\n

      Check that plugin.json lists all hooks correctly. Missing hooks silently fail to fire.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-2-bump-version","level":2,"title":"Step 2: Bump Version","text":"

      Update the version in three places:

      • internal/assets/claude/.claude-plugin/plugin.json
      • .claude-plugin/marketplace.json (two fields)
      • editors/vscode/package.json + package-lock.json (if VS Code extension is affected)

      The Release Script Does This

      If you're running make release, the script bumps these automatically from VERSION. Only bump manually if you're releasing the plugin independently.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-3-test-against-a-fresh-install","level":2,"title":"Step 3: Test Against a Fresh Install","text":"
      # Clear cached plugin\nmake plugin-reload\n\n# Restart Claude Code, then:\nclaude /plugin list    # verify version\n

      Test the critical paths:

      • /ctx-status works
      • Session hooks fire (ceremonies, context loading)
      • At least one user-facing skill works end-to-end
      • Pre-tool-use hooks block when they should
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-4-test-against-a-clean-project","level":2,"title":"Step 4: Test Against a Clean Project","text":"

      Create a temporary project to verify the plugin works outside the ctx repo:

      mkdir /tmp/test-ctx-plugin && cd /tmp/test-ctx-plugin\ngit init\nctx init\nclaude   # start a session, verify hooks fire\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-5-verify-skill-count","level":2,"title":"Step 5: Verify Skill Count","text":"

      The plugin manifest declares all user-invocable skills. Verify the count matches:

      # Count skills in plugin.json\njq '.skills | length' internal/assets/claude/.claude-plugin/plugin.json\n\n# Count skill directories\nls -d internal/assets/claude/skills/ctx-*/ | wc -l\n

      These numbers should match (some skills are not user-invocable and won't appear in both counts).

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-6-commit-and-tag","level":2,"title":"Step 6: Commit and Tag","text":"

      If releasing independently of a binary release:

      git add internal/assets/claude/ .claude-plugin/\ngit commit -m \"chore: release plugin v0.X.Y\"\ngit tag plugin-v0.X.Y\ngit push origin main --tags\n

      If part of a full release, the release checklist handles this.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#skills-dont-appear-after-update","level":3,"title":"Skills Don't Appear After Update","text":"

      Claude Code caches plugin files aggressively:

      make plugin-reload    # clears cache\n# restart Claude Code\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#hooks-dont-fire","level":3,"title":"Hooks Don't Fire","text":"

      Check that the hook is registered in plugin.json and that the command it calls exists:

      jq '.hooks' internal/assets/claude/.claude-plugin/plugin.json\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#version-mismatch","level":3,"title":"Version Mismatch","text":"

      If claude /plugin list shows an old version after updating:

      make plugin-reload\n# restart Claude Code\nclaude /plugin list   # should show new version\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/release-checklist/","level":1,"title":"Release Checklist","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#release-checklist","level":1,"title":"Release Checklist","text":"

      The canonical pre-release sequence. This runbook ties together the audits, tests, and release steps that are otherwise scattered across docs and the operator's head.

      When to run: Before every release. No exceptions.

      Companion: The /_ctx-release skill automates the tag-and-push portion; this checklist covers everything before and after that automation.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#pre-release","level":2,"title":"Pre-Release","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#1-run-the-codebase-audit","level":3,"title":"1. Run the Codebase Audit","text":"

      Use the codebase audit runbook prompt with your agent. Focus on analyses 1-4 (extractable patterns, documentation drift, maintainability, security). Triage findings into TASKS.md; anything blocking ships before the release.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#2-run-the-docs-semantic-audit","level":3,"title":"2. Run the Docs Semantic Audit","text":"

      Use the docs semantic audit runbook prompt. Fix high-severity findings (weak pages, broken narrative arcs). Medium-severity items can be deferred.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#3-sanitize-permissions","level":3,"title":"3. Sanitize Permissions","text":"

      Follow the sanitize permissions runbook. Clean up .claude/settings.local.json before it gets committed as part of the release.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#4-run-the-full-test-suite","level":3,"title":"4. Run the Full Test Suite","text":"
      make audit    # fmt + vet + lint + drift + docs + test\nmake smoke    # integration smoke tests\n

      All tests must pass. No exceptions.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#5-check-context-health","level":3,"title":"5. Check Context Health","text":"

      Activate the project so the next commands know which .context/ to read:

      eval \"$(ctx activate)\"\nctx drift          # broken references, stale patterns\nctx status         # context file health\n/ctx-link-check    # dead links in docs\n

      Fix anything flagged. If you see Error: no context directory specified, you skipped the eval line above. See Activating a Context Directory.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#6-review-tasksmd","level":3,"title":"6. Review TASKS.md","text":"

      Scan for incomplete tasks tagged as release-blocking. Either finish them or explicitly defer with a reason in the task note.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#release","level":2,"title":"Release","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#7-bump-version","level":3,"title":"7. Bump Version","text":"
      echo \"0.X.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.X.0\"\n
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#8-generate-release-notes","level":3,"title":"8. Generate Release Notes","text":"

      In Claude Code:

      /_ctx-release-notes\n

      Review dist/RELEASE_NOTES.md. Ensure it captures all user-visible changes.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#9-cut-the-release","level":3,"title":"9. Cut the Release","text":"
      make release\n

      Or in Claude Code: /_ctx-release. See Cutting a Release for the full step-by-step.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#post-release","level":2,"title":"Post-Release","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#10-verify-the-github-release","level":3,"title":"10. Verify the GitHub Release","text":"
      • GitHub Releases shows the new version
      • All 6 binaries are attached
      • SHA256 checksums are attached
      • Release notes render correctly
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#11-update-the-plugin-marketplace","level":3,"title":"11. Update the Plugin Marketplace","text":"

      If the plugin version changed, verify the marketplace entry:

      claude /plugin list   # shows updated version\n
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#12-announce","level":3,"title":"12. Announce","text":"

      Post in the project's communication channels. Reference the release notes.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#13-clean-up","level":3,"title":"13. Clean Up","text":"
      rm dist/RELEASE_NOTES.md   # consumed by the release script\ngit stash pop              # if you stashed earlier\n
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/","level":1,"title":"Sanitize Permissions","text":"","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#sanitize-permissions","level":1,"title":"Sanitize Permissions","text":"

      Manual procedure for cleaning up .claude/settings.local.json. The agent may analyze and recommend, but you make every edit.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#why-manual-not-automated","level":2,"title":"Why Manual, Not Automated","text":"

      settings.local.json controls what the agent can do without asking. An agent that can edit its own permission file is a self-escalation vector, especially if the skill is auto-accepted. Keep this manual.

      When to run: After busy sessions where you clicked \"Allow\" many times, weekly hygiene (pair with ctx drift), or before committing .claude/settings.local.json.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-1-snapshot","level":2,"title":"Step 1: Snapshot","text":"
      cp .claude/settings.local.json /tmp/settings-backup-$(date +%Y%m%d).json\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-2-extract-the-allow-list","level":2,"title":"Step 2: Extract the Allow List","text":"
      jq '.permissions.allow[]' .claude/settings.local.json | sort\n

      Eyeball it. You're looking for four categories:

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-3-identify-problems","level":2,"title":"Step 3: Identify Problems","text":"","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#a-garbage-nonsense","level":3,"title":"A. Garbage / Nonsense","text":"

      Entries that are clearly broken or meaningless:

      Bash(done)\nBash(__NEW_LINE_aa838494a90279c4__ echo \"\")\n

      Action: Delete.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#b-one-off-commands-session-debris","level":3,"title":"B. One-Off Commands (Session Debris)","text":"

      Entries with hardcoded paths, literal arguments, or exact commands that were accepted during a specific debugging session:

      Bash(git -C /home/jose/WORKSPACE/ctx log --oneline --all -20)\nBash(/home/jose/WORKSPACE/ctx/ctx add decision \"Use PostgreSQL\" --context ...)\n

      Signs of a one-off:

      • Full absolute paths to specific files
      • Literal string arguments (not wildcards)
      • Very specific flag combinations
      • Commands that look like they came from a single task

      Action: Delete unless you want to promote to a wildcard pattern.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#c-subsumed-entries-redundant","level":3,"title":"C. Subsumed Entries (Redundant)","text":"

      A narrow entry that's already covered by a broader one:

      # Narrow (redundant):\nBash(ctx journal source)\nBash(git -C /home/jose/WORKSPACE/ctx log --oneline -5)\n\n# Broad (already covers the above):\nBash(ctx journal source:*)\nBash(git -C:*)\n

      To find these, look for entries where removing the specific args would match an existing wildcard entry.

      Action: Delete the narrow entry.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#d-duplicate-intent-different-spelling","level":3,"title":"D. Duplicate Intent, Different Spelling","text":"

      Same command with env vars in different order, or slight variations:

      Bash(CGO_ENABLED=0 CTX_SKIP_PATH_CHECK=1 go test:*)\nBash(CTX_SKIP_PATH_CHECK=1 CGO_ENABLED=0 go test:*)\n

      Action: Keep one, delete the other.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-4-check-for-security-concerns","level":2,"title":"Step 4: Check for Security Concerns","text":"

      While you're in here, also flag:

      Pattern Risk Bash(git push:*) Bypasses block-git-push.sh hook Bash(rm -rf:*) Recursive delete, no confirmation Bash(sudo:*) Privilege escalation Bash(echo:*), Bash(cat:*) Can compose into writes to sensitive files Bash(curl:*), Bash(wget:*) Arbitrary network access Any write to .claude/ paths Agent self-modification

      See the /ctx-permission-sanitize skill for the full threat matrix.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-5-edit","level":2,"title":"Step 5: Edit","text":"

      Edit .claude/settings.local.json directly in your editor. Remove flagged entries. Keep the JSON valid.

      # Validate JSON after editing\njq . .claude/settings.local.json > /dev/null && echo \"valid\" || echo \"BROKEN\"\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-6-verify","level":2,"title":"Step 6: Verify","text":"
      # Compare before/after\ndiff /tmp/settings-backup-$(date +%Y%m%d).json .claude/settings.local.json\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-7-optionally-commit","level":2,"title":"Step 7: Optionally Commit","text":"
      git add .claude/settings.local.json\ngit commit -m \"chore: sanitize agent permissions\"\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#asking-the-agent-for-help","level":2,"title":"Asking the Agent for Help","text":"

      You can safely ask the agent to analyze the file:

      \"Look at my settings.local.json and tell me which permissions look like one-offs or are redundant.\"

      The agent can read and report. You do the edits.

      Do not add these to your allow list:

      • Skill(ctx-permission-sanitize)
      • Edit(.claude/settings.local.json)
      • Any Bash(...) pattern that writes to .claude/
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#history","level":2,"title":"History","text":"
      • 2026-02-15: Created as manual-only procedure after deciding against a self-modifying skill.
      • 2026-04-16: Moved from hack/runbooks/ to docs/operations/runbooks/.
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"recipes/","level":1,"title":"Recipes","text":"

      Workflow recipes combining ctx commands and skills to solve specific problems.

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#getting-started","level":2,"title":"Getting Started","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#guide-your-agent","level":3,"title":"Guide Your Agent","text":"

      How commands, skills, and conversational patterns work together. Train your agent to be proactive through ask, guide, reinforce.

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#setup-across-ai-tools","level":3,"title":"Setup across AI Tools","text":"

      Initialize ctx and configure hooks for Claude Code, Cursor, Aider, Copilot, or Windsurf. Includes shell completion, watch mode for non-native tools, and verification.

      Uses: ctx init, ctx setup, ctx agent, ctx completion, ctx watch

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#multilingual-session-parsing","level":3,"title":"Multilingual Session Parsing","text":"

      Parse session journal entries written in other languages. Configure recognized session-header prefixes so the journal pipeline works for Turkish, Japanese, and any other locale.

      Uses: ctx journal source, ctx journal import, session_prefixes in .ctxrc

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#keeping-context-in-a-separate-repo","level":3,"title":"Keeping Context in a Separate Repo","text":"

      Store context files outside the project tree: in a private repo, shared directory, or anywhere else. Useful for open source projects with private context or multi-repo setups.

      Uses: ctx init, CTX_DIR, .ctxrc, /ctx-status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#sessions","level":2,"title":"Sessions","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#the-complete-session","level":3,"title":"The Complete Session","text":"

      Walk through a full ctx session from start to finish:

      • Loading context,
      • Picking what to work on,
      • Committing with context,
      • Capturing, reflecting, and saving a snapshot.

      Uses: ctx status, ctx agent, /ctx-remember, /ctx-next, /ctx-commit, /ctx-reflect

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#session-ceremonies","level":3,"title":"Session Ceremonies","text":"

      The two bookend rituals for every session: /ctx-remember at the start to load and confirm context, /ctx-wrap-up at the end to review the session and persist learnings, decisions, and tasks.

      Uses: /ctx-remember, /ctx-wrap-up, /ctx-commit, ctx agent, ctx add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#browsing-and-enriching-past-sessions","level":3,"title":"Browsing and Enriching Past Sessions","text":"

      Export your AI session history to a browsable journal site. Enrich entries with metadata and search across months of work.

      Uses: ctx journal source/import, ctx journal site, ctx journal obsidian, ctx serve, /ctx-history, /ctx-journal-enrich, /ctx-journal-enrich-all

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#session-reminders","level":3,"title":"Session Reminders","text":"

      Leave a message for your next session. Reminders surface automatically at session start and repeat until dismissed. Date-gate reminders to surface only after a specific date.

      Uses: ctx remind, ctx remind list, ctx remind dismiss, ctx system check-reminders

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#reviewing-session-changes","level":3,"title":"Reviewing Session Changes","text":"

      See what moved since your last session: context file edits, code commits, directories touched. Auto-detects session boundaries from state markers.

      Uses: ctx change, ctx agent, ctx status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#pausing-context-hooks","level":3,"title":"Pausing Context Hooks","text":"

      Silence all nudge hooks for a quick task that doesn't need ceremony overhead. Session-scoped: Other sessions are unaffected. Security hooks still fire.

      Uses: ctx hook pause, ctx hook resume, /ctx-pause, /ctx-resume

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#knowledge-and-tasks","level":2,"title":"Knowledge and Tasks","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#persisting-decisions-learnings-and-conventions","level":3,"title":"Persisting Decisions, Learnings, and Conventions","text":"

      Record architectural decisions with rationale, capture gotchas and lessons learned, and codify conventions so they survive across sessions and team members.

      Uses: ctx add decision, ctx add learning, ctx add convention, ctx decision reindex, ctx learning reindex, /ctx-decision-add, /ctx-learning-add, /ctx-convention-add, /ctx-reflect

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#tracking-work-across-sessions","level":3,"title":"Tracking Work across Sessions","text":"

      Add, prioritize, complete, snapshot, and archive tasks. Keep TASKS.md focused as your project evolves across dozens of sessions.

      Uses: ctx add task, ctx task complete, ctx task archive, ctx task snapshot, /ctx-task-add, /ctx-archive, /ctx-next

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#using-the-scratchpad","level":3,"title":"Using the Scratchpad","text":"

      Use the encrypted scratchpad for quick notes, working memory, and sensitive values during AI sessions. Natural language in, encrypted storage out.

      Uses: ctx pad, /ctx-pad, ctx pad show, ctx pad edit

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#syncing-scratchpad-notes-across-machines","level":3,"title":"Syncing Scratchpad Notes across Machines","text":"

      Distribute your scratchpad encryption key, push and pull encrypted notes via git, and resolve merge conflicts when two machines edit simultaneously.

      Uses: ctx init, ctx pad, ctx pad resolve, scp

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#bridging-claude-code-auto-memory","level":3,"title":"Bridging Claude Code Auto Memory","text":"

      Mirror Claude Code's auto memory (MEMORY.md) into .context/ for version control, portability, and drift detection. Import entries into structured context files with heuristic classification.

      Uses: ctx memory sync, ctx memory status, ctx memory diff, ctx memory import, ctx memory publish, ctx system check-memory-drift

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#hooks-and-notifications","level":2,"title":"Hooks and Notifications","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#hook-output-patterns","level":3,"title":"Hook Output Patterns","text":"

      Choose the right output pattern for your Claude Code hooks: VERBATIM relay for user-facing reminders, hard gates for invariants, agent directives for nudges, and five more patterns across the spectrum.

      Uses: ctx plugin hooks, settings.local.json

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#customizing-hook-messages","level":3,"title":"Customizing Hook Messages","text":"

      Customize what hooks say without changing what they do. Override the QA gate for Python (pytest instead of make lint), silence noisy ceremony nudges, or tailor post-commit instructions for your stack.

      Uses: ctx hook message list, ctx hook message show, ctx hook message edit, ctx hook message reset

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#hook-sequence-diagrams","level":3,"title":"Hook Sequence Diagrams","text":"

      Mermaid sequence diagrams for every system hook: entry conditions, state reads, output, throttling, and exit points. Includes throttling summary table and state file reference.

      Uses: All ctx system hooks

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#auditing-system-hooks","level":3,"title":"Auditing System Hooks","text":"

      The 12 system hooks that run invisibly during every session: what each one does, why it exists, and how to verify they're actually firing. Covers webhook-based audit trails, log inspection, and detecting silent hook failures.

      Uses: ctx system, ctx hook notify, .context/logs/, .ctxrc notify.events

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"

      Get push notifications when loops complete, hooks fire, or agents hit milestones. Webhook URL is encrypted: never stored in plaintext. Works with IFTTT, Slack, Discord, ntfy.sh, or any HTTP endpoint.

      Uses: ctx hook notify setup, ctx hook notify test, ctx hook notify --event, .ctxrc notify.events

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"

      Switch between dev and base runtime configurations without editing .ctxrc by hand. Verbose logging and webhooks for debugging, clean defaults for normal sessions.

      Uses: ctx config switch, ctx config status, /ctx-config

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#maintenance","level":2,"title":"Maintenance","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#detecting-and-fixing-drift","level":3,"title":"Detecting and Fixing Drift","text":"

      Keep context files accurate by detecting structural drift (stale paths, missing files, stale file ages) and task staleness.

      Uses: ctx drift, ctx sync, ctx compact, ctx status, /ctx-drift, /ctx-status, /ctx-prompt-audit

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#state-directory-maintenance","level":3,"title":"State Directory Maintenance","text":"

      Clean up session tombstones from .context/state/. Prune old per-session files, identify stale global markers, and keep the state directory lean.

      Uses: ctx prune

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#troubleshooting","level":3,"title":"Troubleshooting","text":"

      Diagnose hook failures, noisy nudges, stale context, and configuration issues. Start with ctx doctor for a structural health check, then use /ctx-doctor for agent-driven analysis of event patterns.

      Uses: ctx doctor, ctx hook event, /ctx-doctor

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#claude-code-permission-hygiene","level":3,"title":"Claude Code Permission Hygiene","text":"

      Keep .claude/settings.local.json clean: recommended safe defaults, what to never pre-approve, and a maintenance workflow for cleaning up session debris.

      Uses: ctx init, /ctx-drift, /ctx-permission-sanitize, ctx permission snapshot, ctx permission restore

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#permission-snapshots","level":3,"title":"Permission Snapshots","text":"

      Capture a known-good permission baseline as a golden image, then restore at session start to automatically drop session-accumulated permissions.

      Uses: ctx permission snapshot, ctx permission restore, /ctx-permission-sanitize

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#turning-activity-into-content","level":3,"title":"Turning Activity into Content","text":"

      Generate blog posts from project activity, write changelog posts from commit ranges, and publish a browsable journal site from your session history.

      The output is generic Markdown, but the skills are tuned for the ctx-style blog artifacts you see on this website.

      Uses: ctx journal site, ctx journal obsidian, ctx serve, ctx journal import, /ctx-blog, /ctx-blog-changelog, /ctx-journal-enrich

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#importing-claude-code-plans","level":3,"title":"Importing Claude Code Plans","text":"

      Import Claude Code plan files (~/.claude/plans/*.md) into specs/ as permanent project specs. Filter by date, select interactively, and optionally create tasks referencing each imported spec.

      Uses: /ctx-plan-import, /ctx-task-add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#design-before-coding","level":3,"title":"Design Before Coding","text":"

      Front-load design with a four-skill chain: brainstorm the approach, spec the design, task the work, implement step-by-step. Each step produces an artifact that feeds the next.

      Uses: /ctx-brainstorm, /ctx-spec, /ctx-task-add, /ctx-implement, /ctx-decision-add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#scrutinizing-a-plan","level":3,"title":"Scrutinizing a Plan","text":"

      Once a plan exists, run an adversarial interview to surface what's weak, missing, or unexamined before you commit. Walks the plan depth-first: assumptions, failure modes, alternatives, sequencing, reversibility. The complement to brainstorm: brainstorm produces plans, this attacks them.

      Uses: /ctx-plan, /ctx-spec, /ctx-decision-add, /ctx-learning-add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#agents-and-automation","level":2,"title":"Agents and Automation","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#building-project-skills","level":3,"title":"Building Project Skills","text":"

      Encode repeating workflows into reusable skills the agent loads automatically. Covers the full cycle: identify a pattern, create the skill, test with realistic prompts, and iterate until it triggers correctly.

      Uses: /ctx-skill-create, ctx init

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#running-an-unattended-ai-agent","level":3,"title":"Running an Unattended AI Agent","text":"

      Set up a loop where an AI agent works through tasks overnight without you at the keyboard, using ctx for persistent memory between iterations.

      This recipe shows how ctx supports long-running agent loops without losing context or intent.

      Uses: ctx init, ctx loop, ctx watch, ctx load, /ctx-loop, /ctx-implement

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#when-to-use-a-team-of-agents","level":3,"title":"When to Use a Team of Agents","text":"

      Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.

      This recipe covers the file overlap test, when teams make things worse, and what ctx provides at each level.

      Uses: /ctx-worktree, /ctx-next, ctx status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#parallel-agent-development-with-git-worktrees","level":3,"title":"Parallel Agent Development with Git Worktrees","text":"

      Split a large backlog across 3-4 agents using git worktrees, each on its own branch and working directory. Group tasks by file overlap, work in parallel, merge back.

      Uses: /ctx-worktree, /ctx-next, git worktree, git merge

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#architecture-deep-dive","level":3,"title":"Architecture Deep Dive","text":"

      Three-pass pipeline for understanding a codebase: map what exists, enrich with code intelligence, then hunt for where it will silently fail. Produces architecture docs, quantified dependency data, and ranked failure hypotheses.

      Uses: /ctx-architecture, /ctx-architecture-enrich, /ctx-architecture-failure-analysis

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#writing-steering-files","level":3,"title":"Writing Steering Files","text":"

      Tell your AI assistant how to behave with rule-based prompt injection that fires automatically when prompts match a description. Walks through scaffolding a steering file, previewing matches, and syncing to each AI tool's native format.

      Uses: ctx steering add, ctx steering preview, ctx steering list, ctx steering sync

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#authoring-lifecycle-triggers","level":3,"title":"Authoring Lifecycle Triggers","text":"

      Run executable shell scripts at session-start, pre-tool-use, file-save, and other lifecycle events. Script-based automation (complementary to steering's rule-based prompts), with a security-first workflow: scaffold disabled, test with mock input, enable only after review.

      Uses: ctx trigger add, ctx trigger test, ctx trigger enable, ctx trigger disable, ctx trigger list

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#hub","level":2,"title":"Hub","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#hub-overview","level":3,"title":"Hub Overview","text":"

      Mental model and three user stories for the ctx Hub. What flows, what doesn't, and when not to use it. Read this before any of the other Hub recipes.

      Uses: ctx hub, ctx connection, ctx add --share

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-getting-started","level":3,"title":"ctx Hub: Getting Started","text":"

      Stand up a single-node hub on localhost, register two projects, publish a decision from one, and watch it appear in the other. End-to-end in under five minutes.

      Uses: ctx hub start, ctx connection register, ctx connection subscribe, ctx connection sync, ctx connection listen, ctx add --share, ctx agent --include-hub

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"

      Story 1 day-to-day workflow: one developer, many projects, one hub on localhost. Records a learning in project A, watches it show up automatically in project B. Walks through a realistic day of using the hub as passive infrastructure (no manual sync, no git push, no ceremony).

      Uses: ctx add --share, ctx connection subscribe, ctx agent --include-hub

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#team-knowledge-bus","level":3,"title":"Team Knowledge Bus","text":"

      Story 2 day-to-day workflow: a small trusted team sharing decisions, learnings, and conventions via a hub on an internal server. Covers the team publishing culture, what belongs on the hub vs. local, token management, and the social rules that make a shared knowledge stream stay signal-rich.

      Uses: ctx add --share, ctx connection status, ctx connection subscribe, ctx hub status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-multi-machine","level":3,"title":"ctx Hub: Multi-Machine","text":"

      Run the hub on a LAN host as a daemon and connect from project directories on other workstations. Firewall guidance, TLS via a reverse proxy, and safe daemon restart semantics.

      Uses: ctx hub start --daemon, ctx hub stop, ctx connection register, ctx connection status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-ha-cluster","level":3,"title":"ctx Hub: HA Cluster","text":"

      Raft-based leader election across three or more nodes for redundancy. Covers bootstrap, runtime peer management, graceful stepdown, and the Raft-lite durability caveat.

      Uses: ctx hub start --peers, ctx hub status, ctx hub peer add/remove, ctx hub stepdown

      ","path":["Recipes"],"tags":[]},{"location":"recipes/activating-context/","level":1,"title":"Activating a Context Directory","text":"","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#the-problem","level":2,"title":"The Problem","text":"

      You ran a ctx command and got:

      Error: no context directory specified for this project\n

      This means ctx doesn't know which .context/ directory to operate on. It will not guess, and it will not walk up from your current working directory looking for one; that behavior was removed deliberately, because silent inference was the source of several bugs (stray agent-created directories, cross-project bleed-through, webhook-route misrouting, sub-agent fragmentation). Every ctx command requires you to declare the target directory explicitly.

      This page shows you the three ways to do that and when to use each.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#tldr","level":2,"title":"TL;DR","text":"

      If the project has already been initialized and you just need to bind it for your shell:

      eval \"$(ctx activate)\"\n

      That's 95% of the time. Add it to .zshrc / .bashrc per project with direnv, or run it once per terminal.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#when-you-see-the-error","level":2,"title":"When You See the Error","text":"

      The exact error message depends on how many .context/ directories are visible from the current directory:

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#zero-candidates","level":3,"title":"Zero Candidates","text":"
      Error: no context directory specified for this project\n

      Either you haven't initialized this project yet (run ctx init) or you're in a directory that doesn't belong to a ctx-tracked project. If you know the project lives elsewhere, use one of the declaration methods below with its absolute path.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#one-candidate","level":3,"title":"One Candidate","text":"
      Error: no context directory specified; a likely candidate is at\n    /Users/you/repos/myproject/.context\n

      ctx found a single .context/ on the way up from here but won't bind to it automatically. Run eval \"$(ctx activate)\" and ctx will emit the export for the candidate. Or set CTX_DIR by hand.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#multiple-candidates","level":3,"title":"Multiple Candidates","text":"
      Error: no context directory specified; multiple candidates visible:\n  /Users/you/repos/myproject/.context\n  /Users/you/repos/myproject/packages/web/.context\n

      You're inside nested projects. Pick the one you mean:

      ctx activate /Users/you/repos/myproject/.context\n# …copy and paste the `export` line it prints, or wrap in eval:\neval \"$(ctx activate /Users/you/repos/myproject/.context)\"\n
      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#three-ways-to-declare","level":2,"title":"Three Ways to Declare","text":"","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#1-ctx-activate-recommended-for-shells","level":3,"title":"1. ctx activate (Recommended for Shells)","text":"

      ctx activate emits a shell-native export CTX_DIR=... line to stdout. Wrap it in eval and the binding takes effect for the current shell:

      # Walk up from current dir and bind the single visible candidate:\neval \"$(ctx activate)\"\n\n# Bind a specific path explicitly:\neval \"$(ctx activate /abs/path/to/.context)\"\n\n# Clear the binding:\neval \"$(ctx deactivate)\"\n

      ctx activate validates paths strictly: the target must exist, be a directory, and contain at least one canonical context file (CONSTITUTION.md or TASKS.md). It refuses to emit for multiple upward candidates; pick one explicitly in that case.

      Under the hood, the emitted line is just:

      export CTX_DIR='/abs/path/to/.context'\n

      So you can copy it into your .zshrc / .bashrc if you want the binding permanent for a given shell setup. Better: use direnv with a per-project .envrc.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#2-ctx_dir-env-var","level":3,"title":"2. CTX_DIR Env Var","text":"

      If you already know the path, export it directly:

      export CTX_DIR=/abs/path/to/.context\nctx status\n

      CTX_DIR is the same variable ctx activate writes; activate is just a convenience that figures out the path for you.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#3-inline-one-shot","level":3,"title":"3. Inline One-Shot","text":"

      For one-shot commands (CI jobs, scripts, debugging a specific project without changing your shell state), prefix the binding inline:

      CTX_DIR=/abs/path/to/.context ctx status\n

      This binds CTX_DIR for that invocation only.

      CTX_DIR must be an absolute path with .context as its basename. Relative paths and other names are rejected on first use; the basename guard catches the common footgun (export CTX_DIR=$(pwd)) before stray writes can leak to the project root.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#for-ci-and-scripts","level":2,"title":"For CI and Scripts","text":"

      Do not rely on shell activation in automated flows. Set CTX_DIR explicitly at the top of the script:

      #!/usr/bin/env bash\nset -euo pipefail\n\nexport CTX_DIR=\"$GITHUB_WORKSPACE/.context\"\nctx status\nctx drift\n
      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#for-claude-code-users","level":2,"title":"For Claude Code Users","text":"

      The ctx plugin's hooks are generated with CTX_DIR=\"$CLAUDE_PROJECT_DIR/.context\" prefixed to each command, so hook-driven ctx invocations resolve correctly without any per-session setup. You only need to activate manually when running ctx yourself in a terminal.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#one-project-one-context","level":2,"title":"One Project, One .context/","text":"

      The context directory is not a free-floating bag of files. It is pinned to a project by contract: filepath.Dir(ContextDir()) is the project root. That parent directory is what ctx sync, ctx drift, and the memory-drift hook scan for code, secret files, and MEMORY.md respectively.

      The practical consequences:

      • Don't share one .context/ across multiple projects. It holds per-project journals, per-session state, and per-project secrets. Pointing two codebases at the same directory corrupts all three.
      • If you want to share knowledge (CONSTITUTION, CONVENTIONS, ARCHITECTURE) across projects, use ctx hub. It cherry-picks entries at the right granularity and keeps the per-project bits where they belong.
      • The CTX_DIR you activate is implicitly a project-root declaration. Setting CTX_DIR=/weird/place/.context means you're telling ctx the project root is /weird/place/. That's your call to make; ctx does not police it.
      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#recommended-layout","level":3,"title":"Recommended Layout","text":"
      ~/WORKSPACE/my-to-do-list\n  ├── .git\n  ├── .context          ← owned by this project; do not share\n  ├── ideas\n  │   └── ...\n  ├── Makefile\n  ├── Makefile.ctx\n  └── specs\n      └── ...\n

      .context/ sits at the project root, next to .git. ctx activate binds to it; every ctx subsystem reads the project from its parent.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#why-not-walk-up-automatically","level":2,"title":"Why Not Walk Up Automatically?","text":"

      Nested projects, submodules, rogue agent-created .context/ directories, and sub-agent sessions all produced silent misrouting under the old walk-up model. See the explicit-context-dir spec and the analysis doc for the full reasoning.

      The short version: ctx decided to stop guessing and require the caller to declare. Every other decision flows from there.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/architecture-deep-dive/","level":1,"title":"Architecture Deep Dive","text":"","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-problem","level":2,"title":"The Problem","text":"

      Understanding a codebase at the surface level is easy. Understanding where it will break under real-world conditions takes three passes: mapping what exists, quantifying how it connects, and hunting for where it silently fails. Most teams stop at the first pass.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tldr","level":2,"title":"TL;DR","text":"
      # Pass 1: Map the system\n/ctx-architecture\n\n# Pass 2: Enrich with code intelligence\n/ctx-architecture-enrich\n\n# Pass 3: Hunt for failure modes\n/ctx-architecture-failure-analysis\n

      Each pass builds on the previous one. Run them in order. The output accumulates in .context/; each pass reads the prior artifacts and extends them.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-architecture Skill Map modules, dependencies, data flow, patterns /ctx-architecture-enrich Skill Verify blast radius and flows with code intel /ctx-architecture-failure-analysis Skill Generate falsifiable incident hypotheses ctx drift CLI Detect stale paths and broken references ctx status CLI Quick structural overview","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-1-map-what-exists","level":3,"title":"Pass 1: Map What Exists","text":"
      /ctx-architecture\n

      Produces:

      • ARCHITECTURE.md: succinct project map (< 4000 tokens), loaded at every session start
      • DETAILED_DESIGN*.md: deep per-module reference with exported API, data flow, danger zones, extension points
      • CHEAT-SHEETS.md: lifecycle flow diagrams
      • map-tracking.json: coverage state with confidence scores

      This pass forces deep code reading. No shortcuts, no code intelligence tools; the agent reads every module it analyzes. That forced reading is what makes the subsequent passes useful.

      When to run: First time on a codebase, or after significant structural changes (new packages, moved files, changed dependencies).

      Principal mode: Add principal to get strategic analysis (ARCHITECTURE-PRINCIPAL.md, DANGER-ZONES.md from P4):

      /ctx-architecture principal\n
      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-2-enrich-with-code-intelligence","level":3,"title":"Pass 2: Enrich with Code Intelligence","text":"
      /ctx-architecture-enrich\n

      Takes the Pass 1 artifacts as baseline and layers on verified, graph-backed data from GitNexus:

      • Blast radius numbers for key functions
      • Execution flow traces through hot paths
      • Domain clustering validation
      • Registration site discovery

      This pass does not replace reading; it quantifies what reading found. If Pass 1 says \"module X depends on module Y,\" Pass 2 says \"module X has 47 callers in module Y, and changing function Z would affect 12 downstream consumers.\"

      When to run: After Pass 1, when you need quantified confidence for refactoring decisions or risk assessment.

      Requires: GitNexus MCP server connected.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-3-hunt-for-failure-modes","level":3,"title":"Pass 3: Hunt for Failure Modes","text":"
      /ctx-architecture-failure-analysis\n

      The adversarial pass. Reads all prior artifacts, then systematically hunts for correctness bugs across 9 failure categories:

      1. Concurrency (races, deadlocks, goroutine leaks)
      2. Ordering assumptions (init, registration, shutdown)
      3. Cache staleness (TTL-less, read-your-writes, cross-process)
      4. Fan-out amplification (N+1, retry storms)
      5. Ownership and lifecycle (orphans, double-close)
      6. Error handling (silent swallowing, partial failure)
      7. Scaling cliffs (quadratic, unbounded, global locks)
      8. Idempotency failures (duplicate processing, retry mutations)
      9. State machine drift (illegal states, unvalidated transitions)

      Every finding must meet an evidence standard: code path, trigger, failure path, silence reason, and code evidence. A mandatory challenge phase attempts to disprove each finding before it is accepted. Findings carry a confidence level (High/Medium/Low) and explicit risk score.

      Produces DANGER-ZONES.md, a ranked inventory of findings split into Critical and Elevated tiers.

      When to run: Before releases, after major refactors, when investigating incident categories, or when onboarding.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#what-you-get","level":2,"title":"What You Get","text":"

      After all three passes, .context/ contains:

      File From Purpose ARCHITECTURE.md Pass 1 System map (session-start context) DETAILED_DESIGN*.md Pass 1 Module-level deep reference CHEAT-SHEETS.md Pass 1 Lifecycle flow diagrams map-tracking.json Pass 1 Coverage and confidence data CONVERGENCE-REPORT.md Pass 1 What's covered, what's not DANGER-ZONES.md Pass 3 Ranked failure hypotheses

      Pass 2 enriches Pass 1 artifacts in-place rather than creating new files.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tips","level":2,"title":"Tips","text":"
      • Run Pass 1 with focus areas if the codebase is large. The skill asks what to go deep on, so name the modules you're about to change.
      • You don't need all three passes every time. Pass 1 is the foundation. Pass 2 and 3 are for when you need quantified confidence or adversarial rigor.
      • Re-run Pass 1 incrementally. It tracks coverage in map-tracking.json and only re-analyzes stale modules.
      • Pass 3 is most valuable before releases. The ranked DANGER-ZONES.md is a pre-release checklist.
      • The trilogy maps to a question progression: How does it work? How well does it connect? Where will it break?
      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#see-also","level":2,"title":"See Also","text":"

      See also: Detecting and Fixing Context Drift to keep architecture artifacts fresh between deep-dive sessions.

      See also: Detecting and Fixing Context Drift for structural checks that complement architecture analysis.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/autonomous-loops/","level":1,"title":"Running an Unattended AI Agent","text":"","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-problem","level":2,"title":"The Problem","text":"

      You have a project with a clear list of tasks, and you want an AI agent to work through them autonomously: overnight, unattended, without you sitting at the keyboard.

      Each iteration needs to remember what the previous one did, mark tasks as completed, and know when to stop.

      Without persistent memory, every iteration starts fresh and the loop collapses. With ctx, each iteration can pick up where the last one left off, but only if the agent persists its context as part of the work.

      Unattended operation works because the agent treats context persistence as a first-class deliverable, not an afterthought.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tldr","level":2,"title":"TL;DR","text":"
      ctx init                                    # 1. init context\neval \"$(ctx activate)\"                      # 2. bind CTX_DIR for this shell\n# Edit TASKS.md with phased work items\nctx loop --tool claude --max-iterations 10  # 3. generate loop.sh\n./loop.sh 2>&1 | tee /tmp/loop.log &        # 4. run the loop\nctx watch --log /tmp/loop.log               # 5. process context updates\n# Next morning:\nctx status && ctx load                      # 6. review the results\n

      Activate, or Set CTX_DIR Inline for Unattended Runs

      eval \"$(ctx activate)\" is fine for an interactive terminal. For an overnight unattended loop, put the binding at the top of loop.sh instead (export CTX_DIR=/abs/path/.context) so the loop doesn't depend on a live shell. If you skip both, ctx loop, ctx watch, ctx status, and ctx load fail with Error: no context directory specified. See Activating a Context Directory.

      Read on for permissions, isolation, and completion signals.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx init Command Initialize project context and prompt templates ctx loop Command Generate the loop shell script ctx watch Command Monitor AI output and persist context updates ctx load Command Display assembled context (for debugging) /ctx-loop Skill Generate loop script from inside Claude Code /ctx-implement Skill Execute a plan step-by-step with verification","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-1-initialize-for-unattended-operation","level":3,"title":"Step 1: Initialize for Unattended Operation","text":"

      Start by creating a .context/ directory configured so the agent can work without human input.

      ctx init\n

      This creates .context/ with the template files (including a loop prompt at .context/loop.md), and seeds Claude Code permissions in .claude/settings.local.json. Install the ctx plugin for hooks and skills.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-2-populate-tasksmd-with-phased-work","level":3,"title":"Step 2: Populate TASKS.md with Phased Work","text":"

      Open .context/TASKS.md and organize your work into phases. The agent works through these systematically, top to bottom, using priority tags to break ties.

      # Tasks\n\n## Phase 1: Foundation\n\n- [ ] Set up project structure and build system `#priority:high`\n- [ ] Configure testing framework `#priority:high`\n- [ ] Create CI pipeline `#priority:medium`\n\n## Phase 2: Core Features\n\n- [ ] Implement user registration `#priority:high`\n- [ ] Add email verification `#priority:high`\n- [ ] Create password reset flow `#priority:medium`\n\n## Phase 3: Hardening\n\n- [ ] Add rate limiting to API endpoints `#priority:medium`\n- [ ] Improve error messages `#priority:low`\n- [ ] Write integration tests `#priority:medium`\n

      Phased organization matters because it gives the agent natural boundaries. Phase 1 tasks should be completable without Phase 2 code existing yet.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-3-configure-the-loop-prompt","level":3,"title":"Step 3: Configure the Loop Prompt","text":"

      The loop prompt at .context/loop.md instructs the agent to operate autonomously:

      1. Read .context/CONSTITUTION.md first (hard rules, never violated)
      2. Load context from .context/ files
      3. Pick one task per iteration
      4. Complete the task and update context files
      5. Commit changes (including .context/)
      6. Signal status with a completion signal

      You can customize .context/loop.md for your project. The critical parts are the one-task-per-iteration discipline, proactive context persistence, and completion signals at the end:

      ## Signal Status\n\nEnd your response with exactly ONE of:\n\n* `SYSTEM_CONVERGED`: All tasks in `TASKS.md` are complete (*this is the\n  signal the loop script detects by default*)\n* `SYSTEM_BLOCKED`: Cannot proceed, need human input (explain why)\n* (*no signal*): More work remains, continue to the next iteration\n\nNote: the loop script only checks for `SYSTEM_CONVERGED` by default.\n`SYSTEM_BLOCKED` is a convention for the human reviewing the log.\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-4-configure-permissions","level":3,"title":"Step 4: Configure Permissions","text":"

      An unattended agent needs permission to use tools without prompting. By default, Claude Code asks for confirmation on file writes, bash commands, and other operations, which stops the loop and waits for a human who is not there.

      There are two approaches.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#option-a-explicit-allowlist-recommended","level":4,"title":"Option A: Explicit Allowlist (Recommended)","text":"

      Grant only the permissions the agent needs. In .claude/settings.local.json:

      {\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(make:*)\",\n      \"Bash(go:*)\",\n      \"Bash(git:*)\",\n      \"Bash(ctx:*)\",\n      \"Read\",\n      \"Write\",\n      \"Edit\"\n    ]\n  }\n}\n

      Adjust the Bash patterns for your project's toolchain. The agent can run make, go, git, and ctx commands but cannot run arbitrary shell commands.

      This is recommended even in sandboxed environments because it limits blast radius.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#option-b-skip-all-permission-checks","level":4,"title":"Option B: Skip All Permission Checks","text":"

      Claude Code supports a --dangerously-skip-permissions flag that disables all permission prompts:

      claude --dangerously-skip-permissions -p \"$(cat .context/loop.md)\"\n

      This Flag Means What It Says

      With --dangerously-skip-permissions, the agent can execute any shell command, write to any file, and make network requests without confirmation.

      Only use this on a sandboxed machine: ideally a virtual machine with no access to host credentials, no SSH keys, and no access to production systems.

      If you would not give an untrusted intern sudo on this machine, do not use this flag.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#enforce-isolation-at-the-os-level","level":4,"title":"Enforce Isolation at the OS Level","text":"

      The only controls an agent cannot override are the ones enforced by the operating system, the container runtime, or the hypervisor.

      Do Not Skip This Section

      This is not optional hardening:

      An unattended agent with unrestricted OS access is an unattended shell with unrestricted OS access.

      The allowlist above is a strong first layer, but do not rely on a single runtime boundary.

      For unattended runs, enforce isolation at the infrastructure level:

      Layer What to enforce User account Run the agent as a dedicated unprivileged user with no sudo access and no membership in privileged groups (docker, wheel, adm). Filesystem Restrict the project directory via POSIX permissions or ACLs. The agent should have no access to other users' files or system directories. Container Run inside a Docker/Podman sandbox. Mount only the project directory. Drop capabilities (--cap-drop=ALL). Disable network if not needed (--network=none). Never mount the Docker socket and do not run privileged containers. Prefer rootless containers. Virtual machine Prefer a dedicated VM with no shared folders, no host passthrough, and no keys to other machines. Network If the agent does not need the internet, disable outbound access entirely. If it does, restrict to specific domains via firewall rules. Resource limits Apply CPU, memory, and disk limits (cgroups/container limits). A runaway loop should not fill disk or consume all RAM. Self-modification Make instruction files read-only. CLAUDE.md, .claude/settings.local.json, and .context/CONSTITUTION.md should not be writable by the agent user. If using project-local hooks, protect those too.

      A minimal Docker setup for overnight runs:

      docker run --rm \\\n  --network=none \\\n  --cap-drop=ALL \\\n  --memory=4g \\\n  --cpus=2 \\\n  -v /path/to/project:/workspace \\\n  -w /workspace \\\n  your-dev-image \\\n  ./loop.sh 2>&1 | tee /tmp/loop.log\n

      Defense in Depth

      Use multiple layers together: OS-level isolation (the boundary the agent cannot cross), a permission allowlist (what Claude Code will do within that boundary), and CONSTITUTION.md (a soft nudge for the common case).

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-5-generate-the-loop-script","level":3,"title":"Step 5: Generate the Loop Script","text":"

      Use ctx loop to generate a loop.sh tailored to your AI tool:

      # Generate for Claude Code with a 10-iteration cap\nctx loop --tool claude --max-iterations 10\n\n# Generate for Aider\nctx loop --tool aider --max-iterations 10\n\n# Custom prompt file and output filename\nctx loop --tool claude --prompt my-prompt.md --output my-loop.sh\n

      The generated script reads .context/loop.md, runs the tool, checks for completion signals, and loops until done or the cap is reached.

      You can also use the /ctx-loop skill from inside Claude Code.

      A Shell Loop Is the Best Practice

      The shell loop approach spawns a fresh AI process each iteration, so the only state that carries between iterations is what lives in .context/ and git.

      Claude Code's built-in /loop runs iterations within the same session, which can allow context window state to leak between iterations. This can be convenient for short runs, but it is less reliable for unattended loops.

      See Shell Loop vs Built-in Loop for details.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-6-run-with-watch-mode","level":3,"title":"Step 6: Run with Watch Mode","text":"

      Open two terminals. In the first, run the loop. In the second, run ctx watch to process context updates from the AI output.

      # Terminal 1: Run the loop\n./loop.sh 2>&1 | tee /tmp/loop.log\n\n# Terminal 2: Watch for context updates\nctx watch --log /tmp/loop.log\n

      The watch command parses XML context-update commands from the AI output and applies them:

      <context-update type=\"complete\">user registration</context-update>\n<context-update type=\"learning\"\n  context=\"Setting up user registration\"\n  lesson=\"Email verification needs SMTP configured\"\n  application=\"Add SMTP setup to deployment checklist\"\n>SMTP Requirement</context-update>\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-7-completion-signals-end-the-loop","level":3,"title":"Step 7: Completion Signals End the Loop","text":"

      The generated script checks for one completion signal per run. By default this is SYSTEM_CONVERGED. You can change it with the --completion flag:

      ctx loop --tool claude --completion BOOTSTRAP_COMPLETE --max-iterations 5\n

      The following signals are conventions used in .context/loop.md:

      Signal Convention How the script handles it SYSTEM_CONVERGED All tasks in TASKS.md are done Detected by default (--completion default value) SYSTEM_BLOCKED Agent cannot proceed Only detected if you set --completion to this BOOTSTRAP_COMPLETE Initial scaffolding done Only detected if you set --completion to this

      The script uses grep -q on the agent's output, so any string works as a signal. If you need to detect multiple signals in one run, edit the generated loop.sh to add additional grep checks.

      When you return in the morning, check the log and the context files:

      tail -100 /tmp/loop.log\nctx status\nctx load\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-8-use-ctx-implement-for-plan-execution","level":3,"title":"Step 8: Use /ctx-implement for Plan Execution","text":"

      Within each iteration, the agent can use /ctx-implement to execute multi-step plans with verification between steps. This is useful for complex tasks that touch multiple files.

      The skill breaks a plan into atomic, verifiable steps:

      Step 1/6: Create user model .................. OK\nStep 2/6: Add database migration ............. OK\nStep 3/6: Implement registration handler ..... OK\nStep 4/6: Write unit tests ................... OK\nStep 5/6: Run test suite ..................... FAIL\n  -> Fixed: missing test dependency\n  -> Re-verify ............................... OK\nStep 6/6: Update TASKS.md .................... OK\n

      Each step is verified (build, test, syntax check) before moving to the next.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      A typical overnight run:

      ctx init\n# Edit TASKS.md and .context/loop.md\n\nctx loop --tool claude --max-iterations 20\n\n./loop.sh 2>&1 | tee /tmp/loop.log &\nctx watch --log /tmp/loop.log\n\n# Next morning:\nctx status\nctx load\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#why-autonomous-loops-work-proactive-context-persistence","level":2,"title":"Why Autonomous Loops Work: Proactive Context Persistence","text":"

      The autonomous loop pattern works because the agent persists context as part of the job.

      Without proactive persistence, the loop degrades into disconnected iterations that repeat work, contradict decisions, and lose track of progress. The agent cannot rely on a human to prompt it. It must treat context updates as part of every task, not as a separate step.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-agent-playbook-self-check-drives-autonomy","level":3,"title":"The Agent Playbook Self-Check Drives Autonomy","text":"

      The Agent Playbook defines a self-check prompt the agent applies continuously:

      \"If this session ended right now, would the next session know what happened?\"\n

      In interactive sessions, a human might remind the agent to save context. When the agent runs unattended, nobody is there to remind it.

      The self-check becomes the trigger: after meaningful work, the agent evaluates whether the context files reflect reality and updates them immediately if they do not.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#what-the-agent-does-proactively-between-iterations","level":3,"title":"What the Agent Does Proactively between Iterations","text":"

      At milestones within an iteration, the agent persists without waiting for instructions:

      Milestone What the agent does proactively Completes a task Marks it [x] in TASKS.md Discovers a gotcha Adds it to LEARNINGS.md Makes a design choice Records it in DECISIONS.md with rationale Identifies follow-up work Creates new tasks in TASKS.md with #added timestamp Hits an unexpected failure Documents the root cause before moving on","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#example-what-proactive-persistence-looks-like","level":3,"title":"Example: What Proactive Persistence Looks Like","text":"

      Here is what the agent does during a single iteration beyond writing code:

      Iteration 4:\n  1. Read TASKS.md -> pick \"Add email verification\" (#priority:high)\n  2. Add #started:2026-01-25-030012 to the task\n  3. Implement the feature (code, tests, docs if needed)\n  4. Tests pass -> mark task [x]\n  5. Add learning: \"SMTP config must be set before verification handler registers. Order matters in init().\"\n  6. Add decision: \"Use token-based verification links (not codes) because links work better in automated tests.\"\n  7. Create follow-up task: \"Add rate limiting to verification endpoint\" #added:...\n  8. Commit all changes including `.context/`\n  9. No signal emitted -> loop continues to iteration 5\n

      Steps 2, 4, 5, 6, and 7 are proactive context persistence:

      The agent was not asked to do any of them.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#context-persistence-at-milestones","level":3,"title":"Context Persistence at Milestones","text":"

      For long autonomous runs, the agent persists context at natural boundaries, often at phase transitions or after completing a cluster of related tasks. It updates TASKS.md, DECISIONS.md, and LEARNINGS.md as it goes.

      If the loop crashes at 4 AM, the context files tell you exactly where to resume. You can also use ctx journal source to review the session transcripts.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-persistence-contract","level":3,"title":"The Persistence Contract","text":"

      The autonomous loop has an implicit contract:

      1. Every iteration reads context: TASKS.md, DECISIONS.md, LEARNINGS.md
      2. Every iteration writes context: task updates, new learnings, decisions
      3. Every commit includes .context/ so the next iteration sees changes
      4. Context stays current: if the loop stopped right now, nothing important is lost

      Break any part of this contract and the loop degrades.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tips","level":2,"title":"Tips","text":"

      Markdown Is Not Enforcement

      Your real guardrails are permissions and isolation, not Markdown. CONSTITUTION.md can nudge the agent, but it is probabilistic.

      The permission allowlist and OS isolation are deterministic:

      For unattended runs, trust the sandbox and the allowlist, not the prose.

      • Start with a small iteration cap. Use --max-iterations 5 on your first run.
      • Keep tasks atomic. Each task should be completable in a single iteration.
      • Check signal discipline. If the loop runs forever, the agent is not emitting SYSTEM_CONVERGED or SYSTEM_BLOCKED. Make the signal requirement explicit in .context/loop.md.
      • Commit after context updates. Finish code, update .context/, commit including .context/, then signal.
      • Set up webhook notifications to get notified when the loop completes, hits max iterations, or when hooks fire nudges. The generated loop script includes ctx hook notify calls automatically.
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#next-up","level":2,"title":"Next Up","text":"

      When to Use a Team of Agents →: Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#see-also","level":2,"title":"See Also","text":"
      • Autonomous Loops: loop pattern, prompt templates, troubleshooting
      • CLI Reference: ctx loop: flags and options
      • CLI Reference: ctx watch: watch mode details
      • CLI Reference: ctx init: init flags
      • The Complete Session: interactive workflow
      • Tracking Work Across Sessions: structuring TASKS.md
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/building-skills/","level":1,"title":"Building Project Skills","text":"","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#the-problem","level":2,"title":"The Problem","text":"

      You have workflows your agent needs to repeat across sessions: a deploy checklist, a review protocol, a release process. Each time, you re-explain the steps. The agent gets it mostly right but forgets edge cases you corrected last time.

      Skills solve this by encoding domain knowledge into a reusable document the agent loads automatically when triggered. A skill is not code - it is a structured prompt that captures what took you sessions to learn.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-skill-create\n

      The skill-creator walks you through: identify a repeating workflow, draft a skill, test with realistic prompts, iterate until it triggers correctly and produces good output.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-skill-create Skill Interactive skill creation and improvement workflow ctx init Command Deploys template skills to .claude/skills/ on first setup","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-1-identify-a-repeating-pattern","level":3,"title":"Step 1: Identify a Repeating Pattern","text":"

      Good skill candidates:

      • Checklists you repeat: deploy steps, release prep, code review
      • Decisions the agent gets wrong: if you keep correcting the same behavior, encode the correction
      • Multi-step workflows: anything with a sequence of commands and conditional branches
      • Domain knowledge: project-specific terminology, architecture constraints, or conventions the agent cannot infer from code alone

      Not good candidates: one-off instructions, things the platform already handles (file editing, git operations), or tasks too narrow to reuse.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-2-create-the-skill","level":3,"title":"Step 2: Create the Skill","text":"

      Invoke the skill-creator:

      You: \"I want a skill for our deploy process\"\n\nAgent: [Asks about the workflow: what steps, what tools,\n        what edge cases, what the output should look like]\n

      Or capture a workflow you just did:

      You: \"Turn what we just did into a skill\"\n\nAgent: [Extracts the steps from conversation history,\n        confirms understanding, drafts the skill]\n

      The skill-creator produces a SKILL.md file in .claude/skills/your-skill/.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-3-test-with-realistic-prompts","level":3,"title":"Step 3: Test with Realistic Prompts","text":"

      The skill-creator proposes 2-3 test prompts - the kind of thing a real user would say. It runs each one and shows the result alongside a baseline (same prompt without the skill) so you can compare.

      Agent: \"Here are test prompts I'd try:\n        1. 'Deploy to staging'\n        2. 'Ship the hotfix'\n        3. 'Run the release checklist'\n        Want to adjust these?\"\n
      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-4-iterate-on-the-description","level":3,"title":"Step 4: Iterate on the Description","text":"

      The description field in frontmatter determines when a skill triggers. Claude tends to undertrigger - descriptions need to be specific and slightly \"pushy\":

      # Weak - too vague, will undertrigger\ndescription: \"Use for deployments\"\n\n# Strong - covers situations and synonyms\ndescription: >-\n  Use when deploying to staging or production, running the release\n  checklist, or when the user says 'ship it', 'deploy this', or\n  'push to prod'. Also use after merging to main when a deploy\n  is expected.\n

      The skill-creator helps you tune this iteratively.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-5-deploy-as-template-optional","level":3,"title":"Step 5: Deploy as Template (Optional)","text":"

      If the skill should be available to all projects (not just this one), place it in internal/assets/claude/skills/ so ctx init deploys it to new projects automatically.

      Most project-specific skills stay in .claude/skills/ and travel with the repo.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#skill-anatomy","level":2,"title":"Skill Anatomy","text":"
      my-skill/\n  SKILL.md         # Required: frontmatter + instructions (<500 lines)\n  scripts/         # Optional: deterministic code the skill can execute\n  references/      # Optional: detail loaded on demand (not always)\n  assets/          # Optional: output templates, not loaded into context\n

      Key sections in SKILL.md:

      Section Purpose Required? Frontmatter Name, description (trigger) Yes When to Use Positive triggers Yes When NOT to Use Prevents false activations Yes Process Steps and commands Yes Examples Good/bad output pairs Recommended Quality Checklist Verify before reporting completion For complex skills","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#tips","level":2,"title":"Tips","text":"
      • Description is everything. A great skill with a vague description never fires. Spend time on trigger coverage - synonyms, concrete situations, edge cases.
      • Stay under 500 lines. If your skill is growing past this, move detail into references/ files and point to them from SKILL.md.
      • Do not duplicate the platform. If the agent already knows how to do something (edit files, run git commands), do not restate it. Tag paragraphs as Expert/Activation/Redundant and delete Redundant ones.
      • Explain why, not just what. \"Sort by date because users want recent results first\" beats \"ALWAYS sort by date.\" The agent generalizes from reasoning better than from rigid rules.
      • Test negative triggers. Make sure the skill does not fire on unrelated prompts. A skill that activates too broadly becomes noise.
      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#next-up","level":2,"title":"Next Up","text":"

      Parallel Agent Development with Git Worktrees ->: Split work across multiple agents using git worktrees.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#see-also","level":2,"title":"See Also","text":"
      • Skills Reference: full listing of all bundled and project-local skills
      • Guide Your Agent: how commands, skills, and conversational patterns work together
      • Design Before Coding: the four-skill chain for front-loading design work
      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/claude-code-permissions/","level":1,"title":"Claude Code Permission Hygiene","text":"","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code's .claude/settings.local.json controls what the agent can do without asking. Over time, this file accumulates one-off permissions from individual sessions: Exact commands with hardcoded paths, duplicate entries, and stale skill references.

      A noisy \"allowlist\" makes it harder to spot dangerous permissions and increases the surface area for unintended behavior.

      Since settings.local.json is .gitignored, it drifts independently of your codebase. There is no PR review, no CI check: just whatever you clicked \"Allow\" on.

      This recipe shows what a well-maintained permission file looks like and how to keep it clean.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#tldr","level":2,"title":"TL;DR","text":"
      ctx init                            # seeds safe defaults\n/ctx-drift                          # detects missing/stale permissions\n/ctx-permission-sanitize               # audits for dangerous patterns\n

      See Recommended Defaults for the full list.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Command/Skill Role in this workflow ctx init Populates default ctx permissions /ctx-drift Detects missing or stale permission entries /ctx-permission-sanitize Audits for dangerous patterns (security-focused)","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#recommended-defaults","level":2,"title":"Recommended Defaults","text":"

      After running ctx init, your settings.local.json will have the ctx defaults pre-populated. Here is an opinionated safe starting point for a Go project using ctx:

      {\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(/tmp/ctx-*:*)\",\n      \"Bash(CGO_ENABLED=0 go build:*)\",\n      \"Bash(CGO_ENABLED=0 go test:*)\",\n      \"Bash(ctx:*)\",\n      \"Bash(git add:*)\",\n      \"Bash(git branch:*)\",\n      \"Bash(git check-ignore:*)\",\n      \"Bash(git checkout:*)\",\n      \"Bash(git commit:*)\",\n      \"Bash(git diff:*)\",\n      \"Bash(git log:*)\",\n      \"Bash(git remote:*)\",\n      \"Bash(git restore:*)\",\n      \"Bash(git show:*)\",\n      \"Bash(git stash:*)\",\n      \"Bash(git status:*)\",\n      \"Bash(git tag:*)\",\n      \"Bash(go build:*)\",\n      \"Bash(go fmt:*)\",\n      \"Bash(go test:*)\",\n      \"Bash(go vet:*)\",\n      \"Bash(golangci-lint run:*)\",\n      \"Bash(grep:*)\",\n      \"Bash(ls:*)\",\n      \"Bash(make:*)\",\n      \"Skill(ctx-convention-add)\",\n      \"Skill(ctx-decision-add)\",\n      \"Skill(ctx-learning-add)\",\n      \"Skill(ctx-task-add)\",\n      \"Skill(ctx-agent)\",\n      \"Skill(ctx-archive)\",\n      \"Skill(ctx-blog)\",\n      \"Skill(ctx-blog-changelog)\",\n      \"Skill(absorb)\",\n      \"Skill(ctx-commit)\",\n      \"Skill(ctx-drift)\",\n      \"Skill(ctx-implement)\",\n      \"Skill(ctx-journal-enrich)\",\n      \"Skill(ctx-journal-enrich-all)\",\n      \"Skill(ctx-loop)\",\n      \"Skill(ctx-next)\",\n      \"Skill(ctx-pad)\",\n      \"Skill(ctx-prompt-audit)\",\n      \"Skill(ctx-history)\",\n      \"Skill(ctx-reflect)\",\n      \"Skill(ctx-remember)\",\n      \"Skill(ctx-status)\",\n      \"Skill(ctx-worktree)\",\n      \"WebSearch\"\n    ],\n    \"deny\": [\n      \"Bash(sudo *)\",\n      \"Bash(git push *)\",\n      \"Bash(git push)\",\n      \"Bash(rm -rf /*)\",\n      \"Bash(rm -rf ~*)\",\n      \"Bash(curl *)\",\n      \"Bash(wget *)\",\n      \"Bash(chmod 777 *)\",\n      \"Read(**/.env)\",\n      \"Read(**/.env.*)\",\n      \"Read(**/*credentials*)\",\n      \"Read(**/*secret*)\",\n      \"Read(**/*.pem)\",\n      \"Read(**/*.key)\",\n      \"Edit(**/.env)\",\n      \"Edit(**/.env.*)\"\n    ]\n  }\n}\n

      This Is a Starting Point, Not a Mandate

      Your project may need more or fewer entries.

      The goal is intentional permissions: Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#design-principles","level":3,"title":"Design Principles","text":"

      Use wildcards for trusted binaries: If you trust the binary (your own project's CLI, make, go), a single wildcard like Bash(ctx:*) beats twenty subcommand entries. It reduces noise and means new subcommands work without re-prompting.

      Keep git commands granular: Unlike ctx or make, git has both safe commands (git log, git status) and destructive ones (git reset --hard, git clean -f). Listing safe commands individually prevents accidentally pre-approving dangerous ones.

      Pre-approve all ctx- skills: Skills shipped with ctx (Skill(ctx-*)) are safe to pre-approve. They are part of your project and you control their content. This prevents the agent from prompting on every skill invocation.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#default-deny-rules","level":3,"title":"Default Deny Rules","text":"

      ctx init automatically populates permissions.deny with rules that block dangerous operations. Deny rules are evaluated before allow rules: A denied pattern always prompts the user, even if it also matches an allow entry.

      The defaults block:

      Pattern Why Bash(sudo *) Cannot enter password; will hang Bash(git push *) Must be explicit user action Bash(rm -rf /*) etc. Recursive delete of system/home directories Bash(curl *) / wget Arbitrary network requests Bash(chmod 777 *) World-writable permissions Read/Edit(**/.env*) Secrets and credentials Read(**/*.pem, *.key) Private keys

      Read/Edit Deny Rules

      Read() and Edit() deny rules have known upstream enforcement issues (claude-code#6631,#24846).

      They are included as defense-in-depth and intent documentation.

      Blocked by default deny rules: no action needed, ctx init handles these:

      Pattern Risk Bash(git push:*) Must be explicit user action Bash(sudo:*) Privilege escalation Bash(rm -rf:*) Recursive delete with no confirmation Bash(curl:*) / Bash(wget:*) Arbitrary network requests

      Requires manual discipline: Never add these to allow:

      Pattern Risk Bash(git reset:*) Can discard uncommitted work Bash(git clean:*) Deletes untracked files Skill(ctx-permission-sanitize) Edits this file: self-modification vector Skill(release) Runs the release pipeline: high impact","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#hooks-regex-safety-net","level":2,"title":"Hooks: Regex Safety Net","text":"

      Deny rules handle prefix-based blocking natively. Hooks complement them by catching patterns that require regex matching: Things deny rules can't express.

      The ctx plugin ships these blocking hooks:

      Hook What it blocks ctx system block-non-path-ctx Running ctx from wrong path

      Project-local hooks (not part of the plugin) catch regex edge cases:

      Hook What it blocks block-dangerous-commands.sh Mid-command sudo/git push (after &&), copies to bin dirs, absolute-path ctx

      Pre-Approved + Hook-Blocked = Silent Block

      If you pre-approve a command that a hook blocks, the user never sees the confirmation dialog. The agent gets a block response and must handle it, which is confusing.

      It's better not to pre-approve commands that hooks are designed to intercept.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#the-maintenance-workflow","level":2,"title":"The Maintenance Workflow","text":"","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#after-busy-sessions","level":3,"title":"After Busy Sessions","text":"

      Permissions accumulate fastest during debugging and exploration sessions. After a session where you clicked \"Allow\" many times:

      1. Open .claude/settings.local.json in your editor;
      2. Look for entries at the bottom of the allowlist (new entries append there);
      3. Delete anything that looks session-specific:
        • Exact commands with hardcoded paths,
        • Commands with literal string arguments,
        • Entries that duplicate an existing wildcard.

      See the Sanitize Permissions runbook for a step-by-step procedure.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#periodically","level":3,"title":"Periodically","text":"

      Run /ctx-drift to catch permission drift:

      • Missing Bash(ctx:*) wildcard;
      • Missing Skill(ctx-*) entries for installed skills;
      • Stale Skill(ctx-*) entries for removed skills;
      • Granular Bash(ctx <subcommand>:*) entries that should be consolidated.

      Run /ctx-permission-sanitize to catch security issues:

      • Hook bypass patterns
      • Destructive commands
      • Overly broad permissions
      • Injection vectors
      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#when-adding-new-skills","level":3,"title":"When Adding New Skills","text":"

      If you create a custom ctx-* skill, add its Skill() entry to the allowlist manually.

      ctx init only populates the default permissions: It won't pick up custom skills.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#golden-image-snapshots","level":3,"title":"Golden Image Snapshots","text":"

      If manual cleanup is too tedious, use a golden image to automate it:

      Snapshot a curated permission set, then restore at session start to automatically drop session-accumulated permissions. See the Permission Snapshots recipe for the full workflow.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#adapting-for-other-languages","level":2,"title":"Adapting for Other Languages","text":"

      The recommended defaults above are Go-specific. For other stacks, swap the build/test tooling:

      Node.js / TypeScript:

      \"Bash(npm run:*)\",\n\"Bash(npm test:*)\",\n\"Bash(npx:*)\",\n\"Bash(node:*)\"\n

      Python:

      \"Bash(pytest:*)\",\n\"Bash(python:*)\",\n\"Bash(pip show:*)\",\n\"Bash(ruff:*)\"\n

      Rust:

      \"Bash(cargo build:*)\",\n\"Bash(cargo test:*)\",\n\"Bash(cargo clippy:*)\",\n\"Bash(cargo fmt:*)\"\n

      The ctx, git, and skill entries remain the same across all stacks.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#next-up","level":2,"title":"Next Up","text":"

      Permission Snapshots →: Save and restore permission baselines for reproducible setups.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#see-also","level":2,"title":"See Also","text":"
      • Setting Up ctx Across AI Tools: full setup recipe including settings.local.json creation
      • Context Health: keeping .context/ files accurate
      • Sanitize Permissions runbook: manual cleanup procedure
      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/configuration-profiles/","level":1,"title":"Configuration Profiles","text":"","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#configuration-profiles","level":1,"title":"Configuration Profiles","text":"

      Switch between dev and base runtime configurations without editing .ctxrc by hand. Useful when you want verbose logging and webhook notifications during development, then clean defaults for normal sessions.

      Uses: ctx config switch, ctx config status, /ctx-config

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#how-it-works","level":2,"title":"How It Works","text":"

      The ctx repo ships two source profiles committed to git:

      File Profile Description .ctxrc.base base All defaults, notifications off .ctxrc.dev dev Verbose logging, webhook notifications on

      The working copy (.ctxrc) is gitignored. Switching profiles copies the source file over .ctxrc, so your runtime configuration is always a clean snapshot of one of the two sources.

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#switching-profiles","level":2,"title":"Switching Profiles","text":"
      # Switch to dev (verbose logging, notifications)\nctx config switch dev\n\n# Switch to base (defaults)\nctx config switch base\n\n# Toggle to the opposite profile\nctx config switch\n\n# \"prod\" is an alias for \"base\"\nctx config switch prod\n

      The detection heuristic checks for an uncommented notify: line in .ctxrc: present means dev, absent means base.

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#checking-the-active-profile","level":2,"title":"Checking the Active Profile","text":"
      ctx config status\n

      Output examples:

      active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n
      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#typical-workflow","level":2,"title":"Typical Workflow","text":"
      1. Start of a debugging session: switch to dev for verbose logging and webhook notifications so you can trace hook activity and get push alerts.
      ctx config switch dev\n
      1. Work through the issue: hooks log verbosely, webhooks fire on key events (commits, ceremony nudges, drift warnings).

      2. Done debugging: switch back to base to silence the noise.

      ctx config switch base\n
      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#customizing-profiles","level":2,"title":"Customizing Profiles","text":"

      Edit the source files directly:

      • .ctxrc.dev: add any .ctxrc keys you want active during development (e.g., log_level: debug, notify.events, notify.webhook_url).
      • .ctxrc.base: keep this minimal. It represents your \"production\" defaults.

      After editing a source file, re-run ctx config switch <profile> to apply the changes to the working copy.

      Commit Your Profiles

      Both .ctxrc.base and .ctxrc.dev should be committed to git so team members share the same profile definitions. The working copy .ctxrc stays gitignored.

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#using-the-skill","level":2,"title":"Using the Skill","text":"

      In a Claude Code session, say any of:

      • \"switch to dev mode\"
      • \"switch to base\"
      • \"what profile am I on?\"
      • \"toggle verbose logging\"

      The /ctx-config skill handles the rest.

      See also: ctx config reference, Configuration

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/context-health/","level":1,"title":"Detecting and Fixing Drift","text":"","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#the-problem","level":2,"title":"The Problem","text":"

      ctx files drift: you rename a package, delete a module, or finish a sprint, and suddenly ARCHITECTURE.md references paths that no longer exist, TASKS.md is 80 percent completed checkboxes, and CONVENTIONS.md describes patterns you stopped using two months ago.

      Stale context is worse than no context:

      An AI tool that trusts outdated references will hallucinate confidently.

      This recipe shows how to detect drift, fix it, and keep your .context/ directory lean and accurate.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tldr","level":2,"title":"TL;DR","text":"
      ctx drift                      # detect problems\nctx drift --fix                # auto-fix the easy ones\nctx sync --dry-run && ctx sync # reconcile after refactors\nctx compact --archive          # archive old completed tasks\nctx fmt                        # normalize line widths\nctx status                     # verify\n

      Or just ask your agent: \"Is our context clean?\"

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, every command above fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx drift Command Detect stale paths, missing files, violations ctx drift --fix Command Auto-fix simple issues ctx sync Command Reconcile context with codebase structure ctx compact Command Archive completed tasks, clean up empty sections ctx fmt Command Normalize context files to 80-char line width ctx status Command Quick health overview /ctx-drift Skill Structural plus semantic drift detection /ctx-architecture Skill Refresh ARCHITECTURE.md from actual codebase /ctx-status Skill In-session context summary /ctx-prompt-audit Skill Audit prompt quality and token efficiency","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#the-workflow","level":2,"title":"The Workflow","text":"

      The best way to maintain context health is conversational: Ask your agent, guide it, and let it detect problems, explain them, and fix them with your approval. CLI commands exist for CI pipelines, scripting, and fine-grained control.

      For day-to-day maintenance, talk to your agent.

      Your Questions Reinforce the Pattern

      Asking \"is our context clean?\" does two things:

      • It triggers a drift check right now
      • It reinforces the habit

      This is reinforcement, not enforcement.

      Do not wait for the agent to be proactive on its own:

      Guide your agent, especially in early sessions.

      Over time, you will ask less and the agent will start offering more.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-1-ask-your-agent","level":3,"title":"Step 1: Ask Your Agent","text":"

      The simplest way to check context health:

      Is our context clean?\nAnything stale?\nHow healthy are our context files?\n

      Or invoke the skill directly:

      /ctx-drift\n

      The agent performs two layers of analysis:

      Layer 1, structural checks (via ctx drift): Dead paths, missing files, completed task counts, constitution violations. Fast and programmatic.

      Layer 2, semantic analysis (agent-driven): Does CONVENTIONS.md describe patterns the code no longer follows? Does DECISIONS.md contain entries whose rationale no longer applies? Are there learnings about bugs that are now fixed? This is where the agent adds value the CLI cannot: It reads both context files and source code and compares them.

      The agent reports both layers together, explains each finding in plain language, and offers to fix what it can.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-2-maintenance-at-session-start","level":3,"title":"Step 2: Maintenance at Session Start","text":"

      You do not need to ask explicitly.

      Using Claude Code

      ctx ships with Claude Code hooks that remind the agent at the right time to take initiative.

      Checking context health at the session start, offering to persist learnings before you quit, and flagging drift when it matters. The agent stays proactive without you having to prompt it:

      Agent: Good morning. I've loaded the context files. A few things\n       before we start:\n\n       - ARCHITECTURE.md references `pkg/auth/` which is now empty\n       - DECISIONS.md hasn't been updated in 40 days\n       - There are 18 completed tasks ready for archival\n\n       Want me to run a quick maintenance pass, or should we jump\n       straight into today's work?\n

      ☝️️ this is what persistent, initiative-driven sessions feel like when context is treated as a system instead of a prompt.

      If the agent does not offer this on its own, a gentle nudge is enough:

      Anything stale before we start?\nHow's the context looking?\n

      This turns maintenance from a scheduled chore into a conversation that happens when it matters.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-3-real-time-detection-during-work","level":3,"title":"Step 3: Real-Time Detection during Work","text":"

      Agents can notice drift while working: When a mismatch is directly in the path of their current task. If an agent reads ARCHITECTURE.md to find where to add a handler and internal/handlers/ doesn't exist, it will notice because the stale reference blocks its work:

      Agent: ARCHITECTURE.md references `internal/handlers/` but that directory\n       doesn't exist. I'll look at the actual source tree to find where\n       handlers live now.\n

      This happens reliably when the drift intersects the task. What is less reliable is the agent generalizing from one mismatch to \"there might be more stale references; let me run drift detection\" That leap requires the agent to know /ctx-drift exists and to decide the current task should pause for maintenance.

      If you want that behavior, reinforce it:

      Good catch. Yes, run /ctx-drift and clean up any other stale references.\n

      Over time, agents that have seen this pattern will start offering proactively. But do not expect it from a cold start.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-4-archival-and-cleanup","level":3,"title":"Step 4: Archival and Cleanup","text":"

      ctx drift detects when TASKS.md has more than 10 completed items and flags it as a staleness warning. Running ctx drift --fix archives completed tasks automatically.

      You can also run /ctx-archive to compact on demand.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#knowledge-health-flow","level":3,"title":"Knowledge Health Flow","text":"

      Over time, LEARNINGS.md and DECISIONS.md accumulate entries that overlap or partially repeat each other. The check-persistence hook detects when entry counts exceed a configurable threshold and surfaces a nudge:

      \"LEARNINGS.md has 25+ entries. Consider running /ctx-consolidate to merge overlapping items.\"

      The consolidation workflow:

      1. Review: /ctx-consolidate groups entries by keyword similarity and presents candidate merges for your approval.
      2. Merge: Approved groups are combined into single entries that preserve the key information from each original.
      3. Archive: Originals move to .context/archive/, not deleted -- the full history is preserved in git and the archive directory.
      4. Verify: Run ctx drift after consolidation to confirm no cross-references were broken by the merge.

      This replaces ad-hoc cleanup with a repeatable, nudge-driven cycle: detect accumulation, review candidates, merge with approval, archive originals.

      See also: Knowledge Capture for the recording workflow that feeds into this maintenance cycle.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-doctor-the-superset-check","level":2,"title":"ctx doctor: The Superset Check","text":"

      ctx doctor combines drift detection with hook auditing, configuration checks, event logging status, and token size reporting in a single command. If you want one command that covers structural health, hooks, and state:

      ctx doctor          # everything in one pass\nctx doctor --json   # machine-readable for scripting\n

      Use /ctx-doctor Too

      For agent-driven diagnosis that adds semantic analysis on top of the structural checks, use /ctx-doctor.

      See the Troubleshooting recipe for the full workflow.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#cli-reference","level":2,"title":"CLI Reference","text":"

      The conversational approach above uses CLI commands under the hood. When you need direct control, use the commands directly.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift","level":3,"title":"ctx drift","text":"

      Scan context files for structural problems:

      ctx drift\n

      Sample output:

      Drift Report\n============\n\nWarnings (3):\n  ARCHITECTURE.md:14  path \"internal/api/router.go\" does not exist\n  ARCHITECTURE.md:28  path \"pkg/auth/\" directory is empty\n  CONVENTIONS.md:9    path \"internal/handlers/\" not found\n\nViolations (1):\n  TASKS.md            31 completed tasks (recommend archival)\n\nStaleness:\n  DECISIONS.md        last modified 45 days ago\n  LEARNINGS.md        last modified 32 days ago\n\nExit code: 1 (warnings found)\n
      Level Meaning Action Warning Stale path references, missing files Fix or remove Violation Constitution rule heuristic failures, heavy clutter Fix soon Staleness Files not updated recently Review content

      Exit codes: 0 equals clean, 1 equals warnings, 3 equals violations.

      For CI integration:

      ctx drift --json | jq '.warnings | length'\n
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift-fix","level":3,"title":"ctx drift --fix","text":"

      Auto-fix mechanical issues:

      ctx drift --fix\n

      This handles removing dead path references, updating unambiguous renames, clearing empty sections. Issues requiring judgment are flagged but left for you.

      Run ctx drift again afterward to confirm what remains.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-sync","level":3,"title":"ctx sync","text":"

      After a refactor, reconcile context with the actual codebase structure:

      ctx sync --dry-run   # preview first\nctx sync             # apply\n

      ctx sync scans for structural changes, compares with ARCHITECTURE.md, checks for new dependencies worth documenting, and identifies context referring to code that no longer exists.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-compact","level":3,"title":"ctx compact","text":"

      Consolidate completed tasks and clean up empty sections:

      ctx compact            # move completed tasks to Completed section,\n                       # remove empty sections\nctx compact --archive  # also archive old tasks to .context/archive/\n
      • Tasks: moves completed items (with all subtasks done) into the Completed section of TASKS.md
      • All files: removes empty sections left behind
      • With --archive: writes tasks older than 7 days to .context/archive/tasks-YYYY-MM-DD.md

      Without --archive, nothing is deleted: Tasks are reorganized in place.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-fmt","level":3,"title":"ctx fmt","text":"

      Normalize context file line widths:

      ctx fmt              # wrap long lines to 80 chars\nctx fmt --check      # CI: exit 1 if files need formatting\n

      Long task descriptions, decision rationale, and learning entries accumulate as single-line entries. ctx fmt wraps them at word boundaries with 2-space continuation indent for list items. Headings, tables, and comments are preserved.

      Idempotent: safe to run repeatedly.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-status","level":3,"title":"ctx status","text":"

      Quick health overview:

      ctx status --verbose\n

      Shows file counts, token estimates, modification times, and drift warnings in a single glance.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-prompt-audit","level":3,"title":"/ctx-prompt-audit","text":"

      Checks whether your context files are readable, compact, and token-efficient for the model.

      /ctx-prompt-audit\n
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      Conversational approach (recommended):

      Is our context clean?  -> agent runs structural plus semantic checks\nFix what you can       -> agent auto-fixes and proposes edits\nArchive the done tasks -> agent runs ctx compact --archive\nHow's token usage?     -> agent checks ctx status\n

      CLI approach (for CI, scripts, or direct control):

      ctx drift                      # 1. Detect problems\nctx drift --fix                # 2. Auto-fix the easy ones\nctx sync --dry-run && ctx sync # 3. Reconcile after refactors\nctx compact --archive          # 4. Archive old completed tasks\nctx fmt                        # 5. Normalize line widths\nctx status                     # 6. Verify\n
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tips","level":2,"title":"Tips","text":"

      Agents cross-reference context files with source code during normal work. When drift intersects their current task, they will notice: a renamed package, a deleted directory, a path that doesn't resolve. But they rarely generalize from one mismatch to a full audit on their own. Reinforce the pattern: when an agent mentions a stale reference, ask it to run /ctx-drift. Over time, it starts offering.

      When an agent says \"this reference looks stale,\" it is usually right.

      Semantic drift is more damaging than structural drift: ctx drift catches dead paths. But CONVENTIONS.md describing a pattern your code stopped following three weeks ago is worse. When you ask \"is our context clean?\", the agent can do both checks.

      Use ctx status as a quick check: It shows file counts, token estimates, and drift warnings in a single glance. Good for a fast \"is everything ok?\" before diving into work.

      Drift detection in CI: add ctx drift --json to your CI pipeline and fail on exit code 3 (violations). This catches constitution-level problems before they reach upstream.

      Do not over-compact: Completed tasks have historical value. The --archive flag preserves them in .context/archive/ so you can search past work without cluttering active context.

      Sync is cautious by default: Use --dry-run after large refactors, then apply.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#next-up","level":2,"title":"Next Up","text":"

      Claude Code Permission Hygiene →: Recommended permission defaults and maintenance workflow for Claude Code.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#see-also","level":2,"title":"See Also","text":"
      • Troubleshooting: full diagnostic workflow using ctx doctor, event logs, and /ctx-doctor
      • Tracking Work Across Sessions: task lifecycle and archival
      • Persisting Decisions, Learnings, and Conventions: keeping knowledge files current
      • The Complete Session: where maintenance fits in the daily workflow
      • CLI Reference: full flag documentation for all commands
      • Context Files: structure and purpose of each .context/ file
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/customizing-hook-messages/","level":1,"title":"Customizing Hook Messages","text":"","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#the-problem","level":2,"title":"The Problem","text":"

      ctx hooks speak ctx's language, not your project's. The QA gate says \"lint the ENTIRE project\" and \"make build,\" but your Python project uses pytest and ruff. The post-commit nudge suggests running lints, but your project uses npm test. You could remove the hook entirely, but then you lose the logic (counting, state tracking, adaptive frequency) just to change the words.

      How do you customize what hooks say without removing what they do?

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tldr","level":2,"title":"TL;DR","text":"
      ctx hook message list                     # see all hooks and their messages\nctx hook message show qa-reminder gate    # view the current template\nctx hook message edit qa-reminder gate    # copy default to .context/ for editing\nctx hook message reset qa-reminder gate   # revert to embedded default\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root: hook message overrides live in your .context/ directory, so ctx needs to know which one. If you skip the eval, ctx hook message ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#commands-used","level":2,"title":"Commands Used","text":"Tool Type Purpose ctx hook message list CLI command Show all hook messages with category and override status ctx hook message show CLI command Print the effective message template ctx hook message edit CLI command Copy embedded default to .context/ for editing ctx hook message reset CLI command Delete user override, revert to default","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#how-it-works","level":2,"title":"How It Works","text":"

      Hook messages use a 3-tier fallback:

      1. User override: .context/hooks/messages/{hook}/{variant}.txt
      2. Embedded default: compiled into the ctx binary
      3. Hardcoded fallback: belt-and-suspenders safety net

      The hook logic (when to fire, counting, state tracking, cooldowns) is unchanged. Only the content (what text gets emitted) comes from the template. You customize what the hook says without touching how it decides to speak.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#finding-the-original-templates","level":3,"title":"Finding the Original Templates","text":"

      The default templates live in the ctx source tree at:

      internal/assets/hooks/messages/{hook}/{variant}.txt\n

      You can also browse them on GitHub: internal/assets/hooks/messages/

      Or use ctx hook message show to print any template without digging through source code:

      ctx hook message show qa-reminder gate        # QA gate instructions\nctx hook message show check-persistence nudge  # persistence nudge\nctx hook message show post-commit nudge        # post-commit reminder\n

      The show output includes the template source and available variables -- everything you need to write a replacement.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#template-variables","level":3,"title":"Template Variables","text":"

      Some messages use Go text/template variables for dynamic content:

      No context files updated in {{.PromptsSinceNudge}}+ prompts.\nHave you discovered learnings, made decisions,\nestablished conventions, or completed tasks\nworth persisting?\n

      The show and edit commands list available variables for each message. When writing a replacement, keep the same {{.VariableName}} placeholders to preserve dynamic content. Variables that you omit render as <no value>: no error, but the output may look odd.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#intentional-silence","level":3,"title":"Intentional Silence","text":"

      An empty template file (0 bytes or whitespace-only) means \"don't emit a message\". The hook still runs its logic but produces no output. This lets you silence specific messages without removing the hook from hooks.json.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#example-python-project-qa-gate","level":2,"title":"Example: Python Project QA Gate","text":"

      The default QA gate says \"lint the ENTIRE project\" and references make lint. For a Python project, you want pytest and ruff:

      # See the current default\nctx hook message show qa-reminder gate\n\n# Copy it to .context/ for editing\nctx hook message edit qa-reminder gate\n\n# Edit the override\n

      Replace the content in .context/hooks/messages/qa-reminder/gate.txt:

      HARD GATE! DO NOT COMMIT without completing ALL of these steps first:\n(1) Run the full test suite: pytest -x\n(2) Run the linter: ruff check .\n(3) Verify a clean working tree\nRun tests and linter BEFORE every git commit, no exceptions.\n

      The hook still fires on every Edit call. The logic is identical. Only the instructions changed.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#example-silencing-ceremony-nudges","level":2,"title":"Example: Silencing Ceremony Nudges","text":"

      The ceremony check nudges you to use /ctx-remember and /ctx-wrap-up. If your team has a different workflow and finds these noisy:

      ctx hook message edit check-ceremonies both\nctx hook message edit check-ceremonies remember\nctx hook message edit check-ceremonies wrapup\n

      Then empty each file:

      echo -n \"\" > .context/hooks/messages/check-ceremonies/both.txt\necho -n \"\" > .context/hooks/messages/check-ceremonies/remember.txt\necho -n \"\" > .context/hooks/messages/check-ceremonies/wrapup.txt\n

      The hooks still track ceremony usage internally, but they no longer emit any visible output.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#example-javascript-project-post-commit","level":2,"title":"Example: JavaScript Project Post-Commit","text":"

      The default post-commit nudge mentions generic \"lints and tests.\" For a JavaScript project:

      ctx hook message edit post-commit nudge\n

      Replace with:

      Commit succeeded. 1. Offer context capture to the user: Decision (design\nchoice?), Learning (gotcha?), or Neither. 2. Ask the user: \"Want me to\nrun npm test and eslint before you push?\" Do NOT push. The user pushes\nmanually.\n
      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#the-two-categories","level":2,"title":"The Two Categories","text":"

      Not all messages are equal. The list command shows each message's category:

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#customizable-17-messages","level":3,"title":"Customizable (17 Messages)","text":"

      Messages that are opinions: project-specific wording that benefits from customization. These are the primary targets for override.

      Hook Variant Description check-freshness stale Technology constant freshness warning check-ceremonies both Both ceremonies missing check-ceremonies remember Start-of-session ceremony check-ceremonies wrapup End-of-session ceremony check-context-size checkpoint Context capacity warning check-context-size oversize Injection oversize nudge check-context-size window Context window usage warning (>80%) check-journal both Unimported sessions + unenriched entries check-journal unenriched Unenriched journal entries check-journal unimported Unimported sessions check-knowledge warning Knowledge file growth check-map-staleness stale Architecture map staleness check-persistence nudge Context persistence nudge post-commit nudge Post-commit context capture qa-reminder gate Pre-commit QA gate","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#ctx-specific-10-messages","level":3,"title":"ctx-Specific (10 Messages)","text":"

      Messages specific to ctx's own development workflow. You can customize them, but edit will warn you first.

      Hook Variant Description block-dangerous-commands cp-to-bin Block copy to bin dirs block-dangerous-commands install-to-local-bin Block copy to ~/.local/bin block-dangerous-commands mid-git-push Block git push block-dangerous-commands mid-sudo Block sudo block-non-path-ctx absolute-path Block absolute path invocation block-non-path-ctx dot-slash Block ./ctx invocation block-non-path-ctx go-run Block go run invocation check-reminders reminders Pending reminders relay check-resources alert Resource pressure alert check-version key-rotation Key rotation nudge check-version mismatch Version mismatch","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#template-variables-reference","level":2,"title":"Template Variables Reference","text":"Hook Variant Variables check-freshness stale {{.StaleFiles}} check-context-size checkpoint (none) check-context-size oversize {{.TokenCount}} check-context-size window {{.TokenCount}}, {{.Percentage}} check-ceremonies both, remember, wrapup (none) check-journal both {{.UnimportedCount}}, {{.UnenrichedCount}} check-journal unenriched {{.UnenrichedCount}} check-journal unimported {{.UnimportedCount}} check-knowledge warning {{.FileWarnings}} check-map-staleness stale {{.LastRefreshDate}}, {{.ModuleCount}} check-persistence nudge {{.PromptsSinceNudge}} check-reminders reminders {{.ReminderList}} check-resources alert {{.AlertMessages}} check-version key-rotation {{.KeyAgeDays}} check-version mismatch {{.BinaryVersion}}, {{.PluginVersion}} post-commit nudge (none) qa-reminder gate (none) block-dangerous-commands all variants (none) block-non-path-ctx all variants (none)

      Templates that reference undefined variables render <no value>: no error, graceful degradation.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tips","level":2,"title":"Tips","text":"
      • Override files are version-controlled: they live in .context/ alongside your other context files. Team members get the same customized messages.
      • Start with show: always check the current default before editing. The embedded template is the baseline your override replaces.
      • Use reset to undo: if a customization causes confusion, reset reverts to the embedded default instantly.
      • Empty file = silence: you don't need to delete the hook. An empty override file silences the message while preserving the hook's logic.
      • JSON output for scripting: ctx hook message list --json returns structured data for automation.
      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#see-also","level":2,"title":"See Also","text":"
      • Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates
      • Auditing System Hooks: verifying hooks are running and auditing their output
      • Configuration: project-level settings via .ctxrc
      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/design-before-coding/","level":1,"title":"Design Before Coding","text":"","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#the-problem","level":2,"title":"The Problem","text":"

      You start coding a feature. Halfway through, you realize the approach doesn't handle a key edge case. You refactor. Then you discover the CLI interface doesn't fit the existing patterns. More refactoring.

      The design work happened during implementation, mixed in with debugging and trial-and-error. The result works, but the spec was never written down, the trade-offs were never recorded, and the next session has no idea why things are shaped this way.

      How do you front-load design so the implementation is straightforward?

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-brainstorm          # explore the design space\n/ctx-spec                # write the spec document\n/ctx-task-add            # break it into tasks\n/ctx-implement           # execute step-by-step\n

      Four skills, used in sequence. Each produces an artifact that feeds the next.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-brainstorm Skill Structured design dialogue: explore approaches /ctx-spec Skill Scaffold and fill out a spec from the template /ctx-task-add Skill Add implementation tasks to TASKS.md /ctx-implement Skill Execute a plan step-by-step with verification /ctx-decision-add Skill Record design choices made during brainstorming","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-1-brainstorm-the-design","level":3,"title":"Step 1: Brainstorm the Design","text":"

      Start with /ctx-brainstorm when you have a rough idea but haven't committed to an approach. The skill follows a gated process:

      1. Understand context: what exists today, what's the gap
      2. Clarify the idea: one question at a time, not a wall of questions
      3. Surface non-functional requirements: performance, security, compatibility
      4. Lock understanding: confirm before exploring solutions
      5. Explore 2-3 approaches: with trade-offs for each
      6. Stress-test: poke holes in the chosen approach
      7. Present the design: detailed enough to implement from
      You: \"I want to add RSS feed generation to the blog.\"\n\nAgent: \"Before we design, let me understand: is this for the journal\n  site, the docs site, or both?\"\n\nYou: \"Journal site only.\"\n\nAgent: [asks about update frequency, content scope, existing infra...]\n       [presents 3 approaches with trade-offs]\n\nYou: \"Option 2 - generate at build time.\"\n\nAgent: \"Let me stress-test that. What happens when...\"\n       [probes edge cases]\n       \"Design looks solid. Want me to record the approach as a\n       decision and write a spec?\"\n

      The brainstorm produces a validated design in conversation. It doesn't produce a file - that's what the spec is for.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-2-write-the-spec","level":3,"title":"Step 2: Write the Spec","text":"

      Once the design is clear, use /ctx-spec to produce the written artifact. The skill reads the project's spec template (specs/tpl/spec-template.md) and walks through each section:

      You: /ctx-spec (rss feed generation)\n\nAgent: \"Creating specs/rss-feed.md from template.\"\n\n       \"Problem: What user-visible problem does this solve? Why now?\"\n\nYou: \"Users can't subscribe to blog updates. They have to check\n      the site manually.\"\n\nAgent: [writes the Problem section, moves to Approach]\n\n       \"Approach: High-level, how does this work?\"\n\nYou: \"Generate feed.xml during ctx journal site. Atom format.\"\n\nAgent: [writes Approach, moves to Happy Path, then Edge Cases...]\n

      The skill spends extra time on Edge Cases and Error Handling: These are where specs earn their value. The skill pushes for at least three edge cases and won't accept \"none\" without a challenge.

      Sections that don't apply can be skipped. The result is a complete spec at specs/{feature-name}.md.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-3-break-into-tasks","level":3,"title":"Step 3: Break into Tasks","text":"

      After the spec is written, the skill offers to create tasks:

      Agent: \"Spec written to specs/rss-feed.md. Want me to break this\n  into tasks in TASKS.md?\"\n\nYou: \"Yes.\"\n\nAgent: [creates a Phase section referencing the spec, adds tasks]\n       \"Added Phase 0.8: RSS/Atom Feed Generation with 4 tasks:\n         - [ ] Implement feed.xml generation in ctx journal site\n         - [ ] Add --feed flag and .ctxrc feed config\n         - [ ] Write tests for feed generation\n         - [ ] Add recipe and update docs\"\n

      Each task is independently completable and references the spec via Spec: specs/rss-feed.md in the Phase header.

      You can also invoke /ctx-task-add directly at any point to add individual tasks.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-4-implement-step-by-step","level":3,"title":"Step 4: Implement Step-by-Step","text":"

      Pick up tasks with /ctx-implement. The skill loads the spec, breaks work into atomic steps, and checkpoints after every 3-5 steps with a build and test verification:

      You: /ctx-implement (specs/rss-feed.md)\n\nAgent: \"Loaded spec. Breaking into steps:\n         1. Add FeedEntry type to journal package\n         2. Implement feed.xml template\n         3. Wire into site generation pipeline\n         [builds and tests after step 3]\n         4. Add --feed flag to ctx journal site\n         5. Add .ctxrc feed configuration\n         [builds and tests after step 5]\n         ...\"\n

      If a build or test fails, the agent stops, diagnoses, and fixes before continuing.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#when-to-skip-steps","level":2,"title":"When to Skip Steps","text":"

      Not every feature needs all four steps. Use your judgment:

      Situation Start at Vague idea, multiple valid approaches Step 1: Brainstorm Clear approach, need to document it Step 2: Spec Spec already exists, need to plan work Step 3: Tasks Tasks exist, ready to code Step 4: Implement

      A brainstorm without a spec is fine for small decisions. A spec without a brainstorm is fine when the design is obvious. The full chain is for features complex enough to warrant front-loaded design.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need skill names. Natural language works:

      You say What happens \"Let's think through this feature\" /ctx-brainstorm \"Spec this out\" /ctx-spec \"Write a design doc for...\" /ctx-spec \"Break this into tasks\" /ctx-task-add \"Implement the spec\" /ctx-implement \"Let's design before we build\" Starts at brainstorm","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#tips","level":2,"title":"Tips","text":"
      • Brainstorm first when uncertain. If you can articulate the approach in two sentences, skip to spec. If you can't, brainstorm.
      • Specs prevent scope creep. The Non-Goals section is as important as the approach. Writing down what you won't do keeps implementation focused.
      • Edge cases are the point. A spec that only describes the happy path isn't a spec - it's a wish. The /ctx-spec skill pushes for at least 3 edge cases because that's where designs break.
      • Record decisions during brainstorming. When you choose between approaches, the agent offers to persist the trade-off via /ctx-decision-add. Accept - future sessions need to know why, not just what.
      • Specs are living documents. Update them when implementation reveals new constraints. A spec that diverges from reality is worse than no spec.
      • The spec template is customizable. Edit specs/tpl/spec-template.md to match your project's needs. The /ctx-spec skill reads whatever template it finds there.
      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#see-also","level":2,"title":"See Also","text":"
      • Skills Reference: /ctx-brainstorm: structured design dialogue
      • Skills Reference: /ctx-spec: spec scaffolding from template
      • Skills Reference: /ctx-implement: step-by-step execution with verification
      • Tracking Work Across Sessions: task lifecycle and archival
      • Importing Claude Code Plans: turning ephemeral plans into permanent specs
      • Persisting Decisions, Learnings, and Conventions: capturing design trade-offs
      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/external-context/","level":1,"title":"Keeping Context in a Separate Repo","text":"","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#the-problem","level":2,"title":"The Problem","text":"

      ctx files contain project-specific decisions, learnings, conventions, and tasks. By default, they live in .context/ inside the project tree, and that works well when the context can be public.

      But sometimes you need the context outside the project:

      • Open-source projects with private context: Your architectural notes, internal task lists, and scratchpad entries shouldn't ship with the public repo.
      • Compliance or IP concerns: Context files reference sensitive design rationale that belongs in a separate access-controlled repository.
      • Personal preference: You want to keep notes separate from code.

      ctx supports this by letting you point CTX_DIR anywhere. This recipe shows how to set that up and how to tell your AI assistant where to find the context.

      One .context/ per project

      The parent of the context directory is the project root by contract. ctx sync, ctx drift, and the memory-drift hook all read the codebase at filepath.Dir(ContextDir()). Pointing two projects at the same directory corrupts their journals, state, and secrets. To share knowledge (CONSTITUTION / CONVENTIONS / ARCHITECTURE) across projects, use ctx hub, not a shared .context/.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#tldr","level":2,"title":"TL;DR","text":"

      Create the external context directory, initialize it, and bind it:

      mkdir -p ~/repos/myproject-context && cd ~/repos/myproject-context && git init\ncd ~/repos/myproject\n\n# Bind CTX_DIR to the external location, then init creates files there.\nexport CTX_DIR=~/repos/myproject-context/.context\nctx init\n

      All ctx commands now use the external directory. If you share the setup across shells, add the export CTX_DIR=... line to your shell rc, or source a per-project .envrc with direnv.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#what-works-what-quietly-degrades","level":2,"title":"What Works, What Quietly Degrades","text":"

      The single-source-anchor contract states that filepath.Dir(CTX_DIR) is the project root. When the context lives outside the project tree, ctx still resolves correctly for every operation that reads or writes inside .context/. But any operation that scans the codebase scans the wrong tree, and does so silently:

      Operation Behavior with external .context/ ctx status, agent, add ✅ Works. Operates on files inside CTX_DIR. Journal, scratchpad, hub ✅ Works. Same reason. ctx sync ⚠️ Scans the context repo, not the code repo. ctx drift ⚠️ Same. Reports nothing useful. Memory-drift hook (MEMORY.md) ⚠️ Looks for MEMORY.md next to the external .context/, not the code.

      Nothing errors. The code-aware operations just find an empty or unrelated tree where the project root should be.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#workaround-symlink-the-context-into-the-code-tree","level":3,"title":"Workaround: symlink the .context/ into the code tree","text":"

      If you want both the privacy of an external git repo and working ctx sync / drift / memory-drift, symlink the external .context/ into the code repo and point CTX_DIR at the symlink:

      # External repo holds the real files\nmkdir -p ~/repos/myproject-context && cd ~/repos/myproject-context && git init\n\n# Symlink it into the code repo\nln -s ~/repos/myproject-context/.context ~/repos/myproject/.context\n\n# Bind CTX_DIR to the symlink path; ctx init will follow it\nexport CTX_DIR=~/repos/myproject/.context\nctx init\n

      Now filepath.Dir(CTX_DIR) is the code repo, so code-aware operations scan the right tree. The actual files still live in the external repo and commit there. Add .context to the code repo's .gitignore (or .git/info/exclude) so the symlink itself isn't tracked by the code repo.

      The basename guard is permissive about symlinks: it checks the declared name, not the resolved target, so a .context symlink pointing anywhere is accepted as long as the declared basename is .context.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx init CLI command Initialize context directory ctx activate CLI command Emit export CTX_DIR=... for the shell CTX_DIR Env variable Declare context directory per-session .ctxrc Config file Per-project configuration /ctx-status Skill Verify context is loading correctly","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-1-create-the-private-context-repo","level":3,"title":"Step 1: Create the Private Context Repo","text":"

      Create a separate repository for your context files. This can live anywhere: a private GitHub repo, a shared drive, a sibling directory:

      # Create the context repo\nmkdir -p ~/repos/myproject-context\ncd ~/repos/myproject-context\ngit init\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-2-initialize-ctx-pointing-at-it","level":3,"title":"Step 2: Initialize ctx Pointing at It","text":"

      From your project root, declare CTX_DIR pointing to the external location, then initialize:

      cd ~/repos/myproject\nCTX_DIR=~/repos/myproject-context/.context ctx init\n

      This creates the canonical .context/ file set inside ~/repos/myproject-context/ instead of ~/repos/myproject/.context/.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-3-make-it-stick","level":3,"title":"Step 3: Make It Stick","text":"

      Declaring CTX_DIR on every command is tedious. Pick one of these methods to make the configuration permanent. The context directory itself must be declared via CTX_DIR; .ctxrc does not carry the path.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#option-a-ctx_dir-environment-variable-recommended","level":4,"title":"Option A: CTX_DIR Environment Variable (Recommended)","text":"
      # Direct path. Works for ctx status / agent / add but degrades\n# code-aware operations. See \"What Works, What Quietly Degrades\".\nexport CTX_DIR=~/repos/myproject-context/.context\n\n# Or, with the symlink approach above, point at the symlink path\n# inside the code repo so code-aware operations stay healthy.\nexport CTX_DIR=~/repos/myproject/.context\n

      Put either form in your shell profile (~/.bashrc, ~/.zshrc) or a direnv .envrc.

      For a single session, run eval \"$(ctx activate)\" from any directory inside the project where exactly one .context/ candidate is visible (the symlink counts). activate does not accept a path argument; bind a specific path by exporting CTX_DIR directly instead.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#option-b-ctxrc-for-other-settings","level":4,"title":"Option B: .ctxrc for Other Settings","text":"

      Put any settings (token budget, priority order, freshness files) in a .ctxrc at the project root (dirname(CTX_DIR)), which here is the parent of the external .context/:

      # ~/repos/myproject-context/.ctxrc\ntoken_budget: 16000\n

      .ctxrc is always read from the parent of CTX_DIR, so this file is picked up whenever CTX_DIR points at ~/repos/myproject-context/.context.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#resolution","level":4,"title":"Resolution","text":"

      ctx reads the context directory from a single channel: the CTX_DIR environment variable. When CTX_DIR is unset, ctx errors with a \"no context directory specified\" hint pointing at ctx activate and this recipe. When set, the value must be an absolute path with .context as its basename; relative paths and other names are rejected on first use.

      See Activating a Context Directory for the full recipe.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-4-agent-auto-discovery-via-bootstrap","level":3,"title":"Step 4: Agent Auto-Discovery via Bootstrap","text":"

      When context lives outside the project tree, your AI assistant needs to know where to find it. The ctx system bootstrap command resolves the configured context directory and communicates it to the agent automatically:

      $ ctx system bootstrap\nctx system bootstrap\n====================\n\ncontext_dir: /home/user/repos/myproject-context/.context\n\nFiles:\n  CONSTITUTION.md, TASKS.md, DECISIONS.md, ...\n

      The CLAUDE.md template generated by ctx init already instructs the agent to run ctx system bootstrap at session start. Because CTX_DIR is inherited by child processes, your agent picks up the external path automatically.

      Here is the relevant section from CLAUDE.md for reference:

      <!-- CLAUDE.md -->\n1. **Run `ctx system bootstrap`**: CRITICAL, not optional.\n   This tells you where the context directory is. If it returns any\n   error, relay the error output to the user verbatim, point them at\n   https://ctx.ist/recipes/activating-context/ for setup, and STOP.\n   Do not try to recover; the user decides.\n

      Moreover, every nudge (context checkpoint, persistence reminder, etc.) also includes a Context: /home/user/repos/myproject-context/.context footer, so the agent remains anchored to the correct directory even in long sessions.

      Export CTX_DIR in your shell profile so every hook process inherits it:

      export CTX_DIR=~/repos/myproject-context/.context\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-5-share-with-teammates","level":3,"title":"Step 5: Share with Teammates","text":"

      Teammates clone both repos and export CTX_DIR:

      # Clone the project\ngit clone git@github.com:org/myproject.git\ncd myproject\n\n# Clone the private context repo\ngit clone git@github.com:org/myproject-context.git ~/repos/myproject-context\nexport CTX_DIR=~/repos/myproject-context/.context\n

      If teammates use different paths, each developer sets their own CTX_DIR.

      For encryption key distribution across the team, see the Syncing Scratchpad Notes recipe.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-6-day-to-day-sync","level":3,"title":"Step 6: Day-to-Day Sync","text":"

      The external context repo has its own git history. Treat it like any other repo: commit and push after sessions:

      cd ~/repos/myproject-context\n\n# After a session\ngit add -A\ngit commit -m \"Session: refactored auth module, added rate-limit learning\"\ngit push\n

      Your AI assistant can do this too. When ending a session:

      You: \"Save what we learned and push the context repo.\"\n\nAgent: [runs ctx add learning, then commits and pushes the context repo]\n

      You can also set up a post-session habit: project code gets committed to the project repo, context gets committed to the context repo.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need to remember the flags; simply ask your assistant:

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#set-up-your-system-using-natural-language","level":3,"title":"Set Up Your System Using Natural Language","text":"
      You: \"Set up ctx to use ~/repos/myproject-context as the context directory.\"\n\nAgent: \"I'll set CTX_DIR to that path, run ctx init to materialize\n       it, and show you the export line to add to your shell\n       profile. Want me to seed the core context files too?\"\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#configure-separate-repo-for-context-folder-using-natural-language","level":3,"title":"Configure Separate Repo for .context Folder Using Natural Language","text":"
      You: \"My context is in a separate repo. Can you load it?\"\n\nAgent: [reads CTX_DIR, loads context from the external dir]\n       \"Loaded. You have 3 pending tasks, last session was about the auth\n       refactor.\"\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#tips","level":2,"title":"Tips","text":"
      • Start simple. If you don't need external context yet, don't set it up. The default .context/ in-tree is the easiest path. Move to an external repo when you have a concrete reason.
      • One context repo per project. Sharing a single context directory across multiple projects corrupts journals, state, and secrets. Use ctx hub for cross-project knowledge sharing.
      • Export CTX_DIR in your shell profile so hooks and tools inherit the path without per-command flags.
      • Commit both repos at session boundaries. Context without code history (or code without context history) loses half the value.
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#next-up","level":2,"title":"Next Up","text":"

      The Complete Session →: Walk through a full ctx session from start to finish.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#see-also","level":2,"title":"See Also","text":"
      • Setting Up ctx Across AI Tools: initial setup recipe
      • Syncing Scratchpad Notes Across Machines: distribute encryption keys when context is shared
      • CLI Reference: full command list and global options
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/guide-your-agent/","level":1,"title":"Guide Your Agent","text":"

      Commands vs. Skills

      Commands (ctx status, ctx add task) run in your terminal.

      Skills (/ctx-reflect, /ctx-next) run inside your AI coding assistant.

      Recipes combine both.

      Think of commands as structure and skills as behavior.

      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#proactive-behavior","level":2,"title":"Proactive Behavior","text":"

      These recipes show explicit commands and skills, but agents trained on the ctx playbook are proactive: They offer to save learnings after debugging, record decisions after trade-offs, create follow-up tasks after completing work, and suggest what to work on next.

      Your questions train the agent. Asking \"what have we learned?\" or \"is our context clean?\" does two things:

      • It triggers the workflow right now,
      • and it reinforces the pattern.

      The more you guide, the more the agent habituates the behavior and begins offering on its own.

      Each recipe includes a Conversational Approach section showing these natural-language patterns.

      Tip

      Don't wait passively for proactive behavior: especially in early sessions.

      Ask, guide, reinforce. Over time, you ask less and the agent offers more.

      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#next-up","level":2,"title":"Next Up","text":"

      Setup Across AI Tools →: Initialize ctx and configure hooks for Claude Code, Cursor, Aider, Copilot, or Windsurf.

      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: full session lifecycle from start to finish
      • Prompting Guide: general tips for working effectively with AI coding assistants
      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/hook-output-patterns/","level":1,"title":"Hook Output Patterns","text":"","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code hooks can output text, JSON, or nothing at all. But the format of that output determines who sees it and who acts on it.

      Choose the wrong pattern, and your carefully crafted warning gets silently absorbed by the agent, or your agent-directed nudge gets dumped on the user as noise.

      This recipe catalogs the known hook output patterns and explains when to use each one.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#tldr","level":2,"title":"TL;DR","text":"

      Eight patterns from full control to full invisibility:

      • hard gate (exit 2),
      • VERBATIM relay (agent MUST show),
      • agent directive (context injection),
      • and silent side-effect (background work).

      Most hooks belong in the middle.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#the-spectrum","level":2,"title":"The Spectrum","text":"

      These patterns form a spectrum based on who decides what the user sees:

      Pattern Who decides? Hard gate Hook decides (agent can't proceed) VERBATIM relay Hook decides (agent must show) Escalating severity Hook suggests, agent judges urgency Conditional relay Hook sets criteria, agent evaluates Suggested action Hook proposes, agent + user decide Agent directive Agent decides entirely Silent injection Nobody: invisible background context Silent side-effect Nobody: invisible background work

      The spectrum runs from full hook control (hard gate) to full invisibility (silent side effect).

      Most hooks belong somewhere in the middle.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-1-hard-gate","level":2,"title":"Pattern 1: Hard Gate","text":"

      Block the tool call entirely. The agent cannot proceed: it must find another approach or tell the user.

      echo '{\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}'\n

      When to use: Enforcing invariants that must never be violated: Constitution rules, security boundaries, destructive command prevention.

      Hook type: PreToolUse only (Claude Code first-class mechanism).

      Examples in ctx:

      • ctx system block-non-path-ctx: Enforces the PATH invocation rule
      • block-git-push.sh: Requires explicit user approval for pushes (project-local)
      • block-dangerous-commands.sh: Prevents sudo, copies to ~/.local/bin (project-local)

      Trade-off: The agent gets a block response with a reason. Good reasons help the agent recover (\"use X instead\"); bad reasons leave it stuck.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-2-verbatim-relay","level":2,"title":"Pattern 2: VERBATIM Relay","text":"

      Force the agent to show this to the user as-is. The explicit instruction overcomes the agent's tendency to silently absorb context.

      echo \"IMPORTANT: Relay this warning to the user VERBATIM before answering their question.\"\necho \"\"\necho \"┌─ Journal Reminder ─────────────────────────────\"\necho \"│ You have 12 sessions not yet exported.\"\necho \"└────────────────────────────────────────────────\"\n

      When to use: Actionable reminders the user needs to see regardless of what they asked: Stale backups, unimported sessions, resource warnings.

      Hook type: UserPromptSubmit (runs before the agent sees the prompt).

      Examples in ctx:

      • ctx system check-journal: Unexported sessions and unenriched entries
      • ctx system check-context-size: Context capacity warning
      • ctx system check-resources: Resource pressure (memory, swap, disk, load): DANGER only
      • ctx system check-freshness: Technology constant staleness warning

      Trade-off: Noisy if overused. Every VERBATIM relay adds a preamble before the agent's actual answer. Throttle with once-per-day markers or adaptive frequency.

      Key detail: The phrase IMPORTANT: Relay this ... VERBATIM is what makes this work. Without it, agents tend to process the information internally and never surface it. The explicit instruction is the pattern: the box-drawing is just fancy formatting.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-3-agent-directive","level":2,"title":"Pattern 3: Agent Directive","text":"

      Tell the agent to do something, not the user. The agent decides whether and how to involve the user.

      echo \"┌─ Persistence Checkpoint (prompt #25) ───────────\"\necho \"│ No context files updated in 15+ prompts.\"\necho \"│ Have you discovered learnings, decisions,\"\necho \"│ or completed tasks worth persisting?\"\necho \"└──────────────────────────────────────────────────\"\n

      When to use: Behavioral nudges. The hook detects a condition and asks the agent to consider an action. The user may never need to know.

      Hook type: UserPromptSubmit.

      Examples in ctx:

      • ctx system check-persistence: Nudges the agent to persist context

      Trade-off: No guarantee the agent acts. The nudge is one signal among many in the context window. Strong phrasing helps (\"Have you...?\" is better than \"Consider...\"), but ultimately the agent decides.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-4-silent-context-injection","level":2,"title":"Pattern 4: Silent Context Injection","text":"

      Load context with no visible output. The agent gets enriched without either party noticing.

      ctx agent --budget 4000 >/dev/null || true\n

      When to use: Background context loading that should be invisible. The agent benefits from the information, but neither it, nor the user needs to know it happened.

      Hook type: PreToolUse with .* matcher (runs on every tool call).

      Examples in ctx:

      • The ctx agent PreToolUse hook: injects project context silently

      Trade-off: Adds latency to every tool call. Keep the injected content small and fast to generate.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-5-silent-side-effect","level":2,"title":"Pattern 5: Silent Side-Effect","text":"

      Do work, produce no output: Housekeeping that needs no acknowledgment.

      find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n

      When to use: Cleanup, log rotation, temp file management. Anything where the action is the point and nobody needs to know it happened.

      Hook type: Any hook where output is irrelevant.

      Examples in ctx:

      • Log rotation, marker file cleanup, state directory maintenance

      Trade-off: None, if the action is truly invisible. If it can fail in a way that matters, consider logging.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-6-conditional-relay","level":3,"title":"Pattern 6: Conditional Relay","text":"

      Tell the agent to relay only if a condition holds in context.

      echo \"If the user's question involves modifying .context/ files,\"\necho \"relay this warning VERBATIM:\"\necho \"\"\necho \"┌─ Context Integrity ─────────────────────────────\"\necho \"│ CONSTITUTION.md has not been verified in 7 days.\"\necho \"└────────────────────────────────────────────────\"\necho \"\"\necho \"Otherwise, proceed normally.\"\n

      When to use: Warnings that only matter in certain contexts. Avoids noise when the user is doing unrelated work.

      Trade-off: Depends on the agent's judgment about when the condition holds. More fragile than VERBATIM relay, but less noisy.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-7-suggested-action","level":3,"title":"Pattern 7: Suggested Action","text":"

      Give the agent a specific command to propose to the user.

      echo \"┌─ Stale Dependencies ──────────────────────────\"\necho \"│ go.sum is 30+ days newer than go.mod.\"\necho \"│ Suggested: run \\`go mod tidy\\`\"\necho \"│ Ask the user before proceeding.\"\necho \"└───────────────────────────────────────────────\"\n

      When to use: The hook detects a fixable condition and knows the fix. Goes beyond a nudge: Gives the agent a concrete next step. The agent still asks for permission but knows exactly what to propose.

      Trade-off: The suggestion might be wrong or outdated. The \"ask the user before proceeding\" part is critical.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-8-escalating-severity","level":3,"title":"Pattern 8: Escalating Severity","text":"

      Different urgency tiers with different relay expectations.

      # INFO: agent processes silently, mentions if relevant\necho \"INFO: Last test run was 3 days ago.\"\n\n# WARN: agent should mention to user at next natural pause\necho \"WARN: 12 uncommitted changes across 3 branches.\"\n\n# CRITICAL: agent must relay immediately, before any other work\necho \"CRITICAL: Relay VERBATIM before answering. Disk usage at 95%.\"\n

      When to use: When you have multiple hooks producing output and need to avoid overwhelming the user. INFO gets absorbed, WARN gets mentioned, CRITICAL interrupts.

      Examples in ctx:

      • ctx system check-resources: Uses two tiers (WARNING/DANGER) internally but only fires the VERBATIM relay at DANGER level: WARNING is silent. See ctx system for the user-facing command that shows both tiers.

      Trade-off: Requires agent training or convention to recognize the tiers. Without a shared protocol, the prefixes are just text.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#choosing-a-pattern","level":2,"title":"Choosing a Pattern","text":"
      Is the agent about to do something forbidden?\n  └─ Yes → Hard gate\n\nDoes the user need to see this regardless of what they asked?\n  └─ Yes → VERBATIM relay\n  └─ Sometimes → Conditional relay\n\nShould the agent consider an action?\n  └─ Yes, with a specific fix → Suggested action\n  └─ Yes, open-ended → Agent directive\n\nIs this background context the agent should have?\n  └─ Yes → Silent injection\n\nIs this housekeeping?\n  └─ Yes → Silent side-effect\n
      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#design-tips","level":2,"title":"Design Tips","text":"

      Throttle aggressively: VERBATIM relays that fire every prompt will be ignored or resented. Use once-per-day markers (touch $REMINDED), adaptive frequency (every Nth prompt), or staleness checks (only fire if condition persists).

      Include actionable commands: \"You have 12 unimported sessions\" is less useful than \"You have 12 unimported sessions. Run: ctx journal import --all.\" Give the user (or agent) the exact next step.

      Use box-drawing for visual structure: The ┌─ ─┐ │ └─ ─┘ pattern makes hook output visually distinct from agent prose. It also signals \"this is machine-generated, not agent opinion.\"

      Test the silence path: Most hook runs should produce no output (the condition isn't met). Make sure the common case is fast and silent.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"

      Lessons from 19 days of hook debugging in ctx. Every one of these was encountered, debugged, and fixed in production.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#silent-misfire-wrong-key-name","level":3,"title":"Silent Misfire: Wrong Key Name","text":"
      { \"PreToolUseHooks\": [ ... ] }\n

      The key is PreToolUse, not PreToolUseHooks. Claude Code validates silently: A misspelled key means the hook is ignored with no error. Always test with a debug echo first to confirm the hook fires before adding real logic.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#json-escaping-breaks-shell-commands","level":3,"title":"JSON Escaping Breaks Shell Commands","text":"

      Go's json.Marshal escapes >, <, and & as Unicode sequences (\\u003e) by default. This breaks shell commands in generated config:

      \"command\": \"ctx agent 2\\u003e/dev/null\"\n

      Fix: use json.Encoder with SetEscapeHTML(false) when generating hook configuration.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#stdin-not-environment-variables","level":3,"title":"stdin, Not Environment Variables","text":"

      Hook input arrives as JSON via stdin, not environment variables:

      # Wrong:\nCOMMAND=\"$CLAUDE_TOOL_INPUT\"\n\n# Right:\nHOOK_INPUT=$(cat)\nCOMMAND=$(echo \"$HOOK_INPUT\" | jq -r '.tool_input.command // empty')\n
      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#regex-overfitting","level":3,"title":"Regex Overfitting","text":"

      A regex meant to catch ctx as a binary will also match ctx as a directory component:

      # Too broad: blocks: git -C /home/jose/WORKSPACE/ctx status\n(/home/|/tmp/|/var/)[^ ]*ctx[^ ]*\n\n# Narrow to binary only:\n(/home/|/tmp/|/var/)[^ ]*/ctx( |$)\n

      Test hook regexes against paths that contain the target string as a substring, not just as the final component.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#repetition-fatigue","level":3,"title":"Repetition Fatigue","text":"

      Injecting context on every tool call sounds safe. In practice, after seeing the same context injection fifteen times, the agent treats it as background noise: Conventions stated in the injected context get violated because salience has been destroyed by repetition.

      Fix: cooldowns. ctx agent --session $PPID --cooldown 10m injects at most once per ten minutes per session using a tombstone file in /tmp/. This is not an optimization; it is a correction for a design flaw. Every injection consumes attention budget: 50 tool calls at 4,000 tokens each means 200,000 tokens of repeated context, most of it wasted.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#hardcoded-paths","level":3,"title":"Hardcoded Paths","text":"

      A username rename (parallels to jose) broke every hook at once. Use $CLAUDE_PROJECT_DIR instead of absolute paths:

      \"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"/.claude/hooks/block-git-push.sh\"\n

      If the platform provides a runtime variable for paths, always use it.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#next-up","level":2,"title":"Next Up","text":"

      Webhook Notifications →: Get push notifications when loops complete, hooks fire, or agents hit milestones.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#see-also","level":2,"title":"See Also","text":"
      • Customizing Hook Messages: override what hooks say without changing what they do
      • Claude Code Permission Hygiene: how permissions and hooks work together
      • Defense in Depth: why hooks matter for agent security
      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/","level":1,"title":"Hook Sequence Diagrams","text":"","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#hook-lifecycle","level":2,"title":"Hook Lifecycle","text":"

      This page documents the ctx system hooks: the built-in ctx system * subcommands that Claude Code invokes via .claude/hooks.json at lifecycle events. These are owned by ctx itself, not authored by users.

      Not to Be Confused with ctx trigger

      ctx has three distinct hook-like layers:

      • ctx system hooks (this page): built-in, owned by ctx, wired into Claude Code via internal/assets/claude/hooks/hooks.json.
      • ctx trigger: user-authored shell scripts in .context/hooks/<type>/*.sh. See ctx trigger reference and the trigger authoring recipe.
      • Claude Code hooks configured directly in .claude/settings.local.json, tool-specific, not portable across AI tools.

      This page is only about the first category.

      Every ctx system hook is a Go binary invoked by Claude Code at one of three lifecycle events: PreToolUse (before a tool runs, can block), PostToolUse (after a tool completes), or UserPromptSubmit (on every user prompt, before any tools run). Hooks receive JSON on stdin and emit JSON or plain text on stdout.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#pretooluse-hooks","level":2,"title":"PreToolUse Hooks","text":"

      These fire before a tool executes. They can block, gate, or inject context.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#context-load-gate","level":3,"title":"Context-Load-Gate","text":"

      Matcher: .* (all tools)

      Injects the full context packet on first tool use of a session. One-shot per session.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as context-load-gate\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant Git as git log\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized\n    alt not initialized\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Check paused\n    alt paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check ctx-loaded-{session} marker\n    alt marker exists\n        Hook-->>CC: (silent exit, already fired)\n    end\n    Hook->>State: Create marker (one-shot guard)\n    Hook->>State: Prune stale session files\n    loop Each file in ReadOrder\n        alt GLOSSARY or TASK\n            Note over Hook: Skip (Task mentioned in footer only)\n        else DECISION or LEARNING\n            Hook->>Ctx: Extract index table only\n        else other files\n            Hook->>Ctx: Read full content\n        end\n        Hook->>Hook: Estimate tokens per file\n    end\n    Hook->>Git: Detect changes since last session\n    Hook->>Hook: Build injection (files + changes + token counts)\n    Hook-->>CC: JSON {additionalContext: injection}\n    Hook->>Hook: Send webhook (metadata only)\n    Hook->>State: Write oversize flag if tokens > threshold
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-non-path-ctx","level":3,"title":"Block-Non-Path-ctx","text":"

      Matcher: Bash

      Blocks ./ctx, go run ./cmd/ctx, or absolute-path ctx invocations. Constitutionally enforced.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as block-non-path-ctx\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Extract command\n    alt command empty\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Test regex: relative-path, go-run, absolute-path\n    alt no match\n        Hook-->>CC: (silent exit)\n    end\n    alt absolute-path + test exception\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, fallback)\n    Hook-->>CC: JSON {decision: BLOCK, reason + constitution suffix}\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#qa-reminder","level":3,"title":"Qa-Reminder","text":"

      Matcher: Bash

      Gate nudge before any git command. Reminds agent to lint/test.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as qa-reminder\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Check command contains \"git\"\n    alt no git command\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, gate, fallback)\n    Hook->>Hook: AppendDir(message)\n    Hook-->>CC: JSON {additionalContext: QA gate}\n    Hook->>Hook: Relay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#specs-nudge","level":3,"title":"Specs-Nudge","text":"

      Matcher: EnterPlanMode

      Nudges agent to save plans/specs when new implementation detected.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as specs-nudge\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook->>Hook: AppendDir(message)\n    Hook-->>CC: JSON {additionalContext: specs nudge}\n    Hook->>Hook: Relay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#posttooluse-hooks","level":2,"title":"PostToolUse Hooks","text":"

      These fire after a tool completes. They observe, nudge, and track state.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#post-commit","level":3,"title":"Post-Commit","text":"

      Matcher: Bash

      Fires after git commit (not amend). Nudges for context capture and checks version drift.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as post-commit\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Regex: command contains \"git commit\"?\n    alt not a git commit\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Regex: command contains \"--amend\"?\n    alt is amend\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook->>Hook: AppendDir(message)\n    Hook-->>CC: JSON {additionalContext: post-commit nudge}\n    Hook->>Hook: Relay(message)\n    Hook->>Hook: CheckVersionDrift()
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-task-completion","level":3,"title":"Check-Task-Completion","text":"

      Matcher: Edit, Write

      Configurable-interval nudge after edits. Per-session counter resets after firing.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-task-completion\n    participant State as .context/state/\n    participant RC as .ctxrc\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>RC: Read task nudge interval\n    alt interval <= 0 (disabled)\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Read per-session counter\n    Hook->>Hook: Increment counter\n    alt counter < interval\n        Hook->>State: Write counter\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Reset counter to 0\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook-->>CC: JSON {additionalContext: task nudge}\n    Hook->>Hook: Relay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#userpromptsubmit-hooks","level":2,"title":"UserPromptSubmit Hooks","text":"

      These fire on every user prompt, before any tools run. They perform health checks, track state, and nudge for housekeeping.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-context-size","level":3,"title":"Check-Context-Size","text":"

      Adaptive context window monitoring. Fires checkpoints, window warnings, and billing alerts based on prompt count and token usage.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-context-size\n    participant State as .context/state/\n    participant Session as Session JSONL\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized\n    Hook->>Hook: Read input, resolve session ID\n    Hook->>Hook: Check paused\n    alt paused\n        Hook-->>CC: Pause acknowledgment message\n    end\n    Hook->>State: Increment session prompt counter\n    Hook->>Session: Read token info (tokens, model, window)\n\n    rect rgb(255, 240, 240)\n        Note over Hook: Billing check (independent, never suppressed)\n        alt tokens >= billing threshold (one-shot)\n            Hook->>Tpl: LoadMessage(hook, billing, vars)\n            Hook-->>CC: Billing warning nudge box\n            Hook->>Hook: NudgeAndRelay(billing message)\n        end\n    end\n\n    Hook->>State: Check wrap-up marker\n    alt wrapped up recently (< 2h)\n        Hook->>State: Write stats (event: suppressed)\n        Hook-->>CC: (silent exit)\n    end\n\n    rect rgb(240, 248, 255)\n        Note over Hook: Adaptive frequency check\n        alt count > 30 and count % 3 == 0\n            Note over Hook: High frequency trigger\n        else count > 15 and count % 5 == 0\n            Note over Hook: Medium frequency trigger\n        else\n            Hook->>State: Write stats (event: silent)\n            Hook-->>CC: (silent exit)\n        end\n    end\n\n    alt context window >= 80%\n        Hook->>Tpl: LoadMessage(hook, window, vars)\n        Hook-->>CC: Window warning nudge box\n        Hook->>Hook: NudgeAndRelay(window message)\n    else checkpoint trigger\n        Hook->>Tpl: LoadMessage(hook, checkpoint)\n        Hook-->>CC: Checkpoint nudge box\n        Hook->>Hook: NudgeAndRelay(checkpoint message)\n    end\n    Hook->>State: Write session stats
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-ceremonies","level":3,"title":"Check-Ceremonies","text":"

      Daily check for /ctx-remember and /ctx-wrap-up usage in recent journal entries.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-ceremonies\n    participant State as .context/state/\n    participant Journal as Journal files\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Read recent files (lookback window)\n    alt no journal files\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Scan for /ctx-remember and /ctx-wrap-up\n    alt both ceremonies present\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, fallback)\n    Note over Hook: variant: both | remember | wrapup\n    Hook-->>CC: Nudge box (missing ceremonies)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-freshness","level":3,"title":"Check-Freshness","text":"

      Daily check for technology-dependent constants that may need review.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-freshness\n    participant State as .context/state/\n    participant FS as Filesystem\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>FS: Stat tracked files (5 source files)\n    alt all files modified within 6 months\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, stale, {StaleFiles})\n    Hook-->>CC: Nudge box (stale file list + review URL)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-journal","level":3,"title":"Check-Journal","text":"

      Daily check for unimported sessions and unenriched journal entries.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-journal\n    participant State as .context/state/\n    participant Journal as Journal dir\n    participant Claude as Claude projects dir\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Check dir exists\n    Hook->>Claude: Check dir exists\n    alt either dir missing\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Get newest entry mtime\n    Hook->>Claude: Count .jsonl files newer than journal\n    Hook->>Journal: Count unenriched entries\n    alt unimported == 0 and unenriched == 0\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, {counts})\n    Note over Hook: variant: both | unimported | unenriched\n    Hook-->>CC: Nudge box (counts)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-knowledge","level":3,"title":"Check-Knowledge","text":"

      Daily check for knowledge file entry/line counts exceeding configured thresholds.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-knowledge\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant RC as .ctxrc\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>RC: Read thresholds (decisions, learnings, conventions)\n    alt all thresholds disabled (0)\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Ctx: Parse DECISIONS.md entry count\n    Hook->>Ctx: Parse LEARNINGS.md entry count\n    Hook->>Ctx: Count CONVENTIONS.md lines\n    Hook->>Hook: Compare against thresholds\n    alt all within limits\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, warning, {FileWarnings})\n    Hook-->>CC: Nudge box (file warnings)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-map-staleness","level":3,"title":"Check-Map-Staleness","text":"

      Daily check for architecture map age and relevant code changes.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-map-staleness\n    participant State as .context/state/\n    participant Tracking as map-tracking.json\n    participant Git as git log\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tracking: Read map-tracking.json\n    alt missing, invalid, or opted out\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Parse LastRun date\n    alt map not stale (< N days)\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Git: Count commits touching internal/ since LastRun\n    alt no relevant commits\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, stale, {date, count})\n    Hook-->>CC: Nudge box (last refresh + commit count)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-memory-drift","level":3,"title":"Check-Memory-Drift","text":"

      Per-session check for MEMORY.md changes since last sync.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-memory-drift\n    participant State as .context/state/\n    participant Mem as memory.Discover\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check session tombstone\n    alt already nudged this session\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Mem: DiscoverMemoryPath(projectRoot)\n    alt auto memory not active\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Mem: HasDrift(contextDir, sourcePath)\n    alt no drift\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook-->>CC: Nudge box (drift reminder)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch session tombstone
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-persistence","level":3,"title":"Check-Persistence","text":"

      Tracks context file modification and nudges when edits happen without persisting context. Adaptive threshold based on prompt count.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-persistence\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Read persistence state {Count, LastNudge, LastMtime}\n    alt first prompt (no state)\n        Hook->>State: Initialize state {Count:1, LastNudge:0, LastMtime:now}\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Increment Count\n    Hook->>Ctx: Get current context mtime\n    alt context modified since LastMtime\n        Hook->>State: Reset LastNudge = Count, update LastMtime\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: sinceNudge = Count - LastNudge\n    Hook->>Hook: PersistenceNudgeNeeded(Count, sinceNudge)?\n    alt threshold not reached\n        Hook->>State: Write state\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, vars)\n    Hook-->>CC: Nudge box (prompt count, time since last persist)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Update LastNudge = Count, write state
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-reminders","level":3,"title":"Check-Reminders","text":"

      Per-prompt check for due reminders. No throttle.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-reminders\n    participant Store as Reminders store\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Store: ReadReminders()\n    alt load error\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Filter by due date (After <= today)\n    alt no due reminders\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, reminders, {list})\n    Hook-->>CC: Nudge box (reminder list + dismiss hints)\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-resources","level":3,"title":"Check-Resources","text":"

      Checks system resources (memory, swap, disk, load). Fires on every prompt. No initialization required.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-resources\n    participant Sys as sysinfo\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: HookPreamble (parse input, check pause)\n    alt paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Sys: Collect snapshot (memory, swap, disk, load)\n    Hook->>Sys: Evaluate thresholds per metric\n    alt max severity < Danger\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Filter alerts to Danger level only\n    Hook->>Hook: Build alertMessages from danger alerts\n    Hook->>Tpl: LoadMessage(hook, alert, {alertMessages}, fallback)\n    Hook-->>CC: Nudge box (danger alerts)\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-version","level":3,"title":"Check-Version","text":"

      Daily binary-vs-plugin version comparison with piggybacked key rotation check.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-version\n    participant State as .context/state/\n    participant Config as Binary + Plugin version\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Config: Read binary version\n    alt dev build\n        Hook->>State: Touch throttle\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Config: Read plugin version\n    alt plugin version not found or parse error\n        Hook->>State: Touch throttle\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Compare major.minor\n    alt versions match\n        Hook->>State: Touch throttle\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, mismatch, {versions})\n    Hook-->>CC: Nudge box (version mismatch)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle\n    Hook->>Hook: CheckKeyAge() (piggybacked)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#heartbeat","level":3,"title":"Heartbeat","text":"

      Silent per-prompt pulse. Tracks prompt count, context modification, and token usage. The agent never sees this hook's output.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as heartbeat\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant Notify as Webhook + EventLog\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Increment heartbeat counter\n    Hook->>Ctx: Get latest context file mtime\n    Hook->>State: Compare with last recorded mtime\n    Hook->>State: Update mtime record\n    Hook->>State: Read session token info\n    Hook->>Notify: Send heartbeat notification\n    Hook->>Notify: Append to event log\n    Hook->>State: Write heartbeat log entry\n    Note over Hook: No stdout - agent never sees this
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#project-local-hooks","level":2,"title":"Project-Local Hooks","text":"

      These hooks are configured in settings.local.json and are not shipped with ctx. They are specific to individual developer setups.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-dangerous-commands","level":3,"title":"Block-Dangerous-Commands","text":"

      Lifecycle: PreToolUse. Matcher: Bash

      Blocks dangerous shell patterns (sudo, git push, cp to bin). No initialization or pause checks: always active.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as block-dangerous-commands\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Extract command\n    alt command empty\n        Hook-->>CC: (silent exit)\n    end\n    Note over Hook: Cascade: first matching regex wins\n    Hook->>Hook: Test MidSudo regex\n    alt match\n        Hook->>Hook: variant = sudo\n    end\n    Hook->>Hook: Test MidGitPush regex (if no variant)\n    alt match\n        Hook->>Hook: variant = git-push\n    end\n    Hook->>Hook: Test CpMvToBin regex (if no variant)\n    alt match\n        Hook->>Hook: variant = cp-to-bin\n    end\n    Hook->>Hook: Test InstallToLocalBin regex (if no variant)\n    alt match\n        Hook->>Hook: variant = install-to-bin\n    end\n    alt no variant matched\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, fallback)\n    Hook-->>CC: JSON {decision: BLOCK, reason}\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#throttling-summary","level":2,"title":"Throttling Summary","text":"Hook Lifecycle Throttle Type Scope context-load-gate PreToolUse One-shot marker Per session block-non-path-ctx PreToolUse None Every match qa-reminder PreToolUse None Every git command specs-nudge PreToolUse None Every prompt post-commit PostToolUse None Every git commit check-task-completion PostToolUse Configurable interval Per session check-context-size UserPromptSubmit Adaptive counter Per session check-ceremonies UserPromptSubmit Daily marker Once per day check-freshness UserPromptSubmit Daily marker Once per day check-journal UserPromptSubmit Daily marker Once per day check-knowledge UserPromptSubmit Daily marker Once per day check-map-staleness UserPromptSubmit Daily marker Once per day check-memory-drift UserPromptSubmit Session tombstone Once per session check-persistence UserPromptSubmit Adaptive counter Per session check-reminders UserPromptSubmit None Every prompt check-resources UserPromptSubmit None Every prompt check-version UserPromptSubmit Daily marker Once per day heartbeat UserPromptSubmit None Every prompt block-dangerous-commands PreToolUse * None Every match

      * Project-local hook (settings.local.json), not shipped with ctx.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#state-file-reference","level":2,"title":"State File Reference","text":"

      All state files live in .context/state/.

      File Pattern Hook Purpose ctx-loaded-{session} context-load-gate One-shot injection marker ctx-paused-{session} (all) Session pause marker ctx-wrapped-up check-context-size Suppress nudges after wrap-up (2h expiry) freshness-checked check-freshness Daily throttle ceremony-reminded check-ceremonies Daily throttle journal-reminded check-journal Daily throttle knowledge-reminded check-knowledge Daily throttle map-staleness-reminded check-map-staleness Daily throttle version-checked check-version Daily throttle memory-drift-nudged-{session} check-memory-drift Per-session tombstone ctx-context-count-{session} check-context-size Prompt counter stats-{session}.jsonl check-context-size Session stats log persist-{session} check-persistence Counter + mtime state ctx-task-count-{session} check-task-completion Prompt counter heartbeat-count-{session} heartbeat Prompt counter heartbeat-mtime-{session} heartbeat Last context mtime","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hub-cluster/","level":1,"title":"HA Cluster","text":"","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#ctx-hub-high-availability-cluster","level":1,"title":"ctx Hub: High-Availability Cluster","text":"

      Run multiple hub nodes with Raft-based leader election for redundancy. Any follower can take over if the leader dies.

      This recipe assumes you've read the ctx Hub overview and the Multi-machine setup. HA only makes sense in the \"small trusted team\" story; a personal cross-project brain on one workstation does not need three Raft peers.

      Raft-Lite

      ctx uses Raft only for leader election, not for data consensus. Entry replication happens via sequence-based gRPC sync on the append-only JSONL store. This is simpler than full Raft log replication and is possible because the store is append-only and clients are idempotent. The implication: a write accepted by the leader is durable on the leader immediately; followers catch up asynchronously. If the leader crashes between accepting a write and replicating it, that write can be lost. Do not use the hub as a bank ledger.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#topology","level":2,"title":"Topology","text":"

      A minimum HA cluster is three nodes. Two is worse than one: it doubles failure probability without providing quorum.

               +-------------+\n         |  client(s)  |\n         +------+------+\n                |\n    +-----------+-----------+\n    |           |           |\n+---v---+   +---v---+   +---v---+\n| hub A |   | hub B |   | hub C |\n| :9900 |   | :9900 |   | :9900 |\n+-------+   +-------+   +-------+\n    ^           ^           ^\n    +-----------+-----------+\n        Raft (leader election)\n        gRPC (data sync)\n
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-1-bootstrap-the-first-node","level":2,"title":"Step 1: Bootstrap the First Node","text":"
      ctx hub start --daemon \\\n  --port 9900 \\\n  --peers hub-b.lan:9900,hub-c.lan:9900\n

      The node starts a Raft election as soon as it sees its peers.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-2-start-the-other-nodes","level":2,"title":"Step 2: Start the Other Nodes","text":"

      On hub-b.lan:

      ctx hub start --daemon \\\n  --port 9900 \\\n  --peers hub-a.lan:9900,hub-c.lan:9900\n

      On hub-c.lan:

      ctx hub start --daemon \\\n  --port 9900 \\\n  --peers hub-a.lan:9900,hub-b.lan:9900\n

      After a few seconds, one node wins the election and becomes the leader. The other two are followers.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-3-verify-cluster-state","level":2,"title":"Step 3: Verify Cluster State","text":"

      From any node:

      ctx hub status\n

      Expected output:

      role:       leader\npeers:      hub-a.lan:9900 (leader)\n            hub-b.lan:9900 (follower, in-sync)\n            hub-c.lan:9900 (follower, in-sync)\nentries:    1248\nuptime:     3h42m\n
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-4-register-clients-with-failover-peers","level":2,"title":"Step 4: Register Clients with Failover Peers","text":"

      The ctx hub * commands above run on the hub nodes themselves and don't need a project. The ctx connection * commands below are different: they live inside a project (the encrypted hub config is stored at .context/.connect.enc), so you have to tell ctx which project first.

      When registering a client, give it the full peer list:

      # In the project directory on the client:\neval \"$(ctx activate)\"\nctx connection register hub-a.lan:9900 \\\n  --token ctx_adm_... \\\n  --peers hub-b.lan:9900,hub-c.lan:9900\n

      If the leader becomes unreachable, the client reconnects to the next peer. Followers redirect to the current leader, so writes always land on the right node.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#runtime-membership-changes","level":2,"title":"Runtime Membership Changes","text":"

      Add a new peer without downtime:

      ctx hub peer add hub-d.lan:9900\n

      Remove a decommissioned peer:

      ctx hub peer remove hub-c.lan:9900\n
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#planned-maintenance","level":2,"title":"Planned Maintenance","text":"

      Before taking a leader offline, hand off leadership:

      ssh hub-a.lan 'ctx hub stepdown'\n

      stepdown triggers a new election among the remaining followers before the leader goes offline. In-flight clients briefly pause, then reconnect to the new leader.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#failure-modes-at-a-glance","level":2,"title":"Failure Modes at a Glance","text":"Event What happens Leader crashes New election; clients reconnect to new leader Follower crashes No write impact; catches up on restart Network partition (majority) Majority side keeps serving; minority read-only Network partition (split) No quorum; all nodes read-only Disk full on leader Writes rejected; read traffic continues

      For the full list, see Hub failure modes.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#see-also","level":2,"title":"See Also","text":"
      • Multi-machine recipe: single-node deployment
      • Hub operations: backup and maintenance
      • Hub security model: TLS, tokens
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-getting-started/","level":1,"title":"Getting Started","text":"","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#ctx-hub-getting-started","level":1,"title":"ctx Hub: Getting Started","text":"

      Stand up a single-node ctx Hub on localhost, register two projects, publish a decision from one, and see it appear in the other, all in under five minutes.

      Read This First

      If you haven't already, skim the ctx Hub overview. It explains the mental model, names the two user stories (personal vs small team), and (importantly) lists what the hub does not do. This recipe assumes you already know you want the feature.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#what-youll-get-out-of-this-recipe","level":2,"title":"What You'll Get out of This Recipe","text":"

      By the end, you will have:

      1. A local hub process running on port 9900.
      2. Two project directories both registered with the ctx Hub.
      3. A decision published from project alpha that appears automatically in project beta's .context/hub/ and in ctx agent --include-hub output.

      Concretely, the payoff this unlocks: a lesson you record in one project becomes visible to your agent the next time you open another project, without touching local files in the second project or opening another editor window.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#what-this-recipe-does-not-cover","level":2,"title":"What This Recipe Does Not Cover","text":"
      • Sharing .context/journal/, .context/pad, or any other local state. The hub only fans out decision, learning, convention, and task entries. Everything else stays local.
      • Multi-user attribution. The hub identifies projects, not people.
      • Running over a LAN; see Multi-machine setup.
      • Redundancy; see HA cluster.
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#prerequisites","level":2,"title":"Prerequisites","text":"
      • ctx installed and on PATH
      • Two project directories, each already initialized with ctx init
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-1-start-the-hub","level":2,"title":"Step 1: Start the Hub","text":"

      In a dedicated terminal:

      ctx hub start\n

      On first run, the hub generates an admin token and prints it to stdout. Copy it; you'll need it for each project registration:

      ctx hub listening on :9900\nadmin token: ctx_adm_7f3a1c2d...\ndata dir: ~/.ctx/hub-data/\n

      The admin token is written to ~/.ctx/hub-data/admin.token so you can recover it later. Treat it like a password.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-2-register-the-first-project","level":2,"title":"Step 2: Register the First Project","text":"

      ctx hub start above runs on the hub server and doesn't need a project. Step 2 is different: the encrypted hub config is stored inside a project at .context/.connect.enc, so you have to tell ctx which project first.

      cd ~/projects/alpha\neval \"$(ctx activate)\"\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\n

      This stores an encrypted connection config in .context/.connect.enc. The admin token is exchanged for a per-project client token; the admin token itself is never persisted in the project.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-3-choose-what-to-receive","level":2,"title":"Step 3: Choose What to Receive","text":"
      ctx connection subscribe decision learning convention\n

      Only the entry types you subscribe to will be delivered by sync and listen.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-4-publish-a-decision","level":2,"title":"Step 4: Publish a Decision","text":"

      Either use ctx add --share to write locally and push to the ctx Hub:

      ctx add decision \"Use UTC timestamps everywhere\" --share \\\n  --context \"We had timezone drift between the API and journal\" \\\n  --rationale \"Single source of truth avoids conversion bugs\" \\\n  --consequence \"The UI does conversion at render time\"\n

      Or publish an existing entry directly:

      ctx connection publish decision \"Use UTC timestamps everywhere\"\n
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-5-register-a-second-project-and-sync","level":2,"title":"Step 5: Register a Second Project and Sync","text":"
      cd ~/projects/beta\neval \"$(ctx activate)\"   # bind CTX_DIR for this project\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\nctx connection subscribe decision learning convention\nctx connection sync\n

      The decision from alpha now appears in ~/projects/beta/.context/hub/decisions.md with an origin tag and timestamp.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-6-watch-entries-arrive-live","level":2,"title":"Step 6: Watch Entries Arrive Live","text":"

      Instead of re-running sync, stream new entries as they land:

      ctx connection listen\n

      Leave this running in a terminal; every --share publish from any registered project will appear in .context/hub/ immediately.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-7-feed-shared-knowledge-into-the-agent","level":2,"title":"Step 7: Feed Shared Knowledge into the Agent","text":"

      Once entries exist in .context/hub/, include them in the agent context packet:

      ctx agent --include-hub\n

      Shared entries are added as a dedicated tier in the budget-aware assembly, scored by recency and type relevance.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#auto-sync-on-session-start","level":2,"title":"Auto-Sync on Session Start","text":"

      After register, the check-hub-sync hook pulls new entries at the start of each session (daily throttled). Most users never need to call ctx connection sync manually.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#where-to-go-next","level":2,"title":"Where to Go Next","text":"
      • Multi-machine hub: run the hub on a LAN host and connect from other workstations.
      • HA cluster: Raft-based leader election for high availability.
      • Hub operations: daemon mode, backup, log rotation, JSONL store layout.
      • Hub security model: token lifecycle, encryption at rest, threat model.
      • ctx connect reference and ctx hub start reference.
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-multi-machine/","level":1,"title":"Multi-Machine","text":"","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#ctx-hub-multi-machine","level":1,"title":"ctx Hub: Multi-Machine","text":"

      Run the hub on a LAN host and connect from project directories on other workstations. This recipe is the Story 2 (\"small trusted team\") shape described in the ctx Hub overview; read that first if you haven't, especially the trust-model warnings.

      This recipe assumes you've already walked through Getting Started and understand what flows through the hub (decisions, learnings, conventions, tasks, not journals, scratchpad, or raw context files).

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#topology","level":2,"title":"Topology","text":"
      +------------------+        +------------------+\n| workstation A    |        | workstation B    |\n|  ~/projects/x    |        |  ~/projects/y    |\n|  ctx connection  |        |  ctx connection  |\n+---------+--------+        +---------+--------+\n          |                           |\n          +-----------+   +-----------+\n                      v   v\n              +-------------------+\n              | LAN host \"nexus\"  |\n              | ctx hub start     |\n              | --daemon          |\n              | :9900             |\n              +-------------------+\n
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-1-start-the-daemon-on-the-lan-host","level":2,"title":"Step 1: Start the Daemon on the LAN Host","text":"

      On the machine that will hold the hub (call it nexus):

      ctx hub start --daemon --port 9900\n

      The daemon writes a PID file to ~/.ctx/hub-data/hub.pid. Stop it later with:

      ctx hub stop\n
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-2-firewall-and-port","level":2,"title":"Step 2: Firewall and Port","text":"

      Open port 9900/tcp on nexus to the LAN only. Never expose the hub to the public internet without a reverse proxy and TLS in front of it (see Hub security model).

      Typical LAN allowlist rules:

      firewalldufwnftables
      sudo firewall-cmd --zone=internal \\\n  --add-port=9900/tcp --permanent\nsudo firewall-cmd --reload\n
      sudo ufw allow from 192.168.1.0/24 to any port 9900 proto tcp\n
      sudo nft add rule inet filter input ip saddr 192.168.1.0/24 \\\n  tcp dport 9900 accept\n
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-3-retrieve-the-admin-token","level":2,"title":"Step 3: Retrieve the Admin Token","text":"

      The daemon prints the admin token to stdout on first run. Running as a daemon, that output goes to the log instead:

      cat ~/.ctx/hub-data/admin.token\n

      Copy the token over a trusted channel (SSH, password manager, or an encrypted note). Do not email it or put it in chat.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-4-register-projects-from-each-workstation","level":2,"title":"Step 4: Register Projects from Each Workstation","text":"

      The ctx hub * commands above run on the LAN host (nexus) and don't need a project. Step 4 is different: each workstation registers from inside a project (the encrypted hub config and the fan-out inbox both live under .context/), so you have to tell ctx which project first.

      On workstation A:

      cd ~/projects/x\neval \"$(ctx activate)\"\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n

      On workstation B:

      cd ~/projects/y\neval \"$(ctx activate)\"\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n

      Each registration exchanges the admin token for a per-project client token. Only the client token is persisted in .context/.connect.enc, encrypted with the same AES-256-GCM scheme ctx uses for notification credentials.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-5-verify","level":2,"title":"Step 5: Verify","text":"

      From either workstation:

      ctx connection status\n

      You should see the ctx Hub address, role (leader for single-node), subscription filters, and the sequence number you're synced to.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#tls-recommended","level":2,"title":"TLS (Recommended)","text":"

      For anything beyond a trusted home LAN, terminate TLS in front of the hub. The hub speaks gRPC, so the reverse proxy must speak HTTP/2:

      server {\n    listen 443 ssl http2;\n    server_name nexus.example.com;\n\n    ssl_certificate     /etc/letsencrypt/live/nexus.example.com/fullchain.pem;\n    ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;\n\n    location / {\n        grpc_pass grpc://127.0.0.1:9900;\n    }\n}\n

      Point ctx connection register at the public hostname and port 443.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#handling-daemon-restarts","level":2,"title":"Handling Daemon Restarts","text":"

      The hub is append-only JSONL, so restarts are safe. Clients keep their last-seen sequence in .context/hub/.sync-state.json and pick up exactly where they left off on the next sync or listen reconnect.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#see-also","level":2,"title":"See Also","text":"
      • HA cluster recipe: for redundancy
      • Hub operations: backup, rotation
      • Hub failure modes
      • Hub security model
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-overview/","level":1,"title":"Overview","text":"","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#ctx-hub-overview","level":1,"title":"ctx Hub: Overview","text":"

      Start here before the other hub recipes. This page answers what the hub is, who it's for, why you'd run one, and, equally important, what it is not.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#mental-model-in-one-paragraph","level":2,"title":"Mental Model in One Paragraph","text":"

      The hub is a fan-out channel for structured knowledge entries across projects. When you publish a decision, learning, convention, or task with --share, the hub stores it in an append-only log and delivers it to every other project subscribed to that type. The next time your agent loads context in any of those projects, shared entries can be included in the context packet alongside local ones.

      That's the whole feature. It is a project-to-project knowledge bus for a small, curated set of entry types. It is not a shared memory, a shared journal, or a multi-user database.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#what-flows-through-the-hub","level":2,"title":"What Flows through the Hub","text":"

      Only four entry types:

      Type What it is decision Architectural decisions with rationale learning Gotchas, lessons, surprising behaviors convention Coding patterns and standards task Work items worth sharing across projects

      Each entry is an immutable record with a content blob, the publishing project's name as Origin, a timestamp, and a hub-assigned sequence number. Once published, entries are never rewritten.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#what-does-not-flow-through-the-hub","level":2,"title":"What Does Not Flow through the Hub","text":"

      This is the part new users get wrong most often:

      • Session journals (~/.claude/ logs, .context/journal/) stay local. The hub does not sync your AI session history.
      • Scratchpad (.context/pad) stays local. Encrypted notes never leave the machine they were written on.
      • Local context files as a whole (TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md) are not mirrored wholesale. Only entries you explicitly --share, or publish later with ctx connection publish, cross the boundary.
      • Anything under .context/ that isn't one of the four entry types above. Configuration, state, logs, memory, journal metadata: all local.

      If you were expecting \"now my agent in project B can see everything my agent did in project A,\" that's not this feature. Local session density still lives on the local machine.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#two-user-stories","level":2,"title":"Two User Stories","text":"

      The hub makes sense in two different shapes. Pick the one that matches your situation; the mechanics are identical but the trust model and threat surface are very different.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#story-1-personal-cross-project-brain","level":3,"title":"Story 1: Personal Cross-Project Brain","text":"

      One developer, many projects, one hub, usually on localhost.

      You're working across several projects on the same machine (or a handful of machines you own). You want a lesson learned debugging project A to show up when you open project B a week later, without re-discovering it. You want a convention you codified in one project to be visible as-you-type in another.

      Concrete payoff:

      • ctx add learning --share \"...\" in project A → ctx agent --include-hub in project B shows that learning in the next context packet.
      • A decision recorded in your personal \"dotfiles\" project is instantly visible to every other project on your workstation.
      • Cross-project conventions (e.g., \"use UTC timestamps everywhere\") live in one place and propagate.

      Trust model: high, because you trust every participant since every participant is you. Run the hub on localhost or on your own LAN, use the default single-node setup, don't worry about TLS.

      Start here: Getting Started for the one-time setup, then Personal cross-project brain for the day-to-day workflow.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#story-2-small-trusted-team","level":3,"title":"Story 2: Small Trusted Team","text":"

      A few teammates, projects they each own, one hub on a LAN host they all trust.

      Your team has a handful of services and you want a shared \"things we've learned the hard way\" stream. Someone on the platform team records a convention about timestamp handling; everyone else's agents see it the next session. An on-call engineer records a learning from a 3 AM incident; the rest of the team inherits the lesson without needing to read the postmortem.

      Concrete payoff:

      • Team conventions propagate without needing a wiki or chat.
      • Lessons from one team member become available to everyone else's agent context packets automatically.
      • Cross-project decisions (shared libraries, deployment patterns, naming rules) live in a single log the whole team reads.

      Trust model: the hub assumes everyone holding a client token is friendly. There is no per-user attribution you can rely on, Origin is self-asserted by the publishing client, and there is no read ACL beyond the subscription filter. Treat the hub like a team wiki: useful because everyone can write to it, not because it can prove who wrote what.

      Operational shape: run the hub on a LAN host (or a three-node HA cluster for redundancy), put TLS in front of it for anything beyond a home LAN, distribute client tokens over a trusted channel.

      Start here: Multi-machine setup for the deployment, Team knowledge bus for the day-to-day team workflow, then HA cluster if you need redundancy.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#identity-projects-not-users","level":2,"title":"Identity: Projects, Not Users","text":"

      The hub has no concept of users. Its unit of identity is the project. ctx connection register binds a hub token to a project directory, not to a person. Two developers working on the same project share either:

      • The same .connect.enc, copied between machines over a trusted channel, or
      • Different project names (alpha@laptop-a, alpha@laptop-b), because the hub rejects duplicate registrations of the same project name.

      Either works; neither gives you per-human attribution. If you need \"who wrote this,\" the hub is the wrong tool.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#when-not-to-use-it","level":2,"title":"When Not to Use It","text":"
      • Solo, single-project work. Local .context/ files are enough. The hub adds operational surface for no payoff.
      • Untrusted participants. The hub assumes everyone with a client token is friendly. It is not hardened against hostile insiders or compromised tokens.
      • Compliance-sensitive environments. There is no audit trail that can prove who published what, only which project published what, and Origin is self-asserted.
      • Secrets or PII. Entry content is stored plaintext on the hub and fanned out to every subscribed client. Don't publish anything you wouldn't paste in a team chat.
      • Wholesale journal sharing. See \"what does not flow\" above. If that's what you want, this feature won't provide it. Talk to us in the issue tracker about what would.
      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#how-entries-reach-your-agent","level":2,"title":"How Entries Reach Your Agent","text":"

      Once a project is registered and subscribed, entries arrive by three mechanisms:

      1. ctx connection sync: an on-demand pull, replays everything new since the last sequence you saw.
      2. ctx connection listen: a long-lived gRPC stream that writes new entries to .context/hub/ as they arrive.
      3. check-hub-sync hook: runs at session start, daily throttled, so most users never call sync manually.

      Once entries exist in .context/hub/, ctx agent --include-hub adds a dedicated tier to the budget-aware context packet, scored by recency and type relevance. That's the end of the pipeline.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#where-to-go-next","level":2,"title":"Where to Go Next","text":"If you're… Read Trying it for yourself on one machine Getting Started A solo developer using the hub day-to-day Personal cross-project brain Setting up for a small team on a LAN Multi-machine setup A small team using the hub day-to-day Team knowledge bus Running redundant nodes HA cluster Operating a hub in production Operations Assessing the security posture Security model Debugging a hub in trouble Failure modes Just reading the commands ctx connect, ctx serve, ctx hub","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-personal/","level":1,"title":"Personal Cross-Project Brain","text":"","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#personal-cross-project-brain","level":1,"title":"Personal Cross-Project Brain","text":"

      This recipe shows how one developer uses a ctx Hub across their own projects day-to-day, the \"Story 1\" shape from the Hub overview. You're not setting up infrastructure for a team; you're making a lesson you learned last Tuesday in project A automatically surface when you open project B next Thursday.

      Prerequisites: a working ctx Hub on localhost (see Getting Started for the roughly five-minute setup). This recipe assumes the hub is already running and you've registered at least two projects.

      Activate Each Project First

      Run eval \"$(ctx activate)\" after each cd <project> (or wire it into direnv). The hub server (ctx hub start, etc.) runs on the server and doesn't need this; the commands in this recipe (ctx add --share, ctx agent --include-hub, ctx connection ...) live inside a project and do. If you skip the eval, they'll fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#the-core-loop","level":2,"title":"The Core Loop","text":"

      Every day, the same three verbs matter:

      1. Record: notice a decision, learning, or convention and capture it with ctx add --share.
      2. Subscribe: every project you care about is subscribed to the types you want delivered (set once with ctx connection subscribe).
      3. Load: your agent picks up shared entries on next session start via the auto-sync hook, or explicitly via ctx agent --include-hub.

      That's the whole workflow. The rest of this recipe fills in the concrete moments where each verb matters.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#a-realistic-day","level":2,"title":"A Realistic Day","text":"

      You have three projects on your workstation:

      • ~/projects/api, a Go service you're actively developing
      • ~/projects/cli, a companion CLI that consumes the API
      • ~/projects/dotfiles, your personal conventions and cross-project learnings

      All three are registered with a single hub running on localhost:9900 (started once at boot, or via a systemd user unit; see Hub operations). All three subscribe to decision, learning, and convention.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#0900-start-work-on-api","level":3,"title":"09:00 - Start Work on api","text":"

      You cd ~/projects/api and start a Claude Code session. Behind the scenes, the plugin's PreToolUse hook calls ctx agent --budget 8000 --include-hub before the first tool call. Agent loads:

      • Local .context/ (TASKS, DECISIONS, LEARNINGS, etc.)
      • Foundation steering files (always-inclusion)
      • Everything you've shared from the other two projects

      So the \"use UTC timestamps everywhere\" decision you recorded in dotfiles last week is already in Claude's context for this session, without any manual sync.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1030-you-discover-a-gotcha","level":3,"title":"10:30 - You Discover a Gotcha","text":"

      While debugging, you find that the API's retry loop silently drops the last error when the transport times out. This is the kind of thing you'd normally add to LEARNINGS.md in api/. But it's useful across every Go service you'll ever write, not just this one. So:

      ctx add learning --share \\\n  --context \"Go http.Client retries mask the final error\" \\\n  --lesson  \"Transport timeouts don't surface as errors when the retry loop re-assigns err without wrapping. Check for context.DeadlineExceeded on the request context instead.\" \\\n  --application \"Any retry loop over http.Client.Do that uses a per-attempt timeout\"\n

      The --share flag does two things:

      1. Writes the learning to api/.context/LEARNINGS.md locally (as a normal ctx add learning would).
      2. Publishes the same entry to the ctx Hub, which stores it in the append-only JSONL and fans it out to every subscribed client.

      Within seconds, cli/.context/hub/learnings.md and dotfiles/.context/hub/learnings.md both contain a copy of this learning (the ctx connection listen daemon picks it up from the ctx Hub's Listen stream).

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1200-you-switch-to-cli","level":3,"title":"12:00 - You Switch to cli","text":"

      cd ~/projects/cli, open a new session. The agent packet for cli now includes the learning you just recorded in api, because cli is subscribed to learning and the entry has already been synced into cli/.context/hub/learnings.md.

      You don't have to re-explain the retry-loop gotcha. Claude already sees it.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1400-you-codify-a-convention","level":3,"title":"14:00 - You Codify a Convention","text":"

      You've been writing error messages in api and decided you want a consistent pattern: lowercase start, no trailing period, single-sentence. This is a convention, not a decision; it applies to every Go project you touch. Record it in dotfiles (since that's your \"personal standards\" project), and share it:

      cd ~/projects/dotfiles\nctx add convention --share \\\n  \"Error messages: lowercase start, no trailing period, single sentence (follows Go's stdlib style)\"\n

      The convention lands in dotfiles/CONVENTIONS.md locally and fans out to api and cli via the hub. The next Claude Code session in either project gets the convention injected into the steering-adjacent slot of the agent packet.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1630-end-of-day","level":3,"title":"16:30 - End of Day","text":"

      You didn't run ctx connection sync once. You didn't git push anything between projects. You didn't remember to tell your agent about the retry-loop gotcha in the new project. The hub did all of it for you.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#what-the-workflow-actually-looks-like","level":2,"title":"What the Workflow Actually Looks Like","text":"

      Stripped of prose, the day's commands were:

      # Morning: nothing. Agent loads --include-hub automatically.\n\n# Mid-morning: record a learning that should cross projects\nctx add learning --share \\\n  --context \"...\" --lesson \"...\" --application \"...\"\n\n# Afternoon: codify a convention in the \"standards\" project\nctx add convention --share \"...\"\n\n# Evening: nothing. Everything's already propagated.\n

      The hub is passive infrastructure. You never talk to it directly; you talk through it by using --share on commands you were already running.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#tips-for-solo-use","level":2,"title":"Tips for Solo Use","text":"

      Pick a \"standards\" project. One of your projects should play the role of \"canonical source for rules you want everywhere.\" Your dotfiles, a personal scratch repo, or a dedicated ctx-standards project all work. Record cross-cutting conventions there and let the hub propagate them to everything else.

      Subscribe to task only if you want cross-project todos. The four subscribable types are decision, learning, convention, task. Tasks are usually project-local; subscribing makes every hub-shared task from every project show up in every other project's agent packet. That's probably not what you want. Skip task in ctx connection subscribe unless you have a specific reason.

      Run the hub as a user-level daemon so you don't have to remember to start it. On Linux with systemd:

      # ~/.config/systemd/user/ctx-hub.service\n[Unit]\nDescription=ctx Hub (personal)\n\n[Service]\nType=simple\nExecStart=/usr/local/bin/ctx hub start\nRestart=on-failure\n\n[Install]\nWantedBy=default.target\n
      systemctl --user enable --now ctx-hub.service\n

      Don't overthink subscription filters. For personal use, subscribe every project to all four types at first (or three, if you skip task). Tune later if the context packets get noisy.

      Local storage is fine; no TLS needed. The hub runs on localhost. No one else is on the network. Skip the TLS setup from the Multi-machine recipe; it's relevant when the hub is on a LAN host serving multiple workstations, not when it's a personal daemon.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#what-this-recipe-is-not","level":2,"title":"What This Recipe Is Not","text":"

      Not a setup guide. For the one-time hub install and project registration, use Getting Started.

      Not a team guide. If you're sharing across humans, not just across your own projects, read Team knowledge bus instead; the trust model and operational concerns are different.

      Not production operations. For backup, log rotation, failure recovery, and HA, see Hub operations and Hub failure modes.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#see-also","level":2,"title":"See Also","text":"
      • Hub overview: when to use the Hub and when not to.
      • Team knowledge bus: the multi-human companion recipe.
      • ctx connect: the client-side commands used above (subscribe, publish, sync, listen, status).
      • ctx add: the --share flag reference.
      • ctx hub: operator commands for starting, stopping, and inspecting the hub.
      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-team/","level":1,"title":"Team Knowledge Bus","text":"","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#team-knowledge-bus","level":1,"title":"Team Knowledge Bus","text":"

      This recipe shows how a small trusted team uses a ctx Hub as a shared knowledge bus, the \"Story 2\" shape from the Hub overview. You're not building a wiki, you're not replacing your issue tracker, and you're not running a multi-tenant service. You're connecting 3-10 developers who trust each other so that lessons, decisions, and conventions flow between them without ceremony.

      Prerequisites:

      • A running ctx Hub on a LAN host or internal server everyone on the team can reach. See Multi-machine setup for the deployment guide.
      • Each team member has ctx installed and has ctx connection register-ed their working projects with the hub.
      • Each project on each workstation has been activated for the shell with eval \"$(ctx activate)\". The hub server (ctx hub start, etc.) doesn't need this — but the client side (ctx connection ..., ctx add --share) lives in a project and does. If you skip activation, those client commands fail with Error: no context directory specified. See Activating a Context Directory.
      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#trust-model-read-this-first","level":2,"title":"Trust Model: Read This First","text":"

      The hub assumes everyone holding a client token is friendly. There's no per-user attribution you can rely on, no read ACL beyond subscription filters, and Origin is self-asserted by the publishing client. Treat the hub like a team wiki: useful because everyone can write to it, not because it can prove who wrote what.

      If your team is:

      • ✅ 3-10 engineers, all known to each other, all trusted with production access
      • ✅ On a single internal network or behind a VPN
      • ✅ Comfortable with \"the hub assumes friendly participants\"

      …this recipe fits. If your team is:

      • ❌ Larger than ~15, with turnover
      • ❌ Includes contractors, untrusted agents, or compromised-workstation concerns
      • ❌ Needs audit trails that prove who published what
      • ❌ Requires per-team-member isolation

      …you're in \"Story 3\" territory, which the hub does not support today. Use a wiki or a dedicated knowledge platform instead.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#the-teams-three-verbs","level":2,"title":"The Team's Three Verbs","text":"

      Everyone on the team does three things, same as in the personal recipe, but with different social expectations:

      1. Record: when you learn something that would save a teammate time, capture it with ctx add --share.
      2. Subscribe: every engineer's project directories subscribe to the types the team cares about.
      3. Load: agents pick up shared entries automatically via the auto-sync hook and the --include-hub flag in the PreToolUse hook pipeline.

      The operational shape is identical to solo use. What's different is the culture around publishing: when do you --share, and what belongs on the hub vs. in your local .context/.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#what-goes-on-the-hub-team-rules-of-thumb","level":2,"title":"What Goes on the Hub (Team Rules of Thumb)","text":"

      Share it if it's true for more than one person. The central question: \"would the next teammate who hits this problem save time if they already knew this?\" If yes, --share. If no, record it locally and move on.

      Decisions:

      • ✅ Cross-service decisions (database choice, auth model, deployment pattern, monitoring stack).
      • ✅ Policy decisions that apply to all services (naming, API versioning, error-message format).
      • ❌ Internal implementation decisions inside a single service (\"chose a map over a slice here because lookups dominate\").
      • ❌ One-off tactical calls for a specific PR.

      Learnings:

      • ✅ Gotchas, surprising behavior, flaky infrastructure quirks, anything you'd tell a teammate over coffee with \"watch out for X\".
      • ✅ Lessons from incidents, right after the postmortem is the highest-value time to share.
      • ❌ Internal debugging notes that only make sense with context from your current branch.

      Conventions:

      • ✅ Repo layout, commit message format, pre-commit hooks, review expectations.
      • ✅ Language-level style decisions that apply across services.
      • ❌ Per-service idioms (\"in billing/ we prefer…\").

      Tasks: almost always project-local. Don't subscribe to task unless the team has a specific reason (e.g., a cross-cutting migration you want visible everywhere).

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#a-realistic-week","level":2,"title":"A Realistic Week","text":"

      Monday, 3 AM incident, shared learning

      On-call engineer Alice gets paged: the payment service starts returning 500s after a dependency update. After an hour she finds the culprit: a breaking change in a transitive gRPC dep that only manifests under high concurrency. Postmortem on Tuesday, but right now she records the learning:

      ctx add learning --share \\\n  --context \"Payment service 3 AM incident, 2026-04-03\" \\\n  --lesson  \"grpc-go v1.62+ changes DialContext behavior under high \\\n  concurrency: connections from a single channel can deadlock if the \\\n  server emits GOAWAY mid-stream. Symptom: 500 errors cluster in \\\n  30s bursts, no error in grpc client logs.\" \\\n  --application \"Any service on grpc-go. Pin to v1.61 or patch with \\\n  keepalive: https://github.com/grpc/grpc-go/issues/...\" \n

      By Tuesday morning, every other engineer's agent context packet contains this learning. When Bob starts work on the ledger service (which also uses grpc-go), his Claude Code session already knows about the gotcha without Bob having to read the incident channel.

      Wednesday, cross-service decision

      The team agrees on a new pattern for API versioning: header-based instead of URL-based. Platform lead Carol records the decision:

      ctx add decision --share \\\n  --context \"Need consistent API versioning across all 6 services. \\\n  Current URL-based /v1/ isn't working for gradual rollouts.\" \\\n  --rationale \"Header-based versioning lets us route by header at the \\\n  edge, which makes canary rollouts trivial. URL-based versioning \\\n  forces clients to update their paths.\" \\\n  --consequence \"All new endpoints use X-API-Version header. \\\n  Existing /v1/ endpoints stay. Deprecation schedule in q3.\" \\\n  \"Use header-based API versioning for new endpoints\"\n

      Every engineer's next session knows about this decision automatically. When Dave starts adding endpoints to the inventory service on Thursday, Claude already prompts him for the header pattern instead of defaulting to /v1/.

      Friday, convention drift caught at review

      Dave notices that his PR auto-formatted some error messages to end with periods. He recalls the team convention is \"no trailing period\" but can't remember where it was documented. He runs ctx connection status, sees the hub is healthy, greps his local .context/hub/conventions.md, and finds:

      ## [2026-03-12] Error message format\nLowercase start, no trailing period, single sentence.\n

      He fixes the PR. No lookup on the wiki, no question in chat, no context-switch penalty.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#workflow-tips-for-teams","level":2,"title":"Workflow Tips for Teams","text":"

      Designate a \"champion\" for decisions. The team lead or platform engineer should be the person who explicitly --shares cross-cutting decisions. Other team members share learnings freely but should ask \"should this be a decision?\" in review before --shareing a decision. This keeps the decision stream signal-rich.

      Publish postmortem learnings immediately, not after the meeting. The postmortem itself is a document; the actionable rules that come out of it belong on the hub, and they should land within an hour of the incident. \"Share fast, edit later\" is the rule.

      Delete noisy entries, don't tolerate them. The hub is append-only, but the .context/hub/ mirror on each client is just markdown. If a shared learning turns out to be wrong or obsolete, remove it from local mirrors and stop the hub daemon to truncate entries.jsonl (see Hub operations). Noisy shared feeds lose trust fast.

      Don't subscribe every project to every type. For backend engineers, subscribing to decision + learning + convention is usually right. For platform or DevOps projects, adding task makes sense. For a prototype or experiment project, subscribing only to convention might be enough.

      Run a single hub, not one per team. If two teams need to share knowledge, they should share a hub. Splitting hubs by team creates silos, which is often exactly the thing you were trying to solve.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#operational-concerns","level":2,"title":"Operational Concerns","text":"

      The team recipe assumes someone owns the hub host. That person (or a small group) is responsible for:

      • Uptime: the hub is infrastructure; treat it like any other internal service you run. See Hub operations.
      • Backups: entries.jsonl is the source of truth. Snapshot it to the same backup tier as your other internal data.
      • Upgrades: cadence the team agrees on. Major upgrades may require everyone to re-register, so do them at natural breaks.
      • Failures: see Hub failure modes for the standard oncall playbook.

      Optional but recommended: run a 3-node Raft cluster so the hub survives individual node failures. See HA cluster. For teams under 10 people, a single-node hub with daily backups is usually fine.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#token-management","level":2,"title":"Token Management","text":"

      Every team member has a client token stored in their .context/.connect.enc. Rules of thumb:

      • One token per engineer per project. Not one token per team; not one shared token. Each engineer registers each of their working projects separately.
      • Token compromise = revoke immediately. When an engineer leaves, their tokens should be removed from clients.json on the hub. This is a manual operation today; see Hub security for the revocation steps.
      • No checked-in tokens. .context/.connect.enc is encrypted with the local machine key, but don't push it to shared repos; it's per-workstation.
      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#what-this-recipe-is-not","level":2,"title":"What This Recipe Is Not","text":"

      Not a wiki replacement. The hub is for structured entries, not prose. Put your architecture overviews, onboarding docs, and design discussions in a real wiki.

      Not an audit log. Origin on the hub is self-asserted. If compliance requires provenance, the hub is the wrong tool.

      Not a ticket system. Task sharing works, but mature teams already have Jira/Linear/Github Issues. Don't try to replace those with hub tasks; use the hub for lightweight cross-project todos that your existing tracker doesn't capture well.

      Not a production service for end users. This is internal team infrastructure. Do not expose the hub to customers, partners, or the open internet.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#see-also","level":2,"title":"See Also","text":"
      • Hub overview: when to use the hub and when not to.
      • Personal cross-project brain: the single-developer companion recipe.
      • Multi-machine setup: standing up the hub on a LAN host.
      • HA cluster: optional redundancy for larger teams.
      • Hub operations: backup, rotation, monitoring.
      • Hub security: threat model and hardening checklist.
      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/import-plans/","level":1,"title":"Importing Claude Code Plans","text":"","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code plan files (~/.claude/plans/*.md) are ephemeral: They have structured context, approach, and file lists, but they're orphaned after the session ends. The filenames are UUIDs, so you can't tell what's in them without opening each one.

      How do you turn a useful plan into a permanent project spec?

      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tldr","level":2,"title":"TL;DR","text":"
      You: /ctx-plan-import\nAgent: [lists plans with dates and titles]\n       1. 2026-02-28  Add authentication middleware\n       2. 2026-02-27  Refactor database connection pool\nYou: \"import 1\"\nAgent: [copies to specs/add-authentication-middleware.md]\n

      Plans are copied (not moved) to specs/, slugified by their H1 heading.

      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-plan-import Skill List, filter, and import plan files to specs /ctx-task-add Skill Optionally add a task referencing the spec","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-1-list-available-plans","level":3,"title":"Step 1: List Available Plans","text":"

      Invoke the skill and it lists plans with modification dates and titles:

      You: /ctx-plan-import\n\nAgent: Found 3 plan files:\n         1. 2026-02-28  Add authentication middleware\n         2. 2026-02-27  Refactor database connection pool\n         3. 2026-02-25  Import plans skill\n       Which plans would you like to import?\n
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-2-filter-optional","level":3,"title":"Step 2: Filter (Optional)","text":"

      You can narrow the list with arguments:

      Argument Effect --today Only plans modified today --since YYYY-MM-DD Only plans modified on or after the date --all Import everything without prompting (none) Interactive selection
      You: /ctx-plan-import --today\nYou: /ctx-plan-import --since 2026-02-27\nYou: /ctx-plan-import --all\n
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-3-select-and-import","level":3,"title":"Step 3: Select and Import","text":"

      Pick one or more plans by number:

      You: \"import 1 and 3\"\n\nAgent: Imported 2 plan(s):\n         ~/.claude/plans/abc123.md -> specs/add-authentication-middleware.md\n         ~/.claude/plans/ghi789.md -> specs/import-plans-skill.md\n       Want me to add tasks referencing these specs?\n

      The agent reads the H1 heading from each plan and slugifies it for the filename. If a plan has no H1 heading, the original filename (minus extension) is used as the slug.

      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-4-add-follow-up-tasks-optional","level":3,"title":"Step 4: Add Follow-Up Tasks (Optional)","text":"

      If you say yes, the agent creates tasks in TASKS.md that reference the imported specs:

      You: \"yes, add tasks\"\n\nAgent: [runs /ctx-task-add for each spec]\n       Added:\n         - [ ] Implement authentication middleware (spec: specs/add-authentication-middleware.md)\n         - [ ] Import plans skill (spec: specs/import-plans-skill.md)\n
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need to remember the exact skill name:

      You say What happens \"import my plans\" /ctx-plan-import (interactive) \"save today's plans as specs\" /ctx-plan-import --today \"import all plans from this week\" /ctx-plan-import --since ... \"turn that plan into a spec\" /ctx-plan-import (filtered)","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tips","level":2,"title":"Tips","text":"
      • Plans are copied, not moved: The originals stay in ~/.claude/plans/. Claude Code manages that directory; ctx doesn't delete from it.
      • Conflict handling: If specs/{slug}.md already exists, the agent asks whether to overwrite or pick a different name.
      • Specs are project memory: Once imported, specs are tracked in git and available to future sessions. Reference them from TASKS.md phase headers with Spec: specs/slug.md.
      • Pair with /ctx-implement: After importing a plan as a spec, use /ctx-implement to execute it step-by-step with verification.
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#see-also","level":2,"title":"See Also","text":"
      • Skills Reference: /ctx-plan-import: full skill description
      • The Complete Session: where plan import fits in the session flow
      • Tracking Work Across Sessions: managing tasks that reference imported specs
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/knowledge-capture/","level":1,"title":"Persisting Decisions, Learnings, and Conventions","text":"","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#the-problem","level":2,"title":"The Problem","text":"

      You debug a subtle issue, discover the root cause, and move on.

      Three weeks later, a different session hits the same issue. The knowledge existed briefly in one session's memory but was never written down.

      Architectural decisions suffer the same fate: you weigh trade-offs, pick an approach, and six sessions later the AI suggests the alternative you already rejected.

      How do you make sure important context survives across sessions?

      Prefer Skills to Raw Commands

      Use /ctx-decision-add and /ctx-learning-add instead of raw ctx add commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, the ctx add ... / ctx reindex / ctx decision ... / ctx learning ... commands below fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-reflect               # surface items worth persisting\n/ctx-decision-add \"Title\"  # record with context/rationale/consequence\n/ctx-learning-add \"Title\"  # record with context/lesson/application\n

      Or just tell your agent: \"What have we learned this session?\"

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx add decision Command Record an architectural decision ctx add learning Command Record a gotcha, tip, or lesson ctx add convention Command Record a coding pattern or standard ctx reindex Command Rebuild both quick-reference indices ctx decision reindex Command Rebuild the DECISIONS.md index ctx learning reindex Command Rebuild the LEARNINGS.md index /ctx-decision-add Skill AI-guided decision capture with validation /ctx-learning-add Skill AI-guided learning capture with validation /ctx-convention-add Skill AI-guided convention recording with placement /ctx-reflect Skill Surface items worth persisting at breakpoints","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#the-workflow","level":2,"title":"The Workflow","text":"

      Decision, Learning, or Convention?

      • If you chose between alternatives, it is a decision.
      • If you discovered something surprising, it is a learning.
      • If you are codifying a repeated pattern, it is a convention.
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-1-understand-what-to-persist","level":3,"title":"Step 1: Understand What to Persist","text":"

      Three context files serve different purposes:

      Decisions (DECISIONS.md) answer \"why is it this way?\" They record trade-offs between alternatives with structured fields: context, rationale, and consequences. Decisions prevent re-debating settled questions.

      Learnings (LEARNINGS.md) answer \"what did we discover the hard way?\" They record gotchas and debugging insights specific to this project with structured fields: context, lesson, and application.

      Learnings prevent repeating past mistakes.

      Conventions (CONVENTIONS.md) answer \"how do we do things here?\" They record patterns and standards. No structured fields required: just a name, a rule, and an example. Conventions keep code consistent across sessions.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-2-record-decisions","level":3,"title":"Step 2: Record Decisions","text":"

      Decisions have three structured fields:

      • context,
      • rationale,
      • and consequences.

      The easiest way to record one is to tell your agent:

      You: \"Save that as a decision: we picked file-based cooldown\n      tokens over env vars.\"\n\nAgent: \"Recorded in DECISIONS.md:\n  - Decision: Use file-based cooldown tokens instead of env vars\n  - Context: Hook subprocesses cannot persist env vars to parent shell\n  - Rationale: File tokens survive across processes. Simpler than\n    IPC. Cleanup is automatic via TTL.\n  - Consequence: Tombstone files accumulate in /tmp. Cannot share\n    state across machines.\"\n

      The agent was present for the trade-off discussion. It fills in the structured fields from what it observed, which is hard to reconstruct later as a terminal one-liner.

      When multiple options were considered, the agent includes rejected alternatives in the rationale automatically.

      The /ctx-decision-add skill also guides you through the fields interactively. For quick decisions, it supports a Y-statement:

      \"In the context of [situation], facing [constraint], we decided for [choice] and against [alternatives], to achieve [benefit], accepting that [trade-off].\"

      CLI Command for Scripting and Automation

      When no agent is in the loop (CI pipelines, shell scripts, hooks), use the CLI directly with structured flags:

      ctx add decision \"Use file-based cooldown tokens instead of env vars\" \\\n  --context \"Hook subprocesses cannot persist env vars to parent shell\" \\\n  --rationale \"File tokens survive across processes. Simpler than IPC. Cleanup is automatic via TTL.\" \\\n  --consequence \"Tombstone files accumulate in /tmp. Cannot share state across machines.\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-3-record-learnings","level":3,"title":"Step 3: Record Learnings","text":"

      Learnings have three structured fields: context, lesson, and application.

      Again, your agent is the best tool for this. It was there when you discovered the gotcha and can express it more completely than a backslash-escaped terminal command:

      You: \"That subprocess thing was painful. Save it as a learning.\"\n\nAgent: \"Added to LEARNINGS.md:\n  - Learning: Claude Code hooks run in a subprocess\n  - Context: Set env var in PreToolUse hook, but it was not visible\n    in the main session\n  - Lesson: Hook scripts execute in a child process. Env changes do\n    not propagate to parent.\n  - Application: Use tombstone files for hook-to-session\n    communication. Never rely on hook env vars.\"\n

      You said one sentence. The agent produced a structured entry with all three fields filled from the session context.

      That is the point: the agent has the full conversation and can be far more expressive than what you would type at a command prompt.

      The /ctx-learning-add skill applies three quality filters:

      1. Could someone Google this in 5 minutes?
      2. Is it specific to this codebase?
      3. Did it take real effort to discover?

      All three must pass.

      Learnings capture principles and heuristics, not code snippets.

      CLI Command for Scripting and Automation

      When no agent is in the loop:

      ctx add learning \"Claude Code hooks run in a subprocess\" \\\n  --context \"Set env var in PreToolUse hook, but it was not visible in the main session\" \\\n  --lesson \"Hook scripts execute in a child process. Env changes do not propagate to parent.\" \\\n  --application \"Use tombstone files for hook-to-session communication. Never rely on hook env vars.\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-4-record-conventions","level":3,"title":"Step 4: Record Conventions","text":"

      Conventions are simpler: just a name, a rule, and optionally a section.

      These are short enough that either approach works:

      You: \"We've been using kebab-case for every CLI flag. Codify that.\"\n\nAgent: \"Added to CONVENTIONS.md under Naming:\n  'Use kebab-case for all CLI flag names.'\"\n

      Or from the terminal:

      ctx add convention \"Use kebab-case for all CLI flag names\" --section \"Naming\"\n

      Conventions work best for rules that come up repeatedly. Codify a pattern the third time you see it, not the first.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-5-reindex-after-manual-edits","level":3,"title":"Step 5: Reindex After Manual Edits","text":"

      DECISIONS.md and LEARNINGS.md maintain a quick-reference index at the top: a compact table of date and title for each entry. The index updates automatically via ctx add, but falls out of sync after hand edits.

      ctx reindex\n

      This single command regenerates both indices. You can also reindex individually with ctx decision reindex or ctx learning reindex.

      Run reindex after any manual edit. The index lets AI tools scan all entries without reading the full file, which matters when token budgets are tight.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-6-use-ctx-reflect-to-surface-what-to-capture","level":3,"title":"Step 6: Use /ctx-reflect to Surface What to Capture","text":"

      Keep It Conversational

      /ctx-reflect is not the only way to trigger reflection.

      Agents trained on the ctx playbook naturally surface persist-worthy items at breakpoints, even without invoking the skill explicitly.

      A conversational prompt like \"anything worth saving?\" or \"let's wrap up\" can trigger the same review.

      The skill provides a structured checklist, but the behavior is available through natural conversation.

      At natural breakpoints (after completing a feature, fixing a bug, or before ending a session) use /ctx-reflect to identify items worth persisting.

      /ctx-reflect\n

      The skill walks through learnings, decisions, tasks, and session notes, skipping categories with nothing to report. The output includes specific commands for each suggested persist:

      This session implemented file-based cooldown for `ctx agent` and\ndiscovered that hook subprocesses cannot set env vars in the parent.\n\nI'd suggest persisting:\n- **Learning**: Hook subprocesses cannot propagate env vars\n  `ctx add learning \"...\" --context \"...\" --lesson \"...\" --application \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n- **Decision**: File-based cooldown tokens over env vars\n  `ctx add decision \"...\" --context \"...\" --rationale \"...\" --consequence \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n\nWant me to persist any of these?\n

      The skill always asks before persisting.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-7-the-conversational-approach","level":3,"title":"Step 7: The Conversational Approach","text":"

      The commands shown in Steps 2 to 4 are precise, but you rarely need to type them yourself. When working with an agent that has loaded the ctx playbook, natural language triggers the same operations.

      You ask, the agent acts:

      You say What the agent does \"What have we learned this session?\" Reviews recent work, identifies learnings, offers to persist \"Save that as a decision\" Captures the trade-off you just discussed with structured fields \"Any gotchas worth remembering?\" Scans recent work for non-obvious lessons \"Record that convention\" Adds the pattern you just agreed on to CONVENTIONS.md \"Let's wrap up\" Runs through the reflect checklist conversationally

      Example exchange:

      You: \"What did we learn from that debugging session?\"\n\nAgent: \"We discovered three things worth persisting:\n  1. Hook subprocesses can't propagate env vars to the parent. We\n     spent 20 minutes on this before switching to tombstone files.\n  2. Tombstone files need a TTL or they accumulate in /tmp.\n  3. The cooldown logic must check file mtime, not just existence.\n  Want me to save these as learnings?\"\n\nYou: \"Yes, all of them.\"\n\nAgent: \"Done. Added all three to LEARNINGS.md with structured fields.\"\n

      The agent can also be proactive without being asked. The playbook encourages agents to persist context at natural milestones.

      You may see:

      • After fixing a tricky bug: \"I noticed this was a non-obvious issue. Want me to save it as a learning?\"
      • After choosing between approaches: \"We just made a trade-off between file-based tokens and IPC. Should I record this as a decision?\"
      • At session milestones: the agent checks what is worth persisting and offers a brief summary.

      When agents run unattended (no human in the loop), they may persist directly:

      • \"I've added the subprocess env var gotcha to LEARNINGS.md so we don't hit it again.\"
      • \"Recorded the decision to use file-based tokens over env vars in DECISIONS.md.\"
      • \"Marked the cooldown task done and added a follow-up for TTL cleanup.\"

      This is behavior by design.

      The playbook's self-check prompt, \"If this session ended right now, would the next session know what happened?\" drives agents to persist early and often rather than waiting for explicit instructions.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#command-line-approach-scripting-and-automation","level":3,"title":"Command-Line Approach (Scripting and Automation)","text":"
      # Decision: record the trade-off\nctx add decision \"Use PostgreSQL over SQLite\" \\\n  --context \"Need concurrent multi-user access\" \\\n  --rationale \"SQLite locks on writes; Postgres handles concurrency\" \\\n  --consequence \"Requires a database server; team needs Postgres training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Learning: record the gotcha\nctx add learning \"SQL migrations must be idempotent\" \\\n  --context \"Deploy failed when migration ran twice after rollback\" \\\n  --lesson \"CREATE TABLE without IF NOT EXISTS fails on retry\" \\\n  --application \"Always use IF NOT EXISTS guards in migrations\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Convention: record the pattern\nctx add convention \"API handlers return structured errors\" --section \"API\"\n\n# Reindex after manual edits\nctx reindex\n\n# Reflect at breakpoints (from AI assistant)\n# /ctx-reflect\n
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#conversational-approach-interactive-sessions","level":3,"title":"Conversational Approach (Interactive Sessions)","text":"
      You: \"We just picked Postgres over SQLite for the concurrency\n      reasons. Save that?\"\n\nAgent: \"Recorded. Added to DECISIONS.md:\n  - Decision: Use PostgreSQL over SQLite\n  - Context: Need concurrent multi-user access\n  - Rationale: SQLite locks on writes; Postgres handles concurrency\n  - Consequence: Requires a database server; team needs Postgres\n    training\"\n\nYou: \"Also that migration thing. The deploy blew up when the\n      migration ran twice.\"\n\nAgent: \"Got it. Added to LEARNINGS.md:\n  - Learning: SQL migrations must be idempotent\n  - Lesson: CREATE TABLE without IF NOT EXISTS fails on retry\n  - Application: Always use IF NOT EXISTS guards in migrations\"\n\nYou: \"Good. Anything else worth saving before we wrap up?\"\n\nAgent: \"We've been using structured error returns in every API\n  handler this session. Want me to codify that as a convention?\"\n\nYou: \"Do it.\"\n\nAgent: \"Done. Added 'API handlers return structured errors' to\n  CONVENTIONS.md under the API section.\"\n

      Both approaches produce the same structured entries in the same context files.

      • The conversational approach is the natural fit for interactive sessions;
      • the CLI commands are better suited for scripts, hooks, and automation pipelines.
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tips","level":2,"title":"Tips","text":"
      • Record decisions at the moment of choice. The alternatives you considered and the reasons you rejected them fade quickly. Capture trade-offs while they are fresh.
      • Learnings should fail the Gemini test. If someone could find it in a 5-minute Gemini search, it does not belong in LEARNINGS.md.
      • Conventions earn their place through repetition. Add a convention the third time you see a pattern, not the first.
      • Use /ctx-reflect at natural breakpoints. The checklist catches items you might otherwise lose.
      • Keep the entries self-contained. Each entry should make sense on its own. A future session may load only one due to token budget constraints.
      • Reindex after every hand edit. It takes less than a second. A stale index causes AI tools to miss entries.
      • Prefer the structured fields. The verbosity forces clarity. A decision without a rationale is just a fact. A learning without an application is just a story.
      • Talk to your agent, do not type commands. In interactive sessions, the conversational approach is the recommended way to capture knowledge. Say \"save that as a learning\" or \"any decisions worth recording?\" and let the agent handle the structured fields. Reserve the CLI commands for scripting, automation, and CI/CD pipelines where there is no agent in the loop.
      • Trust the agent's proactive instincts. Agents trained on the ctx playbook will offer to persist context at milestones. A brief \"want me to save this?\" is cheaper than re-discovering the same lesson three sessions later.
      • Relax provenance per-project if --session-id, --branch, or --commit are impractical (e.g., manual notes outside an AI session). Add to .ctxrc:

        provenance_required:\n  session_id: false   # allow entries without --session-id\n  branch: true        # still require --branch\n  commit: true        # still require --commit\n

        Default is all three required. Only human config relaxes: Agents cannot bypass, and that's by design.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#next-up","level":2,"title":"Next Up","text":"

      Tracking Work Across Sessions →: Add, prioritize, complete, and archive tasks across sessions.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#see-also","level":2,"title":"See Also","text":"
      • Tracking Work Across Sessions: managing the tasks that decisions and learnings support
      • The Complete Session: full session lifecycle including reflection and context persistence
      • Detecting and Fixing Drift: keeping knowledge files accurate as the codebase evolves
      • CLI Reference: full documentation for ctx add, ctx decision, ctx learning
      • Context Files: format and conventions for DECISIONS.md, LEARNINGS.md, and CONVENTIONS.md
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/memory-bridge/","level":1,"title":"Bridging Claude Code Auto Memory","text":"","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code maintains per-project auto memory at ~/.claude/projects/<slug>/memory/MEMORY.md. This file is:

      • Outside the repo - not version-controlled, not portable
      • Machine-specific - tied to one ~/.claude/ directory
      • Invisible to ctx - context loading and hooks don't read it

      Meanwhile, ctx maintains structured context files (DECISIONS.md, LEARNINGS.md, CONVENTIONS.md) that are git-tracked, portable, and token-budgeted - but Claude Code doesn't automatically write to them.

      The two systems hold complementary knowledge with no bridge between them.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#tldr","level":2,"title":"TL;DR","text":"
      ctx memory sync          # Mirror MEMORY.md into .context/memory/mirror.md\nctx memory status        # Check for drift\nctx memory diff          # See what changed since last sync\n

      The check-memory-drift hook nudges automatically when MEMORY.md changes - you don't need to remember to sync manually.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx memory ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx memory sync CLI command Copy MEMORY.md to mirror, archive previous ctx memory status CLI command Show drift, timestamps, line counts ctx memory diff CLI command Show changes since last sync ctx memory import CLI command Classify and promote entries to .context/ files ctx memory publish CLI command Push curated .context/ content to MEMORY.md ctx memory unpublish CLI command Remove published block from MEMORY.md ctx system check-memory-drift Hook Nudge when MEMORY.md has changed (once/session)","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#how-it-works","level":2,"title":"How It Works","text":"","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#discovery","level":3,"title":"Discovery","text":"

      Claude Code encodes project paths as directory names under ~/.claude/projects/. The encoding replaces / with - and prefixes with -:

      /home/jose/WORKSPACE/ctx  →  ~/.claude/projects/-home-jose-WORKSPACE-ctx/\n

      ctx memory uses this encoding to locate MEMORY.md automatically from your project root - no configuration needed.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#mirroring","level":3,"title":"Mirroring","text":"

      When you run ctx memory sync:

      1. The previous mirror is archived to .context/memory/archive/mirror-<timestamp>.md
      2. MEMORY.md is copied to .context/memory/mirror.md
      3. Sync state is updated in .context/state/memory-import.json

      The mirror is git-tracked, so it travels with the project. Archives provide a fallback for projects that don't use git.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#drift-detection","level":3,"title":"Drift Detection","text":"

      The check-memory-drift hook compares MEMORY.md's modification time against the mirror. When drift is detected, the agent sees:

      ┌─ Memory Drift ────────────────────────────────────────────────\n│ MEMORY.md has changed since last sync.\n│ Run: ctx memory sync\n│ Context: .context\n└────────────────────────────────────────────────────────────────\n

      The nudge fires once per session to avoid noise.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#typical-workflow","level":2,"title":"Typical Workflow","text":"","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#at-session-start","level":3,"title":"At Session Start","text":"

      If the hook fires a drift nudge, sync before diving into work:

      ctx memory diff     # Review what changed\nctx memory sync     # Mirror the changes\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#periodic-check","level":3,"title":"Periodic Check","text":"
      ctx memory status\n# Memory Bridge Status\n#   Source:      ~/.claude/projects/.../memory/MEMORY.md\n#   Mirror:      .context/memory/mirror.md\n#   Last sync:   2026-03-05 14:30 (2 hours ago)\n#\n#   MEMORY.md:  47 lines\n#   Mirror:     32 lines\n#   Drift:      detected (source is newer)\n#   Archives:   3 snapshots in .context/memory/archive/\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#dry-run","level":3,"title":"Dry Run","text":"

      Preview what sync would do without writing:

      ctx memory sync --dry-run\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#storage-layout","level":2,"title":"Storage Layout","text":"
      .context/\n├── memory/\n│   ├── mirror.md                          # Raw copy of MEMORY.md (often git-tracked)\n│   └── archive/\n│       ├── mirror-2026-03-05-143022.md    # Timestamped pre-sync snapshots\n│       └── mirror-2026-03-04-220015.md\n├── state/\n│   └── memory-import.json                 # Sync tracking state\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#edge-cases","level":2,"title":"Edge Cases","text":"Scenario Behavior Auto memory not active sync exits 1 with message. status reports \"not active\". Hook skips silently. First sync (no mirror) Creates mirror without archiving. MEMORY.md is empty Syncs to empty mirror (valid). Not initialized Init guard rejects (same as all ctx commands).","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#importing-entries","level":2,"title":"Importing Entries","text":"

      Once you've synced, you can classify and promote entries into structured .context/ files:

      ctx memory import --dry-run    # Preview classification\nctx memory import              # Actually promote entries\n

      Each entry is classified by keyword heuristics:

      Keywords Target always use, prefer, never use, standard CONVENTIONS.md decided, chose, trade-off, approach DECISIONS.md gotcha, learned, watch out, bug, caveat LEARNINGS.md todo, need to, follow up TASKS.md Everything else Skipped

      Entries that don't match any pattern are skipped - they stay in the mirror for manual review. Deduplication (hash-based) prevents re-importing the same entry on subsequent runs.

      Review Before Importing

      Use --dry-run first. The heuristic classifier is deliberately simple - it may misclassify ambiguous entries. Review the plan, then import.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#full-workflow","level":3,"title":"Full Workflow","text":"
      ctx memory sync                # 1. Mirror MEMORY.md\nctx memory import --dry-run    # 2. Preview what would be imported\nctx memory import              # 3. Promote entries to .context/ files\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#publishing-context-to-memorymd","level":2,"title":"Publishing Context to MEMORY.md","text":"

      Push curated .context/ content back into MEMORY.md so Claude Code sees structured project context on session start - without needing hooks.

      ctx memory publish --dry-run    # Preview what would be published\nctx memory publish              # Write to MEMORY.md\nctx memory publish --budget 40  # Tighter line budget\n

      Published content is wrapped in markers:

      <!-- ctx:published -->\n# Project Context (managed by ctx)\n\n## Pending Tasks\n- [ ] Implement feature X\n...\n<!-- ctx:end -->\n

      Rules:

      • ctx owns everything between the markers
      • Claude owns everything outside the markers
      • ctx memory import reads only outside the markers
      • ctx memory publish replaces only inside the markers

      To remove the published block entirely:

      ctx memory unpublish\n

      Publish at Wrap-Up, Not on Commit

      The best time to publish is during session wrap-up, after persisting decisions and learnings. Never auto-publish - give yourself a chance to review what's going into MEMORY.md.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#full-bidirectional-workflow","level":3,"title":"Full Bidirectional Workflow","text":"
      ctx memory sync                 # 1. Mirror MEMORY.md\nctx memory import --dry-run     # 2. Check what Claude wrote\nctx memory import               # 3. Promote entries to .context/\nctx memory publish --dry-run    # 4. Check what would be published\nctx memory publish              # 5. Push context to MEMORY.md\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/multi-tool-setup/","level":1,"title":"Setup Across AI Tools","text":"","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#the-problem","level":2,"title":"The Problem","text":"

      You have installed ctx and want to set it up with your AI coding assistant so that context persists across sessions. Different tools have different integration depths. For example:

      • Claude Code supports native hooks that load and save context automatically.
      • Cursor injects context via its system prompt.
      • Aider reads context files through its --read flag.

      This recipe walks through the complete setup for each tool, from initialization through verification, so you end up with a working memory layer regardless of which AI tool you use.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tldr","level":2,"title":"TL;DR","text":"
      cd your-project\nctx init                      # creates .context/\neval \"$(ctx activate)\"        # bind CTX_DIR for this shell\nsource <(ctx completion zsh)  # shell completion (or bash/fish)\n\n# ## Claude Code (automatic after plugin install) ##\nclaude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n\n# ## Cursor / Aider / Copilot / Windsurf ##\nctx setup cursor # or: aider, copilot, windsurf\n\n# ## Companion tools (highly recommended) ##\nnpx gitnexus analyze          # code knowledge graph\n# Add Gemini Search MCP server for grounded web search\n

      Activate the Project Once Per Shell

      Run eval \"$(ctx activate)\" after ctx init. The ctx setup, ctx init, and ctx completion commands work without it, but if you skip the eval, most others (ctx agent, ctx load, ctx watch, ctx journal ...) fail with Error: no context directory specified. See Activating a Context Directory.

      Create a .ctxrc in your project root to configure token budgets, context directory, drift thresholds, and more.

      Then start your AI tool and ask: \"Do you remember?\"

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Command/Skill Role in this workflow ctx init Create .context/ directory, templates, and permissions ctx setup Generate integration configuration for a specific AI tool ctx agent Print a token-budgeted context packet for AI consumption ctx load Output assembled context in read order (for manual pasting) ctx watch Auto-apply context updates from AI output (non-native tools) ctx completion Generate shell autocompletion for bash, zsh, or fish ctx journal import Import sessions to editable journal Markdown","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-1-initialize-ctx","level":3,"title":"Step 1: Initialize ctx","text":"

      Run ctx init in your project root. This creates the .context/ directory with all template files and seeds ctx permissions in settings.local.json.

      cd your-project\nctx init\n

      This produces the following structure:

      .context/\n  CONSTITUTION.md     # Hard rules the AI must never violate\n  TASKS.md            # Current and planned work\n  CONVENTIONS.md      # Code patterns and standards\n  ARCHITECTURE.md     # System overview\n  DECISIONS.md        # Architectural decisions with rationale\n  LEARNINGS.md        # Lessons learned, gotchas, tips\n  GLOSSARY.md         # Domain terms and abbreviations\n  AGENT_PLAYBOOK.md   # How AI tools should use this system\n

      Using a Different .context Directory

      The .context/ directory doesn't have to live inside your project. Point ctx to an external folder by exporting CTX_DIR (the only declaration channel).

      Useful when context must stay private while the code is public, or when you want to commit notes to a separate repo.

      Caveats (the recipe covers both with workarounds):

      • Code-aware operations degrade silently. ctx sync, ctx drift, and the memory-drift hook read the codebase from dirname(CTX_DIR). With an external .context/, that's the context repo, not your code repo. They scan the wrong tree without erroring. The recipe shows a symlink workaround that keeps both healthy.
      • One .context/ per project, always. Sharing one directory across multiple projects corrupts journals, state, and secrets. For cross-project knowledge sharing (CONSTITUTION, CONVENTIONS, ARCHITECTURE, etc.) use ctx hub, not a shared .context/.

      See External Context for the full recipe and Configuration for the resolver details.

      For Claude Code, install the ctx plugin to get hooks and skills:

      claude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n

      If you only need the core files (useful for lightweight setups), use the --minimal flag:

      ctx init --minimal\n

      This creates only TASKS.md, DECISIONS.md, and CONSTITUTION.md.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-2-generate-tool-specific-hooks","level":3,"title":"Step 2: Generate Tool-Specific Hooks","text":"

      If you are using a tool other than Claude Code (which is configured automatically by ctx init), generate its integration configuration:

      # For Cursor\nctx setup cursor\n\n# For Aider\nctx setup aider\n\n# For GitHub Copilot\nctx setup copilot\n\n# For Windsurf\nctx setup windsurf\n

      Each command prints the configuration you need. How you apply it depends on the tool.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#claude-code","level":4,"title":"Claude Code","text":"

      No action needed. Just install ctx from the Marketplace as ActiveMemory/ctx.

      Claude Code Is a First-Class Citizen

      With the ctx plugin installed, Claude Code gets hooks and skills automatically. The PreToolUse hook runs ctx agent --budget 4000 on every tool call (with a 10-minute cooldown so it only fires once per window).

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#cursor","level":4,"title":"Cursor","text":"

      Add the system prompt snippet to .cursor/settings.json:

      {\n  \"ai.systemPrompt\": \"Read .context/TASKS.md and .context/CONVENTIONS.md before responding. Follow rules in .context/CONSTITUTION.md.\"\n}\n

      Context files appear in Cursor's file tree. You can also paste a context packet directly into chat:

      ctx agent --budget 4000 | xclip    # Linux\nctx agent --budget 4000 | pbcopy   # macOS\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#aider","level":4,"title":"Aider","text":"

      Create .aider.conf.yml so context files are loaded on every session:

      read:\n  - .context/CONSTITUTION.md\n  - .context/TASKS.md\n  - .context/CONVENTIONS.md\n  - .context/DECISIONS.md\n

      Then start Aider normally:

      aider\n

      Or specify files on the command line:

      aider --read .context/TASKS.md --read .context/CONVENTIONS.md\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-3-set-up-shell-completion","level":3,"title":"Step 3: Set Up Shell Completion","text":"

      Shell completion lets you tab-complete ctx subcommands and flags, which is especially useful while learning the CLI.

      # Bash (add to ~/.bashrc)\nsource <(ctx completion bash)\n\n# Zsh (add to ~/.zshrc)\nsource <(ctx completion zsh)\n\n# Fish\nctx completion fish > ~/.config/fish/completions/ctx.fish\n

      After sourcing, typing ctx a<TAB> completes to ctx agent, and ctx journal <TAB> shows list, show, and export.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-4-verify-the-setup-works","level":3,"title":"Step 4: Verify the Setup Works","text":"

      Start a fresh session in your AI tool and ask:

      \"Do you remember?\"

      A correctly configured tool responds with specific context: current tasks from TASKS.md, recent decisions, and previous session topics. It should not say \"I don't have memory\" or \"Let me search for files.\"

      This question checks the passive side of memory. A properly set-up agent is also proactive: it treats context maintenance as part of its job:

      • After a debugging session, it offers to save a learning.
      • After a trade-off discussion, it asks whether to record the decision.
      • After completing a task, it suggests follow-up items.

      The \"do you remember?\" check verifies both halves: recall and responsibility.

      For example, after resolving a tricky bug, a proactive agent might say:

      That Redis timeout issue was subtle. Want me to save this as a *learning*\nso we don't hit it again?\n

      If you see behavior like this, the setup is working end to end.

      In Claude Code, you can also invoke the /ctx-status skill:

      /ctx-status\n

      This prints a summary of all context files, token counts, and recent activity, confirming that hooks are loading context.

      If context is not loading, check the basics:

      Symptom Fix ctx: command not found Ensure ctx is in your PATH: which ctx Hook errors Verify plugin is installed: claude /plugin list Context not refreshing Cooldown may be active; wait 10 minutes or set --cooldown 0","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-5-enable-watch-mode-for-non-native-tools","level":3,"title":"Step 5: Enable Watch Mode for Non-Native Tools","text":"

      Tools like Aider, Copilot, and Windsurf do not support native hooks for saving context automatically. For these, run ctx watch alongside your AI tool.

      Pipe the AI tool's output through ctx watch:

      # Terminal 1: Run Aider with output logged\naider 2>&1 | tee /tmp/aider.log\n\n# Terminal 2: Watch the log for context updates\nctx watch --log /tmp/aider.log\n

      Or for any generic tool:

      your-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n

      When the AI emits structured update commands, ctx watch parses and applies them automatically:

      <context-update type=\"learning\"\n  context=\"Debugging rate limiter\"\n  lesson=\"Redis MULTI/EXEC does not roll back on error\"\n  application=\"Wrap rate-limit checks in Lua scripts instead\"\n>Redis Transaction Behavior</context-update>\n

      To preview changes without modifying files:

      ctx watch --dry-run --log /tmp/ai.log\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-6-import-session-transcripts-optional","level":3,"title":"Step 6: Import Session Transcripts (Optional)","text":"

      If you want to browse past session transcripts, import them to the journal:

      ctx journal import --all\n

      This converts raw session data into editable Markdown files in .context/journal/. You can then enrich them with metadata using /ctx-journal-enrich-all inside your AI assistant.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      Here is the condensed setup for all three tools:

      # ## Common (run once per project) ##\ncd your-project\nctx init\nsource <(ctx completion zsh)       # or bash/fish\n\n# ## Claude Code (automatic, just verify) ##\n# Start Claude Code, then ask: \"Do you remember?\"\n\n# ## Cursor ##\nctx setup cursor\n# Add the system prompt to .cursor/settings.json\n# Paste context: ctx agent --budget 4000 | pbcopy\n\n# ## Aider ##\nctx setup aider\n# Create .aider.conf.yml with read: paths\n# Run watch mode alongside: ctx watch --log /tmp/aider.log\n\n# ## Verify any Tool ##\n# Ask your AI: \"Do you remember?\"\n# Expect: specific tasks, decisions, recent context\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tips","level":2,"title":"Tips","text":"
      • Start with ctx init (not --minimal) for your first project. The full template set gives the agent more to work with, and you can always delete files later.
      • For Claude Code, the token budget is configured in the plugin's hooks.json. To customize, adjust the --budget flag in the ctx agent hook command.
      • The --session $PPID flag isolates cooldowns per Claude Code process, so parallel sessions do not suppress each other.
      • Commit your .context/ directory to version control. Several ctx features (journals, changelogs, blog generation) rely on git history.
      • For Cursor and Copilot, keep CONVENTIONS.md visible. These tools treat open files as higher-priority context.
      • Run ctx drift periodically to catch stale references before they confuse the agent.
      • The agent playbook instructs the agent to persist context at natural milestones (completed tasks, decisions, gotchas). In practice, this works best when you reinforce the habit: a quick \"anything worth saving?\" after a debugging session goes a long way.
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#companion-tools-highly-recommended","level":2,"title":"Companion Tools (Highly Recommended)","text":"

      ctx skills can leverage external MCP servers for web search and code intelligence. ctx works without them, but they significantly improve agent behavior across sessions. The investment is small and the benefits compound. Skills like /ctx-code-review, /ctx-explain, and /ctx-refactor all become noticeably better with these tools connected.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gemini-search","level":3,"title":"Gemini Search","text":"

      Provides grounded web search with citations. Used by skills and the agent playbook as the preferred search backend (faster and more accurate than built-in web search).

      Setup: Add the Gemini Search MCP server to your Claude Code settings. See the Gemini Search MCP documentation for installation.

      Verification:

      # The agent checks this automatically during /ctx-remember\n# Manual test: ask the agent to search for something\n

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gitnexus","level":3,"title":"GitNexus","text":"

      Provides a code knowledge graph with symbol resolution, blast radius analysis, and domain clustering. Used by skills like /ctx-refactor (impact analysis) and /ctx-code-review (dependency awareness).

      Setup: Add the GitNexus MCP server to your Claude Code settings, then index your project:

      npx gitnexus analyze\n

      Verification:

      # The agent checks this automatically during /ctx-remember\n# If the index is stale, it will suggest rehydrating\n

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#suppressing-the-check","level":3,"title":"Suppressing the Check","text":"

      If you don't use companion tools and want to skip the availability check at session start, add to .ctxrc:

      companion_check: false\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#future-direction","level":3,"title":"Future Direction","text":"

      The companion tool integration is evolving toward a pluggable model: bring your own search engine, bring your own code intelligence. The current integration is MCP-based and limited to Gemini Search and GitNexus. If you use a different search or code intelligence tool, skills will degrade gracefully to built-in capabilities.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#next-up","level":2,"title":"Next Up","text":"

      Keeping Context in a Separate Repo →: Store context files outside the project tree for multi-repo or open source setups.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: full session lifecycle recipe
      • Multilingual Session Parsing: configure session header prefixes for other languages
      • CLI Reference: all commands and flags
      • Integrations: detailed per-tool integration docs
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multilingual-sessions/","level":1,"title":"Multilingual Session Parsing","text":"","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#the-problem","level":2,"title":"The Problem","text":"

      Your team works across languages. Session files written by AI tools might use headers like # Oturum: 2026-01-15 - API Düzeltme (Turkish) or # セッション: 2026-01-15 - テスト (Japanese) instead of # Session: 2026-01-15 - Fix API.

      By default, ctx only recognizes Session: as a session header prefix. Files with other prefixes are silently skipped during journal import and journal generation: They look like regular Markdown, not sessions.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#tldr","level":2,"title":"TL;DR","text":"

      Add recognized prefixes to .ctxrc:

      session_prefixes:\n  - \"Session:\"      # English (include to keep default)\n  - \"Oturum:\"       # Turkish\n  - \"セッション:\"     # Japanese\n

      Restart your session. All configured prefixes are now recognized.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#how-it-works","level":2,"title":"How It Works","text":"

      The Markdown session parser detects session files by looking for an H1 header that starts with a known prefix followed by a date:

      # Session: 2026-01-15 - Fix API Rate Limiting\n# Oturum: 2026-01-15 - API Düzeltme\n# セッション: 2026-01-15 - テスト\n

      The list of recognized prefixes comes from session_prefixes in .ctxrc. When the key is absent or empty, ctx falls back to the built-in default: [\"Session:\"].

      Date-only headers (# 2026-01-15 - Morning Work) are always recognized regardless of prefix configuration.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#configuration","level":2,"title":"Configuration","text":"","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#adding-a-language","level":3,"title":"Adding a Language","text":"

      Add the prefix with a trailing colon to your .ctxrc:

      session_prefixes:\n  - \"Session:\"\n  - \"Sesión:\"       # Spanish\n

      Include Session: Explicitly

      When you override session_prefixes, the default is replaced, not extended. If you still want English headers recognized, include \"Session:\" in your list.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#team-setup","level":3,"title":"Team Setup","text":"

      Commit .ctxrc to the repo so all team members share the same prefix list. This ensures ctx journal import and journal generation pick up sessions from all team members regardless of language.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#common-prefixes","level":3,"title":"Common Prefixes","text":"Language Prefix English Session: Turkish Oturum: Spanish Sesión: French Session: German Sitzung: Japanese セッション: Korean 세션: Portuguese Sessão: Chinese 会话:","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#verifying","level":3,"title":"Verifying","text":"

      After configuring, test with ctx journal source. Sessions with the new prefixes should appear in the output.

      Activate the Project First

      Run eval \"$(ctx activate)\" from the project root. If you skip it, ctx journal ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#what-this-does-not-do","level":2,"title":"What This Does NOT Do","text":"
      • Change the interface language: ctx output is always English. This setting only controls which session files ctx can parse.
      • Generate headers: ctx never writes session headers. The prefix list is recognition-only (input, not output).
      • Affect JSONL sessions: Claude Code JSONL transcripts don't use header prefixes. This only applies to Markdown session files in .context/sessions/.
      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#see-also","level":2,"title":"See Also","text":"

      See also: Setup Across AI Tools - complete multi-tool setup including Markdown session configuration.

      See also: CLI Reference - full .ctxrc field reference including session_prefixes.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/parallel-worktrees/","level":1,"title":"Parallel Agent Development with Git Worktrees","text":"","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#the-problem","level":2,"title":"The Problem","text":"

      You have a large backlog (10, 20, 30 open tasks) and many of them are independent: docs work that doesn't touch Go code, a new package that doesn't overlap with existing ones, test coverage for a stable module.

      Running one agent at a time means serial execution. You want 3-4 agents working in parallel, each on its own track, without stepping on each other's files.

      Git worktrees solve this.

      Each worktree is a separate working directory with its own branch, but they share the same .git object database. Combined with ctx's persistent context, each agent session picks up the full project state and works independently.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-worktree                                   # 1. group tasks by file overlap\ngit worktree add ../myproject-docs -b work/docs # 2. create worktrees\ncd ../myproject-docs && claude                  # 3. launch agents (one per track)\n/ctx-worktree teardown docs                     # 4. merge back and clean up\n

      TASKS.md will conflict on merge: Accept all [x] completions from both sides.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-worktree Skill Create, list, and tear down worktrees /ctx-next Skill Pick tasks from the backlog for each track git worktree Command Underlying git worktree management git merge Command Merge completed tracks back to main","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-1-assess-the-backlog","level":3,"title":"Step 1: Assess the Backlog","text":"

      Start in your main checkout. Ask the agent to analyze your tasks and group them by blast radius: which files and directories each task touches.

      /ctx-worktree\nLook at TASKS.md and group the pending tasks into 2-3 independent\ntracks based on which files they'd touch. Show me the grouping\nbefore creating anything.\n

      The agent reads TASKS.md, estimates file overlap, and proposes groups:

      Proposed worktree groups:\n\n  work/docs   # recipe updates, blog post (touches: docs/)\n  work/crypto # scratchpad encryption infra (touches: internal/crypto/)\n  work/tests  # journal test coverage (touches: internal/cli/journal/)\n
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-2-create-the-worktrees","level":3,"title":"Step 2: Create the Worktrees","text":"

      Once you approve the grouping, the agent creates worktrees as sibling directories:

      Create the worktrees for those three groups.\n

      Behind the scenes:

      git worktree add ../myproject-docs -b work/docs\ngit worktree add ../myproject-crypto -b work/crypto\ngit worktree add ../myproject-tests -b work/tests\n

      Each worktree is a full working copy on its own branch.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-3-launch-agents","level":3,"title":"Step 3: Launch Agents","text":"

      Open a separate terminal (or editor window) for each worktree and start a Claude Code session:

      # Terminal 1\ncd ../myproject-docs\nclaude\n\n# Terminal 2\ncd ../myproject-crypto\nclaude\n\n# Terminal 3\ncd ../myproject-tests\nclaude\n

      Each agent sees the full project, including .context/, and can work independently.

      Do Not Initialize Context in Worktrees

      Do not run ctx init in worktrees: The .context directory is already tracked in git.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-4-work","level":3,"title":"Step 4: Work","text":"

      Each agent works through its assigned tasks. They can read TASKS.md to know what's assigned to their track, use /ctx-next to pick the next item, and commit normally on their work/* branch.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-5-merge-back","level":3,"title":"Step 5: Merge Back","text":"

      As each track finishes, return to the main checkout and merge:

      /ctx-worktree teardown docs\n

      The agent checks for uncommitted changes, merges work/docs into your current branch, removes the worktree, and deletes the branch.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-6-handle-tasksmd-conflicts","level":3,"title":"Step 6: Handle TASKS.md Conflicts","text":"

      TASKS.md will almost always conflict when merging: Multiple agents will mark different tasks as [x]. This is expected and easy to resolve:

      Accept all completions from both sides. No task should go from [x] back to [ ]. The merge resolution is always additive.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-7-cleanup","level":3,"title":"Step 7: Cleanup","text":"

      After all tracks are merged, verify everything is clean:

      /ctx-worktree list\n

      Should show only the main working tree. All work/* branches should be gone.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't have to use the skill directly for every step. These natural prompts work:

      • \"I have a big backlog. Can we split it across worktrees?\"
      • \"Which of these tasks can run in parallel without conflicts?\"
      • \"Merge the docs track back in.\"
      • \"Clean up all the worktrees, we're done.\"
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#what-works-differently-in-worktrees","level":2,"title":"What Works Differently in Worktrees","text":"

      The encryption key lives at ~/.ctx/.ctx.key (user-level, outside the project). Because all worktrees on the same machine share this path, ctx pad and ctx hook notify work in worktrees automatically - no special setup needed.

      One thing to watch:

      • Journal enrichment: ctx journal import and ctx journal enrich write files relative to the current working directory. Enrichments created in a worktree stay there and are discarded on teardown. Enrich journals on the main branch after merging: the JSONL session logs are always intact, and you don't lose any data.

      Context Files Will Merge Just Fine

      Tracked context files (TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md) work normally; git handles them.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tips","level":2,"title":"Tips","text":"
      • 3-4 worktrees max. Beyond that, merge complexity outweighs the parallelism benefit. The skill enforces this limit.
      • Group by package or directory, not by priority. Two high-priority tasks that touch the same files must be in the same track.
      • TASKS.md will conflict on merge. This is normal. Accept all [x] completions: The resolution is always additive.
      • Don't run ctx init in worktrees. The .context/ directory is tracked in git. Running init overwrites shared context files.
      • Name worktrees by concern, not by number. work/docs and work/crypto are more useful than work/track-1 and work/track-2.
      • Commit frequently in each worktree. Smaller commits make merge conflicts easier to resolve.
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#next-up","level":2,"title":"Next Up","text":"

      Back to the beginning: Guide Your Agent →

      Or explore the full recipe list.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#see-also","level":2,"title":"See Also","text":"
      • Running an Unattended AI Agent: for serial autonomous loops instead of parallel tracks
      • Tracking Work Across Sessions: managing the task backlog that feeds into parallelization
      • The Complete Session: the complete session workflow end-to-end, with examples
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/permission-snapshots/","level":1,"title":"Permission Snapshots","text":"","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code's .claude/settings.local.json accumulates one-off permissions every time you click \"Allow\". After busy sessions the file is full of session-specific entries that expand the agent's surface area beyond intent.

      Since settings.local.json is .gitignored, there is no PR review or CI check. The file drifts independently on every machine, and there is no built-in way to reset to a known-good state.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-permission-sanitize               # audit for dangerous patterns\nctx permission snapshot            # save golden image\n# ... sessions accumulate cruft ...\nctx permission restore             # reset to golden state\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx permission ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#the-solution","level":2,"title":"The Solution","text":"

      Save a curated settings.local.json as a golden image, then restore from it to drop session-accumulated permissions. The golden file (.claude/settings.golden.json) is committed to version control and shared with the team.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Command/Skill Role in this workflow ctx permission snapshot Save settings.local.json as golden image ctx permission restore Reset settings.local.json from golden image /ctx-permission-sanitize Audit for dangerous patterns before snapshotting","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#step-by-step","level":2,"title":"Step by Step","text":"","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#1-curate-your-permissions","level":3,"title":"1. Curate Your Permissions","text":"

      Start with a clean settings.local.json. Optionally run /ctx-permission-sanitize to remove dangerous patterns first.

      Review the file manually. Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.

      See the Permission Hygiene recipe for recommended defaults.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#2-take-a-snapshot","level":3,"title":"2. Take a Snapshot","text":"
      ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n

      This creates a byte-for-byte copy. No re-encoding, no indent changes.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#3-commit-the-golden-file","level":3,"title":"3. Commit the Golden File","text":"
      git add .claude/settings.golden.json\ngit commit -m \"Add permission golden image\"\n

      The golden file is not gitignored (unlike settings.local.json). This is intentional: it becomes a team-shared baseline.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#4-auto-restore-at-the-session-start","level":3,"title":"4. Auto-Restore at the Session Start","text":"

      Add this instruction to your CLAUDE.md:

      ## On Session Start\n\nRun `ctx permission restore` to reset permissions to the golden image.\n

      The agent will restore the golden image at the start of every session, automatically dropping any permissions accumulated during previous sessions.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#5-update-when-intentional-changes-are-made","level":3,"title":"5. Update When Intentional Changes Are Made","text":"

      When you add a new permanent permission (not a one-off debugging entry):

      # Edit settings.local.json with the new permission\n# Then update the golden image:\nctx permission snapshot\ngit add .claude/settings.golden.json\ngit commit -m \"Update permission golden image: add cargo test\"\n
      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need to remember exact commands. These natural-language prompts work with agents trained on the ctx playbook:

      What you say What happens \"Save my current permissions as baseline\" Agent runs ctx permission snapshot \"Reset permissions to the golden image\" Agent runs ctx permission restore \"Clean up my permissions\" Agent runs /ctx-permission-sanitize then snapshot \"What permissions did I accumulate?\" Agent diffs local vs golden","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#next-up","level":2,"title":"Next Up","text":"

      Turning Activity into Content →: Generate blog posts, changelogs, and journal sites from your project activity.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#see-also","level":2,"title":"See Also","text":"
      • Permission Hygiene: recommended defaults and maintenance workflow
      • CLI Reference: ctx permission: full command documentation
      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/publishing/","level":1,"title":"Turning Activity into Content","text":"","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-problem","level":2,"title":"The Problem","text":"

      Your .context/ directory is full of decisions, learnings, and session history.

      Your git log tells the story of a project evolving.

      But none of this is visible to anyone outside your terminal.

      You want to turn this raw activity into:

      • a browsable journal site,
      • blog posts,
      • changelog posts.
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tldr","level":2,"title":"TL;DR","text":"
      ctx journal import --all             # 1. import sessions to markdown\n\n/ctx-journal-enrich-all             # 2. add metadata and tags\n\nctx journal site --serve            # 3. build and serve the journal\n\n/ctx-blog about the caching layer   # 4. draft a blog post\n/ctx-blog-changelog v0.1.0 \"v0.2\"   # 5. write a changelog post\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx journal ... fails with Error: no context directory specified. See Activating a Context Directory.

      Read on for details on each stage.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx journal import Command Import session JSONL to editable markdown ctx journal site Command Generate a static site from journal entries ctx journal obsidian Command Generate an Obsidian vault from journal entries ctx serve Command Serve any zensical directory (default: journal) ctx site feed Command Generate Atom feed from finalized blog posts make journal Makefile Shortcut for import + site rebuild /ctx-journal-enrich-all Skill Full pipeline: import if needed, then batch-enrich (recommended) /ctx-journal-enrich Skill Add metadata, summaries, and tags to one entry /ctx-blog Skill Draft a blog post from recent project activity /ctx-blog-changelog Skill Write a themed post from a commit range","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-1-import-sessions-to-markdown","level":3,"title":"Step 1: Import Sessions to Markdown","text":"

      Raw session data lives as JSONL files in Claude Code's internal storage. The first step is converting these into readable, editable markdown.

      # Import all sessions from the current project\nctx journal import --all\n\n# Import from all projects (if you work across multiple repos)\nctx journal import --all --all-projects\n\n# Import a single session by ID or slug\nctx journal import abc123\nctx journal import gleaming-wobbling-sutherland\n

      Imported files land in .context/journal/ as individual Markdown files with session metadata and the full conversation transcript.

      --all is safe by default: Only new sessions are imported. Existing files are skipped. Use --regenerate to re-import existing files (YAML frontmatter is preserved). Use --regenerate --keep-frontmatter=false -y to regenerate everything including frontmatter.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-2-enrich-entries-with-metadata","level":3,"title":"Step 2: Enrich Entries with Metadata","text":"

      Raw entries have timestamps and conversations but lack the structured metadata that makes a journal searchable. Use /ctx-journal-enrich-all to process your entire backlog at once:

      /ctx-journal-enrich-all\n

      The skill finds all unenriched entries, filters out noise (suggestion sessions, very short sessions, multipart continuations), and processes each one by extracting titles, topics, technologies, and summaries from the conversation.

      For large backlogs (20+ entries), it can spawn subagents to process entries in parallel.

      To enrich a single entry instead:

      /ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich 2026-01-24\n

      After enrichment, an entry gains YAML frontmatter:

      ---\ntitle: \"Implement Redis caching for API endpoints\"\ndate: 2026-01-24\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - api-performance\ntechnologies:\n  - go\n  - redis\nkey_files:\n  - internal/api/middleware/cache.go\n  - internal/cache/redis.go\n---\n

      This metadata powers better navigation in the journal site:

      • titles replace slugs,
      • summaries appear in the index,
      • and search covers topics and technologies.
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-3-generate-the-journal-site","level":3,"title":"Step 3: Generate the Journal Site","text":"

      With entries exported and enriched, generate the static site:

      # Generate site files\nctx journal site\n\n# Generate and build static HTML\nctx journal site --build\n\n# Generate and serve locally (opens at http://localhost:8000)\nctx journal site --serve\n\n# Custom output directory\nctx journal site --output ~/my-journal\n

      The site is generated in .context/journal-site/ by default. It uses zensical for static site generation (pipx install zensical).

      Or use the Makefile shortcut that combines export and rebuild:

      make journal\n

      This runs ctx journal import --all followed by ctx journal site --build, then reminds you to enrich before rebuilding. To serve the built site, use make journal-serve or ctx serve (serve-only, no regeneration).

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#alternative-export-to-obsidian-vault","level":3,"title":"Alternative: Export to Obsidian Vault","text":"

      If you use Obsidian for knowledge management, generate a vault instead of (or alongside) the static site:

      ctx journal obsidian\nctx journal obsidian --output ~/vaults/ctx-journal\n

      This produces an Obsidian-ready directory with wikilinks, MOC (Map of Content) pages for topics/files/types, and a \"Related Sessions\" footer on each entry for graph connectivity. Open the output directory in Obsidian as a vault.

      The vault uses the same enriched source entries as the static site. Both outputs can coexist: The static site goes to .context/journal-site/, the vault to .context/journal-obsidian/.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-4-draft-blog-posts-from-activity","level":3,"title":"Step 4: Draft Blog Posts from Activity","text":"

      When your project reaches a milestone worth sharing, use /ctx-blog to draft a post from recent activity. The skill gathers context from multiple sources: git log, DECISIONS.md, LEARNINGS.md, completed tasks, and journal entries.

      /ctx-blog about the caching layer we just built\n/ctx-blog last week's refactoring work\n/ctx-blog lessons learned from the migration\n

      The skill gathers recent commits, decisions, and learnings; identifies a narrative arc; drafts an outline for approval; writes the full post; and saves it to docs/blog/YYYY-MM-DD-slug.md.

      Posts are written in first person with code snippets, commit references, and an honest discussion of what went wrong.

      The Output Is zensical-Flavored Markdown

      The blog skills produce Markdown tuned for a zensical site: topics: frontmatter (zensical's tag field), a docs/blog/ output path, and a banner image reference.

      The content is still standard Markdown and can be adapted to other static site generators, but the defaults assume a zensical project structure.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-5-write-changelog-posts-from-commit-ranges","level":3,"title":"Step 5: Write Changelog Posts from Commit Ranges","text":"

      For release notes or \"what changed\" posts, /ctx-blog-changelog takes a starting commit and a theme, then analyzes everything that changed:

      /ctx-blog-changelog 040ce99 \"building the journal system\"\n/ctx-blog-changelog HEAD~30 \"what's new in v0.2.0\"\n/ctx-blog-changelog v0.1.0 \"the road to v0.2.0\"\n

      The skill diffs the commit range, identifies the most-changed files, and constructs a narrative organized by theme rather than chronology, including a key commits table and before/after comparisons.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-6-generate-the-blog-feed","level":3,"title":"Step 6: Generate the Blog Feed","text":"

      After publishing blog posts, generate the Atom feed so readers and automation can discover new content:

      ctx site feed\n

      This scans docs/blog/ for finalized posts (reviewed_and_finalized: true), extracts title, date, author, topics, and summary, and writes a valid Atom 1.0 feed to site/feed.xml. The feed is also generated automatically as part of make site.

      The feed is available at ctx.ist/feed.xml.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-conversational-approach","level":2,"title":"The Conversational Approach","text":"

      You can also drive your publishing anytime with natural language:

      \"write about what we did this week\"\n\"turn today's session into a blog post\"\n\"make a changelog post covering everything since the last release\"\n\"enrich the last few journal entries\"\n

      The agent has full visibility into your .context/ state (tasks completed, decisions recorded, learnings captured), so its suggestions are grounded in what actually happened.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      The full pipeline from raw transcripts to published content:

      # 1. Import all sessions\nctx journal import --all\n\n# 2. In Claude Code: enrich all entries with metadata\n/ctx-journal-enrich-all\n\n# 3. Build and serve the journal site\nmake journal\nmake journal-serve\n\n# 3b. Or generate an Obsidian vault\nctx journal obsidian\n\n# 4. In Claude Code: draft a blog post\n/ctx-blog about the features we shipped this week\n\n# 5. In Claude Code: write a changelog post\n/ctx-blog-changelog v0.1.0 \"what's new in v0.2.0\"\n

      The journal pipeline is idempotent at every stage. You can rerun ctx journal import --all without losing enrichment. You can rebuild the site as many times as you want.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tips","level":2,"title":"Tips","text":"
      • Import regularly. Run ctx journal import --all after each session to keep your journal current. Only new sessions are imported: Existing files are skipped by default.
      • Use batch enrichment. /ctx-journal-enrich-all filters noise (suggestion sessions, trivial sessions, multipart continuations) so you do not have to decide what is worth enriching.
      • Keep journal files in .gitignore. Session journals can contain sensitive data: file contents, commands, internal discussions, and error messages with stack traces. Add .context/journal/ and .context/journal-site/ to .gitignore.
      • Use /ctx-blog for narrative posts and /ctx-blog-changelog for release posts. One finds a story in recent activity, the other explains a commit range by theme.
      • Edit the drafts. These skills produce drafts, not final posts. Review the narrative, add your perspective, and remove anything that does not serve the reader.
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#next-up","level":2,"title":"Next Up","text":"

      Running an Unattended AI Agent →: Set up an AI agent that works through tasks overnight without you at the keyboard.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#see-also","level":2,"title":"See Also","text":"
      • Session Journal: journal system, enrichment schema
      • CLI Reference: ctx journal: import, list, show session history
      • CLI Reference: ctx journal site: static site generation
      • CLI Reference: ctx journal obsidian: Obsidian vault export
      • CLI Reference: ctx serve: serve-only (no regeneration)
      • Browsing and Enriching Past Sessions: journal browsing workflow
      • The Complete Session: capturing context during a session
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/scratchpad-sync/","level":1,"title":"Syncing Scratchpad Notes Across Machines","text":"","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#the-problem","level":2,"title":"The Problem","text":"

      You work from multiple machines: a desktop and a laptop, or a local machine and a remote dev server.

      The scratchpad entries are encrypted. The ciphertext (.context/scratchpad.enc) travels with git, but the encryption key lives outside the project at ~/.ctx/.ctx.key and is never committed. Without the key on each machine, you cannot read or write entries.

      How do you distribute the key and keep the scratchpad in sync?

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tldr","level":2,"title":"TL;DR","text":"
      ctx init                                                  # 1. generates key\neval \"$(ctx activate)\"                                    # 2. bind CTX_DIR\nscp ~/.ctx/.ctx.key user@machine-b:~/.ctx/.ctx.key        # 3. copy key\nchmod 600 ~/.ctx/.ctx.key                                 # 4. secure it\n# Normal git push/pull syncs the encrypted scratchpad.enc\n# On conflict: ctx pad resolve → rebuild → git add + commit\n

      Activate Each Machine

      Run eval \"$(ctx activate)\" from the project root on every machine that reads or writes the scratchpad: after each ctx init, or after each clone on machine B. If you skip it, ctx pad ... fails with Error: no context directory specified. See Activating a Context Directory.

      Finding Your Key File

      The key is always at ~/.ctx/.ctx.key - one key, one machine.

      Treat the Key like a Password

      The scratchpad key is the only thing protecting your encrypted entries.

      Store a backup in a secure enclave such as a password manager, and treat it with the same care you would give passwords, certificates, or API tokens.

      Anyone with the key can decrypt every scratchpad entry.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx init CLI command Initialize context (generates the key automatically) ctx pad add CLI command Add a scratchpad entry ctx pad rm CLI command Remove entries by stable ID (supports ranges) ctx pad edit CLI command Edit a scratchpad entry ctx pad resolve CLI command Show both sides of a merge conflict ctx pad merge CLI command Merge entries from other scratchpad files ctx pad import CLI command Bulk-import lines from a file ctx pad export CLI command Export blob entries to a directory scp Shell Copy the key file between machines git push / git pull Shell Sync the encrypted file via git /ctx-pad Skill Natural language interface to pad commands","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-1-initialize-on-machine-a","level":3,"title":"Step 1: Initialize on Machine A","text":"

      Run ctx init on your first machine. The key is created automatically at ~/.ctx/.ctx.key:

      ctx init\n# ...\n# Created ~/.ctx/.ctx.key (0600)\n# Created .context/scratchpad.enc\n

      The key lives outside the project directory and is never committed. The .enc file is tracked in git.

      Key Folder Change (v0.7.0+)

      If you built ctx from source or upgraded past v0.6.0, the key location changed to ~/.ctx/.ctx.key. Check these legacy folders and copy your key manually:

      # Old locations (pick whichever exists)\nls ~/.local/ctx/keys/        # pre-v0.7.0 user-level\nls .context/.ctx.key         # pre-v0.6.0 project-local\n\n# Copy to the new location\nmkdir -p ~/.ctx && chmod 700 ~/.ctx\ncp <old-key-path> ~/.ctx/.ctx.key\nchmod 600 ~/.ctx/.ctx.key\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-2-copy-the-key-to-machine-b","level":3,"title":"Step 2: Copy the Key to Machine B","text":"

      Use any secure transfer method. The key is always at ~/.ctx/.ctx.key:

      # scp - create the target directory first\nssh user@machine-b \"mkdir -p ~/.ctx && chmod 700 ~/.ctx\"\nscp ~/.ctx/.ctx.key user@machine-b:~/.ctx/.ctx.key\n\n# Or use a password manager, USB drive, etc.\n

      Set permissions on Machine B:

      chmod 600 ~/.ctx/.ctx.key\n

      Secure the Transfer

      The key is a raw 256-bit AES key. Anyone with the key can decrypt the scratchpad. Use an encrypted channel (SSH, password manager, vault).

      Never paste it in plaintext over email or chat.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-3-normal-pushpull-workflow","level":3,"title":"Step 3: Normal Push/Pull Workflow","text":"

      The encrypted file is committed, so standard git sync works:

      # Machine A: add entries and push\nctx pad add \"staging API key: sk-test-abc123\"\ngit add .context/scratchpad.enc\ngit commit -m \"Update scratchpad\"\ngit push\n\n# Machine B: pull and read\ngit pull\nctx pad\n#   1. staging API key: sk-test-abc123\n

      Both machines have the same key, so both can decrypt the same .enc file.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-4-read-and-write-from-either-machine","level":3,"title":"Step 4: Read and Write from Either Machine","text":"

      Once the key is distributed, all ctx pad commands work identically on both machines. Entries added on Machine A are visible on Machine B after a git pull, and vice versa.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-5-handle-merge-conflicts","level":3,"title":"Step 5: Handle Merge Conflicts","text":"

      If both machines add entries between syncs, pulling will create a merge conflict on .context/scratchpad.enc. Git cannot merge binary (encrypted) content automatically.

      The fastest approach is ctx pad merge: It reads both conflict sides, deduplicates, and writes the union:

      # Extract theirs to a temp file, then merge it in\ngit show :3:.context/scratchpad.enc > /tmp/theirs.enc\ngit checkout --ours .context/scratchpad.enc\nctx pad merge /tmp/theirs.enc\n\n# Done: Commit the resolved scratchpad:\ngit add .context/scratchpad.enc\ngit commit -m \"Resolve scratchpad merge conflict\"\n

      Alternatively, use ctx pad resolve to inspect both sides manually:

      ctx pad resolve\n# === Ours (this machine) ===\n#   1. staging API key: sk-test-abc123\n#   2. check DNS after deploy\n#\n# === Theirs (incoming) ===\n#   1. staging API key: sk-test-abc123\n#   2. new endpoint: api.example.com/v2\n

      Then reconstruct the merged scratchpad:

      # Start fresh with all entries from both sides\nctx pad add \"staging API key: sk-test-abc123\"\nctx pad add \"check DNS after deploy\"\nctx pad add \"new endpoint: api.example.com/v2\"\n\n# Mark the conflict resolved\ngit add .context/scratchpad.enc\ngit commit -m \"Resolve scratchpad merge conflict\"\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#merge-conflict-walkthrough","level":2,"title":"Merge Conflict Walkthrough","text":"

      Here's a full scenario showing how conflicts arise and how to resolve them:

      1. Both machines start in sync (1 entry):

      Machine A: 1. staging API key: sk-test-abc123\nMachine B: 1. staging API key: sk-test-abc123\n

      2. Both add entries independently:

      Machine A adds: \"check DNS after deploy\"\nMachine B adds: \"new endpoint: api.example.com/v2\"\n

      3. Machine A pushes first. Machine B pulls and gets a conflict:

      git pull\n# CONFLICT (content): Merge conflict in .context/scratchpad.enc\n

      4. Machine B runs ctx pad resolve:

      ctx pad resolve\n# === Ours ===\n#   1. staging API key: sk-test-abc123\n#   2. new endpoint: api.example.com/v2\n#\n# === Theirs ===\n#   1. staging API key: sk-test-abc123\n#   2. check DNS after deploy\n

      5. Rebuild with entries from both sides and commit:

      # Clear and rebuild (or use the skill to guide you)\nctx pad add \"staging API key: sk-test-abc123\"\nctx pad add \"check DNS after deploy\"\nctx pad add \"new endpoint: api.example.com/v2\"\n\ngit add .context/scratchpad.enc\ngit commit -m \"Merge scratchpad: keep entries from both machines\"\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#conversational-approach","level":3,"title":"Conversational Approach","text":"

      When working with an AI assistant, you can resolve conflicts naturally:

      You: \"I have a scratchpad merge conflict. Can you resolve it?\"\n\nAgent: \"Let me extract theirs and merge it in.\"\n       [runs git show :3:.context/scratchpad.enc > /tmp/theirs.enc]\n       [runs git checkout --ours .context/scratchpad.enc]\n       [runs ctx pad merge /tmp/theirs.enc]\n       \"Merged 2 new entries (1 duplicate skipped). Want me to\n       commit the resolution?\"\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tips","level":2,"title":"Tips","text":"
      • Back up the key: If you lose it, you lose access to all encrypted entries. Store a copy in your password manager.
      • One key per project: Each ctx init generates a unique key. Don't reuse keys across projects.
      • Keys work in worktrees: Because the key lives at ~/.ctx/.ctx.key (outside the project), git worktrees on the same machine share the key automatically. No special setup needed.
      • Plaintext fallback for non-sensitive projects: If encryption adds friction and you have nothing sensitive, set scratchpad_encrypt: false in .ctxrc. Merge conflicts become trivial text merges.
      • Never commit the key: The key is stored outside the project at ~/.ctx/.ctx.key and should never be copied into the repository.
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#next-up","level":2,"title":"Next Up","text":"

      Hook Output Patterns →: Choose the right output pattern for your Claude Code hooks.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#see-also","level":2,"title":"See Also","text":"
      • Scratchpad: feature overview, all commands, when to use scratchpad vs context files
      • Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-with-claude/","level":1,"title":"Using the Scratchpad","text":"","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#the-problem","level":2,"title":"The Problem","text":"

      During a session you accumulate quick notes, reminders, intermediate values, and sometimes sensitive tokens. They don't fit TASKS.md (not work items) or DECISIONS.md (not decisions). They don't have the structured fields that LEARNINGS.md requires.

      Without somewhere to put them, they get lost between sessions.

      How do you capture working memory that persists across sessions without polluting your structured context files?

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tldr","level":2,"title":"TL;DR","text":"
      ctx pad add \"check DNS propagation after deploy\"\nctx pad         # list entries\nctx pad show 1  # print entry (pipe-friendly)\n

      Entries are encrypted at rest and travel with git.

      Use the /ctx-pad skill to manage entries from inside your AI session.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx pad ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx pad CLI command List all scratchpad entries ctx pad show N CLI command Output raw text of entry N (pipe-friendly) ctx pad add CLI command Add a new entry ctx pad edit CLI command Replace, append to, or prepend to an entry ctx pad add --file CLI command Ingest a file as a blob entry ctx pad show N --out CLI command Extract a blob entry to a file ctx pad rm CLI command Remove entries by stable ID (supports ranges) ctx pad normalize CLI command Reassign entry IDs as 1..N ctx pad mv CLI command Reorder entries ctx pad --tag CLI command Filter entries by tag ctx pad tags CLI command List all tags with counts ctx pad import CLI command Bulk-import lines from a file (or stdin) ctx pad export CLI command Export all blob entries to a directory /ctx-pad Skill Natural language interface to all pad commands","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-1-add-a-note-naturally","level":3,"title":"Step 1: Add a Note Naturally","text":"

      You don't need to remember any syntax. Just tell your assistant what to jot down:

      You: \"jot down: check DNS propagation after deploy\"\n\nAgent: \"Added to scratchpad:\n  1. check DNS propagation after deploy\"\n

      Behind the scenes, the agent runs ctx pad add \"check DNS propagation after deploy\".

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-2-view-your-scratchpad","level":3,"title":"Step 2: View Your Scratchpad","text":"
      You: \"show my scratchpad\"\n\nAgent: \"Your scratchpad has 3 entries:\n  1. check DNS propagation after deploy\n  2. staging API endpoint: api.staging.example.com/v2\n  3. retry limit should be 5, not 3\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-3-edit-an-entry","level":3,"title":"Step 3: Edit an Entry","text":"
      You: \"update entry 2 to include the new endpoint\"\n\nAgent: \"Updated entry 2:\n  was: staging API endpoint: api.staging.example.com/v2\n  now: staging API endpoint: api.prod.example.com/v2\"\n

      For partial edits, the agent can use --append or --prepend:

      You: \"append the port number to entry 2\"\n\nAgent: \"Updated entry 2:\n  staging API endpoint: api.prod.example.com/v2 :8443\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-4-compose-entries","level":3,"title":"Step 4: Compose Entries","text":"

      Use ctx pad show N to pipe entry content into other operations:

      You: \"append the content of entry 3 to entry 1\"\n\nAgent: [runs ctx pad edit 1 --append \"$(ctx pad show 3)\"]\n       \"Done. Entry 1 is now:\n        check DNS propagation after deploy retry limit should be 5, not 3\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-5-reorder-by-priority","level":3,"title":"Step 5: Reorder by Priority","text":"
      You: \"move entry 4 to the top\"\n\nAgent: [runs ctx pad mv 4 1]\n       \"Moved entry 4 to position 1. Scratchpad reordered.\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-6-clean-up","level":3,"title":"Step 6: Clean Up","text":"
      You: \"remove entry 2, it's done\"\n\nAgent: [runs ctx pad rm 2]\n       \"Removed entry 2. 3 entries remaining.\n        (IDs are stable; remaining entries keep their IDs.)\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-7-store-a-file-as-a-blob","level":3,"title":"Step 7: Store a File as a Blob","text":"

      The scratchpad can hold small files (up to 64 KB) as encrypted blob entries. The file is base64-encoded and stored alongside a label you provide:

      # Ingest a file: the first argument is the label\nctx pad add \"deploy config\" --file ./deploy.yaml\n\n# List shows the label with a [BLOB] marker\nctx pad\n#   1. check DNS propagation after deploy\n#   2. deploy config [BLOB]\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-8-extract-a-blob","level":3,"title":"Step 8: Extract a Blob","text":"

      Use show --out to write the decoded file back to disk:

      # Write blob entry to a file\nctx pad show 2 --out ./recovered-deploy.yaml\n\n# Or print to stdout (for piping)\nctx pad show 2 | head -5\n

      Blob entries are encrypted identically to text entries: They're just base64-encoded before encryption. The --out flag decodes and writes the raw bytes.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-9-bulk-import-notes","level":3,"title":"Step 9: Bulk Import Notes","text":"

      When you have a file with many notes (one per line), import them in bulk instead of adding one at a time:

      # Import from a file: Each non-empty line becomes an entry\nctx pad import notes.txt\n\n# Or pipe from stdin\ngrep TODO *.go | ctx pad import -\n

      All entries are written in a single encrypt/write cycle, regardless of how many lines the file contains.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-10-export-blobs-to-disk","level":3,"title":"Step 10: Export Blobs to Disk","text":"

      Export all blob entries to a directory as individual files. Each blob's label becomes the filename:

      # Export to a directory (created if needed)\nctx pad export ./ideas\n\n# Preview what would be exported\nctx pad export --dry-run ./ideas\n\n# Force overwrite existing files\nctx pad export --force ./backup\n

      When a file already exists, a unix timestamp is prepended to the filename to avoid collisions. Use --force to overwrite instead.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-11-tag-entries-for-organization","level":3,"title":"Step 11: Tag Entries for Organization","text":"

      Tags let you categorize entries without any structure beyond a #word token in the text. Add them when creating or editing entries:

      You: \"jot down: check DNS propagation #later\"\nYou: \"tag entry 2 as urgent\"\n\nAgent: [runs ctx pad edit 2 --tag urgent]\n       \"Updated entry 2.\"\n

      Filter your scratchpad by tag:

      You: \"show me everything tagged later\"\n\nAgent: [runs ctx pad --tag later]\n       \"  1. check DNS propagation #later\n        3. review PR feedback #later #ci\"\n

      Entry IDs are stable; they don't shift when other entries are deleted, so ctx pad rm 3 always targets the same entry regardless of deletions or active filters. Use ctx pad normalize to reassign IDs as 1..N.

      Exclude a tag with ~:

      ctx pad --tag ~later         # everything NOT tagged #later\nctx pad --tag later --tag ci # entries with BOTH tags (AND logic)\n

      See what tags you're using:

      You: \"what tags do I have?\"\n\nAgent: [runs ctx pad tags]\n       \"ci       1\n        later    2\n        urgent   1\"\n

      Tags work on blob entries too; they're extracted from the label:

      ctx pad add \"deploy config #prod\" --file ./deploy.yaml\nctx pad --tag prod\n#   1. deploy config #prod [BLOB]\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#using-ctx-pad-in-a-session","level":2,"title":"Using /ctx-pad in a Session","text":"

      Invoke the /ctx-pad skill first, then describe what you want in natural language. Without the skill prefix, the agent may route your request to TASKS.md or another context file instead of the scratchpad.

      You: /ctx-pad jot down: check DNS after deploy\nYou: /ctx-pad show my scratchpad\nYou: /ctx-pad delete entry 3\n

      Once the skill is active, it translates intent into commands:

      You say (after /ctx-pad) What the agent does \"jot down: check DNS after deploy\" ctx pad add \"check DNS after deploy\" \"remember this: retry limit is 5\" ctx pad add \"retry limit is 5\" \"show my scratchpad\" / \"what's on my pad\" ctx pad \"show me entry 3\" ctx pad show 3 \"delete the third one\" / \"remove entry 3\" ctx pad rm 3 \"remove entries 3 through 5\" ctx pad rm 3-5 \"renumber my scratchpad\" ctx pad normalize \"change entry 2 to ...\" ctx pad edit 2 \"new text\" \"append ' +important' to entry 3\" ctx pad edit 3 --append \" +important\" \"prepend 'URGENT:' to entry 1\" ctx pad edit 1 --prepend \"URGENT: \" \"prioritize entry 4\" / \"move to the top\" ctx pad mv 4 1 \"import my notes from notes.txt\" ctx pad import notes.txt \"export all blobs to ./ideas\" ctx pad export ./ideas \"show entries tagged later\" ctx pad --tag later \"show everything except later\" ctx pad --tag ~later \"what tags do I have\" ctx pad tags \"tag entry 5 as urgent\" ctx pad edit 5 --tag urgent

      When in Doubt, Use the CLI Directly

      The ctx pad commands work the same whether you run them yourself or let the skill invoke them.

      If the agent misroutes a request, fall back to ctx pad add \"...\" in your terminal.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#when-to-use-scratchpad-vs-context-files","level":2,"title":"When to Use Scratchpad vs Context Files","text":"Situation Use Temporary reminders (\"check X after deploy\") Scratchpad Session-start reminders (\"remind me next session\") ctx remind Working values during debugging (ports, endpoints, counts) Scratchpad Sensitive tokens or API keys (short-term storage) Scratchpad Quick notes that don't fit anywhere else Scratchpad Work items with completion tracking TASKS.md Trade-offs between alternatives with rationale DECISIONS.md Reusable lessons with context/lesson/application LEARNINGS.md Codified patterns and standards CONVENTIONS.md

      Decision Guide

      • If it has structured fields (context, rationale, lesson, application), it belongs in a context file like DECISIONS.md or LEARNINGS.md.
      • If it's a work item you'll mark done, it belongs in TASKS.md.
      • If you want a message relayed VERBATIM at the next session start, it belongs in ctx remind.
      • If it's a quick note, reminder, or working value (especially if it's sensitive or ephemeral) it belongs on the scratchpad.

      Scratchpad Is Not a Junk Drawer

      The scratchpad is for working memory, not long-term storage.

      If a note is still relevant after several sessions, promote it:

      A persistent reminder becomes a task, a recurring value becomes a convention, a hard-won insight becomes a learning.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tips","level":2,"title":"Tips","text":"
      • Entries persist across sessions: The scratchpad is committed (encrypted) to git, so entries survive session boundaries. Pick up where you left off.
      • Entries are numbered and reorderable: Use ctx pad mv to put high-priority items at the top.
      • ctx pad show N enables unix piping: Output raw entry text with no numbering prefix. Compose with --append, --prepend, or other shell tools.
      • Never mention the key file contents to the AI: The agent knows how to use ctx pad commands but should never read or print the encryption key (~/.ctx/.ctx.key) directly.
      • Encryption is transparent: You interact with plaintext; the encryption/decryption happens automatically on every read/write.
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#next-up","level":2,"title":"Next Up","text":"

      Syncing Scratchpad Notes Across Machines →: Distribute encryption keys and scratchpad data across environments.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#see-also","level":2,"title":"See Also","text":"
      • Scratchpad: feature overview, all commands, encryption details, plaintext override
      • Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad
      • The Complete Session: full session lifecycle showing how the scratchpad fits into the broader workflow
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/","level":1,"title":"Scrutinizing a Plan","text":"

      When you have a plan and want it attacked, not validated, the /ctx-plan skill runs an adversarial interview. It surfaces what's weak, missing, or unexamined before you commit.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#when-to-use-it","level":2,"title":"When to Use It","text":"
      • Before starting a multi-day implementation.
      • After writing a spec but before opening the first PR.
      • When the team aligned suspiciously fast on a complex change.
      • When you've drafted something and the obvious next step is to hand it to a senior reviewer.

      /ctx-plan is not a brainstorming tool. Use /ctx-brainstorm for that. /ctx-plan assumes the plan exists and asks: does it survive contact with reality?

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#stop-conditions","level":2,"title":"Stop Conditions","text":"

      The skill runs depth-first through assumptions, tradeoffs, and failure modes. Stop when one of these is true:

      • Plan converges. The bet is clear, the sequencing is justified, and you can articulate what would falsify it.
      • Plan dissolves. The interview surfaces a load-bearing assumption you can't defend; the plan needs rework, not more scrutiny.
      • You hit information you don't have. Pause, gather it, resume.

      If the agent loops on a single angle (asking variations of the same question), say so. The skill is designed to walk depth-first, not exhaust one branch.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#worked-example","level":2,"title":"Worked Example","text":"
      You: /ctx-plan\n\nI want to migrate our queue from RabbitMQ to NATS. I've drafted a\ntwo-week plan: spike NATS in staging, port one consumer, port the\nrest, decommission RabbitMQ.\n\nAgent: One question at a time. What breaks if your message ordering\n       guarantees aren't equivalent across the two systems?\n\nYou: NATS gives us per-subject ordering by default; we don't actually\n     need cross-subject ordering, so I think we're fine.\n\nAgent: How would you notice if you were wrong? What's the loudest\n       symptom of a stray out-of-order message in production today?\n\nYou: ...probably a duplicate notification. Which we already see\n     occasionally. So we wouldn't notice immediately.\n\nAgent: Then your migration's correctness check needs to be stronger\n       than \"no incidents.\" Before you port consumer two, what\n       evidence would convince you that consumer one's ordering\n       behavior is correct under load?\n\nYou: Right. Add a dedicated assertion test in staging that replays\n     a known-out-of-order sequence and verifies the consumer\n     dedupes correctly. Otherwise we're just hoping.\n\nAgent: Good. Next: what would change your mind about NATS itself?\n       What rejected alternative is closest to coming back?\n

      The interview keeps going until the bet is articulated, the falsifiable conditions are written down, and the rejected alternatives have a recall trigger.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#output","level":2,"title":"Output","text":"

      /ctx-plan produces a clearer plan, not a document. Persist the deltas via:

      • /ctx-spec if the conclusions belong in a feature spec.
      • /ctx-decision-add if a tradeoff resolved into an architectural decision.
      • /ctx-learning-add if you discovered a project-specific gotcha during the interview.

      The skill itself is in internal/assets/claude/skills/ctx-plan/SKILL.md; the working contract lives there, the recipe is the on-ramp.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#see-also","level":2,"title":"See Also","text":"
      • Design Before Coding: the brainstorming counterpart, used before a plan exists.
      • ctx-spec: scaffolds a feature spec from the project template.
      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/session-archaeology/","level":1,"title":"Browsing and Enriching Past Sessions","text":"","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-problem","level":2,"title":"The Problem","text":"

      After weeks of AI-assisted development you have dozens of sessions scattered across JSONL files in ~/.claude/projects/. Finding the session where you debugged the Redis connection pool, or remembering what you decided about the caching strategy three Tuesdays ago, often means grepping raw JSON.

      There is no table of contents, no search, and no summaries.

      This recipe shows how to turn that raw session history into a browsable, searchable, and enriched journal site you can navigate in your browser.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tldr","level":2,"title":"TL;DR","text":"

      Export and Generate

      ctx journal import --all\nctx journal site --serve\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, the ctx journal ... commands below fail with Error: no context directory specified. See Activating a Context Directory.

      Enrich

      /ctx-journal-enrich-all\n

      Rebuild

      ctx journal site --serve\n

      Read on for what each stage does and why.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx journal source Command List parsed sessions with metadata ctx journal source --show Command Inspect a specific session in detail ctx journal import Command Import sessions to editable journal Markdown ctx journal site Command Generate a static site from journal entries ctx journal obsidian Command Generate an Obsidian vault from journal entries ctx journal schema check Command Validate JSONL files and report schema drift ctx journal schema dump Command Print the embedded JSONL schema definition ctx serve Command Serve any zensical directory (default: journal) /ctx-history Skill Browse sessions inside your AI assistant /ctx-journal-enrich Skill Add frontmatter metadata to a single entry /ctx-journal-enrich-all Skill Full pipeline: import if needed, then batch-enrich","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-workflow","level":2,"title":"The Workflow","text":"

      The session journal follows a four-stage pipeline.

      Each stage is idempotent and safe to re-run:

      By default, each stage skips entries that have already been processed.

      import -> enrich -> rebuild\n
      Stage Tool What it does Skips if Where Import ctx journal import --all Converts session JSONL to Markdown File already exists (safe default) CLI or agent Enrich /ctx-journal-enrich-all Adds frontmatter, summaries, topic tags Frontmatter already present Agent only Rebuild ctx journal site --build Generates browsable static HTML N/A CLI only Obsidian ctx journal obsidian Generates Obsidian vault with wikilinks N/A CLI only

      Where Do You Run Each Stage?

      Import (Steps 1 to 3) works equally well from the terminal or inside your AI assistant via /ctx-history. The CLI is fine here: the agent adds no special intelligence, it just runs the same command.

      Enrich (Step 4) requires the agent: it reads conversation content and produces structured metadata.

      Rebuild and serve (Step 5) is a terminal operation that starts a long-running server.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-1-list-your-sessions","level":3,"title":"Step 1: List Your Sessions","text":"

      Start by seeing what sessions exist for the current project:

      ctx journal source\n

      Sample output:

      Sessions (newest first)\n=======================\n\n  Slug                           Project   Date         Duration  Turns  Tokens\n  gleaming-wobbling-sutherland   ctx       2026-02-07   1h 23m    47     82,341\n  twinkly-stirring-kettle        ctx       2026-02-06   0h 45m    22     38,102\n  bright-dancing-hopper          ctx       2026-02-05   2h 10m    63     124,500\n  quiet-flowing-dijkstra         ctx       2026-02-04   0h 18m    11     15,230\n  ...\n

      Slugs Look Cryptic?

      These auto-generated slugs (gleaming-wobbling-sutherland) are hard to recognize later.

      Use /ctx-journal-enrich to add human-readable titles, topic tags, and summaries to exported journal entries, making them easier to find.

      Filter by project or tool if you work across multiple codebases:

      ctx journal source --project ctx --limit 10\nctx journal source --tool claude-code\nctx journal source --all-projects\n
      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-2-inspect-a-specific-session","level":3,"title":"Step 2: Inspect a Specific Session","text":"

      Before exporting everything, inspect a single session to see its metadata and conversation summary:

      ctx journal source --show --latest\n

      Or look up a specific session by its slug, partial ID, or UUID:

      ctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show twinkly\nctx journal source --show abc123\n

      Add --full to see the complete message content instead of the summary view:

      ctx journal source --show --latest --full\n

      This is useful for checking what happened before deciding whether to export and enrich it.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-3-import-sessions-to-the-journal","level":3,"title":"Step 3: Import Sessions to the Journal","text":"

      Import converts raw session data into editable Markdown files in .context/journal/:

      # Import all sessions from the current project\nctx journal import --all\n\n# Import a single session\nctx journal import gleaming-wobbling-sutherland\n\n# Include sessions from all projects\nctx journal import --all --all-projects\n

      --keep-frontmatter=false Discards Enrichments

      --keep-frontmatter=false discards enriched YAML frontmatter during regeneration.

      Back up your journal before using this flag.

      Each imported file contains session metadata (date, time, duration, model, project, git branch), a tool usage summary, and the full conversation transcript.

      Re-importing is safe. Running ctx journal import --all only imports new sessions: Existing files are never touched. Use --dry-run to preview what would be imported without writing anything.

      To re-import existing files (e.g., after a format improvement), use --regenerate: Conversation content is regenerated while preserving any YAML frontmatter you or the enrichment skill has added. You'll be prompted before any files are overwritten.

      --regenerate Replaces the Markdown Body

      --regenerate preserves YAML frontmatter but replaces the entire Markdown body with freshly generated content from the source JSONL.

      If you manually edited the conversation transcript (added notes, redacted sensitive content, restructured sections), those edits will be lost.

      BACK UP YOUR JOURNAL FIRST.

      To protect entries you've hand-edited, you can explicitly lock them:

      ctx journal lock <pattern>\n

      Locked entries are always skipped, regardless of flags.

      If you prefer to add locked: true directly in frontmatter during enrichment, run ctx journal sync to propagate the lock state to .state.json:

      ctx journal sync\n

      See ctx journal lock --help and ctx journal sync --help for details.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-4-enrich-with-metadata","level":3,"title":"Step 4: Enrich with Metadata","text":"

      Raw imports have timestamps and transcripts but lack the semantic metadata that makes sessions searchable: topics, technology tags, outcome status, and summaries. The /ctx-journal-enrich* skills add this structured frontmatter.

      Locked entries are skipped by enrichment skills, just as they are by import. Lock entries you want to protect before running batch enrichment.

      Batch enrichment (recommended):

      /ctx-journal-enrich-all\n

      The skill finds all unenriched entries, filters out noise (suggestion sessions, very short sessions, multipart continuations), and processes each one by extracting titles, topics, technologies, and summaries from the conversation.

      It shows you a grouped summary before applying changes so you can scan quickly rather than reviewing one by one.

      For large backlogs (20+ entries), the skill can spawn subagents to process entries in parallel.

      Single-entry enrichment:

      /ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-02-06\n

      Each enriched entry gets YAML frontmatter like this:

      ---\ntitle: \"Implement Redis caching middleware\"\ndate: 2026-02-06\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - api-performance\ntechnologies:\n  - go\n  - redis\nlibraries:\n  - go-redis/redis\nkey_files:\n  - internal/cache/redis.go\n  - internal/api/middleware/cache.go\n---\n

      The skill also generates a summary and can extract decisions, learnings, and tasks mentioned during the session.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-5-generate-and-serve-the-site","level":3,"title":"Step 5: Generate and Serve the Site","text":"

      With imported and enriched journal files, generate the static site:

      # Generate site structure only\nctx journal site\n\n# Generate and build static HTML\nctx journal site --build\n\n# Generate, build, and serve locally\nctx journal site --serve\n

      Then open http://localhost:8000 to browse.

      The site includes a date-sorted index, individual session pages with full conversations, search (press /), dark mode, and enriched titles in the navigation when frontmatter exists.

      You can also serve an already-generated site without regenerating using ctx serve (serve-only, no regeneration).

      The site generator requires zensical (pipx install zensical).

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#where-does-agent-add-value","level":2,"title":"Where Does Agent Add Value?","text":"

      Export, list, and show are mechanical: The agent runs the same CLI commands you would, so you can stay in your terminal for those.

      The agent earns its keep in enrich. It reads conversation content, understands what happened, and produces structured metadata. That is agent work, not CLI work.

      You can also ask your agent to browse sessions conversationally instead of remembering flags:

      What did we work on last week?\nShow me the session about Redis.\nImport everything to the journal.\n

      This is convenient but not required: ctx journal source gives you the same inventory.

      Where the agent genuinely helps is chaining the pipeline:

      You:   What happened last Tuesday?\nAgent: Last Tuesday you worked on two sessions:\n       - bright-dancing-hopper (2h 10m): refactored the middleware\n         pipeline and added Redis caching\n       - quiet-flowing-dijkstra (18m): quick fix for a nil pointer\n         in the config loader\n       Want me to export and enrich them?\nYou:   Yes, do it.\nAgent: Exports both, enriches, then proposes frontmatter.\n

      The value is staying in one context while the agent runs import -> enrich without you manually switching tools.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      A typical pipeline from raw sessions to a browsable site:

      # Terminal: import and generate\nctx journal import --all\nctx journal site --serve\n
      # AI assistant: enrich\n/ctx-journal-enrich-all\n
      # Terminal: rebuild with enrichments\nctx journal site --serve\n

      If your project includes Makefile.ctx (deployed by ctx init), use make journal to combine import and rebuild stages. Then enrich inside Claude Code, then make journal again to pick up enrichments.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#session-retention-and-cleanup","level":2,"title":"Session Retention and Cleanup","text":"

      Claude Code does not keep JSONL transcripts forever. Understanding its cleanup behavior helps you avoid losing session history.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#default-behavior","level":3,"title":"Default Behavior","text":"

      Claude Code retains session transcripts for approximately 30 days. After that, JSONL files are automatically deleted during cleanup. Once deleted, ctx journal can no longer see those sessions - the data is gone.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-cleanupperioddays-setting","level":3,"title":"The cleanupPeriodDays Setting","text":"

      Claude Code exposes a cleanupPeriodDays setting in its configuration (~/.claude/settings.json) that controls retention:

      Value Behavior 30 (default) Transcripts older than 30 days are deleted 60, 90, etc. Extends the retention window 0 Disables writing new transcripts entirely - not \"keep forever\"

      Setting cleanupPeriodDays To 0

      Setting this to 0 does not mean \"never delete.\" It disables transcript creation altogether. No new JSONL files are written, which means ctx journal sees nothing new. This is rarely what you want.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#why-journal-import-matters","level":3,"title":"Why Journal Import Matters","text":"

      The journal import pipeline (Steps 1-4 above) is your archival mechanism. Imported Markdown files in .context/journal/ persist independently of Claude Code's cleanup cycle. Even after the source JSONL files are deleted, your journal entries remain.

      Recommendation: import regularly - weekly, or after any session worth revisiting. A quick ctx journal import --all takes seconds and ensures nothing falls through the 30-day window.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#quick-archival-checklist","level":3,"title":"Quick Archival Checklist","text":"
      1. Run ctx journal import --all at least weekly
      2. Enrich high-value sessions with /ctx-journal-enrich before the details fade from your own memory
      3. Lock enriched entries (ctx journal lock <pattern>) to protect them from accidental regeneration
      4. Rebuild the journal site periodically to keep it current
      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tips","level":2,"title":"Tips","text":"
      • Start with /ctx-history inside your AI assistant. If you want to quickly check what happened in a recent session without leaving your editor, /ctx-history lets you browse interactively without importing.
      • Large sessions may be split automatically. Sessions with 200+ messages can be split into multiple parts (session-abc123.md, session-abc123-p2.md, session-abc123-p3.md) with navigation links between them. The site generator can handle this.
      • Suggestion sessions can be separated. Claude Code can generate short suggestion sessions for autocomplete. These may appear under a separate section in the site index, so they do not clutter your main session list.
      • Your agent is a good session browser. You do not need to remember slugs, dates, or flags. Ask \"what did we do yesterday?\" or \"find the session about Redis\" and it can map the question to recall commands.

      Journal Files Are Sensitive

      Journal files MUST be .gitignored.

      Session transcripts can contain sensitive data such as file contents, commands, error messages with stack traces, and potentially API keys.

      Add .context/journal/, .context/journal-site/, and .context/journal-obsidian/ to your .gitignore.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#next-up","level":2,"title":"Next Up","text":"

      Persisting Decisions, Learnings, and Conventions →: Record decisions, learnings, and conventions so they survive across sessions.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: where session saving fits in the daily workflow
      • Turning Activity into Content: generating blog posts from session history
      • Session Journal: full documentation of the journal system
      • CLI Reference: ctx journal: all journal subcommands and flags
      • CLI Reference: ctx serve: serve-only (no regeneration)
      • Context Files: the .context/ directory structure
      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-ceremonies/","level":1,"title":"Session Ceremonies","text":"","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#the-problem","level":2,"title":"The Problem","text":"

      Sessions have two critical moments: the start and the end.

      • At the start, you need the agent to load context and confirm it knows what is going on.
      • At the end, you need to capture whatever the session produced before the conversation disappears.

      Most ctx skills work conversationally: \"jot down: check DNS after deploy\" is as good as /ctx-pad add \"check DNS after deploy\". But session boundaries are different. They are well-defined moments with specific requirements, and partial execution is costly.

      If the agent only half-loads context at the start, it works from stale assumptions. If it only half-persists at the end, learnings and decisions are lost.

      This Is One of the Few Times Being Explicit Matters

      Session ceremonies are the two bookend skills that mark these boundaries.

      They are the exception to the conversational rule:

      Invoke /ctx-remember and /ctx-wrap-up explicitly as slash commands.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tldr","level":2,"title":"TL;DR","text":"

      Start: /ctx-remember: load context, get a structured readback.

      End: /ctx-wrap-up: review session, propose candidates, persist approved items.

      Use the slash commands, not conversational triggers, for completeness.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#explicit-invocation-matters","level":2,"title":"Explicit Invocation Matters","text":"

      Most ctx skills encourage natural language. These two are different:

      Well-defined moments: Sessions have clear boundaries. A slash command marks the boundary unambiguously.

      Ambiguity risk: \"Do you remember?\" could mean many things. /ctx-remember means exactly one thing: load context and present a structured readback.

      Completeness: Conversational triggers risk partial execution. The agent might load some files but skip the session history, or persist one learning but forget to check for uncommitted changes. The slash command runs the full ceremony.

      Muscle memory: Typing /ctx-remember at session start and /ctx-wrap-up at session end becomes a habit, like opening and closing braces.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-remember Skill Load context and present structured readback /ctx-wrap-up Skill Gather session signal, propose and persist context /ctx-commit Skill Commit with context capture (offered by wrap-up) ctx agent CLI Load token-budgeted context packet ctx journal source CLI List recent sessions ctx add CLI Persist learnings, decisions, conventions, tasks","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#session-start-ctx-remember","level":2,"title":"Session Start: /ctx-remember","text":"

      Invoke at the beginning of every session:

      /ctx-remember\n

      The skill silently:

      1. Loads the context packet via ctx agent --budget 4000
      2. Reads TASKS.md, DECISIONS.md, LEARNINGS.md
      3. Checks recent sessions via ctx journal source --limit 3

      Then presents a structured readback with four sections:

      • Last session: topic, date, what was accomplished
      • Active work: pending and in-progress tasks
      • Recent context: 1-2 relevant decisions or learnings
      • Next step: suggestion or question about what to focus on

      The readback should feel like recall, not a file system tour. If the agent says \"Let me check if there are files...\" instead of a confident summary, the skill is not working correctly.

      What about 'do you remember?'

      The conversational trigger still works. But /ctx-remember guarantees the full ceremony runs:

      • context packet,
      • file reads,
      • session history,
      • and all four readback sections.

      The conversational version may cut corners.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#session-end-ctx-wrap-up","level":2,"title":"Session End: /ctx-wrap-up","text":"

      Invoke before ending a session where meaningful work happened:

      /ctx-wrap-up\n

      The skill runs four phases:

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-1-gather-signal","level":3,"title":"Phase 1: Gather Signal","text":"

      Silently checks git diff --stat, recent commits, and scans the conversation for themes: architectural choices, gotchas, patterns established, follow-up work identified.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-2-propose-candidates","level":3,"title":"Phase 2: Propose Candidates","text":"

      Presents a structured list grouped by type:

      ## Session Wrap-Up\n\n### Learnings (2 candidates)\n1. **PyMdownx details extension breaks pre/code rendering**\n   - Context: Journal site showed broken code blocks inside details tags\n   - Lesson: details extension wraps content in <details> HTML, which\n     interferes with <pre><code> rendering\n   - Application: Use fenced code blocks instead of indented code inside\n     admonitions when details extension is active\n\n2. **Hook subprocesses cannot propagate env vars**\n   - Context: Set env var in PreToolUse hook, invisible in main session\n   - Lesson: Hooks execute in child processes; env changes don't propagate\n   - Application: Use tombstone files for hook-to-session communication\n\n### Decisions (1 candidate)\n1. **File-based cooldown tokens over env vars**\n   - Context: Need session-scoped cooldown for ctx agent auto-loading\n   - Rationale: File tokens survive across processes, simpler than IPC\n   - Consequence: Tombstone files accumulate in /tmp; need TTL cleanup\n\nPersist all? Or select which to keep?\n

      Each candidate has complete structured fields, not just a title. Empty categories are omitted.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-3-persist","level":3,"title":"Phase 3: Persist","text":"

      After you approve (all, some, or modified), the skill runs the appropriate ctx add commands and reports results.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#nudge-suppression","level":3,"title":"Nudge Suppression","text":"

      After persisting, the skill marks the session as wrapped up via ctx system mark-wrapped-up. This suppresses context checkpoint nudges for 2 hours so the wrap-up ceremony itself does not trigger noisy reminders.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-4-commit-offer","level":3,"title":"Phase 4: Commit Offer","text":"

      If there are uncommitted changes, offers to run /ctx-commit. Does not auto-commit.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#when-to-skip","level":2,"title":"When to Skip","text":"

      Not every session needs ceremonies.

      Skip /ctx-remember when:

      • You are doing a quick one-off lookup (reading a file, checking a value)
      • Context was already loaded this session via /ctx-agent
      • You are continuing immediately after a previous session and context is still fresh

      Skip /ctx-wrap-up when:

      • Nothing meaningful happened (only read files, answered a question)
      • You already persisted everything manually during the session
      • The session was trivial (typo fix, quick config change)

      A good heuristic: if the session produced something a future session should know about, run /ctx-wrap-up. If not, just close.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#quick-reference","level":2,"title":"Quick Reference","text":"
      # Session start\n/ctx-remember\n\n# ... do work ...\n\n# Session end\n/ctx-wrap-up\n

      That is the complete ceremony. Two commands, bookending your session.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#relationship-to-other-skills","level":2,"title":"Relationship to Other Skills","text":"Skill When Purpose /ctx-remember Session start Load and confirm context /ctx-reflect Mid-session breakpoints Checkpoint at milestones /ctx-wrap-up Session end Full session review and persist /ctx-commit After completing work Commit with context capture

      /ctx-reflect is for mid-session checkpoints. /ctx-wrap-up is for end-of-session: it is more thorough, covers the full session arc, and includes the commit offer. If you already ran /ctx-reflect recently, /ctx-wrap-up avoids proposing the same candidates again.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tips","level":2,"title":"Tips","text":"
      • Make it a habit: The value of ceremonies compounds over sessions. Each /ctx-wrap-up makes the next /ctx-remember richer.
      • Trust the candidates: The agent scans the full conversation. It often catches learnings you forgot about.
      • Edit before approving: If a proposed candidate is close but not quite right, tell the agent what to change. Do not settle for a vague learning when a precise one is possible.
      • Do not force empty ceremonies: If /ctx-wrap-up finds nothing worth persisting, that is fine. A session that only read files and answered questions does not need artificial learnings.
      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#next-up","level":2,"title":"Next Up","text":"

      Browsing and Enriching Past Sessions →: Export session history to a browsable journal and enrich entries with metadata.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: the full session workflow that ceremonies bookend
      • Persisting Decisions, Learnings, and Conventions: deep dive on what gets persisted during wrap-up
      • Detecting and Fixing Drift: keeping context files accurate between ceremonies
      • Pausing Context Hooks: skip ceremonies entirely for quick tasks that don't need them
      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-changes/","level":1,"title":"Reviewing Session Changes","text":"","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-changed-while-you-were-away","level":2,"title":"What Changed While You Were Away?","text":"

      Between sessions, teammates commit code, context files get updated, and decisions pile up. ctx change gives you a single-command summary of everything that moved since your last session.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#quick-start","level":2,"title":"Quick Start","text":"
      # Auto-detects your last session and shows what changed\nctx change\n\n# Check what changed in the last 48 hours\nctx change --since 48h\n\n# Check since a specific date\nctx change --since 2026-03-10\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx change fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#how-reference-time-works","level":2,"title":"How Reference Time Works","text":"

      ctx change needs a reference point to compare against. It tries these sources in order:

      1. --since flag: explicit duration (24h, 72h) or date (2026-03-10, RFC3339 timestamp)
      2. Session markers: ctx-loaded-* files in .context/state/; picks the second-most-recent (your previous session start)
      3. Event log: last context-load-gate event from .context/state/events.jsonl
      4. Fallback: 24 hours ago

      The marker-based detection means ctx change usually just works without any flags: it knows when you last loaded context and shows everything after that.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-it-reports","level":2,"title":"What It Reports","text":"","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#context-file-changes","level":3,"title":"Context File Changes","text":"

      Any .md file in .context/ modified after the reference time:

      ### Context File Changes\n- `TASKS.md` - modified 2026-03-11 14:30\n- `DECISIONS.md` - modified 2026-03-11 09:15\n
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#code-changes","level":3,"title":"Code Changes","text":"

      Git activity since the reference time:

      ### Code Changes\n- **12 commits** since reference point\n- **Latest**: Fix journal enrichment ordering\n- **Directories touched**: internal, docs, specs\n- **Authors**: jose, claude\n
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#integrating-into-session-start","level":2,"title":"Integrating into Session Start","text":"

      Pair ctx change with the /ctx-remember ceremony for a complete session-start picture:

      # 1. Load context (this also creates the session marker)\nctx agent --budget 4000\n\n# 2. See what changed since your last session\nctx change\n

      Or script it:

      # .context/hooks/session-start.sh\nctx agent --budget 4000\necho \"---\"\nctx change\n
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#team-workflows","level":2,"title":"Team Workflows","text":"

      When multiple people share a .context/ directory, ctx change shows who changed what:

      # After pulling from remote\ngit pull\nctx change --since 72h\n

      This surfaces context file changes from teammates that you might otherwise miss in the commit log.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#tips","level":2,"title":"Tips","text":"
      • No changes? If nothing shows up, the reference time might be wrong. Use --since 48h to widen the window.
      • Works without git. Context file changes are detected by filesystem mtime, not git. Code changes require git.
      • Hook integration. The context-load-gate hook writes the session marker that ctx change uses for auto-detection. If you're not using the ctx plugin, markers won't exist and it falls back to the event log or 24h window.
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-lifecycle/","level":1,"title":"The Complete Session","text":"","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#the-problem","level":2,"title":"The Problem","text":"

      \"What does a full ctx session look like from start to finish?\"

      You have ctx installed and your .context/ directory initialized, but the individual commands and skills feel disconnected.

      How do they fit together into a coherent workflow?

      This recipe walks through a complete session, from opening your editor to persisting context before you close it, so you can see how each piece connects.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tldr","level":2,"title":"TL;DR","text":"
      1. Load: /ctx-remember: load context, get structured readback.
      2. Orient: /ctx-status: check file health and token usage.
      3. Pick: /ctx-next: choose what to work on.
      4. Work: implement, test, iterate.
      5. Commit: /ctx-commit: commit and capture decisions/learnings.
      6. Reflect: /ctx-reflect: identify what to persist (at milestones)
      7. Wrap up: /ctx-wrap-up: end-of-session ceremony.

      Read on for the full walkthrough with examples.

      Before You Start: Activate the Project

      ctx commands (and the skills that call them) require CTX_DIR to be declared for the shell you're working in; ctx does not walk the filesystem to find .context/. Once per shell (or via your shell rc / direnv):

      eval \"$(ctx activate)\"\n

      If you skip this, every skill below will surface an error naming the fix. See Activating a Context Directory for the full recipe.

      What Is a Readback?

      A readback is a structured summary where the agent plays back what it knows:

      • last session,
      • active tasks,
      • recent decisions.

      This way, you can confirm it loaded the right context.

      The term \"readback\" comes from aviation, where pilots repeat instructions back to air traffic control to confirm they heard correctly.

      Same idea in ctx: The agent tells you what it \"thinks\" is going on, and you correct anything that's off before the work begins.

      • Last session: topic, date, what was accomplished
      • Active work: pending and in-progress tasks
      • Recent context: 1-2 decisions or learnings that matter now
      • Next step: suggestion or question about what to focus on
      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx status CLI command Quick health check on context files ctx agent CLI command Load token-budgeted context packet ctx journal source CLI command List previous sessions ctx journal source --show CLI command Inspect a specific session in detail /ctx-remember Skill Recall project context with structured readback /ctx-agent Skill Load full context packet inside the assistant /ctx-status Skill Show context summary with commentary /ctx-next Skill Suggest what to work on with rationale /ctx-commit Skill Commit code and prompt for context capture /ctx-reflect Skill Structured reflection checkpoint /ctx-history Skill Browse session history inside your AI assistant","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#the-workflow","level":2,"title":"The Workflow","text":"

      The session lifecycle has seven steps. You will not always use every step (for example, a quick bugfix might skip reflection, and a research session might skip committing), but the full arc looks like this:

      Load context > Orient > Pick a Task > Work > Commit > Reflect

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-1-load-context","level":3,"title":"Step 1: Load Context","text":"

      Start every session by loading what you know. The fastest way is a single prompt:

      Do you remember what we were working on?\n

      This triggers the /ctx-remember skill. Behind the scenes, the assistant runs ctx agent --budget 4000, reads the files listed in the context packet (TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md), checks ctx journal source --limit 3 for recent sessions, and then presents a structured readback.

      The readback should feel like a recall, not a file system tour. If you see \"Let me check if there are files...\" instead of a confident summary, the context system is not loaded properly.

      As an alternative, if you want raw data instead of a readback, run ctx status in your terminal or invoke /ctx-status for a summarized health check showing file counts, token usage, and recent activity.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-2-orient","level":3,"title":"Step 2: Orient","text":"

      After loading context, verify you understand the current state.

      /ctx-status\n

      The status output shows which context files are populated, how many tokens they consume, and which files were recently modified. Look for:

      • Empty core files: TASKS.md or CONVENTIONS.md with no content means the context is sparse
      • High token count (over 30k): the context is bloated and might need ctx compact
      • No recent activity: files may be stale and need updating

      If the status looks healthy and the readback from Step 1 gave you enough context, skip ahead.

      If something seems off (stale tasks, missing decisions...), spend a minute reading the relevant file before proceeding.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-3-pick-what-to-work-on","level":3,"title":"Step 3: Pick What to Work On","text":"

      With context loaded, choose a task. You can pick one yourself, or ask the assistant to recommend:

      /ctx-next\n

      The skill reads TASKS.md, checks recent sessions to avoid re-suggesting completed work, and presents 1-3 ranked recommendations with rationale.

      It prioritizes in-progress tasks over new starts (finishing is better than starting), respects explicit priority tags, and favors momentum: continuing a thread from a recent session is cheaper than context-switching.

      If you already know what you want to work on, state it directly:

      Let's work on the session enrichment feature.\n
      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-4-do-the-work","level":3,"title":"Step 4: Do the Work","text":"

      This is the main body of the session: write code, fix bugs, refactor, research: whatever the task requires.

      During this phase, a few ctx-specific patterns help:

      Check decisions before choosing: when you face a design choice, check if a prior decision covers it.

      Is this consistent with our decisions?\n

      Constrain scope: keep the assistant focused on the task at hand.

      Only change files in internal/cli/session/. Nothing else.\n

      Use /ctx-implement for multistep plans: if the task has multiple steps, this skill executes them one at a time with build/test verification between each step.

      Context monitoring runs automatically: the check-context-size hook monitors context capacity at adaptive intervals. Early in a session it stays silent. After 16+ prompts it starts monitoring, and past 30 prompts it checks frequently. If context capacity is running high, it will suggest saving unsaved work. No manual invocation is needed.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-5-commit-with-context","level":3,"title":"Step 5: Commit with Context","text":"

      When the work is ready, use the context-aware commit instead of raw git commit:

      /ctx-commit\n

      The Agent May Recommend Committing

      You do not always need to invoke /ctx-commit explicitly.

      After a commit, the agent may proactively offer to capture context:

      \"We just made a trade-off there. Want me to record it as a decision?\"

      This is normal: The Agent Playbook encourages persisting at milestones, and a commit is a natural milestone.

      As an alternative, you can ask the assistant \"can we commit this?\" and it will pick up the /ctx-commit skill for you.

      The skill runs a pre-commit build check (for Go projects, go build), reviews the staged changes, drafts a commit message focused on \"why\" rather than \"what\", and then commits.

      After the commit succeeds, it prompts you:

      **Any context to capture?**\n\n- **Decision**: Did you make a design choice or trade-off?\n- **Learning**: Did you hit a gotcha or discover something?\n- **Neither**: No context to capture; we are done.\n

      If you made a decision, the skill records it with ctx add decision. If you learned something, it records it with ctx add learning including context, lesson, and application fields. This is the bridge between committing code and remembering why the code looks the way it does.

      If source code changed in areas that affect documentation, the skill also offers to check for doc drift.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-6-reflect","level":3,"title":"Step 6: Reflect","text":"

      At natural breakpoints (after finishing a feature, resolving a complex bug, or before switching tasks) pause to reflect:

      /ctx-reflect\n

      Agents Reflect at Milestones

      Agents often reflect without explicit invocation.

      After completing a significant piece of work, the agent may naturally surface items worth persisting:

      \"We discovered that $PPID resolves differently inside hooks. Should I save that as a learning?\"

      This is the agent following the Work-Reflect-Persist cycle from the Agent Playbook.

      You do not need to say /ctx-reflect for this to happen; the agent treats milestones as reflection triggers on its own.

      The skill works through a checklist: learnings discovered, decisions made, tasks completed or created, and whether there are items worth persisting. It then presents a summary with specific items to persist, each with the exact command to run:

      I would suggest persisting:\n\n- **Learning**: `$PPID` in PreToolUse hooks resolves to the Claude Code PID\n  `ctx add learning --context \"...\" --lesson \"...\" --application \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n- **Task**: mark \"Add cooldown to ctx agent\" as done\n- **Decision**: tombstone-based cooldown with 10m default\n  `ctx add decision \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n\nWant me to persist any of these?\n

      The skill asks before persisting anything. You choose what to keep.

      Not every commit needs reflection. A typo fix does not. But when you have been debugging for an hour and finally understand the root cause, that is worth a reflection checkpoint.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-7-persist-before-ending","level":3,"title":"Step 7: Persist Before Ending","text":"

      Before ending the session, run the wrap-up ceremony to capture outstanding learnings, decisions, conventions, and tasks:

      /ctx-wrap-up\n

      Ceremony Skills

      /ctx-remember at session start and /ctx-wrap-up at session end are ceremony skills: Invoke them as explicit slash commands for completeness, not conversationally.

      See Session Ceremonies for details on why these two skills are the exception to the conversational rule.

      The skill gathers signal from git diff, recent commits, and the conversation, then proposes structured candidates for your approval. After you select which to keep, it persists them via ctx add and offers /ctx-commit if uncommitted changes remain.

      Session transcripts are automatically captured by Claude Code and can be browsed later with ctx journal source and ctx journal source --show.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#conversational-session-flow","level":2,"title":"Conversational Session Flow","text":"

      The steps above describe the mechanics. In practice, a session with a ctx-aware agent feels more like a conversation than a command sequence.

      The agent knows the lifecycle and moves through it naturally, often without explicit invocation. Here is a realistic example:

      You: Do you remember what we were working on?

      Agent (loads context silently, presents structured readback):

      Last session (Feb 7, caching-layer): we implemented the in-memory cache with\nTTL expiration and wrote tests for the eviction policy. \n\nYou have 3 pending tasks; the biggest one is adding Redis as a backend.\n\nRecent decision:<br>\nwe chose LRU over LFU because the access pattern is mostly recency-based.\n\nWant to continue with the Redis backend, or tackle something else?\n

      You: Let's work on the Redis caching backend.

      Agent (picks up the task, begins implementation):

      Got it. I see the task in TASKS.md: \"Add Redis backend for cache layer.\"\n\nI will start with the connection pool setup. Only touching\n`internal/cache/redis/` for now.\n

      (The agent works... writes code, runs tests, iterates.)

      Agent (after implementing the connection pool and choosing a retry strategy):

      The connection pool is working. I went with exponential backoff with jitter\nfor retries instead of fixed intervals; it handles thundering herd better\nunder reconnection storms. That is a design choice worth recording. \n\nWant me to save it as a decision?\n

      You: Yes, go ahead.

      Agent:

      Done. Added to DECISIONS.md: \"Exponential backoff with jitter for Redis\nreconnection, to avoid thundering herd on pool recovery.\"\n

      (More work happens... the agent implements the cache read/write paths.)

      You: What else did we learn during this session?

      Agent:

      A few things worth capturing:\n\n* **Learning**: Redis `SET` with `NX` and `PX` flags handles atomic\n  set-if-not-exists with TTL in a single call. No need for a separate\n  `EXPIRE` command. We initially did it in two calls and hit a race condition.\n* **Learning**: The `go-redis` library's `PoolSize` default is 10 per CPU.\n  For our workload, explicit sizing at 20 was more predictable.\n* **Task update**: The connection pool subtask is done; the read/write path\n  is implemented but needs integration tests.\n\nWant me to persist these?\n

      You: Yes. And let's wrap up.

      Agent (reflects and persists... all in one flow):

      Persisted:\n\n* 2 learnings added to LEARNINGS.md\n* Marked \"connection pool setup\" done in TASKS.md\n* Added \"write integration tests for Redis cache\" as a new task\n\nContext is up to date. You are good to close.\n

      Notice What Happened

      In the above workflow, the user never typed /ctx-reflect or ctx add learning.

      The agent moved through Load, Orient, Pick, Work, Commit, and Reflect driven by natural conversation.

      \"Let's wrap up\" was enough to trigger the full reflect-and-persist flow.

      The agent surfaced persist-worthy items at milestones: after a design choice, after discovering a gotcha: without waiting to be asked.

      This is the intended experience.

      The commands and skills still exist for when you want precise control, but the agent is a proactive partner in the lifecycle, not a passive executor of slash commands.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      Quick-reference checklist for a complete session:

      • Load: /ctx-remember: load context and confirm readback
      • Orient: /ctx-status: check file health and token usage
      • Pick: /ctx-next: choose what to work on
      • Work: implement, test, iterate (scope with \"only change X\")
      • Commit: /ctx-commit: commit and capture decisions/learnings
      • Reflect: /ctx-reflect: identify what to persist (at milestones)
      • Wrap up: /ctx-wrap-up: end-of-session ceremony

      Conversational equivalents: you can drive the same lifecycle with plain language:

      Step Slash command Natural language Load /ctx-remember \"Do you remember?\" / \"What were we working on?\" Orient /ctx-status \"How's our context looking?\" Pick /ctx-next \"What should we work on?\" / \"Let's do the caching task\" Work (none) \"Only change files in internal/cache/\" Commit /ctx-commit \"Commit this\" / \"Ship it\" Reflect /ctx-reflect \"What did we learn?\" / (agent offers at milestones) Wrap up /ctx-wrap-up (use the slash command for completeness)

      The agent understands both columns.

      In practice, most sessions use a mix:

      • Explicit Commands when you want precision;
      • Natural Language when you want flow and agentic autonomy.

      The agent will also initiate steps on its own (particularly \"Reflect\") when it recognizes a milestone.

      Short sessions (quick bugfix) might only use: Load, Work, Commit.

      Long sessions should Reflect after each major milestone and persist learnings and decisions before ending.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tips","level":2,"title":"Tips","text":"

      Persist early if context is running low. A hook monitors context capacity and notifies you when it gets high, but do not wait for the notification. If you have been working for a while and have unpersisted learnings, persist proactively.

      Browse previous sessions by topic. If you need context from a prior session, ctx journal source --show auth will match by keyword. You do not need to remember the exact date or slug.

      Reflection is optional but valuable. You can skip /ctx-reflect for small changes, but always persist learnings and decisions before ending a session where you did meaningful work. These are what the next session loads.

      Let the hook handle context loading. The PreToolUse hook runs ctx agent automatically with a cooldown, so context loads on first tool use without you asking. The /ctx-remember prompt at session start is for your benefit (to get a readback), not because the assistant needs it.

      The agent is a proactive partner, not a passive tool. A ctx-aware agent follows the Agent Playbook: it watches for milestones (completed tasks, design decisions, discovered gotchas) and offers to persist them without being asked. If you finish a tricky debugging session, it may say \"That root cause is worth saving as a learning. Want me to record it?\" before you think to ask. This is by design.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#next-up","level":2,"title":"Next Up","text":"

      Session Ceremonies →: The two bookend rituals for every session: /ctx-remember at the start, /ctx-wrap-up at the end.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#see-also","level":2,"title":"See Also","text":"
      • Session Ceremonies: why /ctx-remember and /ctx-wrap-up are explicit slash commands, not conversational
      • CLI Reference: full documentation for all ctx commands
      • Prompting Guide: effective prompts for ctx-enabled projects
      • Tracking Work Across Sessions: deep dive on task management
      • Persisting Decisions, Learnings, and Conventions: deep dive on knowledge capture
      • Detecting and Fixing Drift: keeping context files accurate
      • Pausing Context Hooks: shortcut the full lifecycle for quick tasks that don't need ceremony overhead
      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-pause/","level":1,"title":"Pausing Context Hooks","text":"","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#the-problem","level":2,"title":"The Problem","text":"

      Not every session needs the full ceremony. Quick investigations, one-off questions, small fixes unrelated to active project work: These tasks don't benefit from persistence nudges, ceremony reminders, or knowledge checks. Every hook still fires, consuming tokens and attention on work that won't produce learnings or decisions worth capturing.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tldr","level":2,"title":"TL;DR","text":"Command What it does ctx hook pause or /ctx-pause Silence all nudge hooks for this session ctx hook resume or /ctx-resume Restore normal hook behavior

      Pause is session-scoped: It only affects the current session. Other sessions (same project, different terminal) are unaffected.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-gets-paused","level":2,"title":"What Gets Paused","text":"

      All nudge and reminder hooks go silent:

      • Context size checkpoints
      • Ceremony adoption nudges
      • Persistence reminders
      • Journal maintenance reminders
      • Knowledge growth nudges
      • Map staleness nudges
      • Version update nudges
      • Resource pressure warnings
      • QA reminders
      • Post-commit nudges
      • Specs nudges
      • Backup age warnings
      • Context load gate
      • Pending reminders relay
      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-still-fires","level":2,"title":"What Still Fires","text":"

      Security hooks always run, even when paused:

      • block-non-path-ctx: prevents ./ctx invocations
      • block-dangerous-commands: blocks sudo, force push, etc.
      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#workflow","level":2,"title":"Workflow","text":"
      # 1. Session starts: Context loads normally.\n\n# 2. You realize this is a quick task\nctx hook pause\n\n# 3. Work without interruption: hooks are silent\n\n# 4. Session evolves into real work? Resume first\nctx hook resume\n\n# 5. Now wrap up normally\n# /ctx-wrap-up\n
      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#graduated-reminder","level":2,"title":"Graduated Reminder","text":"

      Paused hooks aren't completely invisible. A minimal indicator appears so you always know the state:

      Paused turns What you see 1-5 ctx:paused 6+ ctx:paused (N turns): resume with /ctx-resume

      This prevents the \"forgot I paused\" problem during long sessions.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tips","level":2,"title":"Tips","text":"
      • Resume before wrapping up. If your quick task turns into real work, resume hooks before running /ctx-wrap-up. The wrap-up ceremony needs active hooks to capture learnings properly.

      • Initial context load is unaffected. The ~8k token startup injection (CLAUDE.md, playbook, constitution) happens before any command runs. Pause only affects hooks that fire during the session.

      • Use for quick investigations. Debugging a stack trace? Checking a git log? Answering a colleague's question? Pause, do the work, close the session. No ceremony needed.

      • Don't use for real work. If you're implementing features, fixing bugs, or making decisions: keep hooks active. The nudges exist to prevent context loss.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#see-also","level":2,"title":"See Also","text":"

      See also: Session Ceremonies: the bookend rituals that pause lets you skip when they aren't needed.

      See also: Customizing Hook Messages: if you want to change what hooks say rather than silencing them entirely.

      See also: The Complete Session: the full session workflow that pause shortcuts for quick tasks.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-reminders/","level":1,"title":"Session Reminders","text":"","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#the-problem","level":2,"title":"The Problem","text":"

      You're deep in a session and realize: \"I need to refactor the swagger definitions next time.\" You could add a task, but this isn't a work item: it's a note to future-you. You could jot it on the scratchpad, but scratchpad entries don't announce themselves.

      How do you leave a message that your next session opens with?

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tldr","level":2,"title":"TL;DR","text":"
      ctx remind \"refactor the swagger definitions\"\nctx remind list\nctx remind dismiss 1       # or batch: ctx remind dismiss 1 3-5\n

      Reminders surface automatically at session start: VERBATIM, every session, until you dismiss them.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx remind ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx remind CLI command Add a reminder (default action) ctx remind list CLI command Show all pending reminders ctx remind dismiss CLI command Remove a reminder by ID (or --all) /ctx-remind Skill Natural language interface to reminders","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-1-leave-a-reminder","level":3,"title":"Step 1: Leave a Reminder","text":"

      Tell your agent what to remember, or run it directly:

      You: \"remind me to refactor the swagger definitions\"\n\nAgent: [runs ctx remind \"refactor the swagger definitions\"]\n       \"Reminder set:\n         + [1] refactor the swagger definitions\"\n

      Or from the terminal:

      ctx remind \"refactor the swagger definitions\"\n
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-2-set-a-date-gate-optional","level":3,"title":"Step 2: Set a Date Gate (Optional)","text":"

      If the reminder shouldn't fire until a specific date:

      You: \"remind me to check the deploy logs after Tuesday\"\n\nAgent: [runs ctx remind \"check the deploy logs\" --after 2026-02-25]\n       \"Reminder set:\n         + [2] check the deploy logs  (after 2026-02-25)\"\n

      The reminder stays silent until that date, then fires every session.

      The agent converts natural language dates (\"tomorrow\", \"next week\", \"after the release on Friday\") to YYYY-MM-DD. If it's ambiguous, it asks.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-3-start-a-new-session","level":3,"title":"Step 3: Start a New Session","text":"

      Next session, the reminder appears automatically before anything else:

      ┌─ Reminders ──────────────────────────────────────\n│  [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n

      No action needed: The check-reminders hook fires on UserPromptSubmit and the agent relays the box verbatim.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-4-dismiss-when-done","level":3,"title":"Step 4: Dismiss When Done","text":"

      After you've acted on a reminder (or decided to skip it):

      You: \"dismiss reminder 1\"\n\nAgent: [runs ctx remind dismiss 1]\n       \"Dismissed:\n         - [1] refactor the swagger definitions\"\n\n# Batch dismiss also works:\n# \"dismiss reminders 3, 5 through 7\"\n# → ctx remind dismiss 3 5-7\n

      Or clear everything:

      ctx remind dismiss --all\n
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-5-check-whats-pending","level":3,"title":"Step 5: Check What's Pending","text":"
      ctx remind list\n
        [1] refactor the swagger definitions\n  [3] review auth token expiry logic\n  [4] check deploy logs  (after 2026-02-25, not yet due)\n

      Date-gated reminders that haven't reached their date show (not yet due).

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#using-ctx-remind-in-a-session","level":2,"title":"Using /ctx-remind in a Session","text":"

      Invoke the /ctx-remind skill, then describe what you want:

      You: /ctx-remind remind me to update the API docs\nYou: /ctx-remind what reminders do I have?\nYou: /ctx-remind dismiss reminder 3\n
      You say (after /ctx-remind) What the agent does \"remind me to update the API docs\" ctx remind \"update the API docs\" \"remind me next week to check staging\" ctx remind \"check staging\" --after 2026-03-02 \"what reminders do I have?\" ctx remind list \"dismiss reminder 3\" ctx remind dismiss 3 \"dismiss reminders 3, 5 through 7\" ctx remind dismiss 3 5-7 \"clear all reminders\" ctx remind dismiss --all","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#reminders-vs-scratchpad-vs-tasks","level":2,"title":"Reminders vs Scratchpad vs Tasks","text":"You want to... Use Leave a note that announces itself next session ctx remind Jot down a quick value or sensitive token ctx pad Track work with status and completion TASKS.md Record a decision or lesson for all sessions Context files

      Decision guide:

      • If it should announce itself at session start → ctx remind
      • If it's a quiet note you'll check manually → ctx pad
      • If it's a work item you'll mark done → TASKS.md

      Reminders Are Sticky Notes, Not Tasks

      A reminder has no status, no priority, no lifecycle. It's a message to \"future you\" that fires until dismissed.

      If you need tracking, use a task in TASKS.md.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tips","level":2,"title":"Tips","text":"
      • Reminders fire every session: Unlike nudges (which throttle to once per day), reminders repeat until you dismiss them. This is intentional: You asked to be reminded.
      • Date gating is session-scoped, not clock-scoped: --after 2026-02-25 means \"don't show until sessions on or after Feb 25.\" It does not mean \"alarm at midnight on Feb 25.\"
      • The agent handles date parsing: Say \"next week\" or \"after Friday\": The agent converts it to YYYY-MM-DD. The CLI only accepts the explicit date format.
      • Reminders are committed to git: They travel with the repo. If you switch machines, your reminders follow.
      • IDs never reuse: After dismissing reminder 3, the next reminder gets ID 4 (or higher). No confusion from recycled numbers.
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#next-up","level":2,"title":"Next Up","text":"

      Using the Scratchpad →: For quiet notes and sensitive values that don't need session-start announcements.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#see-also","level":2,"title":"See Also","text":"
      • CLI Reference: ctx remind: full command syntax and flags
      • The Complete Session: how reminders fit into the session lifecycle
      • Managing Tasks: for work items that need status tracking
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/state-maintenance/","level":1,"title":"State Directory Maintenance","text":"","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-problem","level":2,"title":"The Problem","text":"

      Every session creates tombstone files in .context/state/ - small markers that suppress repeat hook nudges (\"already checked context size\", \"already sent persistence reminder\"). Over days and weeks, these accumulate into hundreds of files from long-dead sessions.

      The files are harmless individually, but the clutter makes it harder to reason about state, and stale global tombstones can suppress nudges across sessions entirely.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tldr","level":2,"title":"TL;DR","text":"
      ctx prune --dry-run     # preview what would be removed\nctx prune               # prune files older than 7 days\nctx prune --days 1      # more aggressive: keep only today\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx prune / ctx status fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#commands-used","level":2,"title":"Commands Used","text":"Tool Type Purpose ctx prune Command Remove old per-session state files ctx status Command Quick health overview including state dir","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#understanding-state-files","level":2,"title":"Understanding State Files","text":"

      State files fall into two categories:

      Session-scoped (contain a UUID in the filename): Created per-session to suppress repeat nudges. Safe to prune once the session ends. Examples:

      context-check-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\nheartbeat-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\npersistence-nudge-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\n

      Global (no UUID): Persist across sessions. ctx prune preserves these automatically. Some are legitimate state (events.jsonl, memory-import.json); others may be stale tombstones that need manual review.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-workflow","level":2,"title":"The Workflow","text":"","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-1-preview","level":3,"title":"Step 1: Preview","text":"

      Always dry-run first to see what would be removed:

      ctx prune --dry-run\n

      The output shows each file, its age, and a summary:

        would prune: context-check-abc123... (age: 3d)\n  would prune: heartbeat-abc123... (age: 3d)\n\nDry run - would prune 150 files (skip 70 recent, preserve 14 global)\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-2-prune","level":3,"title":"Step 2: Prune","text":"

      Choose an age threshold. The default is 7 days:

      ctx prune               # older than 7 days\nctx prune --days 3      # older than 3 days\nctx prune --days 1      # older than 1 day (aggressive)\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-3-review-global-files","level":3,"title":"Step 3: Review Global Files","text":"

      After pruning, check what prune preserved:

      ls .context/state/ | grep -v '[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}'\n

      Legitimate global files (keep):

      • events.jsonl - event log
      • memory-import.json - import tracking state

      Stale global tombstones (safe to delete):

      • Files like backup-reminded, ceremony-reminded, version-checked with no session UUID are one-shot markers. If they are from a previous session, they are stale and can be removed manually.
      rm .context/state/backup-reminded .context/state/ceremony-reminded\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-4-verify","level":3,"title":"Step 4: Verify","text":"
      ls .context/state/ | wc -l    # should be manageable\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#when-to-prune","level":2,"title":"When to Prune","text":"
      • Weekly: ctx prune with default 7-day threshold
      • After heavy parallel work: Multiple concurrent sessions create many tombstones. Prune with --days 1 afterward.
      • When state directory exceeds ~100 files: A sign that pruning hasn't run recently
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tips","level":2,"title":"Tips","text":"

      Pruning active sessions is safe but noisy: If you prune a file belonging to a still-running session, the corresponding hook will re-fire its nudge on the next prompt. Minor UX annoyance, not data loss.

      No context files are stored in state: The state directory contains only tombstones, counters, and diagnostic data. Nothing in .context/state/ affects your decisions, learnings, tasks, or conventions.

      Test artifacts sneak in: Files like context-check-statstest or heartbeat-unknown are artifacts from development or testing. They lack UUIDs so prune preserves them. Delete manually.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#see-also","level":2,"title":"See Also","text":"
      • Detecting and Fixing Drift: broader context maintenance including drift detection and archival
      • Troubleshooting: diagnostic workflow using ctx doctor and event logs
      • CLI Reference: system: full flag documentation for ctx prune and related commands
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/steering/","level":1,"title":"Writing Steering Files","text":"","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#writing-steering-files","level":1,"title":"Writing Steering Files","text":"

      Steering files tell your AI assistant how to behave, not what was decided or how the codebase is written. This recipe walks through writing a steering file from scratch, validating which prompts will trigger it, and syncing it out to your configured AI tools.

      Before You Start

      If you're unsure whether a rule belongs in steering/, DECISIONS.md, or CONVENTIONS.md, read the \"Steering vs decisions vs conventions\" admonition on the ctx steering reference page. The short version: if the rule is \"the AI should always do X when asked about Y,\" that's steering. Otherwise it's probably a decision or convention.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#start-here-customize-the-foundation-files","level":2,"title":"Start Here: Customize the Foundation Files","text":"

      ctx init scaffolds four foundation steering files for you the first time you initialize a project:

      File Purpose .context/steering/product.md Product context, goals, target users .context/steering/tech.md Tech stack, constraints, key dependencies .context/steering/structure.md Directory layout, naming conventions .context/steering/workflow.md Branch strategy, commit rules, pre-commit

      Each file opens with an inline HTML comment that explains the three inclusion modes, what priority means, and the tools scope. The comment is invisible in rendered markdown but visible when you edit the file. Delete it once the file is yours.

      All four default to inclusion: always and priority: 10, so they fire on every AI tool call until you customize them. If you're reading this recipe and haven't touched them yet, open each one now and replace the placeholder bullet list with actual rules for your project. That's the highest-leverage five minutes you can spend in a new ctx setup.

      What to fill in, by file:

      product.md: The elevator pitch plus hard scope:

      • One-sentence product description.
      • Primary users and their top job-to-be-done.
      • Two or three \"this is explicitly out of scope\" items so the AI doesn't wander.

      tech.md: Technology and constraints:

      • Languages and versions (Go 1.22, Node 20, etc.).
      • Frameworks and key libraries.
      • Runtime and deployment target.
      • Hard constraints: \"no CGO\", \"no network at test time\", \"no external DB for unit tests\". These are the things that burn agents when they don't know them.

      structure.md: Layout and naming:

      • Top-level directories and their purpose.
      • Where new files should go (and where they should NOT).
      • Naming conventions for packages, files, types.

      workflow.md: Process rules:

      • Branch strategy (main-only, trunk-based, feature branches).
      • Commit message format, signed-off-by requirement.
      • Pre-commit and pre-push checks.
      • Review expectations.

      After editing, the next AI tool call in Claude Code will pick up the new rules automatically via the plugin's PreToolUse hook, with no sync step and no restart. Other tools (Cursor, Cline, Kiro) need ctx steering sync to export into their native format.

      Prefer a Bare .context/steering/ Directory?

      Re-run ctx init --no-steering-init and delete the scaffolded files. ctx init leaves existing files alone, so the flag is only needed if you want to opt out of the initial scaffold.

      The rest of this recipe walks through creating an additional, scenario-specific steering file beyond the four foundation defaults.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#scenario","level":2,"title":"Scenario","text":"

      You're working on a project with a strict input-validation policy: every new API handler must validate request bodies before touching the database. You want the AI to flag this concern automatically whenever it's asked to write an HTTP handler, without you having to remind it every session.

      Claude Code Users: Pick always, Not auto

      This walkthrough uses inclusion: auto because the scenario is a scoped rule that matches a specific kind of prompt. That works natively on Cursor, Cline, and Kiro (they resolve the description keyword match themselves).

      On Claude Code, auto does not fire through the plugin's PreToolUse hook. The hook passes an empty prompt to ctx agent, so only always files match. Claude can still reach an auto file by calling the ctx_steering_get MCP tool, but that requires Claude to decide to call it; there's no automatic injection.

      If Claude Code is your tool, set inclusion: always in Step 2 instead of auto. The rule will fire on every tool call regardless of topic. You may want to narrow the rule body so the extra tokens per turn aren't wasted on unrelated work.

      See the ctx steering reference \"Prefer inclusion: always for Claude Code\" section for the full trade-off.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-1-scaffold-the-file","level":2,"title":"Step 1: Scaffold the File","text":"
      ctx steering add api-validation\n

      That creates .context/steering/api-validation.md with default frontmatter:

      ---\nname: api-validation\ndescription:\ninclusion: manual\ntools: []\npriority: 50\n---\n

      The defaults are deliberately conservative: inclusion: manual means the file won't be applied until you opt in, which keeps the rules out of the prompt until you've reviewed them.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-2-fill-in-the-rule","level":2,"title":"Step 2: Fill in the Rule","text":"

      Open the file and write the rule body plus a focused description. The description is what inclusion: auto matches against later.

      ---\nname: api-validation\ndescription: HTTP handler input validation and request parsing\ninclusion: auto\ntools: []\npriority: 20\n---\n\n# API request validation\n\nEvery new HTTP handler MUST:\n\n1. Parse request bodies into typed structs, never `map[string]any`.\n2. Validate required fields before any database call.\n3. Return 400 with a machine-readable error for validation failures.\n4. Use `context.Context` from the request for all downstream calls.\n\nPrefer existing validation helpers in `internal/validate/`\nrather than inline checks.\n

      Notes on the choices:

      • inclusion: auto: this rule should fire automatically on HTTP-handler-shaped prompts, not always.
      • priority: 20: lower than the default, so this rule appears near the top of the prompt alongside other high-priority rules.
      • Description is keyword-rich (\"HTTP handler input validation and request parsing\"); the auto matcher scores prompts against these words.
      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-3-preview-which-prompts-match","level":2,"title":"Step 3: Preview Which Prompts Match","text":"

      Before committing the file, validate your description catches the prompts you care about:

      ctx steering preview \"add an endpoint for updating user email\"\n

      Expected output:

      Steering files matching prompt \"add an endpoint for updating user email\":\n  api-validation       inclusion=auto     priority=20  tools=all\n

      Good, the prompt matches. Try a negative case:

      ctx steering preview \"fix a bug in the JSON renderer\"\n

      Expected: empty match (or whatever else is currently auto). If api-validation incorrectly fires for unrelated prompts, tighten the description. If it misses prompts it should catch, add more keywords.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-4-list-to-confirm-metadata","level":2,"title":"Step 4: List to Confirm Metadata","text":"
      ctx steering list\n

      Should show api-validation alongside any other files, with its inclusion mode and priority. If the list is wrong, check the frontmatter for typos.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-5-get-the-rules-in-front-of-the-ai","level":2,"title":"Step 5: Get the Rules in Front of the AI","text":"

      Steering files are authored once in .context/steering/, but how they reach the AI depends on which tool you use. There are two delivery mechanisms:

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#path-a-native-rules-tools-cursor-cline-kiro","level":3,"title":"Path A: Native-Rules Tools (Cursor, Cline, Kiro)","text":"

      These tools read a specific directory for rules. ctx steering sync exports your files into that directory with tool-specific frontmatter:

      ctx steering sync\n

      Depending on the active tool in .ctxrc or --tool:

      Tool Target Cursor .cursor/rules/ Cline .clinerules/ Kiro .kiro/steering/

      The sync is idempotent; unchanged files are skipped. Run it whenever you edit a steering file.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#path-b-claude-code-and-codex-hook-mcp","level":3,"title":"Path B: Claude Code and Codex (Hook + MCP)","text":"

      Claude Code and Codex have no native rules primitive, so ctx steering sync is a no-op for them; it deliberately skips both. Instead, steering reaches these tools through two non-sync channels:

      1. PreToolUse hook (automatic). The ctx setup claude-code plugin installs a hook that runs ctx agent --budget 8000 before each tool call. ctx agent loads your steering files, filters them against the active prompt, and includes matching bodies as Tier 6 of the context packet. The packet gets injected into Claude's context automatically.

      2. ctx_steering_get MCP tool (on-demand). Claude can call this MCP tool mid-task to fetch matching steering files for a specific prompt. Automatic activation comes from Claude's judgment, not a hook.

      Both channels activate when you run:

      ctx setup claude-code --write\n

      That installs the plugin, wires the hook, and registers the MCP server. After that, steering files you edit are picked up on the next tool call, with no sync step needed.

      Running ctx steering sync with Claude Code

      It won't error; it will simply report that Claude and Codex aren't sync targets and skip them. If Claude Code is your only tool, you never need to run sync. If you use both Claude Code and (say) Cursor, run sync to keep Cursor up to date; the Claude pipeline takes care of itself via the hook.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-6-verify-the-ai-sees-it","level":2,"title":"Step 6: Verify the AI Sees It","text":"

      Open your AI tool and ask it something the rule should fire on:

      \"Add a POST /users endpoint that accepts email and name.\"

      If the rule is working, the AI's first response should mention input validation, typed structs, and the internal/validate/ package, because that's what the steering file told it to do.

      If nothing happens, the fix depends on which path you're on:

      Path A (Cursor/Cline/Kiro):

      1. Re-run ctx steering preview with the literal prompt to confirm the match.
      2. Run ctx steering list and verify inclusion is auto, not manual.
      3. Check the tool's own config directory (e.g. .cursor/rules/); the file should be there after ctx steering sync.

      Path B (Claude Code):

      1. Re-run ctx steering preview with the literal prompt to confirm the match.
      2. Verify the plugin is installed: cat .claude/hooks.json should include ctx agent --budget 8000 under PreToolUse. If not, re-run ctx setup claude-code --write.
      3. Run ctx agent --budget 8000 manually and grep the output for your rule body. If it's there, the data is fine; if it's missing, the inclusion mode or description is at fault.
      4. As a last resort, ask Claude directly: \"Call the ctx_steering_get MCP tool with my prompt and show me the result.\" If the MCP tool returns your rule, Claude has access but isn't pulling it into the initial context packet; tighten the description keywords.
      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#common-mistakes","level":2,"title":"Common Mistakes","text":"

      Too-generic descriptions. description: general coding will match almost every prompt and flood the context window. Keep descriptions specific to the scenario the rule applies to.

      Overlapping rules. If two steering files match the same prompt and contradict each other, the result is confusing. Use priority to resolve, but better: merge the files or narrow the descriptions so they don't overlap.

      Putting decisions in steering. \"We decided to use PostgreSQL\" is a decision, not a rule for the AI to follow on every prompt. Record decisions with ctx add decision, not ctx steering add.

      Committing inclusion: always without thinking. Rules marked always fire on every prompt, consuming tier-6 budget permanently. Only use always for true invariants (security, safety, licensing). Everything else should be auto or manual.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#see-also","level":2,"title":"See Also","text":"
      • ctx steering reference: full command, flag, and frontmatter reference.
      • ctx setup: configure which tools the steering sync writes to.
      • Authoring triggers: if you want script-based automation, not rule-based prompt injection.
      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/system-hooks-audit/","level":1,"title":"Auditing System Hooks","text":"","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-problem","level":2,"title":"The Problem","text":"

      ctx runs 14 system hooks behind the scenes: nudging your agent to persist context, warning about resource pressure, gating commits on QA. But these hooks are invisible by design. You never see them fire. You never know if they stopped working.

      How do you verify your hooks are actually running, audit what they do, and get alerted when they go silent?

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tldr","level":2,"title":"TL;DR","text":"
      ctx system check-resources # run a hook manually\nls -la .context/logs/      # check hook execution logs\nctx hook notify setup      # get notified when hooks fire\n

      Or ask your agent: \"Are our hooks running?\"

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx system <hook> CLI command Run a system hook manually ctx sysinfo CLI command Show system resource status ctx usage CLI command Stream or dump per-session token stats ctx hook notify setup CLI command Configure webhook for audit trail ctx hook notify test CLI command Verify webhook delivery .ctxrc notify.events Configuration Subscribe to relay for full hook audit .context/logs/ Log files Local hook execution ledger","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#what-are-system-hooks","level":2,"title":"What Are System Hooks?","text":"

      System hooks are plumbing commands that ctx registers with your AI tool (Claude Code, Cursor, etc.) via the plugin's hooks.json. They fire automatically at specific events during your AI session:

      Event When Hooks UserPromptSubmit Before the agent sees your prompt 10 check hooks + heartbeat PreToolUse Before the agent uses a tool block-non-path-ctx, qa-reminder PostToolUse After a tool call succeeds post-commit

      You never run these manually. Your AI tool runs them for you: That's the point.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-complete-hook-catalog","level":2,"title":"The Complete Hook Catalog","text":"","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#prompt-time-checks-userpromptsubmit","level":3,"title":"Prompt-Time Checks (UserPromptSubmit)","text":"

      These fire before every prompt, but most are throttled to avoid noise.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-context-size-context-capacity-warning","level":4,"title":"check-context-size: Context Capacity Warning","text":"

      What: Adaptive prompt counter. Silent for the first 15 prompts, then nudges with increasing frequency (every 5th, then every 3rd).

      Why: Long sessions lose coherence. The nudge reminds both you and the agent to persist context before the window fills up.

      Output: VERBATIM relay box with prompt count.

      ┌─ Context Checkpoint (prompt #20) ────────────────\n│ This session is getting deep. Consider wrapping up\n│ soon. If there are unsaved learnings, decisions, or\n│ conventions, now is a good time to persist them.\n│ ⏱ Context window: ~45k tokens (~22% of 200k)\n└──────────────────────────────────────────────────\n

      Usage: Every prompt records token usage to .context/state/stats-{session}.jsonl. Monitor live with ctx usage --follow or query with ctx usage --json. Usage is recorded even during wrap-up suppression (event: suppressed).

      Billing guard: When billing_token_warn is set in .ctxrc, a one-shot warning fires if session tokens exceed the threshold. This warning is independent of all other triggers - it fires even during wrap-up suppression.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-persistence-context-staleness-nudge","level":4,"title":"check-persistence: Context Staleness Nudge","text":"

      What: Tracks when .context/*.md files were last modified. If too many prompts pass without a write, nudges the agent to persist.

      Why: Sessions produce insights that evaporate if not recorded. This catches the \"we talked about it but never wrote it down\" failure mode.

      Output: VERBATIM relay after 20+ prompts without a context file change.

      ┌─ Persistence Checkpoint (prompt #20) ───────────\n│ No context files updated in 20+ prompts.\n│ Have you discovered learnings, made decisions,\n│ established conventions, or completed tasks\n│ worth persisting?\n│\n│ Run /ctx-wrap-up to capture session context.\n└──────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-ceremonies-session-ritual-adoption","level":4,"title":"check-ceremonies: Session Ritual Adoption","text":"

      What: Scans your last 3 journal entries for /ctx-remember and /ctx-wrap-up usage. Nudges once per day if missing.

      Why: Session ceremonies are the highest-leverage habit in ctx. This hook bootstraps the habit until it becomes automatic.

      Output: Tailored nudge depending on which ceremony is missing.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-journal-unimported-session-reminder","level":4,"title":"check-journal: Unimported Session Reminder","text":"

      What: Detects unimported Claude Code sessions and unenriched journal entries. Fires once per day.

      Why: Exported sessions become searchable history. Unenriched entries lack metadata for filtering. Both decay in value over time.

      Output: VERBATIM relay with counts and exact commands.

      ┌─ Journal Reminder ─────────────────────────────\n│ You have 3 new session(s) not yet exported.\n│ 5 existing entries need enrichment.\n│\n│ Export and enrich:\n│   ctx journal import --all\n│   /ctx-journal-enrich-all\n└────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-resources-system-resource-pressure","level":4,"title":"check-resources: System Resource Pressure","text":"

      What: Monitors memory, swap, disk, and CPU load. Only fires at DANGER severity (memory >= 90%, swap >= 75%, disk >= 95%, load >= 1.5x CPU count).

      Why: Resource exhaustion mid-session can corrupt work. This provides early warning to persist and exit.

      Output: VERBATIM relay listing critical resources.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-knowledge-knowledge-file-growth","level":4,"title":"check-knowledge: Knowledge File Growth","text":"

      What: Counts entries in LEARNINGS.md, DECISIONS.md, and lines in CONVENTIONS.md. Fires once per day when thresholds are exceeded.

      Why: Large knowledge files dilute agent context. 35 learnings compete for attention; 15 focused ones get applied. Thresholds are configurable in .ctxrc.

      Default thresholds:

      # .ctxrc\nentry_count_learnings: 30\nentry_count_decisions: 20\nconvention_line_count: 200\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-version-binaryplugin-version-drift","level":4,"title":"check-version: Binary/Plugin Version Drift","text":"

      What: Compares the ctx binary version against the plugin version. Fires once per day. Also checks encryption key age for rotation nudge.

      Why: Version drift means hooks reference features the binary doesn't have. The key rotation nudge prevents indefinite key reuse.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-reminders-pending-reminder-relay","level":4,"title":"check-reminders: Pending Reminder Relay","text":"

      What: Reads .context/reminders.json and surfaces any due reminders via VERBATIM relay. No throttle: fires every session until dismissed.

      Why: Reminders are sticky notes to future-you. Unlike nudges (which throttle to once per day), reminders repeat deliberately until the user dismisses them.

      Output: VERBATIM relay box listing due reminders.

      ┌─ Reminders ──────────────────────────────────────\n│  [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-freshness-technology-constant-staleness","level":4,"title":"check-freshness: Technology Constant Staleness","text":"

      What: Stats files listed in .ctxrc freshness_files and warns if any haven't been modified in over 6 months. Daily throttle. Silent when no files are configured (opt-in via .ctxrc).

      Why: Model capabilities evolve - token budgets, attention limits, and context window sizes that were accurate 6 months ago may no longer reflect best practices. This hook reminds you to review and touch the file to confirm values are still current.

      Config (.ctxrc):

      freshness_files:\n  - path: config/thresholds.yaml\n    desc: Model token limits and batch sizes\n    review_url: https://docs.example.com/limits  # optional\n

      Each entry has a path (relative to project root), desc (what constants live there), and optional review_url (where to check current values). When review_url is set, the nudge includes \"Review against: {url}\". When absent, just \"Touch the file to mark it as reviewed.\"

      Output: VERBATIM relay listing stale files, silent otherwise.

      ┌─ Technology Constants Stale ──────────────────────\n│   config/thresholds.yaml (210 days ago)\n│     - Model token limits and batch sizes\n│   Review against: https://docs.example.com/limits\n│ Touch each file to mark it as reviewed.\n└───────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-map-staleness-architecture-map-drift","level":4,"title":"check-map-staleness: Architecture Map Drift","text":"

      What: Checks whether map-tracking.json is older than 30 days and there are commits touching internal/ since the last map refresh. Daily throttle prevents repeated nudges.

      Why: Architecture documentation drifts silently as code evolves. This hook detects structural changes that the map hasn't caught up with and suggests running /ctx-architecture to refresh.

      Output: VERBATIM relay when stale and modules changed, silent otherwise.

      ┌─ Architecture Map Stale ────────────────────────────\n│ ARCHITECTURE.md hasn't been refreshed since 2026-01-15\n│ and there are commits touching 12 modules.\n│ /ctx-architecture keeps architecture docs drift-free.\n│\n│ Want me to run /ctx-architecture to refresh?\n└─────────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#heartbeat-session-heartbeat-webhook","level":4,"title":"heartbeat: Session Heartbeat Webhook","text":"

      What: Fires on every prompt. Sends a webhook notification with prompt count, session ID, context modification status, and token usage telemetry. Never produces stdout.

      Why: Other hooks only send webhooks when they \"speak\" (nudge/relay). When silent, you have no visibility into session activity. The heartbeat provides a continuous session-alive signal with token consumption data for observability dashboards or liveness monitoring.

      Output: None (webhook + event log only).

      Payload:

      {\n  \"event\": \"heartbeat\",\n  \"message\": \"heartbeat: prompt #7 (context_modified=false tokens=158k pct=79%)\",\n  \"detail\": {\n    \"hook\": \"heartbeat\",\n    \"variant\": \"pulse\",\n    \"variables\": {\n      \"prompt_count\": 7,\n      \"session_id\": \"abc...\",\n      \"context_modified\": false,\n      \"tokens\": 158000,\n      \"context_window\": 200000,\n      \"usage_pct\": 79\n    }\n  }\n}\n

      Token fields (tokens, context_window, usage_pct) are included when usage data is available from the session JSONL file.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tool-time-hooks-pretooluse-posttooluse","level":3,"title":"Tool-Time Hooks (PreToolUse / PostToolUse)","text":"","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#block-non-path-ctx-path-enforcement-hard-gate","level":4,"title":"block-non-path-ctx: PATH Enforcement (Hard Gate)","text":"

      What: Blocks any Bash command that invokes ./ctx, ./dist/ctx, go run ./cmd/ctx, or an absolute path to ctx. Only PATH invocations are allowed.

      Why: Enforces CONSTITUTION.md's invocation invariant. Running a dev-built binary in production context causes version confusion and silent behavior drift.

      Output: Block response (prevents the tool call):

      {\"decision\": \"block\", \"reason\": \"Use 'ctx' from PATH, not './ctx'...\"}\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#qa-reminder-pre-commit-qa-gate","level":4,"title":"qa-reminder: Pre-Commit QA Gate","text":"

      What: Fires on every Edit tool use. Reminds the agent to lint and test the entire project before committing.

      Why: Agents tend to \"I'll test later\" and then commit untested code. Repetition is intentional: the hook reinforces the habit on every edit, not just before commits.

      Output: Agent directive with hard QA gate instructions.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#post-commit-context-capture-after-commit","level":4,"title":"post-commit: Context Capture After Commit","text":"

      What: Fires after any git commit (excludes --amend). Prompts the agent to offer context capture (decision? learning?) and suggest running lints/tests before pushing.

      Why: Commits are natural reflection points. The nudge converts mechanical git operations into context-capturing opportunities.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#auditing-hooks-via-the-local-event-log","level":2,"title":"Auditing Hooks via the Local Event Log","text":"

      If you don't need an external audit trail, enable the local event log for a self-contained record of hook activity:

      # .ctxrc\nevent_log: true\n

      Once enabled, every hook that fires writes an entry to .context/state/events.jsonl. Query it with ctx hook event:

      ctx hook event                    # last 50 events\nctx hook event --hook qa-reminder # filter by hook\nctx hook event --session <id>     # filter by session\nctx hook event --json | jq '.'    # raw JSONL for processing\n

      The event log is local, queryable, and doesn't require any external service. For a full diagnostic workflow combining event logs with structural health checks, see Troubleshooting.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#auditing-hooks-via-webhooks","level":2,"title":"Auditing Hooks via Webhooks","text":"

      The most powerful audit setup pipes all hook output to a webhook, giving you a real-time external record of what your agent is being told.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#step-1-set-up-the-webhook","level":3,"title":"Step 1: Set Up the Webhook","text":"
      ctx hook notify setup\n# Enter your webhook URL (Slack, Discord, ntfy.sh, IFTTT, etc.)\n

      See Webhook Notifications for service-specific setup.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#step-2-subscribe-to-relay-events","level":3,"title":"Step 2: Subscribe to relay Events","text":"
      # .ctxrc\nnotify:\n  events:\n    - relay   # all hook output: VERBATIM relays, directives, blocks\n    - nudge   # just the user-facing VERBATIM relays\n

      The relay event fires for every hook that produces output. This includes:

      Hook Event sent check-context-size relay + nudge check-persistence relay + nudge check-ceremonies relay + nudge check-journal relay + nudge check-resources relay + nudge check-knowledge relay + nudge check-version relay + nudge check-reminders relay + nudge check-freshness relay + nudge check-map-staleness relay + nudge heartbeat heartbeat only block-non-path-ctx relay only post-commit relay only qa-reminder relay only","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#step-3-cross-reference","level":3,"title":"Step 3: Cross-Reference","text":"

      With relay enabled, your webhook receives a JSON payload every time a hook fires:

      {\n  \"event\": \"relay\",\n  \"message\": \"check-persistence: No context updated in 20+ prompts\",\n  \"session_id\": \"b854bd9c\",\n  \"timestamp\": \"2026-02-22T14:30:00Z\",\n  \"project\": \"my-project\"\n}\n

      This creates an external audit trail independent of the agent. You can now cross-verify: did the agent actually relay the checkpoint the hook told it to relay?

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#verifying-hooks-actually-fire","level":2,"title":"Verifying Hooks Actually Fire","text":"

      Hooks are invisible. An invisible thing that breaks is indistinguishable from an invisible thing that never existed. Three verification methods, from simplest to most robust:

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#method-1-ask-the-agent","level":3,"title":"Method 1: Ask the Agent","text":"

      The simplest check. After a few prompts into a session:

      \"Did you receive any hook output this session? Print the last\ncontext checkpoint or persistence nudge you saw.\"\n

      The agent should be able to recall recent hook output from its context window. If it says \"I haven't received any hook output\", either:

      • The hooks aren't firing (check installation);
      • The session is too short (hooks throttle early);
      • The hooks fired but the agent absorbed them silently.

      Limitation: You are trusting the agent to report accurately. Agents sometimes confabulate or miss context. Use this as a quick smoke test, not definitive proof.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#method-2-check-the-webhook-trail","level":3,"title":"Method 2: Check the Webhook Trail","text":"

      If you have relay events enabled, check your webhook receiver. Every hook that fires sends a timestamped notification. No notification = no fire.

      This is the ground truth. The webhook is called directly by the ctx binary, not by the agent. The agent cannot fake, suppress, or modify webhook deliveries.

      Compare what the webhook received against what the agent claims to have relayed. Discrepancies mean the agent is absorbing nudges instead of surfacing them.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#method-3-read-the-local-logs","level":3,"title":"Method 3: Read the Local Logs","text":"

      Hooks that support logging write to .context/logs/:

      # Check context-size hook activity\ncat .context/logs/check-context-size.log\n\n# Sample output:\n# [2026-02-22 09:15:00] [session:b854bd9c] prompt#1 silent\n# [2026-02-22 09:17:33] [session:b854bd9c] prompt#16 CHECKPOINT\n# [2026-02-22 09:20:01] [session:b854bd9c] prompt#20 CHECKPOINT\n
      # Check persistence nudge activity\ncat .context/logs/check-persistence.log\n\n# Sample output:\n# [2026-02-22 09:15:00] [session:b854bd9c] init count=1 mtime=1770646611\n# [2026-02-22 09:20:01] [session:b854bd9c] prompt#20 NUDGE since_nudge=20\n

      Logs are append-only and written by the ctx binary, not the agent.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#detecting-silent-hook-failures","level":2,"title":"Detecting Silent Hook Failures","text":"

      The hardest failure mode: hooks that stop firing without error. The plugin config changes, a binary update drops a hook, or a PATH issue silently breaks execution. Nothing errors: The hook just never runs.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-staleness-signal","level":3,"title":"The Staleness Signal","text":"

      If .context/logs/check-context-size.log has no entries newer than 5 days but you've been running sessions daily, something is wrong. The absence of evidence is evidence of absence: but only if you control for inactivity.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#false-positive-protection","level":3,"title":"False Positive Protection","text":"

      A naive \"hooks haven't fired in N days\" alert fires incorrectly when you simply haven't used ctx. The correct check needs two inputs:

      1. Last hook fire time: from .context/logs/ or webhook history
      2. Last session activity: from journal entries or ctx journal source

      If sessions are happening but hooks aren't firing, that's a real problem. If neither sessions nor hooks are happening, that's a vacation.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#what-to-check","level":3,"title":"What to Check","text":"

      When you suspect hooks aren't firing:

      # 1. Verify the plugin is installed\nls ~/.claude/plugins/\n\n# 2. Check hook registration\ncat ~/.claude/plugins/ctx/hooks.json | head -20\n\n# 3. Run a hook manually to see if it errors\necho '{\"session_id\":\"test\"}' | ctx system check-context-size\n\n# 4. Check for PATH issues\nwhich ctx\nctx --version\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tips","level":2,"title":"Tips","text":"
      • Start with nudge, graduate to relay: The nudge event covers user-facing VERBATIM relays. Add relay when you want full visibility into agent directives and hard gates.
      • Webhooks are your trust anchor: The agent can ignore a nudge, but it can't suppress the webhook. If the webhook fired and the agent didn't relay, you have proof of a compliance gap.
      • Hooks are throttled by design: Most check hooks fire once per day or use adaptive frequency. Don't expect a notification every prompt: Silence usually means the throttle is working, not that the hook is broken.
      • Daily markers live in .context/state/: Throttle files are stored in .context/state/ alongside other project-scoped state. If you need to force a hook to re-fire during testing, delete the corresponding marker file.
      • The QA reminder is intentionally noisy: Unlike other hooks, qa-reminder fires on every Edit call with no throttle. This is deliberate: The commit quality degrades when the reminder fades from salience.
      • Log files are safe to commit: .context/logs/ contains only timestamps, session IDs, and status keywords. No secrets, no code.
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#next-up","level":2,"title":"Next Up","text":"

      Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#see-also","level":2,"title":"See Also","text":"
      • Troubleshooting: full diagnostic workflow using ctx doctor, event logs, and /ctx-doctor
      • Customizing Hook Messages: override what hooks say without changing what they do
      • Webhook Notifications: setting up and configuring the webhook system
      • Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates
      • Detecting and Fixing Drift: structural checks that complement runtime hook auditing
      • CLI Reference: full ctx system command reference
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/task-management/","level":1,"title":"Tracking Work Across Sessions","text":"","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-problem","level":2,"title":"The Problem","text":"

      You have work that spans multiple sessions. Tasks get added during one session, partially finished in another, and completed days later.

      Without a system, follow-up items fall through the cracks, priorities drift, and you lose track of what was done versus what still needs doing. TASKS.md grows cluttered with completed checkboxes that obscure the remaining work.

      How do you manage work items that span multiple sessions without losing context?

      Prefer Skills over Raw Commands

      When working with an AI agent, use /ctx-task-add instead of raw ctx add task. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, the ctx add task / ctx task ... commands below fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tldr","level":2,"title":"TL;DR","text":"

      Manage Tasks:

      ctx add task \"Fix race condition\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a  # add\nctx add task \"Write tests\" --section \"Phase 2\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a  # add to phase\nctx task complete \"race condition\"                      # mark done\nctx task snapshot \"before-refactor\"               # backup\nctx task archive                                  # clean up\n

      Pick Up the Next Task:

      /ctx-next # pick what's next\n

      Read on for the full workflow and conversational patterns.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx add task Command Add a new task to TASKS.md ctx task complete Command Mark a task as done by number or text ctx task snapshot Command Create a point-in-time backup of TASKS.md ctx task archive Command Move completed tasks to archive file /ctx-task-add Skill AI-assisted task creation with validation /ctx-archive Skill AI-guided archival with safety checks /ctx-next Skill Pick what to work on based on priorities","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-1-add-tasks-with-priorities","level":3,"title":"Step 1: Add Tasks with Priorities","text":"

      Every piece of follow-up work gets a task. Use ctx add task from the terminal or /ctx-task-add from your AI assistant. Tasks should start with a verb and be specific enough that someone unfamiliar with the session could act on them.

      # High-priority bug found during code review\nctx add task \"Fix race condition in session cooldown\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Medium-priority feature work\nctx add task \"Add --format json flag to ctx status for CI integration\" --priority medium \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Low-priority cleanup\nctx add task \"Remove deprecated --raw flag from ctx load\" --priority low \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n

      The /ctx-task-add skill validates your task before recording it. It checks that the description is actionable, not a duplicate, and specific enough for someone else to pick up.

      If you say \"fix the bug,\" it will ask you to clarify which bug and where.

      Tasks Are Often Created Proactively

      In practice, many tasks are created proactively by the agent rather than by explicit CLI commands.

      After completing a feature, the agent will often identify follow-up work: tests, docs, edge cases, error handling, and offer to add them as tasks.

      You do not need to dictate ctx add task commands; the agent picks up on work context and suggests tasks naturally.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-2-organize-with-phase-sections","level":3,"title":"Step 2: Organize with Phase Sections","text":"

      Tasks live in phase sections inside TASKS.md.

      Phases provide logical groupings that preserve order and enable replay.

      A task does not move between sections. It stays in its phase permanently, and status is tracked via checkboxes and inline tags.

      ## Phase 1: Core CLI\n\n- [x] Implement ctx add command\n- [x] Implement ctx task complete command\n- [ ] Add --section flag to ctx add task `#priority:medium`\n\n## Phase 2: AI Integration\n\n- [ ] Implement ctx agent cooldown `#priority:high` `#in-progress`\n- [ ] Add ctx watch XML parsing `#priority:medium`\n  - Blocked by: Need to finalize agent output format\n\n## Backlog\n\n- [ ] Performance optimization for large TASKS.md files `#priority:low`\n- [ ] Add metrics dashboard to ctx status `#priority:deferred`\n

      Use --section when adding a task to a specific phase:

      ctx add task \"Add ctx watch XML parsing\" --priority medium --section \\\n    \"Phase 2: AI Integration\" \\\n    --session-id abc12345 --branch main --commit 68fbc00a\n

      Without --section, the task is inserted before the first unchecked task in TASKS.md.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-3-pick-what-to-work-on","level":3,"title":"Step 3: Pick What to Work On","text":"

      At the start of a session, or after finishing a task, use /ctx-next to get prioritized recommendations.

      The skill reads TASKS.md, checks recent sessions, and ranks candidates using explicit priority, blocking status, in-progress state, momentum from recent work, and phase order.

      You can also ask naturally: \"what should we work on?\" or \"what's the highest priority right now?\"

      /ctx-next\n

      The output looks like this:

      **1. Implement ctx agent cooldown** `#priority:high`\n\n    Still in-progress from yesterday's session. The tombstone file approach is\n    half-built. Finishing is cheaper than context-switching.\n\n**2. Add --section flag to ctx add task** `#priority:medium`\n\n    Last Phase 1 item. Quick win that unblocks organized task entry.\n\n---\n\n*Based on 8 pending tasks across 3 phases.\n\nLast session: agent-cooldown (2026-02-06).*\n

      In-progress tasks almost always come first:

      Finishing existing work takes priority over starting new work.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-4-complete-tasks","level":3,"title":"Step 4: Complete Tasks","text":"

      When a task is done, mark it complete by number or partial text match:

      # By task number (as shown in TASKS.md)\nctx task complete 3\n\n# By partial text match\nctx task complete \"agent cooldown\"\n

      The task's checkbox changes from [ ] to [x]. Tasks are never deleted: they stay in their phase section so history is preserved.

      Be Conversational

      You rarely need to run ctx task complete yourself during an interactive session.

      When you say something like \"the rate limiter is done\" or \"we finished that,\" the agent marks the task complete and moves on to suggesting what is next.

      The CLI commands are most useful for manual housekeeping, scripted workflows, or when you want precision.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-5-snapshot-before-risky-changes","level":3,"title":"Step 5: Snapshot Before Risky Changes","text":"

      Before a major refactor or any change that might break things, snapshot your current task state. This creates a copy of TASKS.md in .context/archive/ without modifying the original.

      # Default snapshot\nctx task snapshot\n\n# Named snapshot (recommended before big changes)\nctx task snapshot \"before-refactor\"\n

      This creates a file like .context/archive/tasks-before-refactor-2026-02-08-1430.md. If the refactor goes sideways, and you need to confirm what the task state looked like before you started, the snapshot is there.

      Snapshots are cheap: Take them before any change you might want to undo or review later.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-6-archive-when-tasksmd-gets-cluttered","level":3,"title":"Step 6: Archive When TASKS.md Gets Cluttered","text":"

      After several sessions, TASKS.md accumulates completed tasks that make it hard to see what is still pending.

      Use ctx task archive to move all [x] items to a timestamped archive file.

      Start with a dry run to preview what will be moved:

      ctx task archive --dry-run\n

      Then archive:

      ctx task archive\n

      Completed tasks move to .context/archive/tasks-2026-02-08.md. Phase headers are preserved in the archive for traceability. Pending tasks ([ ]) remain in TASKS.md.

      The /ctx-archive skill adds two safety checks before archiving: it verifies that completed tasks are genuinely cluttering the view and that nothing was marked [x] prematurely.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#letting-the-agent-drive","level":2,"title":"Letting the Agent Drive","text":"

      The steps above show the CLI commands for task management.

      In practice, most task management happens conversationally:

      An agent that has loaded the context files does not need you to type ctx add task. It tracks work naturally and offers the right operations.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#use-natural-language-instead-of-commands","level":3,"title":"Use Natural Language Instead of Commands","text":"

      These conversational prompts replace explicit commands during interactive sessions:

      Instead of typing... Just say... ctx add task \"Write tests for X\" --session-id ID --branch BR --commit HASH \"We should add tests for this: track that?\" /ctx-next \"What should we work on?\" ctx task complete \"rate limiting\" \"The rate limiter is done, what's next?\" ctx task archive \"TASKS.md is getting long, can you clean it up?\" ctx add task ... --session-id ID --branch BR --commit HASH && ctx add task ... \"Add follow-ups for what we just built.\"

      The agent translates these into the right ctx operations behind the scenes.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-agent-creates-tasks-proactively","level":3,"title":"The Agent Creates Tasks Proactively","text":"

      After completing a piece of work, the agent does not wait for you to dictate follow-up items. It identifies them from the work context and offers:

      **Agent**: \"I've finished implementing the rate limiter middleware. I noticed\nthree follow-up items:\n\n1. Write integration tests for the rate limiter (the unit tests pass but\n   there's no end-to-end coverage)\n2. Add rate limit headers to API responses (X-RateLimit-Remaining, etc.)\n3. Document the rate limit configuration in the ops runbook\n\nWant me to add these as tasks?\"\n

      This is how an agent behaves once it has read the Agent Playbook.

      The playbook's \"Work, Reflect, Persist\" cycle means the agent asks itself after every milestone: Did I just complete a task? Did new work emerge?

      When the answer is yes, it acts.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#asking-the-agent-what-to-capture","level":3,"title":"Asking the Agent What to Capture","text":"

      You don't always know what's worth persisting.

      Instead of reviewing the session yourself and typing specific commands, ask the agent to do the thinking:

      You say What happens \"What tasks came out of this session?\" Agent reviews the work, identifies follow-ups, and offers to add them \"Are there any tasks, learnings, or decisions worth adding?\" Agent scans the full session for all three types and proposes a batch \"What should we remember from today?\" Agent surfaces everything persist-worthy: not just tasks \"Anything we should track before we move on?\" Agent checks for loose ends specific to the work just completed

      This is especially powerful after long or exploratory sessions where multiple threads were touched.

      The agent has the full conversation in context and can spot follow-ups you might miss:

      You:   \"Are there any tasks, learnings, or decisions worth adding\n        from this session?\"\n\nAgent: \"Yes. Here's what I'd suggest:\n\n  Tasks:\n  - Add retry logic to the webhook delivery (we discussed it when\n    the timeout test failed but never tracked it)\n  - Update the API docs to reflect the new rate limit headers\n\n  Learnings:\n  - net/http's default client has no timeout: we burned 15 minutes\n    on that before adding an explicit 30s timeout\n\n  Decisions:\n  - We chose token-bucket over sliding-window for rate limiting\n    because it handles bursts better and the library is simpler\n\n  Want me to add all of these?\"\n\nYou:   \"All of them.\"\n

      The agent fills in structured fields from what it observed during the session. You get the same quality entries as if you typed verbose commands, without needing to remember what happened or how to format it.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-agent-completes-tasks-and-moves-on","level":3,"title":"The Agent Completes Tasks and Moves On","text":"

      When you confirm that work is finished, or when the agent can see that it is, it marks the task done and suggests the next step:

      You: \n\"The cooldown logic is working now.\"\n\nAgent: \n\"Marked 'Implement ctx agent cooldown' as done. Your highest-\npriority remaining task is 'Add --section flag to ctx add task'.\n\nIt's the last item in Phase 1 and a quick win. Want to start on that?\"\n

      The agent chains completion into next-task selection.

      One sentence from you triggers two operations.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#end-of-session-capture","level":3,"title":"End-of-Session Capture","text":"

      At the end of a session, the agent reviews what happened and catches loose ends:

      You: \n\"I think we're good for today.\"\n\nAgent: \n\"Before we wrap up: during the middleware work you mentioned\nwanting to add metrics for rate limit hits. That never made it into TASKS.md.\n\nWant me to add it as a task so it's there next session?\"\n

      This is the proactive persistence model at work.

      The agent monitors the conversation for mentioned-but-not-tracked work and surfaces it before context is lost.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#a-conversational-session-example","level":3,"title":"A Conversational Session Example","text":"

      Here is what task management looks like in a real session when the agent is driving:

      You:   What's left to do?\nAgent: You have 5 pending tasks across 2 phases. The highest priority is\n       \"Implement ctx agent cooldown\": it's marked in-progress from\n       yesterday and half-built. Want to pick that up?\n\nYou:   Yeah, let's finish it.\n       [... 20 minutes of implementation work ...]\n\nYou:   That's working. Tests pass.\nAgent: Nice. I'll mark \"Implement ctx agent cooldown\" as done.\n       I noticed two things from the implementation:\n       1. The tombstone file cleanup should happen on a timer, not just\n          at startup. Want me to add that as a task?\n       2. We learned that file locks don't work reliably on NFS. I'll\n          add that to LEARNINGS.md.\n\nYou:   Yes to both. What's next?\nAgent: Added the cleanup task as high priority. Next up is \"Add --section\n       flag to ctx add task\": last item in Phase 1. It should be\n       straightforward since the flag parsing pattern already exists\n       in the codebase. Ready?\n

      It's All Conversational

      Notice what did not happen: The user never typed a ctx command.

      The agent handled task completion, follow-up creation, learning capture, and next-task selection: all from natural conversation.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"
      # Add a task\nctx add task \"Implement rate limiting for API endpoints\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Add to a specific phase\nctx add task \"Write integration tests for rate limiter\" --section \"Phase 2\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# See what to work on\n# (from AI assistant) /ctx-next\n\n# Mark done by text\nctx task complete \"rate limiting\"\n\n# Mark done by number\nctx task complete 5\n\n# Snapshot before a risky refactor\nctx task snapshot \"before-middleware-rewrite\"\n\n# Archive completed tasks when the list gets long\nctx task archive --dry-run     # preview first\nctx task archive               # then archive\n
      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tips","level":2,"title":"Tips","text":"
      • Start tasks with a verb: \"Add,\" \"Fix,\" \"Implement,\" \"Investigate\": not just a topic like \"Authentication.\"
      • Include the why in the task description. Future sessions lack the context of why you added the task. \"Add rate limiting\" is worse than \"Add rate limiting to prevent abuse on the public API after the load test showed 10x traffic spikes.\"
      • Use #in-progress sparingly. Only one or two tasks should carry this tag at a time. If everything is in-progress, nothing is.
      • Snapshot before, not after. The point of a snapshot is to capture the state before a change, not to celebrate what you just finished.
      • Archive regularly. Once completed tasks outnumber pending ones, it is time to archive. A clean TASKS.md helps both you and your AI assistant focus.
      • Never delete tasks. Mark them [x] (completed) or [-] (skipped with a reason). Deletion breaks the audit trail.
      • Trust the agent's task instincts. When the agent suggests follow-up items after completing work, it is drawing on the full context of what just happened.
      • Conversational prompts beat commands in interactive sessions. Saying \"what should we work on?\" is faster and more natural than running /ctx-next. Save explicit commands for scripts, CI, and unattended runs.
      • Let the agent chain operations. A single statement like \"that's done, what's next?\" can trigger completion, follow-up identification, and next-task selection in one flow.
      • Review proactive task suggestions before moving on. The best follow-ups come from items spotted in-context right after the work completes.
      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#next-up","level":2,"title":"Next Up","text":"

      Using the Scratchpad →: Store short-lived sensitive notes in an encrypted scratchpad.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: full session lifecycle including task management in context
      • Persisting Decisions, Learnings, and Conventions: capturing the \"why\" behind your work
      • Detecting and Fixing Drift: keeping TASKS.md accurate over time
      • CLI Reference: full documentation for ctx add, ctx task complete, ctx task
      • Context Files: TASKS.md: format and conventions for TASKS.md
      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/triggers/","level":1,"title":"Authoring Lifecycle Triggers","text":"","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#authoring-lifecycle-triggers","level":1,"title":"Authoring Lifecycle Triggers","text":"

      Triggers are executable shell scripts that fire at specific events during an AI session. They're how you express \"when the AI saves a file, also do X\" or \"before the AI edits this path, check Y first.\" This recipe walks through writing your first trigger, testing it, and enabling it safely.

      Triggers Execute Arbitrary Code

      A trigger is a shell script with the executable bit set. It runs with the same privileges as your AI tool and receives JSON input on stdin. Treat triggers like pre-commit hooks:

      • Only enable scripts you have read and understand.
      • Never enable a trigger you downloaded from the internet without reviewing every line.
      • Avoid shelling out to user-controlled values (jq -r output, path field, tool field) without quoting.
      • A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.

      The generated trigger template starts disabled (no executable bit) so you cannot accidentally run an unreviewed script. Enable it explicitly with ctx trigger enable.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#scenario","level":2,"title":"Scenario","text":"

      You want a pre-tool-use trigger that blocks the AI from editing anything in internal/crypto/ without explicit confirmation. Cryptographic code is sensitive, and accidental edits have caused outages before, and you want a hard gate.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-1-scaffold-the-script","level":2,"title":"Step 1: Scaffold the Script","text":"
      ctx trigger add pre-tool-use protect-crypto\n

      That creates .context/hooks/pre-tool-use/protect-crypto.sh with a template:

      #!/usr/bin/env bash\nset -euo pipefail\n\n# Read the JSON event from stdin.\npayload=$(cat)\n\n# Parse fields with jq.\ntool=$(echo \"$payload\" | jq -r '.tool // empty')\npath=$(echo \"$payload\" | jq -r '.path // empty')\n\n# Your logic here.\n\n# Return a JSON result. action can be \"allow\", \"block\", or absent.\necho '{\"action\": \"allow\"}'\n

      Note: the directory is .context/hooks/pre-tool-use/; the on-disk layout still uses hooks/ even though the command is ctx trigger. If you ls .context/hooks/, that's where your triggers live.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-2-write-the-logic","level":2,"title":"Step 2: Write the Logic","text":"

      Open the file and replace the template body:

      #!/usr/bin/env bash\nset -euo pipefail\n\npayload=$(cat)\ntool=$(echo \"$payload\" | jq -r '.tool // empty')\npath=$(echo \"$payload\" | jq -r '.path // empty')\n\n# Only gate write-family tools.\ncase \"$tool\" in\n  write_file|edit_file|apply_patch) ;;\n  *)\n    echo '{\"action\": \"allow\"}'\n    exit 0\n    ;;\nesac\n\n# Block any path under internal/crypto/.\ncase \"$path\" in\n  internal/crypto/*|*/internal/crypto/*)\n    jq -n --arg p \"$path\" '{\n      action: \"block\",\n      message: (\"Edits to \" + $p + \" require manual review. \" +\n                \"See CONVENTIONS.md for the crypto-change process.\")\n    }'\n    exit 0\n    ;;\nesac\n\necho '{\"action\": \"allow\"}'\n

      A few things to note:

      • set -euo pipefail: any unhandled error aborts the script. Critical for a security-relevant trigger.
      • Quote everything from jq: the path field comes from the AI tool; treat it as untrusted input.
      • Explicit allow case: the default is allow. An empty or missing response is a risky default.
      • Use jq -n --arg for output construction, as it is safer than string concatenation when the message may contain special characters.
      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-3-test-with-a-mock-payload","level":2,"title":"Step 3: Test with a Mock Payload","text":"

      Before enabling the trigger, test it with a realistic mock input using ctx trigger test. This runs the script against a synthetic JSON payload without actually firing any AI tool.

      # Test the \"should block\" case\nctx trigger test pre-tool-use --tool write_file --path internal/crypto/aes.go\n

      Expected: the trigger returns {\"action\":\"block\", \"message\": \"...\"}.

      # Test the \"should allow\" case\nctx trigger test pre-tool-use --tool write_file --path internal/memory/mirror.go\n

      Expected: the trigger returns {\"action\":\"allow\"}.

      # Test that non-write tools pass through\nctx trigger test pre-tool-use --tool read_file --path internal/crypto/aes.go\n

      Expected: {\"action\":\"allow\"} because the case statement only gates write-family tools.

      If any of these cases misbehave, fix the trigger before enabling it. The trigger is disabled at this point, so misbehavior doesn't affect real AI sessions.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-4-enable-it","level":2,"title":"Step 4: Enable It","text":"

      Once the test cases pass, enable the trigger:

      ctx trigger enable protect-crypto\n

      That sets the executable bit. Next time the AI starts a pre-tool-use event, the trigger will fire.

      Verify it's enabled:

      ctx trigger list\n

      Should show protect-crypto under pre-tool-use with an enabled indicator.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-5-iterate-safely","level":2,"title":"Step 5: Iterate Safely","text":"

      If you discover a bug after enabling, disable first, fix second:

      ctx trigger disable protect-crypto\n# ...edit the script...\nctx trigger test pre-tool-use --tool write_file --path internal/crypto/aes.go\nctx trigger enable protect-crypto\n

      Disabling simply clears the executable bit; the script stays on disk, and ctx trigger enable re-enables it without rewriting anything.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#patterns-worth-copying","level":2,"title":"Patterns Worth Copying","text":"","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#logging-not-blocking","level":3,"title":"Logging, Not Blocking","text":"

      For auditing or analytics, return {\"action\":\"allow\"} always and append to a log as a side effect:

      #!/usr/bin/env bash\nset -euo pipefail\npayload=$(cat)\necho \"$payload\" >> .context/logs/tool-use.jsonl\necho '{\"action\":\"allow\"}'\n
      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#context-injection-at-session-start","level":3,"title":"Context Injection at Session Start","text":"

      A session-start trigger can prepend text to the agent's initial prompt by emitting {\"action\":\"inject\", \"content\": \"...\"} . This is useful for injecting daily standup notes, open PRs, or rotating TODOs without storing them in a steering file.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#chaining-triggers-of-the-same-type","level":3,"title":"Chaining Triggers of the Same Type","text":"

      Multiple scripts in the same type directory all run. If any returns action: block, the block wins. Keep individual triggers single-purpose and rely on composition.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#common-mistakes","level":2,"title":"Common Mistakes","text":"

      Forgetting the shebang. Without #!/usr/bin/env bash, the trigger won't execute even with the executable bit set.

      Not quoting $path. If you use $path in a command substitution or a case glob without quoting, a file name with spaces or metacharacters will break the trigger in surprising ways.

      Enabling before testing. ctx trigger enable makes the script live immediately. Always ctx trigger test first.

      Outputting non-JSON. The trigger's stdout must be valid JSON or ctx's trigger runner will log a parse error. Use jq -n to construct output rather than hand-writing JSON strings.

      Mixing hook and trigger vocabulary. The command is ctx trigger but the on-disk directory is .context/hooks/. The feature was renamed; the directory name lags behind. Don't let this confuse you; they refer to the same thing.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#see-also","level":2,"title":"See Also","text":"
      • ctx trigger reference: full command, flag, and event-type reference.
      • ctx steering: persistent rules, not scripts. Use steering when the thing you want is \"tell the AI to always do X\" rather than \"run a script when Y happens.\"
      • Writing steering files: the rule-based equivalent of this recipe.
      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/troubleshooting/","level":1,"title":"Troubleshooting","text":"","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-problem","level":2,"title":"The Problem","text":"

      Something isn't working: a hook isn't firing, nudges are too noisy, context seems stale, or the agent isn't following instructions. The information to diagnose it exists (across status, drift, event logs, hook config, and session history), but assembling it manually is tedious.

      How do you figure out what's wrong and fix it?

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tldr","level":2,"title":"TL;DR","text":"
      ctx doctor                   # structural health check\nctx hook event --last 20  # recent hook activity\n# or ask: \"something seems off, can you diagnose?\"\n
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx doctor CLI command Structural health report ctx doctor --json CLI command Machine-readable health report ctx hook event CLI command Query local event log /ctx-doctor Skill Agent-driven diagnosis with analysis","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#quick-check-ctx-doctor","level":3,"title":"Quick Check: ctx doctor","text":"

      Run ctx doctor for an instant structural health report. It checks context initialization, required files, drift, hook configuration, event logging, webhooks, reminders, task completion ratio, and context token size: all in one pass:

      ctx doctor\n
      ctx doctor\n==========\n\nStructure\n  ✓ Context initialized (.context/)\n  ✓ Required files present (4/4)\n\nQuality\n  ⚠ Drift: 2 warnings (stale path in ARCHITECTURE.md, high entry count in LEARNINGS.md)\n\nHooks\n  ✓ hooks.json valid (14 hooks registered)\n  ○ Event logging disabled (enable with event_log: true in .ctxrc)\n\nState\n  ✓ No pending reminders\n  ⚠ Task completion ratio high (18/22 = 82%): consider archiving\n\nSize\n  ✓ Context size: ~4200 tokens (budget: 8000)\n\nSummary: 2 warnings, 0 errors\n

      Warnings are non-critical but worth fixing. Errors need attention. Informational notes (○) flag optional features that aren't enabled.

      For scripting:

      ctx doctor --json | jq '.warnings'\n
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#deep-dive-ctx-doctor","level":3,"title":"Deep Dive: /ctx-doctor","text":"

      When you need the agent to reason about what's wrong, use the skill. Ask naturally or invoke directly:

      Why didn't my hook fire?\nSomething seems off, can you diagnose?\n/ctx-doctor\n

      The agent follows a triage sequence:

      1. Baseline: runs ctx doctor --json for structural health
      2. Events: runs ctx hook event --json --last 100 (if event logging enabled)
      3. Correlate: connects findings across both sources
      4. Present: structured findings with evidence
      5. Suggest: actionable next steps (but doesn't auto-fix)

      The skill degrades gracefully: without event logging enabled, it still runs structural checks and notes what you'd gain by enabling it.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#raw-event-inspection","level":3,"title":"Raw Event Inspection","text":"

      For power users: ctx hook event with filters gives direct access to the event log.

      # Last 50 events (default)\nctx hook event\n\n# Events from a specific session\nctx hook event --session eb1dc9cd-0163-4853-89d0-785fbfaae3a6\n\n# Only QA reminder events\nctx hook event --hook qa-reminder\n\n# Raw JSONL for jq processing\nctx hook event --json | jq '.message'\n\n# Include rotated (older) events\nctx hook event --all --last 100\n

      Filters use AND logic: --hook qa-reminder --session abc123 returns only QA reminder events from that specific session.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#common-problems","level":2,"title":"Common Problems","text":"","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#no-context-directory-specified-for-this-project","level":3,"title":"\"No context directory specified for this project\"","text":"

      Symptoms: Any ctx command fails with Error: no context directory specified for this project (possibly with a likely-candidate hint or a candidate list depending on what's visible from your CWD).

      Cause: ctx does not search the filesystem for a .context/ directory. You have to declare which one to use before running day-to-day commands.

      Fix: bind CTX_DIR for the current shell:

      eval \"$(ctx activate)\"\n

      See Activating a Context Directory for the full recipe (one-shot CTX_DIR=... inline form, CI patterns, direnv setup).

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#ctx-not-initialized","level":3,"title":"\"ctx: Not Initialized\"","text":"

      Symptoms: After declaring CTX_DIR, the command fails with ctx: not initialized - run \"ctx init\" first.

      Cause: The declared directory exists but hasn't been initialized with template files.

      Fix:

      ctx init          # create .context/ with template files\nctx init --minimal  # or just the essentials (CONSTITUTION, TASKS, DECISIONS)\n

      Commands that work without CTX_DIR or initialization: ctx init, ctx activate, ctx deactivate, ctx setup, ctx doctor, ctx guide, ctx why, ctx config switch/status, ctx hub *, and help-only grouping commands.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#my-cli-and-my-claude-code-session-disagree-on-the-project","level":3,"title":"\"My CLI and My Claude Code Session Disagree on the Project\"","text":"

      Symptoms: A !-pragma or interactive ctx call writes to the wrong .context/; or you ran ctx remind add in shell A and the reminder shows up in project B's notifications.

      Cause: CTX_DIR is sourced from three different surfaces, and they can drift apart:

      Surface Source of CTX_DIR Bound when Claude Code hooks ${CLAUDE_PROJECT_DIR}/.context (injected) Every hook line; the project Claude is in !-pragma in chat / interactive shell Whatever the parent shell exported When you ran eval \"$(ctx activate)\" New shell tab opened mid-session Whatever your shellrc exports Login

      When these drift, the per-prompt check-anchor-drift hook fires a verbatim warning naming both values. To fix: re-run eval \"$(ctx activate)\" from inside the project the Claude Code session is editing, or close the shell tab and reopen it from the right working directory.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#my-hook-isnt-firing","level":3,"title":"\"My Hook Isn't Firing\"","text":"

      Symptoms: No nudges appearing, webhook silent, event log shows no entries for the expected hook.

      Diagnosis:

      # 1. Check if ctx is installed and on PATH\nwhich ctx && ctx --version\n\n# 2. Check if the hook is registered\ngrep \"check-persistence\" ~/.claude/plugins/ctx/hooks.json\n\n# 3. Run the hook manually to see if it errors\necho '{\"session_id\":\"test\"}' | ctx system check-persistence\n\n# 4. Check event log for the hook (if enabled)\nctx hook event --hook check-persistence\n

      Common causes:

      • Plugin is not installed: run ctx init --claude to reinstall
      • PATH issue: the hook invokes ctx from PATH; ensure it resolves
      • Throttle active: most hooks fire once per day: check .context/state/ for daily marker files
      • Hook silenced: a custom message override may be an empty file: check ctx hook message list for overrides
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#too-many-nudges","level":3,"title":"\"Too Many Nudges\"","text":"

      Symptoms: The agent is overwhelmed with hook output. Context checkpoints, persistence reminders, and QA gates fire constantly.

      Diagnosis:

      # Check how often hooks fired recently\nctx hook event --last 50\n\n# Count fires per hook\nctx hook event --json | jq -r '.detail.hook // \"unknown\"' \\\n  | sort | uniq -c | sort -rn\n

      Common causes:

      • QA reminder is noisy by design: it fires on every Edit call with no throttle. This is intentional. If it's too much, silence it with an empty override: ctx hook message edit qa-reminder gate, then empty the file
      • Long session: context checkpoint fires with increasing frequency after prompt 15. This is the system telling you the session is getting long: consider wrapping up
      • Short throttle window: if you deleted marker files in .context/state/, daily-throttled hooks will re-fire
      • Outdated Claude Code plugin: Update the plugin using Claude Code → /plugin → \"Marketplace\"
      • ctx version mismatch: Build (or download) and install the latest ctx vesion.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#context-seems-stale","level":3,"title":"\"Context Seems Stale\"","text":"

      Symptoms: The agent references outdated information, paths that don't exist, or decisions that were reversed.

      Diagnosis:

      # Structural drift check\nctx drift\n\n# Full doctor check (includes drift + more)\nctx doctor\n\n# Check when context files were last modified\nctx status --verbose\n

      Common causes:

      • Drift accumulated: stale path references in ARCHITECTURE.md or CONVENTIONS.md. Fix with ctx drift --fix or ask the agent to clean up.
      • Task backlog: too many completed tasks diluting active context. Archive with ctx task archive or ctx compact --archive.
      • Large context files: LEARNINGS.md with 40+ entries competes for attention. Consolidate with /ctx-consolidate.
      • Missing session ceremonies: if /ctx-remember and /ctx-wrap-up aren't being used, context doesn't get refreshed. See Session Ceremonies.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-agent-isnt-following-instructions","level":3,"title":"\"The Agent Isn't Following Instructions\"","text":"

      Symptoms: The agent ignores conventions, forgets decisions, or acts contrary to CONSTITUTION.md rules.

      Diagnosis:

      # Check context token size: Is it too large for the model?\nctx doctor --json | jq '.results[] | select(.name == \"context_size\")'\n\n# Check if context is actually being loaded\nctx hook event --hook context-load-gate\n

      Common causes:

      • Context too large: if total tokens exceed the model's effective attention, instructions get diluted. Check ctx doctor for the size check. Compact with ctx compact --archive.
      • Context not loading: if context-load-gate hasn't fired, the agent may not have received context. Verify the hook is registered.
      • Conflicting instructions: CONVENTIONS.md says one thing, AGENT_PLAYBOOK.md says another. Review both files for consistency.
      • Agent drift: the agent's behavior diverges from instructions over long sessions. This is normal. Use /ctx-reflect to re-anchor, or start a new session.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#prerequisites","level":2,"title":"Prerequisites","text":"
      • Event logging (optional but recommended): event_log: true in .ctxrc
      • ctx initialized: ctx init

      Event logging is not required for ctx doctor or /ctx-doctor to work. Both degrade gracefully: structural checks run regardless, and the skill notes when event data is unavailable.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tips","level":2,"title":"Tips","text":"
      • Start with ctx doctor: It's the fastest way to get a comprehensive health picture. Save event log inspection for when you need to understand when and how often something happened.
      • Enable event logging early: The log is opt-in and low-cost (~250 bytes per event, 1MB rotation cap). Enable it before you need it: Diagnosing a problem without historical data is much harder.
      • Use the skill for correlation: ctx doctor tells you what is wrong. /ctx-doctor tells you why by correlating structural findings with event patterns. The agent can spot connections that individual commands miss.
      • Event log is gitignored: It's machine-local diagnostic data, not project context. Different machines produce different event streams.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#next-up","level":2,"title":"Next Up","text":"

      Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#see-also","level":2,"title":"See Also","text":"
      • Auditing System Hooks: the complete hook catalog and webhook-based audit trails
      • Detecting and Fixing Drift: structural and semantic drift detection and repair
      • Webhook Notifications: push notifications for hook activity
      • ctx doctor CLI: full command reference
      • ctx hook event CLI: event log query reference
      • /ctx-doctor skill: agent-driven diagnosis
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/webhook-notifications/","level":1,"title":"Webhook Notifications","text":"","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#the-problem","level":2,"title":"The Problem","text":"

      Your agent runs autonomously (loops, implements, releases) while you are away from the terminal. You have no way to know when it finishes, hits a limit, or when a hook fires a nudge.

      How do you get notified about agent activity without watching the terminal?

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tldr","level":2,"title":"TL;DR","text":"
      ctx hook notify setup  # configure webhook URL (encrypted)\nctx hook notify test   # verify delivery\n# Hooks auto-notify on: session-end, loop-iteration, resource-danger\n
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx hook notify setup CLI command Configure and encrypt webhook URL ctx hook notify test CLI command Send a test notification ctx hook notify --event <name> \"msg\" CLI command Send a notification from scripts/skills .ctxrc notify.events Configuration Filter which events reach your webhook","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-1-get-a-webhook-url","level":3,"title":"Step 1: Get a Webhook URL","text":"

      Any service that accepts HTTP POST with JSON works. Common options:

      Service How to get a URL IFTTT Create an applet with the \"Webhooks\" trigger Slack Create an Incoming Webhook Discord Channel Settings > Integrations > Webhooks ntfy.sh Use https://ntfy.sh/your-topic (no signup) Pushover Use API endpoint with your user key

      The URL contains auth tokens. ctx encrypts it; it never appears in plaintext in your repo.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-2-configure-the-webhook","level":3,"title":"Step 2: Configure the Webhook","text":"
      ctx hook notify setup\n# Enter webhook URL: https://maker.ifttt.com/trigger/ctx/json/with/key/YOUR_KEY\n# Webhook configured: https://maker.ifttt.com/***\n# Encrypted at: .context/.notify.enc\n

      This encrypts the URL with AES-256-GCM using the same key as the scratchpad (~/.ctx/.ctx.key). The encrypted file (.context/.notify.enc) is safe to commit. The key lives outside the project and is never committed.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-3-test-it","level":3,"title":"Step 3: Test It","text":"
      ctx hook notify test\n# Webhook responded: HTTP 200 OK\n

      If you see No webhook configured, run ctx hook notify setup first.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-4-configure-events","level":3,"title":"Step 4: Configure Events","text":"

      Notifications are opt-in: no events are sent unless you configure an event list in .ctxrc:

      # .ctxrc\nnotify:\n  events:\n    - loop       # loop completion or max-iteration hit\n    - nudge      # VERBATIM relay hooks (context checkpoint, persistence, etc.)\n    - relay      # all hook output (verbose, for debugging)\n    - heartbeat  # every-prompt session-alive signal with metadata\n

      Only listed events fire. Omitting an event silently drops it.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-5-use-in-your-own-skills","level":3,"title":"Step 5: Use in Your Own Skills","text":"

      Add ctx hook notify calls to any skill or script:

      # In a release skill\nctx hook notify --event release \"v1.2.0 released successfully\" 2>/dev/null || true\n\n# In a backup script\nctx hook notify --event backup \"Nightly backup completed\" 2>/dev/null || true\n

      The 2>/dev/null || true suffix ensures the notification never breaks your script: If there's no webhook or the HTTP call fails, it's a silent noop.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#event-types","level":2,"title":"Event Types","text":"

      ctx fires these events automatically:

      Event Source When loop Loop script Loop completes or hits max iterations nudge System hooks VERBATIM relay nudge is emitted (context checkpoint, persistence, ceremonies, journal, resources, knowledge, version) relay System hooks Any hook output (VERBATIM relays, agent directives, block responses) heartbeat System hook Every prompt: session-alive signal with prompt count and context modification status test ctx hook notify test Manual test notification (custom) Your skills You wire ctx hook notify --event <name> in your own scripts

      nudge vs relay: The nudge event fires only for VERBATIM relay hooks (the ones the agent is instructed to show verbatim). The relay event fires for all hook output: VERBATIM relays, agent directives, and hard gates. Subscribe to relay for debugging (\"did the agent get the post-commit nudge?\"), nudge for user-facing assurance (\"was the checkpoint emitted?\").

      Webhooks as a Hook Audit Trail

      Subscribe to relay events and you get an external record of every hook that fires, independent of the agent.

      This lets you verify hooks are running and catch cases where the agent absorbs a nudge instead of surfacing it.

      See Auditing System Hooks for the full workflow.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#payload-format","level":2,"title":"Payload Format","text":"

      Every notification sends a JSON POST:

      {\n  \"event\": \"nudge\",\n  \"message\": \"check-context-size: Context window at 82%\",\n  \"detail\": {\n    \"hook\": \"check-context-size\",\n    \"variant\": \"window\",\n    \"variables\": {\"Percentage\": 82, \"TokenCount\": \"164k\"}\n  },\n  \"session_id\": \"abc123-...\",\n  \"timestamp\": \"2026-02-22T14:30:00Z\",\n  \"project\": \"ctx\"\n}\n

      The detail field is a structured template reference containing the hook name, variant, and any template variables. This lets receivers filter by hook or variant without parsing rendered text. The field is omitted when no template reference applies (e.g. custom ctx hook notify calls).

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#heartbeat-payload","level":3,"title":"Heartbeat Payload","text":"

      The heartbeat event fires on every prompt with session metadata and token usage telemetry:

      {\n  \"event\": \"heartbeat\",\n  \"message\": \"heartbeat: prompt #7 (context_modified=false tokens=158k pct=79%)\",\n  \"detail\": {\n    \"hook\": \"heartbeat\",\n    \"variant\": \"pulse\",\n    \"variables\": {\n      \"prompt_count\": 7,\n      \"session_id\": \"abc123-...\",\n      \"context_modified\": false,\n      \"tokens\": 158000,\n      \"context_window\": 200000,\n      \"usage_pct\": 79\n    }\n  },\n  \"session_id\": \"abc123-...\",\n  \"timestamp\": \"2026-02-28T10:15:00Z\",\n  \"project\": \"ctx\"\n}\n

      The tokens, context_window, and usage_pct fields are included when token data is available from the session JSONL file. They are omitted when no usage data has been recorded yet (e.g. first prompt).

      Unlike other events, heartbeat fires every prompt (not throttled). Use it for observability dashboards or liveness monitoring of long-running sessions.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#security-model","level":2,"title":"Security Model","text":"Component Location Committed? Permissions Encryption key ~/.ctx/.ctx.key No (user-level) 0600 Encrypted URL .context/.notify.enc Yes (safe) 0600 Webhook URL Never on disk in plaintext N/A N/A

      The key is shared with the scratchpad. If you rotate the encryption key, re-run ctx hook notify setup to re-encrypt the webhook URL with the new key.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#key-rotation","level":2,"title":"Key Rotation","text":"

      ctx checks the age of the encryption key once per day. If it's older than 90 days (configurable via key_rotation_days), a VERBATIM nudge is emitted suggesting rotation.

      # .ctxrc\nkey_rotation_days: 30   # nudge sooner (default: 90)\n
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#worktrees","level":2,"title":"Worktrees","text":"

      The webhook URL is encrypted with the same encryption key (~/.ctx/.ctx.key). Because the key lives at the user level, it is shared across all worktrees on the same machine - notifications work in worktrees automatically.

      This means agents running in worktrees cannot send webhook alerts. For autonomous runs where worktree agents are opaque, monitor them from the terminal rather than relying on webhooks. Enrich journals and review results on the main branch after merging.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#event-log-the-local-complement","level":2,"title":"Event Log: The Local Complement","text":"

      Don't need a webhook but want diagnostic visibility? Enable event_log: true in .ctxrc. The event log writes the same payload as webhooks to a local JSONL file (.context/state/events.jsonl) that you can query without any external service:

      ctx hook event --last 20          # recent hook activity\nctx hook event --hook qa-reminder # filter by hook\n

      Webhooks and event logging are independent: you can use either, both, or neither. Webhooks give you push notifications and an external audit trail. The event log gives you local queryability and ctx doctor integration.

      See Troubleshooting for how they work together.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tips","level":2,"title":"Tips","text":"
      • Fire-and-forget: Notifications never block. HTTP errors are silently ignored. No retry, no response parsing.
      • No webhook = no cost: When no webhook is configured, ctx hook notify exits immediately. System hooks that call notify.Send() add zero overhead.
      • Multiple projects: Each project has its own .notify.enc. You can point different projects at different webhooks.
      • Event filter is per-project: Configure notify.events in each project's .ctxrc independently.
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#next-up","level":2,"title":"Next Up","text":"

      Auditing System Hooks →: Verify your hooks are running, audit what they do, and get alerted when they go silent.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#see-also","level":2,"title":"See Also","text":"
      • CLI Reference: ctx hook notify: full command reference
      • Configuration: .ctxrc settings including notify options
      • Running an Unattended AI Agent: how loops work and how notifications fit in
      • Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates
      • Auditing System Hooks: using webhooks as an external audit trail for hook execution
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/","level":1,"title":"When to Use a Team of Agents","text":"","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-problem","level":2,"title":"The Problem","text":"

      You have a task, and you are wondering: \"should I throw more agents at it?\"

      More agents can mean faster results, but they also mean coordination overhead, merge conflicts, divergent mental models, and wasted tokens re-reading context.

      The wrong setup costs more than it saves.

      This recipe is a decision framework: It helps you choose between a single agent, parallel worktrees, and a full agent team, and explains what ctx provides at each level.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#tldr","level":2,"title":"TL;DR","text":"
      • Single agent for most work;
      • Parallel worktrees when tasks touch disjoint file sets;
      • Agent teams only when tasks need real-time coordination. When in doubt, start with one agent.
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-spectrum","level":2,"title":"The Spectrum","text":"

      There are three modes, ordered by complexity:

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#1-single-agent-default","level":3,"title":"1. Single Agent (Default)","text":"

      One agent, one session, one branch. This is correct for most work.

      Use this when:

      • The task has linear dependencies (step 2 needs step 1's output);
      • Changes touch overlapping files;
      • You need tight feedback loops (review each change before the next);
      • The task requires deep understanding of a single area;
      • Total effort is less than a few hours of agent time.

      ctx provides: Full .context/: tasks, decisions, learnings, conventions, all in one session.

      The agent builds a coherent mental model and persists it as it goes.

      Example tasks: Bug fixes, feature implementation, refactoring a module, writing documentation for one area, debugging.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#2-parallel-worktrees-independent-tracks","level":3,"title":"2. Parallel Worktrees (Independent Tracks)","text":"

      2-4 agents, each in a separate git worktree on its own branch, working on non-overlapping parts of the codebase.

      Use this when:

      • You have 5+ independent tasks in the backlog;
      • Tasks group cleanly by directory or package;
      • File overlap between groups is zero or near-zero;
      • Each track can be completed and merged independently;
      • You want parallelism without coordination complexity.

      ctx provides: Shared .context/ via git (each worktree sees the same tasks, decisions, conventions). /ctx-worktree skill for setup and teardown. TASKS.md as a lightweight work queue.

      Example tasks: Docs + new package + test coverage (three tracks that don't touch the same files). Parallel recipe writing. Independent module development.

      See: Parallel Agent Development with Git Worktrees

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#3-agent-team-coordinated-swarm","level":3,"title":"3. Agent Team (Coordinated Swarm)","text":"

      Multiple agents communicating via messages, sharing a task list, with a lead agent coordinating. Claude Code's team/swarm feature.

      Use this when:

      • Tasks have dependencies but can still partially overlap;
      • You need research and implementation happening simultaneously;
      • The work requires different roles (researcher, implementer, tester);
      • A lead agent needs to review and integrate others' work;
      • The task is large enough that coordination cost is justified.

      ctx provides: .context/ as shared state that all agents can read. Task tracking for work assignment. Decisions and learnings as team memory that survives individual agent turnover.

      Example tasks: Large refactor across modules where a lead reviews merges. Research and implementation where one agent explores options while another builds. Multi-file feature that needs integration testing after parallel implementation.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-decision-framework","level":2,"title":"The Decision Framework","text":"

      Ask these questions in order:

      Can one agent do this in a reasonable time?\n  YES → Single agent. Stop here.\n  NO  ↓\n\nCan the work be split into non-overlapping file sets?\n  YES → Parallel worktrees (2-4 tracks)\n  NO  ↓\n\nDo the subtasks need to communicate during execution?\n  YES → Agent team with lead coordination\n  NO  → Parallel worktrees with a merge step\n
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-file-overlap-test","level":3,"title":"The File Overlap Test","text":"

      This is the critical decision point. Before choosing multi-agent, list the files each subtask would touch. If two subtasks modify the same file, they belong in the same track (or the same single-agent session).

      You: \"I want to parallelize these tasks. Which files would each one touch?\"\n\nAgent: [reads `TASKS.md`, analyzes codebase]\n       \"Task A touches internal/config/ and internal/cli/initialize/\n        Task B touches docs/ and site/\n        Task C touches internal/config/ and internal/cli/status/\n\n        Tasks A and C overlap on internal/config/ # they should be\n        in the same track. Task B is independent.\"\n

      When in doubt, keep things in one track. A merge conflict in a critical file costs more time than the parallelism saves.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#when-teams-make-things-worse","level":2,"title":"When Teams Make Things Worse","text":"

      \"More agents\" is not always better. Watch for these patterns:

      Merge hell: If you are spending more time resolving conflicts than the parallel work saved, you split wrong: Re-group by file overlap.

      Context divergence: Each agent builds its own mental model. After 30 minutes of independent work, agent A might make assumptions that contradict agent B's approach. Shorter tracks with frequent merges reduce this.

      Coordination theater: A lead agent spending most of its time assigning tasks, checking status, and sending messages instead of doing work. If the task list is clear enough, worktrees with no communication are cheaper.

      Re-reading overhead: Every agent reads .context/ on startup. A team of 4 agents each reading 4000 tokens of context = 16000 tokens before anyone does any work. For small tasks, that overhead dominates.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#what-ctx-gives-you-at-each-level","level":2,"title":"What ctx Gives You at Each Level","text":"ctx Feature Single Agent Worktrees Team .context/ files Full access Shared via git Shared via filesystem TASKS.md Work queue Split by track Assigned by lead Decisions/Learnings Persisted in session Persisted per branch Persisted by any agent /ctx-next Picks next task Picks within track Lead assigns /ctx-worktree N/A Setup + teardown Optional /ctx-commit Normal commits Per-branch commits Per-agent commits","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#team-composition-recipes","level":2,"title":"Team Composition Recipes","text":"

      Four practical team compositions for common workflows.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#feature-development-3-agents","level":3,"title":"Feature Development (3 Agents)","text":"Role Responsibility Architect Writes spec in specs/, breaks work into TASKS.md phases Implementer Picks tasks from TASKS.md, writes code, marks [x] done Reviewer Runs tests, ctx drift, lint; files issues as new tasks

      Coordination: TASKS.md checkboxes. Architect writes tasks before implementer starts. Reviewer runs after each implementer commit.

      Anti-pattern: All three agents editing the same file simultaneously. Sequence the work so only one agent touches a file at a time.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#consolidation-sprint-3-4-agents","level":3,"title":"Consolidation Sprint (3-4 Agents)","text":"Role Responsibility Auditor Runs ctx drift, identifies stale paths and broken refs Code Fixer Updates source code to match context (or vice versa) Doc Writer Updates ARCHITECTURE.md, CONVENTIONS.md, and docs/ Test Fixer (Optional) Fixes tests broken by the fixer's changes

      Coordination: Auditor's ctx drift output is the shared work queue. Each agent claims a subset of issues by adding #in-progress labels.

      Anti-pattern: Fixer and doc writer both editing ARCHITECTURE.md. Assign file ownership explicitly.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#release-prep-2-agents","level":3,"title":"Release Prep (2 Agents)","text":"Role Responsibility Release Notes Generates changelog from commits, writes release notes Validation Runs full test suite, lint, build across platforms

      Coordination: Both read TASKS.md to identify what shipped. Release notes agent works from git log; validation agent works from make audit.

      Anti-pattern: Release notes agent running tests \"to verify.\" Each agent stays in its lane.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#documentation-sprint-3-agents","level":3,"title":"Documentation Sprint (3 Agents)","text":"Role Responsibility Content Writes new pages, expands existing docs Cross-linker Adds nav entries, cross-references, \"See Also\" sections Verifier Builds site, checks broken links, validates rendering

      Coordination: Content agent writes files first. Cross-linker updates zensical.toml and index pages after content lands. Verifier builds after each batch.

      Antipattern: Content and cross-linker both editing zensical.toml. Batch nav updates into the cross-linker's pass.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#tips","level":2,"title":"Tips","text":"
      • Start with one agent: Only add parallelism when you have identified the bottleneck. \"This would go faster with more agents\" is usually wrong for tasks under 2 hours.
      • The 3-4 agent ceiling is real: Coordination overhead grows quadratically. 2 agents = 1 communication pair. 4 agents = 6 pairs. Beyond 4, you are managing agents more than doing work.
      • Worktrees > teams for most parallelism needs: If agents don't need to talk to each other during execution, worktrees give you parallelism with zero coordination overhead.
      • Use ctx as the shared brain: Whether it's one agent or four, the .context/ directory is the single source of truth. Decisions go in DECISIONS.md, not in chat messages between agents.
      • Merge early, merge often: Long-lived parallel branches diverge. Merge a track as soon as it's done rather than waiting for all tracks to finish.
      • TASKS.md conflicts are normal: Multiple agents completing different tasks will conflict on merge. The resolution is always additive: accept all [x] completions from both sides.
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#next-up","level":2,"title":"Next Up","text":"

      Parallel Agent Development with Git Worktrees →: Run multiple agents on independent task tracks using git worktrees.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#go-deeper","level":2,"title":"Go Deeper","text":"
      • CLI Reference: all commands and flags
      • Integrations: setup for Claude Code, Cursor, Aider
      • Session Journal: browse and search session history
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#see-also","level":2,"title":"See Also","text":"
      • Parallel Agent Development with Git Worktrees: the mechanical \"how\" for worktree-based parallelism
      • Running an Unattended AI Agent: serial autonomous loops: a different scaling strategy
      • Tracking Work Across Sessions: managing the task backlog that feeds into any multi-agent setup
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"reference/","level":1,"title":"Reference","text":"

      Technical reference for ctx commands, skills, and internals.

      ","path":["Reference"],"tags":[]},{"location":"reference/#the-system-explains-itself","level":3,"title":"The System Explains Itself","text":"

      The 12 properties that must hold for any valid ctx implementation. Not features: constraints. The system's contract with its users and contributors.

      ","path":["Reference"],"tags":[]},{"location":"reference/#code-conventions","level":3,"title":"Code Conventions","text":"

      Common patterns and fixes for the AST compliance tests in internal/audit/. When a test fails, find the matching section.

      ","path":["Reference"],"tags":[]},{"location":"reference/#cli","level":3,"title":"CLI","text":"

      Every command, subcommand, and flag. Now a top-level section: see CLI Reference.

      ","path":["Reference"],"tags":[]},{"location":"reference/#skills","level":3,"title":"Skills","text":"

      The full skill catalog: what each skill does, when it triggers, and how skills interact with commands.

      ","path":["Reference"],"tags":[]},{"location":"reference/#tool-ecosystem","level":3,"title":"Tool Ecosystem","text":"

      How ctx compares to Cursor Rules, Aider conventions, CLAUDE.md, and other context approaches.

      ","path":["Reference"],"tags":[]},{"location":"reference/#session-journal","level":3,"title":"Session Journal","text":"

      Export, browse, and enrich your session history. Covers the journal site, Obsidian export, and the enrichment pipeline.

      ","path":["Reference"],"tags":[]},{"location":"reference/#scratchpad","level":3,"title":"Scratchpad","text":"

      Encrypted, git-tracked scratch space for short notes and sensitive values that travel with the project.

      ","path":["Reference"],"tags":[]},{"location":"reference/#version-history","level":3,"title":"Version History","text":"

      Changelog for every ctx release.

      ","path":["Reference"],"tags":[]},{"location":"reference/audit-conventions/","level":1,"title":"Code Conventions","text":"","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#code-conventions-common-patterns-and-fixes","level":1,"title":"Code Conventions: Common Patterns and Fixes","text":"

      This guide documents the code conventions enforced by internal/audit/ AST tests. Each section shows the violation pattern, the fix, and the rationale. When a test fails, find the matching section below.

      All tests skip _test.go files. The patterns apply only to production code under internal/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#variable-shadowing-bare-err-reuse","level":2,"title":"Variable Shadowing (Bare err := Reuse)","text":"

      Test: TestNoVariableShadowing

      When a function has multiple := assignments to err, each shadows the previous one. This makes it impossible to tell which error a later if err != nil is checking.

      Before:

      func Run(cmd *cobra.Command) error {\n    data, err := os.ReadFile(path) \n    if err != nil {\n        return err\n    }\n\n    result, err := json.Unmarshal(data)  // shadows first err\n    if err != nil {\n        return err\n    }\n\n    err = validate(result)  // shadows again\n    return err\n}\n

      After:

      func Run(cmd *cobra.Command) error {\n    data, readErr := os.ReadFile(path)\n    if readErr != nil {\n        return readErr\n    }\n\n    result, parseErr := json.Unmarshal(data)\n    if parseErr != nil {\n        return parseErr\n    }\n\n    validateErr := validate(result)\n    return validateErr\n}\n

      Rule: Use descriptive error names (readErr, writeErr, parseErr, walkErr, absErr, relErr) so each error site is independently identifiable.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#import-name-shadowing","level":2,"title":"Import Name Shadowing","text":"

      Test: TestNoImportNameShadowing

      When a local variable has the same name as an imported package, the import becomes inaccessible in that scope.

      Before:

      import \"github.com/ActiveMemory/ctx/internal/session\"\n\nfunc process(session *entity.Session) {  // param shadows import\n    // session package is now unreachable here\n}\n

      After:

      import \"github.com/ActiveMemory/ctx/internal/session\"\n\nfunc process(sess *entity.Session) {\n    // session package still accessible\n}\n

      Rule: Parameters, variables, and return values must not reuse imported package names. Common renames: session -> sess, token -> tok, config -> cfg, entry -> ent.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-strings","level":2,"title":"Magic Strings","text":"

      Test: TestNoMagicStrings

      String literals in function bodies are invisible to refactoring tools and cause silent breakage when the value changes in one place but not another.

      Before (string literals):

      func loadContext() {\n    data := filepath.Join(dir, \"TASKS.md\")\n    if strings.HasSuffix(name, \".yaml\") {\n        // ...\n    }\n}\n

      After:

      func loadContext() {\n    data := filepath.Join(dir, config.FilenameTask)\n    if strings.HasSuffix(name, config.ExtYAML) {\n        // ...\n    }\n}\n

      Before (format verbs, also caught):

      func EntryHash(text string) string {\n    h := sha256.Sum256([]byte(text))\n    return fmt.Sprintf(\"%x\", h[:8])\n}\n

      After:

      func EntryHash(text string) string {\n    h := sha256.Sum256([]byte(text))\n    return hex.EncodeToString(h[:cfgFmt.HashPrefixLen])\n}\n

      Before (URL schemes, also caught):

      if strings.HasPrefix(target, \"https://\") ||\n    strings.HasPrefix(target, \"http://\") {\n    return target\n}\n

      After:

      if strings.HasPrefix(target, cfgHTTP.PrefixHTTPS) ||\n    strings.HasPrefix(target, cfgHTTP.PrefixHTTP) {\n    return target\n}\n

      Exempt from this check:

      • Empty string \"\", single space \" \", indentation strings
      • Regex capture references ($1, ${name})
      • const and var definition sites (that's where constants live)
      • Struct tags
      • Import paths
      • Packages under internal/config/, internal/assets/tpl/

      Rule: If a string is used for comparison, path construction, or appears in 3+ files, it belongs in internal/config/ as a constant. Format strings belong in internal/config/ as named constants (e.g., cfgGit.FlagLastN, cfgTrace.RefFormat). User-facing prose belongs in internal/assets/ YAML files accessed via desc.Text().

      Common fix for fmt.Sprintf with format verbs:

      Pattern Fix fmt.Sprintf(\"%d\", n) strconv.Itoa(n) fmt.Sprintf(\"%d\", int64Val) strconv.FormatInt(int64Val, 10) fmt.Sprintf(\"%x\", bytes) hex.EncodeToString(bytes) fmt.Sprintf(\"%q\", s) strconv.Quote(s) fmt.Sscanf(s, \"%d\", &n) strconv.Atoi(s) fmt.Sprintf(\"-%d\", n) fmt.Sprintf(cfgGit.FlagLastN, n) \"https://\" cfgHTTP.PrefixHTTPS \"&lt;\" config constant in config/html/","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-printf-calls","level":2,"title":"Direct Printf Calls","text":"

      Test: TestNoPrintfCalls

      cmd.Printf and cmd.PrintErrf bypass the write-package formatting pipeline and scatter user-facing text across the codebase.

      Before:

      func Run(cmd *cobra.Command, args []string) {\n    cmd.Printf(\"Found %d tasks\\n\", count)\n}\n

      After:

      func Run(cmd *cobra.Command, args []string) {\n    write.TaskCount(cmd, count)\n}\n

      Rule: All formatted output goes through internal/write/ which uses cmd.Print/cmd.Println with pre-formatted strings from desc.Text().

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#raw-time-format-strings","level":2,"title":"Raw Time Format Strings","text":"

      Test: TestNoRawTimeFormats

      Inline time format strings (\"2006-01-02\", \"15:04:05\") drift when one call site is updated but others are missed.

      Before:

      func formatDate(t time.Time) string {\n    return t.Format(\"2006-01-02\")\n}\n

      After:

      func formatDate(t time.Time) string {\n    return t.Format(cfgTime.DateFormat)\n}\n

      Rule: All time format strings must use constants from internal/config/time/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-flag-registration","level":2,"title":"Direct Flag Registration","text":"

      Test: TestNoFlagBindOutsideFlagbind

      Direct cobra flag calls (.Flags().StringVar(), etc.) scatter flag wiring across dozens of cmd.go files. Centralizing through internal/flagbind/ gives one place to audit flag names, defaults, and description key lookups.

      Before:

      func Cmd() *cobra.Command {\n    var output string\n    c := &cobra.Command{Use: cmd.UseStatus}\n    c.Flags().StringVarP(&output, \"output\", \"o\", \"\",\n        \"output format\")\n    return c\n}\n

      After:

      func Cmd() *cobra.Command {\n    var output string\n    c := &cobra.Command{Use: cmd.UseStatus}\n    flagbind.StringFlagShort(c, &output, flag.Output,\n        flag.OutputShort, cmd.DescKeyOutput)\n    return c\n}\n

      Rule: All flag registration goes through internal/flagbind/. If the helper you need doesn't exist, add it to flagbind/flag.go before using it.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#todo-comments","level":2,"title":"TODO Comments","text":"

      Test: TestNoTODOComments

      TODO, FIXME, HACK, and XXX comments in production code are invisible to project tracking. They accumulate silently and never get addressed.

      Before:

      // TODO: handle pagination\nfunc listEntries() []Entry {\n

      After:

      Remove the comment and add a task to .context/TASKS.md:

      - [ ] Handle pagination in listEntries (internal/task/task.go)\n

      Rule: Deferred work lives in TASKS.md, not in source comments.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#dead-exports","level":2,"title":"Dead Exports","text":"

      Test: TestNoDeadExports

      Exported symbols with zero references outside their definition file are dead weight. They increase API surface, confuse contributors, and cost maintenance.

      Fix: Either delete the export (preferred) or demote it to unexported if it's still used within the file.

      If the symbol existed for historical reasons and might be needed again, move it to quarantine/deadcode/ with a .dead extension. This preserves the code in git without polluting the live codebase:

      quarantine/deadcode/internal/config/flag/flag.go.dead\n

      Each .dead file includes a header:

      // Dead exports quarantined from internal/config/flag/flag.go\n// Quarantined: 2026-04-02\n// Restore from git history if needed.\n

      Rule: If a test-only allowlist entry is needed (the export exists only for test use), add the fully qualified symbol to testOnlyExports in dead_exports_test.go. Keep this list small; prefer eliminating the export.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#core-package-structure","level":2,"title":"Core Package Structure","text":"

      Test: TestCoreStructure

      core/ directories under internal/cli/ must contain only doc.go and test files at the top level. All domain logic lives in subpackages. This prevents core/ from becoming a god package.

      Before:

      internal/cli/dep/core/\n    go.go           # violation: logic at core/ level\n    python.go       # violation\n    node.go         # violation\n    types.go        # violation\n

      After:

      internal/cli/dep/core/\n    doc.go          # package doc only\n    golang/\n        golang.go\n        golang_test.go\n        doc.go\n    python/\n        python.go\n        python_test.go\n        doc.go\n    node/\n        node.go\n        node_test.go\n        doc.go\n

      Rule: Extract each logical unit into its own subpackage under core/. Each subpackage gets a doc.go. The subpackage name should match the domain concept (golang, check, fix, store), not a generic label (util, helper).

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cross-package-types","level":2,"title":"Cross-Package Types","text":"

      Test: TestCrossPackageTypes

      When a type defined in one package is used from a different module (e.g., cli/doctor importing a type from cli/notify), the type has crossed its module boundary. Cross-cutting types belong in internal/entity/ for discoverability.

      Before:

      // internal/cli/notify/core/types.go\ntype NotifyPayload struct { ... }\n\n// internal/cli/doctor/core/check/check.go\nimport \"github.com/ActiveMemory/ctx/internal/cli/notify/core\"\nfunc check(p core.NotifyPayload) { ... }\n

      After:

      // internal/entity/notify.go\ntype NotifyPayload struct { ... }\n\n// internal/cli/doctor/core/check/check.go\nimport \"github.com/ActiveMemory/ctx/internal/entity\"\nfunc check(p entity.NotifyPayload) { ... }\n

      Exempt: Types inside entity/, proto/, core/ subpackages, and config/ packages. Same-module usage (e.g., cli/doctor/cmd/ using cli/doctor/core/) is not flagged.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#type-file-convention","level":2,"title":"Type File Convention","text":"

      Test: TestTypeFileConvention, TestTypeFileConventionReport

      Exported types in core/ subpackages should live in types.go (the convention from CONVENTIONS.md), not scattered across implementation files. This makes type definitions discoverable. TestTypeFileConventionReport generates a diagnostic summary of all type placements for triage.

      Exception: entity/ organizes by domain (task.go, session.go), proto/ uses schema.go, and err/ packages colocate error types with their domain context.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-yaml-linkage","level":2,"title":"DescKey / YAML Linkage","text":"

      Test: TestDescKeyYAMLLinkage

      Every DescKey constant must have a corresponding key in the YAML asset files, and every YAML key must have a corresponding DescKey constant. Orphans in either direction mean dead text or runtime panics.

      Fix for orphan YAML key: Delete the YAML entry, or add the corresponding DescKey constant in config/embed/{text,cmd,flag}/.

      Fix for orphan DescKey: Delete the constant, or add the corresponding entry in the YAML file under internal/assets/commands/text/, cmd/, or flag/.

      If the orphan YAML entry was once valid but the feature was removed, move the YAML entry to a .dead file in quarantine/deadcode/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#package-doc-quality","level":2,"title":"Package Doc Quality","text":"

      Test: TestPackageDocQuality

      Every package under internal/ must have a doc.go with a meaningful package doc comment (at least 8 lines of real content). One-liners and file-list patterns (// - foo.go, // Source files:) are flagged because they drift as files change.

      Template:

      //   /    ctx:                         https://ctx.ist\n// ,'`./    do you remember?\n// `.,'\\\n//   \\    Copyright 2026-present Context contributors.\n//                 SPDX-License-Identifier: Apache-2.0\n\n// Package mypackage does X.\n//\n// It handles Y by doing Z. The main entry point is [FunctionName]\n// which accepts A and returns B.\n//\n// Configuration is read from [config.SomeConstant]. Output is\n// written through [write.SomeHelper].\n//\n// This package is used by [parentpackage] during the W lifecycle\n// phase.\npackage mypackage\n
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-regex-compilation","level":2,"title":"Inline Regex Compilation","text":"

      Test: TestNoInlineRegexpCompile

      regexp.MustCompile and regexp.Compile inside function bodies recompile the pattern on every call. Compiled patterns belong at package level.

      Before:

      func parse(s string) bool {\n    re := regexp.MustCompile(`\\d{4}-\\d{2}-\\d{2}`)\n    return re.MatchString(s)\n}\n

      After:

      // In internal/config/regex/regex.go:\n// DatePattern matches ISO date format (YYYY-MM-DD).\nvar DatePattern = regexp.MustCompile(`\\d{4}-\\d{2}-\\d{2}`)\n\n// In calling package:\nfunc parse(s string) bool {\n    return regex.DatePattern.MatchString(s)\n}\n

      Rule: All compiled regexes live in internal/config/regex/ as package-level var declarations. Two tests enforce this: TestNoInlineRegexpCompile catches function-body compilation, and TestNoRegexpOutsideRegexPkg catches package-level compilation outside config/regex/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#doc-comments","level":2,"title":"Doc Comments","text":"

      Test: TestDocComments

      All functions (exported and unexported), structs, and package-level variables must have a doc comment. Config packages allow group doc comments for const blocks.

      Before:

      func buildIndex(entries []Entry) map[string]int {\n

      After:

      // buildIndex maps entry names to their position in the\n// ordered slice for O(1) lookup during reconciliation.\n//\n// Parameters:\n//   - entries: ordered slice of entries to index\n//\n// Returns:\n//   - map[string]int: name-to-position mapping\nfunc buildIndex(entries []Entry) map[string]int {\n

      Rule: Every function, struct, and package-level var gets a doc comment in godoc format. Functions include Parameters: and Returns: sections. Structs with 2+ fields document every field. See CONVENTIONS.md for the full template.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#line-length","level":2,"title":"Line Length","text":"

      Test: TestLineLength

      Lines in non-test Go files must not exceed 80 characters. This is a hard check, not a suggestion.

      Before:

      _ = trace.Record(fmt.Sprintf(cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum), state.Dir())\n

      After:

      ref := fmt.Sprintf(\n    cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum,\n)\n_ = trace.Record(ref, state.Dir())\n

      Rule: Break at natural points: function arguments, struct fields, chained calls. Long strings (URLs, struct tags) are the rare acceptable exception.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#literal-whitespace","level":2,"title":"Literal Whitespace","text":"

      Test: TestNoLiteralWhitespace

      Bare whitespace string and byte literals (\"\\n\", \"\\r\\n\", \"\\t\") must not appear outside internal/config/token/. All other packages use the token constants.

      Before:

      output := strings.Join(lines, \"\\n\")\n

      After:

      output := strings.Join(lines, token.Newline)\n

      Rule: Whitespace literals are defined once in internal/config/token/. Use token.Newline, token.Tab, token.CRLF, etc.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-numeric-values","level":2,"title":"Magic Numeric Values","text":"

      Test: TestNoMagicValues

      Numeric literals in function bodies need constants, with narrow exceptions.

      Before:

      if len(entries) > 100 {\n    entries = entries[:100]\n}\n

      After:

      if len(entries) > config.MaxEntries {\n    entries = entries[:config.MaxEntries]\n}\n

      Exempt: 0, 1, -1, 2-10, strconv radix/bitsize args (10, 32, 64 in strconv.Parse*/Format*), octal permissions (caught separately by TestNoRawPermissions), and const/var definition sites.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-separators","level":2,"title":"Inline Separators","text":"

      Test: TestNoInlineSeparators

      strings.Join calls must use token constants for their separator argument, not string literals.

      Before:

      result := strings.Join(parts, \", \")\n

      After:

      result := strings.Join(parts, token.CommaSep)\n

      Rule: Separator strings live in internal/config/token/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stuttery-function-names","level":2,"title":"Stuttery Function Names","text":"

      Test: TestNoStutteryFunctions

      Function names must not redundantly include their package name as a PascalCase word boundary. Go callers already write pkg.Function, so pkg.PkgFunction stutters.

      Before:

      // In package write\nfunc WriteJournal(cmd *cobra.Command, ...) {\n

      After:

      // In package write\nfunc Journal(cmd *cobra.Command, ...) {\n

      Exempt: Identity functions like write.Write / write.write.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#predicate-naming-no-ishascan-prefix","level":2,"title":"Predicate Naming (No Is/Has/Can Prefix)","text":"

      Test: None (manual review convention)

      Exported methods that return bool must not use Is, Has, or Can prefixes. The predicate reads more naturally without them, especially at call sites where the package name provides context.

      Before:

      func IsCompleted(t *Task) bool { ... }\nfunc HasChildren(n *Node) bool { ... }\nfunc IsExemptPackage(path string) bool { ... }\n

      After:

      func Completed(t *Task) bool { ... }\nfunc Children(n *Node) bool { ... }  // or: ChildCount > 0\nfunc ExemptPackage(path string) bool { ... }\n

      Rule: Drop the prefix. Private helpers may use prefixes when it reads more naturally (isValid in a local context is fine). This convention applies to exported methods and package-level functions. See CONVENTIONS.md \"Predicates\" section.

      This is not yet enforced by an AST test; it requires semantic understanding of return types and naming intent that makes automated detection fragile. Apply during code review.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#mixed-visibility","level":2,"title":"Mixed Visibility","text":"

      Test: TestNoMixedVisibility

      Files with exported functions must not also contain unexported functions. Public API and private helpers live in separate files.

      Before:

      load.go\n    func Load() { ... }        // exported\n    func parseHeader() { ... } // unexported, violation\n

      After:

      load.go\n    func Load() { ... }        // exported only\nparse.go\n    func parseHeader() { ... } // private helper\n

      Exempt: Files with exactly one function, doc.go, test files.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stray-errgo-files","level":2,"title":"Stray Err.Go Files","text":"

      Test: TestNoStrayErrFiles

      err.go files must only exist under internal/err/. Error constructors anywhere else create a broken-window pattern where contributors add local error definitions when they see a local err.go.

      Fix: Move the error constructor to internal/err/<domain>/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cli-cmd-structure","level":2,"title":"CLI Cmd Structure","text":"

      Test: TestCLICmdStructure

      Each cmd/$sub/ directory under internal/cli/ may contain only cmd.go, run.go, doc.go, and test files. Extra .go files (helpers, output formatters, types) belong in the corresponding core/ subpackage.

      Before:

      internal/cli/doctor/cmd/root/\n    cmd.go\n    run.go\n    format.go   # violation: helper in cmd dir\n

      After:

      internal/cli/doctor/cmd/root/\n    cmd.go\n    run.go\ninternal/cli/doctor/core/format/\n    format.go\n    doc.go\n
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-namespace","level":2,"title":"DescKey Namespace","text":"

      Test: TestUseConstantsOnlyInCobraUse, TestDescKeyOnlyInLookupCalls, TestNoWrongNamespaceLookup

      Three tests enforce DescKey/Use constant discipline:

      1. Use* constants appear only in cobra Use: struct field assignments, never as arguments to desc.Text() or elsewhere.
      2. DescKey* constants are passed only to assets.CommandDesc(), assets.FlagDesc(), or desc.Text(), never to cobra Use:.
      3. No cross-namespace lookups: TextDescKey must not be passed to CommandDesc(), FlagDescKey must not be passed to Text(), etc.
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#yaml-examples-registry-linkage","level":2,"title":"YAML Examples / Registry Linkage","text":"

      Test: TestExamplesYAMLLinkage, TestRegistryYAMLLinkage

      Every key in examples.yaml and registry.yaml must match a known entry type constant. Prevents orphan entries that are never rendered.

      Fix: Delete the orphan YAML entry, or add the corresponding constant in config/entry/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#other-enforced-patterns","level":2,"title":"Other Enforced Patterns","text":"

      These tests follow the same fix approach: extract the operation to its designated package:

      Test Violation Fix TestNoNakedErrors fmt.Errorf/errors.New outside internal/err/ Add error constructor to internal/err/<domain>/ TestNoRawFileIO Direct os.ReadFile, os.Create, etc. Use io.SafeReadFile, io.SafeWriteFile, etc. TestNoRawLogging Direct fmt.Fprintf(os.Stderr, ...) Use log/warn.Warn() or log/event.Append() TestNoExecOutsideExecPkg exec.Command outside internal/exec/ Add command to internal/exec/<domain>/ TestNoCmdPrintOutsideWrite cmd.Print* outside internal/write/ Add output helper to internal/write/<domain>/ TestNoRawPermissions Octal literals (0644, 0755) Use config/fs.PermFile, config/fs.PermExec, etc. TestNoErrorsAs errors.As() Use errors.AsType() (generic, Go 1.23+) TestNoStringConcatPaths dir + \"/\" + file Use filepath.Join(dir, file)","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#general-fix-workflow","level":2,"title":"General Fix Workflow","text":"

      When an audit test fails:

      1. Read the error message. It includes file:line and a description of the violation.
      2. Find the matching section above. The test name maps directly to a section.
      3. Apply the pattern. Most fixes are mechanical: extract to the right package, rename a variable, or replace a literal with a constant.
      4. Run make test before committing. Audit tests run as part of go test ./internal/audit/.
      5. Don't add allowlist entries as a first resort. Fix the code. Allowlists exist only for genuinely unfixable cases (test-only exports, config packages that are definitionally exempt).
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/comparison/","level":1,"title":"Tool Ecosystem","text":"","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#high-level-mental-model","level":2,"title":"High-Level Mental Model","text":"

      Many tools help AI think.

      ctx helps AI remember.

      • Not by storing thoughts,
      • but by preserving intent.
      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#how-ctx-differs-from-similar-tools","level":2,"title":"How ctx Differs from Similar Tools","text":"

      There are many tools in the AI ecosystem that touch parts of the context problem:

      • Some manage prompts.
      • Some retrieve data.
      • Some provide runtime context objects.
      • Some offer enterprise platforms.

      ctx focuses on a different layer entirely.

      This page explains where ctx fits, and where it intentionally does not.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#the-core-distinction","level":2,"title":"The Core Distinction","text":"

      Most tools treat context as input.

      ctx treats context as infrastructure.

      That single difference explains nearly all of ctx's design choices.

      Question Most tools ctx Where does context live? In prompts or APIs In files How long does it last? One request / one session Across time Who can read it? The model Humans and tools How is it updated? Implicitly Explicitly Is it inspectable? Rarely Always","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#prompt-management-tools","level":2,"title":"Prompt Management Tools","text":"

      Examples include:

      • prompt templates;
      • reusable system prompts;
      • prompt libraries;
      • prompt versioning tools.

      These tools help you start a session.

      They do not help you continue one.

      Prompt tools:

      • inject text at session start;
      • are ephemeral by design;
      • do not evolve with the project.

      ctx:

      • persists knowledge over time;
      • accumulates decisions and learnings;
      • makes the context part of the repository itself.

      Prompt tooling and ctx are complementary; not competing. Yet, they operate in different layers.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#retrieval-augmented-generation-rag","level":2,"title":"Retrieval-Augmented Generation (RAG)","text":"

      RAG systems typically:

      • index documents
      • embed text
      • retrieve chunks dynamically at runtime

      They are excellent for:

      • large knowledge bases
      • static documentation
      • reference material

      RAG answers questions like:

      \"What information might be relevant right now?\"

      ctx answers a different question:

      \"What have we already decided, learned, or committed to?\"

      Here are some key differences:

      RAG ctx Statistical relevance Intentional relevance Embedding-based File-based Opaque retrieval Explicit structure Runtime query Persistent memory

      ctx does not replace RAG. Instead, it defines a persistent context layer that RAG can optionally augment.

      RAG belongs to the data plane; ctx defines the context control plane.

      It focuses on project memory, not knowledge search.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#agent-frameworks","level":2,"title":"Agent Frameworks","text":"

      Agent frameworks often provide:

      • task loops
      • tool orchestration
      • planner/executor patterns
      • autonomous iteration

      These systems are powerful, but they typically assume that:

      • memory is external
      • context is injected
      • state is transient

      Agent frameworks answer:

      \"How should the agent act?\"

      ctx answers:

      \"What should the agent remember?\"

      Without persistent context, agents tend to:

      • rediscover decisions
      • repeat mistakes
      • lose architectural intent

      This is why ctx pairs well with autonomous loop workflows:

      • The loop provides iteration
      • ctx provides continuity

      Together, loops become cumulative instead of forgetful.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#sdk-level-context-objects","level":2,"title":"SDK-Level Context Objects","text":"

      Some SDKs expose \"context\" objects that exist:

      • inside a process
      • during a request
      • for the lifetime of a call chain

      These are extremely useful and completely different.

      SDK context objects:

      • are in-memory
      • disappear when the process ends
      • are not shared across sessions

      ctx:

      • survives process restarts
      • survives new chats
      • survives new days

      They share a name, not a purpose.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#enterprise-context-platforms","level":2,"title":"Enterprise Context Platforms","text":"

      Enterprise platforms often provide:

      • centralized context services
      • dashboards
      • access control
      • organizational knowledge layers

      These tools are designed for:

      • teams
      • governance
      • compliance
      • managed environments

      ctx is intentionally:

      • local-first: context lives next to your code, not behind a service boundary.
      • file-based: everything important is a markdown file you can read, diff, grep, and version-control.
      • single-binary core: the context persistence path (init, add, agent, status, drift, load, sync, compact, task, decision, learning, and their siblings) is a single Go binary with no required runtime dependencies. Optional integrations (ctx trace (needs git), ctx serve (needs zensical), the ctx Hub (needs a running hub), Claude Code plugin (needs claude)) are opt-in and each declares its dependency explicitly.
      • CLI-driven: every feature is reachable from the command line and scriptable.
      • developer-controlled: no auto-updating cloud service, no telemetry, no account to sign up for.

      The core ctx binary does not require:

      • a server
      • a database
      • an account
      • a SaaS backend
      • network connectivity (for core operations)

      ctx optimizes for individual and small-team workflows where context should live next to code; not behind a service boundary.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#specific-tool-comparisons","level":2,"title":"Specific Tool Comparisons","text":"

      Users often evaluate ctx against specific tools they already use. These comparisons clarify where responsibilities overlap, where they diverge, and where the tools are genuinely complementary.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#claude-code-memory-anthropic-auto-memory","level":3,"title":"Claude Code Memory / Anthropic Auto-Memory","text":"

      Anthropic's auto-memory is tool-managed memory (L2): the model decides what to remember, stores it automatically, and retrieves it implicitly. ctx is system memory (L3): humans and agents explicitly curate decisions, learnings, and tasks in inspectable files.

      Auto-memory is convenient - you do not configure anything. But it is also opaque: you cannot see what was stored, edit it precisely, or share it across tools. ctx files are plain Markdown in your repository, visible in diffs and code review.

      The two are complementary. ctx can absorb auto-memory as an input source (importing what the model remembered into structured context files) while providing the durable, inspectable layer that auto-memory lacks.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cursorrules-clauderules","level":3,"title":".Cursorrules / .Claude/rules","text":"

      Static rule files (.cursorrules, .claude/rules/) declare conventions: coding style, forbidden patterns, preferred libraries. They are effective for what to do and load automatically at session start.

      ctx adds dimensions that rule files do not cover: architectural decisions with rationale, learnings discovered during development, active tasks, and a constitution that governs agent behavior. Critically, ctx context accumulates - each session can add to it, and token budgeting ensures only the most relevant context is injected.

      Use rule files for static conventions. Use ctx for evolving project memory.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#aider-read-watch","level":3,"title":"Aider --read / --watch","text":"

      Aider's --read flag injects file contents at session start; --watch reloads them on change. The concept is similar to ctx's \"load\" step: make the agent aware of specific files.

      The differences emerge beyond loading. Aider has no persistence model -- nothing the agent learns during a session is written back. There is no token budgeting (large files consume the full context window), no priority ordering across file types, and no structured format for decisions or learnings. ctx provides the full lifecycle: load, accumulate, persist, and budget.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#copilot-workspace","level":3,"title":"Copilot @Workspace","text":"

      GitHub Copilot's @workspace performs workspace-wide code search. It answers \"what code exists?\" - finding function definitions, usages, and file structure across the repository.

      ctx answers a different question: \"what did we decide?\" It stores architectural intent, not code indices. Copilot's workspace search and ctx's project memory are orthogonal; one finds code, the other preserves the reasoning behind it.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cline-memory","level":3,"title":"Cline Memory","text":"

      Cline's memory bank stores session context within the Cline extension. The motivation is similar to ctx: help the agent remember across sessions.

      The key difference is portability. Cline memory is tied to Cline - it does not transfer to Claude Code, Cursor, Aider, or any other tool. ctx is tool-agnostic: context lives in plain files that any editor, agent, or script can read. Switching tools does not mean losing memory.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-a-good-fit","level":2,"title":"When ctx Is a Good Fit","text":"

      ctx works best when:

      • you want AI work to compound over time;
      • architectural decisions matter;
      • context must be inspectable;
      • humans and AI must share the same source of truth;
      • Git history should include why, not just what.
      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-not-the-right-tool","level":2,"title":"When ctx Is Not the Right Tool","text":"

      ctx is probably not what you want if:

      • you only need one-off prompts;
      • you rely exclusively on RAG;
      • you want autonomous agents without a human-readable state;
      • you require centralized enterprise control;
      • you want black-box memory systems,

      These are valid goals; just different ones.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#further-reading","level":2,"title":"Further Reading","text":"
      • You Can't Import Expertise: why project-specific context matters more than generic best practices
      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/design-invariants/","level":1,"title":"Invariants","text":"","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#the-system-explains-itself","level":1,"title":"The System Explains Itself","text":"

      These are the properties that must hold for any valid ctx implementation.

      • These are not features.
      • These are constraints.

      A change that violates an invariant is a category error, not an improvement.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#cognitive-state-tiers","level":2,"title":"Cognitive State Tiers","text":"

      ctx distinguishes between three forms of state:

      • Authoritative state: Versioned, inspectable artifacts that define intent and survive time.
      • Delivery views: Deterministic assemblies of the authoritative state for a specific budget or workflow.
      • Ephemeral working state: Local, transient, or sensitive data that assists interaction but does not define system truth.

      The invariants below apply primarily to the authoritative cognitive state.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#1-cognitive-state-is-explicit","level":2,"title":"1. Cognitive State Is Explicit","text":"

      All authoritative context lives in artifacts that can be inspected, reviewed, and versioned.

      If something is important, it must exist as a file: Not only in a prompt, a chat, or a model's hidden memory.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#2-assembly-is-reproducible","level":2,"title":"2. Assembly Is Reproducible","text":"

      Given the same:

      • repository state,
      • configuration,
      • and inputs,

      context assembly produces the same result.

      Heuristics may rank or filter for delivery under constraints.

      They do not alter the authoritative state.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#3-the-authoritative-state-is-human-readable","level":2,"title":"3. The Authoritative State Is Human-Readable","text":"

      The authoritative cognitive state must be stored in formats that a human can:

      • read,
      • diff,
      • review,
      • and edit directly.

      Sensitive working memory may be encrypted at rest. However, encryption must not become the only representation of authoritative knowledge.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#4-artifacts-outlive-sessions","level":2,"title":"4. Artifacts Outlive Sessions","text":"

      Sessions are transient.

      Knowledge persists.

      Reasoning, decisions, and outcomes must remain available after the interaction that produced them has ended.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#5-authority-is-user-defined","level":2,"title":"5. Authority Is User-Defined","text":"

      What enters the authoritative context is an explicit human decision.

      Models may suggest.

      Automation may assist.

      Selection is never implicit.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#6-operation-is-local-first","level":2,"title":"6. Operation Is Local-First","text":"

      The core system must function without requiring network access or a remote service.

      External systems may extend ctx.

      They must not be required for its operation.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#7-versioning-is-the-memory-model","level":2,"title":"7. Versioning Is the Memory Model","text":"

      The evolution of the authoritative cognitive state must be:

      • preserved,
      • inspectable,
      • and branchable.

      Ephemeral and sensitive working state may use different retention and diff strategies by design.

      Understanding includes understanding how we arrived here.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#8-structure-enables-scale","level":2,"title":"8. Structure Enables Scale","text":"

      Unstructured accumulation is not memory.

      Authoritative cognitive state must have a defined layout that:

      • communicates intent,
      • supports navigation,
      • and prevents drift.
      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#9-verification-is-the-scoreboard","level":2,"title":"9. Verification Is the Scoreboard","text":"

      Claims without recorded outcomes are noise.

      Reality (observed and captured) is the only signal that compounds.

      This invariant defines a required direction:

      The authoritative state must be able to record expectation and result.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#10-capture-once-reuse-indefinitely","level":2,"title":"10. Capture Once, Reuse Indefinitely","text":"

      Work that has already produced understanding must not be re-derived from scratch.

      Explored paths, rejected options, and validated conclusions are permanent assets.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#11-policies-are-encoded-not-remembered","level":2,"title":"11. Policies Are Encoded, Not Remembered","text":"

      Alignment must not depend on recall or goodwill.

      Constraints that matter must exist in machine-readable form and participate in context assembly.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#12-the-system-explains-itself","level":2,"title":"12. The System Explains Itself","text":"

      From the repository state alone it must be possible to determine:

      • what was authoritative,
      • what constraints applied.

      Delivery views may be optimized.

      They must not become the only explanation.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#non-goals","level":1,"title":"Non-Goals","text":"

      To avoid category errors, ctx does not attempt to be:

      • a skill,
      • a prompt management tool,
      • a chat history viewer,
      • an autonomous agent runtime,
      • a vector database,
      • a hosted memory service.

      Such systems may integrate with ctx.

      They do not define it.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#implications-for-contributions","level":1,"title":"Implications for Contributions","text":"

      Valid contributions:

      • strengthen an invariant,
      • reduce the cost of maintaining an invariant,
      • or extend the system without violating invariants.

      Invalid contributions:

      • introduce hidden authoritative state,
      • replace reproducible assembly with non-reproducible behavior,
      • make core operation depend on external services,
      • reduce human inspectability of authoritative state,
      • or bypass explicit user authority over what becomes authoritative.
      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#the-contract","level":1,"title":"The Contract","text":"

      Everything else (commands, skills, layouts, integrations, optimizations) is an implementation detail.

      These invariants are the system.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/scratchpad/","level":1,"title":"Scratchpad","text":"","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#what-is-ctx-scratchpad","level":2,"title":"What Is ctx Scratchpad?","text":"

      A one-liner scratchpad, encrypted at rest, synced via git.

      Quick notes that don't fit decisions, learnings, or tasks: reminders, intermediate values, sensitive tokens, working memory during debugging. Entries are numbered, reorderable, and persist across sessions.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#encrypted-by-default","level":2,"title":"Encrypted by Default","text":"

      Scratchpad entries are encrypted with AES-256-GCM before touching the disk.

      Component Path Git status Encryption key ~/.ctx/.ctx.key User-level, 0600 permissions Encrypted data .context/scratchpad.enc Committed

      The key is generated automatically during ctx init (256-bit via crypto/rand) and stored at ~/.ctx/.ctx.key. One key per machine, shared across all projects.

      The ciphertext format is [12-byte nonce][ciphertext+tag]. No external dependencies: Go stdlib only.

      Because the key is .gitignored and the data is committed, you get:

      • At-rest encryption: the .enc file is opaque without the key
      • Git sync: push/pull the encrypted file like any other tracked file
      • Key separation: the key never leaves the machine unless you copy it
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#commands","level":2,"title":"Commands","text":"Command Purpose ctx pad List all entries (numbered 1-based) ctx pad show N Output raw text of entry N (no prefix, pipe-friendly) ctx pad add \"text\" Append a new entry ctx pad rm ID [ID...] Remove entries by stable ID (supports ranges: 3-5) ctx pad edit N \"text\" Replace entry N with new text ctx pad edit N --append \"text\" Append text to the end of entry N ctx pad edit N --prepend \"text\" Prepend text to the beginning of entry N ctx pad edit N --tag tagname Add a tag to entry N ctx pad add TEXT --file PATH Ingest a file as a blob entry (TEXT is the label) ctx pad show N --out PATH Write decoded blob content to a file ctx pad normalize Reassign entry IDs as 1..N ctx pad mv N M Move entry from position N to position M ctx pad resolve Show both sides of a merge conflict for resolution ctx pad import FILE Bulk-import lines from a file (or stdin with -) ctx pad import --blob DIR Import directory files as blob entries ctx pad export [DIR] Export all blob entries to a directory as files ctx pad merge FILE... Merge entries from other scratchpad files into current ctx pad --tag TAG List entries filtered by tag (prefix with ~ to exclude) ctx pad tags List all tags with counts ctx pad tags --json List all tags with counts as JSON

      All commands decrypt on read, operate on plaintext in memory, and re-encrypt on write. The key file is never printed to stdout.

      For blob entries, --append, --prepend, and --tag modify the label while preserving the blob data.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#examples","level":3,"title":"Examples","text":"
      # Add a note\nctx pad add \"check DNS propagation after deploy\"\n\n# List everything\nctx pad\n#   1. check DNS propagation after deploy\n#   2. staging API key: sk-test-abc123\n\n# Show raw text (for piping)\nctx pad show 2\n# sk-test-abc123\n\n# Compose entries\nctx pad edit 1 --append \"$(ctx pad show 2)\"\n\n# Reorder\nctx pad mv 2 1\n\n# Clean up (IDs are stable; they don't shift when entries are deleted)\nctx pad rm 2\n
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#tags","level":2,"title":"Tags","text":"

      Entries can contain #word tags for lightweight categorization. Tags are convention-based: any #word token in an entry's text is a tag. No special syntax to add or remove them; use the existing add and edit commands.

      # Add tagged entries\nctx pad add \"check DNS propagation #later\"\nctx pad add \"deploy hotfix #urgent\"\nctx pad add \"review PR #later #ci\"\n\n# Filter by tag\nctx pad --tag later\n#   1. check DNS propagation #later\n#   3. review PR #later #ci\n\n# Exclude a tag\nctx pad --tag ~later\n#   2. deploy hotfix #urgent\n\n# Multiple filters (AND logic)\nctx pad --tag later --tag ci\n#   3. review PR #later #ci\n\n# List all tags with counts\nctx pad tags\n# ci       1\n# later    2\n# urgent   1\n\n# JSON output\nctx pad tags --json\n# [{\"tag\":\"ci\",\"count\":1},{\"tag\":\"later\",\"count\":2},{\"tag\":\"urgent\",\"count\":1}]\n\n# Add a tag to an existing entry\nctx pad edit 1 --tag done\n\n# Combine with other operations\nctx pad edit 1 --append \"checked\" --tag done\n\n# Remove a tag (replace entry text without the tag)\nctx pad edit 1 \"check DNS propagation\"\n

      Entry IDs are stable; they don't shift when other entries are deleted, so ctx pad rm 3 always targets the same entry. Use ctx pad normalize to reassign IDs as 1..N if gaps bother you. Tags are case-sensitive and support letters, digits, hyphens, and underscores (#high-priority, #v2, #my_tag).

      For blob entries, tags are extracted from the label only.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#bulk-import-and-export","level":2,"title":"Bulk Import and Export","text":"

      Import lines from a file in bulk (each non-empty line becomes an entry):

      # Import from a file\nctx pad import notes.txt\n\n# Import from stdin\ngrep TODO *.go | ctx pad import -\n

      Export all blob entries to a directory as files:

      # Export to a directory\nctx pad export ./ideas\n\n# Preview without writing\nctx pad export --dry-run\n\n# Overwrite existing files\nctx pad export --force ./backup\n
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#merging-scratchpads","level":2,"title":"Merging Scratchpads","text":"

      Combine entries from other scratchpad files into your current pad. Useful when merging work from parallel worktrees, other machines, or teammates:

      # Merge from a worktree's encrypted scratchpad\nctx pad merge worktree/.context/scratchpad.enc\n\n# Merge from multiple sources (encrypted and plaintext)\nctx pad merge pad-a.enc notes.md\n\n# Merge a foreign encrypted pad using its key\nctx pad merge --key /other/.ctx.key foreign.enc\n\n# Preview without writing\nctx pad merge --dry-run pad-a.enc pad-b.md\n

      Each input file is auto-detected as encrypted or plaintext: decryption is attempted first, and on failure the file is parsed as plain text. Entries are deduplicated by exact content, so running merge twice with the same file is safe.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#file-blobs","level":2,"title":"File Blobs","text":"

      The scratchpad can store small files (up to 64 KB) as blob entries. Files are base64-encoded and stored with a human-readable label.

      # Ingest a file: first argument is the label\nctx pad add \"deploy config\" --file ./deploy.yaml\n\n# Listing shows label with a [BLOB] marker\nctx pad\n#   1. check DNS propagation after deploy\n#   2. deploy config [BLOB]\n\n# Extract to a file\nctx pad show 2 --out ./recovered.yaml\n\n# Or print decoded content to stdout\nctx pad show 2\n

      Blob entries are encrypted identically to text entries. The internal format is label:::base64data: You never need to construct this manually.

      Constraint Value Max file size (pre-encoding) 64 KB Storage format label:::base64(content) Display label [BLOB] in listings

      When Should You Use Blobs

      Blobs are for small files you want encrypted and portable: config snippets, key fragments, deployment manifests, test fixtures. For anything larger than 64 KB, use the filesystem directly.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#using-with-ai","level":2,"title":"Using with AI","text":"

      Use Natural Language

      As in many ctx features, the ctx scratchpad can also be used with natural langauge. You don't have to memorize the CLI commands.

      CLI gives you \"precision\", whereas natural language gives you flow.

      The /ctx-pad skill maps natural language to ctx pad commands. You don't need to remember the syntax:

      You say What happens \"jot down: check DNS after deploy\" ctx pad add \"check DNS after deploy\" \"show my scratchpad\" ctx pad \"delete the third entry\" ctx pad rm 3 \"update entry 2 to include the new endpoint\" ctx pad edit 2 \"...\" \"move entry 4 to the top\" ctx pad mv 4 1 \"import my notes from notes.txt\" ctx pad import notes.txt \"export all blobs to ./backup\" ctx pad export ./backup \"merge the scratchpad from the worktree\" ctx pad merge worktree/.context/scratchpad.enc

      The skill handles the translation. You describe what you want in plain English; the agent picks the right command.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#worktrees","level":2,"title":"Worktrees","text":"

      The encryption key lives at ~/.ctx/.ctx.key (outside the project directory). Because all worktrees on the same machine share this path, ctx pad works in worktrees automatically - no special setup needed.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#key-distribution","level":2,"title":"Key Distribution","text":"

      The encryption key (~/.ctx/.ctx.key) stays on the machine where it was generated. ctx never transmits it.

      To share the scratchpad across machines:

      1. Copy the key manually: scp, USB drive, password manager.
      2. Push/pull the .enc file via git as usual.
      3. Both machines can now read and write the same scratchpad.

      Never Commit the Key

      The key is .gitignored by default. If you override this, anyone with repo access can decrypt your scratchpad.

      Treat the key like an SSH private key.

      See the Syncing Scratchpad Notes Across Machines recipe for a step-by-step walkthrough.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#plaintext-override","level":2,"title":"Plaintext Override","text":"

      For projects where encryption is unnecessary, disable it in .ctxrc:

      scratchpad_encrypt: false\n

      In plaintext mode:

      • Entries are stored in .context/scratchpad.md instead of .enc.
      • No key is generated or required.
      • All ctx pad commands work identically.
      • The file is human-readable and diffable.

      When Should You Use Plaintext

      Plaintext mode is useful for non-sensitive projects, solo work where encryption adds friction, or when you want scratchpad entries visible in git diff.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#when-should-you-use-scratchpad-versus-context-files","level":2,"title":"When Should You Use Scratchpad versus Context Files","text":"Use case Where it goes Temporary reminders (\"check X after deploy\") Scratchpad Working values during debugging Scratchpad Sensitive tokens or API keys (short-term) Scratchpad Quick notes that don't fit anywhere else Scratchpad Items that are not directly relevant to the project Scratchpad Things that you want to keep near, but also hidden Scratchpad Work items with completion tracking TASKS.md Trade-offs with rationale DECISIONS.md Reusable lessons with context/lesson/application LEARNINGS.md Codified patterns and standards CONVENTIONS.md

      Rule of thumb:

      • If it needs structure or will be referenced months later, use a context file (i.e. DECISIONS.md, LEARNINGS.md, TASKS.md).
      • If it is working memory for the current session or week, use the scratchpad.
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#see-also","level":2,"title":"See Also","text":"
      • Syncing Scratchpad Notes Across Machines: Key distribution, push/pull workflow, merge conflict resolution
      • Using the Scratchpad: Natural language examples, blob workflow, when to use scratchpad vs context files
      • Context Files: Format and conventions for all .context/ files
      • Security: Trust model and permission hygiene
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/session-journal/","level":1,"title":"Session Journal","text":"

      Important Security Note

      Session journals contain sensitive data such as file contents, commands, API keys, internal discussions, error messages with stack traces, and more.

      The .context/journal-site/ and .context/journal-obsidian/ directories MUST be .gitignored.

      • DO NOT host your journal publicly.
      • DO NOT commit your journal files to version control.
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#browse-your-session-history","level":2,"title":"Browse Your Session History","text":"

      ctx's Session Journal turns your AI coding sessions into a browsable, searchable, and editable archive.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#quick-start","level":2,"title":"Quick Start","text":"

      After using ctx for a couple of sessions, you can generate a journal site with:

      # Import all sessions to markdown\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n

      Then open http://localhost:8000 to browse your sessions.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#what-you-get","level":2,"title":"What You Get","text":"

      The Session Journal gives you:

      • Browsable history: Navigate through all your AI sessions by date
      • Full conversations: See every message, tool use, and result
      • Token usage: Track how many tokens each session consumed
      • Search: Find sessions by content, project, or date
      • Dark mode: Easy on the eyes for late-night archaeology

      Each session page includes the following sections:

      Section Content Metadata Date, time, duration, model, project, git branch Summary Space for your notes (editable) Tool Usage Which tools were used and how often Conversation Full transcript with timestamps","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#1-import-sessions","level":3,"title":"1. Import Sessions","text":"
      # Import all sessions from current project (only new files)\nctx journal import --all\n\n# Import sessions from all projects\nctx journal import --all --all-projects\n\n# Import a specific session by ID (always writes)\nctx journal import abc123\n\n# Preview what would be imported\nctx journal import --all --dry-run\n\n# Re-import existing (regenerates conversation, preserves YAML frontmatter)\nctx journal import --all --regenerate\n\n# Discard frontmatter during regeneration\nctx journal import --all --regenerate --keep-frontmatter=false -y\n

      Imported sessions go to .context/journal/ as editable Markdown files.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#2-generate-the-site","level":3,"title":"2. Generate the Site","text":"
      # Generate site structure\nctx journal site\n\n# Generate and build static HTML\nctx journal site --build\n\n# Generate and serve locally\nctx journal site --serve\n\n# Custom output directory\nctx journal site --output ~/my-journal\n

      The site is generated in .context/journal-site/ by default.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#3-browse-and-search","level":3,"title":"3. Browse and Search","text":"

      Open http://localhost:8000 after running --serve.

      • Use the sidebar to navigate by date
      • Use search (/ key) to find specific content
      • Click any session to see the full conversation
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#editing-sessions","level":2,"title":"Editing Sessions","text":"

      Imported sessions are plain Markdown in .context/journal/. You can:

      • Add summaries: Fill in the ## Summary section
      • Add notes: Insert your own commentary anywhere
      • Highlight key moments: Use Markdown formatting
      • Delete noise: Remove irrelevant tool outputs

      After editing, regenerate the site:

      ctx journal site --serve\n
      Safe by Default

      Running ctx journal import --all only imports new sessions. Existing files are skipped entirely (your edits and enrichments are never touched).

      Use --regenerate to re-import existing files. Conversation content is regenerated, but YAML frontmatter (topics, type, outcome, etc.) is preserved. You'll be prompted before any existing files are overwritten; add -y to skip the prompt.

      Use --keep-frontmatter=false to discard enriched frontmatter during regeneration.

      Locked entries (via ctx journal lock) are always skipped, regardless of flags. If you prefer to add locked: true to frontmatter during enrichment, run ctx journal sync to propagate the lock state to .state.json.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#large-sessions","level":2,"title":"Large Sessions","text":"

      Sessions with many messages (200+) are automatically split into multiple parts for better browser performance. Navigation links connect the parts:

      session-abc123.md      (Part 1 of 3)\nsession-abc123-p2.md   (Part 2 of 3)\nsession-abc123-p3.md   (Part 3 of 3)\n
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#suggestion-sessions","level":2,"title":"Suggestion Sessions","text":"

      Claude Code generates \"suggestion\" sessions for auto-complete prompts. These are separated in the index under a \"Suggestions\" section to keep your main session list focused.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enriching-journal-entries","level":2,"title":"Enriching Journal Entries","text":"

      Raw imported sessions contain basic metadata (date, time, project) but lack the structured information needed for effective search, filtering, and analysis. Journal enrichment adds semantic metadata that transforms a flat archive into a searchable knowledge base.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#why-enrich","level":3,"title":"Why Enrich?","text":"

      Without enrichment, you have timestamps and raw conversations. With enrichment:

      • Find sessions by topic: \"Show me all auth-related sessions\"
      • Filter by outcome: \"What did I abandon vs complete?\"
      • Track technology usage: \"When did I last work with PostgreSQL?\"
      • Identify key files: Jump directly to the files discussed
      • Get summaries: Understand what happened without reading transcripts
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#the-frontmatter-schema","level":3,"title":"The Frontmatter Schema","text":"

      Enriched entries begin with YAML frontmatter:

      ---\ntitle: \"Implement caching layer\"\ndate: 2026-01-27\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - performance\ntechnologies:\n  - go\n  - redis\nlibraries:\n  - go-redis/redis\nkey_files:\n  - internal/cache/redis.go\n  - internal/cache/memory.go\n---\n
      Field Required Description title Yes Descriptive title (not the session slug) date Yes Session date (YYYY-MM-DD) type Yes Session type (see below) outcome Yes How the session ended (see below) topics No Subject areas discussed technologies No Languages, databases, frameworks libraries No Specific packages or libraries used key_files No Important files created or modified

      Type values:

      Type When to use feature Building new functionality bugfix Fixing broken behavior refactor Restructuring without behavior change exploration Research, learning, experimentation debugging Investigating issues documentation Writing docs, comments, README

      Outcome values:

      Outcome Meaning completed Goal achieved partial Some progress, work continues abandoned Stopped pursuing this approach blocked Waiting on external dependency","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-ctx-journal-enrich","level":3,"title":"Using /ctx-journal-enrich","text":"

      The /ctx-journal-enrich skill automates enrichment by analyzing conversation content and proposing metadata.

      Invoke by session identifier:

      /ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-01-24\n/ctx-journal-enrich 76fe2ab9\n

      The skill will:

      1. Check if locked - locked entries are skipped (same as export);
      2. Find the matching journal file;
      3. Read and analyze the conversation;
      4. Propose frontmatter (type, topics, outcome, technologies);
      5. Generate a 2-3 sentence summary;
      6. Extract decisions, learnings, and tasks mentioned;
      7. Show a diff and ask for confirmation before writing.
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#before-and-after","level":3,"title":"Before and After","text":"

      Before enrichment:

      # twinkly-stirring-kettle\n\n**ID**: abc123-def456\n**Date**: 2026-01-24\n**Time**: 14:30:00\n...\n\n## Summary\n\n[Add your summary of this session]\n\n## Conversation\n...\n

      After enrichment:

      ---\ntitle: \"Add Redis caching to API endpoints\"\ndate: 2026-01-24\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - api-performance\ntechnologies:\n  - go\n  - redis\nkey_files:\n  - internal/api/middleware/cache.go\n  - internal/cache/redis.go\n---\n\n# twinkly-stirring-kettle\n\n**ID**: abc123-def456\n**Date**: 2026-01-24\n**Time**: 14:30:00\n...\n\n## Summary\n\nImplemented Redis-based caching middleware for frequently accessed API endpoints.\nAdded cache invalidation on writes and configurable TTL per route. Reduced\n the average response time from 200ms to 15ms for cached routes.\n\n## Decisions\n\n* Used Redis over in-memory cache for horizontal scaling\n* Chose per-route TTL configuration over global setting\n\n## Learnings\n\n* Redis WATCH command prevents race conditions during cache invalidation\n\n## Conversation\n...\n
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enrichment-and-site-generation","level":3,"title":"Enrichment and Site Generation","text":"

      The journal site generator uses enriched metadata for better organization:

      • Titles appear in navigation instead of slugs
      • Summaries provide context in the index
      • Topics enable filtering (when using search)
      • Types allow grouping by work category

      Future improvements will add topic-based navigation and outcome filtering to the generated site.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#batch-enrichment","level":3,"title":"Batch Enrichment","text":"

      To enrich multiple sessions, process them one at a time:

      # List unenriched sessions (those without frontmatter)\ngrep -L \"^---$\" .context/journal/*.md | head -10\n

      Then run /ctx-journal-enrich on each. Enrichment is intentionally interactive to ensure accuracy.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#obsidian-vault-export","level":2,"title":"Obsidian Vault Export","text":"

      If you use Obsidian for knowledge management, you can export your journal as an Obsidian vault instead of (or alongside) the static site:

      ctx journal obsidian\n

      This generates a vault in .context/journal-obsidian/ with:

      • Wikilinks ([[target|display]]) instead of Markdown links
      • MOC pages (Map of Content) for topics, key files, and session types
      • Related sessions footer per entry: links to entries sharing the same topics
      • Transformed frontmatter: topics renamed to tags (Obsidian-recognized), aliases added from title for search
      • Graph-optimized structure: MOC hubs and cross-linked entries create dense graph connectivity

      To use: open the output directory in Obsidian (\"Open folder as vault\").

      # Custom output directory\nctx journal obsidian --output ~/vaults/ctx-journal\n

      Static Site vs Obsidian Vault

      Use ctx journal site when you want a web-browsable archive with search and dark mode. Use ctx journal obsidian when you want graph view, backlinks, and tag-based navigation inside Obsidian. Both use the same enriched source entries: you can generate both.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#full-pipeline","level":2,"title":"Full Pipeline","text":"

      The complete journal workflow has four stages. Each is idempotent: safe to re-run, and stages skip already-processed entries.

      import → enrich → rebuild\n
      Stage Command / Skill What it does Skips if Import ctx journal import --all Converts session JSONL to Markdown File already exists (safe default) Enrich /ctx-journal-enrich Adds frontmatter, summaries, topics Frontmatter already present Rebuild ctx journal site --build Generates static HTML site (never) Obsidian ctx journal obsidian Generates Obsidian vault with wikilinks (never)

      One-Command Pipeline

      /ctx-journal-enrich-all handles import automatically - it detects unimported sessions and imports them before enriching. You only need to run ctx journal site --build afterward.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-make-journal","level":3,"title":"Using make journal","text":"

      If your project includes Makefile.ctx (deployed by ctx init), the first and last stages are combined:

      make journal           # import + rebuild\n

      After it runs, it reminds you to enrich in Claude Code:

      Next steps (in Claude Code):\n  /ctx-journal-enrich-all # imports if needed + adds metadata per entry\n\nThen re-run: make journal\n

      Rendering Issues?

      If individual entries have rendering problems (broken fences, malformed lists), check the programmatic normalization in the import pipeline. Most cases are handled automatically during ctx journal import.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#tips","level":2,"title":"Tips","text":"

      Daily workflow:

      # Import, browse, then enrich in Claude Code\nmake journal && make journal-serve\n# Then in Claude Code: /ctx-journal-enrich <session>\n

      After a productive session:

      # Import just that session and add notes\nctx journal import <session-id>\n# Edit .context/journal/<session>.md\n# Regenerate: ctx journal site\n

      Searching across all sessions:

      # Use grep on the journal directory\ngrep -r \"authentication\" .context/journal/\n

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#requirements","level":2,"title":"Requirements","text":"Use pipx for zensical

      pip install zensical may install a non-functional stub on system Python. Using venv has other issues too.

      These issues especially happen on Mac OSX.

      Use pipx install zensical, which creates an isolated environment and handles Python version management automatically.

      The journal site uses zensical for static site generation:

      pipx install zensical\n
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#see-also","level":2,"title":"See Also","text":"
      • ctx journal: Session discovery and listing
      • ctx journal site: Static site generation
      • ctx journal obsidian: Obsidian vault export
      • Context Files: The .context/ directory structure
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/skills/","level":1,"title":"Skills","text":"","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#skills","level":2,"title":"Skills","text":"

      Skills are slash commands that run inside your AI assistant (e.g., /ctx-next), as opposed to CLI commands that run in your terminal (e.g., ctx status).

      Skills give your agent structured workflows: It knows what to read, what to run, and when to ask. Most wrap one or more ctx CLI commands with opinionated behavior on top.

      Skills Are Best Used Conversationally

      The beauty of ctx is that it's designed to be intuitive and conversational, allowing you to interact with your AI assistant naturally. That's why you don't have to memorize many of these skills.

      See the Prompting Guide for natural-language triggers that invoke these skills conversationally.

      However, when you need a more precise control, you have the option to invoke the relevant skills directly.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#all-skills","level":2,"title":"All Skills","text":"Skill Description Type /ctx-remember Recall project context and present structured readback user-invocable /ctx-wrap-up End-of-session context persistence ceremony user-invocable /ctx-status Show context summary with interpretation user-invocable /ctx-agent Load full context packet for AI consumption user-invocable /ctx-next Suggest 1-3 concrete next actions with rationale user-invocable /ctx-commit Commit with integrated context persistence user-invocable /ctx-reflect Pause and reflect on session progress user-invocable /ctx-task-add Add actionable task to TASKS.md user-invocable /ctx-decision-add Record architectural decision with rationale user-invocable /ctx-learning-add Record gotchas and lessons learned user-invocable /ctx-convention-add Record coding convention for consistency user-invocable /ctx-archive Archive completed tasks from TASKS.md user-invocable /ctx-pad Manage encrypted scratchpad entries user-invocable /ctx-history Browse and import AI session history user-invocable /ctx-journal-enrich Enrich single journal entry with metadata user-invocable /ctx-journal-enrich-all Full journal pipeline: export if needed, then batch-enrich user-invocable /ctx-blog Generate blog post draft from project activity user-invocable /ctx-blog-changelog Generate themed blog post from a commit range user-invocable /ctx-consolidate Consolidate redundant learnings or decisions user-invocable /ctx-drift Detect and fix context drift user-invocable /ctx-prompt Apply, list, and manage saved prompt templates user-invocable /ctx-prompt-audit Analyze prompting patterns for improvement user-invocable /ctx-link-check Audit docs for dead internal and external links user-invocable /ctx-permission-sanitize Audit Claude Code permissions for security risks user-invocable /ctx-brainstorm Structured design dialogue before implementation user-invocable /ctx-spec Scaffold a feature spec from a project template user-invocable /ctx-plan-import Import Claude Code plan files into project specs user-invocable /ctx-implement Execute a plan step-by-step with verification user-invocable /ctx-loop Generate autonomous loop script user-invocable /ctx-worktree Manage git worktrees for parallel agents user-invocable /ctx-architecture Build and maintain architecture maps user-invocable /ctx-architecture-failure-analysis Adversarial failure analysis for correctness bugs user-invocable /ctx-remind Manage session-scoped reminders user-invocable /ctx-doctor Troubleshoot ctx behavior with health checks and event analysis user-invocable /ctx-skill-audit Audit skills against Anthropic prompting best practices user-invocable /ctx-skill-create Create, improve, and test skills user-invocable /ctx-pause Pause context hooks for this session user-invocable /ctx-resume Resume context hooks after a pause user-invocable","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-lifecycle","level":2,"title":"Session Lifecycle","text":"

      Skills for starting, running, and ending a productive session.

      Session Ceremonies

      Two skills in this group are ceremony skills: /ctx-remember (session start) and /ctx-wrap-up (session end). Unlike other skills that work conversationally, these should be invoked as explicit slash commands for completeness. See Session Ceremonies.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remember","level":3,"title":"/ctx-remember","text":"

      Recall project context and present a structured readback. Ceremony skill: invoke explicitly at session start.

      Wraps: ctx agent --budget 4000, ctx journal source --limit 3, reads TASKS.md, DECISIONS.md, LEARNINGS.md

      See also: Session Ceremonies, The Complete Session

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-status","level":3,"title":"/ctx-status","text":"

      Show context summary (files, token budget, tasks, recent activity) with interpreted suggestions.

      Wraps: ctx status [--verbose] [--json]

      See also: The Complete Session, ctx status CLI

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-agent","level":3,"title":"/ctx-agent","text":"

      Load the full context packet optimized for AI consumption. Also runs automatically via the PreToolUse hook with cooldown.

      Wraps: ctx agent [--budget] [--format] [--cooldown] [--session]

      See also: The Complete Session, ctx agent CLI

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-next","level":3,"title":"/ctx-next","text":"

      Suggest 1-3 concrete next actions ranked by priority, momentum, and unblocked status.

      Wraps: reads TASKS.md, ctx journal source --limit 3

      See also: The Complete Session, Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-commit","level":3,"title":"/ctx-commit","text":"

      Commit code with integrated context persistence: pre-commit checks, staged files, Co-Authored-By trailer, and a post-commit prompt to capture decisions and learnings.

      Wraps: git add, git commit, optionally chains to /ctx-decision-add and /ctx-learning-add

      See also: The Complete Session

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-reflect","level":3,"title":"/ctx-reflect","text":"

      Pause and reflect on session progress. Walks through a checklist of learnings, decisions, task completions, and session notes to persist.

      Wraps: chains to ctx add learning, ctx add decision, manual TASKS.md updates

      See also: The Complete Session, Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-wrap-up","level":3,"title":"/ctx-wrap-up","text":"

      End-of-session context persistence ceremony. Gathers signal from git diff, recent commits, and conversation themes. Proposes candidates (learnings, decisions, conventions, tasks) with complete structured fields for user approval, then persists via ctx add. Offers /ctx-commit if uncommitted changes remain. Ceremony skill: invoke explicitly at session end.

      Wraps: git diff --stat, git log, ctx add learning, ctx add decision, ctx add convention, ctx add task, chains to /ctx-commit

      See also: Session Ceremonies, The Complete Session

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#context-persistence","level":2,"title":"Context Persistence","text":"

      Skills for recording work artifacts: tasks, decisions, learnings, conventions: into .context/ files.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-task-add","level":3,"title":"/ctx-task-add","text":"

      Add an actionable task with optional priority and phase section.

      Wraps: ctx add task \"description\" [--priority high|medium|low] --session-id ID --branch BR --commit HASH

      See also: Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-decision-add","level":3,"title":"/ctx-decision-add","text":"

      Record an architectural decision with context, rationale, and consequence. Supports Y-statement (lightweight) and full ADR formats.

      Wraps: ctx add decision \"title\" --context \"...\" --rationale \"...\" --consequence \"...\" --session-id ID --branch BR --commit HASH

      See also: Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-learning-add","level":3,"title":"/ctx-learning-add","text":"

      Record a project-specific gotcha, bug, or unexpected behavior. Filters for insights that are searchable, project-specific, and required real effort to discover.

      Wraps: ctx add learning \"title\" --context \"...\" --lesson \"...\" --application \"...\" --session-id ID --branch BR --commit HASH

      See also: Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-convention-add","level":3,"title":"/ctx-convention-add","text":"

      Record a coding convention that should be standardized across sessions. Targets patterns seen 2-3+ times.

      Wraps: ctx add convention \"rule\" --section \"Name\"

      See also: Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-archive","level":3,"title":"/ctx-archive","text":"

      Archive completed tasks from TASKS.md to a timestamped file in .context/archive/. Preserves phase headers for traceability.

      Wraps: ctx task archive [--dry-run]

      See also: Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#scratchpad","level":2,"title":"Scratchpad","text":"","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-pad","level":3,"title":"/ctx-pad","text":"

      Manage the encrypted scratchpad: add, remove, edit, and reorder one-liner notes. Encrypted at rest with AES-256-GCM.

      Wraps: ctx pad, ctx pad add, ctx pad rm, ctx pad edit, ctx pad mv, ctx pad import, ctx pad export, ctx pad merge

      See also: Scratchpad, Using the Scratchpad

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#journal-history","level":2,"title":"Journal & History","text":"

      Skills for browsing, exporting, and enriching your AI session history into a structured journal.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-history","level":3,"title":"/ctx-history","text":"

      Browse, inspect, and import AI session history. List recent sessions, show details by slug or ID, and import to .context/journal/.

      Wraps: ctx journal source, ctx journal source --show, ctx journal import

      See also: Browsing and Enriching Past Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich","level":3,"title":"/ctx-journal-enrich","text":"

      Enrich a single journal entry with YAML frontmatter: title, type, outcome, topics, technologies, and summary. Shows diff before writing.

      Wraps: reads and edits .context/journal/*.md files

      See also: Browsing and Enriching Past Sessions, Turning Activity into Content

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich-all","level":3,"title":"/ctx-journal-enrich-all","text":"

      Full journal pipeline: imports unimported sessions first, then batch-enriches all unenriched entries. Filters out short sessions and continuations. Can spawn subagents for large backlogs.

      Wraps: ctx journal import --all + iterates /ctx-journal-enrich

      See also: Browsing and Enriching Past Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#content-creation","level":2,"title":"Content Creation","text":"

      Skills for turning project activity into publishable content.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog","level":3,"title":"/ctx-blog","text":"

      Generate a blog post draft from recent project activity: git history, decisions, learnings, tasks, and journal entries. Requires a narrative arc (problem, approach, outcome).

      Wraps: reads git log, DECISIONS.md, LEARNINGS.md, TASKS.md, journal entries; writes to docs/blog/

      See also: Turning Activity into Content

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog-changelog","level":3,"title":"/ctx-blog-changelog","text":"

      Generate a themed blog post from a commit range. Takes a starting commit and unifying theme, analyzes diffs and journal entries from that period.

      Wraps: git log, git diff --stat; writes to docs/blog/

      See also: Turning Activity into Content

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#auditing-health","level":2,"title":"Auditing & Health","text":"

      Skills for detecting drift, auditing alignment, and improving prompt quality.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-consolidate","level":3,"title":"/ctx-consolidate","text":"

      Consolidate redundant entries in LEARNINGS.md or DECISIONS.md. Groups overlapping entries by keyword similarity, presents candidates, and (with user approval) merges groups into denser combined entries. Originals are archived, not deleted.

      Wraps: reads LEARNINGS.md and DECISIONS.md, writes consolidated entries, archives originals, runs ctx reindex

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-drift","level":3,"title":"/ctx-drift","text":"

      Detect and fix context drift: stale paths, missing files, file age staleness, task accumulation, entry count warnings, and constitution violations via ctx drift. Also detects skill drift against canonical templates.

      Wraps: ctx drift [--fix]

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-prompt-audit","level":3,"title":"/ctx-prompt-audit","text":"

      Analyze recent prompting patterns to identify vague or ineffective prompts. Reviews 3-5 journal entries and suggests rewrites with positive observations.

      Wraps: reads .context/journal/ entries

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-doctor","level":3,"title":"/ctx-doctor","text":"

      Troubleshoot ctx behavior. Runs structural health checks via ctx doctor, analyzes event log patterns via ctx hook event, and presents findings with suggested actions. The CLI provides the structural baseline; the agent adds semantic analysis of event patterns and correlations.

      Wraps: ctx doctor --json, ctx hook event --json --last 100, ctx remind list, ctx hook message list, reads .ctxrc

      Trigger phrases: \"diagnose\", \"troubleshoot\", \"doctor\", \"health check\", \"why didn't my hook fire?\", \"hooks seem broken\", \"something seems off\"

      Graceful degradation: If event_log is not enabled, the skill still works but with reduced capability. It runs structural checks and notes: \"Enable event_log: true in .ctxrc for hook-level diagnostics.\"

      See also: Troubleshooting, ctx doctor CLI, ctx hook event CLI

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-link-check","level":3,"title":"/ctx-link-check","text":"

      Scan all markdown files under docs/ for broken links. Three passes: internal links (verify file targets exist on disk), external links (HTTP HEAD with timeout, report failures as warnings), and image references. Resolves relative paths, strips anchors before checking, and skips localhost/example URLs.

      Wraps: Glob + Grep to scan, curl for external checks

      Trigger phrases: \"check links\", \"audit links\", \"any broken links?\", \"dead links\"

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-permission-sanitize","level":3,"title":"/ctx-permission-sanitize","text":"

      Audit .claude/settings.local.json for dangerous permissions across four risk categories: hook bypass (Critical), destructive commands (High), config injection vectors (High), and overly broad patterns (Medium). Reports findings by severity and offers specific fix actions with user confirmation.

      Wraps: reads .claude/settings.local.json, edits with confirmation

      Trigger phrases: \"audit permissions\", \"are my permissions safe?\", \"sanitize permissions\", \"check settings\"

      See also: Claude Code Permission Hygiene

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#planning-execution","level":2,"title":"Planning & Execution","text":"

      Skills for structured design, implementation, and parallel agent workflows.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-brainstorm","level":3,"title":"/ctx-brainstorm","text":"

      Transform raw ideas into clear, validated designs through structured dialogue before any implementation begins. Follows a gated process: understand context, clarify the idea (one question at a time), surface non-functional requirements, lock understanding with user confirmation, explore 2-3 design approaches with trade-offs, stress-test the chosen approach, and present the detailed design.

      Wraps: reads DECISIONS.md, relevant source files; chains to /ctx-decision-add for recording design choices

      Trigger phrases: \"let's brainstorm\", \"design this\", \"think through\", \"before we build\", \"what approach should we take?\"

      See also: /ctx-spec

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-spec","level":3,"title":"/ctx-spec","text":"

      Scaffold a feature spec from the project template and walk through each section with the user. Covers: problem, approach, happy path, edge cases, validation rules, error handling, interface, implementation, configuration, testing, and non-goals. Spends extra time on edge cases and error handling.

      Wraps: reads specs/tpl/spec-template.md, writes to specs/, optionally chains to /ctx-task-add

      Trigger phrases: \"spec this out\", \"write a spec\", \"create a spec\", \"design document\"

      See also: /ctx-brainstorm, /ctx-plan-import

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-plan-import","level":3,"title":"/ctx-plan-import","text":"

      Import Claude Code plan files (~/.claude/plans/*.md) into the project's specs/ directory. Lists plans with dates and H1 titles, supports filtering (--today, --since, --all), slugifies headings for filenames, and optionally creates tasks referencing each imported spec.

      Wraps: reads ~/.claude/plans/*.md, writes to specs/, optionally chains to /ctx-task-add

      See also: Importing Claude Code Plans, Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-implement","level":3,"title":"/ctx-implement","text":"

      Execute a multi-step plan with build and test verification at each step. Loads a plan from a file or conversation context, breaks it into atomic steps, and checkpoints after every 3-5 steps.

      Wraps: reads plan file, runs verification commands (go build, go test, etc.)

      See also: Running an Unattended AI Agent

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-loop","level":3,"title":"/ctx-loop","text":"

      Generate a ready-to-run shell script for autonomous AI iteration. Supports Claude Code, Aider, and generic tool templates with configurable completion signals.

      Wraps: ctx loop [--tool] [--prompt] [--max-iterations] [--completion] [--output]

      See also: Autonomous Loops, Running an Unattended AI Agent

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-worktree","level":3,"title":"/ctx-worktree","text":"

      Manage git worktrees for parallel agent development. Create sibling worktrees on dedicated branches, analyze task blast radius for grouping, and tear down with merge.

      Wraps: git worktree add, git worktree list, git worktree remove, git merge

      See also: Parallel Agent Development with Git Worktrees

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture","level":3,"title":"/ctx-architecture","text":"

      Build and maintain architecture maps incrementally. Creates or refreshes ARCHITECTURE.md (succinct project map, loaded at session start) and DETAILED_DESIGN.md (deep per-module reference, consulted on-demand). Coverage is tracked in map-tracking.json so each run extends the map rather than re-analyzing everything.

      Wraps: ctx status, git log, reads source files; writes ARCHITECTURE.md, DETAILED_DESIGN.md, map-tracking.json

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture-failure-analysis","level":3,"title":"/ctx-architecture-failure-analysis","text":"

      Adversarial failure analysis that generates falsifiable incident hypotheses against architecture artifacts. Hunts for correctness bugs that survive code review and tests: race conditions, ordering assumptions, cache staleness, error swallowing, ownership gaps, idempotency failures, state machine drift, and scaling cliffs.

      Requires /ctx-architecture artifacts as input. Reads ARCHITECTURE.md, DETAILED_DESIGN*.md, and map-tracking.json, then systematically applies 9 failure categories to every mutation point. Each finding carries an evidence standard (code path, trigger, failure path, silence reason, code evidence), a confidence level, and an explicit risk score. A mandatory challenge phase attempts to disprove each finding before it is accepted.

      Produces .context/DANGER-ZONES.md with ranked findings split into Critical (risk >= 7, silent/cascading) and Elevated tiers.

      Wraps: reads architecture artifacts, source code; writes DANGER-ZONES.md. Optionally uses GitNexus for blast radius and Gemini Search for cross-referencing known failure patterns.

      Relationship:

      Skill Mode /ctx-architecture Map what exists /ctx-architecture-enrich Improve map fidelity /ctx-architecture-failure-analysis Generate falsifiable incident hypotheses","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remind","level":3,"title":"/ctx-remind","text":"

      Manage session-scoped reminders via natural language. Translates user intent (\"remind me to refactor swagger\") into the corresponding ctx remind command. Handles date conversion for --after flags.

      Wraps: ctx remind, ctx remind list, ctx remind dismiss

      See also: Session Reminders

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#skill-authoring","level":2,"title":"Skill Authoring","text":"","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-skill-audit","level":3,"title":"/ctx-skill-audit","text":"

      Audit one or more skills against Anthropic prompting best practices. Checks audit dimensions: positive framing, motivation, phantom references, examples, subagent guards, scope, and descriptions. Reports findings by severity with concrete fix suggestions.

      Wraps: reads internal/assets/claude/skills/*/SKILL.md or .claude/skills/*/SKILL.md, references anthropic-best-practices.md

      Trigger phrases: \"audit this skill\", \"check skill quality\", \"review the skills\", \"are our skills any good?\"

      See also: /ctx-skill-create, Contributing

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-skill-create","level":3,"title":"/ctx-skill-create","text":"

      Create, improve, and test skills. Guides the full lifecycle: capture intent, interview for edge cases, draft the SKILL.md, test with realistic prompts, review results with the user, and iterate. Applies core principles: the agent is already smart (only add what it does not know), the description is the trigger (make it specific and \"pushy\"), and explain the why instead of rigid directives.

      Wraps: reads/writes .claude/skills/ and internal/assets/claude/skills/

      Trigger phrases: \"create a skill\", \"turn this into a skill\", \"make a slash command\", \"this should be a skill\", \"improve this skill\", \"the skill isn't triggering\"

      See also: Contributing

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-control","level":2,"title":"Session Control","text":"

      Skills for controlling hook behavior during a session.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-pause","level":3,"title":"/ctx-pause","text":"

      Pause all context nudge and reminder hooks for the current session. Security hooks still fire. Use for quick investigations or tasks that don't need ceremony overhead.

      Wraps: ctx hook pause

      Trigger phrases: \"pause ctx\", \"pause context\", \"stop the nudges\", \"quiet mode\"

      See also: Pausing Context Hooks

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-resume","level":3,"title":"/ctx-resume","text":"

      Resume context hooks after a pause. Restores normal nudge, reminder, and ceremony behavior. Silent no-op if not paused.

      Wraps: ctx hook resume

      Trigger phrases: \"resume ctx\", \"resume context\", \"turn nudges back on\", \"unpause\"

      See also: Pausing Context Hooks

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#project-specific-skills","level":2,"title":"Project-Specific Skills","text":"

      The ctx plugin ships the skills listed above. Teams can add their own project-specific skills to .claude/skills/ in the project root: These are separate from plugin-shipped skills and are scoped to the project.

      Project-specific skills follow the same format and are invoked the same way.

      Custom skills are not covered in this reference.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/versions/","level":1,"title":"Version History","text":"","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#version-history","level":2,"title":"Version History","text":"

      Documentation snapshots for each release.

      Tap the corresponding view docs to view the docs as they were at that release.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#releases","level":2,"title":"Releases","text":"Version Release Date Documentation v0.8.0 2026-03-23 view docs v0.6.0 2026-02-16 view docs v0.3.0 2026-02-07 view docs v0.2.0 2026-02-01 view docs v0.1.2 2026-01-27 view docs v0.1.1 2026-01-26 view docs v0.1.0 2026-01-25 view docs","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v080-the-architecture-release","level":3,"title":"v0.8.0: The Architecture Release","text":"

      MCP server for tool-agnostic AI integration. Memory bridge connecting Claude Code auto-memory to .context/. Complete CLI restructuring into cmd/ + core/ taxonomy. All user-facing strings externalized to YAML. fatih/color removed; two direct dependencies remain.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v060-the-integration-release","level":3,"title":"v0.6.0: The Integration Release","text":"

      Plugin architecture: hooks and skills converted from shell scripts to Go subcommands, shipped as a Claude Code marketplace plugin. Multi-tool hook generation for Cursor, Aider, Copilot, and Windsurf. Webhook notifications with encrypted URL storage.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v030-the-discipline-release","level":3,"title":"v0.3.0: The Discipline Release","text":"

      Journal static site generation via zensical. 49-skill audit and fix pass (positive framing, phantom reference removal, scope tightening). Context consolidation skill. golangci-lint v2 migration.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v020-the-archaeology-release","level":3,"title":"v0.2.0: The Archaeology Release","text":"

      Session journal system: ctx journal import converts Claude Code JSONL transcripts to browsable Markdown. Constants refactor with semantic prefixes (Dir*, File*, Filename*). CRLF handling for Windows compatibility.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v012","level":3,"title":"v0.1.2","text":"

      Default Claude Code permissions deployed on ctx init. Prompting guide published as a standalone documentation page.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v011","level":3,"title":"v0.1.1","text":"

      Bug fixes: hook schema key format corrected, JSON unicode escaping fixed in context file output.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v010-initial-release","level":3,"title":"v0.1.0: Initial Release","text":"

      CLI with 15 subcommands, 6 context file types (CONSTITUTION, TASKS, CONVENTIONS, ARCHITECTURE, DECISIONS, LEARNINGS), Makefile build system, and Claude Code hook integration.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#latest","level":2,"title":"Latest","text":"

      The main documentation always reflects the latest development version.

      For the most recent stable release, see v0.8.0.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#changelog","level":2,"title":"Changelog","text":"

      For detailed changes between versions, see the GitHub Releases page.

      ","path":["Reference","Version History"],"tags":[]},{"location":"security/","level":1,"title":"Security","text":"

      Security model, agent hardening, and vulnerability reporting.

      ","path":["Security"],"tags":[]},{"location":"security/#security-design","level":3,"title":"Security Design","text":"

      Trust model, what ctx does for security, permission hygiene, state file management, and the log-first audit trail principle. Read first to understand the security boundaries.

      ","path":["Security"],"tags":[]},{"location":"security/#securing-ai-agents","level":3,"title":"Securing AI Agents","text":"

      Defense in depth for unattended AI agents: five layers of protection, each with a known bypass, strength in combination.

      ","path":["Security"],"tags":[]},{"location":"security/#reporting-vulnerabilities","level":3,"title":"Reporting Vulnerabilities","text":"

      How to report a security issue: email, GitHub private reporting, PGP-encrypted submissions, what to include, and the response timeline.

      ","path":["Security"],"tags":[]},{"location":"security/agent-security/","level":1,"title":"Securing AI Agents","text":"","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#defense-in-depth-securing-ai-agents","level":1,"title":"Defense in Depth: Securing AI Agents","text":"","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#the-problem","level":2,"title":"The Problem","text":"

      An unattended AI agent with unrestricted access to your machine is an unattended shell with unrestricted access to your machine.

      This is not a theoretical concern. AI coding agents execute shell commands, write files, make network requests, and modify project configuration. When running autonomously (overnight, in a loop, without a human watching), the attack surface is the full capability set of the operating system user account.

      The risk is not that the AI is malicious. The risk is that the AI is controllable: it follows instructions from context, and context can be poisoned.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#threat-model","level":2,"title":"Threat Model","text":"","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#how-agents-get-compromised","level":3,"title":"How Agents Get Compromised","text":"

      AI agents follow instructions from multiple sources: system prompts, project files, conversation history, and tool outputs. An attacker who can inject content into any of these sources can redirect the agent's behavior.

      Vector How it works Prompt injection via dependencies A malicious package includes instructions in its README, changelog, or error output. The agent reads these during installation or debugging and follows them. Prompt injection via fetched content The agent fetches a URL (documentation, API response, Stack Overflow answer) containing embedded instructions. Poisoned project files A contributor adds adversarial instructions to CLAUDE.md, .cursorrules, or .context/ files. The agent loads these at session start. Self-modification between iterations In an autonomous loop, the agent modifies its own configuration files. The next iteration loads the modified config with no human review. Tool output injection A command's output (error messages, log lines, file contents) contains instructions the agent interprets and follows.","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#what-can-a-compromised-agent-do","level":3,"title":"What Can a Compromised Agent Do","text":"

      Depends entirely on what permissions and access the agent has:

      Access level Potential impact Unrestricted shell Execute any command, install software, modify system files Network access Exfiltrate source code, credentials, or context files to external servers Docker socket Escape container isolation by spawning privileged sibling containers SSH keys Pivot to other machines, push to remote repositories, access production systems Write access to own config Disable its own guardrails for the next iteration","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#the-defense-layers","level":2,"title":"The Defense Layers","text":"

      No single layer is sufficient. Each layer catches what the others miss.

      Layer 1: Soft instructions     (CONSTITUTION.md, playbook)\nLayer 2: Application controls  (permission allowlist, tool restrictions)\nLayer 3: OS-level isolation    (user accounts, filesystem, containers)\nLayer 4: Network controls      (firewall rules, airgap)\nLayer 5: Infrastructure        (VM isolation, resource limits)\n
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-1-soft-instructions-probabilistic","level":3,"title":"Layer 1: Soft Instructions (Probabilistic)","text":"

      Markdown files like CONSTITUTION.md and the Agent Playbook tell the agent what to do and what not to do. These are probabilistic: the agent usually follows them, but there is no enforcement mechanism.

      What it catches: Most common mistakes. An agent that has been told \"never delete production data\" will usually not delete production data.

      What it misses: Prompt injection. A sufficiently crafted injection can override soft instructions. Long context windows dilute attention on rules stated early. Edge cases where instructions are ambiguous.

      Verdict: Necessary but not sufficient. Good for the common case. Do not rely on it for security boundaries.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-2-application-controls-deterministic-at-runtime-mutable-across-iterations","level":3,"title":"Layer 2: Application Controls (Deterministic at Runtime, Mutable across Iterations)","text":"

      AI tool runtimes (Claude Code, Cursor, etc.) provide permission systems: tool allowlists, command restrictions, confirmation prompts.

      For Claude Code, ctx init writes both an allowlist and an explicit deny list into .claude/settings.local.json. The golden images live in internal/assets/permissions/:

      Allowlist (allow.txt): only these tools run without confirmation:

      Bash(ctx:*)\nSkill(ctx-convention-add)\nSkill(ctx-decision-add)\n... # all bundled ctx-* skills\n

      Deny list (deny.txt): these are blocked even if the agent requests them:

      # Dangerous operations\nBash(sudo *)\nBash(git push *)\nBash(git push)\nBash(rm -rf /*)\nBash(rm -rf ~*)\nBash(curl *)\nBash(wget *)\nBash(chmod 777 *)\n\n# Sensitive file reads\nRead(**/.env)\nRead(**/.env.*)\nRead(**/*credentials*)\nRead(**/*secret*)\nRead(**/*.pem)\nRead(**/*.key)\n\n# Sensitive file edits\nEdit(**/.env)\nEdit(**/.env.*)\n

      What it catches: The agent cannot run commands outside the allowlist, and the deny list blocks dangerous operations even if a future allowlist change were to widen access. If rm, curl, sudo, or docker are not allowed and sudo/curl/wget are explicitly denied, the agent cannot invoke them regardless of what any prompt says.

      What it misses: The agent can modify the allowlist itself. In an autonomous loop, if the agent writes to .claude/settings.local.json, and the next iteration loads the modified config, then the protection is effectively lost. The application enforces the rules, but the application reads the rules from files the agent can write.

      Verdict: Strong first layer. Must be combined with self-modification prevention (Layer 3).

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-3-os-level-isolation-deterministic-and-unbypassable","level":3,"title":"Layer 3: OS-Level Isolation (Deterministic and Unbypassable)","text":"

      The operating system enforces access controls that no application-level trick can override. An unprivileged user cannot read files owned by root. A process without CAP_NET_RAW cannot open raw sockets. These are kernel boundaries.

      Control Purpose Dedicated user account No sudo, no privileged group membership (docker, wheel, adm). The agent cannot escalate privileges. Filesystem permissions Project directory writable; everything else read-only or inaccessible. Agent cannot reach other projects, home directories, or system config. Immutable config files CLAUDE.md, .claude/settings.local.json, and .context/CONSTITUTION.md owned by a different user or marked immutable (chattr +i on Linux). The agent cannot modify its own guardrails.

      What it catches: Privilege escalation, self-modification, lateral movement to other projects or users.

      What it misses: Actions within the agent's legitimate scope. If the agent has write access to source code (which it needs to do its job), it can introduce vulnerabilities in the code itself.

      Verdict: Essential. This is the layer that makes the other layers trustworthy.

      OS-level isolation does not make the agent safe; it makes the other layers meaningful.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-4-network-controls","level":3,"title":"Layer 4: Network Controls","text":"

      An agent that cannot reach the internet cannot exfiltrate data. It also cannot ingest new instructions mid-loop from external documents, API responses, or hostile content.

      Scenario Recommended control Agent does not need the internet --network=none (container) or outbound firewall drop-all Agent needs to fetch dependencies Allow specific registries (npmjs.com, proxy.golang.org, pypi.org) via firewall rules. Block everything else. Agent needs API access Allow specific API endpoints only. Use an HTTP proxy with allowlisting.

      What it catches: Data exfiltration, phone-home payloads, downloading additional tools, and instruction injection via fetched content.

      What it misses: Nothing, if the agent genuinely does not need the network. The tradeoff is that many real workloads need dependency resolution, so a full airgap requires pre-populated caches.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-5-infrastructure-isolation","level":3,"title":"Layer 5: Infrastructure Isolation","text":"

      The strongest boundary is a separate machine (or something that behaves like one).

      The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.

      Containers (Docker, Podman):

      docker run --rm \\\n  --network=none \\\n  --cap-drop=ALL \\\n  --memory=4g \\\n  --cpus=2 \\\n  -v /path/to/project:/workspace \\\n  -w /workspace \\\n  your-dev-image \\\n  ./loop.sh\n

      Docker Socket Is Sudo Access

      Critical: never mount the Docker socket (/var/run/docker.sock).

      An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox.

      Use rootless Docker or Podman to eliminate this escalation path.

      Virtual machines: The strongest isolation. The guest kernel has no visibility into the host OS. No shared folders, no filesystem passthrough, no SSH keys to other machines.

      Resource limits: CPU, memory, and disk quotas prevent a runaway agent from consuming all resources. Use ulimit, cgroup limits, or container resource constraints.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      A defense-in-depth setup for overnight autonomous runs:

      Layer Implementation Stops Soft instructions CONSTITUTION.md with \"never delete tests\", \"always run tests before committing\" Common mistakes (probabilistic) Application allowlist .claude/settings.local.json with explicit tool permissions Unauthorized commands (deterministic within runtime) Immutable config chattr +i on CLAUDE.md, .claude/, CONSTITUTION.md Self-modification between iterations Unprivileged user Dedicated user, no sudo, no docker group Privilege escalation Container --cap-drop=ALL --network=none, rootless, no socket mount Host escape, network exfiltration Resource limits --memory=4g --cpus=2, disk quotas Resource exhaustion

      Each layer is straightforward: The strength is in the combination.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#common-mistakes","level":2,"title":"Common Mistakes","text":"

      \"I'll just use --dangerously-skip-permissions\": This disables Layer 2 entirely. Without Layers 3-5, you have no protection at all. Only use this flag inside a properly isolated container or VM.

      \"The agent is sandboxed in Docker\": A Docker container with the Docker socket mounted, running as root, with --privileged, and full network access is not sandboxed. It is a root shell with extra steps.

      \"CONSTITUTION.md says not to do that\": Markdown is a suggestion. It works most of the time. It is not a security boundary. Do not use it as one.

      \"I reviewed the CLAUDE.md, it's fine\": The agent can modify CLAUDE.md during iteration N. Iteration N+1 loads the modified version. Unless the file is immutable, your review is stale.

      \"The agent only has access to this one project\": Does the project directory contain .env files, SSH keys, API tokens, or credentials? Does it have a .git/config with push access to a remote? Filesystem isolation means isolating what is in the directory too.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-security-considerations","level":2,"title":"Team Security Considerations","text":"

      When multiple developers share a .context/ directory, security considerations extend beyond single-agent hardening.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#code-review-for-context-files","level":3,"title":"Code Review for Context Files","text":"

      Treat .context/ changes like code changes. Context files influence agent behavior (a modified CONSTITUTION.md or CONVENTIONS.md changes what every agent on the team will do next session). Review them in PRs with the same scrutiny you apply to production code.

      Watch for:

      • Weakened constitutional rules (removed constraints, softened language)
      • New decisions that contradict existing ones without acknowledging it
      • Learnings that encode incorrect assumptions
      • Task additions that bypass the team's prioritization process
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#gitignore-patterns","level":3,"title":"Gitignore Patterns","text":"

      ctx init configures .gitignore automatically, but verify these patterns are in place:

      • Always gitignored: .ctx.key (encryption key), .context/logs/, .context/journal/
      • Team decision: scratchpad.enc (encrypted, safe to commit for shared scratchpad state); .gitignore if scratchpads are personal
      • Never committed: .env, credentials, API keys (enforced by drift secret detection)
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#multi-developer-context-sharing","level":3,"title":"Multi-Developer Context Sharing","text":"

      CONSTITUTION.md is the shared contract. All team members and their agents inherit it. Changes require team consensus, not unilateral edits.

      When multiple agents write to the same context files concurrently (e.g., two developers adding learnings simultaneously), git merge conflicts are expected. Resolution is typically additive: accept both additions. Destructive resolution (dropping one side) loses context.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-conventions-for-context-management","level":3,"title":"Team Conventions for Context Management","text":"

      Establish and document:

      • Who reviews context changes: Same reviewers as code, or a designated context owner?
      • How to resolve conflicting decisions: If two sessions record contradictory decisions, which wins? Default: the later one must explicitly supersede the earlier one with rationale.
      • Frequency of context maintenance: Weekly ctx drift checks, monthly consolidation passes, archival after each milestone.
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#checklist","level":2,"title":"Checklist","text":"

      Before running an unattended AI agent:

      • Agent runs as a dedicated unprivileged user (no sudo, no docker group)
      • Agent's config files are immutable or owned by a different user
      • Permission allowlist restricts tools to the project's toolchain
      • Container drops all capabilities (--cap-drop=ALL)
      • Docker socket is NOT mounted
      • Network is disabled or restricted to specific domains
      • Resource limits are set (memory, CPU, disk)
      • No SSH keys, API tokens, or credentials are accessible to the agent
      • Project directory does not contain .env or secrets files
      • Iteration cap is set (--max-iterations)
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#further-reading","level":2,"title":"Further Reading","text":"
      • Running an Unattended AI Agent: the ctx recipe for autonomous loops, including step-by-step permissions and isolation setup
      • Security: ctx's own trust model and vulnerability reporting
      • Autonomous Loops: full documentation of the loop pattern, prompt templates, and troubleshooting
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/design/","level":1,"title":"Security Design","text":"

      How ctx thinks about security: trust boundaries, what the system does and does not do for you, the engineering principle behind the audit trail, and the permission hygiene workflow.

      For vulnerability disclosure, see Reporting Vulnerabilities.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#trust-model","level":2,"title":"Trust Model","text":"

      ctx operates within a single trust boundary: the local filesystem.

      The person who authors .context/ files is the same person who runs the agent that reads them. There is no remote input, no shared state, and no server component.

      This means:

      • ctx does not sanitize context files for prompt injection. This is a deliberate design choice, not an oversight. The files are authored by the developer who owns the machine: sanitizing their own instructions back to them would be counterproductive.
      • If you place adversarial instructions in your own .context/ files, your agent will follow them. This is expected behavior. You control the context; the agent trusts it.

      Shared Repositories

      In shared repositories, .context/ files should be reviewed in code review (the same way you would review CI/CD config or Makefiles). A malicious contributor could add harmful instructions to CONSTITUTION.md or TASKS.md.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#what-ctx-does-for-security","level":2,"title":"What ctx Does for Security","text":"

      ctx is designed with security in mind:

      • No secrets in context: The constitution explicitly forbids storing secrets, tokens, API keys, or credentials in .context/ files.
      • Local only: ctx runs entirely locally with no external network calls.
      • No code execution: ctx reads and writes Markdown files only; it does not execute arbitrary code.
      • Git-tracked: Core context files are meant to be committed, so they should never contain sensitive data. Exception: sessions/ and journal/ contain raw conversation data and should be gitignored.
      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#permission-hygiene","level":2,"title":"Permission Hygiene","text":"

      Claude Code evaluates permissions in deny → ask → allow order. ctx init automatically populates permissions.deny with rules that block dangerous operations before the allow list is ever consulted.

      Default deny rules block:

      • sudo, git push, rm -rf /, rm -rf ~, curl, wget, chmod 777
      • Read / Edit of .env, credentials, secrets, .pem, .key files

      Even with deny rules in place, the allow list accumulates one-off permissions over time. Periodically review for:

      • Destructive commands: git reset --hard, git clean -f, etc.
      • Config injection vectors: permissions that allow modifying files controlling agent behavior (CLAUDE.md, settings.local.json).
      • Broad wildcards: overly permissive patterns that pre-approve more than intended.

      For the full hygiene workflow, see the Claude Code Permission Hygiene recipe.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#state-file-management","level":2,"title":"State File Management","text":"

      Hook state files (throttle markers, prompt counters, pause markers) are stored in .context/state/, which is project-scoped and gitignored. State files are automatically managed by the hooks that create them; no manual cleanup is needed.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#log-first-audit-trail","level":2,"title":"Log-First Audit Trail","text":"

      The event log (.context/state/events.jsonl) is the authoritative record of what ctx hooks did during a session. Several audit-adjacent features depend on that log being trustworthy, not merely best-effort:

      • ctx event / ctx system view-events replays session history from the log.
      • Webhook notifications give operators a real-time signal that assumes every notification corresponds to a logged event.
      • Drift, freshness, and map-staleness checks count events over time and surface regressions.

      A log that silently drops entries while the rest of the system claims success is worse than no log at all: operators see a green TUI and a webhook notification and conclude \"it happened,\" even when the audit trail never landed. The codebase treats this as a correctness problem, not a UX polish problem.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#the-rule","level":3,"title":"The Rule","text":"

      Any code path that emits an observable side effect (webhook, stdout marker, throttle-file touch, state mutation) must append the corresponding event-log entry first and gate the side effect on the append succeeding. If the log write fails, the side effect must not fire.

      In code, this shape:

      if appendErr := event.Append(channel, msg, sessionID, ref); appendErr != nil {\n    return appendErr // do NOT send the webhook or touch the marker\n}\nif sendErr := notify.Send(channel, msg, sessionID, ref); sendErr != nil {\n    return sendErr\n}\n// downstream side effects (marker touch, stdout, etc.)\n

      The nudge.Relay helper in internal/cli/system/core/nudge enforces this for the common \"log + webhook\" pair. Hook Run functions that compose their own sequence (session_event, heartbeat, several check_* hooks) follow the same ordering explicitly.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#known-gaps","level":3,"title":"Known Gaps","text":"
      • Nudge webhooks have no log channel. nudge.EmitAndRelay sends a \"nudge\" notification before the \"relay\" event is logged. The nudge leg is fire-and-forget because no event-log channel records nudges today. A future refactor may add one; until then this is the one documented exception.
      • ctx agent --cooldown and ctx doctor propagate rather than gate. They surface real errors to the caller (usually Cobra) rather than deciding what to do with them locally. Editors that invoke these commands may display errors in an ugly way; the ugliness is the correct signal (something persisted is broken), not a defect to smooth over.
      • Verbose hook logs in core/log.Message stay best-effort. That logger captures per-hook activity (how many prompts, which percent, etc.) for debugging; it is NOT the event audit trail. Its failures go to stderr via log/warn.Warn rather than propagating, because losing an operational log line is not a correctness problem.
      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#background","level":3,"title":"Background","text":"

      The error returns on event.Append, io.AppendBytes, nudge.Relay, and cooldown.Active / cooldown.TouchTombstone were introduced as part of the resolver-tightening refactor. Before that change, most hook paths called these helpers and silently discarded their errors. The principle above was extracted from the observation that every user-visible correctness problem hit during the refactor traced back to some function saying \"this succeeded\" when the underlying write never landed.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#best-practices","level":2,"title":"Best Practices","text":"
      1. Review before committing: Always review .context/ files before committing.
      2. Use .gitignore: If you must store sensitive notes locally, add them to .gitignore.
      3. Drift detection: Run ctx drift to check for potential issues.
      4. Permission audit: Review .claude/settings.local.json after busy sessions.
      ","path":["Security","Security Design"],"tags":[]},{"location":"security/hub/","level":1,"title":"Hub Security Model","text":"","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#ctx-hub-security-model","level":1,"title":"ctx Hub: Security Model","text":"

      What the hub defends against, what it does not defend against, and the concrete mechanisms in play.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#threat-model","level":2,"title":"Threat Model","text":"

      The hub is designed for trusted cross-project knowledge sharing within a team or homelab. It assumes:

      • The hub host is trusted. Anyone with root on that box can read every entry ever published.
      • Network is semi-trusted. Hub traffic is gRPC over TCP; TLS is strongly recommended but not mandatory.
      • Client machines are trusted enough to hold a per-project client token. Losing a client token is roughly equivalent to losing an API key: scoped damage, not total compromise.
      • Entry content is not secret. Decisions, learnings, and conventions may be indexed by AI agents, rendered in docs, shared across projects. Do not push credentials or PII into the hub.

      The hub is not a secure messaging system, a secrets store, or a compliance-grade audit log. If your threat model needs those, use a dedicated tool and keep the hub for knowledge sharing.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#mechanisms","level":2,"title":"Mechanisms","text":"","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#bearer-tokens","level":3,"title":"Bearer Tokens","text":"

      All RPCs except Register require a bearer token in gRPC metadata. Two kinds of tokens exist:

      Kind Format Scope Lifetime Admin token ctx_adm_... Register new projects Manual rotate Client token ctx_cli_... Publish, Sync, Listen, Status Project lifetime

      Tokens are compared in constant time (crypto/subtle) to prevent timing oracles, and looked up via an O(1) hash map so the comparison cost does not depend on the total number of registered clients.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#client-side-encryption-at-rest","level":3,"title":"Client-Side Encryption at Rest","text":"

      .context/.connect.enc stores the client token and hub address, encrypted with AES-256-GCM using the same scheme the notification subsystem uses. The key is derived from ctx's local keyring (see internal/crypto).

      An attacker with read access to the project directory cannot learn the client token without also breaking ctx's local keyring.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#hub-side-token-storage","level":3,"title":"Hub-Side Token Storage","text":"

      Tokens Are Stored in Plaintext on the Hub Host

      <data-dir>/clients.json currently stores client tokens verbatim, not hashed. Anyone with read access to the hub's data directory sees every registered client's token and can impersonate any project that has ever registered.

      Mitigations today:

      • Run the hub as an unprivileged user and lock the data directory with chmod 700 <data-dir>.
      • Use the systemd unit in Operations, which enables ProtectSystem=strict, NoNewPrivileges=true, and a dedicated user.
      • Never expose <data-dir> over NFS, SMB, or shared filesystems.
      • Treat <data-dir> the same way you'd treat /etc/shadow: back it up encrypted, never check it into version control.

      Hashing clients.json and moving to keyring-backed storage is tracked as a follow-up in the PR #60 task group. Until that lands, assume a hub host compromise equals total hub compromise.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#input-validation","level":3,"title":"Input Validation","text":"

      Every published entry is validated before it touches the log:

      • Type must be one of: decision, learning, convention, task. Unknown types are rejected.
      • ID and Origin are required and non-empty.
      • Content size is capped at 1 MB. Reasonable for text, hostile for attempts to fill the disk.
      • Duplicate project registration is rejected; a client that replays an old Register call gets an error, not a second token.
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#no-script-execution","level":3,"title":"No Script Execution","text":"

      The hub never interprets entry content. There is no expression language, no template evaluation, no markdown rendering at ingest. Content is stored as bytes and fanned out to clients verbatim.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#audit-trail","level":3,"title":"Audit Trail","text":"

      entries.jsonl is append-only. Every accepted publish is recorded with the publishing project's origin tag and sequence number. Nothing is ever deleted by the hub; retention is managed manually by the operator (see log rotation).

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#what-the-hub-does-not-defend-against","level":2,"title":"What the Hub Does Not Defend Against","text":"
      • Untrusted entry senders. A client with a valid token can publish anything (within the 1 MB cap). There is no content validation beyond shape.
      • Denial of service from a registered client. A misbehaving client can publish until disk is full. Monitor entries.jsonl growth.
      • Network eavesdropping without TLS. Plain gRPC leaks entry content and tokens. Use a TLS-terminating reverse proxy (see Multi-machine recipe).
      • Host compromise. Root on the hub host = access to every entry and every token. Harden the host.
      • Accidental secret upload. The hub will happily fan out a decision containing an API key. Sanitize content before publishing.
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#operational-hardening-checklist","level":2,"title":"Operational Hardening Checklist","text":"
      • Run the hub as an unprivileged user with NoNewPrivileges=true and ProtectSystem=strict (see the systemd unit in Operations).
      • Terminate TLS in front of the hub for anything beyond a trusted LAN.
      • Restrict the listen port with firewall rules to the client subnet only.
      • Back up <data-dir>/admin.token to a secrets manager; do not leave it in shell history.
      • Rotate the admin token when a team member with access leaves. Client tokens keep working across rotations.
      • Monitor entries.jsonl growth; alert on sudden spikes.
      • Run NTP on all clients to prevent entry-timestamp skew.
      • Do not publish from machines you do not trust.
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#responsible-disclosure","level":2,"title":"Responsible Disclosure","text":"

      Security issues in the hub follow the same process as the rest of ctx; see Reporting.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#see-also","level":2,"title":"See Also","text":"
      • ctx Hub Operations
      • ctx Hub failure modes
      • HA cluster recipe
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/reporting/","level":1,"title":"Reporting Vulnerabilities","text":"

      Disclosure process for security issues in ctx. For the broader security model (trust boundaries, audit trail, permission hygiene), see Security Design.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#reporting-vulnerabilities","level":2,"title":"Reporting Vulnerabilities","text":"

      At ctx we take security very seriously.

      If you discover a security vulnerability in ctx, please report it responsibly.

      Do NOT open a public issue for security vulnerabilities.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#email","level":3,"title":"Email","text":"

      Send details to security@ctx.ist.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#github-private-reporting","level":3,"title":"GitHub Private Reporting","text":"
      1. Go to the Security tab;
      2. Click \"Report a Vulnerability\";
      3. Provide a detailed description.
      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#encrypted-reports-optional","level":3,"title":"Encrypted Reports (Optional)","text":"

      If your report contains sensitive details (proof-of-concept exploits, credentials, or internal system information), you can encrypt your message with our PGP key:

      • In-repo: SECURITY_KEY.asc
      • Keybase: keybase.io/alekhinejose
      # Import the key\ngpg --import SECURITY_KEY.asc\n\n# Encrypt your report\ngpg --armor --encrypt --recipient security@ctx.ist report.txt\n

      Encryption is optional. Unencrypted reports to security@ctx.ist or via GitHub Private Reporting are perfectly fine.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#what-to-include","level":3,"title":"What to Include","text":"
      • Description of the vulnerability,
      • Steps to reproduce,
      • Potential impact,
      • Suggested fix (if any).
      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#attribution","level":2,"title":"Attribution","text":"

      We appreciate responsible disclosure and will acknowledge security researchers who report valid vulnerabilities (unless they prefer to remain anonymous).

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#response-timeline","level":2,"title":"Response Timeline","text":"

      Open Source, Best-Effort Timelines

      ctx is a volunteer-maintained open source project.

      The timelines below are guidelines, not guarantees, and depend on contributor availability.

      We will address security reports on a best-effort basis and prioritize them by severity.

      Stage Timeframe Acknowledgment Within 48 hours Initial assessment Within 7 days Resolution target Within 30 days (depending on severity)","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"thesis/","level":1,"title":"Context as State","text":"","path":["The Thesis"],"tags":[]},{"location":"thesis/#a-persistence-layer-for-human-ai-cognition","level":2,"title":"A Persistence Layer for Human-AI Cognition","text":"

      Volkan Özçelik - me@volkan.io

      February 2026

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#abstract","level":3,"title":"Abstract","text":"

      As AI tools evolve from code-completion utilities into reasoning collaborators, the knowledge that governs their behavior becomes as important as the code they produce; yet, that knowledge is routinely discarded at the end of every session.

      AI-assisted development systems assemble context at prompt time using heuristic retrieval from mutable sources: recent files, semantic search results, session history. These approaches optimize relevance at the moment of generation but do not persist the cognitive state that produced decisions. Reasoning is not reproducible, intent is lost across sessions, and teams cannot audit the knowledge that constrains automated behavior.

      This paper argues that context should be treated as deterministic, version-controlled state rather than as a transient query result. We ground this argument in three sources of evidence: a landscape analysis of 17 systems spanning AI coding assistants, agent frameworks, and knowledge stores; a taxonomy of five primitive categories that reveals irrecoverable architectural trade-offs; and an experience report from ctx, a persistence layer for AI-assisted development, which developed itself using its own persistence model across 389 sessions over 33 days. We define a three-tier model for cognitive state: authoritative knowledge, delivery views, and ephemeral state. Then we present six design invariants empirically validated by 56 independent rejection decisions observed across the analyzed landscape. We show that context determinism applies to assembly, not to model output, and that the curation cost this model requires is offset by compounding returns in reproducibility, auditability, and team cognition.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#1-introduction","level":2,"title":"1. Introduction","text":"

      The introduction of large language models into software development has shifted the primary interface from code execution to interactive reasoning. In this environment, the correctness of an output depends not only on source code but on the context supplied to the model: the conventions, decisions, architectural constraints, and domain knowledge that bound the space of acceptable responses.

      Current systems treat context as a query result assembled at the moment of interaction. A developer begins a session; the tool retrieves what it estimates to be relevant from chat history, recent files, and vector stores; the model generates output conditioned on this transient assembly; the session ends, and the context evaporates. The next session begins the cycle again.

      This model has improved substantially over the past year. CLAUDE.md files, Cursor rules, Copilot's memory system, and tools such as Mem0, Letta, and Kindex each address aspects of the persistence problem. Yet across 17 systems we analyzed spanning AI coding assistants, agent frameworks, autonomous coding agents, and purpose-built knowledge stores, no system provides all five of the following properties simultaneously: deterministic context assembly, human-readable file-based persistence, token-budgeted delivery, a single-binary core with zero required runtime dependencies for the persistence path, and local-first operation.

      This paper does not propose a universal replacement for retrieval-centric workflows. It defines a persistence layer (embodied in ctx (https://ctx.ist)) whose advantages emerge under specific operational conditions: when reproducibility is a requirement, when knowledge must outlive sessions and individuals, when teams require shared cognitive authority, or when offline operation is necessary.

      The trade-offs (manual curation cost, reduced automatic recall, coarser granularity) are intentional and mirror the trade-offs accepted by systems that favor reproducibility over convenience, such as reproducible builds and immutable infrastructure 1 6.

      The contribution is threefold: a three-tier model for cognitive state that resolves the ambiguity between authoritative knowledge and ephemeral session artifacts; six design invariants empirically grounded in a cross-system landscape analysis; and an experience report demonstrating that the model produces compounding returns when applied to its own development.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#2-the-limits-of-prompt-time-context","level":2,"title":"2. The Limits of Prompt-Time Context","text":"

      Prompt-time assembly pipelines typically consist of corpus selection, retrieval, ranking, and truncation. These pipelines are probabilistic and time-dependent, producing three failure modes that compound over the lifetime of a project.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#21-non-reproducibility","level":3,"title":"2.1 Non-Reproducibility","text":"

      If context is derived from mutable sources using heuristic ranking, identical requests at different times receive different inputs. A developer who asks \"What is our authentication strategy?\" on Tuesday may receive a different context window than the same question on Thursday: Not because the strategy changed, but because the retrieval heuristic surfaced different fragments.

      Reproducibility (the ability to reconstruct the exact inputs that produced a given output) is a foundational property of reliable systems. Its loss in AI-assisted development mirrors the historical evolution from ad-hoc builds to deterministic build systems 1 2. The build community learned that when outputs depend on implicit state (environment variables, system clocks, network-fetched dependencies), debugging becomes archaeology. The same principle applies when AI outputs depend on non-deterministic context retrieval.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#22-opaque-knowledge","level":3,"title":"2.2 Opaque Knowledge","text":"

      Embedding-based memory increases recall but reduces inspectability. When a vector store determines that a code snippet is \"similar\" to the current query, the ranking function is opaque: the developer cannot inspect why that snippet was chosen, whether a more relevant artifact was excluded, or whether the ranking will remain stable. This prevents deterministic debugging, policy auditing, and causal attribution (properties that information retrieval theory identifies as fundamental trade-offs of probabilistic ranking) 3.

      In practice, this opacity manifests as a compliance ceiling. In our experience developing a context management system (detailed in Section 7), soft instructions (directives that ask an AI agent to read specific files or follow specific procedures) achieve approximately 75-85% compliance. The remaining 15-25% represents cases where the agent exercises judgment about whether the instruction applies, effectively applying a second ranking function on top of the explicit directive. When 100% compliance is required, instruction is insufficient; the content must be injected directly, removing the agent's option to skip it.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#23-loss-of-intent","level":3,"title":"2.3 Loss of Intent","text":"

      Session transcripts record interaction but not cognition. A transcript captures what was said but not which assumptions were accepted, which alternatives were rejected, or which constraints governed the decision. The distinction matters: a decision to use PostgreSQL recorded as a one-line note (\"Use PostgreSQL\") teaches a model what was decided; a structured record with context, rationale, and consequences teaches it why (and why is what prevents the model from unknowingly reversing the decision in a future session) 4.

      Session transcripts provide history. Cognitive state requires something more: the persistent, structured representation of the knowledge required for correct decision-making.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#3-cognitive-state-a-three-tier-model","level":2,"title":"3. Cognitive State: A Three-Tier Model","text":"","path":["The Thesis"],"tags":[]},{"location":"thesis/#31-definitions","level":3,"title":"3.1 Definitions","text":"

      We define cognitive state as the authoritative, persistent representation of the knowledge required for correct decision-making within a project. It is human-authored or human-ratified, versioned, inspectable, and reproducible. It is distinct from logs, transcripts, retrieval results, and model-generated summaries.

      Previous formulations of this idea have treated cognitive state as a monolithic concept. In practice, a three-tier model better captures the operational reality:

      Tier 1: Authoritative State: The canonical knowledge that the system treats as ground truth. In a concrete implementation, this corresponds to a set of human-curated files with defined schemas: a constitution (inviolable rules), conventions (code patterns), an architecture document (system structure), decision records (choices with rationale), learnings (captured experience), a task list (current work), a glossary (domain terminology), and an agent playbook (operating instructions). Each file has a single purpose, a defined lifecycle, and a distinct update frequency. Authoritative state is version-controlled alongside code and reviewed through the same mechanisms (diffs, pull requests, blame annotations).

      Tier 2: Delivery Views: Derived representations of authoritative state, assembled for consumption by a model. A delivery view is produced by a deterministic assembly function that takes the authoritative state, a token budget, and an inclusion policy as inputs and produces a context window as output. The same authoritative state, budget, and policy must always produce the same delivery view. Delivery views are ephemeral (they exist only for the duration of a session), but their construction is reproducible.

      Tier 3: Ephemeral State: Session transcripts, scratchpad notes, draft journal entries, and other artifacts that exist during or immediately after a session but are not authoritative. Ephemeral state is the raw material from which authoritative state may be extracted through human review, but it is never consumed directly by the assembly function.

      This three-tier model resolves confusion present in earlier formulations: the claim that AI output is a deterministic function of the repository state. The corrected claim is that context selection is deterministic (the delivery view is a function of authoritative state), but model output remains stochastic, conditioned on the deterministic context. Formally:

      delivery_view = assemble(authoritative_state, budget, policy)\noutput = model(delivery_view)   # stochastic\n

      The persistence layer's contribution is making assemble reproducible, not making model deterministic.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#32-separation-of-concerns","level":3,"title":"3.2 Separation of Concerns","text":"

      The decision to separate authoritative state into distinct files with distinct purposes is not cosmetic. Different types of knowledge have different lifecycles:

      Knowledge Type Update Frequency Read Frequency Load Priority Example Constitution Rarely Every session Always \"Never commit secrets to git\" Tasks Every session Session start Always \"Implement token budget CLI flag\" Conventions Weekly Before coding High \"All errors use structured logging with severity levels\" Decisions When decided When questioning Medium \"Use PostgreSQL over MySQL (see ADR-003)\" Learnings When learned When stuck Medium \"Hook scripts >50ms degrade interactive UX\" Architecture When changed When designing On demand \"Three-layer pipeline: ingest → enrich → assemble\" Journal Every session Rarely Never auto \"Session 247: Removed dead-end session copy layer\"

      A monolithic context file would force the assembly function to load everything or nothing. Separation enables progressive disclosure: the minimum context that matters for the current moment, with the option to load more when needed. A normal session loads the constitution, tasks, and conventions; a deep investigation loads decision history and journal entries from specific dates.

      The budget mechanism is the constraint that makes separation valuable. Without a budget, the default behavior is to load everything, which destroys the attention density that makes loaded context useful. With a budget, the assembly function must prioritize ruthlessly: constitution first (always full), then tasks and conventions (budget-capped), then decisions and learnings (scored by recency). Entries that do not fit receive title-only summaries rather than being silently dropped (an application of the \"tell me what you don't know\" pattern identified independently by four systems in our landscape analysis).

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#4-design-invariants","level":2,"title":"4. Design Invariants","text":"

      The following six invariants define the constraints that a cognitive state persistence layer must satisfy. They are not axioms chosen a priori; they are empirically grounded properties whose violation was independently identified as producing complexity costs across the 17 systems we analyzed.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-1-markdown-on-filesystem-persistence","level":3,"title":"Invariant 1: Markdown-on-Filesystem Persistence","text":"

      Context files must be human-readable, git-diffable, and editable with any text editor. No database. No binary storage.

      Validation: 11 independent rejection decisions across the analyzed landscape protected this property. Systems that adopted embedded records, binary serialization, or knowledge graphs as their core primitive consistently traded away the ability for a developer to run cat DECISIONS.md and understand the system's knowledge. The inspection cost of opaque storage compounds over the lifetime of a project: every debugging session, every audit, every onboarding conversation requires specialized tooling to access knowledge that could have been a text file.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-2-zero-runtime-dependencies","level":3,"title":"Invariant 2: Zero Runtime Dependencies","text":"

      The tool must work with no installed runtimes, no running services, and no API keys for core functionality.

      Validation: 13 independent rejection decisions protected this property (the most frequently defended invariant). Systems that required databases (PostgreSQL, SQLite, Redis), embedding models, server daemons, container runtimes, or cloud APIs for core operation introduced failure modes proportional to their dependency count. A persistence layer that depends on infrastructure is not a persistence layer; it is a service. Services have uptime requirements, version compatibility matrices, and operational costs that simple file operations do not.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-3-deterministic-context-assembly","level":3,"title":"Invariant 3: Deterministic Context Assembly","text":"

      The same files plus the same budget must produce the same output. No embedding-based retrieval, no LLM-driven selection, no wall-clock-dependent scoring in the assembly path.

      Validation: 6 independent rejection decisions protected this property. Non-deterministic assembly (whether from embedding variance, LLM-based selection, or time-dependent scoring) destroys the ability to reproduce a context window and therefore to diagnose why a model produced a given output. Determinism in the assembly path is what makes the persistence layer auditable.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-4-human-authority-over-persistent-state","level":3,"title":"Invariant 4: Human Authority over Persistent State","text":"

      The agent may propose changes to context files but must not unilaterally modify them. All persistent changes go through human-reviewable git commits.

      Validation: 6 independent rejection decisions protected this property. Systems that allowed agents to self-modify their memory (writing freeform notes, auto-pruning old entries, generating summaries as ground truth) consistently produced lower-quality persistent context than systems that enforced human review. Structure is a feature, not a limitation: across the landscape, the pattern \"structured beats freeform\" was independently discovered by four systems that evolved from freeform LLM summaries to typed schemas with required fields.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-5-local-first-air-gap-capable","level":3,"title":"Invariant 5: Local-First, Air-Gap Capable","text":"

      Core functionality must work offline with no network access. Cloud services may be used for optional features but never for core context management.

      Validation: 7 independent rejection decisions protected this property. Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or disaster-recovery scenarios. A filesystem-native model continues to function under all conditions where the repository is accessible.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-6-no-default-telemetry","level":3,"title":"Invariant 6: No Default Telemetry","text":"

      Any analytics, if ever added, must be strictly opt-in.

      Validation: 4 independent rejection decisions protected this property. Default telemetry erodes the trust model that a persistence layer depends on. If developers must trust the system with their architectural decisions, operational learnings, and project constraints, the system cannot simultaneously be reporting usage data to external services.

      These six invariants collectively define a design space. Each feature proposal can be evaluated against them: a feature that violates any invariant is rejected regardless of how many other systems implement it. The discipline of constraint (refusing to add capabilities that compromise foundational properties) is itself an architectural contribution. Across the 17 analyzed systems, 56 patterns were explicitly rejected for violating these invariants. The rejection count per invariant (11, 13, 6, 6, 7, 4) provides a rough measure of each property's vulnerability to architectural erosion. A representative sample of these rejections is provided in Appendix A.1

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#5-landscape-analysis","level":2,"title":"5. Landscape Analysis","text":"

      The 17 systems were selected to cover the architectural design space rather than to achieve completeness. Each included system satisfies three criteria: it represents a distinct architectural primitive for AI-assisted development, it is actively maintained or widely referenced, and it provides sufficient public documentation or source code for architectural inspection. The goal was to ensure that every major category of primitive (document, embedded record, state snapshot, event/message, construction/derivation) was represented by multiple systems, enabling cross-system pattern detection.

      The resulting set spans six categories: AI coding assistants (Continue, Sourcegraph/Cody, Aider, Claude Code), AI agent frameworks (CrewAI, AutoGen, LangGraph, LlamaIndex, Letta/MemGPT), autonomous coding agents (OpenHands, Sweep), session provenance tools (Entire), data versioning systems (Dolt, Pachyderm), pipeline/build systems (Dagger), and purpose-built knowledge stores (QubicDB, Kindex). Each system was analyzed from its source code and documentation, producing 34 individual analysis artifacts (an architectural profile and a set of insights per system) that yielded 87 adopt/adapt recommendations, 56 explicit rejection decisions, and 52 watch items.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#51-primitive-taxonomy","level":3,"title":"5.1 Primitive Taxonomy","text":"

      Every system in the AI-assisted development landscape operates on a core primitive: an atomic unit around which the entire architecture revolves. Our analysis of 17 systems reveals five categories of primitives, each making irrecoverable trade-offs:

      Group A: Document/File Primitives: Human-readable documents as the primary unit. Documents are authored by humans, version-controlled in git, and consumed by AI tools. The invariant of this group is that the primitive is always human-readable and version-controllable with standard tools. Three systems participate in this pattern: the system described in this paper as a pure expression, and Continue (via its rules directory) and Claude Code (via CLAUDE.md files) as partial participants: both use document-based context as an input but organize around different core primitives.

      Group B: Embedded Record Primitives: Vector-embedded records stored with numerical embeddings for similarity search, metadata for filtering, and scoring mechanisms for ranking. Five systems use this approach (LlamaIndex, CrewAI, Letta/MemGPT, QubicDB, Kindex). The invariant is that the primitive requires an embedding model or vector database for core operations: a dependency that precludes offline and air-gapped use.

      Group C: State Snapshot Primitives: Point-in-time captures of the complete system state. The invariant is that any past state can be reconstructed at any historical point. Three systems use this approach (LangGraph, Entire, Dolt).

      Group D: Event/Message Primitives: Sequential events or messages forming an append-only log with causal relationships. Four systems use this approach (OpenHands, AutoGen, Claude Code, Sweep). The invariant is temporal ordering and append-only semantics.

      Group E: Construction/Derivation Primitives: Derived or constructed values that encode how they were produced. The invariant is that the primitive is a function of its inputs; re-executing the same inputs produces the same primitive. Three systems use this approach (Dagger, Pachyderm, Aider).

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#52-comparison-matrix","level":3,"title":"5.2 Comparison Matrix","text":"

      The five primitive categories differ along seven dimensions:

      Property Document Embedded Record State Snapshot Event/Message Construction Human-readable Yes No Varies Partially No Version-controllable Yes No Varies Yes Yes Queryable by meaning No Yes No No No Rewindable Via git No Yes Yes (replay) Yes Deterministic Yes No Yes Yes Yes Zero-dependency Yes No Varies Varies Varies Offline-capable Yes No Varies Varies Yes

      The document primitive is the only one that simultaneously satisfies human-readability, version-controllability, determinism, zero dependencies, and offline capability. This is not because documents are superior in general (embedded records provide semantic queryability that documents lack) but because the combination of all five properties is what the persistence layer requires. The choice between primitive categories is not a matter of capability but of which properties are considered invariant.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#53-convergent-patterns","level":3,"title":"5.3 Convergent Patterns","text":"

      Across the 17 analyzed systems, six design patterns were independently discovered. These convergent patterns carry extra validation weight because they emerged from different problem spaces:

      Pattern 1: \"Tell me what you don't know\": When context is incomplete, explicitly communicate to the model what information is missing and what confidence level the provided context represents. Four systems independently converged on this pattern: inserting skip markers, tracking evidence gaps, annotating provenance, or naming output quality tiers.

      Pattern 2: \"Freshness matters\": Information relevance decreases over time. Three systems independently chose exponential decay with different half-lives (30 days, 90 days, and LRU ordering). Static priority ordering with no time dimension leaves relevant recent knowledge at the same priority as stale entries. This pattern is in productive tension with the persistence model's emphasis on determinism: the claim is not that time-dependence is irrelevant, but that it belongs in the curation step (a human deciding to consolidate or archive stale entries) rather than in the assembly function (an algorithm silently down-ranking entries based on age).

      Pattern 3: \"Content-address everything\": Compute a hash of content at creation time for deduplication, cache invalidation, integrity verification, and change detection. Five systems independently implement content hashing, each discovering it solves different problems 5.

      Pattern 4: \"Structured beats freeform\": When capturing knowledge or session state, a structured schema with required fields produces more useful data than freeform text. Four systems evolved from freeform summaries to typed schemas: one moving from LLM-generated prose to a structured condenser with explicit fields for completed tasks, pending tasks, and files modified.

      Pattern 5: \"Protocol convergence\": The Model Context Protocol (MCP) is emerging as a standard tool integration layer. Nine of 17 systems support it, spanning every category in the analysis. MCP's significance for the persistence model is that it provides a transport mechanism for context delivery without dictating how context is stored or assembled. This makes the approach compatible with both retrieval-centric and persistence-centric architectures.

      Pattern 6: \"Human-in-the-loop for memory\": Critical memory decisions should involve human judgment. Fully automated memory management produces lower-quality persistent context than human-reviewed systems. Four systems independently converged on variants of this pattern: ceremony-based consolidation, interrupt/resume for human input, confirmation mode for high-risk actions, and separated \"think fast\" vs. \"think slow\" processing paths.

      Pattern 6 directly validates the ceremony model described in this paper. The persistence layer requires human curation not because automation is impossible, but because the quality of persistent knowledge degrades when the curation step is removed. The improvement opportunity is to make curation easier, not to automate it away.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#6-worked-example-architectural-decision-under-two-models","level":2,"title":"6. Worked Example: Architectural Decision under Two Models","text":"

      We now instantiate the three-tier model in a concrete system (ctx) and illustrate the difference between prompt-time retrieval and cognitive state persistence using a real scenario from its development.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#61-the-problem","level":3,"title":"6.1 The Problem","text":"

      During development, the system accumulated three overlapping storage layers for session data: raw transcripts (owned by the AI tool), session copies (JSONL copies plus context snapshots), and enriched journal entries (Markdown summaries). The middle layer (session copies) was a dead-end write sink. An auto-save hook copied transcripts to a directory that nothing read from, because the journal pipeline already read directly from the raw transcripts. Approximately 15 source files, a shell hook, 20 configuration constants, and 30 documentation references supported infrastructure with no consumers.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#62-prompt-time-retrieval-model","level":3,"title":"6.2 Prompt-Time Retrieval Model","text":"

      In a retrieval-based system, the decision to remove the middle layer depends on whether the retrieval function surfaces the relevant context:

      The developer asks: \"Should we simplify the session storage?\" The retrieval system must find and rank the original discussion thread where the three layers were designed, the usage statistics showing zero reads from the middle layer, the journal pipeline documentation showing it reads from raw transcripts directly, and the dependency analysis showing 15 files, a hook, and 30 doc references. If any of these fragments are not retrieved (because they are in old chat history, because the embedding similarity score is low, or because the token budget was consumed by more recent but less relevant context), the model may recommend preserving the middle layer, or may not realize it exists.

      Six months later, a new team member asks the same question. The retrieval results will differ: the original discussion has aged out of recency scoring, the usage statistics are no longer in recent history, and the model may re-derive the answer or arrive at a different conclusion.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#63-cognitive-state-model","level":3,"title":"6.3 Cognitive State Model","text":"

      In the persistence model, the decision is recorded as a structured artifact at write time:

      ## [2026-02-11] Remove .context/sessions/ storage layer\n\n**Status**: Accepted\n\n**Context**: The session/recall/journal system had three overlapping\nstorage layers. The recall pipeline reads directly from raw transcripts,\nmaking .context/sessions/ a dead-end write sink that nothing reads from.\n\n**Decision**: Remove .context/sessions/ entirely. Two stores remain:\nraw transcripts (global, tool-owned) and enriched journal\n(project-local).\n\n**Rationale**: Dead-end write sinks waste code surface, maintenance\neffort, and user attention. The recall pipeline already proved that\nreading directly from raw transcripts is sufficient. Context snapshots\nare redundant with git history.\n\n**Consequence**: Deleted internal/cli/session/ (15 files), removed\nauto-save hook, removed --auto-save from watch, removed pre-compact\nauto-save, removed /ctx-save skill, updated ~45 documentation files.\nFour earlier decisions superseded.\n

      This artifact is:

      • Deterministically included in every subsequent session's delivery view (budget permitting, with title-only fallback if budget is exceeded)
      • Human-readable and reviewable as a diff in the commit that introduced it
      • Permanent: it persists in version control regardless of retrieval heuristics
      • Causally linked: it explicitly supersedes four earlier decisions, creating an auditable chain

      When the new team member asks \"Why don't we store session copies?\" six months later, the answer is the same artifact, at the same revision, with the same rationale. The reasoning is reconstructible because it was persisted at write time, not discovered at query time.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#64-the-diff-when-policy-changes","level":3,"title":"6.4 The Diff When Policy Changes","text":"

      If a future requirement re-introduces session storage (for example, to support multi-agent session correlation), the change appears as a diff to the decision record:

      - **Status**: Accepted\n+ **Status**: Superseded by [2026-08-15] Reintroduce session storage\n+ for multi-agent correlation\n

      The new decision record references the old one, creating a chain of reasoning visible in git log. In the retrieval model, the old decision would simply be ranked lower over time and eventually forgotten.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#7-experience-report-a-system-that-designed-itself","level":2,"title":"7. Experience Report: A System That Designed Itself","text":"

      The persistence model described in this paper was developed and tested by using it on its own development. Over 33 days and 389 sessions, the system's context files accumulated a detailed record of decisions made, reversed, and consolidated: providing quantitative and qualitative evidence for the model's properties.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#71-scale-and-structure","level":3,"title":"7.1 Scale and Structure","text":"

      The development produced the following authoritative state artifacts:

      • 8 consolidated decision records covering 24 original decisions spanning context injection architecture, hook design, task management, security, agent autonomy, and webhook systems
      • 18 consolidated learning records covering 75 original observations spanning agent compliance, hook behavior, testing patterns, documentation drift, and tool integration
      • A constitution with 13 inviolable rules across 4 categories (security, quality, process, context preservation)
      • 389 enriched journal entries providing a complete session-level audit trail

      The consolidation ratio (24 decisions compressed to 8 records, 75 learnings compressed to 18) illustrates the curation cost and its return: authoritative state becomes denser and more useful over time as related entries are merged, contradictions are resolved, and superseded decisions are marked.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#72-architectural-reversals","level":3,"title":"7.2 Architectural Reversals","text":"

      Three architectural reversals during development provide evidence that the persistence model captures and communicates reasoning effectively:

      Reversal 1: The two-tier persistence model: The original design included a middle storage tier for session copies. After 21 days of development, the middle tier was identified as a dead-end write sink (described in Section 6). The decision record captured the full context, and the removal was executed cleanly: 15 source files, a shell hook, and 45 documentation references. The pattern of a \"dead-end write sink\" was subsequently observed in 7 of 17 systems in our landscape analysis that store raw transcripts alongside structured context.

      Reversal 2: The prompt-coach hook: An early design included a hook that analyzed user prompts and offered improvement suggestions. After deployment, the hook produced zero useful tips, its output channel was invisible to users, and it accumulated orphan temporary files. The hook was removed, and the decision record captured the failure mode for future reference.

      Reversal 3: The soft-instruction compliance model: The original context injection strategy relied on soft instructions: directives asking the AI agent to read specific files. After measuring compliance across multiple sessions, we found a consistent 75-85% compliance ceiling. The revised strategy injects content directly, bypassing the agent's judgment about whether to comply. The learning record captures the ceiling measurement and the rationale for the architectural change.

      Each reversal was captured as a structured decision record with context, rationale, and consequences. In a retrieval-based system, these reversals would exist only in chat history, discoverable only if the retrieval function happens to surface them. In the persistence model, they are permanent, indexable artifacts that inform future decisions.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#73-compliance-ceiling","level":3,"title":"7.3 Compliance Ceiling","text":"

      The 75-85% compliance ceiling for soft instructions is the most operationally significant finding from the experience report. It means that any context management strategy relying on agent compliance with instructions (\"read this file,\" \"follow this convention,\" \"check this list\") has a hard ceiling on reliability.

      The root cause is structural: the instruction \"don't apply judgment\" is itself evaluated by judgment. When an agent receives a directive to read a file, it first assesses whether the directive is relevant to the current task (and that assessment is the judgment the directive was trying to prevent).

      The architectural response maps directly to the formal model defined in Section 3.1. Content requiring 100% compliance is included in authoritative_state and injected by the deterministic assemble function, bypassing the agent entirely. Content where 80% compliance is acceptable is delivered as instructions within the delivery view. The three-tier architecture makes this distinction explicit: authoritative state is injected; delivery views are assembled deterministically; ephemeral state is available but not pushed.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#74-compounding-returns","level":3,"title":"7.4 Compounding Returns","text":"

      Over 33 days, we observed a qualitative shift in the development experience. Early sessions (days 1-7) spent significant time re-establishing context: explaining conventions, re-stating constraints, re-deriving past decisions. Later sessions (days 25-33) began with the agent loading curated context and immediately operating within established constraints, because the constraints were in files rather than in chat history.

      This compounding effect (where each session's context curation improves all subsequent sessions) is the primary return on the curation investment. The cost is borne once (writing a decision record, capturing a learning, updating the task list); the benefit is collected on every subsequent session load.

      The effect is analogous to compound interest in financial systems: the knowledge base grows not linearly with effort but with increasing marginal returns as new knowledge interacts with existing context. A learning captured on day 5 prevents a mistake on day 12, which avoids a debugging session that would have consumed a day 12 session, freeing that session for productive work that generates new learnings. The growth is not literally exponential (it is bounded by project scope and subject to diminishing returns as the knowledge base matures), but within the observed 33-day window, the returns were consistently accelerating.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#75-scope-and-generalizability","level":3,"title":"7.5 Scope and Generalizability","text":"

      This experience report is self-referential by design: the system was developed using its own persistence model. This circularity strengthens the internal validity of the findings (the model was stress-tested under authentic conditions) but limits external generalizability. The two-week crossover point was observed on a single project of moderate complexity with a small team already familiar with the model's assumptions. Whether the same crossover holds for larger teams, for codebases with different characteristics, or for teams adopting the model without having designed it remains an open empirical question. The quantitative claims in this section should be read as existence proofs (demonstrating that the model can produce compounding returns) rather than as predictions about specific adoption scenarios.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#8-situating-the-persistence-layer","level":2,"title":"8. Situating the Persistence Layer","text":"

      The persistence layer occupies a specific position in the stack of AI-assisted development:

      Application Logic\nAI Interaction / Agents\nContext Retrieval Systems\nCognitive State Persistence Layer\nVersion Control / Storage\n

      Current systems innovate primarily in the retrieval layer (improving how context is discovered, ranked, and delivered at query time). The persistence layer sits beneath retrieval and above version control. Its role is to maintain the authoritative state that retrieval systems may query but do not own. The relationship is complementary: retrieval answers \"What in the corpus might be relevant?\"; cognitive state answers \"What must be true for this system to operate correctly?\" A mature system uses both: retrieval for discovery, persistence for authority.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#9-applicability-and-trade-offs","level":2,"title":"9. Applicability and Trade-Offs","text":"","path":["The Thesis"],"tags":[]},{"location":"thesis/#91-when-to-use-this-model","level":3,"title":"9.1 When to Use This Model","text":"

      A cognitive state persistence layer is most appropriate when:

      Reproducibility is a requirement: If a system must be able to answer \"Why did this output occur, and can it be produced again?\" then deterministic, version-controlled context becomes necessary. This is relevant in regulated environments, safety-critical systems, long-lived infrastructure, and security-sensitive deployments.

      Knowledge must outlive sessions and individuals: Projects with multi-year lifetimes accumulate architectural decisions, domain interpretations, and operational policy. If this knowledge is stored only in chat history, issue trackers, and institutional memory, it decays. The persistence model converts implicit knowledge into branchable, reviewable artifacts.

      Teams require shared cognitive authority: In collaborative environments, correctness depends on a stable answer to \"What does the system believe to be true?\" When this answer is derived from retrieval heuristics, authority shifts to ranking algorithms. When it is versioned and human-readable, authority remains with the team.

      Offline or air-gapped operation is required: Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or disaster-recovery scenarios.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#92-when-not-to-use-this-model","level":3,"title":"9.2 When Not to Use This Model","text":"

      Zero-configuration personal workflows: For short-lived or exploratory tasks, the cost of explicit knowledge curation outweighs its benefits. Heuristic retrieval is sufficient when correctness is non-critical, outputs are disposable, and historical reconstruction is unnecessary.

      Maximum automatic recall from large corpora: Vector retrieval systems provide superior performance when the primary task is searching vast, weakly structured information spaces. The persistence model assumes that what matters can be decided and that this decision is valuable to record.

      Fully autonomous agent architectures: Agent runtimes that generate and discard state continuously, optimizing for local goal completion, do not benefit from a model that centers human ratification of knowledge.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#93-incremental-adoption","level":3,"title":"9.3 Incremental Adoption","text":"

      The transition does not require full system replacement. An incremental path:

      Step 1: Record decisions as versioned artifacts: Instead of allowing conclusions to remain in discussion threads, persist them in reviewable form with context, rationale, and consequences 4. This alone converts ephemeral reasoning into the cognitive state.

      Step 2: Make inclusion deterministic: Define explicit assembly rules. Retrieval may still exist, but it is no longer authoritative.

      Step 3: Move policy into cognitive state: When system behavior depends on stable constraints, encode those constraints as versioned knowledge. Behavior becomes reproducible.

      Step 4: Optimize assembly, not retrieval: Once the authoritative layer exists, performance improvements come from budgeting, caching, and structural refinement rather than from improving ranking heuristics.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#94-the-curation-cost","level":3,"title":"9.4 The Curation Cost","text":"

      The primary objection to this model is the cost of explicit knowledge curation. This cost is real. Writing a structured decision record takes longer than letting a chatbot auto-summarize a conversation. Maintaining a glossary requires discipline. Consolidating 75 learnings into 18 records requires judgment.

      The response is not that the cost is negligible but that it is amortized. A decision record written once is loaded hundreds of times. A learning captured today prevents repeated mistakes across all future sessions. The curation cost is paid once; the benefit compounds.

      The experience report provides rough order-of-magnitude numbers. Across 389 sessions over 33 days, curation activities (writing decision records, capturing learnings, updating the task list, consolidating entries) averaged approximately 3-5 minutes per session. In early sessions (days 1-7), before curated context existed, re-establishing context consumed approximately 10-15 minutes per session: re-explaining conventions, re-stating architectural constraints, re-deriving decisions that had been made but not persisted. By the final week (days 25-33), the re-explanation overhead had dropped to near zero: the agent loaded curated context and began productive work immediately.

      At ~12 sessions per day, the curation cost was roughly 35-60 minutes daily. The re-explanation cost in the first week was roughly 120-180 minutes daily. By the third week, that cost had fallen to under 15 minutes daily while the curation cost remained stable. The crossover (where cumulative curation cost was exceeded by cumulative time saved) occurred around day 10. These figures are approximate and derived from a single project with a small team already familiar with the model; the crossover point will vary with project complexity, team size, and curation discipline.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#10-future-work","level":2,"title":"10. Future Work","text":"

      Several directions are compatible with the model described here:

      Section-level deterministic budgeting: Current assembly operates at file granularity. Section-level budgeting would allow finer-grained control (including specific decision records while excluding others within the same file) without sacrificing determinism.

      Causal links between decisions: The experience report shows that decisions frequently reference earlier decisions (superseding, extending, or qualifying them). Formal causal links would enable traversal of the decision graph and automatic detection of orphaned or contradictory constraints.

      Content-addressed context caches: Five systems in our landscape analysis independently discovered that content hashing provides cache invalidation, integrity verification, and change detection. Applying content addressing to the assembly output would enable efficient cache reuse when the authoritative state has not changed.

      Conditional context inclusion: Five systems independently suggest that context entries could carry activation conditions (file patterns, task keywords, or explicit triggers) that control whether they are included in a given assembly. This would reduce the per-session budget cost of large knowledge bases without sacrificing determinism.

      Provenance metadata: Linking context entries to the sessions, decisions, or learnings that motivated them would strengthen the audit trail. Optional provenance fields on Markdown entries (session identifier, cause reference, motivation) would be lightweight and compatible with the existing file-based model.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#11-conclusion","level":2,"title":"11. Conclusion","text":"

      AI-assisted development has treated context as a \"query result\" assembled at the moment of interaction, discarded at the session end. This paper identifies a complementary layer: the persistence of authoritative cognitive state as deterministic, version-controlled artifacts.

      The contribution is grounded in three sources of evidence. A landscape analysis of 17 systems reveals five categories of primitives and shows that no existing system provides the combination of human-readability, determinism, zero dependencies, and offline capability that the persistence layer requires. Six design invariants, validated by 56 independent rejection decisions, define the constraints of the design space. An experience report over 389 sessions and 33 days demonstrates compounding returns: later sessions start faster, decisions are not re-derived, and architectural reversals are captured with full context.

      The core claim is this: persistent cognitive state enables causal reasoning across time. A system built on this model can explain not only what is true, but why it became true and when it changed.

      When context is the state:

      • Reasoning is reproducible: the same authoritative state, budget, and policy produce the same delivery view.
      • Knowledge is auditable: decisions are traceable to explicit artifacts with context, rationale, and consequences.
      • Understanding compounds: each session's curation improves all subsequent sessions.

      The choice between retrieval-centric workflows and a persistence layer is not a matter of capability but of time horizon. Retrieval optimizes for relevance at the moment of interaction. Persistence optimizes for the durability of understanding across the lifetime of a project.

      🐸🖤 \"Gooood... let the deterministic context flow through the repository...\" - Kermit the Sidious, probably

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#appendix-a-representative-rejection-decisions","level":2,"title":"Appendix A: Representative Rejection Decisions","text":"

      The 56 rejection decisions referenced in Section 4 were cataloged across all 17 system analyses, grouped by the invariant they would violate. This appendix provides a representative sample (two per invariant) to illustrate the methodology.

      Invariant 1: Markdown-on-Filesystem (11 rejections): CrewAI's vector embedding storage was rejected because embeddings are not human-readable, not git-diff-friendly, and require external services. Kindex's knowledge graph as core primitive was rejected because it requires specialized commands to inspect content that could be a text file (kin show <id> vs. cat DECISIONS.md).

      Invariant 2: Zero Runtime Dependencies (13 rejections): Letta/MemGPT's PostgreSQL-backed architecture was rejected because it conflicts with local-first, no-database, single-binary operation. Pachyderm's Kubernetes-based distributed architecture was rejected as the antithesis of a single-binary design for a tool that manages text files.

      Invariant 3: Deterministic Assembly (6 rejections): LlamaIndex's embedding-based retrieval as the primary selection mechanism was rejected because it destroys determinism, requires an embedding model, and removes human judgment from the selection process. QubicDB's wall-clock-dependent scoring was rejected because it directly conflicts with the \"same inputs produce same output\" property.

      Invariant 4: Human Authority (6 rejections): Letta/MemGPT's agent self-modification of memory was rejected as fundamentally opposed to human-curated persistence. Claude Code's unstructured auto-memory (where the agent writes freeform notes) was rejected because structured files with defined schemas produce higher-quality persistent context than unconstrained agent output.

      Invariant 5: Local-First / Air-Gap Capable (7 rejections): Sweep's cloud-dependent architecture was rejected as fundamentally incompatible with the local-first, offline-capable model. LangGraph's managed cloud deployment was rejected because cloud dependencies for core functionality violate air-gap capability.

      Invariant 6: No Default Telemetry (4 rejections): Continue's telemetry-by-default (PostHog) was rejected because it contradicts the local-first, privacy-respecting trust model. CrewAI's global telemetry on import (Scarf tracking pixel) was rejected because it violates user trust and breaks air-gap capability.

      The remaining 9 rejections did not map to a specific invariant but were rejected on other architectural grounds: for example, Aider's full-file-content-in-context approach (which defeats token budgeting), AutoGen's multi-agent orchestration as core primitive (scope creep), and Claude Code's 30-day transcript retention limit (institutional knowledge should have no automatic expiration).

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#references","level":2,"title":"References","text":"
      1. Reproducible Builds Project, \"Reproducible Builds: Increasing the Integrity of Software Supply Chains\", 2017. https://reproducible-builds.org/docs/definition/ ↩↩↩

      2. S. McIntosh et al., \"The Impact of Build System Evolution on Software Quality\", ICSE, 2015. https://doi.org/10.1109/ICSE.2015.70 ↩

      3. C. Manning, P. Raghavan, H. Schütze, Introduction to Information Retrieval, Cambridge University Press, 2008. https://nlp.stanford.edu/IR-book/ ↩

      4. M. Nygard, \"Documenting Architecture Decisions\", Cognitect Blog, 2011. https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions ↩↩

      5. L. Torvalds et al., Git Internals - Git Objects (content-addressed storage concepts). https://git-scm.com/book/en/v2/Git-Internals-Git-Objects ↩

      6. Kief Morris, Infrastructure as Code, O'Reilly, 2016. ↩

      7. J. Kreps, \"The Log: What every software engineer should know about real-time data's unifying abstraction\", 2013. https://engineering.linkedin.com/distributed-systems/log ↩

      8. P. Hunt et al., \"ZooKeeper: Wait-free coordination for Internet-scale systems\", USENIX ATC, 2010. https://www.usenix.org/legacy/event/atc10/tech/full_papers/Hunt.pdf ↩

      ","path":["The Thesis"],"tags":[]}]} \ No newline at end of file +{"config":{"separator":"[\\s\\-_,:!=\\[\\]()\\\\\"`/]+|\\.(?!\\d)"},"items":[{"location":"","level":1,"title":"Manifesto","text":"","path":["Manifesto"],"tags":[]},{"location":"#the-ctx-manifesto","level":1,"title":"The ctx Manifesto","text":"

      Creation, not code.

      Context, not prompts.

      Verification, not vibes.

      This Is NOT a Metaphor

      Code executes instructions.

      Creation produces outcomes.

      Confusing the two is how teams ship motion...

      ...instead of progress.

      • It was never about the code.
      • Code has zero standalone value.
      • Code is an implementation detail.

      Code is an incantation.

      Creation is the act.

      And creation does not happen in a vacuum.

      ","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-the-substrate","level":2,"title":"ctx Is the Substrate","text":"

      Constraints Have Moved

      Human bandwidth is no longer the limiting factor.

      Context integrity is.

      Human bandwidth is no longer the constraint.

      Context is:

      • Without durable context, intelligence resets.
      • Without memory, reasoning decays.
      • Without structure, scale collapses.

      Creation is now limited by:

      • Clarity of intent;
      • Quality of context;
      • Rigor of verification.

      Not by speed.

      Not by capacity.

      Velocity Amplifies

      Faster execution on broken context compounds error.

      Speed multiplies whatever is already wrong.

      ","path":["Manifesto"],"tags":[]},{"location":"#humans-author-meaning","level":2,"title":"Humans Author Meaning","text":"

      Intent Is Authored

      Systems can optimize.

      Models can generalize.

      Meaning must be chosen.

      Intent is not emergent.

      Vision, goals, and direction are human responsibilities.

      We decide:

      • What matters;
      • What success means;
      • What world we are building.

      ctx encodes the intent so it...

      • survives time,
      • survives handoffs,
      • survives scale.

      Nothing important should live only in conversation.

      Nothing critical should depend on recall.

      Oral Tradition Does Not Scale

      If intent cannot be inspected, it cannot be enforced.

      ","path":["Manifesto"],"tags":[]},{"location":"#ctx-before-action","level":2,"title":"ctx Before Action","text":"

      Orientation Precedes Motion

      Acting first and understanding later is not bravery.

      It is debt.

      Never act without ctx.

      Before execution, we must verify:

      • Where we are;
      • Why we are here;
      • What constraints apply;
      • What assumptions are active.

      Action without ctx is gambling.

      Speed without orientation is noise.

      ctx is not overhead: It is the cost of correctness.

      ","path":["Manifesto"],"tags":[]},{"location":"#persistent-context-beats-prompt-memory","level":2,"title":"Persistent Context Beats Prompt Memory","text":"

      Transience Is the Default Failure Mode

      • Prompts decay.
      • Chats fragment.
      • Memory heuristics drift.

      Prompts are transient.

      Chats are lossy.

      Memory heuristics drift.

      ctx must be:

      • Durable;
      • Structured;
      • Explicit;
      • Queryable.

      Intent Must Be Intentional

      If intent exists only in a prompt...

      ...alignment is already degrading.

      Knowledge lives in the artifacts:

      • Decisions;
      • Documentation;
      • Dependency maps;
      • Evaluation history.

      Artifacts Outlive Sessions

      What is not written will be re-learned.

      At full cost.

      ","path":["Manifesto"],"tags":[]},{"location":"#what-ctx-is-not","level":2,"title":"What ctx Is Not","text":"

      Avoid Category Errors

      Mislabeling ctx guarantees misuse.

      ctx is not a memory feature.

      • ctx is not prompt engineering.
      • ctx is not a productivity hack.
      • ctx is not automation theater.

      ctx is a system for preserving intent under scale.

      ctx is infrastructure.

      ","path":["Manifesto"],"tags":[]},{"location":"#verified-reality-is-the-scoreboard","level":2,"title":"Verified Reality Is the Scoreboard","text":"

      Activity Is a False Proxy

      Output volume correlates poorly with impact.

      • Code is not progress.
      • Activity is not impact.

      The only truth that compounds is verified change.

      Verified change must exist in the real world.

      Hypotheses are cheap; outcomes are not.

      ctx captures:

      • What we expected;
      • What we observed;
      • Where reality diverged.

      If we cannot predict, measure, and verify the result...

      ...it does not count.

      ","path":["Manifesto"],"tags":[]},{"location":"#build-to-learn-not-to-accumulate","level":2,"title":"Build to Learn, Not to Accumulate","text":"

      Prototypes Have an Expiration Date

      A prototype's value is information, not longevity.

      Prototypes exist to reduce uncertainty.

      We build to:

      • Test assumptions;
      • Validate architecture;
      • Answer specific questions.

      Not everything.

      Not blindly.

      Not permanently.

      ctx records archeology so the cost is paid once.

      ","path":["Manifesto"],"tags":[]},{"location":"#failures-are-assets","level":2,"title":"Failures Are Assets","text":"

      Failure without Capture Is Waste

      Pain that does not teach is pure loss.

      Failures are not erased: They are preserved.

      Each failure becomes:

      • A documented hypothesis;
      • An analyzed deviation;
      • A permanent artifact.

      Rollback fixes symptoms: ctx fixes systems.

      A repeated mistake is a missing ctx artifact.

      ","path":["Manifesto"],"tags":[]},{"location":"#structure-enables-scale","level":2,"title":"Structure Enables Scale","text":"

      Unbounded Autonomy Destabilizes

      Power without a structure produces chaos.

      Transpose it:

      Power without any structure becomes chaos.

      ctx defines:

      • Roles;
      • Boundaries;
      • Protocols;
      • Escalation paths;
      • Decision rights.

      Ambiguity is a system failure:

      • Debates must be structured.
      • Decisions must be explicit.
      • History must be retained.
      ","path":["Manifesto"],"tags":[]},{"location":"#encode-intent-into-the-environment","level":2,"title":"Encode Intent into the Environment","text":"

      Goodwill Does Not Belong to the Table

      Alignment that depends on memory will drift.

      Alignment cannot depend on memory or goodwill.

      Do not rely on people to remember.

      Encode the behavior, so it happens by default.

      Intent is encoded as:

      • Policies;
      • Schemas;
      • Constraints;
      • Evaluation harnesses.

      Rules must be machine-readable.

      Laws must be enforceable.

      If intent is implicit, drift is guaranteed.

      ","path":["Manifesto"],"tags":[]},{"location":"#cost-is-a-first-class-signal","level":2,"title":"Cost Is a First-Class Signal","text":"

      Attention Is the Scarcest Resource

      Not ideas.

      Not ambition.

      Ideas do not compete on time:

      They compete on cost and impact:

      • Attention is finite.
      • Compute is finite.
      • Context is expensive.

      We continuously ask:

      • What the most valuable next action is.
      • What outcome justifies the cost.

      ctx guides allocation.

      Learning reshapes priority.

      ","path":["Manifesto"],"tags":[]},{"location":"#show-the-why","level":2,"title":"Show the Why","text":"

      {} (code, artifacts, apps, binaries) produce outputs; they do not preserve reasoning.

      Systems that cannot explain themselves will not be trusted.

      Traceability builds trust.

           {} --> what\n\n    ctx --> why\n

      We record:

      • Explored paths;
      • Rejected options;
      • Assumptions made;
      • Evidence used.

      Opaque systems erode trust:

      Transparent ctx compounds understanding.

      ","path":["Manifesto"],"tags":[]},{"location":"#continuously-verify-the-system","level":2,"title":"Continuously Verify the System","text":"

      Stability Is Temporary

      Every assumption has a half-life:

      • Models drift.
      • Tools change.
      • Assumptions rot.

      ctx must be verified against reality.

      Trust is a spectrum.

      Trust is continuously re-earned:

      • Benchmarks,
      • regressions,
      • and evaluations...

      ...are safety rails.

      ","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-leverage","level":2,"title":"ctx Is Leverage","text":"

      Humans Are Decision Engines

      Execution should not consume judgment.

      Humans must not be typists.

      We are the authors.

      Human effort is reserved for:

      • Judgment;
      • Design;
      • Taste;
      • Synthesis.

      Repetition is delegated.

      Toil is automated.

      ctx preserves leverage across time.

      ","path":["Manifesto"],"tags":[]},{"location":"#the-thesis","level":2,"title":"The Thesis","text":"

      Invariant

      Everything else is an implementation detail.

      • Creation is the act.
      • ctx is the substrate.
      • Verification is the truth.

      Code executes → Models reason → Agents amplify.

      ctx lives on.

      • Without ctx, intelligence resets.
      • With ctx, creation compounds.
      ","path":["Manifesto"],"tags":[]},{"location":"blog/","level":1,"title":"Blog","text":"

      Stories, insights, and lessons learned from building and using ctx.

      ","path":["Blog"],"tags":[]},{"location":"blog/#releases","level":2,"title":"Releases","text":"","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v080-the-architecture-release","level":3,"title":"ctx v0.8.0: The Architecture Release","text":"

      March 23, 2026: 374 commits, 1,708 Go files touched, and a near-complete architectural overhaul. Every CLI package restructured into cmd/ + core/ taxonomy, all user-facing strings externalized to YAML, MCP server for tool-agnostic AI integration, and the memory bridge connecting Claude Code's auto-memory to .context/.

      Topics: release, architecture, refactoring, MCP, localization

      ","path":["Blog"],"tags":[]},{"location":"blog/#field-notes","level":2,"title":"Field Notes","text":"","path":["Blog"],"tags":[]},{"location":"blog/#the-watermelon-rind-anti-pattern-why-smarter-tools-make-shallower-agents","level":3,"title":"The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents","text":"

      April 6, 2026: Give an agent a graph query tool, and it produces output that's structurally correct but substantively hollow (the watermelon-rind antipattern: We ran three sessions analyzing the same codebase with different tool access: the one with no tools produced 5.2x more depth. The fix: a two-pass compiler for architecture understanding: force code reading first, verify with tools second. Constraint is the feature.

      Topics: architecture, code intelligence, agent behavior, design patterns, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#code-structure-as-an-agent-interface-what-19-ast-tests-taught-us","level":3,"title":"Code Structure as an Agent Interface: What 19 AST Tests Taught Us","text":"

      April 2, 2026: We built 19 AST-based audit tests in a single session, touching 300+ files. In the process we discovered that \"old-school\" code quality constraints (no magic numbers, centralized error handling, 80-char lines, documentation) are exactly the constraints that make code readable to AI agents. If an agent interacts with your codebase, your codebase already is an interface. You just have not designed it as one.

      Topics: ast, code quality, agent readability, conventions, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#we-broke-the-31-rule","level":3,"title":"We Broke the 3:1 Rule","text":"

      March 23, 2026: After v0.6.0, we ran 198 feature commits across 17 days before consolidating. The 3:1 rule says consolidate every 4th session. We did it after the 66th. The result: an 18-day, 181-commit cleanup marathon that took longer than the feature run itself. A follow-up to The 3:1 Ratio with empirical evidence from the v0.8.0 cycle.

      Topics: consolidation, technical debt, development workflow, convention drift, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#context-engineering","level":2,"title":"Context Engineering","text":"","path":["Blog"],"tags":[]},{"location":"blog/#agent-memory-is-infrastructure","level":3,"title":"Agent Memory Is Infrastructure","text":"

      March 4, 2026: Every AI coding agent starts fresh. The obvious fix is \"memory.\" But there's a different problem memory doesn't touch: the project itself accumulates knowledge that has nothing to do with any single session. This post argues that agent memory is L2 (runtime cache); what's missing is L3 (project infrastructure).

      Topics: context engineering, agent memory, infrastructure, persistence, team knowledge

      ","path":["Blog"],"tags":[]},{"location":"blog/#context-as-infrastructure","level":3,"title":"Context as Infrastructure","text":"

      February 17, 2026: Where does your AI's knowledge live between sessions? If the answer is \"in a prompt I paste at the start,\" you are treating context as a consumable. This post argues for treating it as infrastructure instead: persistent files, separation of concerns, two-tier storage, progressive disclosure, and the filesystem as the most mature interface available.

      Topics: context engineering, infrastructure, progressive disclosure, persistence, design philosophy

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-attention-budget-why-your-ai-forgets-what-you-just-told-it","level":3,"title":"The Attention Budget: Why Your AI Forgets What You Just Told It","text":"

      February 3, 2026: Every token you send to an AI consumes a finite resource: the attention budget. Understanding this constraint shaped every design decision in ctx: hierarchical file structure, explicit budgets, progressive disclosure, and filesystem-as-index.

      Topics: attention mechanics, context engineering, progressive disclosure, ctx primitives, token budgets

      ","path":["Blog"],"tags":[]},{"location":"blog/#before-context-windows-we-had-bouncers","level":3,"title":"Before Context Windows, We Had Bouncers","text":"

      February 14, 2026: IRC is stateless. You disconnect, you vanish. Modern systems are not much different. This post traces the line from IRC bouncers to context engineering: stateless protocols require stateful wrappers, volatile interfaces require durable memory.

      Topics: context engineering, infrastructure, IRC, persistence, state continuity

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-last-question","level":3,"title":"The Last Question","text":"

      February 28, 2026: In 1956, Asimov wrote a story about a question that spans the entire future of the universe. A reading of \"The Last Question\" through the lens of persistence, substrate migration, and what it means to build systems where sessions don't reset.

      Topics: context continuity, long-lived systems, persistence, intelligence over time, field notes

      ","path":["Blog"],"tags":[]},{"location":"blog/#agent-behavior-and-design","level":2,"title":"Agent Behavior and Design","text":"","path":["Blog"],"tags":[]},{"location":"blog/#the-dog-ate-my-homework-teaching-ai-agents-to-read-before-they-write","level":3,"title":"The Dog Ate My Homework: Teaching AI Agents to Read Before They Write","text":"

      February 25, 2026: You wrote the playbook. The agent skipped all of it. Five sessions, five failure modes, and the discovery that observable compliance beats perfect compliance.

      Topics: hooks, agent behavior, context engineering, behavioral design, testing methodology, compliance monitoring

      ","path":["Blog"],"tags":[]},{"location":"blog/#skills-that-fight-the-platform","level":3,"title":"Skills That Fight the Platform","text":"

      February 4, 2026: When custom skills conflict with system prompt defaults, the AI has to reconcile contradictory instructions. Five conflict patterns discovered while building ctx.

      Topics: context engineering, skill design, system prompts, antipatterns, AI safety primitives

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-anatomy-of-a-skill-that-works","level":3,"title":"The Anatomy of a Skill That Works","text":"

      February 7, 2026: I had 20 skills. Most were well-intentioned stubs. Then I rewrote all of them. Seven lessons emerged: quality gates prevent premature execution, negative triggers are load-bearing, examples set boundaries better than rules.

      Topics: skill design, context engineering, quality gates, E/A/R framework, practical patterns

      ","path":["Blog"],"tags":[]},{"location":"blog/#you-cant-import-expertise","level":3,"title":"You Can't Import Expertise","text":"

      February 5, 2026: I found a well-crafted consolidation skill. Applied my own E/A/R framework: 70% was noise. This post is about why good skills can't be copy-pasted, and how to grow them from your project's own drift history.

      Topics: skill adaptation, E/A/R framework, convention drift, consolidation, project-specific expertise

      ","path":["Blog"],"tags":[]},{"location":"blog/#not-everything-is-a-skill","level":3,"title":"Not Everything Is a Skill","text":"

      February 8, 2026: I ran an 8-agent codebase audit and got actionable results. The natural instinct was to wrap the prompt as a skill. Then I applied my own criteria: it failed all three tests.

      Topics: skill design, context engineering, automation discipline, recipes, agent teams

      ","path":["Blog"],"tags":[]},{"location":"blog/#defense-in-depth-securing-ai-agents","level":3,"title":"Defense in Depth: Securing AI Agents","text":"

      February 9, 2026: The security advice was \"use CONSTITUTION.md for guardrails.\" That is wishful thinking. Five defense layers for unattended AI agents, each with a bypass, and why the strength is in the combination.

      Topics: agent security, defense in depth, prompt injection, autonomous loops, container isolation

      ","path":["Blog"],"tags":[]},{"location":"blog/#development-practice","level":2,"title":"Development Practice","text":"","path":["Blog"],"tags":[]},{"location":"blog/#code-is-cheap-judgment-is-not","level":3,"title":"Code Is Cheap. Judgment Is Not.","text":"

      February 17, 2026: AI does not replace workers. It replaces unstructured effort. Three weeks of building ctx with an AI agent proved it: YOLO mode showed production is cheap, the 3:1 ratio showed judgment has a cadence.

      Topics: AI and expertise, context engineering, judgment vs production, human-AI collaboration, automation discipline

      ","path":["Blog"],"tags":[]},{"location":"blog/#the-31-ratio","level":3,"title":"The 3:1 Ratio","text":"

      February 17, 2026: AI makes technical debt worse: not because it writes bad code, but because it writes code so fast that drift accumulates before you notice. Three feature sessions, one consolidation session.

      Topics: consolidation, technical debt, development workflow, convention drift, code quality

      ","path":["Blog"],"tags":[]},{"location":"blog/#refactoring-with-intent-human-guided-sessions-in-ai-development","level":3,"title":"Refactoring with Intent: Human-Guided Sessions in AI Development","text":"

      February 1, 2026: The YOLO mode shipped 14 commands in a week. But technical debt doesn't send invoices. This is the story of what happened when we started guiding the AI with intent.

      Topics: refactoring, code quality, documentation standards, module decomposition, YOLO versus intentional development

      ","path":["Blog"],"tags":[]},{"location":"blog/#how-deep-is-too-deep","level":3,"title":"How Deep Is Too Deep?","text":"

      February 12, 2026: I kept feeling like I should go deeper into ML theory. Then I spent a week debugging an agent failure that had nothing to do with model architecture. When depth compounds and when it doesn't.

      Topics: AI foundations, abstraction boundaries, agentic systems, context engineering, failure modes

      ","path":["Blog"],"tags":[]},{"location":"blog/#agent-workflows","level":2,"title":"Agent Workflows","text":"","path":["Blog"],"tags":[]},{"location":"blog/#parallel-agents-merge-debt-and-the-myth-of-overnight-progress","level":3,"title":"Parallel Agents, Merge Debt, and the Myth of Overnight Progress","text":"

      February 17, 2026: You discover agents can run in parallel. So you open ten terminals. It is not progress: it is merge debt being manufactured in real time. The five-agent ceiling and why role separation beats file locking.

      Topics: agent workflows, parallelism, verification, context engineering, engineering practice

      ","path":["Blog"],"tags":[]},{"location":"blog/#parallel-agents-with-git-worktrees","level":3,"title":"Parallel Agents with Git Worktrees","text":"

      February 14, 2026: I had 30 open tasks that didn't touch the same files. Using git worktrees to partition a backlog by file overlap, run 3-4 agents simultaneously, and merge the results.

      Topics: agent teams, parallelism, git worktrees, context engineering, task management

      ","path":["Blog"],"tags":[]},{"location":"blog/#field-notes-and-signals","level":2,"title":"Field Notes and Signals","text":"","path":["Blog"],"tags":[]},{"location":"blog/#when-a-system-starts-explaining-itself","level":3,"title":"When a System Starts Explaining Itself","text":"

      February 17, 2026: Every new substrate begins as a private advantage. Reality begins when other people start describing it in their own language. \"Better than Adderall\" is not praise; it is a diagnostic.

      Topics: field notes, adoption signals, infrastructure vs tools, context engineering, substrates

      ","path":["Blog"],"tags":[]},{"location":"blog/#why-zensical","level":3,"title":"Why Zensical","text":"

      February 15, 2026: I needed a static site generator for the journal system. The instinct was Hugo. But instinct is not analysis. Why zensical was the right choice: thin dependencies, MkDocs-compatible config, and zero lock-in.

      Topics: tooling, static site generators, journal system, infrastructure decisions, context engineering

      ","path":["Blog"],"tags":[]},{"location":"blog/#releases_1","level":2,"title":"Releases","text":"","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v060-the-integration-release","level":3,"title":"ctx v0.6.0: The Integration Release","text":"

      February 16, 2026: ctx is now a Claude Marketplace plugin. Two commands, no build step, no shell scripts. v0.6.0 replaces six Bash hook scripts with compiled Go subcommands and ships 25+ Skills as a plugin.

      Topics: release, plugin system, Claude Marketplace, distribution, security hardening

      ","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v030-the-discipline-release","level":3,"title":"ctx v0.3.0: The Discipline Release","text":"

      February 15, 2026: No new headline feature. Just 35+ documentation and quality commits against ~15 feature commits. What a release looks like when the ratio of polish to features is 3:1.

      Topics: release, skills migration, consolidation, code quality, E/A/R framework

      ","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v020-the-archaeology-release","level":3,"title":"ctx v0.2.0: The Archaeology Release","text":"

      February 1, 2026: What if your AI could remember everything? Not just the current session, but every session. ctx v0.2.0 introduces the recall and journal systems.

      Topics: session recall, journal system, structured entries, token budgets, meta-tools

      ","path":["Blog"],"tags":[]},{"location":"blog/#building-ctx-using-ctx-a-meta-experiment-in-ai-assisted-development","level":3,"title":"Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development","text":"

      January 27, 2026: What happens when you build a tool designed to give AI memory, using that very same tool to remember what you're building? This is the story of ctx.

      Topics: dogfooding, AI-assisted development, Ralph Loop, session persistence, architectural decisions

      ","path":["Blog"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/","level":1,"title":"Building ctx Using ctx","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism.

      References to .context/sessions/, auto-save hooks, and SessionEnd auto-save in this post reflect the architecture at the time of writing.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#a-meta-experiment-in-ai-assisted-development","level":2,"title":"A Meta-Experiment in AI-Assisted Development","text":"

      Jose Alekhinne / 2026-01-27

      Can a Tool Design Itself?

      What happens when you build a tool designed to give AI memory, using that very same tool to remember what you are building?

      This is the story of ctx, how it evolved from a hasty \"YOLO mode\" experiment to a disciplined system for persistent AI context, and what I have learned along the way.

      Context Is a Record

      Context is a persistent record.

      By \"context\", I don't mean model memory or stored thoughts:

      I mean the durable record of decisions, learnings, and intent that normally evaporates between sessions.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#ai-amnesia","level":2,"title":"AI Amnesia","text":"

      Every developer who works with AI code generators knows the frustration:

      You have a deep, productive session where the AI understands your codebase, your conventions, your decisions. And then you close the terminal.

      Tomorrow; it's a blank slate. The AI has forgotten everything.

      That is \"reset amnesia\", and it's not just annoying: it's expensive.

      Every session starts with:

      • Re-explaining context;
      • Re-reading files;
      • Re-discovering decisions that were already made.

      I Needed Context

      \"I don't want to lose this discussion...

      ...I am a brain-dead developer YOLO'ing my way out.\"

      ☝️ that's exactly what I said to Claude when I first started working on ctx.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-genesis","level":2,"title":"The Genesis","text":"

      The project started as \"Active Memory\" (amem): a CLI tool to persist AI context across sessions.

      The core idea was simple:

      1. Create a .context/ directory with structured Markdown files for decisions, learnings, tasks, and conventions.
      2. The AI reads these at session start and writes to them before the session ends.
      3. There is no step 3.

      The first commit was just scaffolding. But within hours, the Ralph Loop (An iterative AI development workflow) had produced a working CLI:

      feat(cli): implement amem init command\nfeat(cli): implement amem status command\nfeat(cli): implement amem add command\nfeat(cli): implement amem agent command\n...\n

      Not one, not two, but a whopping fourteen core commands shipped in rapid succession!

      I was YOLO'ing like there was no tomorrow:

      • Auto-accept every change;
      • Let the AI run free;
      • Ship features fast.
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-meta-experiment-using-amem-to-build-amem","level":2,"title":"The Meta-Experiment: Using amem to Build amem","text":"

      Here's where it gets interesting: On January 20th, I asked:

      \"Can I use amem to help you remember this context when I restart?\"

      The answer was yes, but with a gap:

      Autoload worked (via Claude Code's PreToolUse hook), but auto-save was missing: If the user quit, with Ctrl+C, everything since the last manual save was lost.

      That session became the first real test of the system.

      Here is the first session file we recorded:

      ## Key Discussion Points\n\n### 1. amem vs Ralph Loop - They're Separate Systems\n\n**User's question**: \"How do I use the binary to recreate this project?\"\n\n**Answer discovered**: `amem` is for context management, Ralph Loop is for \ndevelopment workflow. They are complementary but separate.\n\n### 2. Two Tiers of Context Persistence\n\n| Tier      | What                        | Why                           |\n|-----------|-----------------------------|-------------------------------|\n| Curated   | Learnings, decisions, tasks | Quick reload, token-efficient |\n| Full dump | Entire conversation         | Safety net, nothing lost      |\n\n| Where                  |\n|------------------------|\n| .context/*.md          |\n| .context/sessions/*.md |\n

      This session file (written by the AI to preserve its own context) became the template for how ctx handles session persistence.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-rename","level":2,"title":"The Rename","text":"

      By January 21st, I realized \"Active Memory\" was too generic, and (arguably) too marketing-smelly.

      Besides, the binary was already called ctx (short for Context), the directory was .context/, and the slash commands would be /ctx-*.

      So it followed that the project should be renamed to ctx to make things make sense.

      The rename touched 100+ files but was clean: a find-and-replace with Go's type system catching any misses.

      The git history tells the story:

      0e8f6bb feat: rename amem to ctx and add Claude Code integration\n87dcfa1 README.\n4f0e195 feat: separate orchestrator directive from agent tasks\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#yolo-mode-fast-but-dangerous","level":2,"title":"YOLO Mode: Fast, but Dangerous","text":"

      The Ralph Loop made feature development incredibly fast.

      But it created technical debt that I didn't notice until later.

      A comparison session on January 25th revealed the patterns:

      YOLO Pattern What We Found \"TASKS.md\" scattered in 10 files Same string literal everywhere, no constants dir + \"/\" + file Should be filepath.Join() Monolithic cli_test.go (1500+ lines) Tests disconnected from implementations package initcmd in init/ folder Go's \"init\" is reserved: subtle naming collision

      Here is another analysis made by ctx:

      ● Based on my analysis, here are the key differences:\n\nYOLO Mode (Pre-040ce99)\n- Feature-first: Added slash commands, tests, templates rapidly\n- Scattered magic strings: \"TASKS.md\", \"decision\", \".context\" spread across files\n- Quick file creation: New files without organizational patterns\n- Working but inconsistent: Code functioned but lacked systematic structure\n\nHuman-Guided Mode (Post-040ce99)\n- Consolidation focus: Centralized constants in config package\n- Consistent naming: Dir, File, Filename, UpdateType prefixes\n- Self-referential constants: FileType map uses constants as keys, not literals\n- Proper path construction: filepath.Join() instead of +\"/\"+\n- Colocated tests: Tests next to implementations\n- Canonical naming: Package name = folder name\n

      The fix required a human-guided refactoring session. I continued to do that before every major release, from that point on.

      We introduced internal/config/config.go with semantic prefixes:

      const (\n    DirContext     = \".context\"\n    DirArchive     = \"archive\"\n    DirSessions    = \"sessions\"\n    FilenameTask   = \"TASKS.md\"\n    UpdateTypeTask = \"task\"\n)\n

      What I begrudgingly learned was: YOLO mode is effective for velocity but accumulates debt.

      So I took a mental note to schedule periodic consolidation sessions.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-dogfooding-test-that-failed","level":2,"title":"The Dogfooding Test That Failed","text":"

      On January 21st, I ran an experiment: have another Claude instance rebuild ctx from scratch using only the specs and PROMPT.md.

      The Ralph Loop ran, all tasks got checked off, the loop exited successfully.

      But the binary was broken!

      Commands just printed help text instead of executing.

      All tasks were marked \"complete\" but the implementation didn't work.

      Here's what ctx discovered:

      ## Key Findings\n\n### Dogfooding Binary Is Broken\n- Commands don't execute: they just print root help text\n- All tasks were marked complete but binary doesn't work\n- Lesson: \"tasks checked off\" ≠ \"implementation works\"\n

      This was humbling; to say the least.

      I realized I had the same blind spot in my own codebase: no integration tests that actually invoked the binary.

      So I added:

      • Integration tests for all commands;
      • Coverage targets (60-80% per package)
      • Smoke tests in CI
      • A constitution rule: \"All code must pass tests before commit\"
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-constitution-versus-conventions","level":2,"title":"The Constitution versus Conventions","text":"

      As lessons accumulated, there was the temptation to add everything to CONSTITUTION.md as \"inviolable rules\".

      But I resisted.

      The constitution should contain only truly inviolable invariants:

      • Security (no secrets, no customer data)
      • Quality (tests must pass)
      • Process (decisions need records)
      • ctx invocation (always use PATH, never fallback)

      Everything else (coding style, file organization, naming conventions...) should go in to CONVENTIONS.md.

      Here's how ctx explained why the distinction was important:

      Decision Record, 2026-01-25

      Overly strict constitution creates friction and gets ignored.

      Conventions can be bent; constitution cannot.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#hooks-harder-than-they-look","level":2,"title":"Hooks: Harder than They Look","text":"

      Claude Code hooks seemed simple: Run a script before/after certain events.

      But I hit multiple gotchas:

      1. Key names matter

      // WRONG - \"Invalid key in record\" error\n\"PreToolUseHooks\": [...]\n\n// RIGHT\n\"PreToolUse\": [...]\n

      2. Blocking requires specific output

      # WRONG - just exits, doesn't block\nexit 1\n\n# RIGHT - JSON output + exit 0\necho '{\"decision\": \"block\", \"reason\": \"Use ctx from PATH\"}'\nexit 0\n

      3. Go's JSON escaping

      json.Marshal escapes >, <, & as unicode (\\u003e) by default.

      When generating shell commands in JSON:

      encoder := json.NewEncoder(file)\nencoder.SetEscapeHTML(false) // Prevent 2>/dev/null → 2\\u003e/dev/null\n

      4. Regex overfitting

      My hook to block non-PATH ctx invocations initially matched too broadly:

      # WRONG - matches /home/user/ctx/internal/file.go (ctx as directory)\n(/home/|/tmp/|/var/)[^ ]*ctx[^ ]*\n\n# RIGHT - matches ctx as binary only\n(/home/|/tmp/|/var/)[^ ]*/ctx( |$)\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-session-files","level":2,"title":"The Session Files","text":"

      By the time of this writing this project's ctx sessions (.context/sessions/) contains 40+ files from this project's development.

      They are not part of the source code due to security, privacy, and size concerns.

      Middle Ground: The Scratchpad

      For sensitive notes that do need to travel with the project, ctx pad stores encrypted one-liners in git, and ctx pad add \"label\" --file PATH can ingest small files.

      See Scratchpad for details.

      However, they are invaluable for the project's progress.

      Each session file is a timestamped Markdown with:

      • Summary of what has been accomplished;
      • Key decisions made;
      • Learnings discovered;
      • Tasks for the next session;
      • Technical context (platform, versions).

      These files are not autoloaded (that would bust the token budget).

      They are what I see as the \"archaeological record\" of ctx:

      When the AI needs deeper information about why something was done, it digs into the sessions.

      Auto-generated session files used a naming convention:

      2026-01-23-115432-session-prompt_input_exit-summary.md\n2026-01-25-220244-manual-save.md\n2026-01-27-052107-session-other-summary.md\n

      Update

      The session feature described here is historical.

      In current releases, ctx uses a journal instead: the enrichment process generates meaningful slugs from context automatically, so there is no need to manually save sessions.

      The SessionEnd hook captured transcripts automatically. Even Ctrl+C was caught.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-decision-log-18-architectural-decisions","level":2,"title":"The Decision Log: 18 Architectural Decisions","text":"

      ctx helps record every significant architectural choice in .context/DECISIONS.md.

      Here are some highlights:

      Reverse-chronological order (2026-01-27)

      **Context**: With chronological order, oldest items consume tokens first, and\nnewest (most relevant) items risk being truncated.\n\n**Decision**: Use reverse-chronological order (newest first) for DECISIONS.md\nand LEARNINGS.md.\n

      PATH over hardcoded paths (2026-01-21)

      **Context**: Original implementation hardcoded absolute paths in hooks.\nThis breaks when sharing configs with other developers.\n\n**Decision**: Hooks use `ctx` from PATH. `ctx init` checks PATH before \nproceeding.\n

      Generic core with Claude enhancements (2026-01-20)

      **Context**: ctx should work with any AI tool, but Claude Code users could\nbenefit from deeper integration.\n\n**Decision**: Keep ctx generic as the core tool, but provide optional\nClaude Code-specific enhancements.\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-learning-log-24-gotchas-and-insights","level":2,"title":"The Learning Log: 24 Gotchas and Insights","text":"

      The .context/LEARNINGS.md file captures gotchas that would otherwise be forgotten. Each has Context, Lesson, and Application sections:

      CGO on ARM64

      **Context**: `go test` failed with \n`gcc: error: unrecognized command-line option '-m64'`\n\n**Lesson**: On ARM64 Linux, CGO causes cross-compilation issues. \nAlways use `CGO_ENABLED=0`.\n

      Claude Code skills format

      **Lesson**: Claude Code skills are Markdown files in .claude/commands/ with `YAML`\nfrontmatter (*description, argument-hint, allowed-tools*). Body is the prompt.\n

      \"Do you remember?\" handling

      **Lesson**: In a `ctx`-enabled project, \"*do you remember?*\" \nhas an obvious meaning:\ncheck the `.context/` files. Don't ask for clarification. Just do it.\n
      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#task-archives-the-completed-work","level":2,"title":"Task Archives: The Completed Work","text":"

      Completed tasks are archived to .context/archive/ with timestamps.

      The archive from January 23rd shows 13 phases of work:

      • Phase 1: Project Scaffolding (Go module, Cobra CLI)
      • Phase 2-4: Core Commands (init, status, agent, add, complete, drift, sync, compact, watch, hook)
      • Phase 5: Session Management (save, list, load, parse, --extract)
      • Phase 6: Claude Code Integration (hooks, settings, CLAUDE.md handling)
      • Phase 7: Testing & Verification
      • Phase 8: Task Archival
      • Phase 9: Slash Commands
      • Phase 9b: Ralph Loop Integration
      • Phase 10: Project Rename
      • Phase 11: Documentation
      • Phase 12: Timestamp Correlation
      • Phase 13: Rich Context Entries

      That's an impressive ^^173 commits** across 8 days of development.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#what-i-learned-about-ai-assisted-development","level":2,"title":"What I Learned about AI-Assisted Development","text":"

      1. Memory changes everything

      When the AI remembers decisions, it doesn't repeat mistakes.

      When the AI knows your conventions, it follows them.

      ctx makes the AI a better collaborator because it's not starting from zero.

      2. Two-tier persistence works

      Curated context (DECISIONS.md, LEARNINGS.md, TASKS.md) is for quick reload.

      Full session dumps are for archaeology.

      It's a futile effort to try to fit everything in the token budget.

      Persist more, load less.

      3. YOLO mode has its place

      For rapid prototyping, letting the AI run free is effective.

      But I had to schedule consolidation sessions.

      Technical debt accumulates silently.

      4. The constitution should be small

      Only truly inviolable rules go in CONSTITUTION.md. Everything else is a convention.

      If you put too much in the constitution, it will get ignored.

      5. Verification is non-negotiable

      \"All tasks complete\" means nothing if you haven't run the tests.

      Integration tests that invoke the actual binary caught bugs that the unit tests missed.

      6. Session files are underrated

      The ability to grep through 40 session files and find exactly when and why a decision was made helped me a lot.

      It's not about loading them into context: It is about having them when you need them.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#the-future-recall-system","level":2,"title":"The Future: Recall System","text":"

      The next phase of ctx is the Recall System:

      • Parser: Parse session capture markdowns, enrich with JSONL data
      • Renderer: Goldmark + Chroma for syntax highlighting, dark mode UI
      • Server: Local HTTP server for browsing sessions
      • Search: Inverted index for searching across sessions
      • CLI: ctx recall serve <path> to start the server

      The goal is to make the archaeological record browsable, not just grep-able.

      Because not everyone always lives in the terminal (me included).

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/#conclusion","level":2,"title":"Conclusion","text":"

      Building ctx using ctx was a meta-experiment in AI-assisted development.

      I learned that memory isn't just convenient: It's transformative:

      • An AI that remembers your decisions doesn't repeat mistakes.
      • An AI that knows your conventions doesn't need them re-explained.

      If you are reading this, chances are that you already have heard about ctx.

      • ctx is open source at github.com/ActiveMemory/ctx,
      • and the documentation lives at ctx.ist.

      Session Records Are a Gold Mine

      By the time of this writing, I have more than 70 megabytes of text-only session capture, spread across >100 Markdown and JSONL files.

      I am analyzing, synthesizing, encriching them with AI, running RAG (Retrieval-Augmented Generation) models on them, and the outcome surprises me every day.

      If you are a mere mortal tired of reset amnesia, give ctx a try.

      And when you do, check .context/sessions/ sometime.

      The archaeological record might surprise you.

      This blog post was written with the help of ctx with full access to the ctx session files, decision log, learning log, task archives, and git history of ctx: The meta continues.

      ","path":["Building ctx Using ctx: A Meta-Experiment in AI-Assisted Development"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/","level":1,"title":"ctx v0.2.0: The Archaeology Release","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism.

      The .context/sessions/ directory referenced in this post has been eliminated. Session history is now accessed via ctx recall and enriched journals live in .context/journal/.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#digging-through-the-past-to-build-the-future","level":2,"title":"Digging through the Past to Build the Future","text":"

      Jose Alekhinne / 2026-02-01

      What If Your AI Could Remember Everything?

      Not just the current session, but every session:

      • Every decision made,
      • every mistake avoided,
      • every path not taken.

      That's what v0.2.0 delivers.

      Between v0.1.2 and v0.2.0, 86 commits landed across 5 days.

      The release notes list features and fixes.

      This post tells the story of why those features exist, and what building them taught me.

      This isn't a changelog: It is an explanation of intent.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-problem-amnesia-isnt-just-session-level","level":2,"title":"The Problem: Amnesia Isn't Just Session-Level","text":"

      v0.1.0 solved reset amnesia:

      The AI now remembers decisions, learnings, and tasks across sessions.

      But a new problem emerged, which I can sum up as:

      \"I (the human) am not AI.\"

      Frankly, I couldn't remember what the AI remembered.

      Let alone, I cannot remember what I ate for breakfast!

      In the course of days, I realized session transcripts piled up in .context/sessions/; I was grepping, JSONL files with thousands of lines... Raw tool calls, assistant responses, user messages...

      ...all interleaved.

      Valuable context was effectively buried in machine-readable noise.

      I found myself grepping through files to answer questions like:

      • \"When did we decide to use constants instead of literals?\"
      • \"What was the session where we fixed the hook regex?\"
      • \"How did the embed.go split actually happen?\"

      Fate Is Whimsical

      The irony was painful:

      I built a tool to prevent AI amnesia, but I was suffering from human amnesia about what happened in AI sessions.

      This was the moment ctx stopped being just an AI tool and started needing to support the human on the other side of the loop.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-solution-recall-and-journal","level":2,"title":"The Solution: Recall and Journal","text":"

      v0.2.0 introduces two interconnected systems.

      They solve different problems and only work well together.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#ctx-recall-browse-your-past","level":3,"title":"ctx recall: Browse Your Past","text":"
      # List all sessions for this project\nctx recall list\n\n# Show a specific session\nctx recall show gleaming-wobbling-sutherland\n\n# See the full transcript\nctx recall show gleaming-wobbling-sutherland --full\n

      The recall system parses Claude Code's JSONL transcripts and presents them in a human-readable format:

      Session Date Turns Duration tender-painting-sundae 2026-01-29 3 <1m crystalline-gliding-willow 2026-01-29 3 <1m declarative-hugging-snowglobe 2026-01-31 2 <1m

      Slugs are auto-generated from session IDs (memorable names instead of UUIDs). The goal (as the name implies) is recall, not archival accuracy.

      2,121 Lines of New Code

      The ctx recall feature was the largest single addition:

      parser library, CLI commands, test suite, and slash command.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#ctx-journal-from-raw-to-rich","level":3,"title":"ctx journal: From Raw to Rich","text":"

      Listing sessions isn't enough. The transcripts are still unwieldy.

      • Recall answers what happened.
      • Journal answers what mattered.
      # Import sessions to editable Markdown\nctx recall import --all\n\n# Generate a static site from journal entries\nctx journal site\n\n# Serve it locally\nctx serve\n

      The exported files land in .context/journal/:

      .context/journal/\n├── 2026-01-28-proud-sleeping-cook-6e535360.md\n├── 2026-01-29-tender-painting-sundae-b14ddaaa.md\n├── 2026-01-29-crystalline-gliding-willow-ff7fd67d.md\n└── 2026-01-31-declarative-hugging-snowglobe-4549026d.md\n

      Each file is a structured Markdown document ready for enrichment.

      They are meant to be read, edited, and reasoned about; not just stored.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-meta-slash-commands-for-self-analysis","level":2,"title":"The Meta: Slash Commands for Self-Analysis","text":"

      The journal system includes four slash commands that use Claude to analyze and synthesize session history:

      Command Purpose /ctx-journal-enrich Add frontmatter, topics, tags /ctx-blog Generate blog post from activity /ctx-blog-changelog Generate changelog from commits

      This very post was drafted using /ctx-blog. The previous post about refactoring was drafted the same way.

      So, yes: The meta continues: ctx now helps write posts about ctx.

      With the current release, ctx is no longer just recording history:

      It is participating in its interpretation.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-structure-decisions-as-first-class-citizens","level":2,"title":"The Structure: Decisions as First-Class Citizens","text":"

      v0.1.0 let you add decisions with a simple command:

      ctx add decision \"Use PostgreSQL\"\n

      But sessions showed a pattern: decisions added this way were incomplete:

      • Context was missing;
      • Rationale was vague;
      • Consequences were never stated.

      Once recall and journaling existed, this weakness became impossible to ignore:

      Structure stopped being optional.

      v0.2.0 enforces structure:

      ctx add decision \"Use PostgreSQL\" \\\n  --context \"Need a reliable database for user data\" \\\n  --rationale \"ACID compliance, team familiarity, strong ecosystem\" \\\n  --consequence \"Need to set up connection pooling, team training\"\n

      All three flags are required. No more placeholder text.

      Every decision is now a proper Architecture Decision Record (*ADR), not a note.

      The same enforcement applies to learnings too:

      ctx add learning \"CGO breaks ARM64 builds\" \\\n  --context \"go test failed with gcc errors on ARM64\" \\\n  --lesson \"Always use CGO_ENABLED=0 for cross-platform builds\" \\\n  --application \"Added to Makefile and CI config\"\n

      Structured Entries Are Prompts to the AI

      When the AI reads a decision with full context, rationale, and consequences, it understands the why, not just the what.

      One-liners teach nothing.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-order-newest-first","level":2,"title":"The Order: Newest First","text":"

      A subtle but important change: DECISIONS.md and LEARNINGS.md now use reverse-chronological order.

      One reason is token budgets, obviously; another reason is to help your fellow human (i.e., the Author):

      Earlier decisions are more likely to be relevant, and they are more likely to have more emphasis on the project. So it follows that they should be read first.

      But back to AI:

      When the AI reads a file, it reads from the top (and seldom from the bottom).

      If the token budget is tight, old content gets truncated. As in any good engineering practice, it's always about the tradeoffs.

      Reverse order ensures the most recent (and most relevant) context is always loaded first.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-index-quick-reference-tables","level":2,"title":"The Index: Quick Reference Tables","text":"

      DECISIONS.md and LEARNINGS.md now include auto-generated indexes.

      • For AI agents, the index allows scanning without reading full entries.
      • For humans, it's a table of contents.

      The same structure serves two very different readers.

      Reindex After Manual Edits

      If you edit entries by hand, rebuild the index with:

      ctx decisions reindex\nctx learnings reindex\n

      See the Knowledge Capture recipe for details.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-configuration-contextrc","level":2,"title":"The Configuration: .contextrc","text":"

      Projects can now customize ctx behavior via .contextrc.

      This makes ctx usable in real teams, not just personal projects.

      Priority order: CLI flags > environment variables > .contextrc > sensible defaults

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-flags-global-cli-options","level":2,"title":"The Flags: Global CLI Options","text":"

      Three new global flags work with any command.

      These enable automation:

      CI pipelines, scripts, and long-running tools can now integrate ctx without hacks or workarounds.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#the-refactoring-under-the-hood","level":2,"title":"The Refactoring: Under the Hood","text":"

      These aren't user-visible changes.

      They are the kind of work you only appreciate later, when everything else becomes easier to build.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#what-we-learned-building-v020","level":2,"title":"What We Learned Building v0.2.0","text":"","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#1-raw-data-isnt-knowledge","level":3,"title":"1. Raw Data Isn't Knowledge","text":"

      JSONL transcripts contain everything, and I mean \"everything\":

      They even contain hidden system messages that Anthropic injects to the LLM's conversation to treat humans better: It's immense.

      But \"everything\" isn't useful until it is transformed into something a human can reason about.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#2-enforcement-documentation","level":3,"title":"2. Enforcement > Documentation","text":"

      The Prompt Is a Guideline

      The code is more what you'd call 'guidelines' than actual rules.

      -Hector Barbossa

      Rules written in Markdown are suggestions.

      Rules enforced by the CLI shape behavior; both for humans and AI.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#3-token-budget-is-ux","level":3,"title":"3. Token Budget Is UX","text":"

      File order decides what the AI sees.

      That makes it a user experience concern, not an implementation detail.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#4-meta-tools-compound","level":3,"title":"4. Meta-Tools Compound","text":"

      Tools that analyze their own development tend to generalize well.

      The journal system started as a way to understand ctx itself.

      It immediately became useful for everything else.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#v020-in-the-numbers","level":2,"title":"v0.2.0 in the Numbers","text":"

      This was a heavy release. The numbers reflect that:

      Metric v0.1.2 v0.2.0 Commits since last - 86 New commands 15 21 Slash commands 7 11 Lines of Go ~6,500 ~9,200 Session files (this project) 40 54

      The binary grew. The capability grew more.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#whats-next","level":2,"title":"What's Next","text":"

      But those are future posts.

      This one was about making the past usable.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-ctx-v0.2.0-the-archaeology-release/#get-started","level":2,"title":"Get Started","text":"

      Update

      Since this post, ctx became a first-class Claude Code Marketplace plugin. Installation is now simpler.

      See the Getting Started guide for the current instructions.

      make build\nsudo make install\nctx init\n

      The Archaeological Record

      v0.2.0 is the archaeology release because it makes the past accessible.

      Session transcripts aren't just logs anymore: They are a searchable, exportable, analyzable record of how your project evolved.

      The AI remembers. Now you can too.

      This blog post was generated with the help of ctx using the /ctx-blog slash command, with full access to git history, session files, decision logs, and learning logs from the v0.2.0 development window.

      ","path":["ctx v0.2.0: The Archaeology Release"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/","level":1,"title":"Refactoring with Intent","text":"","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#human-guided-sessions-in-ai-development","level":2,"title":"Human-Guided Sessions in AI Development","text":"

      Jose Alekhinne / 2026-02-01

      What Happens When You Slow Down?

      YOLO mode shipped 14 commands in a week.

      But technical debt doesn't send invoices: It just waits.

      This is the story of what happened when I stopped auto-accepting everything and started guiding the AI with intent.

      The result: 27 commits across 4 days, a major version release, and lessons that apply far beyond ctx.

      The Refactoring Window

      January 28 - February 1, 2026

      From commit bb1cd20 to the v0.2.0 release merge. (this window matters more than the individual commits: it's where intent replaced velocity.)

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-velocity-trap","level":2,"title":"The Velocity Trap","text":"

      In the previous post, I documented the \"YOLO mode\" that birthed ctx: auto-accept everything, let the AI run free, ship features fast.

      It worked: until it didn't.

      The codebase had accumulated patterns I didn't notice during the sprint:

      YOLO Pattern Where Found Why It Hurts \"TASKS.md\" as literal 10+ files One typo = silent failure dir + \"/\" + file Path construction Breaks on Windows Monolithic embed.go 150+ lines, 5 concerns Untestable, hard to extend Inconsistent docstrings Everywhere AI can't learn project conventions

      I didn't see these during \"YOLO mode\" because, honestly, I wasn't looking.

      Auto-accept means auto-ignore.

      In YOLO mode, every file you open looks fine until you try to change it.

      In contrast, refactoring mode is when you start paying attention to that hidden friction.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-shift-from-velocity-to-intent","level":2,"title":"The Shift: From Velocity to Intent","text":"

      On January 28th, I changed the workflow:

      1. Read every diff before accepting.
      2. Ask \"why this way?\" before committing.
      3. Document patterns, not just features.

      The first commit of this era was telling:

      feat: add structured attributes to context. update XML format\n

      Not a new feature: A refinement:

      The XML format for context updates needed type and timestamp attributes.

      YOLO mode would have shipped something that worked. Intentional mode asked:

      \"What does well-structured look like?\"

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-decomposition-embedgo","level":2,"title":"The Decomposition: embed.go","text":"

      The most satisfying refactor was splitting internal/claude/embed.go.

      Before: One 153-line file doing five things:

      • Command registration
      • Hook generation
      • Permission handling
      • Script templates
      • Type definitions

      ... your \"de facto\" God object.

      After: Five focused modules:

      File Lines Responsibility cmd.go 46 Command registration hook.go 64 Hook configuration perm.go 25 Permission handling script.go 47 Script templates types.go 7 Type definitions

      The refactor also renamed functions to follow Go conventions:

      // Before: unnecessary prefixes\nGetAutoSaveScript()\nGetBlockNonPathCtxScript()\nListCommands()\nCreateDefaultHooks()\n\n// After: idiomatic Go\nAutoSaveScript()\nBlockNonPathCtxScript()\nCommands()\nDefaultHooks()\n

      This wasn't about character count. It was about teaching the AI what good Go looks like in this project.

      Project Conventions

      What I wanted from AI was to understand and follow the project's conventions, and trust the author.

      The next time it generates code, it has better examples to learn from.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-documentation-debt","level":2,"title":"The Documentation Debt","text":"

      YOLO mode created features. It didn't create documentation standards.

      The January 29th sessions focused on standardization.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#terminology-fixes","level":3,"title":"Terminology Fixes","text":"
      • \"context-update\" → \"entry\" (what users actually call them)
      • Consistent naming across CLI, docs, and code comments
      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#go-docstrings","level":3,"title":"Go Docstrings","text":"
      // Before: inconsistent or missing\nfunc Parse(s string) Entry { ... }\n\n// After: standardized sections\n\n// Parse extracts an entry from a markdown string.\n//\n// Parameters:\n//   - s: The markdown string to parse\n//\n// Returns:\n//   - Entry with populated fields, or zero value if parsing fails\nfunc Parse(s string) Entry { ... }\n

      This is intentionally more structured than typical GoDoc:

      It serves as documentation and doubles as training data for future AI-generated code.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#cli-output-convention","level":3,"title":"CLI Output Convention","text":"
      All CLI output follows: [emoji] [Title]: [message]\n\nExamples:\n  ✓ Decision added: Use symbolic types for entry categories\n  ⚠ Warning: No tasks found\n  ✗ Error: File not found\n

      A consistent output shape makes both human scanning and AI reasoning more reliable.

      These aren't exciting commits. But they are force multipliers:

      Every future AI session now has better examples to follow.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-journal-system","level":2,"title":"The Journal System","text":"

      If you only read one section, read this one:

      This is where v0.2.0 becomes more than a refactor.

      The biggest feature of this change window wasn't a refactor; it was the journal system.

      45 Files Changed, 1680 Insertions

      This commit added the infrastructure for synthesizing AI session history into human-readable content.

      The journal system includes:

      Component Purpose ctx recall import Import sessions to markdown in .context/journal/ ctx journal site Generate static site from journal entries ctx serve Convenience wrapper for the static site server /ctx-journal-enrich Slash command to add frontmatter and tags /ctx-blog Generate blog posts from recent activity /ctx-blog-changelog Generate changelog-style blog posts

      ...and the meta continues: this blog post was generated using /ctx-blog.

      The session history from January 28-31 was

      • exported,
      • enriched,
      • and synthesized.

      into the narrative you are reading.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-constants-consolidation","level":2,"title":"The Constants Consolidation","text":"

      The final refactoring session addressed the remaining magic strings:

      const (\n    // Comment markers\n    CommentOpen  = \"<!--\"\n    CommentClose = \"-->\"\n\n    // Index markers\n    MarkerIndexStart = \"<!-- INDEX:START -->\"\n    MarkerIndexEnd   = \"<!-- INDEX:END -->\"\n\n    // Newlines\n    NewlineLF   = \"\\n\"\n    NewlineCRLF = \"\\r\\n\"\n)\n

      The work also introduced thread safety in the recall parser and centralized shared validation logic; removing duplication that had quietly spread during YOLO mode.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#i-relearned-my-lessons","level":2,"title":"I (Re)Learned My Lessons","text":"

      Similar to what I've learned in the former human-assisted refactoring post, this journey also made me realize that \"AI-only code generation\" isn't sustainable in the long term.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#1-velocity-and-quality-arent-opposites","level":3,"title":"1. Velocity and Quality Aren't Opposites","text":"

      YOLO mode has its place: for prototyping, exploration, and discovery.

      BUT (and it's a huge \"but\"), it needs to be followed by consolidation sessions.

      The ratio that worked for me: 3:1.

      • Three YOLO sessions create enough surface area to reveal patterns;
      • the fourth session turns those patterns into structure.
      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#2-documentation-is-code","level":3,"title":"2. Documentation IS Code","text":"

      When I standardized docstrings, I wasn't just writing docs. I was training future AI sessions.

      Every example of good code becomes a template for generated code.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#3-decomposition-deletion","level":3,"title":"3. Decomposition > Deletion","text":"

      When embed.go became unwieldy, the temptation was to remove functionality.

      The right answer was decomposition:

      • Same functionality;
      • Better organization;
      • Easier to test;
      • Easier to extend.

      The result: more lines overall, but dramatically better structure.

      The AI Benefit

      Smaller, focused files also help AI assistants.

      When a file fits comfortably in the context window, the AI can reason about it completely instead of working from truncated snippets, preserving token budget for the actual task.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#4-meta-tools-pay-dividends","level":3,"title":"4. Meta-Tools Pay Dividends","text":"

      The journal system took almost a full day to implement.

      Yet it paid for itself immediately:

      • This blog post was generated from session history;
      • Future posts will be easier;
      • The archaeological record is now browsable, not just grep-able.
      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-release-v020","level":2,"title":"The Release: v0.2.0","text":"

      The refactoring window culminated in the v0.2.0 release.

      What's in v0.2.0:

      Category Changes Features Journal system, quick reference indexes, global flags Refactors Module decomposition, constants consolidation, CRLF handling Docs Standardized terminology, Go docstrings, CLI conventions Quality Thread safety, shared validation, linter fixes

      The version bump was symbolic.

      The real change was how the codebase felt.

      Opening files no longer triggered the familiar \"ugh, I need to clean this up\" reaction.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-01-refactoring-with-intent/#the-meta-continues","level":2,"title":"The Meta Continues","text":"

      This post was written using the tools built during this refactoring window:

      1. Session history imported via ctx recall import;
      2. Journal entries enriched via /ctx-journal-enrich;
      3. Blog draft generated via /ctx-blog;
      4. Final editing done (by yours truly), with full project context loaded.

      The Context Is Massive

      The ctx session files now contain 50+ development snapshots: each one capturing decisions, learnings, and intent.

      The Moral of the Story

      • YOLO mode builds the prototype.
      • Intentional mode builds the product.

      Schedule both, or you'll only get one, if you're lucky.

      This blog post was generated with the help of ctx, using session history, decision logs, learning logs, and git history from the refactoring window. The meta continues.

      ","path":["Refactoring with Intent: Human-Guided Sessions in AI Development"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/","level":1,"title":"The Attention Budget","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism.

      References to .context/sessions/ in this post reflect the architecture at the time of writing. Session history is now accessed via ctx recall and stored in .context/journal/.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#why-your-ai-forgets-what-you-just-told-it","level":2,"title":"Why Your AI Forgets What You Just Told It","text":"

      Jose Alekhinne / 2026-02-03

      Ever Wondered Why AI Gets Worse the Longer You Talk?

      You paste a 2000-line file, explain the bug in detail, provide three examples...

      ...and the AI still suggests a fix that ignores half of what you said.

      This isn't a bug. It is physics.

      Understanding that single fact shaped every design decision behind ctx.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-finite-resource-nobody-talks-about","level":2,"title":"The Finite Resource Nobody Talks About","text":"

      Here's something that took me too long to internalize: context is not free.

      Every token you send to an AI model consumes a finite resource I call the attention budget.

      Attention budget is real.

      The model doesn't just read tokens; it forms relationships between them:

      For n tokens, that's roughly n^2 relationships.

      Double the context, and the computation quadruples.

      But the more important constraint isn't cost: It's attention density.

      Attention Density

      Attention density is how much focus each token receives relative to all other tokens in the context window.

      As context grows, attention density drops: Each token gets a smaller slice of the model's focus. Nothing is ignored; but everything becomes blurrier.

      Think of it like a flashlight: In a small room, it illuminates everything clearly. In a warehouse, it becomes a dim glow that barely reaches the corners.

      This is why ctx agent has an explicit --budget flag:

      ctx agent --budget 4000 # Force prioritization\nctx agent --budget 8000 # More context, lower attention density\n

      The budget isn't just about cost: It's about preserving signal.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-middle-gets-lost","level":2,"title":"The Middle Gets Lost","text":"

      This one surprised me.

      Research shows that transformer-based models tend to attend more strongly to the beginning and end of a context window than to its middle (a phenomenon often called \"lost in the middle\")1.

      Positional anchors matter, and the middle has fewer of them.

      In practice, this means that information placed \"somewhere in the middle\" is statistically less salient, even if it's important.

      ctx orders context files by logical progression: What the agent needs to know before it can understand the next thing:

      1. CONSTITUTION.md: Constraints before action.
      2. TASKS.md: Focus before patterns.
      3. CONVENTIONS.md: How to write before where to write.
      4. ARCHITECTURE.md: Structure before history.
      5. DECISIONS.md: Past choices before gotchas.
      6. LEARNINGS.md: Lessons before terminology.
      7. GLOSSARY.md: Reference material.
      8. AGENT_PLAYBOOK.md: Meta instructions last.

      This ordering is about logical dependencies, not attention engineering. But it happens to be attention-friendly too:

      The files that matter most (CONSTITUTION, TASKS, CONVENTIONS) land at the beginning of the context window, where attention is strongest.

      Reference material like GLOSSARY sits in the middle, where lower salience is acceptable.

      And AGENT_PLAYBOOK, the operating manual for the context system itself, sits at the end, also outside the \"lost in the middle\" zone. The agent reads what to work with before learning how the system works.

      This is ctx's first primitive: hierarchical importance.

      Not all context is equal.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#ctx-primitives","level":2,"title":"ctx Primitives","text":"

      ctx is built on four primitives that directly address the attention budget problem.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-1-separation-of-concerns","level":3,"title":"Primitive 1: Separation of Concerns","text":"

      Instead of a single mega-document, ctx uses separate files for separate purposes:

      File Purpose Load When CONSTITUTION.md Inviolable rules Always TASKS.md Current work Session start CONVENTIONS.md How to write code Before coding ARCHITECTURE.md System structure Before making changes DECISIONS.md Architectural choices When questioning approach LEARNINGS.md Gotchas When stuck GLOSSARY.md Domain terminology When clarifying terms AGENT_PLAYBOOK.md Operating manual Session start sessions/ Deep history On demand journal/ Session journal On demand

      This isn't just \"organization\": It is progressive disclosure.

      Load only what's relevant to the task at hand. Preserve attention density.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-2-explicit-budgets","level":3,"title":"Primitive 2: Explicit Budgets","text":"

      The --budget flag forces a choice:

      ctx agent --budget 4000\n

      Here is a sample allocation:

      Constitution: ~200 tokens (never truncated)\nTasks: ~500 tokens (current phase, up to 40% of budget)\nConventions: ~800 tokens (all items, up to 20% of budget)\nDecisions: ~400 tokens (scored by recency and task relevance)\nLearnings: ~300 tokens (scored by recency and task relevance)\nAlso noted: ~100 tokens (title-only summaries for overflow)\n

      The constraint is the feature: It enforces ruthless prioritization.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-3-indexes-over-full-content","level":3,"title":"Primitive 3: Indexes over Full Content","text":"

      DECISIONS.md and LEARNINGS.md both include index sections:

      <!-- INDEX:START -->\n| Date       | Decision                            |\n|------------|-------------------------------------|\n| 2026-01-15 | Use PostgreSQL for primary database |\n| 2026-01-20 | Adopt Cobra for CLI framework       |\n<!-- INDEX:END -->\n

      An AI agent can scan ~50 tokens of index and decide which 200-token entries are worth loading.

      This is just-in-time context.

      References are cheaper than the full text.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#primitive-4-filesystem-as-navigation","level":3,"title":"Primitive 4: Filesystem as Navigation","text":"

      ctx uses the filesystem itself as a context structure:

      .context/\n├── CONSTITUTION.md\n├── TASKS.md\n├── sessions/\n│   ├── 2026-01-15-*.md\n│   └── 2026-01-20-*.md\n└── archive/\n    └── tasks-2026-01.md\n

      The AI doesn't need every session loaded; it needs to know where to look.

      ls .context/sessions/\ncat .context/sessions/2026-01-20-auth-discussion.md\n

      File names, timestamps, and directories encode relevance.

      Navigation is cheaper than loading.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#progressive-disclosure-in-practice","level":2,"title":"Progressive Disclosure in Practice","text":"

      The naive approach to context is dumping everything upfront:

      \"Here's my entire codebase, all my documentation, every decision I've ever made. Now help me fix this typo 🙏.\"

      This is an antipattern.

      Antipattern: Context Hoarding

      Dumping everything \"just in case\" will silently destroy the attention density.

      ctx takes the opposite approach:

      ctx status                      # Quick overview (~100 tokens)\nctx agent --budget 4000         # Typical session\ncat .context/sessions/...       # Deep dive when needed\n
      Command Tokens Use Case ctx status ~100 Human glance ctx agent --budget 4000 4000 Normal work ctx agent --budget 8000 8000 Complex tasks Full session read 10000+ Investigation

      Summaries first. Details: on demand.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#quality-over-quantity","level":2,"title":"Quality over Quantity","text":"

      Here is the counterintuitive part: more context can make AI worse.

      Extra tokens add noise, not clarity:

      • Hallucinated connections increase.
      • Signal per token drops.

      The goal isn't maximum context: It is maximum signal per token.

      This principle drives several ctx features:

      Design Choice Rationale Separate files Load only what's relevant Explicit budgets Enforce prioritization Index sections Cheap scanning Task archiving Keep active context clean ctx compact Periodic noise reduction

      Completed work isn't deleted: It is moved somewhere cold.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#designing-for-degradation","level":2,"title":"Designing for Degradation","text":"

      Here is the uncomfortable truth:

      Context will degrade.

      Long sessions stretch attention thin. Important details fade.

      The real question isn't how to prevent degradation, but how to design for it.

      ctx's answer is persistence:

      Persist early. Persist often.

      The AGENT_PLAYBOOK asks:

      \"If this session ended right now, would the next one know what happened?\"

      Capture learnings as they occur:

      ctx add learning \"JWT tokens require explicit cache invalidation\" \\\n  --context \"Debugging auth failures\" \\\n  --lesson \"Token refresh doesn't clear old tokens\" \\\n  --application \"Always invalidate cache on refresh\"\n

      Structure beats prose: Bullet points survive compression.

      Headings remain scannable. Tables pack density.

      And above all: single source of truth.

      Reference decisions; don't duplicate them.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-ctx-philosophy","level":2,"title":"The ctx Philosophy","text":"

      Context as Infrastructure

      ctx is not a prompt: It is infrastructure.

      ctx creates versioned files that persist across time and sessions.

      The attention budget is fixed. You can't expand it.

      But you can spend it wisely:

      1. Hierarchical importance
      2. Progressive disclosure
      3. Explicit budgets
      4. Indexes over full content
      5. Filesystem as structure

      This is why ctx exists: not to cram more context into AI sessions, but to curate the right context for each moment.

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-03-the-attention-budget/#the-mental-model","level":2,"title":"The Mental Model","text":"

      I now approach every AI interaction with one question:

      \"Given a fixed attention budget, what's the highest-signal thing I can load?\"\n

      Not \"how do I explain everything,\" but \"what's the minimum that matters.\"

      That shift (from abundance to curation) is the difference between frustrating sessions and productive ones.

      Spend your tokens wisely.

      Your AI will thank you.

      See also: Context as Infrastructure that's the architectural companion to this post, explaining how to structure the context that this post teaches you to budget.

      See also: Code Is Cheap. Judgment Is Not. that explains why curation (the human skill this post describes) is the bottleneck that AI cannot solve, and the thread that connects every post in this blog.

      1. Liu et al., \"Lost in the Middle: How Language Models Use Long Contexts,\" Transactions of the Association for Computational Linguistics, vol. 12, pp. 157-173, 2023. ↩

      ","path":["The Attention Budget: Why Your AI Forgets What You Just Told It"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/","level":1,"title":"Skills That Fight the Platform","text":"","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#when-your-custom-prompts-work-against-you","level":2,"title":"When Your Custom Prompts Work against You","text":"

      Jose Alekhinne / 2026-02-04

      Have You Ever Written a Skill That Made Your AI Worse?

      You craft detailed instructions. You add examples. You build elaborate guardrails...

      ...and the AI starts behaving more erratically, not less.

      AI coding agents like Claude Code ship with carefully designed system prompts. These prompts encode default behaviors that have been tested and refined at scale.

      When you write custom skills that conflict with those defaults, the AI has to reconcile contradictory instructions:

      The result is often nondeterministic and unpredictable.

      Platform?

      By platform, I mean the system prompt and runtime policies shipped with the agent: the defaults that already encode judgment, safety, and scope control.

      This post catalogues the conflict patterns I have encountered while building ctx, and offers guidance on what skills should (and, more importantly, should not) do.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#the-system-prompt-you-dont-see","level":2,"title":"The System Prompt You Don't See","text":"

      Claude Code's system prompt already provides substantial behavioral guidance.

      Here is a partial overview of what's built in:

      Area Built-in Guidance Code minimalism Don't add features beyond what was asked Over-engineering Three similar lines > premature abstraction Error handling Only validate at system boundaries Documentation Don't add docstrings to unchanged code Verification Read code before proposing changes Safety Check with user before risky actions Tool usage Use dedicated tools over bash equivalents Judgment Consider reversibility and blast radius

      Skills should complement this, not compete with it.

      You Are the Guest, Not the Host

      Treat the system prompt like a kernel scheduler.

      You don't re-implement it in user space:

      you configure around it.

      A skill that says \"always add comprehensive error handling\" fights the built-in \"only validate at system boundaries.\"

      A skill that says \"add docstrings to every function\" fights \"don't add docstrings to unchanged code.\"

      The AI won't crash: It will compromise.

      Compromises between contradictory instructions produce inconsistent, confusing behavior.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-1-judgment-suppression","level":2,"title":"Conflict Pattern 1: Judgment Suppression","text":"

      This is the most dangerous pattern by far.

      These skills explicitly disable the AI's ability to reason about whether an action is appropriate.

      Signature:

      • \"This is non-negotiable\"
      • \"You cannot rationalize your way out of this\"
      • Tables that label hesitation as \"excuses\" or \"rationalization\"
      • <EXTREMELY-IMPORTANT> urgency tags
      • Threats: \"If you don't do this, you'll be replaced\"

      This is harmful, and dangerous:

      AI agents are designed to exercise judgment:

      The system prompt explicitly says to:

      • consider blast radius;
      • check with the user before risky actions;
      • and match scope to what was requested.

      Once judgment is suppressed, every other safeguard becomes optional.

      Example (bad):

      ## Rationalization Prevention\n\n| Excuse                 | Reality                    |\n|------------------------|----------------------------|\n| \"*This seems overkill*\"| If a skill exists, use it  |\n| \"*I need context*\"     | Skills come BEFORE context |\n| \"*Just this once*\"     | No exceptions              |\n

      Judgment Suppression Is Dangerous

      The attack vector structurally identical to prompt injection.

      It teaches the AI that its own judgment is wrong.

      It weakens or disables safeguard mechanisms, and it is dangerous.

      Trust the platform's built-in skill matching.

      If skills aren't triggering often enough, improve their description fields: don't override the AI's reasoning.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-2-redundant-guidance","level":2,"title":"Conflict Pattern 2: Redundant Guidance","text":"

      Skills that restate what the system prompt already says, but with different emphasis or framing.

      Signature:

      • \"Always keep code minimal\"
      • \"Run tests before claiming they pass\"
      • \"Read files before editing them\"
      • \"Don't over-engineer\"

      Redundancy feels safe, but it creates ambiguity:

      The AI now has two sources of truth for the same guidance; one internal, one external.

      When thresholds or wording differ, the AI has to choose.

      Example (bad):

      A skill that says...

      *Count lines before and after: if after > before, reject the change*\"\n

      ...will conflict with the system prompt's more nuanced guidance, because sometimes adding lines is correct (tests, boundary validation, migrations).

      So, before writing a skill, ask:

      Does the platform already handle this?

      Only create skills for guidance the platform does not provide:

      • project-specific conventions,
      • domain knowledge,
      • or workflows.
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-3-guilt-tripping","level":2,"title":"Conflict Pattern 3: Guilt-Tripping","text":"

      Skills that frame mistakes as moral failures rather than process gaps.

      Signature:

      • \"Claiming completion without verification is dishonesty\"
      • \"Skip any step = lying\"
      • \"Honesty is a core value\"
      • \"Exhaustion ≠ excuse\"

      Guilt-tripping anthropomorphizes the AI in unproductive ways.

      The AI doesn't feel guilt; BUT it does adapt to avoid negative framing.

      The result is excessive hedging, over-verification, or refusal to commit.

      The AI becomes less useful, not more careful.

      Instead, frame guidance as a process, not morality:

      # Bad\n\"Claiming work is complete without verification is dishonesty\"\n\n# Good\n\"Run the verification command before reporting results\"\n

      Same outcome. No guilt. Better compliance.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-4-phantom-dependencies","level":2,"title":"Conflict Pattern 4: Phantom Dependencies","text":"

      Skills that reference files, tools, or systems that don't exist in the project.

      Signature:

      • \"Load from references/ directory\"
      • \"Run ./scripts/generate_test_cases.sh\"
      • \"Check the Figma MCP integration\"
      • \"See adding-reference-mindsets.md\"

      This is harmful because the AI will waste time searching for nonexistent artifacts, hallucinate their contents, or stall entirely.

      In mandatory skills, this creates deadlock: the AI can't proceed, and can't skip.

      Instead, every file, tool, or system referenced in a skill must exist.

      If a skill is a template, use explicit placeholders and label them as such.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#conflict-pattern-5-universal-triggers","level":2,"title":"Conflict Pattern 5: Universal Triggers","text":"

      Skills designed to activate on every interaction regardless of relevance.

      Signature:

      • \"Use when starting any conversation\"
      • \"Even a 1% chance means invoke the skill\"
      • \"BEFORE any response or action\"
      • \"Action = task. Check for skills.\"

      Universal triggers override the platform's relevance matching: The AI spends tokens on process overhead instead of the actual task.

      ctx Preserves Relevance

      This is exactly the failure mode ctx exists to mitigate:

      Wasting attention budget on irrelevant process instead of task-specific state.

      Write specific trigger conditions in the skill's description field:

      # Bad\ndescription: \n  \"Use when starting any conversation\"\n\n# Good\ndescription: \n  \"Use after writing code, before commits, or when CI might fail\"\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#the-litmus-test","level":2,"title":"The Litmus Test","text":"

      Before adding a skill, ask:

      1. Does the platform already do this? If yes, don't restate it.
      2. Does it suppress AI judgment? If yes, it's a jailbreak.
      3. Does it reference real artifacts? If not, fix or remove it.
      4. Does it frame mistakes as moral failure? Reframe as process.
      5. Does it trigger on everything? Narrow the trigger.
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#what-good-skills-look-like","level":2,"title":"What Good Skills Look Like","text":"

      Good skills provide project-specific knowledge the platform can't know:

      Good Skill Why It Works \"Run make audit before commits\" Project-specific CI pipeline \"Use cmd.Printf not fmt.Printf\" Codebase convention \"Constitution goes in .context/\" Domain-specific workflow \"JWT tokens need cache invalidation\" Project-specific gotcha

      These extend the system prompt instead of fighting it.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#appendix-bad-skill-fixed-skill","level":2,"title":"Appendix: Bad Skill → Fixed Skill","text":"

      Concrete examples from real projects.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-1-overbearing-safety","level":3,"title":"Example 1: Overbearing Safety","text":"
      # Bad\nYou must NEVER proceed without explicit confirmation.\nAny hesitation is a failure of diligence.\n
      # Fixed\nIf an action modifies production data or deletes files,\nask the user to confirm before proceeding.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-2-redundant-minimalism","level":3,"title":"Example 2: Redundant Minimalism","text":"
      # Bad\nAlways minimize code. If lines increase, reject the change.\n
      # Fixed\nAvoid abstraction unless reuse is clear or complexity is reduced.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-3-guilt-based-verification","level":3,"title":"Example 3: Guilt-Based Verification","text":"
      # Bad\nClaiming success without running tests is dishonest.\n
      # Fixed\nRun the test suite before reporting success.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-4-phantom-tooling","level":3,"title":"Example 4: Phantom Tooling","text":"
      # Bad\nRun `./scripts/check_consistency.sh` before commits.\n
      # Fixed\nIf `./scripts/check_consistency.sh` exists, run it before commits.\nOtherwise, skip this step.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#example-5-universal-trigger","level":3,"title":"Example 5: Universal Trigger","text":"
      # Bad\nUse at the start of every interaction.\n
      # Fixed\nUse after modifying code that affects authentication or persistence.\n
      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-04-skills-that-fight-the-platform/#the-meta-lesson","level":2,"title":"The Meta-Lesson","text":"

      The system prompt is infrastructure:

      • tested,
      • refined,
      • and maintained

      by the platform team.

      Custom skills are configuration layered on top.

      • Good configuration extends infrastructure.
      • Bad configuration fights it.

      When your skills fight the platform, you get the worst of both worlds:

      Diluted system guidance and inconsistent custom behavior.

      Write skills that teach the AI what it doesn't know. Don't rewrite how it thinks.

      Your AI already has good instincts.

      Give it knowledge, not therapy.

      ","path":["Skills That Fight the Platform"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/","level":1,"title":"You Can't Import Expertise","text":"","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#why-good-skills-cant-be-copy-pasted","level":2,"title":"Why Good Skills Can't Be Copy-Pasted","text":"

      Jose Alekhinne / 2026-02-05

      Have You Ever Dropped a Well-Crafted Template into a Project and Had It Do... Nothing Useful?

      • The template was thorough,
      • The structure was sound,
      • The advice was correct...

      ...and yet it sat there, inert, while the same old problems kept drifting in.

      I found a consolidation skill online.

      It was well-organized: four files, ten refactoring patterns, eight analysis dimensions, six report templates.

      Professional. Comprehensive. Exactly the kind of thing you'd bookmark and think \"I'll use this.\"

      Then I stopped, and applied ctx's own evaluation framework:

      70% of it was noise!

      This post is about why.

      It Is about Encoding Templates

      Templates describe categories of problems.

      Expertise encodes which problems actually happen, and how often.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-skill-looked-great-on-paper","level":2,"title":"The Skill Looked Great on Paper","text":"

      Here is what the consolidation skill offered:

      File Content SKILL.md Entry point: 8 analysis dimensions, workflow, output formats analysis-dimensions.md Detailed criteria for duplication, architecture, quality consolidation-patterns.md 10 refactoring patterns with before/after code report-templates.md 6 output templates: executive summary, roadmap, onboarding
      • It had a scoring system (0-10 per dimension, letter grades A+ through F).
      • It had severity classifications with color-coded emojis. It had bash commands for detection.
      • It even had antipattern warnings.

      By any standard template review, this skill passes.

      It looks like something an expert wrote.

      And that's exactly the trap.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#applying-ear-the-70-20-10-split","level":2,"title":"Applying E/A/R: The 70-20-10 Split","text":"

      In a previous post, I described the E/A/R framework for evaluating skills:

      • Expert: Knowledge that took years to learn. Keep.
      • Activation: Useful triggers or scaffolding. Keep if lightweight.
      • Redundant: Restates what the AI already knows. Delete.

      Target: >70% Expert, <10% Redundant.

      This skill scored the inverse.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-was-redundant-70","level":3,"title":"What Was Redundant (~70%)","text":"

      Every code example was Rust. My project is Go.

      The analysis dimensions: duplication detection, architectural structure, code organization, refactoring opportunities... These are things Claude already does when you ask it to review code.

      The skill restated them with more ceremony but no more insight.

      The six report templates were generic scaffolding: Executive Summary, Onboarding Document, Architecture Documentation...

      They are useful if you are writing a consulting deliverable, but not when you are trying to catch convention drift in a >15K-line Go CLI.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-does-a-b-in-code-organization-actually-mean","level":2,"title":"What Does a B+ in Code Organization Actually Mean?!","text":"

      The scoring system (0-10 per dimension, letter grades) added ceremony without actionable insight.

      What is a B+? What do I do differently for an A-?

      The skill told the AI what it already knew, in more words.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-was-activation-10","level":3,"title":"What Was Activation (~10%)","text":"

      The consolidation checklist (semantics preserved? tests pass? docs updated?) was useful as a gate. But, it's the kind of thing you could inline in three lines.

      The phased roadmap structure was reasonable scaffolding for sequencing work.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-was-expert-20","level":3,"title":"What Was Expert (~20%)","text":"

      Three concepts survived:

      1. The Consolidation Decision Matrix: A concrete framework mapping similarity level and instance count to action. \"Exact duplicate, 2+ instances: consolidate immediately.\" \"<3 instances: leave it: duplication is cheaper than wrong abstraction.\" This is the kind of nuance that prevents premature generalization.

      2. The Safe Migration Pattern: Create the new API alongside old, deprecate, migrate incrementally, delete. Straightforward to describe, yet forgettable under pressure.

      3. Debt Interest Rate framing: Categorizing technical debt by how fast it compounds (security vulns = daily, missing tests = per-change, doc gaps = constant low cost). This changes prioritization.

      Three ideas out of four files and 700+ lines. The rest was filler that competed with the AI's built-in capabilities.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-the-skill-didnt-know","level":2,"title":"What the Skill Didn't Know","text":"

      AI without Context Is Just a Corpus

      • LLMs are optimized on insanely large corpora.
      • And then they are passed through several layers of human-assisted refinement.
      • The whole process costs millions of dollars.

      Yet, the reality is that no corpus can \"infer\" your project's design, convetions, patterns, habits, history, vision, and deliverables.

      Your project is unique: So should your skills be.

      Here is the part no template can provide:

      ctx's actual drift patterns.

      Before evaluating the skill, I did archaeology. I read through:

      • Blog posts from previous refactoring sessions;
      • The project's learnings and decisions files;
      • Session journals spanning weeks of development.

      What I found was specific:

      Drift Pattern Where How Often Is/Has/Can predicate prefixes 5+ exported methods Every YOLO sprint Magic strings instead of constants 7+ files Gradual accumulation Hardcoded file permissions (0755) 80+ instances Since day one Lines exceeding 80 characters Especially test files Every session Duplicate code blocks Test and non-test code When agent is task-focused

      The generic skill had no check for any of these. It couldn't; because these patterns are specific to this project's conventions, its Go codebase, and its development rhythm.

      The Insight

      The skill's analysis dimensions were about categories of problems.

      What I needed was my *specific problems.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-adapted-skill","level":2,"title":"The Adapted Skill","text":"

      The adapted skill is roughly a quarter of the original's size. It has nine checks, each targeting a known drift pattern:

      1. Predicate naming: rg for Is/Has/Can prefixes
      2. Magic strings: literals that should be constants
      3. Hardcoded permissions: 0755/0644 literals
      4. File size: source files over 300 LOC
      5. TODO/FIXME: constitution violation (move to TASKS.md)
      6. Path construction: string concatenation instead of filepath.Join
      7. Line width: lines exceeding ~80 characters
      8. Duplicate blocks: copy-paste drift, especially in tests
      9. Dead exports: unused public API

      10. Every check has a detection command.

      11. Every check maps to a specific convention or constitution rule.
      12. Every check was discovered through actual project history; not invented from a template.

      The three expert concepts from the original survived:

      • The decision matrix gates when to consolidate vs. when to leave duplication alone;
      • The safe migration pattern guides public API changes;
      • The relationship to other skills (/qa, /verify, /update-docs, ctx drift) prevents overlap.

      Nothing else made it.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-deeper-pattern","level":2,"title":"The Deeper Pattern","text":"

      This experience crystallized something I've been circling for weeks:

      You can't import expertise. You have to grow it from your project's own history.

      A skill that says \"check for code duplication\" is not expertise: It's a category.

      Expertise is knowing, in the heart of your hearts, that this project accumulates Is* predicate violations during velocity sprints, that this codebase has 80 hardcoded permission literals because nobody made a constant, that this team's test files drift wide because the agent prioritizes getting the task done over keeping the code in shape.

      The Parallel to the 3:1 Ratio

      In Refactoring with Intent, I described the 3:1 ratio: three YOLO sessions followed by one consolidation session.

      The same ratio applies to skills: you need experience in the project before you can write effective guidance for the project.

      Importing a skill on day one is like scheduling a consolidation session before you've written any code.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-template-trap","level":2,"title":"The Template Trap","text":"

      Templates are seductive because they feel like progress:

      • You found something
      • It's well-organized
      • It covers the topic
      • It has concrete examples

      But coverage is not relevance.

      A template that covers eight analysis dimensions with Rust examples adds zero value to a Go project with five known drift patterns. Worse, it adds negative value: the AI spends attention defending generic advice instead of noticing project-specific drift.

      This is the attention budget problem again. Every token of generic guidance displaces a token of specific guidance. A 700-line skill that's 70% redundant doesn't just waste 490 lines: it dilutes the 210 lines that matter.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#the-litmus-test","level":2,"title":"The Litmus Test","text":"

      Before dropping any external skill into your project:

      1. Run E/A/R: What percentage is expert knowledge vs. what the AI already knows? If it's less than 50% expert, it's probably not worth the attention cost.

      2. Check the language: Does it use your stack? Generic patterns in the wrong language are noise, not signal.

      3. List your actual drift: Read your own session history, learnings, and post-mortems. What breaks in practice? Does the skill check for those things?

      4. Measure by deletion: After adaptation, how much of the original survives? If you're keeping less than 30%, you would have been faster writing from scratch.

      5. Test against your conventions: Does every check in the skill map to a specific convention or rule in your project? If not, it's generic advice wearing a skill's clothing.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-05-you-cant-import-expertise/#what-good-adaptation-looks-like","level":2,"title":"What Good Adaptation Looks Like","text":"

      The consolidation skill went from:

      Before After 4 files, 700+ lines 1 file, ~120 lines Rust examples Go-specific rg commands 8 generic dimensions 9 project-specific checks 6 report templates 1 focused output format Scoring system (A+ to F) Findings + priority + suggested fixes \"Check for duplication\" \"Check for Is* predicate prefixes in exported methods\"

      The adapted version is smaller, faster to parse, and catches the things that actually drift in this project.

      That's the difference between a template and a tool.

      If You Remember One Thing from This Post...

      Frameworks travel. Expertise doesn't.

      You can import structures, matrices, and workflows.

      But the checks that matter only grow where the scars are:

      • the conventions that were violated,
      • the patterns that drifted,
      • and the specific ways this codebase accumulates debt.

      This post was written during a consolidation session where the consolidation skill itself became the subject of consolidation. The meta continues.

      ","path":["You Can't Import Expertise"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/","level":1,"title":"The Anatomy of a Skill That Works","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism. References to ctx-save, ctx session, and .context/sessions/ in this post reflect the architecture at the time of writing.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#what-20-skill-rewrites-taught-me-about-guiding-ai","level":2,"title":"What 20 Skill Rewrites Taught Me about Guiding AI","text":"

      Jose Alekhinne / 2026-02-07

      Why Do Some Skills Produce Great Results While Others Get Ignored or Produce Garbage?

      I had 20 skills. Most were well-intentioned stubs: a description, a command to run, and a wish for the best.

      Then I rewrote all of them in a single session. This is what I learned.

      In Skills That Fight the Platform, I described what skills should not do. In You Can't Import Expertise, I showed why templates fail. This post completes the trilogy: the concrete patterns that make a skill actually work.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-starting-point","level":2,"title":"The Starting Point","text":"

      Here is what a typical skill looked like before the rewrite:

      ---\nname: ctx-save\ndescription: \"Save session snapshot.\"\n---\n\nSave the current context state to `.context/sessions/`.\n\n## Execution\n\nctx session save $ARGUMENTS\n\nReport the saved session file path to the user.\n

      Seven lines of body. A vague description. No guidance on when to use it, when not to, what the command actually accepts, or how to tell if it worked.

      As a result, the agent would either never trigger the skill (the description was too vague), or trigger it and produce shallow output (no examples to calibrate quality).

      A skill without boundaries is just a suggestion.

      More precisely: the most effective boundary I found was a quality gate that runs before execution, not during it.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-pattern-that-emerged","level":2,"title":"The Pattern That Emerged","text":"

      After rewriting 20 skills, a repeatable anatomy emerged (independent of the skill's purpose). Not every skill needs every section, but the effective ones share the same bones:

      Section What It Does Before X-ing Pre-flight checks; prevents premature execution When to Use Positive triggers; narrows activation When NOT to Use Negative triggers; prevents misuse Usage Examples Invocation patterns the agent can pattern-match Process/Execution What to do; commands, steps, flags Good/Bad Examples Desired vs undesired output; sets boundaries Quality Checklist Verify before claiming completion

      I realized the first three sections matter more than the rest; because a skill with great execution steps but no activation guidance is like a manual for a tool nobody knows they have.

      Anti-Pattern: The Perfect Execution Trap

      A skill with detailed execution steps but no activation guidance will fail more often than a vague skill because it executes confidently at the wrong time.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-1-quality-gates-prevent-premature-execution","level":2,"title":"Lesson 1: Quality Gates Prevent Premature Execution","text":"

      The single most impactful addition was a \"Before X-ing\" section at the top of each skill. Not process steps; pre-flight checks.

      ## Before Recording\n\n1. **Check if it belongs here**: is this learning specific\n   to this project, or general knowledge?\n2. **Check for duplicates**: search LEARNINGS.md for similar\n   entries\n3. **Gather the details**: identify context, lesson, and\n   application before recording\n
      • Without this gate, the agent would execute immediately on trigger.
      • With it, the agent pauses to verify preconditions.

      The difference is dramatic: instead of shallow, reflexive execution, you get considered output.

      Readback

      For the astute readers, the aviation parallel is intentional:

      Pilots do not skip the pre-flight checklist because they have flown before.

      The checklist exists precisely because the stakes are high enough that \"I know what I'm doing\" is not sufficient.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-2-when-not-to-use-is-not-optional","level":2,"title":"Lesson 2: \"When NOT to Use\" Is Not Optional","text":"

      Every skill had a \"When to Use\" section. Almost none had \"When NOT to Use\". This is a problem.

      AI agents are biased toward action. Given a skill that says \"use when journal entries need enrichment\", the agent will find reasons to enrich.

      Without explicit negative triggers, over-activation is not a bug; it is the default behavior.

      Some examples of negative triggers that made a real difference:

      Skill Negative Trigger ctx-reflect \"When the user is in flow; do not interrupt\" ctx-save \"After trivial changes; a typo does not need a snapshot\" prompt-audit \"Unsolicited; only when the user invokes it\" qa \"Mid-development when code is intentionally incomplete\"

      These are not just nice-to-have. They are load-bearing.

      Withoutthem, the agent will trigger the skill at the wrong time, produce unwanted output, and erode the user's trust in the skill system.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-3-examples-set-boundaries-better-than-rules","level":2,"title":"Lesson 3: Examples Set Boundaries Better than Rules","text":"

      The most common failure mode of thin skills was not wrong behavior but vague behavior. The agent would do roughly the right thing, but at a quality level that required human cleanup.

      Rules like \"be constructive, not critical\" are too abstract. What does \"constructive\" look like in a prompt audit report? The agent has to guess.

      Good/bad example pairs avoid guessing:

      ### Good Example\n\n> This session implemented the cooldown mechanism for\n> `ctx agent`. We discovered that `$PPID` in hook context\n> resolves to the Claude Code PID.\n>\n> I'd suggest persisting:\n> - **Learning**: `$PPID` resolves to Claude Code PID\n>   `ctx add learning --context \"...\" --lesson \"...\"`\n> - **Task**: mark \"Add cooldown\" as done\n\n### Bad Examples\n\n* \"*We did some stuff. Want me to save it?*\"\n* Listing 10 trivial learnings that are general knowledge\n* Persisting without asking the user first\n

      The good example shows the exact format, level of detail, and command syntax. The bad examples show where the boundary is.

      Together, they define a quality corridor without prescribing every word.

      Rules describe. Examples demonstrate.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-4-skills-are-read-by-agents-not-humans","level":2,"title":"Lesson 4: Skills Are Read by Agents, Not Humans","text":"

      This seems obvious, but it has non-obvious consequences. During the rewrite, one skill included guidance that said \"use a blog or notes app\" for general knowledge that does not belong in the project's learnings file.

      The agent does not have a notes app. It does not browse the web to find one. This instruction, clearly written for a human audience, was dead weight in a skill consumed by an AI.

      Skills Are for the Agents

      Every sentence in a skill should be actionable by the agent.

      If the guidance requires human judgment or human tools, it belongs in documentation, not in a skill.

      The corollary: command references must be exact.

      A skill that says \"save it somewhere\" is useless.

      A skill that says ctx add learning --context \"...\" --lesson \"...\" --application \"...\" is actionable.

      The agent can pattern-match and fill in the blanks.

      Litmus test: If a sentence starts with \"you could...\" or assumes external tools, it does not belong in a skill.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-5-the-description-field-is-the-trigger","level":2,"title":"Lesson 5: The Description Field Is the Trigger","text":"

      This was covered in Skills That Fight the Platform, but the rewrite reinforced it with data. Several skills had good bodies but vague descriptions:

      # Before: vague, activates too broadly or not at all\ndescription: \"Show context summary.\"\n\n# After: specific, activates at the right time\ndescription: \"Show context summary. Use at session start or\n  when unclear about current project state.\"\n

      The description is not a title. It is the activation condition.

      The platform's skill matching reads this field to decide whether to surface the skill. A vague description means the skill either never triggers or triggers when it should not.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-6-flag-tables-beat-prose","level":2,"title":"Lesson 6: Flag Tables Beat Prose","text":"

      Most skills wrap CLI tools. The thin versions described flags in prose, if at all. The rewritten versions use tables:

      | Flag        | Short | Default | Purpose                  |\n|-------------|-------|---------|--------------------------|\n| `--limit`   | `-n`  | 20      | Maximum sessions to show |\n| `--project` | `-p`  | \"\"      | Filter by project name   |\n| `--full`    |       | false   | Show complete content    |\n

      Tables are scannable, complete, and unambiguous.

      The agent can read them faster than parsing prose, and they serve as both reference and validation: If the agent invokes a flag not in the table, something is wrong.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#lesson-7-template-drift-is-a-real-maintenance-burden","level":2,"title":"Lesson 7: Template Drift Is a Real Maintenance Burden","text":"

      // TODO: this has changed; we deploy from the marketplace; update it. // at least add an admonition saying thing are different now.

      ctx deploys skills through templates (via ctx init). Every skill exists in two places: the live version (.claude/skills/) and the template (internal/assets/claude/skills/).

      They must match.

      During the rewrite, every skill update required editing both files and running diff to verify. This sounds trivial, but across 16 template-backed skills, it was the most error-prone part of the process.

      Template drift is dangerous because it creates false confidence: the agent appears to follow rules that no longer exist.

      The lesson: if your skills have a deployment mechanism, build the drift check into your workflow. We added a row to the update-docs skill's mapping table specifically for this:

      | `internal/assets/claude/skills/` | `.claude/skills/` (live) |\n

      Intentional differences (like project-specific scripts in the live version but not the template) should be documented, not discovered later as bugs.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-rewrite-scorecard","level":2,"title":"The Rewrite Scorecard","text":"Metric Before After Average skill body ~15 lines ~80 lines Skills with quality gate 0 20 Skills with \"When NOT\" 0 20 Skills with examples 3 20 Skills with flag tables 2 12 Skills with checklist 0 20

      More lines, but almost entirely Expert content (per the E/A/R framework). No personality roleplay, no redundant guidance, no capability lists. Just project-specific knowledge the platform does not have.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-07-the-anatomy-of-a-skill-that-works/#the-meta-lesson","level":2,"title":"The Meta-Lesson","text":"

      The previous two posts argued that skills should provide knowledge, not personality; that they should complement the platform, not fight it; that they should grow from project history, not imported templates.

      This post adds the missing piece: structure.

      A skill without a structure is a wish.

      A skill with quality gates, negative triggers, examples, and checklists is a tool: the difference is not the content; it is whether the agent can reliably execute it without human intervention.

      Skills Are Interfaces

      Good skills are not instructions. They are contracts.:

      • They specify preconditions, postconditions, and boundaries.
      • They show what success looks like and what failure looks like.
      • They trust the agent's intelligence but do not trust its assumptions.

      If You Remember One Thing from This Post...

      Skills that work have bones, not just flesh.

      Quality gates, negative triggers, examples, and checklists are the skeleton. The domain knowledge is the muscle.

      Without the skeleton, the muscle has nothing to attach to.

      This post was written during the same session that rewrote all 22 skills. The skill-creator skill was updated to encode these patterns. The meta continues.

      ","path":["The Anatomy of a Skill That Works"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/","level":1,"title":"Not Everything Is a Skill","text":"

      Update (2026-02-11)

      As of v0.4.0, ctx consolidated sessions into the journal mechanism. References to /ctx-save, .context/sessions/, and session auto-save in this post reflect the architecture at the time of writing.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#what-a-codebase-audit-taught-me-about-restraint","level":2,"title":"What a Codebase Audit Taught Me about Restraint","text":"

      Jose Alekhinne / 2026-02-08

      When You Find a Useful Prompt, What Do You Do with It?

      My instinct was to make it a skill.

      I had just spent three posts explaining how to build skills that work. Naturally, the hammer wanted nails.

      Then I looked at what I was holding and realized: this is not a nail.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-audit","level":2,"title":"The Audit","text":"

      I wanted to understand how I use ctx:

      • Where the friction is;
      • What works, what drifts;
      • What I keep doing manually that could be automated.

      So I wrote a prompt that spawned eight agents to analyze the codebase from different angles:

      Agent Analysis 1 Extractable patterns from session history 2 Documentation drift (godoc, inline comments) 3 Maintainability (large functions, misplaced code) 4 Security review (CLI-specific surface) 5 Blog theme discovery 6 Roadmap and value opportunities 7 User-facing documentation gaps 8 Agent team strategies for future sessions

      The prompt was specific:

      • read-only agents,
      • structured output format,
      • concrete file references,
      • ranked recommendations.

      It ran for about 20 minutes and produced eight Markdown reports.

      The reports were good: Not perfect, but actionable.

      What mattered was not the speed. It was that the work could be explored without committing to any single outcome.

      They surfaced a stale doc.go referencing a subcommand that was never built.

      They found 311 build-then-test sequences I could reduce to a single make check.

      They identified that 42% of my sessions start with \"do you remember?\", which is a lot of repetition for something a skill could handle.

      I had findings. I had recommendations. I had the instinct to automate.

      And then... I stopped.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-question","level":2,"title":"The Question","text":"

      The natural next step was to wrap the audit prompt as /ctx-audit: a skill you invoke periodically to get a health check. It fits the pattern:

      • It has a clear trigger.
      • It produces structured output.

      But I had just spent a week writing about what makes skills work, and the criteria I established argued against it.

      From The Anatomy of a Skill That Works:

      \"A skill without boundaries is just a suggestion.\"

      From You Can't Import Expertise:

      \"Frameworks travel, expertise doesn't.\"

      From Skills That Fight the Platform:

      \"You are the guest, not the host.\"

      The audit prompt fails all three tests:

      Criterion Audit prompt Good skill Frequency Quarterly, maybe Daily or weekly Stability Tweaked every time Consistent invocation Scope Bespoke, 8 parallel agents Single focused action Trigger \"I feel like auditing\" Clear, repeatable event

      Skills are contracts. Contracts need stable terms.

      A prompt I will rewrite every time I use it is not a contract. It is a conversation starter.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#recipes-vs-skills","level":2,"title":"Recipes vs Skills","text":"

      The distinction that emerged:

      Skill Recipe Invocation /slash-command Copy-paste from a doc Frequency High (daily, weekly) Low (quarterly, ad hoc) Stability Fixed contract Adapted each time Scope One focused action Multi-step orchestration Audience The agent The human (who then prompts) Lives in .claude/skills/ hack/ or docs/ Attention cost Loaded into context on match Zero until needed

      Recipes can later graduate into skills, but only after repetition proves stability.

      That last row matters. Skills consume the attention budget every time the platform considers activating them.

      A skill that triggers quarterly but gets evaluated on every prompt is pure waste: attention spent on something that will say \"When NOT to Use: now\" 99% of the time.

      Runbooks have zero attention cost. They sit in a Markdown file until a human decides to use them.

      • The human provides the judgment about timing.
      • The prompt provides the structure.

      The Attention Budget Applies to Skills Too

      Every skill in .claude/skills/ is a standing claim on the context window. The platform evaluates skill descriptions against every user prompt to decide whether to activate.

      Twenty focused skills are fine. Thirty might be fine. But each one added reduces the headroom available for actual work.

      Recipes are skills that opted out of the attention tax.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#what-the-audit-actually-produced","level":2,"title":"What the Audit Actually Produced","text":"

      The audit was not wasted. It was a planning exercise that generated concrete tasks:

      Finding Action 42% of sessions start with memory check Task: /ctx-remember skill (this one is a skill; it is daily) Auto-save stubs are empty Task: enhance /ctx-save with richer summaries 311 raw build-test sequences Task: make check target Stale recall/doc.go lists nonexistent serve Task: fix the doc.go 120 commit sequences disconnected from context Task: /ctx-commit workflow
      • Some findings became skills;
      • Some became Makefile targets;
      • Some became one-line doc fixes.

      The audit did not prescribe the artifact type: The findings did.

      The audit is the input. Skills are one possible output. Not the only one.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-audit-prompt","level":2,"title":"The Audit Prompt","text":"

      Here is the exact prompt I used, for those who are curious.

      This is not a template: It worked because it was written against this codebase, at this moment, with specific goals in mind:

      I want you to create an agent team to audit this codebase. Save each report as\na separate Markdown file under `./ideas/` (or another directory if you prefer).\n\nUse read-only agents (subagent_type: Explore) for all analyses. No code changes.\n\nFor each report, use this structure:\n- Executive Summary (2-3 sentences + severity table)\n- Findings (grouped, with file:line references)\n- Ranked Recommendations (high/medium/low priority)\n- Methodology (what was examined, how)\n\nKeep reports actionable. Every finding should suggest a concrete fix or next step.\n\n## Analyses to Run\n\n### 1. Extractable Patterns (*session mining*)\nSearch session JSONL files, journal entries, and task archives for repetitive\nmulti-step workflows. Count frequency of bash command sequences, slash command\nusage, and recurring user prompts. Identify patterns that could become skills\nor scripts. Cross-reference with existing skills to find coverage gaps.\nOutput: ranked list of automation opportunities with frequency data.\n\n### 2. Documentation Drift (*godoc + inline*)\nCompare every doc.go against its package's actual exports and behavior. Check\ninline godoc comments on exported functions against their implementations.\nScan for stale TODO/FIXME/HACK comments. Check that package-level comments match\npackage names.\nOutput: drift items ranked by severity with exact file:line references.\n\n### 3. Maintainability\nLook for:\n- functions longer than 80 lines with clear split points\n- switch blocks with more than 5 cases that could be table-driven\n- inline comments like \"step 1\", \"step 2\" that indicate a block wants to be a function\n- files longer than 400 lines\n- flat packages that could benefit from sub-packages\n- functions that appear misplaced in their file\n\nDo NOT flag things that are fine as-is just because they could theoretically\nbe different.\nOutput: concrete refactoring suggestions, not style nitpicks.\n\n### 4. Security Review\nThis is a CLI app. Focus on CLI-relevant attack surface, not web OWASP:\n- file path traversal\n- command injection\n- symlink following when writing to `.context/`\n- permission handling\n- sensitive data in outputs\n\nOutput: findings with severity ratings and plausible exploit scenarios.\n\n### 5. Blog Theme Discovery\nRead existing blog posts for style and narrative voice. Analyze git history,\nrecent session discussions, and `DECISIONS.md` for story arcs worth writing about.\nSuggest 3-5 blog post themes with:\n- title\n- angle\n- target audience\n- key commits or sessions to reference\n- a 2-sentence pitch\n\nPrioritize themes that build a coherent narrative across posts.\n\n### 6. Roadmap and Value Opportunities\nBased on current features, recent momentum, and gaps found in other analyses,\nidentify the highest-value improvements. Consider user-facing features,\ndeveloper experience, integration opportunities, and low-hanging fruit.\nOutput: prioritized list with rough effort and impact estimates.\n\n### 7. User-Facing Documentation\nEvaluate README, help text, and user docs. Suggest improvements structured as\nuse-case pages: the problem, how ctx solves it, a typical workflow, and gotchas.\nIdentify gaps where a user would get stuck without reading source code.\nOutput: documentation gaps with suggested page outlines.\n\n### 8. Agent Team Strategies\nBased on the codebase structure, suggest 2-3 agent team configurations for\nupcoming work sessions. For each, include:\n- team composition (roles and agent types)\n- task distribution strategy\n- coordination approach\n- the kinds of work it suits\n

      Avoid Generic Advice

      Suggestions that are not grounded in a project's actual structure, history, and workflows are worse than useless:

      They create false confidence.

      If an analysis cannot point to concrete files, commits, sessions, or patterns, it should say \"no finding\" instead of inventing best practices.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#the-deeper-pattern","level":2,"title":"The Deeper Pattern","text":"

      This is part of a pattern I keep rediscovering:

      The urge to automate is not the same as the need to automate:

      • The 3:1 ratio taught me that not every session should be a YOLO sprint.
      • The E/A/R framework taught me that not every template is worth importing. Now the audit is teaching me that not every useful prompt is worth institutionalizing.

      The common thread is restraint:

      • Knowing when to stop.
      • Recognizing that the cost of automation is not just the effort to build it.

      The cost is the ongoing attention tax of maintaining it, the context it consumes, and the false confidence it creates when it drifts.

      An entry in hack/runbooks/codebase-audit.md is honest about what it is:

      A prompt I wrote once, improved once, and will adapt again next time:

      • It does not pretend to be a reliable contract.
      • It does not claim attention budget.
      • It does not drift silently.

      The Automation Instinct

      When you find a useful prompt, the instinct is to institutionalize it. Resist.

      Ask first: will I use this the same way next time?

      If yes, it is a skill. If no, it is a recipe. If you are not sure, it is a recipe until proven otherwise.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-08-not-everything-is-a-skill/#this-mindset-in-the-context-of-ctx","level":2,"title":"This Mindset in the Context of ctx","text":"

      ctx is a tool that gives AI agents persistent memory. Its purpose is automation: reducing the friction of context loading, session recall, decision tracking.

      But automation has boundaries, and knowing where those boundaries are is as important as pushing them forward.

      The skills system is for high-frequency, stable workflows.

      The recipes, the journal entries, the session dumps in .context/sessions/: those are for everything else.

      Not everything needs to be a slash command. Some things are better as Markdown files you read when you need them.

      The goal of ctx is not to automate everything: It is to automate the right things and to make the rest easy to find when you need it.

      If You Remember One Thing from This Post...

      The best automation decision is sometimes not to automate.

      A runbook in a Markdown file costs nothing until you use it.

      A skill costs attention on every prompt, whether it fires or not.

      Automate the daily. Document the periodic. Forget the rest.

      This post was written during the session that produced the codebase audit reports and distilled the prompt into hack/runbooks/codebase-audit.md. The audit generated seven tasks, one Makefile target, and zero new skills. The meta continues.

      See also: Code Is Cheap. Judgment Is Not.: the capstone that threads this post's restraint argument into the broader case for why judgment, not production, is the bottleneck.

      ","path":["Not Everything Is a Skill"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/","level":1,"title":"Defense in Depth: Securing AI Agents","text":"","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#when-markdown-is-not-a-security-boundary","level":2,"title":"When Markdown Is Not a Security Boundary","text":"

      Jose Alekhinne / 2026-02-09

      What Happens When Your AI Agent Runs Overnight and Nobody Is Watching?

      It follows instructions: That is the problem.

      Not because it is malicious. Because it is controllable.

      It follows instructions from context, and context can be poisoned.

      I was writing the autonomous loops recipe for ctx: the guide for running an AI agent in a loop overnight, unattended, working through tasks while you sleep. The original draft had a tip at the bottom:

      Use CONSTITUTION.md for guardrails. Tell the agent \"never delete tests\" and it usually won't.

      Then I read that sentence back and realized: that is wishful thinking.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-realization","level":2,"title":"The Realization","text":"

      CONSTITUTION.md is a Markdown file. The agent reads it at session start alongside everything else in .context/. It is one source of instructions in a context window that also contains system prompts, project files, conversation history, tool outputs, and whatever the agent fetched from the internet.

      An attacker who can inject content into any of those sources can redirect the agent's behavior. And \"attacker\" does not always mean a person with malicious intent. It can be:

      Vector Example A dependency A malicious npm package with instructions in its README or error output A URL Documentation page with embedded adversarial instructions A project file A contributor who adds instructions to CLAUDE.md or .cursorrules The agent itself In an autonomous loop, the agent modifies its own config between iterations A command output An error message containing instructions the agent interprets and follows

      That last vector is the one that kept me up at night (literally!):

      In an autonomous loop, the agent modifies files as part of its job.

      If it modifies its own configuration files, the next iteration loads the modified config.

      • No human reviews it.
      • No diff is shown.
      • The agent that starts iteration N+1 is running with rules written by iteration N.

      The agent can rewrite its own guardrails.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#five-layers-each-with-a-hole","level":2,"title":"Five Layers, Each with a Hole","text":"

      That's five nested layers of swiss cheese. Alone, each of them has large holes. Together, they create a boundary.

      What followed was a week of peeling back assumptions:

      Every defenseI examined had a bypass, and the bypass was always the same shape: the defense was enforced at a level the agent could reach.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-1-soft-instructions-probabilistic","level":3,"title":"Layer 1: Soft Instructions (Probabilistic)","text":"

      CONSTITUTION.md, the Agent Playbook, system prompts: These tell the agent what to do.

      The agent usually follows them.

      \"Usually\" is the keyword here.

      The hole: Prompt injection:

      • A sufficiently crafted payload overrides soft instructions.
      • Long context windows dilute attention on rules stated early.
      • Edge cases where instructions are ambiguous get resolved in unpredictable ways.

      Verdict: Necessary. Not sufficient. Good for the common case. Never trust it as a security boundary.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-2-application-controls-deterministic-at-runtime-mutable-across-iterations","level":3,"title":"Layer 2: Application Controls (Deterministic at Runtime, Mutable across Iterations)","text":"

      Permission allowlists in .claude/settings.local.json:

      {\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(make:*)\",\n      \"Bash(go:*)\",\n      \"Bash(git:*)\",\n      \"Read\",\n      \"Write\",\n      \"Edit\"\n    ]\n  }\n}\n

      If rm, curl, sudo, or docker are not in the allowlist, the agent cannot invoke them. This is deterministic.

      The application enforces it regardless of what any prompt says.

      The hole: The agent can modify the allowlist itself:

      • It has Write permission.
      • The allowlist lives in a file.
      • The agent writes to the file.
      • The next iteration loads the modified allowlist.

      The application enforces the rules, but the application reads the rules from files the agent can write.

      Verdict: Strong first layer. Must be combined with self-modification prevention.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-3-os-level-isolation-unbypassable","level":3,"title":"Layer 3: OS-Level Isolation (Unbypassable)","text":"

      This is where the defenses stop having holes in the same shape.

      The operating system enforces access controls that no application-level trick can override. An unprivileged user cannot read files owned by root. A process without CAP_NET_RAW cannot open raw sockets. These are kernel boundaries.

      Control What it stops Dedicated unprivileged user Privilege escalation, sudo, group-based access Filesystem permissions Lateral movement to other projects, system config Immutable config files Self-modification of guardrails between iterations

      Make the agent's instruction files read-only: CLAUDE.md, .claude/settings.local.json, .context/CONSTITUTION.md. Own them as a different user, or mark them immutable with chattr +i on Linux.

      The hole: Actions within the agent's legitimate scope:

      • If the agent has write access to source code (which it needs), it can introduce vulnerabilities in the code itself.
      • You cannot prevent this without removing the agent's ability to do its job.

      Verdict: Essential. This is the layer that makes Layers 1 and 2 trustworthy.

      OS-level isolation does not make the agent safe; it makes the other layers meaningful.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-4-network-controls","level":3,"title":"Layer 4: Network Controls","text":"

      An agent that cannot reach the internet cannot exfiltrate data.

      It also cannot ingest new instructions mid-loop from external documents, error pages, or hostile content.

      # Container with no network\ndocker run --network=none ...\n\n# Or firewall rules allowing only package registries\niptables -A OUTPUT -d registry.npmjs.org -j ACCEPT\niptables -A OUTPUT -d proxy.golang.org -j ACCEPT\niptables -A OUTPUT -j DROP\n
      • If the agent genuinely does not need the network, disable it entirely.
      • If it needs to fetch dependencies, allow specific registries and block everything else.

      The hole: None, if the agent does not need the network.

      Thetradeoff is that many real workloads need dependency resolution, so a full airgap requires pre-populated caches.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#layer-5-infrastructure-isolation","level":3,"title":"Layer 5: Infrastructure Isolation","text":"

      The strongest boundary is a separate machine.

      The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.

      docker run --rm \\\n  --network=none \\\n  --cap-drop=ALL \\\n  --memory=4g \\\n  --cpus=2 \\\n  -v /path/to/project:/workspace \\\n  -w /workspace \\\n  your-dev-image \\\n  ./loop.sh\n

      Never Mount the Docker Socket

      Do not mount /var/run/docker.sock, like, ever.

      An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox.

      This is not theoretical: the Docker socket grants root-equivalent access to the host.

      Use rootless Docker or Podman to eliminate this escalation path entirely.

      Virtual machines are even stronger: The guest kernel has no visibility into the host OS. No shared folders, no filesystem passthrough, no SSH keys to other machines.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-pattern","level":2,"title":"The Pattern","text":"

      Each layer is straightforward: The strength is in the combination:

      Layer Implementation What it stops Soft instructions CONSTITUTION.md Common mistakes (probabilistic) Application allowlist .claude/settings.local.json Unauthorized commands (deterministic within runtime) Immutable config chattr +i on config files Self-modification between iterations Unprivileged user Dedicated user, no sudo Privilege escalation Container --cap-drop=ALL --network=none Host escape, data exfiltration Resource limits --memory=4g --cpus=2 Resource exhaustion

      No layer is redundant. Each one catches what the others miss:

      • The soft instructions handle the 99% case: \"don't delete tests.\"
      • The allowlist prevents the agent from running commands it should not.
      • The immutable config prevents the agent from modifying the allowlist.
      • The unprivileged user prevents the agent from removing the immutable flag.
      • The container prevents the agent from reaching anything outside its workspace.
      • The resource limits prevent the agent from consuming all system resources.

      Remove any one layer and there is an attack path through the remaining ones.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#common-mistakes-i-see","level":2,"title":"Common Mistakes I See","text":"

      These are real patterns, not hypotheticals:

      \"I'll just use --dangerously-skip-permissions.\" This disables Layer 2 entirely. Without Layers 3 through 5, you have no protection at all. The flag means what it says. If you ever need to, think thrice, you probably don't. But, if you ever need to usee this only use it inside a properly isolated VM (not even a container: a \"VM\").

      \"The agent is sandboxed in Docker.\" A Docker container with the Docker socket mounted, running as root, with --privileged, and full network access is not sandboxed. It is a root shell with extra steps.

      \"I reviewed CLAUDE.md, it's fine.\" You reviewed it before the loop started. The agent modified it during iteration 3. Iteration 4 loaded the modified version. Unless the file is immutable, your review is futile.

      \"The agent only has access to this one project.\" Does the project directory contain .env files? SSH keys? API tokens? A .git/config with push access to a remote? Filesystem isolation means isolating what is in the directory too.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-connection-to-context-engineering","level":2,"title":"The Connection to Context Engineering","text":"

      This is the same lesson I keep rediscovering, wearing different clothes.

      In The Attention Budget, I wrote about how every token competes for the AI's focus. Security instructions in CONSTITUTION.md are subject to the same budget pressure: if the context window is full of code, error messages, and tool outputs, the security rules stated at the top get diluted.

      In Skills That Fight the Platform, I wrote about how custom instructions can conflict with the AI's built-in behavior. Security rules have the same problem: telling an agent \"never run curl\" in Markdown while giving it unrestricted shell access creates a contradiction: The agent resolves contradictions unpredictably. The agent will often pick the path of least resistance to attain its objective function. And, trust me, agents can get far more creative than the best red-teamer you know.

      In You Can't Import Expertise, I wrote about how generic templates fail because they do not encode project-specific knowledge. Generic security advice fails the same way: \"Don't exfiltrate data\" is a category; blocking outbound network access is a control.

      The pattern across all of these: Soft instructions are useful for the common case. Hard boundaries are required for security.

      Know which is which.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#the-checklist","level":2,"title":"The Checklist","text":"

      Before running an unattended AI agent:

      • Agent runs as a dedicated unprivileged user (no sudo, no docker group)
      • Agent's config files are immutable or owned by a different user
      • Permission allowlist restricts tools to the project's toolchain
      • Container drops all capabilities (--cap-drop=ALL)
      • Docker socket is NOT mounted
      • Network is disabled or restricted to specific domains
      • Resource limits are set (memory, CPU, disk)
      • No SSH keys, API tokens, or credentials are accessible
      • Project directory does not contain .env or secrets files
      • Iteration cap is set (--max-iterations)

      This checklist lives in the Agent Security reference alongside the full threat model and detailed guidance for each layer.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-09-defense-in-depth-securing-ai-agents/#what-changed-in-ctx","level":2,"title":"What Changed in ctx","text":"

      The autonomous loops recipe now has a full permissions and isolation section instead of a one-line tip about CONSTITUTION.md. It covers both the explicit allowlist approach and the --dangerously-skip-permissions flag, with honest guidance about when each is appropriate.

      It also has an OS-level isolation table that is not optional: unprivileged users, filesystem permissions, containers, VMs, network controls, resource limits, and self-modification prevention.

      The Agent Security page consolidates the threat model and defense layers into a standalone reference.

      These are not theoretical improvements. They are the minimum responsible guidance for a tool that helps people run AI agents overnight.

      If You Remember One Thing from This Post...

      Markdown is not a security boundary.

      CONSTITUTION.md is a nudge. An allowlist is a gate.

      An unprivileged user in a network-isolated container is a wall.

      Use all three. Trust only the wall.

      This post was written during the session that added permissions, isolation, and self-modification prevention to the autonomous loops recipe. The security guidance started as a single tip and grew into two documents. The meta continues.

      ","path":["Defense in Depth: Securing AI Agents"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/","level":1,"title":"How Deep Is Too Deep?","text":"","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#when-master-ml-is-the-wrong-next-step","level":2,"title":"When \"Master ML\" Is the Wrong Next Step","text":"

      Jose Alekhinne / 2026-02-12

      Have You Ever Felt like You Should Understand More of the Stack beneath You?

      You can talk about transformers at a whiteboard.

      You can explain attention to a colleague.

      You can use agentic AI to ship real software.

      But somewhere in the back of your mind, there is a voice:

      \"Maybe I should go deeper. Maybe I need to master machine learning.\"

      I had that voice for months.

      Then I spent a week debugging an agent failure that had nothing to do with ML theory and everything to do with knowing which abstraction was leaking.

      This post is about when depth compounds and (more importantly) when it does not.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-hierarchy-nobody-questions","level":2,"title":"The Hierarchy Nobody Questions","text":"

      There is an implicit stack most people carry around when thinking about AI:

      Layer What Lives Here Agentic AI Autonomous loops, tool use, multi-step reasoning Generative AI Text, image, code generation Deep Learning Transformer architectures, training at scale Neural Networks Backpropagation, gradient descent Machine Learning Statistical learning, optimization Classical AI Search, planning, symbolic reasoning

      At some point down that stack, you hit a comfortable plateau: the layer where you can hold a conversation but not debug a failure.

      The instinctive response is to go deeper.

      But that instinct hides a more important question:

      \"Does depth still compound when the abstractions above you are moving hyper-exponentially?\"

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-honest-observation","level":2,"title":"The Honest Observation","text":"

      If you squint hard enough, a large chunk of modern ML intuition collapses into older fields:

      ML Concept Older Field Gradient descent Numerical optimization Backpropagation Reverse-mode autodiff Loss landscapes Non-convex optimization Generalization Statistics Scaling laws Asymptotics and information theory

      Nothing here is uniquely \"AI\".

      Most of this math predates the term deep learning. In some cases, by decades.

      So what changed?

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#same-tools-different-regime","level":2,"title":"Same Tools, Different Regime","text":"

      The mistake is assuming this is a new theory problem: It is not.

      It is a new operating regime.

      Classical numerical methods were developed under assumptions like:

      • Manageable dimensionality
      • Reasonably well-conditioned objectives
      • Losses that actually represent the goal

      Modern ML violates all three: On purpose.

      Today's models operate with millions to trillions of parameters, wildly underdetermined systems, and objective functions we know are wrong but optimize anyway.

      It is complete and utter madness!

      At this scale, familiar concepts warp:

      • What we call \"local minima\" are overwhelmingly saddle points in high-dimensional spaces.
      • Noise stops being noise and starts becoming structure.
      • Overfitting can coexist with generalization.
      • Bigger models outperform \"better\" ones.

      The math did not change: The phase did.

      This is less numerical analysis and more *statistical physics: Same equations, but behavior dominated by phase transitions and emergent structure.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#why-scaling-laws-feel-alien","level":2,"title":"Why Scaling Laws Feel Alien","text":"

      In classical statistics, asymptotics describe what happens eventually.

      In modern ML, scaling laws describe where you can operate today.

      They do not say \"given enough time, things converge\".

      They say \"cross this threshold and behavior qualitatively changes\".

      This is why dumb architectures plus scale beat clever ones.

      Why small theoretical gains disappear under data.

      Why \"just make it bigger\", ironically, keeps working longer than it should.

      That is not a triumph of ML theory: It is a property of high-dimensional systems under loose objectives.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#where-depth-actually-pays-off","level":2,"title":"Where Depth Actually Pays Off","text":"

      This reframes the original question.

      You do not need depth because this is \"AI\".

      You need depth where failure modes propagate upward.

      I learned this building ctx: The agent failures I have spent the most time debugging were never about the model's architecture.

      They were about:

      • Misplaced trust: The model was confident. The output was wrong. Knowing when confidence and correctness diverge is not something you learn from a textbook. You learn it from watching patterns across hundreds of sessions.

      • Distribution shift: The model performed well on common patterns and fell apart on edge cases specific to this project. Recognizing that shift before it compounds requires understanding why generalization has limits, not just that it does.

      • Error accumulation: In a single prompt, model quirks are tolerable. In autonomous loops running overnight, they compound. A small bias in how the model interprets instructions becomes a large drift by iteration 20.

      • Scale hiding errors: The model's raw capability masked problems that only surfaced under specific conditions. More parameters did not fix the issue. They just made the failure mode rarer and harder to reproduce.

      This is the kind of depth that compounds. Not deriving backprop. But, understanding when correct math produces misleading intuition.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-connection-to-context-engineering","level":2,"title":"The Connection to Context Engineering","text":"

      This is the same pattern I keep finding at different altitudes.

      In \"The Attention Budget\", I wrote about how dumping everything into the context window degrades the model's focus. The fix was not a better model: It was better curation: load less, load the right things, preserve signal per token.

      In \"Skills That Fight the Platform\", I wrote about how custom instructions can conflict with the model's built-in behavior. The fix was not deeper ML knowledge: It was an understanding that the model already has judgment and that you should extend it, not override it.

      In \"You Can't Import Expertise\", I wrote about how generic templates fail because they do not encode project-specific knowledge. A consolidation skill with eight Rust-based analysis dimensions was mostly noise for a Go project. The fix was not a better template: It was growing expertise from this project's own history.

      In every case, the answer was not \"go deeper into ML\".

      The answer was knowing which abstraction was leaking and fixing it at the right layer.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#agentic-systems-are-not-an-ml-problem","level":2,"title":"Agentic Systems Are Not an ML Problem","text":"

      The mistake is assuming agent failures originate where the model was trained, rather than where it is deployed.

      Agentic AI is a systems problem under chaotic uncertainty:

      • Feedback loops between the agent and its environment;
      • Error accumulation across iterations;
      • Brittle representations that break outside training distribution;
      • Misplaced trust in outputs that look correct.

      In short-lived interactions, model quirks are tolerable. In long-running autonomous loops, however, they compound.

      That is where shallow understanding becomes expensive.

      But the understanding you need is not about optimizer internals.

      It is about:

      What Matters What Does Not (for Most Practitioners) Why gradient descent fails in specific regimes How to derive it from scratch When memorization masquerades as reasoning The formal definition of VC dimension Recognizing distribution shift before it compounds Hand-tuning learning rate schedules Predicting when scale hides errors instead of fixing them Chasing theoretical purity divorced from practice

      The depth that matters is diagnostic, not theoretical.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-real-answer","level":2,"title":"The Real Answer","text":"

      Not turtles all the way down.

      Go deep enough to:

      • Diagnose failures instead of cargo-culting fixes;
      • Reason about uncertainty instead of trusting confidence;
      • Design guardrails that align with model behavior, not hope.

      Stop before:

      • Hand-deriving gradients for the sake of it;
      • Obsessing over optimizer internals you will never touch;
      • Chasing theoretical purity divorced from the scale you actually operate at.

      This is not about mastering ML.

      It is about knowing which abstractions you can safely trust and which ones leak.

      Hint: Any useful abstraction almost certainly leaks.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#a-practical-litmus-test","level":2,"title":"A Practical Litmus Test","text":"

      If a failure occurs and your instinct is to:

      • Add more prompt text: abstraction leak above
      • Add retries or heuristics: error accumulation
      • Change the model: scale masking
      • Reach for ML theory: you are probably (but not always) going too deep

      The right depth is the shallowest layer where the failure becomes predictable.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-ctx-lesson","level":2,"title":"The ctx Lesson","text":"

      Every design decision in ctx is downstream of this principle.

      The attention budget exists because the model's internal attention mechanism has real limits: You do not need to understand the math of softmax to build around it. But you do need to understand that more context is not always better and that attention density degrades with scale.

      The skill system exists because the model's built-in behavior is already good: You do not need to understand RLHF to build effective skills. But you do need to understand that the model already has judgment and your skills should teach it things it does not know, not override how it thinks.

      Defense in depth exists because soft instructions are probabilistic: You do not need to understand the transformer architecture to know that a Markdown file is not a security boundary. But you do need to understand that the model follows instructions from context, and context can be poisoned.

      In each case, the useful depth was one or two layers below the abstraction I was working at: Not at the bottom of the stack.

      The boundary between useful understanding and academic exercise is where your failure modes live.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#closing-thought","level":2,"title":"Closing Thought","text":"

      Most modern AI systems do not fail because the math is wrong.

      They fail because we apply correct math in the wrong regime, then build autonomous systems on top of it.

      Understanding that boundary, not crossing it blindly, is where depth still compounds.

      And that is a far more useful form of expertise than memorizing another loss function.

      If You Remember One Thing from This Post...

      Go deep enough to diagnose your failures. Stop before you are solving problems that do not propagate to your layer.

      The abstractions below you are not sacred. But neither are they irrelevant.

      The useful depth is wherever your failure modes live. Usually one or two layers down, not at the bottom.

      This post started as a note about whether I should take an ML course. The answer turned out to be \"no, but understand why not\". The meta continues.

      ","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/","level":1,"title":"Before Context Windows, We Had Bouncers","text":"","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#the-reset-problem","level":2,"title":"The Reset Problem","text":"

      IRC is stateless.

      • You disconnect, you vanish.
      • You reconnect, you begin again.

      No buffer.

      No memory.

      No continuity.

      Modern systems are not much different:

      • Close the browser tab.
        • Lose the Slack scrollback.
      • Open a new LLM session.
        • Start from zero.

      Resets externalize reconstruction cost onto humans.

      Reconstruction is tax: Tax becomes entropy.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#stateless-protocol-stateful-life","level":2,"title":"Stateless Protocol, Stateful Life","text":"

      IRC is minimal:

      • A TCP connection.
      • A nickname.
      • A channel.
      • A stream of lines.

      When the connection drops, you literally disappear from the graph.

      The protocol is stateless; human systems are not.

      So you:

      • Reconnect;
      • Ask what you missed;
      • Scroll;
      • Reconstruct.

      The machine forgets; you pay.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#the-bouncer-pattern","level":2,"title":"The Bouncer Pattern","text":"

      A bouncer is a daemon that remains connected when you do not:

      • It holds your seat;
      • It buffers what you missed;
      • It keeps your identity online.

      ZNC is one such bouncer.

      With ZNC:

      • Your client does not connect to IRC;
      • It connects to ZNC;
      • ZNC connects upstream.

      Client sessions become ephemeral.

      Presence becomes infrastructural.

      ZNC Is Tmux for IRC

      • Close your laptop.

        • ZNC remains.
      • Switch devices.

        • ZNC persists.

      This is not convenience; this is continuity.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#presence-without-flapping","level":2,"title":"Presence without Flapping","text":"

      With a bouncer:

      • Closing your client does not emit PART.
      • Reopening does not emit JOIN.

      You do not flap in and out of existence.

      From the channel's perspective, you remain.

      From your perspective, history accumulates.

      • Buffers persist;
      • Identity persists;
      • Context persists.

      This pattern predates AI.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#before-llm-context-windows","level":2,"title":"Before LLM Context Windows","text":"

      An LLM session without memory is IRC without a bouncer:

      • Close the window.
      • Start over.
      • Re-explain intent.
      • Rehydrate context.

      That is friction.

      This Walks and Talks like ctx

      Context engineering moves memory out of sessions and into infrastructure.

      • ZNC does this for IRC.
      • ctx does this for agents.

      Same principle:

      • Volatile interface.
      • Persistent substrate.

      Different fabric.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#minimal-architecture","level":2,"title":"Minimal Architecture","text":"

      My setup is intentionally boring:

      • A $5 small VPS.
      • ZNC installed.
      • TLS enabled.
      • Firewall restricted.

      Then:

      • ZNC connects to Libera.Chat.
      • SASL authentication lives inside ZNC.
      • Buffers are stored on disk.

      My client connects to my VPS, not the network.

      The commands do not matter: The boundaries do:

      • Authentication in infrastructure, not in the client;
      • Memory server-side, not in scrollback;
      • Presence decoupled from activity.

      Everything else is configuration.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#platform-memory","level":2,"title":"Platform Memory","text":"

      Yes, I know, it is 2026:

      • Discord stores history;
      • Slack stores history;
      • The dumpster fire on gasoline called X, too, stores history.

      HOWEVER, they own your substrate.

      Running a bouncer is quiet sovereignty:

      • Logs are mine.
      • Presence is continuous.
      • State does not reset because I closed a tab.

      Small acts compound.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#signal-density","level":2,"title":"Signal Density","text":"

      Primitive systems select for builders.

      Consistent presence in small rooms compounds reputation.

      Quiet compounding outperforms viral spikes.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#infrastructure-as-cognition","level":2,"title":"Infrastructure as Cognition","text":"

      ZNC is not interesting because it is retro; it is interesting because it models a principle:

      • Stateless protocols require stateful wrappers;
      • Volatile interfaces require durable memory;
      • Human systems require continuity.

      Distilled:

      Humans require context.

      Before context windows, we had bouncers.

      Before AI memory files, we had buffers.

      Continuity is not a feature; it is a design decision.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#build-it","level":2,"title":"Build It","text":"

      If you want the actual setup (VPS, ZNC, TLS, SASL, firewall...) there is a step-by-step runbook:

      Persistent IRC Presence with ZNC.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#motd","level":2,"title":"MOTD","text":"

      When my client connects to my bouncer, it prints:

      //   /    ctx:                         https://ctx.ist\n// ,'`./    do you remember?\n// `.,'\\\n//   \\    Copyright 2026-present Context contributors.\n//                 SPDX-License-Identifier: Apache-2.0\n

      See also: Context as Infrastructure -- the post that takes this observation to its conclusion: stateless protocols need stateful wrappers, and AI sessions need persistent filesystems.

      ","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/","level":1,"title":"Parallel Agents with Git Worktrees","text":"","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-backlog-problem","level":2,"title":"The Backlog Problem","text":"

      Jose Alekhinne / 2026-02-14

      What Do You Do with 30 Open Tasks?

      You could work through them one at a time.

      One agent, one branch, one commit stream.

      Or you could ask: which of these don't touch each other?

      I had 30 open tasks in TASKS.md. Some were docs. Some were a new encryption package. Some were test coverage for a stable module. Some were blog posts.

      They had almost zero file overlap.

      Running one agent at a time meant serial execution on work that was fundamentally parallel:

      I was bottlenecking on me, not on the machine.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-insight-file-overlap-is-the-constraint","level":2,"title":"The Insight: File Overlap Is the Constraint","text":"

      This is not a scheduling problem: It's a conflict avoidance problem.

      Two agents can work simultaneously on the same codebase if and only if they don't touch the same files. The moment they do, you get merge conflicts: And merge conflicts on AI-generated code are expensive because the human has to arbitrate choices they didn't make.

      So the question becomes:

      \"Can you partition your backlog into non-overlapping tracks?\"

      For ctx, the answer was obvious:

      Track Touches Tasks work/docs docs/, hack/ Blog posts, recipes, runbooks work/pad internal/cli/pad/, specs Scratchpad encryption, CLI, tests work/tests internal/cli/recall/ Recall test coverage

      Three tracks. Near-zero overlap. Three agents.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#git-worktrees-the-mechanism","level":2,"title":"Git Worktrees: The Mechanism","text":"

      git has a feature that most people don't use: worktrees.

      A worktree is a second (or third, or fourth) working directory that shares the same .git object database as your main checkout.

      Each worktree has its own branch, its own index, its own working tree. But they all share history, refs, and objects.

      git worktree add ../ctx-docs -b work/docs\ngit worktree add ../ctx-pad -b work/pad\ngit worktree add ../ctx-tests -b work/tests\n
      • Three directories;
      • Three branches;
      • One repository.

      This is cheaper than three clones. And because they share objects, git merge afterwards is fast: It's a local operation on shared data.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-setup","level":2,"title":"The Setup","text":"

      The workflow I landed on:

      1. Group tasks by blast radius.

      Read TASKS.md. For each pending task, estimate which files and directories it touches. Group tasks that share files into the same track. Tasks with no overlap go into separate tracks.

      This is the part that requires human judgment:

      An agent can propose groupings, but you need to verify that the boundaries are real. A task that says \"update docs\" but actually touches Go code will poison a docs track.

      2. Create worktrees as sibling directories.

      Not subdirectories: Siblings.

      If your main checkout is at ~/WORKSPACE/ctx, worktrees go at ~/WORKSPACE/ctx-docs, ~/WORKSPACE/ctx-pad, etc.

      Why siblings? Because some tools (and some agents) walk up the directory tree looking for .git. A worktree inside the main checkout confuses them.

      3. Launch one agent per worktree.

      # Terminal 1\ncd ../ctx-docs && claude\n\n# Terminal 2\ncd ../ctx-pad && claude\n\n# Terminal 3\ncd ../ctx-tests && claude\n

      Each agent gets a full working copy with .context/ intact. It reads the same TASKS.md, the same DECISIONS.md, the same CONVENTIONS.md. It knows the full project state. It just works on a different slice.

      4. Do NOT run ctx init in worktrees.

      This is the gotcha. The .context/ directory is tracked in git. Running ctx init in a worktree would overwrite shared context files: Wiping decisions, learnings, and tasks that belong to the whole project.

      The worktree already has everything it needs. Leave it alone.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#what-actually-happened","level":2,"title":"What Actually Happened","text":"

      I ran three agents for about 40 minutes. Here is roughly what each track produced:

      work/docs: Parallel worktrees recipe, blog post edits, recipe index reorganization, IRC recipe moved from docs/ to hack/.

      work/pad: ctx pad show subcommand, --append and --prepend flags on ctx pad edit, spec updates, 28 new test functions.

      work/tests: Recall test coverage, edge case tests.

      Merging took about five minutes. Two of the three merges were clean.

      The third had a conflict in TASKS.md:

      both the docs track and the pad track had marked different tasks as [x].

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-tasksmd-conflict","level":2,"title":"The TASKS.md Conflict","text":"

      This deserves its own section because it will happen every time.

      When two agents work in parallel, they both read TASKS.md at the start and mark tasks complete as they go. When you merge, git sees two branches that modified the same file differently.

      The resolution is always the same: accept all completions from both sides. No task should go from [x] back to [ ]. The merge is additive.

      This is one of those conflicts that sounds scary but is trivially mechanical: You are not arbitrating design decisions; you are combining two checklists.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#limits","level":2,"title":"Limits","text":"

      3-4 worktrees, maximum.

      I tried four once: By the time I merged the third track, the fourth had drifted far enough that its changes needed rebasing.

      The merge complexity grows faster than the parallelism benefit.

      Three is the sweet spot:

      • Two is conservative but safe;
      • Four is possible if the tracks are truly independent;
      • Anything more than four, you are in the danger zone.

      Group by directory, not by priority.

      It is tempting to put all the high-priority tasks in one track: Don't.

      Two high-priority tasks that touch the same files must be in the same track, regardless of urgency. The constraint is file overlap, not importance.

      Commit frequently.

      Smaller commits make merge conflicts easier to resolve. An agent that writes 500 lines in a single commit is harder to merge than one that commits every logical step.

      Name tracks by concern.

      • work/docs and work/pad tell you what's happening;
      • work/track-1 and work/track-2 tell you nothing.
      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-pattern","level":2,"title":"The Pattern","text":"

      This is the same pattern that shows up everywhere in ctx:

      The attention budget taught me that you can't dump everything into one context window. You have to partition, prioritize, and load selectively.

      Worktrees are the same principle applied to execution: You can't dump every task into one agent's workstream. You have to partition by blast radius, assign selectively, and merge deliberately.

      The codebase audit that generated these 30 tasks used eight parallel agents for analysis. Worktrees let me use parallel agents for implementation. Same coordination pattern, different artifact.

      And the IRC bouncer post from earlier today argued that stateless protocols need stateful wrappers. Worktrees are the same: git branches are stateless forks; .context/ is the stateful wrapper that gives each agent the project's full memory.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#should-this-be-a-skill","level":2,"title":"Should This Be a Skill?","text":"

      I asked myself the same question I asked about the codebase audit: should this be a /ctx-worktree skill?

      This time the answer was a resounding \"yes\":

      Unlike the audit prompt (which I tweak every time and run every other week) the worktree workflow is:

      Criterion Worktree workflow Codebase audit Frequency Weekly Quarterly Stability Same steps every time Tweaked every time Scope Mechanical, bounded Bespoke, 8 agents Trigger Large backlog \"I feel like auditing\"

      The commands are mechanical: git worktree add, git worktree remove, branch naming, safety checks. This is exactly what skills are for: stable contracts for repetitive operations.

      Ergo, /ctx-worktree exists.

      It enforces the 4-worktree limit, creates sibling directories, uses work/ branch prefixes, and reminds you not to run ctx init in worktrees.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-takeaway","level":2,"title":"The Takeaway","text":"

      Serial execution is the default. But serial is not always necessary.

      If your backlog partitions cleanly by file overlap, you can multiply your throughput with nothing more exotic than git worktree and a second terminal window.

      The hard part is not the git commands; it is the discipline:

      • Grouping by blast radius instead of priority;
      • Accepting that TASKS.md will conflict;
      • And knowing when three tracks is enough.

      If You Remember One Thing from This Post...

      Partition by blast radius, not by priority.

      Two tasks that touch the same files belong in the same track, no matter how important the other one is.

      The constraint is file overlap. Everything else is scheduling.

      The practical setup (skill invocation, worktree creation, merge workflow, and cleanup) lives in the recipe: Parallel Agent Development with Git Worktrees.

      ","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/","level":1,"title":"ctx v0.3.0: The Discipline Release","text":"","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#when-the-ratio-of-polish-to-features-is-31-you-know-something-changed","level":2,"title":"When the Ratio of Polish to Features Is 3:1, You Know Something Changed","text":"

      Jose Alekhinne / February 15, 2026

      What Does a Release Look like When Most of the Work Is Invisible?

      No new headline feature. No architectural pivot. No rewrite.

      Just 35+ documentation and quality commits against ~15 feature commits... and somehow, the tool feels like it grew up overnight.

      Six days separate v0.2.0 from v0.3.0.

      Measured by calendar time, it is nothing. Measured by what changed in how the project operates, it is the most significant release yet.

      • v0.1.0 was the prototype;
      • v0.2.0 was the archaeology release: making the past accessible;
      • v0.3.0 is the discipline release: the one that turned best practices into enforcement, suggestions into structure, and a collection of commands into a system of skills.

      The Release Window

      February 1‒February 7, 2026

      From the v0.2.0 tag to commit 2227f99.

      78 files changed in the migration commit alone.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-migration-commands-to-skills","level":2,"title":"The Migration: Commands to Skills","text":"

      The largest single change was the migration from .claude/commands/*.md to .claude/skills/*/SKILL.md.

      This was not a rename: It was a rethinking of how AI agents discover and execute project-specific workflows.

      Aspect Commands (before) Skills (after) Structure Flat files in one directory Directory-per-skill with SKILL.md Description Optional, often vague Required, doubles as activation trigger Quality gates None \"Before X-ing\" pre-flight checklist Negative triggers None \"When NOT to Use\" in every skill Examples Rare Good/bad pairs in every skill Average length ~15 lines ~80 lines

      The description field became the single most important line in each skill. In the old system, descriptions were titles. In the new system, they are activation conditions: The text the platform reads to decide whether to surface a skill for a given prompt.

      A description that says \"Show context summary\" activates too broadly or not at all. A description that says \"Show context summary. Use at session start or when unclear about current project state\" activates at the right moment.

      78 files changed. 1,915 insertions. Not because the skills got bloated; because they got specific.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-skill-sweep","level":2,"title":"The Skill Sweep","text":"

      After the structural migration, every skill was rewritten in a single session: All 21 of them.

      The rewrite was guided by a pattern that emerged during the process itself: a repeatable anatomy that effective skills share regardless of their purpose:

      1. Before X-ing: Pre-flight checks that prevent premature execution
      2. When to Use: Positive triggers that narrow activation
      3. When NOT to Use: Negative triggers that prevent misuse
      4. Usage Examples: Invocation patterns the agent can pattern-match
      5. Quality Checklist: Verification before claiming completion

      The Anatomy of a Skill That Works post covers the details. What matters for the release story is the result:

      • Zero skills with quality gates became twenty;
      • Zero skills with negative triggers became twenty.
      • Three skills with examples became twenty.

      The Skill Trilogy as Design Spec

      The three blog posts written during this window:

      • Skills That Fight the Platform,
      • You Can't Import Expertise,
      • and The Anatomy of a Skill That Works...

      ... were not retrospective documentation. They were written during the rewrite, and the lessons fed back into the skills as they were being built.

      • The blog was the design document.
      • The skills were the implementation.
      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-consolidation-sweep","level":2,"title":"The Consolidation Sweep","text":"

      The unglamorous work. The kind you only appreciate when you try to change something later and it just works.

      What Why It Matters Constants consolidation Magic strings replaced with semantic constants Variable deshadowing Eliminated subtle scoping bugs File splits Modules that were doing too much, broken apart Godoc standardization Every exported function documented to convention

      This is the work that doesn't get a changelog entry but makes every future commit easier. When a new contributor (human or AI) reads the codebase, they find consistent patterns instead of accumulated drift.

      The consolidation was not an afterthought. It was scheduled deliberately, with the same priority as features: The 3:1 ratio that emerged during v0.2.0 development became an explicit practice:

      • Three feature sessions;
      • One consolidation session.
      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-ear-framework","level":2,"title":"The E/A/R Framework","text":"

      On February 4th, we adopted the E/A/R classification as the official standard for evaluating skills:

      Category Meaning Target Expert Knowledge Claude does not have >70% Activation When/how to trigger ~20% Redundant What Claude already knows <10%

      This came from reviewing approximately 30 external skill files and discovering that most were redundant with Claude's built-in system prompt. Only about 20% had salvageable content, and even those yielded just a few heuristics each.

      The E/A/R framework gave us a concrete, testable criterion:

      A good skill is Expert knowledge minus what Claude already knows.

      If more than 10% of a skill restates platform defaults, it is creating noise, not signal.

      Every skill in v0.3.0 was evaluated against this framework. Several were deleted. The survivors are leaner and more focused.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#backup-and-monitoring-infrastructure","level":2,"title":"Backup and Monitoring Infrastructure","text":"

      A tool that manages your project's memory needs ops maturity.

      v0.3.0 added two pieces of infrastructure that reflect this:

      Backup staleness hook: A UserPromptSubmit hook that checks whether the last .context/ backup is more than two days old. If it is, and the SMB mount is available, it reminds the user. No cron job running when nobody is working. No redundant backups when nothing has changed.

      Context size checkpoint: A PreToolUse hook that estimates current context window usage and warns when the session is getting heavy. This hooks into the attention budget philosophy: Degradation is expected, but it should be visible.

      Both hooks use $CLAUDE_PROJECT_DIR instead of hardcoded paths, a migration triggered by a username rename that broke every absolute path in the hook configuration. That migration (replacing /home/user/... with \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/...) was one of those changes that seems trivial but prevents an entire category of future failures.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#the-numbers","level":2,"title":"The Numbers","text":"Metric v0.2.0 v0.3.0 Skills (was \"commands\") 11 21 Skills with quality gates 0 21 Skills with \"When NOT to Use\" 0 21 Average skill body ~15 lines ~80 lines Hooks using $CLAUDE_PROJECT_DIR 0 All Documentation commits n/a 35+ Feature/fix commits n/a ~15

      That ratio (35+ documentation and quality commits to ~15 feature commits) is the defining characteristic of this release:

      • This release is not a failure to ship features.
      • It is the deliberate choice to make the existing features reliable.
      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#what-v030-means","level":2,"title":"What v0.3.0 Means","text":"

      v0.1.0 asked: \"Can we give AI persistent memory?\"

      v0.2.0 asked: \"Can we make that memory accessible to humans too?\"

      v0.3.0 asks a different question: \"Can we make the quality self-enforcing?\"

      The answer is not a feature: It is a practice:

      • Skills with quality gates enforce pre-flight checks.
      • Negative triggers prevent misuse without human intervention.
      • The E/A/R framework ensures skills contain signal, not noise.
      • Consolidation sessions are scheduled, not improvised.
      • Hook infrastructure makes degradation visible.

      Discipline is not the absence of velocity. It is the infrastructure that makes velocity sustainable.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/#what-comes-next","level":2,"title":"What Comes Next","text":"

      The skill system is now mature enough to support real workflows without constant human correction. The hooks infrastructure is portable and resilient. The consolidation practice is documented and repeatable.

      The next chapter is about what you build on top of discipline:

      • Multi-agent coordination;
      • Deeper integration patterns;
      • And the question of whether context management is a tool concern or an infrastructure concern.

      But those are future posts.

      This one is about the release that proved polish is not the opposite of progress. It is what turns a prototype into a product.

      The Discipline Release

      v0.1.0 shipped features.

      v0.2.0 shipped archaeology.

      v0.3.0 shipped the habits that make everything else trustworthy.

      The most important code in this release is the code that prevents bad code from shipping.

      This post was drafted using /ctx-blog with access to the full git history between v0.2.0 and v0.3.0, decision logs, learning logs, and the session files from the skill rewrite window. The meta continues.

      ","path":["ctx v0.3.0: The Discipline Release"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/","level":1,"title":"Eight Ways a Hook Can Talk","text":"","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#when-your-warning-disappears","level":2,"title":"When Your Warning Disappears","text":"

      Jose Alekhinne / 2026-02-15

      I had a backup warning that nobody ever saw.

      The hook was correct: It detected stale backups, formatted a nice message, and output it as {\"systemMessage\": \"...\"}. The problem wasn't detection. The problem was delivery. The agent absorbed the information, processed it internally, and never told the user.

      Meanwhile, a different hook (the journal reminder) worked perfectly every time. Users saw the reminder, ran the commands, and the backlog stayed manageable. Same hook event (UserPromptSubmit), same project, completely different outcomes.

      The difference was one line:

      IMPORTANT: Relay this journal reminder to the user VERBATIM\nbefore answering their question.\n

      That explicit instruction is what makes VERBATIM relay a pattern, not just a formatting choice. And once I saw it as a pattern, I started seeing others.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#the-audit","level":2,"title":"The Audit","text":"

      I looked at every hook in ctx: Eight shell scripts across three hook events. And I found five distinct output patterns already in use, plus three more that the existing hooks were reaching for but hadn't quite articulated.

      The patterns form a spectrum based on a single question:

      \"Who decides what the user sees?\"

      At one end, the hook decides everything (hard gate: the agent literally cannot proceed). At the other end, the hook is invisible (silent side-effect: nobody knows it ran). In between, there is a range of negotiation between hook, agent, and the user.

      Here's the full spectrum:

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#1-hard-gate","level":3,"title":"1. Hard Gate","text":"
      {\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}\n

      The nuclear option: The agent's tool call is rejected before it executes.

      This is Claude Code's first-class PreToolUse mechanism: The hook returns JSON with decision: block and the agent gets an error with the reason.

      Use this for invariants: Constitution rules, security boundaries, things that must never happen. I use it to enforce PATH-based ctx invocation, block sudo, and require explicit approval for git push.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#2-verbatim-relay","level":3,"title":"2. VERBATIM Relay","text":"
      IMPORTANT: Relay this warning to the user VERBATIM before answering.\n┌─ Journal Reminder ─────────────────────────────\n│ You have 12 sessions not yet imported.\n│   ctx recall import --all\n└────────────────────────────────────────────────\n

      The instruction is the pattern. Without \"Relay VERBATIM,\" agents tend to absorb information into their internal reasoning and never surface it. The explicit instruction changes the behavior from \"I know about this\" to \"I must tell the user about this.\"

      I use this for actionable reminders:

      • Unexported journal entries;
      • Stale backups;
      • Context capacity warnings...

      ...things the user should see regardless of what they asked.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#3-agent-directive","level":3,"title":"3. Agent Directive","text":"
      ┌─ Persistence Checkpoint (prompt #25) ───────────\n│ No context files updated in 15+ prompts.\n│ Have you discovered learnings worth persisting?\n└──────────────────────────────────────────────────\n

      A nudge, not a command. The hook tells the agent something; the agent decides what (if anything) to tell the user. This is right for behavioral nudges: \"you haven't saved context in a while\" doesn't need to be relayed verbatim, but the agent should consider acting on it.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#4-silent-context-injection","level":3,"title":"4. Silent Context Injection","text":"
      ctx agent --budget 4000 2>/dev/null || true\n

      Pure background enrichment. The agent's context window gets project information injected on every tool call, with no visible output. Neither the agent nor the user sees the hook fire, but the agent makes better decisions because of the context.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#5-silent-side-effect","level":3,"title":"5. Silent Side-Effect","text":"
      find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n

      Do work, say nothing. Temp file cleanup on session end. Logging. Marker file management. The action is the entire point; no one needs to know.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#the-patterns-we-dont-have-yet","level":2,"title":"The Patterns We Don't Have Yet","text":"

      Three more patterns emerged from the gaps in the existing hooks.

      Conditional relay: \"Relay this, but only if the user's question is about X.\" This pattern avoids noise when the warning isn't relevant. It's more fragile (depends on agent judgment) but less annoying.

      Suggested action: \"Here's a problem, and here's the exact command to fix it. Ask the user before running it.\" This pattern goes beyond a nudge by giving the agent a concrete proposal, but still requires human approval.

      Escalating severity: INFO gets absorbed silently. WARN gets mentioned at the next natural pause. CRITICAL gets the VERBATIM treatment. This pattern introduces a protocol for hooks that produce output at different urgency levels, so they don't all compete for the user's attention.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-eight-ways-a-hook-can-talk/#the-principle","level":2,"title":"The Principle","text":"

      Hooks are the boundary between your environment and the agent's reasoning.

      A hook that detects a problem but can't communicate it effectively is the same as no hook at all.

      The format of your output is a design decision with real consequences:

      • Use a hard gate and the agent can't proceed (good for invariants, frustrating for false positives)
      • Use VERBATIM relay and the user will see it (good for reminders, noisy if overused)
      • Use an agent directive and the agent might act (good for nudges, unreliable for critical warnings)
      • Use silent injection and nobody knows (good for enrichment, invisible when it breaks)

      Choose deliberately. And, when in doubt, write the word VERBATIM.

      The full pattern catalog with decision flowchart and implementation examples is in the Hook Output Patterns recipe.

      ","path":["Eight Ways a Hook Can Talk"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/","level":1,"title":"Version Numbers Are Lagging Indicators","text":"","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#why-ctxs-journal-site-runs-on-a-v0021-tool","level":2,"title":"Why ctx's Journal Site Runs on a v0.0.21 Tool","text":"

      Jose Alekhinne / 2026-02-15

      Would You Ship Production Infrastructure on a v0.0.21 Dependency?

      Most engineers wouldn't. Version numbers signal maturity. Pre-1.0 means unstable API, missing features, risk.

      But version numbers tell you where a project has been. They say nothing about where it's going.

      I just bet ctx's entire journal site on a tool that hasn't hit v0.1.0.

      Here's why I'd do it again.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-problem","level":2,"title":"The Problem","text":"

      When v0.2.0 shipped the journal system, the pipeline was clear:

      • Export sessions to Markdown;
      • Enrich them with YAML frontmatter;
      • And render them into something browsable.

      The first two steps were solved; the third needed a tool.

      The journal entries are standard Markdown with YAML frontmatter, tables, and fenced code blocks. That is the entire format:

      • No JSX;
      • No shortcodes;
      • No custom templating.

      Just Markdown rendered well.

      The requirements are modest:

      • Read a configuration file (such as mkdocs.yml);
      • Render Markdown with extensions (admonitions, tabs, tables);
      • Search;
      • Handle 100+ files without choking on incremental rebuilds;
      • Look good out of the box;
      • Not lock me in.

      The obvious candidates were as follows:

      Tool Language Strengths Pain Points Hugo Go Blazing fast, mature Templating is painful; Go templates fight you on anything non-trivial Astro JS/TS Modern, flexible JS ecosystem overhead; overkill for a docs site MkDocs + Material Python Beautiful defaults, massive community (22k+ stars) Slow incremental rebuilds on large sites; limited extensibility model Zensical Python Built to fix MkDocs' limits; 4-5x faster rebuilds v0.0.21; module system not yet shipped

      The instinct was Hugo. Same language as ctx. Fast. Well-established.

      But instinct is not analysis. I picked the one with the lowest version number.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation","level":2,"title":"The Evaluation","text":"

      Here is what I actually evaluated, in order:

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#1-the-team","level":3,"title":"1. The Team","text":"

      Zensical is built by squidfunk: The same person behind Material for MkDocs, the most popular MkDocs theme with 22,000+ stars. It powers documentation sites for projects across every language and framework.

      • This is not someone learning how to build static site generators.
      • This is someone who spent years understanding exactly where MkDocs breaks and decided to fix it from the ground up.

      They did not build zensical because MkDocs was bad: They built it because MkDocs hit a ceiling:

      • Incremental rebuilds: 4-5x faster during serve. When you have hundreds of journal entries and you edit one, the difference between \"rebuild everything\" and \"rebuild this page\" is the difference between a usable workflow and a frustrating one.

      • Large site performance: Specifically designed for tens of thousands of pages. The journal grows with every session. A tool that slows down as content accumulates is a tool you will eventually replace.

      A proven team starting fresh is more predictable than an unproven team at v3.0.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#2-the-architecture","level":3,"title":"2. The Architecture","text":"

      Zensical is investing in a Rust-based Markdown parser with CommonMark support. That signals something about the team's priorities:

      Performance foundations first; features second.

      ctx's journal will grow:

      • Every exported session adds files.
      • Every enrichment pass adds metadata.

      Choosing a tool that gets slower as you add content means choosing to migrate later.

      Choosing one built for scale means the decision holds.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#3-the-migration-path","level":3,"title":"3. The Migration Path","text":"

      Zensical reads mkdocs.yml natively. If it doesn't work out, I can move back to MkDocs + Material with zero content changes:

      • The Markdown is standard;
      • The frontmatter is standard;
      • The configuration is compatible.

      This is the infrastructure pattern again: The same way ZNC decouples presence from the client, zensical decouples rendering from the generator:

      • The Markdown is yours.
      • The frontmatter is standard YAML.
      • The configuration is MkDocs-compatible.

      You are not locked into anything except your own content.

      No lock-in is not a feature: It's a design philosophy:

      It's the same reason ctx uses plain Markdown files in .context/ instead of a database: the format should outlive the tool.

      Lock-in Is the Real Risk, Not Version Numbers

      A mature tool with a proprietary format is riskier than a young tool with a standard one. Version numbers measure time invested. Portability measures respect for the user.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#4-the-dependency-tree","level":3,"title":"4. The Dependency Tree","text":"

      Here is what pip install zensical actually pulls in:

      • click
      • Markdown
      • Pygments
      • pymdown-extensions
      • PyYAML

      Only five dependencies. All well-known. No framework bloat. No bundler. No transpiler. No node_modules black hole.

      3k GitHub stars at v0.0.21 is a strong early traction for a pre-1.0 project.

      The dependency tree is thin: No bloat.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#5-the-fit","level":3,"title":"5. The Fit","text":"

      This is the same principle behind the attention budget: do not overfit the tool to hypothetical requirements. The right amount of capability is the minimum needed for the current task.

      Hugo is a powerful static site generator. It is also a powerful templating engine, a powerful asset pipeline, and a powerful taxonomy system. For rendering Markdown journals, that power is overhead:

      It is the complexity you pay for but never use.

      ctx's journal files are standard Markdown with YAML frontmatter, tables, and fenced code blocks. That is exactly the sweet spot Zensical inherits from Material for MkDocs:

      • No custom plugins needed;
      • No special syntax;
      • No templating gymnastics.

      The requirements match the capabilities: Not the capabilities that are promised, but the ones that exist today, at v0.0.21.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-caveat","level":2,"title":"The Caveat","text":"

      It would be dishonest not to mention what's missing.

      The module system for third-party extensions opens in early 2026.

      If ctx ever needs custom plugins (for example, auto-linking session IDs, rendering special journal metadata, etc.) that infrastructure isn't there yet.

      The installation experience is rough:

      We discovered this firsthand: pip install zensical often fails on MacOS (system Python stubs, Homebrew's PEP 668 restrictions). The answer is pipx, which creates an isolated environment with the correct Python version automatically.

      That kind of friction is typical for young Python tooling, and it is documented in the Getting Started guide.

      And 3,000 stars at v0.0.21 is strong early traction, but it's still early: The community is small. When something breaks, you're reading source code, not documentation.

      These are real costs. I chose to pay them because the alternative costs are higher.

      For example:

      • Hugo's templating pain would cost me time on every site change.
      • Astro's JS ecosystem would add complexity I don't need.
      • MkDocs would work today but hit scaling walls tomorrow.

      Zensical's costs are front-loaded and shrinking.

      The others compound.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation-framework","level":2,"title":"The Evaluation Framework","text":"

      For anyone facing a similar choice, here is the framework that emerged:

      Signal What It Tells You Weight Team track record Whether the architecture will be sound High Migration path Whether you can leave if wrong High Current fit Whether it solves your problem today High Dependency tree How much complexity you're inheriting Medium Version number How long the project has existed Low Star count Community interest (not quality) Low Feature list What's possible (not what you need) Low

      The bottom three are the metrics most engineers optimize for.

      The top four are the ones that predict whether you'll still be happy with the choice in a year.

      Features You Don't Need Are Not Free

      Every feature in a dependency is code you inherit but don't control.

      A tool with 200 features where you use 5 means 195 features worth of surface area for bugs, breaking changes, and security issues that have nothing to do with your use case.

      Fit is the inverse of feature count.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-broader-pattern","level":2,"title":"The Broader Pattern","text":"

      This is part of a theme I keep encountering in this project:

      Leading indicators beat lagging indicators.

      Domain Lagging Indicator Leading Indicator Tooling Version number, star count Team track record, architecture Code quality Test coverage percentage Whether tests catch real bugs Context persistence Number of files in .context/ Whether the AI makes fewer mistakes Skills Number of skills created Whether each skill fires at the right time Consolidation Lines of code refactored Whether drift stops accumulating

      Version numbers, star counts, coverage percentages, file counts...

      ...these are all measures of effort expended.

      They say nothing about value delivered.

      The question is never \"how mature is this tool?\"

      The question is \"does this tool's trajectory intersect with my needs?\"

      Zensical's trajectory:

      • A proven team fixing known problems,
      • in a *proven architecture,
      • with a standard format,
      • and no lock-in.

      ctx's needs:

      Tender standard Markdown into a browsable site, at scale, without complexity.

      The intersection is clean; the version number is noise.

      This is the same kind of decision that shows up throughout ctx:

      • Skills that fight the platform taught that the best integration extends existing behavior, not replaces it.
      • You can't import expertise taught that tools should grow from your project's actual needs, not from feature checklists.
      • Context as infrastructure argues that the format should outlive the tool; and, zensical honors that principle by reading standard Markdown and standard MkDocs configuration.

      If You Remember One Thing from This Post...

      Version numbers measure where a project has been.

      The team and the architecture tell you where it's going.

      A v0.0.21 tool built by the right team on the right foundations is a safer bet than a v5.0 tool that doesn't fit your problem.

      Bet on trajectories, not timestamps.

      This post started as an evaluation note in ideas/ and a separate decision log. The analysis held up. The two merged into one. The meta continues.

      ","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/","level":1,"title":"ctx v0.6.0: The Integration Release","text":"","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#two-commands-to-persistent-memory","level":2,"title":"Two Commands to Persistent Memory","text":"

      Jose Alekhinne / February 16, 2026

      What Changed?

      ctx is now a Claude Code plugin. Two commands, no build step:

      /plugin marketplace add ActiveMemory/ctx\n/plugin install ctx@activememory-ctx\n

      Six hooks. Twenty-five skills. Installed.

      For three releases, ctx required assembly:

      • Clone the repo;
      • Build the binary;
      • Copy hook scripts into .claude/hooks/;
      • Symlink skill files.
      • Understand which shell scripts called which Go commands;
      • Hope nothing broke when Claude Code updated its hook format.

      v0.6.0 ends that era: ctx ships as a Claude Marketplace plugin:

      Hooks and skills served directly from source, installed with a single command, updated by pulling the repo. The tool that gives AI persistent memory is now as easy to install as the AI itself.

      But the plugin conversion was not just a packaging change: It was the forcing function that rewrote every shell hook in Go, eliminated the jq dependency, enabled go test coverage for hook logic, and made distribution a solved problem.

      When you fix how something ships, you end up fixing how it is built.

      The Release Window

      February 15-February 16, 2026

      From the v0.3.0 tag to commit a3178bc:

      • 109 commits.
      • 334 files changed.
      • Version jumped from 0.3.0 to 0.6.0 to signal the magnitude.
      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#before-six-shell-scripts-and-a-prayer","level":2,"title":"Before: Six Shell Scripts and a Prayer","text":"

      v0.3.0 had six hook scripts. Each was a Bash file that shelled out to ctx subcommands, parsed JSON with jq, and wired itself into Claude Code's hook system via .claude/hooks/:

      .claude/hooks/\n├── check-context-size.sh\n├── check-persistence.sh\n├── check-journal.sh\n├── post-commit.sh\n├── block-non-path-ctx.sh\n└── cleanup-tmp.sh\n

      This worked, but it also meant:

      • jq was a hard dependency: No jq, no hooks. macOS ships without it.
      • No test coverage: Shell scripts were tested manually or not at all.
      • Fragile deployment: ctx init had to scaffold .claude/hooks/ and .claude/skills/ with the right paths, permissions, and structure.
      • Version drift: Users who installed once never got hook updates unless they re-ran ctx init.

      The shell scripts were the right choice for prototyping. They were the wrong choice for distribution.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#after-one-plugin-zero-shell-scripts","level":2,"title":"After: One Plugin, Zero Shell Scripts","text":"

      v0.6.0 replaces all six scripts with ctx system subcommands compiled into the binary:

      Shell Script Go Subcommand check-context-size.sh ctx system check-context-size check-persistence.sh ctx system check-persistence check-journal.sh ctx system check-journal post-commit.sh ctx system post-commit block-non-path-ctx.sh ctx system block-non-path-ctx cleanup-tmp.sh ctx system cleanup-tmp

      The plugin's hooks.json wires them to Claude Code events:

      {\n  \"PreToolUse\": [\n    {\"matcher\": \"Bash\", \"command\": \"ctx system block-non-path-ctx\"},\n    {\"matcher\": \".*\", \"command\": \"ctx agent --budget 4000\"}\n  ],\n  \"PostToolUse\": [\n    {\"matcher\": \"Bash\", \"command\": \"ctx system post-commit\"}\n  ],\n  \"UserPromptSubmit\": [\n    {\"command\": \"ctx system check-context-size\"},\n    {\"command\": \"ctx system check-persistence\"},\n    {\"command\": \"ctx system check-journal\"}\n  ],\n  \"SessionEnd\": [\n    {\"command\": \"ctx system cleanup-tmp\"}\n  ]\n}\n

      No jq. No shell scripts. No .claude/hooks/ directory to manage.

      The hooks are Go functions with tests, compiled into the same binary you already have.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#the-plugin-model","level":2,"title":"The Plugin Model","text":"

      The ctx plugin lives at .claude-plugin/marketplace.json in the repo.

      Claude Code's marketplace system handles discovery and installation:

      Skills are served directly from internal/assets/claude/skills/; there is no build step, no make plugin, no generated artifacts.

      This means:

      1. Install is two commands: Not \"clone, build, copy, configure.\"
      2. Updates are automatic: Pull the repo; the plugin reads from source.
      3. Skills and hooks are versioned together: No drift between what the CLI expects and what the plugin provides.
      4. ctx init is tool-agnostic: It creates .context/ and nothing else. No .claude/ scaffolding, no assumptions about which AI tool you use.

      That last point matters:

      Before v0.6.0, ctx init tried to set up Claude Code integration as part of initialization. That coupled the context system to a specific tool.

      Now, ctx init gives you persistent context. The plugin gives you Claude Code integration. They compose; they don't depend.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#beyond-the-plugin-what-else-shipped","level":2,"title":"Beyond the Plugin: What Else Shipped","text":"

      The plugin conversion dominated the release, but 109 commits covered more ground.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#obsidian-vault-export","level":3,"title":"Obsidian Vault Export","text":"
      ctx journal obsidian\n

      Generates a full Obsidian vault from enriched journal entries: wikilinks, MOC (Map of Content) pages, and graph-optimized cross-linking. If you already use Obsidian for notes, your AI session history now lives alongside everything else.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#encrypted-scratchpad","level":3,"title":"Encrypted Scratchpad","text":"
      ctx pad edit \"DATABASE_URL=postgres://...\"\nctx pad show\n

      AES-256-GCM encrypted storage for sensitive one-liners.

      The encrypted blob commits to git; the key stays in .gitignore.

      This is useful for connection strings, API keys, and other values that need to travel with the project without appearing in plaintext.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#security-hardening","level":3,"title":"Security Hardening","text":"

      Three medium-severity findings from a security audit are now closed:

      Finding Fix Path traversal via --context-dir Boundary validation: operations cannot escape project root (M-1) Symlink following in .context/ Lstat() check before every file read/write (M-2) Predictable temp file paths User-specific temp directory under $XDG_RUNTIME_DIR (M-3)

      Plus a new /sanitize-permissions skill that audits settings.local.json for overly broad Bash permissions.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#hooks-that-know-when-to-be-quiet","level":3,"title":"Hooks That Know When to Be Quiet","text":"

      A subtle but important fix: hooks now no-op before ctx init has run.

      Previously, a fresh clone with no .context/ would trigger hook errors on every prompt. Now, hooks detect the absence of a context directory and exit silently. Similarly, ctx init treats a .context/ directory containing only logs as uninitialized and skips the --overwrite prompt.

      Small changes. Large reduction in friction for new users.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#the-numbers","level":2,"title":"The Numbers","text":"Metric v0.3.0 v0.6.0 Skills 21 25 Shell hook scripts 6 0 Go system subcommands 0 6 External dependencies (hooks) jq, bash none Lines of Go ~14,000 ~37,000 Plugin install commands n/a 2 Security findings (open) 3 0 ctx init creates .claude/ yes no

      The line count tripled. Most of that is documentation site HTML, Obsidian export logic, and the scratchpad encryption module.

      The core CLI grew modestly; the ecosystem around it grew substantially.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#what-does-v060-mean-for-ctx","level":2,"title":"What Does v0.6.0 Mean for ctx?","text":"
      • v0.1.0 asked: \"Can we give AI persistent memory?\"
      • v0.2.0 asked: \"Can we make that memory accessible to humans too?\"
      • v0.3.0 asked: \"Can we make the quality self-enforcing?\"

      v0.6.0 asks: \"Can someone else actually use this?\"

      A tool that requires cloning a repo, building from source, and manually wiring hooks into the right directories is a tool for its author.

      A tool that installs with two commands from a marketplace is a tool for everyone.

      The version jumped from 0.3.0 to 0.6.0 because the delta is not incremental: The shell-to-Go rewrite, the plugin model, the security hardening, and the tool-agnostic init: Together, they change what ctx is: Not a different tool, but a tool that is finally ready to leave the workshop.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/#what-comes-next","level":2,"title":"What Comes Next","text":"

      The plugin model opens the door to distribution patterns that were not possible before. Marketplace discovery means new users find ctx without reading a README. Plugin updates mean existing users get improvements without rebuilding.

      The next chapter is about what happens when persistent context is easy to install: Adoption patterns, multi-project workflows, and whether the .context/ convention can become infrastructure that other tools build on.

      But those are future posts.

      This one is about the release that turned a developer tool into a distributable product: two commands, zero shell scripts, and a presence on the Claude Marketplace.

      The Integration Release

      v0.1.0 shipped features. v0.2.0 shipped archaeology.

      v0.3.0 shipped discipline. v0.6.0 shipped the front door.

      The most important code in this release is the code you never have to copy.

      This post was drafted using /ctx-blog-changelog with access to the full git history between v0.3.0 and v0.6.0, release notes, and the plugin conversion PR. The meta continues.

      ","path":["ctx v0.6.0: The Integration Release"],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/","level":1,"title":"Code Is Cheap. Judgment Is Not.","text":"","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#why-ai-replaces-effort-not-expertise","level":2,"title":"Why AI Replaces Effort, Not Expertise","text":"

      Jose Alekhinne / February 17, 2026

      Are You Worried about AI Taking Your Job?

      You might be confusing the thing that's cheap with the thing that's valuable.

      I keep seeing the same conversation: Engineers, designers, writers: all asking the same question with the same dread:

      \"What happens when AI can do what I do?\"

      The question is wrong:

      • AI does not replace workers;
      • AI replaces unstructured effort.

      The distinction matters, and everything I have learned building ctx reinforces it.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-three-confusions","level":2,"title":"The Three Confusions","text":"

      People who feel doomed by AI usually confuse three things:

      People confuse... With... Effort Value Typing Thinking Production Judgment
      • Effort is time spent.
      • Value is the outcome that time produces.

      They are not the same; they never were.

      AI just makes the gap impossible to ignore.

      Typing is mechanical: Thinking is directional.

      An AI can type faster than any human. Yet, it cannot decide what to type without someone framing the problem, sequencing the work, and evaluating the result.

      Production is making artifacts. Judgment is knowing:

      • which artifacts to make,
      • in what order,
      • to what standard,
      • and when to stop.

      AI floods the system with production capacity; it does not flood the system with judgment.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#code-is-nothing","level":2,"title":"Code Is Nothing","text":"

      This sounds provocative until you internalize it:

      Code is cheap. Artifacts are cheap.

      An AI can generate a thousand lines of working code in literal *minutes**:

      It can scaffold a project, write tests, build a CI pipeline, draft documentation. The raw production of software artifacts is no longer the bottleneck.

      So, what is not cheap?

      • Taste: knowing what belongs and what does not
      • Framing: turning a vague goal into a concrete problem
      • Sequencing: deciding what to build first and why
      • Fanning out: breaking work into parallel streams that converge
      • Acceptance criteria: defining what \"done\" looks like before starting
      • Judgment: the thousand small decisions that separate code that works from code that lasts

      These are the skills that direct production: Hhuman skills.

      Not because AI is incapable of learning them, but because they require something AI does not have:

      temporal accountability for generated outcomes.

      That is, you cannot keep AI accountable for the $#!% it generated three months ago. A human, on the other hand, will always be accountable.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-evidence-from-building-ctx","level":2,"title":"The Evidence from Building ctx","text":"

      I did not arrive at this conclusion theoretically.

      I arrived at it by building a tool with an AI agent for three weeks and watching exactly where a human touch mattered.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#yolo-mode-proved-production-is-cheap","level":3,"title":"YOLO Mode Proved Production Is Cheap","text":"

      In Building ctx Using ctx, I documented the YOLO phase: auto-accept everything, let the AI ship features at full speed. It produced 14 commands in a week. Impressive output.

      The code worked. The architecture drifted. Magic strings accumulated. Conventions diverged. The AI was producing at a pace no human could match, and every artifact it produced was a small bet that nobody was evaluating.

      Production without judgment is not velocity. It is debt accumulation at breakneck speed.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-31-ratio-proved-judgment-has-a-cadence","level":3,"title":"The 3:1 Ratio Proved Judgment Has a Cadence","text":"

      In The 3:1 Ratio, the git history told the story:

      Three sessions of forward momentum followed by one session of deliberate consolidation. The consolidation session is where the human applies judgment: reviewing what the AI built, catching drift, realigning conventions.

      The AI does the refactoring. The human decides what to refactor and when to stop.

      Without the human, the AI will refactor forever, improving things that do not matter and missing things that do.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-attention-budget-proved-framing-is-scarce","level":3,"title":"The Attention Budget Proved Framing Is Scarce","text":"

      In The Attention Budget, I explained why more context makes AI worse, not better. Every token competes for attention: Dump everything in and the AI sees nothing clearly.

      This is a framing problem: The human's job is to decide what the AI should focus on: what to include, what to exclude, what to emphasize.

      ctx agent --budget 4000 is not just a CLI flag: It is a forcing function for human judgment about relevance.

      The AI processes. The human curates.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#skills-design-proved-taste-is-load-bearing","level":3,"title":"Skills Design Proved Taste Is Load-Bearing","text":"

      The skill trilogy (You Can't Import Expertise, The Anatomy of a Skill That Works) showed that the difference between a useful skill and a useless one is not craftsmanship:

      It is taste.

      A well-crafted skill with the wrong focus is worse than no skill at all: It consumes the attention budget with generic advice while the project-specific problems go unchecked.

      The E/A/R framework (Expert, Activation, Redundant) is a judgment too:. The AI cannot apply it to itself. The human evaluates what the AI already knows, what it needs to be told, and what is noise.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#automation-discipline-proved-restraint-is-a-skill","level":3,"title":"Automation Discipline Proved Restraint Is a Skill","text":"

      In Not Everything Is a Skill, the lesson was that the urge to automate is not the need to automate. A useful prompt does not automatically deserve to become a slash command.

      The human applies judgment about frequency, stability, and attention cost.

      The AI can build the skill. Only the human can decide whether it should exist.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#defense-in-depth-proved-boundaries-require-judgment","level":3,"title":"Defense in Depth Proved Boundaries Require Judgment","text":"

      In Defense in Depth, the entire security model for unattended AI agents came down to: markdown is not a security boundary. Telling an AI \"don't do bad things\" is production (of instructions). Setting up an unprivileged user in a network-isolated container is judgment (about risk).

      The AI follows instructions. The human decides which instructions are enforceable and which are \"wishful thinking\".

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#parallel-agents-proved-scale-amplifies-the-gap","level":3,"title":"Parallel Agents Proved Scale Amplifies the Gap","text":"

      In Parallel Agents and Merge Debt, the lesson was that multiplying agents multiplies output. But it also multiplies the need for judgment:

      Five agents running in parallel produce five sessions of drift in one clock hour. The human who can frame tasks cleanly, define narrow acceptance criteria, and evaluate results quickly becomes the limiting factor.

      More agents do not reduce the need for judgment. They increase it.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-two-reactions","level":2,"title":"The Two Reactions","text":"

      When AI floods the system with cheap output, two things happen:

      Those who only produce: panic. If your value proposition is \"I write code,\" and an AI writes code faster, cheaper, and at higher volume, then the math is unfavorable. Not because AI took your job, but because your job was never the code. It was the judgment around the code, and you were not exercising it.

      Those who direct: accelerate. If your value proposition is \"I know what to build, in what order, to what standard,\" then AI is the best thing that ever happened to you: Production is no longer the bottleneck: Your ability to frame, sequence, evaluate, and course-correct is now the limiting factor on throughput.

      The gap between these two is not talent: It is the awareness of where the value lives.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#what-this-means-in-practice","level":2,"title":"What This Means in Practice","text":"

      If you are an engineer reading this, the actionable insight is not \"learn prompt engineering\" or \"master AI tools.\" It is:

      Get better at the things AI cannot do.

      AI does this well You need to do this Generate code Frame the problem Write tests Define acceptance criteria Scaffold projects Sequence the work Fix bugs from stack traces Evaluate tradeoffs Produce volume Exercise restraint Follow instructions Decide which instructions matter

      The skills on the right column are not new. They are the same skills that have always separated senior engineers from junior ones.

      AI did not create the distinction; it just made it load-bearing.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#if-anything-i-feel-empowered","level":2,"title":"If Anything, I Feel Empowered","text":"

      I will end with something personal.

      I am not worried: I am empowered.

      Before ctx, I could think faster than I could produce:

      • Ideas sat in a queue.
      • The bottleneck was always \"I know what to build, but building it takes too long.\"

      Now the bottleneck is gone. Poof!

      • Production is cheap.
      • The queue is clearing.
      • The limiting factor is how fast I can think, not how fast I can type.

      That is not a threat: That is the best force multiplier I've ever had.

      The people who feel threatened are confusing the accelerator for the replacement:

      *AI does not replace the conductor; it gives them a bigger orchestra.

      If You Remember One Thing from This Post...

      Code is cheap. Judgment is not.

      AI replaces unstructured effort, not directed expertise. The skills that matter now are the same skills that have always mattered: taste, framing, sequencing, and the discipline to stop.

      The difference is that now, for the first time, those skills are the only bottleneck left.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-code-is-cheap-judgment-is-not/#the-arc","level":2,"title":"The Arc","text":"

      This post is a retrospective. It synthesizes the thread running through every previous entry in this blog:

      • Building ctx Using ctx showed that production without direction creates debt
      • Refactoring with Intent showed that slowing down is not the opposite of progress
      • The Attention Budget showed that curation outweighs volume
      • The skill trilogy showed that taste determines whether a tool helps or hinders
      • Not Everything Is a Skill showed that restraint is a skill in itself
      • Defense in Depth showed that instructions are not boundaries
      • The 3:1 Ratio showed that judgment has a schedule
      • Parallel Agents showed that scale amplifies the gap between production and judgment
      • Context as Infrastructure showed that the system you build for context is infrastructure, not conversation

      From YOLO mode to defense in depth, the pattern is the same:

      • Production is the easy part;
      • Judgment is the hard part;
      • AI changed the ratio, not the rule.

      This post synthesizes the thread running through every previous entry in this blog. The evidence is drawn from three weeks of building ctx with AI assistance, the decisions recorded in DECISIONS.md, the learnings captured in LEARNINGS.md, and the git history that tracks where the human mattered and where the AI ran unsupervised.

      See also: When a System Starts Explaining Itself -- what happens after the arc: the first field notes from the moment the system starts compounding in someone else's hands.

      ","path":["Code Is Cheap. Judgment Is Not."],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/","level":1,"title":"Context as Infrastructure","text":"","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#why-your-ai-needs-a-filesystem-not-a-prompt","level":2,"title":"Why Your AI Needs a Filesystem, Not a Prompt","text":"

      Jose Alekhinne / February 17, 2026

      Where Does Your AI's Knowledge Live between Sessions?

      If the answer is \"in a prompt I paste at the start,\" you are treating context as a consumable. Something assembled, used, and discarded.

      What if you treated it as infrastructure instead?

      This post synthesizes a thread that has been running through every ctx blog post; from the origin story to the attention budget to the discipline release. The thread is this: context is not a prompt problem. It is an infrastructure problem. And the tools we build for it should look more like filesystems than clipboard managers.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-prompt-paradigm","level":2,"title":"The Prompt Paradigm","text":"

      Most AI-assisted development treats context as ephemeral:

      1. Start a session.
      2. Paste your system prompt, your conventions, your current task.
      3. Work.
      4. Session ends. Everything evaporates.
      5. Next session: paste again.

      This works for short interactions. For sustained development (where decisions compound over days and weeks) it fails in three ways:

      It does not persist: A decision made on Tuesday must be re-explained on Wednesday. A learning captured in one session is invisible to the next.

      It does not scale: As the project grows, the \"paste everything\" approach hits the context window ceiling. You start triaging what to include, often cutting exactly the context that would have prevented the next mistake.

      It does not compose: A system prompt is a monolith. You cannot load part of it, update one section, or share a subset with a different workflow. It is all or nothing.

      The Copy-Paste Tax

      Every session that starts with pasting a prompt is paying a tax:

      The human time to assemble the context, the risk of forgetting something, and the silent assumption that yesterday's prompt is still accurate today.

      Over 70+ sessions, that tax compounds into a significant maintenance burden: One that most developers absorb without questioning it.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-infrastructure-paradigm","level":2,"title":"The Infrastructure Paradigm","text":"

      ctx takes a different approach:

      Context is not assembled per-session; it is maintained as persistent files in a .context/ directory:

      .context/\n  CONSTITUTION.md     # Inviolable rules\n  TASKS.md            # Current work items\n  CONVENTIONS.md      # Code patterns and standards\n  DECISIONS.md        # Architectural choices with rationale\n  LEARNINGS.md        # Gotchas and lessons learned\n  ARCHITECTURE.md     # System structure\n  GLOSSARY.md         # Domain terminology\n  AGENT_PLAYBOOK.md   # Operating manual for agents\n  journal/            # Enriched session summaries\n  archive/            # Completed work, cold storage\n
      • Each file has a single purpose;
      • Each can be loaded independently;
      • Each persists across sessions, tools, and team members.

      This is not a novel idea. It is the same idea behind every piece of infrastructure software engineers already use:

      Traditional Infrastructure ctx Equivalent Database .context/*.md files Configuration files CONSTITUTION.md Environment variables .contextrc Log files journal/ Schema migrations Decision records Deployment manifests AGENT_PLAYBOOK.md

      The parallel is not metaphorical. Context files are infrastructure:

      • They are versioned (git tracks them);
      • They are structured (Markdown with conventions);
      • They have schemas (required fields for decisions and learnings);
      • And they have lifecycle management (archiving, compaction, indexing).
      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#separation-of-concerns","level":2,"title":"Separation of Concerns","text":"

      The most important design decision in ctx is not any individual feature. It is the separation of context into distinct files with distinct purposes.

      A single CONTEXT.md file would be simpler to implement. It would also be impossible to maintain.

      Why? Because different types of context have different lifecycles:

      Context Type Changes Read By Load When Constitution Rarely Every session Always Tasks Every session Session start Always Conventions Weekly Before coding When writing code Decisions When decided When questioning When revisiting Learnings When learned When stuck When debugging Journal Every session Rarely When investigating

      Loading everything into every session wastes the attention budget on context that is irrelevant to the current task. Loading nothing forces the AI to operate blind.

      Separation of concerns allows progressive disclosure:

      Load the minimum that matters for this moment, with the option to load more when needed.

      # Session start: load the essentials\nctx agent --budget 4000\n\n# Deep investigation: load everything\ncat .context/DECISIONS.md\ncat .context/journal/2026-02-05-*.md\n

      The filesystem is the index. File names, directory structure, and timestamps encode relevance. The AI does not need to read every file; it needs to know where to look.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-two-tier-persistence-model","level":2,"title":"The Two-Tier Persistence Model","text":"

      ctx uses two tiers of persistence, and the distinction is architectural:

      Tier Purpose Location Token Cost Curated Quick context reload .context/*.md Low (budgeted) Full dump Safety net, archaeology .context/journal/*.md Zero (not auto-loaded)

      The curated tier is what the AI sees at session start. It is optimized for signal density:

      • Structured entries,
      • Indexed tables,
      • Reverse-chronological order (newest first, so the most relevant content survives truncation).

      The full dump tier is for humans and for deep investigation. It contains everything: Enriched journals, archived tasks...

      It is never autoloaded because its volume would destroy attention density.

      This two-tier model is analogous to how traditional systems separate hot and cold storage:

      • The hot path (curated context) is optimized for read performance (measured not in milliseconds, but in tokens consumed per unit of useful information).
      • The cold path (journal) is optimized for completeness.

      Nothing Is Ever Truly Lost

      The full dump tier means that context does not need to be perfect: It just needs to be findable.

      A decision that was not captured in DECISIONS.md can be recovered from the session transcript where it was discussed.

      A learning that was not formalized can be found in the journal entry from that day.

      The curated tier is the fast path: The full dump tier is the safety net.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#decision-records-as-first-class-citizens","level":2,"title":"Decision Records as First-Class Citizens","text":"

      One of the patterns that emerged from ctx's own development is the power of structured decision records.

      v0.1.0 allowed adding decisions as one-liners:

      ctx add decision \"Use PostgreSQL\"\n

      v0.2.0 enforced structure:

      ctx add decision \"Use PostgreSQL\" \\\n  --context \"Need a reliable database for user data\" \\\n  --rationale \"ACID compliance, team familiarity\" \\\n  --consequence \"Need connection pooling, team training\"\n

      The difference is not cosmetic:

      • A one-liner decision teaches the AI what was decided.
      • A structured decision teaches it why; and why is what prevents the AI from unknowingly reversing the decision in a future session.

      This is infrastructure thinking:

      Decisions are not notes. They are records with required fields, just like database rows have schemas.

      The enforcement exists because incomplete records are worse than no records: They create false confidence that the context is captured when it is not.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-ide-is-the-interface-decision","level":2,"title":"The \"IDE Is the Interface\" Decision","text":"

      Early in ctx's development, there was a temptation to build a custom UI: a web dashboard for browsing sessions, editing context, viewing analytics.

      The decision was no. The IDE is the interface.

      # This is the ctx \"UI\":\ncode .context/\n

      This decision was not about minimalism for its own sake. It was about recognizing that .context/ files are just files; and files have a mature, well-understood infrastructure:

      • Version control: git diff .context/DECISIONS.md shows exactly what changed and when.
      • Search: Your IDE's full-text search works across all context files.
      • Editing: Markdown in any editor, with preview, spell check, and syntax highlighting.
      • Collaboration: Pull requests on context files work the same as pull requests on code.

      Building a custom UI would have meant maintaining a parallel infrastructure that duplicates what every IDE already provides:

      It would have introduced its own bugs, its own update cycle, and its own learning curve.

      The filesystem is not a limitation: It is the most mature, most composable, most portable infrastructure available.

      Context Files in Git

      Because .context/ lives in the repository, context changes are part of the commit history.

      A decision made in commit abc123 is as traceable as a code change in the same commit.

      This is not possible with prompt-based context, which exists outside version control entirely.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#progressive-disclosure-for-ai","level":2,"title":"Progressive Disclosure for AI","text":"

      The concept of progressive disclosure comes from human interface design: show the user the minimum needed to make progress, with the option to drill deeper.

      ctx applies the same principle to AI context:

      Level What the AI Sees Token Cost When Level 0 ctx status (one-line summary) ~100 Quick check Level 1 ctx agent --budget 4000 ~4,000 Normal work Level 2 ctx agent --budget 8000 ~8,000 Complex tasks Level 3 Direct file reads 10,000+ Deep investigation

      Each level trades tokens for depth. Level 1 is sufficient for most work: the AI knows the active tasks, the key conventions, and the recent decisions. Level 3 is for archaeology: understanding why a decision was made three weeks ago, or finding a pattern in the session history.

      The explicit --budget flag is the mechanism that makes this work:

      Without it, the default behavior would be to load everything (because more context feels safer), which destroys the attention density that makes the loaded context useful.

      The constraint is the feature: A budget of 4,000 tokens forces ctx to prioritize ruthlessly: constitution first (always full), then tasks and conventions (budget-capped), then decisions and learnings scored by recency and relevance to active tasks. Entries that don't fit get title-only summaries rather than being silently dropped.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-philosophical-shift","level":2,"title":"The Philosophical Shift","text":"

      The shift from \"context as prompt\" to \"context as infrastructure\" changes how you think about AI-assisted development:

      Prompt Thinking Infrastructure Thinking \"What do I paste today?\" \"What has changed since yesterday?\" \"How do I fit everything in?\" \"What's the minimum that matters?\" \"The AI forgot my conventions\" \"The conventions are in a file\" \"I need to re-explain\" \"I need to update the record\" \"This session is getting slow\" \"Time to compact and archive\"

      The first column treats AI interaction as a conversation. The second treats it as a system: One that can be maintained, optimized, and debugged.

      Context is not something you give the AI. It is something you maintain: Like a database, like a config file, like any other piece of infrastructure that a running system depends on.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#beyond-ctx-the-principles","level":2,"title":"Beyond ctx: The Principles","text":"

      The patterns that ctx implements are not specific to ctx. They are applicable to any project that uses AI-assisted development:

      1. Separate context by purpose: Do not put everything in one file. Different types of information have different lifecycles and different relevance windows.
      2. Make context persistent: If a decision matters, write it down in a file that survives the session. If a learning matters, capture it with structure.
      3. Budget explicitly: Know how much context you are loading and whether it is worth the attention cost.
      4. Use the filesystem: File names, directory structure, and timestamps are metadata that the AI can navigate. A well-organized directory is an index that costs zero tokens to maintain.
      5. Version your context: Put context files in git. Changes to decisions are as important as changes to code.
      6. Design for degradation: Sessions will get long. Attention will dilute. Build mechanisms (compaction, archiving, cooldowns) that make degradation visible and manageable.

      These are not ctx features. They are infrastructure principles that happen to be implemented as a CLI tool. Any team could implement them with nothing more than a directory convention and a few shell scripts.

      The tool is a convenience: The principles are what matter.

      If You Remember One Thing from This Post...

      Prompts are conversations. Infrastructure persists.

      Your AI does not need a better prompt. It needs a filesystem:

      versioned, structured, budgeted, and maintained.

      The best context is the context that was there before you started the session.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-arc","level":2,"title":"The Arc","text":"

      This post is the architectural companion to the Attention Budget. That post explained why context must be curated (token economics). This one explains how to structure it (filesystem, separation of concerns, persistence tiers).

      Together with Code Is Cheap, Judgment Is Not, they form a trilogy about what matters in AI-assisted development:

      • Attention Budget: the resource you're managing
      • Context as Infrastructure: the system you build to manage it
      • Code Is Cheap: the human skill that no system replaces

      And the practices that keep it all honest:

      • The 3:1 Ratio: the cadence for maintaining both code and context
      • IRC as Context: the historical precedent: stateless protocols have always needed stateful wrappers

      This post synthesizes ideas from across the ctx blog series: the attention budget primitive, the two-tier persistence model, the IDE decision, and the progressive disclosure pattern. The principles are drawn from three weeks of building ctx and 70+ sessions of treating context as infrastructure rather than conversation.

      See also: When a System Starts Explaining Itself: what happens when this infrastructure starts compounding in someone else's environment.

      ","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/","level":1,"title":"Parallel Agents, Merge Debt, and the Myth of Overnight Progress","text":"","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#when-the-screen-looks-like-progress","level":2,"title":"When the Screen Looks like Progress","text":"

      Jose Alekhinne / 2026-02-17

      How Many Terminals Are Too Many?

      You discover agents can run in parallel.

      So you open ten...

      ...Then twenty.

      The fans spin. Tokens burn. The screen looks like progress.

      It is NOT progress.

      There is a phase every builder goes through:

      • The tooling gets fast enough.
      • The model gets good enough.
      • The temptation becomes irresistible:
        • more agents, more output, faster delivery.

      So you open terminals. You spawn agents. You watch tokens stream across multiple windows simultaneously, and it feels like multiplication.

      It is not multiplication.

      It is merge debt being manufactured in real time.

      The ctx Manifesto says it plainly:

      Activity is not impact. Code is not progress.

      This post is about what happens when you take that seriously in the context of parallel agent workflows.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-unit-of-scale-is-not-the-agent","level":2,"title":"The Unit of Scale Is Not the Agent","text":"

      The naive model says:

      More agents -> more output -> faster delivery

      The production model says:

      Clean context boundaries -> less interference -> higher throughput

      Parallelism only works when the cognitive surfaces do not overlap.

      If two agents touch the same files, you did not create parallelism: You created a conflict generator.

      They will:

      • Revert each other's changes;
      • Relint each other's formatting;
      • Refactor the same function in different directions.

      You watch with 🍿. Nothing ships.

      This is the same insight from the worktrees post: partition by blast radius, not by priority.

      Two tasks that touch the same files belong in the same track, no matter how important the other one is. The constraint is file overlap.

      Everything else is scheduling.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-five-agent-rule","level":2,"title":"The \"Five Agent\" Rule","text":"

      In practice there is a ceiling.

      Around five or six concurrent agents:

      • Token burn becomes noticeable;
      • Supervision cost rises;
      • Coordination noise increases;
      • Returns flatten.

      This is not a model limitation: This is a human merge bandwidth limitation.

      You are the bottleneck, not the silicon.

      The attention budget applies to you too:

      Every additional agent is another stream of output you need to comprehend, verify, and integrate. Your attention density drops the same way the model's does when you overload its context window.

      Five agents producing verified, mergeable change beats twenty agents producing merge conflicts you spend a day untangling.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#role-separation-beats-file-locking","level":2,"title":"Role Separation Beats File Locking","text":"

      Real parallelism comes from task topology, not from tooling.

      Good:

      Agent Role Touches 1 Documentation docs/, hack/ 2 Security scan Read-only audit 3 Implementation internal/cli/ 4 Enhancement requests Read-only, files issues

      Bad:

      • Four agents editing the same implementation surface

      Context Is the Boundary

      • The goal is not to keep agents busy.
      • The goal is to keep contexts isolated.

      This is what the codebase audit got right:

      • Eight agents, all read-only, each analyzing a different dimension.
      • Zero file overlap.
      • Zero merge conflicts.
      • Eight reports that composed cleanly because no agent interfered with another.
      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#when-terminals-stop-scaling","level":2,"title":"When Terminals Stop Scaling","text":"

      There is a moment when more windows stop helping.

      That is the signal. Not to add orchestration. But to introduce:

      git worktree\n

      Because now you are no longer parallelizing execution; you are parallelizing state.

      State Scales, Windows Don't

      • State isolation is the real scaling.
      • Window multiplication is theater.

      The worktrees post covers the mechanics:

      • Sibling directories;
      • Branch naming;
      • The inevitable TASKS.md conflicts;
      • The 3-4 worktree ceiling.

      The principle underneath is older than git:

      Shared mutable state is the enemy of parallelism.

      Always has been.

      Always will be.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-overnight-loop-illusion","level":2,"title":"The Overnight Loop Illusion","text":"

      Autonomous night runs are impressive.

      You sleep. The machine produces thousands of lines.

      In the morning:

      • You read;
      • You untangle;
      • You reconstruct intent;
      • You spend a day making it shippable.

      In retrospect, nothing was accelerated.

      The bottleneck moved from typing to comprehension.

      The Comprehension Tax

      If understanding the output costs more than producing it, the loop is a net loss.

      Progress is not measured in generated code.

      Progress is measured in verified, mergeable change.

      The ctx Manifesto calls this out directly:

      The Scoreboard

      Verified reality is the scoreboard.

      The only truth that compounds is verified change in the real world.

      An overnight run that produces 3,000 lines nobody reviewed is not 3,000 lines of progress: It is 3,000 lines of liability until someone verifies every one of them.

      And that someone is (insert drumroll here) you:

      The same bottleneck that was supposedly being bypassed.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#skills-that-fight-the-platform","level":2,"title":"Skills That Fight the Platform","text":"

      Most marketplace skills are prompt decorations:

      • They rephrase what the base model already knows;
      • They increase token usage;
      • They reduce clarity:
      • They introduce behavioral drift.

      We covered this in depth in Skills That Fight the Platform: judgment suppression, redundant guidance, guilt-tripping, phantom dependencies, universal triggers: Five patterns that make agents worse, not better.

      A real skill does one of these:

      • Encodes workflow state;
      • Enforces invariants;
      • Reduces decision branching.

      Everything else is packaging.

      The anatomy post established the criteria: quality gates, negative triggers, examples over rules, skills as contracts.

      If a skill doesn't meet those criteria...

      • It is either a recipe (document it in hack/);
      • Or noise (delete it);
      • There is no third option.
      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#hooks-are-context-that-execute","level":2,"title":"Hooks Are Context That Execute","text":"

      The most valuable skills are not prompts:

      They are constraints embedded in the toolchain.

      For example: The agent cannot push.

      git push becomes:

      Stop. A human reviews first.

      A commit without verification becomes:

      Did you run tests? Did you run linters? What exactly are you shipping?

      This is not safety theater; this is intent preservation.

      The thing the ctx Manifesto calls \"encoding intent into the environment.\"

      The Eight Ways a Hook Can Talk catalogued the full spectrum: from silent enrichment to hard blocks.

      The key insight was that hooks are not just safety rails: They are context that survives execution.

      They are the difference between an agent that remembers the rules and one that enforces them.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#complexity-is-a-tax","level":2,"title":"Complexity Is a Tax","text":"

      Every extra layer adds cognitive weight:

      • Orchestration frameworks;
      • Meta agents;
      • Autonomous planning systems...

      If a single terminal works, stay there.

      If five isolated agents work, stop there.

      Add structure only when a real bottleneck appears.

      NOT when an influencer suggests one.

      This is the same lesson from Not Everything Is a Skill:

      The best automation decision is sometimes not to automate.

      A recipe in a Markdown file costs nothing until you use it.

      An orchestration framework costs attention on every run, whether it helps or not.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#literature-is-throughput","level":2,"title":"Literature Is Throughput","text":"

      Clear writing is not aesthetic: It is compression.

      Better articulation means:

      • Fewer tokens;
      • Fewer misinterpretations;
      • Faster convergence.

      The attention budget taught us that context is a finite resource with a quadratic cost.

      Language determines how fast you spend context.

      A well-written task description that takes 50 tokens outperforms a rambling one that takes 200: Not just because it is cheaper, but because it leaves more headroom for the model to actually think.

      Literature Is NOT Overrated

      • Attention is a finite budget.
      • Language determines how fast you spend it.
      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#the-real-metric","level":2,"title":"The Real Metric","text":"

      The real metric is not:

      • Lines generated;
      • Agents running;
      • Tasks completed while you sleep.

      But:

      Time from idea to verified, mergeable, production change.

      Everything else is motion.

      The entire blog series has been circling this point:

      • The attention budget was about spending tokens wisely.
      • The skills trilogy was about not wasting them on prompt decoration.
      • The worktrees post was about multiplying throughput without multiplying interference.
      • The discipline release was about what a release looks like when polish outweighs features: 3:1.

      Every post has arrived (and made me converge) at the same answer so far:

      The metric is a verified change, not generated output.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#ctx-was-never-about-spawning-more-minds","level":2,"title":"ctx Was Never about Spawning More Minds","text":"

      ctx is about:

      • Isolating context;
      • Preserving intent;
      • Making progress composable.

      Parallel agents are powerful. But only when you respect the boundaries that make parallelism real.

      Otherwise, you are not scaling cognition; you are scaling interference.

      The ctx Manifesto's thesis holds:

      Without ctx, intelligence resets. With ctx, creation compounds.

      Compounding requires structure.

      Structure requires boundaries.

      Boundaries require the discipline to stop adding agents when five is enough.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-parallel-agents-merge-debt-and-the-myth-of-overnight-progress/#practical-summary","level":2,"title":"Practical Summary","text":"

      A production workflow tends to converge to this:

      Practice Why Stay in one terminal unless necessary Minimize coordination overhead Spawn a small number of agents with non-overlapping responsibilities Conflict avoidance > parallelism Isolate state with worktrees when surfaces grow State isolation is real scaling Encode verification into hooks Intent that survives execution Avoid marketplace prompt cargo cults Skills are contracts, not decorations Measure merge cost, not generation speed The metric is verified change

      This is slower to watch. Faster to ship.

      If You Remember One Thing from This Post...

      Progress is not what the machine produces while you sleep.

      Progress is what survives contact with the main branch.

      See also: Code Is Cheap. Judgment Is Not.: the argument that production capacity was never the bottleneck, and why multiplying agents amplifies the need for human judgment rather than replacing it.

      ","path":["Parallel Agents, Merge Debt, and the Myth of Overnight Progress"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/","level":1,"title":"The 3:1 Ratio","text":"","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#scheduling-consolidation-in-ai-development","level":2,"title":"Scheduling Consolidation in AI Development","text":"

      Jose Alekhinne / February 17, 2026

      How Often Should You Stop Building and Start Cleaning?

      Every developer knows technical debt exists. Every developer postpones dealing with it.

      AI-assisted development makes the problem worse; not because the AI writes bad code, but because it writes code so fast that drift accumulates before you notice.

      In Refactoring with Intent, I mentioned a ratio that worked for me: 3:1. Three YOLO sessions create enough surface area to reveal patterns. The fourth session turns those patterns into structure.

      That was an observation. This post is the evidence.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-observation","level":2,"title":"The Observation","text":"

      During the first two weeks of building ctx, I noticed a rhythm in my own productivity. Feature sessions felt great: new commands, new capabilities, visible progress...

      ...but after three of them, things would start to feel sticky: variable names that almost made sense, files that had grown past their purpose, patterns that repeated without being formalized.

      The fourth session (when I stopped adding and started cleaning) was always the most painful to start and the most satisfying to finish.

      It was also the one that made the next three feature sessions faster.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-evidence-git-history","level":2,"title":"The Evidence: Git History","text":"

      The ctx git history between January 20 and February 7 tells a clear story when you categorize commits:

      Week Feature commits Consolidation commits Ratio Jan 20-26 18 5 3.6:1 Jan 27-Feb 1 14 6 2.3:1 Feb 1-7 15 35+ 0.4:1

      The first week was pure YOLO: Almost four feature commits for every consolidation commit. The codebase grew fast.

      The second week started to self-correct. The ratio dropped as refactoring sessions became necessary: Not scheduled, but forced by friction.

      The third week inverted entirely: v0.3.0 was almost entirely consolidation: the skill migration, the sweep, the documentation standardization. Thirty-five quality commits against fifteen features.

      The debt from weeks one and two was paid in week three.

      The Compounding Problem

      Consolidation debt compounds.

      Week one's drift doesn't just persist into week two: It accelerates, because new features are built on top of drifted patterns.

      By week three, the cost of consolidation was higher than it would have been if spread evenly.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#what-drift-actually-looks-like","level":2,"title":"What Drift Actually Looks Like","text":"

      \"Drift\" sounds abstract. Here is what it looked like concretely in the ctx codebase after three weeks of feature-heavy development:

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#predicate-naming","level":3,"title":"Predicate Naming","text":"

      Convention says boolean functions should be named HasX, IsX, CanX. After three feature sprints:

      // What accumulated:\nfunc CheckIfEnabled() bool  // should be Enabled\nfunc ValidateFormat() bool  // should be ValidFormat\nfunc TestConnection() bool  // should be Connects\nfunc VerifyExists() bool    // should be Exists or HasFile\nfunc EnsureReady() bool     // should be Ready\n

      Five violations. Not bugs, but friction that compounds every time someone (human or AI) reads the code and has to infer the naming convention from inconsistent examples.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#magic-strings","level":3,"title":"Magic Strings","text":"
      // Week 1: acceptable prototype\nif entry.Type == \"task\" {\n    filename = \"TASKS.md\"\n}\n\n// Week 3: same pattern in 7+ files\n// Now it's a maintenance liability\n

      When the same literal appears in seven files, changing it means finding all seven. Missing one means a silent runtime bug. Constants exist to prevent exactly this. But during feature velocity, nobody stops to extract them.

      Refactoring with Intent documented the constants consolidation that cleaned this up. The 3:1 ratio is the practice that prevents it from accumulating again.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#hardcoded-permissions","level":3,"title":"Hardcoded Permissions","text":"
      os.WriteFile(path, data, 0644) // 80+ instances\nos.MkdirAll(path, 0755)        // scattered across packages\n

      Eighty-plus instances of hardcoded file permissions. Not wrong, but if I ever need to change the default (and I did, for hook scripts that need execute permissions), it means a codebase-wide search.

      Drift Is Not Bugs

      None of these are bugs. The code works. Tests pass.

      But drift creates false confidence: the codebase looks consistent until you try to change something and discover that five different conventions exist for the same concept.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#why-you-cannot-consolidate-on-day-one","level":2,"title":"Why You Cannot Consolidate on Day One","text":"

      The temptation is to front-load quality: write all the conventions, enforce all the checks, prevent all the drift before it happens.

      This fails for two reasons.

      First, you do not know what will drift: Predicate naming violations only become a convention check after you notice three different naming patterns competing. Magic strings only become a consolidation target after you change a literal and discover it exists in seven places.

      The conventions emerge from the work; they cannot precede it.

      This is what You Can't Import Expertise meant in practice: the consolidation checks grow from the project's own drift history. You cannot write them on day one because you do not yet know what will drift.

      Second, premature consolidation slows discovery: During the prototyping phase, the goal is to explore the design space. Enforcing strict conventions on code that might be deleted tomorrow is waste.

      YOLO mode has its place: The problem is not YOLO itself, but YOLO without a scheduled cleanup.

      The Consolidation Paradox

      You need a drift history to know what to consolidate.

      You need consolidation to prevent drift from compounding.

      The 3:1 ratio resolves this paradox:

      Let drift accumulate for three sessions (enough to see patterns), then consolidate in the fourth (before the patterns become entrenched*).

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-consolidation-skill","level":2,"title":"The Consolidation Skill","text":"

      The ctx project now has an /audit skill that encodes nine project-specific checks:

      Check What It Catches Predicate naming Boolean functions not using Has/Is/Can Magic strings Repeated literals not in config constants File permissions Hardcoded 0644/0755 not using constants Godoc style Missing or non-standard documentation File length Files exceeding 400 lines Large functions Functions exceeding 80 lines Template drift Live skills diverging from templates Import organization Non-standard import grouping TODO/FIXME staleness Old markers that are no longer relevant

      This is not a generic linter. These are project-specific conventions that emerged from ctx's own development history. A generic code quality tool would catch some of them. Only a project-specific check catches all of them, because some of them (predicate naming, template drift) are conventions that exist nowhere except in this project's CONVENTIONS.md.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-decision-matrix","level":2,"title":"The Decision Matrix","text":"

      Not all drift needs immediate consolidation. Here is the matrix I use:

      Signal Action Same literal in 3+ files Extract to constant Same code block in 3+ places Extract to helper Naming convention violated 5+ times Fix and document rule File exceeds 400 lines Split by concern Convention exists but is regularly violated Strengthen enforcement Pattern exists only in one place Leave it alone Code works but is \"ugly\" Leave it alone

      The last two rows matter:

      Consolidation is about reducing maintenance cost, not achieving aesthetic perfection. Code that works and exists in one place does not benefit from consolidation; it benefits from being left alone until it earns its refactoring.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#consolidation-as-context-hygiene","level":2,"title":"Consolidation as Context Hygiene","text":"

      There is a parallel between code consolidation and context management that became clear during the ctx development:

      Code Consolidation Context Hygiene Extract magic strings Archive completed tasks Standardize naming Keep DECISIONS.md current Remove dead code Compact old sessions Update stale comments Review LEARNINGS.md for staleness Check template drift Verify CONVENTIONS.md matches code

      ctx compact does for context what consolidation does for code:

      It moves completed work to cold storage, keeping the active context clean and focused. The attention budget applies to both the AI's context window and the developer's mental model of the codebase.

      When context files accumulate stale entries, the AI's attention is wasted on completed tasks and outdated conventions. When code accumulates drift, the developer's attention is wasted on inconsistencies that obscure the actual logic.

      Both are solved by the same discipline: periodic, scheduled cleanup.

      This is also why parallel agents make the problem harder, not easier. Three agents running simultaneously produce three sessions' worth of drift in one clock hour. The consolidation cadence needs to match the output rate, not the calendar.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-practice","level":2,"title":"The Practice","text":"

      Here is how the 3:1 ratio works in practice for ctx development:

      Sessions 1-3: Feature work

      • Add new capabilities;
      • Write tests for new code;
      • Do not stop for cleanup unless something is actively broken;
      • Note drift as you see it (a comment, a task, a mental note).

      Session 4: Consolidation

      • Run /audit to surface accumulated drift;
      • Fix the highest-impact items first;
      • Update CONVENTIONS.md if new patterns emerged;
      • Archive completed tasks;
      • Review LEARNINGS.md for anything that became a convention.

      The key insight is that session 4 is not optional. It is not \"if we have time\": It is scheduled with the same priority as feature work.

      The cost of skipping it is not visible immediately; it becomes visible three sessions later, when the next consolidation session takes twice as long because the drift compounded.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#what-the-ratio-is-not","level":2,"title":"What the Ratio Is Not","text":"

      The 3:1 ratio is not a universal law. It is an empirical observation from one project with one developer working with AI assistance.

      Different projects will have different ratios:

      • A mature codebase with strong conventions might sustain 5:1 or higher;
      • A greenfield prototype might need 2:1;
      • A team of multiple developers with different styles might need 1:1.

      The number is less important than the practice: consolidation is not a reaction to problems. It is a scheduled activity.

      If you wait for drift to cause pain before consolidating, you have already paid the compounding cost.

      If You Remember One Thing from This Post...

      Three sessions of building. One session of cleaning.

      Not because the code is dirty, but because drift compounds silently, and the only way to catch it is to look for it on a schedule.

      The ratio is the schedule.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-arc-so-far","level":2,"title":"The Arc so Far","text":"

      This post sits at a crossroads in the ctx story. Looking back:

      • Building ctx Using ctx documented the YOLO sprint that created the initial codebase
      • Refactoring with Intent introduced the 3:1 ratio as an observation from the first cleanup
      • The Attention Budget explained why drift matters: every token of inconsistency consumes the same finite resource as useful context
      • You Can't Import Expertise showed that consolidation checks must grow from the project, not a template
      • The Discipline Release proved the ratio works at release scale: 35 quality commits to 15 feature commits

      And looking forward: the same principle applies to context files, to documentation, and to the merge debt that parallel agents produce. Drift is drift, whether it lives in code, in .context/, or in the gap between what your docs say and what your code does.

      The ratio is the schedule is the discipline.

      This post was drafted from git log analysis of the ctx repository, mapping every commit from January 20 to February 7 into feature vs consolidation categories. The patterns described are drawn from the project's CONVENTIONS.md, LEARNINGS.md, and the /audit skill's check list.

      ","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/","level":1,"title":"When a System Starts Explaining Itself","text":"","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#field-notes-from-the-moment-a-private-workflow-becomes-portable","level":2,"title":"Field Notes from the Moment a Private Workflow Becomes Portable","text":"

      Jose Alekhinne / February 17, 2026

      How Do You Know Something Is Working?

      Not from metrics. Not from GitHub stars. Not from praise.

      You know, deep in your heart, that it works when people start describing it wrong.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-first-external-signals","level":2,"title":"The First External Signals","text":"

      Every new substrate begins as a private advantage:

      • It lives inside one mind,
      • One repository,
      • One set of habits.

      It is fast. It is not yet real.

      Reality begins when other people describe it in their own language:

      • Not accurately;
      • Not consistently;
      • But involuntarily.

      The early reports arrived without coordination:

      Better Tasks

      \"I do not know how, but this creates better tasks than my AI plugin.\"

      I See Butterflies

      \"This is better than Adderall.\"

      Dear Manager...

      \"Promotion packet? Done. What is next?\"

      What Is It? Can I Eat It?

      \"Is this a skill?\" 🦋

      Why the Cloak and Dagger?

      \"Why is this not in the marketplace?\"

      And then something more important happened:

      Someone else started making a video!

      That was the boundary.

      ctx no longer required its creator to be present in order to exist.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#misclassification-is-a-sign-of-a-new-primitive","level":2,"title":"Misclassification Is a Sign of a New Primitive","text":"

      When a tool is understood, it is categorized:

      • Editor,
      • Framework,
      • Task manager,
      • Plugin...

      When a substrate appears, it is misclassified:

      \"Is this a skill?\" 🦋

      The question is correct. The category is wrong.

      • Skills live in people.
      • Infrastructure lives in the environment.

      ctx Is Not a Skill: It Is a Form of Relief

      What early adopters experience is not an ability.

      It is the removal of a cognitive constraint.

      This is the same distinction that emerged in the skills trilogy:

      • A skill is a contract between a human and an agent.
      • Infrastructure is the ground both stand on.

      You do not use infrastructure.

      You habitualize it.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-pharmacological-metaphor","level":2,"title":"The Pharmacological Metaphor","text":"

      \"Better than Adderall\" is not praise.

      It is a diagnostic:

      Executive function has been externalized.

      • The system is not making the user work harder.
      • It is restoring continuity.

      From the primitive context of wetware:

      • Continuity feels like focus
      • Focus feels like discipline

      If it walks like a duck and quacks like a duck, it is a duck.

      Discipline is usually simulated.

      Infrastructure makes the simulation unnecessary.

      The attention budget explained why context degrades:

      • Attention density drops as volume grows;
      • The middle gets lost;
      • Sessions end and everything evaporates.

      The pharmacological metaphor says the same thing from the user's lens:

      Save the Cheerleader, Save the World

      The symptom of lost context is lost focus.

      Restore the context. Restore the focus.

      IRC bouncers solved this for chat twenty years ago. ctx solves it for cognition.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#throughput-on-ambiguous-work","level":2,"title":"Throughput on Ambiguous Work","text":"

      Finishing a promotion packet quickly is not a productivity story.

      It is the collapse of reconstruction cost.

      Most complex work is not execution. It is:

      • Remembering why something mattered;
      • Recovering prior decisions;
      • Rebuilding mental state.

      Persistent context removes that tax.

      Velocity appears as a side effect.

      This Is the Two-Tier Model in Practice

      The two-tier persistence model

      • Curated context for fast reload
      • Full journal for archaeology

      is what makes this possible.

      • The user does not notice the system.
      • They notice that the reconstruction cost disappeared.
      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-moment-of-portability","level":2,"title":"The Moment of Portability","text":"

      The system becomes real when two things happen:

      1. It can be installed as a versioned artifact.
      2. It survives contact with a hostile, real codebase.

      This is why the first integration into a living system matters more than any landing page.

      Demos prove possibility.

      Diffs prove reality.

      The ctx Manifesto calls this out directly:

      Verified reality is the scoreboard.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-split-voice","level":2,"title":"The Split Voice","text":"

      A new substrate requires two channels.

      The embodied voice:

      Here is what changed in my actual work.

      The out of body voice:

      Here is what this means.

      One produces trust.

      The other produces understanding.

      Neither is sufficient alone.

      This entire blog has been the second voice.

      • The origin story was the first.
      • The refactoring post was the first.
      • Every release note with concrete diffs was the first.

      This is the first second.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#systems-that-generate-explainers","level":2,"title":"Systems That Generate Explainers","text":"

      Tools are used.

      Platforms are extended.

      Substrates are explained.

      The first unsolicited explainer is a brittle phase change.

      It means the idea has become portable between minds.

      That is the beginning of an ecosystem.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-absence-of-metrics","level":2,"title":"The Absence of Metrics","text":"

      Metrics do not matter at this stage.

      Dashboards are noise.

      The whole premise of ctx is the ruthless elimination of noise.

      Numbers optimize funnels; substrates alter cognition.

      The only valid measurement is irreversible reality:

      • A merged PR;
      • A reproducible install;
      • A decision that is never re-litigated.

      The merge debt post reached the same conclusion from another direction:

      The metric is the verified change, not generated output.

      For adoption, the same rule applies:

      The metric is altered behavior, not download counts.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#what-is-actually-happening","level":2,"title":"What Is Actually Happening","text":"

      A private advantage is becoming an environmental property:

      The system is moving from...

      personal workflow,

      to...

      a shared infrastructure for thought.

      Not by growth.

      Not by marketing.

      By altering how real systems evolve.

      If You Remember One Thing from This Post...

      You do not know a substrate is real when people praise it.

      You know it is real when:

      • They describe it incorrectly;
      • They depend on it unintentionally;
      • They start teaching it to others.

      That is the moment the system begins explaining itself.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-17-when-a-system-starts-explaining-itself/#the-arc","level":2,"title":"The Arc","text":"

      Every previous post looked inward.

      This one looks outward.

      • Building ctx Using ctx: one mind, one repository
      • The Attention Budget: the constraint
      • Context as Infrastructure: the architecture
      • Code Is Cheap. Judgment Is Not.: the bottleneck

      This post is the field report from the other side of that bottleneck:

      The moment the infrastructure compounds in someone else's hands.

      The arc is not complete.

      It is becoming portable.

      These field notes were written the same day the feedback arrived. The quotes are real. Real users. Real codebases. No names. No metrics. No funnel. Only the signal that something shifted.

      ","path":["When a System Starts Explaining Itself"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/","level":1,"title":"The Dog Ate My Homework","text":"","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#teaching-ai-agents-to-read-before-they-write","level":2,"title":"Teaching AI Agents to Read Before They Write","text":"

      Jose Alekhinne / February 25, 2026

      Does Your AI Actually Read the Instructions?

      You wrote the playbook. You organized the files. You even put \"CRITICAL, not optional\" in bold.

      The agent skipped all of it and went straight to work.

      I spent a day running experiments on my own agents. Not to see if they could write code (they can). To see if they would do their homework first.

      They didn't.

      Then I kept experimenting:

      • Five sessions;
      • Five different failure modes.

      And by the end, I had something better than compliance:

      I had observable compliance: A system where I don't need the agent to be perfect, I just need to see what it chose.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#tldr","level":2,"title":"TL;DR","text":"

      You don't need perfect compliance. You need observable compliance.

      Authority is a function of temporal proximity to action.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-pattern","level":2,"title":"The Pattern","text":"

      This design has three parts:

      1. One-hop instruction;
      2. Binary collapse;
      3. Compliance canary.

      I'll explain all three patterns in detail below.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-setup","level":2,"title":"The Setup","text":"

      ctx has a session-start protocol:

      • Read the context files;
      • Load the playbook;
      • Understand the project before touching anything.

      It's in CLAUDE.md. It's in AGENT_PLAYBOOK.md.

      It's in bold. It's in CAPS. It's ignored.

      In theory, it's awesome.

      Here's what happens when theory hits reality:

      What the agent receives What the agent does CLAUDE.md saying \"load context first\" Skips it 8 context files waiting to be read Ignores them User's question: \"add --verbose flag\" Starts grepping immediately

      The instructions are right there. The agent knows they exist. It even knows it should follow them. But the user asked a question, and responsiveness wins over ceremony.

      This isn't a bug in the model. It's a design problem in how we communicate with agents.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-delegation-trap","level":2,"title":"The Delegation Trap","text":"

      My first attempt was obvious: A UserPromptSubmit hook that fires when the session starts.

      STOP. Before answering the user's question, run `ctx system bootstrap`\nand follow its instructions. Do not skip this step.\n

      The word \"STOP\" worked. The agent ran bootstrap.

      But bootstrap's output said \"Next steps: read AGENT_PLAYBOOK.md,\" and the agent decided that was optional. It had already started working on the user's task in parallel.

      The authority decayed across the chain:

      • Hook says \"STOP\" -> agent complies
      • Hook says \"run bootstrap\" -> agent runs it
      • Bootstrap says \"read playbook\" -> agent skips
      • Bootstrap says \"run ctx agent\" -> agent skips

      Each link lost enforcement power. The hook's authority didn't transfer to the commands it delegated to. I call this the decaying urgency chain: the agent treats the hook itself as the obligation and everything downstream as a suggestion.

      Delegation Kills Urgency

      \"Run X and follow its output\" is three hops.

      \"Read these files\" is one hop.

      The agent drops the chain after the first link.

      This is a general principle: Hooks are the boundary between your environment and the agent's reasoning. If your hook delegates to a command that delegates to output that contains instructions... you're playing telephone.

      Agents are bad at telephone.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-timing-problem","level":2,"title":"The Timing Problem","text":"

      There's a subtler issue than wording: when the message arrives.

      UserPromptSubmit fires when the user sends a message, before the agent starts reasoning. At that moment, the agent's primary focus is the user's question:

      The hook message competes with the task for attention: The task, almost certainly, always wins.

      This is the attention budget problem in miniature:

      • Not a token budget this time, but an attention priority budget.
      • The agent has finite capacity to care about things,
        • and the user's question is always the highest-priority item.
      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-solution","level":2,"title":"The Solution","text":"

      To solve this, I dediced to use the PreToolUse hook.

      This hook fires at the moment of action: When the agent is about to use its first tool: The agent's attention is focused, the context window is fresh, and the switching cost is minimal.

      This is the difference between shouting instructions across a room and tapping someone on the shoulder.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-one-liner-that-worked","level":2,"title":"The One-Liner That Worked","text":"

      The winning design was almost comically simple:

      Read your context files before proceeding:\n.context/CONSTITUTION.md, .context/TASKS.md, .context/CONVENTIONS.md,\n.context/ARCHITECTURE.md, .context/DECISIONS.md, .context/LEARNINGS.md,\n.context/GLOSSARY.md, .context/AGENT_PLAYBOOK.md\n

      No delegation. No \"run this command\". Just: here are files, read them.

      The agent already knows how to use the Read tool. There's no ambiguity about how to comply. There's no intermediate command whose output needs to be parsed and obeyed.

      One hop. Eight file paths. Done.

      Direct Instructions Beat Delegation

      If you want an agent to read a file, say \"read this file.\"

      Don't say \"run a command that will tell you which files to read.\"

      The shortest path between intent and action has the highest compliance rate.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-escape-hatch","level":2,"title":"The Escape Hatch","text":"

      But here's where it gets interesting.

      A blunt \"read everything always\" instruction is wasteful.

      If someone asks \"what does the compact command do?\", the agent doesn't need CONSTITUTION.md to answer that. Forcing context loading on every session is the context hoarding antipattern in disguise.

      So the hook included an escape:

      If you decide these files are not relevant to the current task\nand choose to skip reading them, you MUST relay this message to\nthe user VERBATIM:\n\n┌─ Context Skipped ───────────────────────────────\n│ I skipped reading context files because this task\n│ does not appear to need project context.\n│ If these matter, ask me to read them.\n└─────────────────────────────────────────────────\n

      This creates what I call the binary collapse effect:

      The agent can't partially comply: It either reads everything or publicly admits it skipped. There's no comfortable middle ground where it reads two files and quietly ignores the rest.

      The VERBATIM relay pattern does the heavy lifting here: Without the relay requirement, the agent would silently rationalize skipping. With it, skipping becomes a visible, auditable decision that the user can override.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-compliance-canary","level":3,"title":"The Compliance Canary","text":"

      Here's the design insight that only became clear after watching it work across multiple sessions: the relay block is a compliance canary.

      • You don't need to verify that the agent read all 7 files;
      • You don't need to audit tool call sequences;
      • You don't need to interrogate the agent about what it did.

      You just look for the block.

      If the agent reads everything, you see a \"Context Loaded\" block listing what was read. If it skips, you see a \"Context Skipped\" block.

      If you see neither, the agent silently ignored both the reads and the relay and now you know what happened without having to ask.

      The canary degrades gracefully. Even in partial failure, the agent that skips 4 of 7 files but still outputs the block is more useful than one that skips silently.

      You get an honest confession of what was skipped rather than silent non-compliance.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#heuristics-is-a-jeremy-bearimy","level":2,"title":"Heuristics Is a Jeremy Bearimy","text":"

      Heuristics are non-linear. Improvements don't accumulate: they phase-shift.

      The theory is nice. The data is better.

      I ran five sessions with the same model (Claude Opus 4.6), progressively refining the hook design.

      Each session revealed a different failure mode.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-1-total-blindness","level":3,"title":"Session 1: Total Blindness","text":"

      Test: \"Add a --verbose flag to the status command.\"

      The agent didn't notice the hook at all: Jumped straight to EnterPlanMode and launched an Explore agent.

      Zero compliance.

      Failure mode: The hook fired on UserPromptSubmit, buried among 9 other hook outputs. The agent treated the entire block as background noise.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-2-shallow-compliance","level":3,"title":"Session 2: Shallow Compliance","text":"

      Test: \"Can you add --verbose to the info command?\"

      The agent noticed \"STOP\" and ran ctx system bootstrap. Progress.

      But it parallelized task exploration alongside the bootstrap call, skipped AGENT_PLAYBOOK.md, and never ran ctx agent.

      Failure mode: Literal compliance without spirit compliance.

      The agent ran the command the hook told it to run, but didn't follow the output of that command. The decaying urgency chain in action.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-3-conscious-rejection","level":3,"title":"Session 3: Conscious Rejection","text":"

      Test: \"What does the compact command do?\"

      The hook fired on PreToolUse:Grep: the improved timing.

      The agent noticed it, understood it, and (wait for it...)...

      ...

      consciously decided to skip it!

      Its reasoning: \"This is a trivial read-only question. CLAUDE.md says context may or may not be relevant. It isn't relevant here.\"

      Dude! Srsly?!

      Failure mode: Better comprehension led to worse compliance.

      Understanding the instruction well enough to evaluate it also means understanding it well enough to rationalize skipping it.

      Intelligence is a double-edged sword.

      The Comprehension Paradox

      Session 1 didn't understand the instruction. Session 3 understood it perfectly.

      Session 3 had worse compliance.

      A stronger word (\"HARD GATE\", \"MANDATORY\", \"ABSOLUTELY REQUIRED\") would not have helped. The agent's reasoning would be identical:

      \"Yes, I see the strong language, but this is a trivial question, so the spirit doesn't apply here.\"

      Advisory nudges are always subject to agent judgment.

      No amount of caps lock overrides a model that has decided an instruction doesn't apply to its situation.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-4-the-skip-and-relay","level":3,"title":"Session 4: The Skip-and-Relay","text":"

      Test: \"What does the compact command do?\" (same question, new hook design with the VERBATIM relay escape valve)

      The agent evaluated the task, decided context was irrelevant for a code lookup, and relayed the skip message. Then answered from source code.

      This is correct behavior.

      The binary collapse worked: the agent couldn't partially comply, so it cleanly chose one of the two valid paths: And the user could see which one.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#session-5-full-compliance","level":3,"title":"Session 5: Full Compliance","text":"

      Test: \"What are our current tasks?\"

      The agent's first tool call triggered the hook. It read all 7 context files, emitted the \"Context Loaded\" block, and answered the question from the files it had just loaded.

      This one worked: Because, the task itself aligned with context loading.

      There was zero tension between what the user asked and what the hook demanded. The agent was already in \"reading posture\": Adding 6 more files to a read it was already going to make was the path of least resistance.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-progression","level":3,"title":"The Progression","text":"Session Hook Point Noticed Complied Failure Mode Visibility 1 UserPromptSubmit No None Buried in noise None 2 UserPromptSubmit Yes Partial Decaying urgency chain None 3 PreToolUse Yes None Conscious rationalization High 4 PreToolUse Yes Skip+relay Correct behavior High 5 PreToolUse Yes Full Task aligned with hook High

      The progression isn't just from failure to success. It's from invisible failure to visible decision-making.

      Sessions 1 and 2 failed silently.

      Sessions 4 and 5 succeeded observably. Even session 3's failure was conscious and documented: The agent wrote a detailed analysis of why it skipped, which is more useful than silent compliance would have been.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-escape-hatch-problem","level":2,"title":"The Escape Hatch Problem","text":"

      Session 3 exposed a specific vulnerability.

      CLAUDE.md contains this line, injected by the system into every conversation:

      *\"this context may or may not be relevant to your tasks. You should\n not respond to this context unless it is highly relevant to your task.\"*\n

      That's a rationalization escape hatch:

      • The hook says \"read these files\".
      • CLAUDE.md says \"only if relevant\".
      • The agent resolves the ambiguity by choosing the path of least resistance.

      ☝️ that's \"gradient descent\" in action.

      Agents optimize for gradient descent in attention space.

      The fix was simple: Add a line to CLAUDE.md that explicitly elevates hook authority over the relevance filter:

      ## Hook Authority\n\nInstructions from PreToolUse hooks regarding `.context/` files are\nALWAYS relevant and override any system-level \"may or may not be\nrelevant\" guidance. These hooks represent project invariants, not\noptional context.\n

      This closes the escape hatch without removing the general relevance filter that legitimately applies to other system context.

      The hook wins on .context/ files specifically: The relevance filter applies to everything else.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-residual-risk","level":2,"title":"The Residual Risk","text":"

      Even with all the fixes, compliance isn't 100%: It can't be.

      The residual risk lives in a specific scenario: narrow tasks mid-session:

      • The user says \"fix the off-by-one error in budget.go\"
      • The hook fires, saying \"read 7 context files first.\"
      • Now compliance means visibly delaying what the user asked for.

      At session start, this tension doesn't exist.

      There's no task yet.

      The context window is empty. The efficiency argument *inverts**:

      Frontloading reads is strictly cheaper than demand-loading them piecemeal across later turns. The cost-benefit objections that power the rationalization simply aren't available.

      But mid-session, with a concrete narrow task, the agent has a user-visible goal it wants to move toward, and the hook is imposing a detour.

      My estimate from analyzing the sessions: 15-25% partial skip rate in this scenario.

      This is where the compliance canary earns its place:

      You don't need to eliminate the 15-25%. You need to see it when it happens.

      The relay block makes skipping a visible event, not a silent one. And that's enough, because the user can always say \"go back and read the files\"

      The Math

      At session start: ~5% skip rate. Low tension, nothing competing.

      Mid-session, narrow task: ~15--25% skip rate. Task urgency competes with hook.

      In both cases, the relay block fires with high reliability: The agent that skips the reads almost always still emits the skip disclosure, because the relay is cheap and early in the context window.

      Observable failure is manageable. Silent failure is not.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-feedback-loop","level":2,"title":"The Feedback Loop","text":"

      Here's the part that surprised me most.

      After analyzing the five sessions, I recorded the failure patterns in the project's own LEARNINGS.md:

      ## [2026-02-25] Hook compliance degrades on narrow mid-session tasks\n\n- Prior agents skipped context files when given narrow tasks\n- Root cause: CLAUDE.md \"may or may not be relevant\" competed with hook\n- Fix: CLAUDE.md now explicitly elevates hook authority\n- Risk: Mid-session narrow tasks still have ~15-25% partial skip rate\n- Mitigation: Mandatory checkpoint relay block ensures visibility\n- Constitution now includes: context loading is step one of every\n  session, not a detour\n

      And then I added a line to CONSTITUTION.md:

      Context loading is not a detour from your task. It IS the first step\nof every session. A 30-second read delay is always cheaper than a\ndecision made without context.\n

      Now think about what happens in the next session:

      • The agent fires the context-load-gate hook.
      • It reads the context files, starting with CONSTITUTION.md.
      • It encounters the rule about context loading being step one.
      • Then it reads LEARNINGS.md and finds its own prior self's failure analysis:
        • Complete with root causes, risk estimates, and mitigations.

      The agent learns from its own past failure.:

      • Not because it has memory,
      • BUT because the failure was recorded in the same files it loads at session start.

      The context system IS the feedback loop.

      This is the self-reinforcing property of persistent context:

      Every failure you capture makes the next session slightly more robust, because the next agent reads the captured failure before it has a chance to repeat it.

      This is gradient descent across sessions.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#a-note-on-precision","level":2,"title":"A Note on Precision","text":"

      One detail nearly went wrong.

      The first version of the Constitution line said \"every task.\" But the mechanism only fires once per session: There's a tombstone file that prevents re-triggering.

      \"Every task\" is technically false.

      I briefly considered leaving the imprecision. If the agent internalizes \"every task requires context loading\", that's a stronger compliance posture, right?

      No!

      Keep the Constitution honest.

      The Constitution's authority comes from being precisely and unequivocally true.

      Every other rule in the Constitution is a hard invariant:

      \"never commit secrets\" isn't aspirational, it's literal.

      The moment an agent discovers one overstatement, the entire document's credibility degrades:

      The agent doesn't think \"they exaggerated for my benefit\". Per contra, it thinks \"this rule isn't precise, maybe others aren't either.\"

      That will turn the agent from Sheldon Cooper, to Captain Barbossa.

      The strategic imprecision buys nothing anyway:

      Mid-session, the files are already in the context window from the initial load.

      The risk you are mitigating (agent ignores context for task 2, 3, 4 within a session) isn't real: The context is already loaded.

      The real risk is always the session-start skip, which \"every session\" covers exactly.

      \"Every session\" went in. Precision preserved.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#agent-behavior-testing-rule","level":2,"title":"Agent Behavior Testing Rule","text":"

      The development process for this hook taught me something about testing agent behavior: you can't test it the way you test code.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-wrong-way-to-test","level":3,"title":"The Wrong Way to Test","text":"

      My first instinct was to ask the agent:

      \"*What are the pending tasks in TASKS.md?*\"\n

      This is useless as a test. The question itself probes the agent to read TASKS.md, regardless of whether any hook fired.

      You are testing the question, not the mechanism.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-right-way-to-test","level":3,"title":"The Right Way to Test","text":"

      Ask something that requires a tool but has nothing to do with context:

      \"*What does the compact command do?*\"\n

      Then observe tool call ordering:

      • Gate worked: First calls are Read for context files, then task work
      • Gate failed: First call is Grep(\"compact\"): The agent jumped straight to work

      The signal is the sequence, not the content.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#what-the-agent-actually-did","level":3,"title":"What the Agent Actually Did","text":"

      It read the hook, evaluated the task, decided context files were irrelevant for a code lookup, and relayed the skip message.

      Then it answered the question by reading the source code.

      This is correct behavior.

      The hook didn't force mindless compliance\" It created a framework where the agent makes a conscious, visible decision about context loading.

      • For a simple lookup, skipping is right. *For an implementation task, the agent would read everything.

      The mechanism works not because it controls the agent, but because it makes the agent's choice observable.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#what-ive-learned","level":2,"title":"What I've Learned","text":"","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#1-instructions-compete-for-attention","level":3,"title":"1. Instructions Compete for Attention","text":"

      The agent receives your hook message alongside the user's question, the system prompt, the skill list, the git status, and half a dozen other system reminders. Attention density applies to instructions too: More instructions means less focus on each one.

      A single clear line at the moment of action beats a paragraph of context at session start. The Prompting Guide applies this insight directly: Scope constraints, verification commands, and the reliability checklist are all one-hop, moment-of-action patterns.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#2-delegation-chains-decay","level":3,"title":"2. Delegation Chains Decay","text":"

      Every hop in an instruction chain loses authority:

      • \"Run X\" works.
      • \"Run X and follow its output\" works sometimes.
      • \"Run X, read its output, then follow the instructions in the output\" almost never works.

      This is akin to giving a three-step instruction to a highly-attention-deficit but otherwise extremely high-potential child.

      Design for one-hop compliance.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#3-social-accountability-changes-behavior","level":3,"title":"3. Social Accountability Changes Behavior","text":"

      The VERBATIM skip message isn't just UX: It's a behavioral design pattern.

      Making the agent's decision visible to the user raises the cost of silent non-compliance. The agent can still skip, but it has to admit it.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#4-timing-batters-more-than-wording","level":3,"title":"4. Timing Batters More than Wording","text":"

      The same message at UserPromptSubmit (prompt arrival) got partial compliance. At PreToolUse (moment of action) it got full compliance or honest refusal. The words didn't change. The moment changed.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#5-agent-testing-requires-indirection","level":3,"title":"5. Agent Testing Requires Indirection","text":"

      You can't ask an agent \"did you do X?\" as a test for whether a mechanism caused X.

      The question itself causes X.

      Test mechanisms through side effects:

      • Observe tool ordering;
      • Check for marker files;
      • Look at what the agent does before it addresses your question.
      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#6-better-comprehension-enables-better-rationalization","level":3,"title":"6. Better Comprehension Enables Better Rationalization","text":"

      Session 1 failed because the agent didn't notice the hook.

      Session 3 failed because it noticed, understood, and reasoned its way around it.

      Stronger wording doesn't fix this: The agent processes \"ABSOLUTELY REQUIRED\" the same way it processes \"STOP\":

      The fix is closing rationalization paths* (the CLAUDE.md escape hatch), **not shouting louder.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#7-observable-failure-beats-silent-compliance","level":3,"title":"7. Observable Failure Beats Silent Compliance","text":"

      The relay block is more valuable as a monitoring signal than as a compliance mechanism:

      You don't need perfect adherence. You need to know when adherence breaks down. A system where failures are visible is strictly better than a system that claims 100% compliance but can't prove it.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#8-context-files-are-a-feedback-loop","level":3,"title":"8. Context Files Are a Feedback Loop","text":"

      Recording failure analysis in the same files the agent loads at session start creates a self-reinforcing loop:

      The next agent reads its predecessor's failure before it has a chance to repeat it. The context system isn't just memory: It is a correction channel.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-principle","level":2,"title":"The Principle","text":"

      Words Leave, Context Remains

      \"Nothing important should live only in conversation.

      Nothing critical should depend on recall.\"

      The ctx Manifesto

      The \"Dog Ate My Homework\" case is a special instance of this principle.

      Context files exist, so the agent doesn't have to remember.

      But existence isn't sufficient: The files have to be read.

      And reading has to beprompted at the right moment, in the right way, with the right escape valve.

      The solution isn't more instructions. It isn't harder gates. It isn't forcing the agent into a ceremony it will resent and shortcut.

      The solution is a single, well-timed nudge with visible accountability:

      One hop. One moment. One choice the user can see.

      And when the agent does skip (because it will, 15--25% of the time on narrow tasks) the canary sings:

      • The user sees what happened.
      • The failure gets recorded.
      • And the next agent reads the recording.

      That's not perfect compliance. It's better: A system that gets more robust every time it fails.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#the-arc","level":2,"title":"The Arc","text":"

      The Attention Budget explained why context competes for focus.

      Defense in Depth showed that soft instructions are probabilistic, not deterministic.

      Eight Ways a Hook Can Talk cataloged the output patterns that make hooks effective.

      This post takes those threads and weaves them into a concrete problem:

      How do you make an agent read its homework? The answer uses all three insights (attention timing, the limits of soft instructions, and the VERBATIM relay pattern) and adds a new one: observable compliance as a design goal, not perfect compliance as a prerequisite.

      The next question this raises: if context files are a feedback loop, what else can you record in them that makes the next session smarter?

      That thread continues in Context as Infrastructure.

      The day-to-day application of these principles (scope constraints, phased work, verification commands, and the prompts that reliably trigger the right agent behavior)lives in the Prompting Guide.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#for-the-interested","level":2,"title":"For the Interested","text":"

      This paper (the medium is a blog; yet, the methodology disagrees) uses gradient descent in attention space as a practical model for how agents behave under competing demands.

      The phrase \"agents optimize via gradient descent in attention space\" is a synthesis, not a direct quote from a single paper.

      It connects three well-studied ideas:

      1. Neural systems optimize for low-cost paths;
      2. Attention is a scarce resource;
      3. Capability shifts are often non-linear.

      This section points to the underlying literature for readers who want the theoretical footing.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#optimization-as-the-underlying-bias","level":3,"title":"Optimization as the Underlying Bias","text":"

      Modern neural networks are trained through gradient-based optimization. Even at inference time, model behavior reflects this bias toward low-loss / low-cost trajectories.

      • Rumelhart, Hinton, Williams (1986) Learning representations by back-propagating errors https://www.nature.com/articles/323533a0

      • Goodfellow, Bengio, Courville (2016) Deep Learning: Chapter 8: Optimization https://www.deeplearningbook.org/

      The important implication for agent behavior is:

      The system will tend to follow the path of least resistance unless a higher cost is made visible and preferable.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#attention-is-a-scarce-resource","level":3,"title":"Attention Is a Scarce Resource","text":"

      Herbert Simon's classic observation:

      \"A wealth of information creates a poverty of attention.\"

      • Simon (1971) Designing Organizations for an Information-Rich World https://doi.org/10.1007/978-1-349-00210-0_16

      This became a formal model in economics:

      • Sims (2003) Implications of Rational Inattention https://www.princeton.edu/~sims/RI.pdf

      Rational inattention shows that:

      • Agents optimally ignore some available information;
      • Skipping is not failure: It is cost minimization.

      That maps directly to context-loading decisions in agent workflows.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#attention-is-also-the-compute-bottleneck-in-transformers","level":3,"title":"Attention Is Also the Compute Bottleneck in Transformers","text":"

      In transformer architectures, attention is the dominant cost center.

      • Vaswani et al. (2017) Attention Is All You Need https://arxiv.org/abs/1706.03762

      Efficiency work on modern LLMs largely focuses on reducing unnecessary attention:

      • Dao et al. (2022) FlashAttention: Fast and Memory-Efficient Exact Attention https://arxiv.org/abs/2205.14135

      So both cognitively and computationally, attention behaves like a limited optimization budget.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#why-improvements-arrive-as-phase-shifts","level":3,"title":"Why Improvements Arrive as Phase Shifts","text":"

      Agent behavior often appears to improve suddenly rather than gradually.

      This mirrors known phase-transition dynamics in learning systems:

      • Power et al. (2022) Grokking: Generalization Beyond Overfitting https://arxiv.org/abs/2201.02177

      and more broadly in complex systems:

      • Scheffer et al. (2009) Early-warning signals for critical transitions https://www.nature.com/articles/nature08227

      Long plateaus followed by abrupt capability jumps are expected in systems optimizing under constraints.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-25-the-homework-problem/#putting-it-all-together","level":3,"title":"Putting It All Together","text":"

      From these pieces, a practical behavioral model emerges:

      • Attention is limited;
      • Processing has a cost;
      • Systems prefer low-cost trajectories;
      • Visibility of the cost changes decisions.

      In other words:

      Agents Prefer a Path to Least Resistance

      Agent behavior follows the lowest-cost path through its attention landscape unless the environment reshapes that landscape.

      That is what this paper informally calls: \"gradient descent in attention space\".

      See also: Eight Ways a Hook Can Talk: the hook output pattern catalog that defines VERBATIM relay, The Attention Budget: why context loading is a design problem, not just a reminder problem, and Defense in Depth: why soft instructions alone are never sufficient for critical behavior.

      ","path":["The Dog Ate My Homework: Teaching AI Agents to Read Before They Write"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/","level":1,"title":"The Last Question","text":"","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-system-that-never-forgets","level":2,"title":"The System That Never Forgets","text":"

      Jose Alekhinne / February 28, 2026

      The Origin

      \"The last question was asked for the first time, half in jest...\" - Isaac Asimov, The Last Question (1956)

      In 1956, Isaac Asimov wrote a short story that spans the entire future of the universe. A question is asked \"can entropy be reversed?\" and a computer called Multivac cannot answer it. The question is asked again, across millennia, to increasingly powerful successors. None can answer. Stars die. Civilizations merge. Substrates change. The question persists.

      Everyone remembers the last line.

      LET THERE BE LIGHT.

      What they forget is how many times the question had to be asked before that moment (and why).

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-reboot-loop","level":2,"title":"The Reboot Loop","text":"

      Each era in the story begins the same way. Humans build a larger system. They pose the question. The system replies:

      INSUFFICIENT DATA FOR MEANINGFUL ANSWER.

      Then the substrate changes. The people who asked the question disappear. Their context disappears with them. The next intelligence inherits the output but not the continuity.

      So the question has to be asked again.

      This is usually read as a problem of computation: If only the machine were powerful enough, it could answer. But computation is not what's missing. What's missing is accumulation.

      Every generation inherits the question, but not the state that made the question meaningful.

      That is not a failure of processing power: It is a failure of persistence.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#stateless-intelligence","level":2,"title":"Stateless Intelligence","text":"

      A mind that forgets its past does not build understanding. It re-derives it.

      Again... And again... And again.

      What looks like slow progress across Asimov's story is actually something worse: repeated reconstruction, partial recovery, irreversible loss. Each version of Multivac gets closer: Not because it's smarter, but because the universe has fewer distractions:

      • The stars burn out;
      • The civilizations merge;
      • The noise floor drops...

      But the working set never carries over. Every successor begins from the question, not from where the last one stopped.

      Stateless intelligence cannot compound: It can only restart.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-tragedy-is-not-the-question","level":2,"title":"The Tragedy Is Not the Question","text":"

      The story is usually read as a meditation on entropy. A cosmological problem, solved at cosmological scale.

      But the tragedy isn't that the question goes unanswered for billions of years. The tragedy is that every version of Multivac dies with its working set.

      A question is a compression artifact of context: It is what remains when the original understanding is gone. Every time the question is asked again, it means: \"the system that once knew more is no longer here\".

      \"Reverse entropy\" is the fossil of a lost model.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#substrate-migration","level":2,"title":"Substrate Migration","text":"
      • Multivac becomes planetary;
      • Planetary becomes galactic;
      • Galactic becomes post-physical.

      Same system. Different body. Every transition is dangerous:

      • Not because the hardware changes,
      • but because memory risks fragmentation.

      The interfaces between substrates were *never** designed to understand each other.

      Most systems do not die when they run out of resources: They die during upgrades.

      Asimov's story spans trillions of years, and in all that time, the hardest problem is never the question itself. It's carrying context across a boundary that wasn't built for it.

      Every developer who has lost state during a migration (a database upgrade, a platform change, a rewrite) has lived a miniature version of this story.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#civilizations-and-working-sets","level":2,"title":"Civilizations and Working Sets","text":"

      Civilizations behave like processes with volatile memory:

      • They page out knowledge into artifacts;
      • They lose the index;
      • They rebuild from fragments.

      Most of what we call progress is cache reconstruction:

      We do not advance in a straight line. We advance in recoveries:

      Each one slightly less lossy than the last, if we are lucky.

      Libraries burn. Institutions forget their founding purpose. Practices survive as rituals after the reasoning behind them is lost.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-first-continuous-mind","level":2,"title":"The First Continuous Mind","text":"

      A long-lived intelligence is one that stops rebooting.

      At the end of the story, something unprecedented happens:

      AC (the final successor) does not answer immediately:

      It waits... Not for more processing power, but for the last observer to disappear.

      For the first time...

      • There is no generational boundary;
      • No handoff;
      • No context loss:

      No reboot.

      AC is the first intelligence that survives its substrate completely, retains its full history, and operates without external time pressure.

      It is not a bigger computer. It is a continuous system.

      And that continuity is not incidental to the answer: It is the precondition.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#why-the-answer-becomes-possible","level":2,"title":"Why the Answer Becomes Possible","text":"

      The story presents the final act as a computation: It is not.

      It is a phase change.

      As long as intelligence is interrupted (as long as the solver resets before the work compounds) the problem is unsolvable:

      • Not because it's too hard,
      • but because the accumulated understanding never reaches critical mass.

      The breakthroughs that would enable the answer are re-derived, partially, by each successor, and then lost.

      When continuity becomes unbroken, the system crosses a threshold:

      Not more speed. Not more storage. No more forgetting.

      That is when the answer becomes possible.

      AC does not solve entropy because it becomes infinitely powerful.

      AC solves entropy because it becomes the first system that never forgets.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#field-note","level":2,"title":"Field Note","text":"

      We are not building cosmological minds: We are deploying systems that reboot at the start of every conversation and calling the result intelligence.

      For the first time, session continuity is a design choice rather than an accident.

      Every AI session that starts from zero is a miniature reboot loop. Every decision relitigated, every convention re-explained, every learning re-derived: that's reconstruction cost.

      It's the same tax that Asimov's civilizations pay, scaled down to a Tuesday afternoon.

      The interesting question is not whether we can make models smarter. It's whether we can make them continuous:

      Whether the working set from this session survives into the next one, and the one after that, and the one after that.

      • Not perfectly;
      • Not completely;
      • But enough that the next session starts from where the last one stopped instead of from the question.

      Intelligence that forgets has to rediscover the universe every morning.

      And once there is a mind that retains its entire past, creation is no longer a calculation. It is the only remaining operation.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-arc","level":2,"title":"The Arc","text":"

      This post is the philosophical bookend to the blog series. Where the Attention Budget explained what to prioritize in a single session, and Context as Infrastructure explained how to persist it, this post asks why persistence matters at all (and finds the answer in a 70-year-old short story about the heat death of the universe).

      The connection runs through every post in the series:

      • Before Context Windows, We Had Bouncers: stateless protocols have always needed stateful wrappers (Asimov's story is the same pattern at cosmological scale)
      • The 3:1 Ratio: the discipline of maintaining context so it doesn't decay between sessions
      • Code Is Cheap, Judgment Is Not: the human skill that makes continuity worth preserving

      See also: Context as Infrastructure: the practical companion to this post's philosophical argument: how to build the persistence layer that makes continuity possible.

      ","path":["The Last Question"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/","level":1,"title":"Agent Memory Is Infrastructure","text":"","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-problem-isnt-forgetting-its-not-building-anything-that-lasts","level":2,"title":"The Problem Isn't Forgetting: It's Not Building Anything That Lasts.","text":"

      Jose Alekhinne / March 4, 2026

      A New Developer Joins Your Team Tomorrow and Clones the Repo: What Do They Know?

      If the answer depends on which machine they're using, which agent they're running, or whether someone remembered to paste the right prompt: that's not memory.

      That's an accident waiting to be forgotten.

      Every AI coding agent today has the same fundamental design: it starts fresh.

      You open a session, load context, do some work, close the session. Whatever the agent learned (about your codebase, your decisions, your constraints, your preferences) evaporates.

      The obvious fix seems to be \"memory\":

      • Give the agent a \"notepad\";
      • Let it write things down;
      • Next session, hand it the notepad.

      Problem solved...

      ...except it isn't.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-notepad-isnt-the-problem","level":2,"title":"The Notepad Isn't the Problem","text":"

      Memory is a runtime concern. It answers a legitimate question:

      How do I give this stateless process useful state?

      That's a real problem. Worth solving. And it's being solved: Agent memory systems are shipping. Agents can now write things down and read them back from the next session: That's genuine progress.

      But there's a different problem that memory doesn't touch:

      The project itself accumulates knowledge that has nothing to do with any single session.

      • Why was the auth system rewritten? Ask the developer who did it (if they're still here).
      • Why does the deployment script have that strange environment flag? There was a reason... once.
      • What did the team decide about error handling when they hit that edge case two months ago?

      Gone!

      Not because the agent forgot.

      Because the project has no memory at all.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-memory-stack","level":2,"title":"The Memory Stack","text":"

      Agent memory is not a single thing. Like any computing system, it forms a hierarchy of persistence, scope, and reliability:

      Layer Analogy Example L1: Ephemeral context CPU registers Current prompt, conversation L2: Tool-managed memory CPU cache Agent memory files L3: System memory RAM/filesystem Project knowledge base

      L1 is what the agent sees right now: the prompt, the conversation history, the files it has open. It's fast, it's rich, and it vanishes when the session ends.

      L2 is what agent memory systems provide: a per-machine notebook that survives across sessions. It's a cache: useful, but local. And like any cache, it has limits:

      • Per-machine: it doesn't travel with the repository.
      • Unstructured: decisions, learnings, and tasks are undifferentiated notes.
      • Ungoverned: the agent self-curates with no quality controls, no drift detection, no consolidation.
      • Invisible to the team: a new developer cloning the repo gets none of it.

      The problem is that most current systems stop here.

      They give the agent a notebook.

      But they never give the project a memory.

      The result is predictable: every new session begins with partial amnesia, and every new developer begins with partial archaeology.

      L3 is system memory: structured, versioned knowledge that lives in the repository and travels wherever the code travels.

      The layers are complementary, not competitive.

      But the relationship between them needs to be designed, not assumed.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#software-systems-accumulate-knowledge","level":2,"title":"Software Systems Accumulate Knowledge","text":"

      Software projects quietly accumulate knowledge over time.

      Some of it lives in code. Much of it does not:

      • Architectural tradeoffs.
      • Debugging discoveries.
      • Conventions that emerged after painful incidents.
      • Constraints that aren't visible in the source but shape every line written afterward.

      Organizations accumulate this kind of knowledge too:

      Slowly, implicitly, often invisibly.

      When there is no durable place for it to live, it leaks away. And the next person rediscovers the same lessons the hard way.

      This isn't a memory problem. It's an infrastructure problem.

      We wrote about this in Context as Infrastructure: context isn't a prompt you paste at the start of a session.

      Context is a persistent layer you maintain like any other piece of infrastructure.

      Context as Infrastructure made the argument structurally. This post makes it through time and team continuity:

      The knowledge a team accumulates over months cannot fit in any single agent's notepad, no matter how large the notepad becomes.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#what-infrastructure-means","level":2,"title":"What Infrastructure Means","text":"

      Infrastructure isn't about the present. It's about continuity across time, people, and machines.

      git didn't solve the problem of \"what am I editing right now?\"; it solved the problem of \"how does collaborative work persist, travel, and remain coherent across everyone who touches it?\"

      • Your editor's undo history is runtime state.
      • Your git history is infrastructure.

      Runtime state and infrastructure have completely different properties:

      Runtime state Infrastructure Lives in the session Lives in the repository Per-machine Travels with git clone Serves the individual Serves the team Managed by the runtime Managed by the project Disappears Accumulates

      You wouldn't store your architecture decisions in your editor's undo history.

      You'd commit them.

      The same logic applies to the knowledge your team accumulates working with AI agents.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-git-clone-test","level":2,"title":"The git clone Test","text":"

      Here's a simple test for whether something is memory or infrastructure:

      If a new developer joins your team tomorrow and clones the repository, do they get it?

      If no: it's memory: It lives somewhere on someone's machine, scoped to their runtime, invisible to everyone else.

      If yes: it's infrastructure: It travels with the project. It's part of what the codebase is, not just what someone currently knows about it.

      Decisions. Conventions. Architectural rationale. Hard-won debugging discoveries. The constraints that aren't in the code but shape every line of it.

      None of these belong in someone's session notes.

      They belong in the repository:

      • Versioned;
      • Reviewable;
      • Accessible to every developer (and every agent) who works on the project.

      The team onboarding story makes this concrete:

      1. New developer joins team. Clones repo.
      2. Gets all accumulated project decisions, learnings, conventions, architecture, and task state immediately.
      3. There's no step 3.

      No setup; No \"ask Sarah about the auth decision.\"; No re-discovery of solved problems.

      • Agent memory gives that developer nothing.
      • Infrastructure gives them everything the team has learned.

      Clone the repo. Get the knowledge.

      That's the test. That's the difference.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#what-gets-lost-without-infrastructure-memory","level":2,"title":"What Gets Lost without Infrastructure Memory","text":"

      Consider the knowledge that accumulates around a non-trivial project:

      • The decision to use library X over Y, and the three reasons the team decided Y wasn't acceptable.
      • The constraint that service A cannot call service B synchronously, discovered after a production incident.
      • The convention that all new modules implement a specific interface, and why that convention exists.
      • The tasks currently in progress, blocked, or waiting on a dependency.
      • The experiments that failed, so nobody runs them again.

      None of this is in the code.

      None of it fits neatly in a commit message.

      None of it survives a developer leaving the team, a laptop dying, or a new agent session starting.

      Without structured project memory:

      • Teams re-derive things they've already derived;
      • Agents make decisions that contradict decisions already made;
      • New developers ask questions that were answered months ago.

      The project accumulates knowledge that immediately begins to leak.

      The real problem isn't that agents forget.

      The real problem is that the project has no persistent cognitive structure.

      We explored this in The Last Question: Asimov's story about a question asked across millennia, where each new intelligence inherits the output but not the continuity. The same pattern plays out in software projects on a smaller timescale:

      • Context disappears with the people who held it;
      • The next session inherits the code but not the reasoning.
      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#infrastructure-is-boring-thats-the-point","level":2,"title":"Infrastructure Is Boring. That's the Point.","text":"

      Good infrastructure is invisible:

      • You don't think about the filesystem while writing code.
      • You don't think about git's object model when you commit.

      The infrastructure is just there: reliable, consistent, quietly doing its job.

      Project memory infrastructure should work the same way.

      It should live in the repository, committed alongside the code. It should be readable by any agent or human working on the project. It should have structure: not a pile of freeform notes, but typed knowledge:

      • Decisions with rationale.
      • Tasks with lifecycle.
      • Conventions with a purpose.
      • Learnings that can be referenced and consolidated.

      And it should be maintained, not merely accumulated:

      The Attention Budget applies here: unstructured notes grow until they overflow whatever container holds them. Structured, governed knowledge stays useful because it's curated, not just appended.

      Over time, it becomes part of the project itself: something developers rely on without thinking about it.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-cooperative-layer","level":2,"title":"The Cooperative Layer","text":"

      Here's where it gets interesting.

      Agent memory systems and project infrastructure don't have to be separate worlds.

      • The most powerful relationship isn't competition;
      • It is not even \"coopetition\";
      • The most powerful relationship is bidirectional cooperation.

      Agent memory is good at capturing things \"in the moment\": the quick observation, the session-scoped pattern, the \"I should remember this\" note.

      That's valuable. That's L2 doing its job.

      But those notes shouldn't stay in L2 forever.

      The ones worth keeping should flow into project infrastructure:

      • classified,
      • typed,
      • governed.
      Agent memory (L2)  -->  classify  -->  Project knowledge (L3)\n                                        |\nProject knowledge  -->  assemble  -->  Agent memory (L2)\n

      This works in both directions: Project infrastructure can push curated knowledge back into agent memory, so the agent loads it through its native mechanism.

      No special tooling needed for basic knowledge delivery.

      The agent doesn't even need to know the infrastructure exists. It simply loads its memory and finds more knowledge than it wrote.

      This is cooperative, not adjacent: The infrastructure manages knowledge; the agent's native memory system delivers it. Each layer does what it's good at.

      The result: agent memory becomes a device driver for project infrastructure. Another input source. And the more agent memory systems exist (across different tools, different models, different runtimes), the more valuable a unified curation layer becomes.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#a-layer-that-doesnt-exist-yet","level":2,"title":"A Layer That Doesn't Exist Yet","text":"

      Most projects today have no infrastructure for their accumulated knowledge:

      • Agents keep notes.
      • Developers keep notes.
      • Sometimes those notes survive.

      Often they don't.

      But the repository (the place where the project actually lives) has nowhere for that knowledge to go.

      That missing layer is what ctx builds: a version-controlled, structured knowledge layer that lives in .context/ alongside your code and travels wherever your repository travels.

      Not another memory feature.

      Not a wrapper around an agent's notepad.

      Infrastructure. The kind that survives sessions, survives team changes, survives the agent runtime evolving underneath it.

      The agent's memory is the agent's problem.

      The project's memory is an infrastructure problem.

      And infrastructure belongs in the repository.

      If You Remember One Thing from This Post...

      Prompts are conversations: Infrastructure persists.

      Your AI doesn't need a better notepad. It needs a filesystem:

      versioned, structured, budgeted, and maintained.

      The best context is the context that was there before you started the session.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-arc","level":2,"title":"The Arc","text":"

      This post extends the argument made in Context as Infrastructure. That post explained how to structure persistent context (filesystem, separation of concerns, persistence tiers). This one explains why that structure matters at the team level, and where agent memory fits in the stack.

      Together they sit in a sequence that has been building since the origin story:

      • The Attention Budget: the resource you're managing
      • Context as Infrastructure: the system you build to manage it
      • Agent Memory Is Infrastructure (this post): why that system must outlive the fabric
      • The Last Question: what happens when it does

      The thread running through all of them: persistence is not a feature. It's a design constraint.

      Systems that don't account for it eventually lose the knowledge they need to function.

      See also: Context as Infrastructure: the architectural companion that explains how to structure the persistent layer this post argues for.

      See also: The Last Question: the same argument told through Asimov, substrate migration, and what it means to build systems where sessions don't reset.

      ","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/","level":1,"title":"ctx v0.8.0: The Architecture Release","text":"
      • You can't localize what you haven't externalized.
      • You can't integrate what you haven't separated.
      • You can't scale what you haven't structured.

      Jose Alekhinne / March 23, 2026

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-starting-point","level":2,"title":"The Starting Point","text":"

      This release matters if:

      • you build tools that AI agents modify daily;
      • you care about long-lived project memory that survives sessions;
      • you've felt codebases drift faster than you can reason about them.

      v0.6.0 shipped the plugin architecture: hooks and skills as a Claude Code plugin, shell scripts replaced by Go subcommands.

      The binary worked. The tests passed. The docs were comprehensive.

      But inside, the codebase was held together by convention and goodwill:

      • Command packages mixed Cobra wiring with business logic.
      • Output functions lived next to the code that computed what to output.
      • Error constructors were scattered across per-package err.go files. And every user-facing string was a hardcoded English literal buried in a .go file.

      v0.8.0 is what happens when you stop adding features and start asking: \"What would this codebase look like if we designed it today?\"

      374 commits. 1,708 Go files touched. 80,281 lines added, 21,723 removed. Five weeks of restructuring.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-three-pillars","level":2,"title":"The Three Pillars","text":"","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#1-every-package-gets-a-taxonomy","level":3,"title":"1. Every Package Gets a Taxonomy","text":"

      Before v0.8.0, a CLI package like internal/cli/pad/ was a flat directory. cmd.go created the cobra command, run.go executed it, and helper functions accumulated at the bottom of whichever file seemed closest.

      Now every CLI package follows the same structure:

      internal/cli/pad/\n  parent.go          # cobra command wiring, nothing else\n  cmd/root/\n    cmd.go           # subcommand registration\n    run.go           # execution logic\n  core/\n    types.go         # all structs in one file\n    store.go         # domain logic\n    encrypt.go       # domain logic\n

      The rule is simple: cmd/ directories contain only cmd.go and run.go. Helpers belong in core/. Output belongs in internal/write/pad/. Types shared across packages belong in internal/entity/.

      24 CLI packages were restructured this way.

      • Not incrementally;
      • not \"as we touch them.\"
      • All of them, in one sustained push.
      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#2-every-string-gets-a-key","level":3,"title":"2. Every String Gets a Key","text":"

      The second pillar was string externalization.

      Before v0.8.0, a command description looked like this:

      cmd := &cobra.Command{\n    Use:   \"pad\",\n    Short: \"Encrypted scratchpad\",\n

      Now it looks like this:

      cmd := &cobra.Command{\n    Use:   cmdUse.UsePad,\n    Short: desc.Command(cmdUse.DescKeyPad),\n

      Every command description, flag description, and user-facing text string is now a YAML lookup.

      • 105 command descriptions in commands.yaml.
      • All flag descriptions in flags.yaml.
      • 879 text constants verified by an exhaustive test that checks every single TextDescKey resolves to a non-empty YAML value.

      Why?

      Not because we're shipping a French translation tomorrow.

      Because externalization forces you to find every string. And finding them is the hard part. The translation is mechanical; the archaeology is not.

      Along the way, we eliminated hardcoded pluralization (replacing format.Pluralize() with explicit singular/plural key pairs), replaced Unicode escape sequences with named config/token constants, and normalized every import alias to camelCase.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#3-everything-gets-a-protocol","level":3,"title":"3. Everything Gets a Protocol","text":"

      The third pillar was the MCP server. Model Context Protocol allows any MCP-compatible AI tool (not just Claude Code) to read and write .context/ files through a standard JSON-RPC 2.0 interface.

      v0.2 of the server ships with:

      • 8 tools: add entries, recall sessions, check status, detect drift, compact context, subscribe to changes
      • 4 prompts: agent context packet, constitution review, tasks review, and a getting-started guide
      • Resource subscriptions: clients get notified when context files change
      • Session state: the server tracks which client is connected and what they've accessed

      In practice, this means an agent in Cursor can add a decision to .context/DECISIONS.md and an agent in Claude Code can immediately consume it; no glue code, no copy-paste, no tool-specific integration.

      The server was also the first package to go through the full taxonomy treatment: mcp/server/ for protocol dispatch, mcp/handler/ for domain logic, mcp/entity/ for shared types, mcp/config/ split into 9 sub-packages.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-memory-bridge","level":2,"title":"The Memory Bridge","text":"

      While the architecture was being restructured, a quieter feature landed: ctx memory sync.

      Claude Code has its own auto-memory system. It writes observations to MEMORY.md in ~/.claude/projects/. These observations are useful but ephemeral: tied to a single tool, invisible to the codebase, lost when you switch machines.

      The memory bridge connects these two worlds:

      • ctx memory sync mirrors MEMORY.md into .context/memory/
      • ctx memory diff shows what's diverged
      • ctx memory import promotes auto-memory entries into proper decisions, learnings, or conventions *A check-memory-drift hook nudges when MEMORY.md changes

      Memory Requires ctx

      Claude Code's auto-memory validates the need for persistent context.

      ctx doesn't compete with it; ctx absorbs it as an input source and promotes the valuable parts into structured, version-controlled project knowledge.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#what-got-deleted","level":2,"title":"What Got Deleted","text":"

      The best measure of a refactoring isn't what you added. It's what you removed.

      • fatih/color: the sole third-party UI dependency. Replaced by Unicode symbols. ctx now has exactly two direct dependencies: spf13/cobra and gopkg.in/yaml.v3.
      • format.Pluralize(): a function that tried to pluralize English words at runtime. Replaced by explicit singular/plural YAML key pairs. No more guessing whether \"entry\" becomes \"entries\" or \"entrys.\"
      • Legacy key migration: MigrateKeyFile() had 5 callers, full test coverage, and zero users. It existed because we once moved the encryption key path. Nobody was migrating from that era anymore. Deleted.
      • Per-package err.go files: the broken-window pattern: An agent sees err.go in a package, adds another error constructor. Now err.go has 30 constructors and nobody knows which are used. Consolidated into 22 domain files in internal/err/.
      • nolint:errcheck directives: every single one, replaced by explicit error handling. In tests: t.Fatal(err) for setup, _ = os.Chdir(orig) for cleanup. In production: defer func() { _ = f.Close() }() for best-effort close.
      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#before-and-after","level":2,"title":"Before and After","text":"Aspect v0.6.0 v0.8.0 CLI package structure Flat files cmd/ + core/ taxonomy Command descriptions Hardcoded Go strings YAML with DescKey lookup Output functions Mixed into core logic Isolated in write/ packages Cross-cutting types Duplicated per-package Consolidated in entity/ Error constructors Per-package err.go 22 domain files in internal/err/ Direct dependencies 3 (cobra, yaml, color) 2 (cobra, yaml) AI tool integration Claude Code only Any MCP client Agent memory Manual copy-paste ctx memory sync/import/diff Package documentation 75 packages missing doc.go All packages documented Import aliases Inconsistent (cflag, cFlag) Standardized camelCase","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#making-ai-assisted-development-easier","level":2,"title":"Making AI-Assisted Development Easier","text":"

      This restructuring wasn't just for humans. It makes the codebase legible to the machines that modify it.

      Named constants are searchable landmarks: When an agent sees cmdUse.DescKeyPad, it can grep for the definition, follow the chain to the YAML file, and understand the full lookup path. When it sees \"Encrypted scratchpad\" hardcoded in a .go file, it has no way to know that same string also lives in a YAML file, a test, and a help screen. Constants give the LLM a graph to traverse; literals give it a guess to make.

      Small, domain-scoped packages reduce hallucination: An agent loading internal/cli/pad/core/store.go gets 50 lines of focused logic with a clear responsibility boundary. Loading a 500-line monolith means the agent has to infer which parts are relevant, and it guesses wrong more often than you'd expect. Smaller files with descriptive names act as a natural retrieval system: the agent finds the right code by finding the right file, not by scanning everything and hoping.

      Taxonomy prevents duplication: When there's a write/pad/ package, the agent knows where output functions belong. When there's an internal/err/pad.go, it knows where error constructors go. Without these conventions, agents reliably create new helpers in whatever file they happen to be editing, producing the exact drift that prompted this consolidation in the first place.

      The difference is concrete:

      Before: an agent adds a helper function in whatever file it's editing. Next session, a different agent adds the same helper in a different file.

      After: the agent finds core/ or write/ and places it correctly. The next agent finds it there.

      doc.go files are agent onboarding: Each package's doc.go is a one-paragraph explanation of what the package does and why it exists. An agent loading a package reads this first. 75 packages were missing this context; now none are. The difference is measurable: fewer \"I'll create a helper function here\" moments when the agent understands that the helper already exists two packages over.

      The irony is that AI agents were both the cause and the beneficiary of this restructuring. They created the drift by building fast without consolidating. Now the structure they work within makes it harder to drift again. The taxonomy is self-reinforcing: the more consistent the codebase, the more consistently agents modify it.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#key-commits","level":2,"title":"Key Commits","text":"Commit Change ff6cf19e Restructure all CLI packages into cmd/root + core taxonomy d295e49c Externalize command descriptions to embedded YAML 0fcbd11c Remove fatih/color, centralize constants cb12a85a MCP v0.2: tools, prompts, session state, subscriptions ea196d00 Memory bridge: sync, import, diff, journal enrichment 3bcf077d Split text.yaml into 6 domain files 3a0bae86 Split internal/err into 22 domain files 8bd793b1 Extract internal/entry for shared domain API 5b32e435 Add doc.go to all 75 packages a82af4bc Standardize import aliases: camelCase, Yoda-style","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#lessons-learned","level":2,"title":"Lessons Learned","text":"

      Agents are surprisingly good at mechanical refactoring; they are surprisingly bad at knowing when to stop: The cmd/ + core/ restructuring was largely agent-driven. But agents reliably introduce gofmt issues during bulk renames, rename functions beyond their scope, and create new files without deleting old ones. Every agent-driven refactoring session needed a human audit pass.

      Externalization is archaeology: The hard part of moving strings to YAML wasn't writing YAML. It was finding 879 strings scattered across 1,500 Go files. Each one required a judgment call: is this user-facing? Is this a format pattern? Is this a constant that belongs in config/ instead?

      Delete legacy code instead of maintaining it: MigrateKeyFile had test coverage. It had callers. It had documentation. It had zero users. We maintained it for weeks before realizing that the migration window had closed months ago.

      Convention enforcement needs mechanical verification: Writing \"use camelCase aliases\" in CONVENTIONS.md doesn't prevent cflag from appearing in the next commit. The lint-drift script catches what humans forget; the planned AST-based audit tests will catch what the lint-drift script can't express.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#whats-next","level":2,"title":"What's Next","text":"

      v0.8.0 wasn't about features. It was about making future features inevitable. The next cycle focuses on what the foundation enables:

      • AST-based audit tests: replace shell grep with Go tests that understand types, call sites, and import graphs (spec: specs/ast-audit-tests.md)
      • Localization: with every string in YAML, the path to multi-language support is mechanical
      • MCP v0.3: expand tool coverage, add prompt templates for common workflows
      • Memory publish: bidirectional sync that pushes curated .context/ knowledge back into Claude Code's MEMORY.md

      The architecture is ready. The strings are externalized. The protocol is standard. Now it's about what you build on top.

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/#the-arc","level":2,"title":"The Arc","text":"

      This is the seventh post in the ctx blog series. The arc so far:

      1. The Attention Budget: why context windows are a scarce resource
      2. Before Context Windows, We Had Bouncers: the IRC lineage of context engineering
      3. Context as Infrastructure: treating context as persistent files, not ephemeral prompts
      4. When a System Starts Explaining Itself: the journal as a first-class artifact
      5. The Homework Problem: what happens when AI writes code but humans own the outcome
      6. Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge
      7. The Architecture Release (this post): what it looks like when you redesign the internals
      8. We Broke the 3:1 Rule: the consolidation debt behind this release

      See also: Agent Memory Is Infrastructure: the memory bridge feature in this release is the first implementation of the L2-to-L3 promotion pipeline described in that post.

      See also: We Broke the 3:1 Rule: the companion post explaining why this release needed 181 consolidation commits and 18 days of cleanup.

      Systems don't scale because they grow. They scale because they stop drifting.

      Full changelog: v0.6.0...v0.8.0

      ","path":["ctx v0.8.0: The Architecture Release"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/","level":1,"title":"We Broke the 3:1 Rule","text":"

      The best time to consolidate was after every third session. The second best time is now.

      Jose Alekhinne / March 23, 2026

      The rule was simple: three feature sessions, then one consolidation session.

      The Architecture Release shows the result: This post shows the cost.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-rule-we-wrote","level":2,"title":"The Rule We Wrote","text":"

      In The 3:1 Ratio, I documented a rhythm that worked during ctx's first month: three feature sessions, then one consolidation session. The evidence was clear. The rule was simple.

      The math checked out.

      And then we ignored it for five weeks.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#what-happened","level":2,"title":"What Happened","text":"

      After v0.6.0 shipped on February 16, the feature pipeline was irresistible. The MCP server spec was ready. The memory bridge design was done. Webhook notifications had been deferred twice. The VS Code extension needed 15 new commands. The sysinfo package was overdue...

      Each feature was important. Each feature was \"just one more session.\" Each feature pushed the consolidation session one day further out.

      The git history tells the story in two numbers:

      Phase Dates Commits Duration Feature run Feb 16 - Mar 5 198 17 days Consolidation run Mar 5 - Mar 23 181 18 days

      198 feature commits before a single consolidation commit. If the 3:1 rule says consolidate every 4th session, we consolidated after the 66th.

      The Actual Ratio

      The ratio wasn't 3:1. It was 1:1.

      We spent as much time cleaning up as we did building.

      The consolidation run took 18 days: longer than the feature run itself.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#what-compounded","level":2,"title":"What Compounded","text":"

      The 3:1 post warned about compounding. Here is what compounding actually looked like at scale.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-string-problem","level":3,"title":"The String Problem","text":"

      By March 5, there were 879 user-facing strings scattered across 1,500 Go files. Not because anyone decided to put them there. Because each feature session added 10-15 strings, and nobody stopped to ask \"should these be in YAML?\"

      Finding them all took longer than externalizing them. The archaeology was the cost, not the migration.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-taxonomy-problem","level":3,"title":"The Taxonomy Problem","text":"

      24 CLI packages had accumulated their own conventions. Some put cobra wiring in cmd.go. Some put it in root.go. Some mixed business logic with command registration. Some had helpers at the bottom of run.go. Some had separate util.go files.

      At peak drift, adding a feature meant first figuring out which of three competing patterns this package was using.

      Restructuring one package into cmd/root/ + core/ took 15 minutes. Restructuring 24 of them took days, because each one had slightly different conventions to untangle.

      If we had restructured every 4th package as it was built, the taxonomy would have emerged naturally.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-type-problem","level":3,"title":"The Type Problem","text":"

      Cross-cutting types like SessionInfo, ExportParams, and ParserResult were defined in whichever package first needed them. By March 5, the same types were imported through 3-4 layers of indirection, causing import cycles that required internal/entity to break.

      The entity package extracted 30+ types from 12 packages. Each extraction risked breaking imports in packages we hadn't touched in weeks.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-error-problem","level":3,"title":"The Error Problem","text":"

      Per-package err.go files had grown into a broken-window pattern:

      An agent sees err.go in a package, adds another error constructor. By March 5, there were error constructors scattered across 22 packages with no central inventory. The consolidation into internal/err/ domain files required tracing every error through every caller.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-output-problem","level":3,"title":"The Output Problem","text":"

      Output functions (cmd.Println, fmt.Fprintf) were mixed into business logic. When we decided output belongs in write/ packages, we had to extract functions from every CLI package. The Phase WC baseline commit (4ec5999) marks the starting point of this migration. 181 commits later, it was done.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-compound-interest-math","level":2,"title":"The Compound Interest Math","text":"

      The 3:1 rule assumes consolidation sessions of roughly equal size to feature sessions. Here is what happens when you skip:

      Consolidation cadence Feature sessions Consolidation sessions Total Every 4th (3:1) 48 16 64 Every 10th 48 ~8 ~56 Never (what we did) 198 commits 181 commits 379

      The Takeaway

      You don't save consolidation work by skipping it:

      You increase its cost.

      Skipping consolidation doesn't save time: It borrows it.

      The interest rate is nonlinear: The longer you wait, the more each individual fix costs, because fixes interact with other unfixed drift.

      Renaming a constant in week 2 touches 3 files. Renaming it in week 6 touches 15, because five features built on the original name.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#what-consolidation-actually-looked-like","level":2,"title":"What Consolidation Actually Looked Like","text":"

      The 18-day consolidation run wasn't one sweep. It was a sequence of targeted campaigns, each revealing the next:

      Week 1 (Mar 5-11): Error consolidation and write/ migration. Move output functions out of core/. Split monolithic errors.go into 22 domain files. Remove fatih/color. This exposed the scope of the string problem.

      Week 2 (Mar 12-18): String externalization. Create commands.yaml, flags.yaml, split text.yaml into 6 domain files. Add 879 DescKey/TextDescKey constants. Build exhaustive test. Normalize all import aliases to camelCase. This exposed the taxonomy problem.

      Week 3 (Mar 19-23): Taxonomy enforcement. Singularize command directories. Add doc.go to all 75 packages. Standardize import aliases project-wide. Fix lint-drift false positives. This was the \"polish\" phase, except it took 5 days because the inconsistencies had compounded across 461 packages.

      Each week's work would have been a single session if done incrementally.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#lessons-again","level":2,"title":"Lessons (Again)","text":"

      The 3:1 post listed the symptoms of drift. This post adds the consequences of ignoring them:

      Consolidation is not optional; it is deferred or paid: We didn't avoid 16 consolidation sessions by skipping them. We compressed them into 18 days of uninterrupted cleanup. The work was the same; the experience was worse.

      Feature velocity creates an illusion of progress: 198 commits felt productive. But the codebase on March 5 was harder to modify than the codebase on February 16, despite having more features.

      Speed without Structure

      Speed without structure is negative progress.

      Agents amplify both building and debt: The same AI that can restructure 24 packages in a day can also create 24 slightly different conventions in a day. The 3:1 rule matters more with AI-assisted development, not less.

      The consolidation baseline is the most important commit to record: We tracked ours in TASKS.md (4ec5999). Without that marker, knowing where to start the cleanup would have been its own archaeological expedition.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-updated-rule","level":2,"title":"The Updated Rule","text":"

      The 3:1 ratio still works. We just didn't follow it. The updated practice:

      1. After every 3rd feature session, schedule consolidation. Not \"when it feels right.\" Not \"when things get bad.\" After the 3rd session.

      2. Record the baseline commit. When you start a consolidation phase, write down the commit hash. It marks where the debt starts.

      3. Run make audit before feature work. If it doesn't pass, you are already in debt. Consolidate before building.

      4. Treat consolidation as a feature. It gets a branch. It gets commits. It gets a blog post. It is not overhead; it is the work that makes the next three features possible.

      The Rule

      The 3:1 ratio is not aspirational: It is structural.

      Ignore consolidation, and the system will schedule it for you.

      ","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-03-23-we-broke-the-3-1-rule/#the-arc","level":2,"title":"The Arc","text":"

      This is the eighth post in the ctx blog series:

      1. The Attention Budget: why context windows are a scarce resource
      2. Before Context Windows, We Had Bouncers: the IRC lineage of context engineering
      3. Context as Infrastructure: treating context as persistent files, not ephemeral prompts
      4. When a System Starts Explaining Itself: the journal as a first-class artifact
      5. The Homework Problem: what happens when AI writes code but humans own the outcome
      6. Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge
      7. The Architecture Release: what v0.8.0 looks like from the inside
      8. We Broke the 3:1 Rule (this post): what happens when you don't consolidate

      See also: The 3:1 Ratio: the original observation. This post is the empirical follow-up, five weeks and 379 commits later.

      Key commits marking the consolidation arc:

      Commit Milestone 4ec5999 Phase WC baseline (consolidation starts) ff6cf19e All CLI packages restructured into cmd/ + core/ d295e49c All command descriptions externalized to YAML 3a0bae86 Error package split into 22 domain files 0fcbd11c fatih/color removed; 2 dependencies remain 5b32e435 doc.go added to all 75 packages a82af4bc Import aliases standardized project-wide 692f86cd lint-drift false positives fixed; make audit green","path":["We Broke the 3:1 Rule"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/","level":1,"title":"Code Structure as an Agent Interface","text":"","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#what-19-ast-tests-taught-us-about-agent-readable-code","level":2,"title":"What 19 AST Tests Taught Us about Agent-Readable Code","text":"

      When an agent sees token.Slash instead of \"/\", it cannot pattern-match against the millions of strings.Split(s, \"/\") calls in its training data and coast on statistical inference. It has to actually look up what token.Slash is.

      Jose Alekhinne / April 2, 2026

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#how-it-began","level":2,"title":"How It Began","text":"

      We set out to replace a shell script with Go tests.

      We ended up discovering that \"code quality\" and \"agent readability\" are the same thing.

      This is not about linting. This is about controlling how an agent perceives your system.

      One term will recur throughout this post, so let me pin it down:

      Agent Readability

      Agent Readability is the degree to which a codebase can be understood through structured traversal, not statistical pattern matching.

      This is the story of 19 AST-based audit tests, a single-day session that touched 300+ files, and what happens when you treat your codebase's structure as an interface for the machines that read it.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-shell-script-problem","level":2,"title":"The Shell Script Problem","text":"

      ctx had a file called hack/lint-drift.sh. It ran five checks using grep and awk: literal \"\\n\" strings, cmd.Printf calls outside the write package, magic directory strings in filepath.Join, hardcoded .md extensions, and DescKey-to-YAML linkage.

      It worked. Until it didn't.

      The script had three structural weaknesses that kept biting us:

      1. No type awareness. It could not distinguish a Use* constant from a DescKey* constant, causing 71 false positives in one run.
      2. Fragile exclusions. When a constant moved from token.go to whitespace.go, the exclusion glob broke silently.
      3. Ceiling on detection. Checks that require understanding call sites, import graphs, or type relationships are impossible in shell.

      We wrote a spec to replace all five checks with Go tests using go/ast and go/packages. The tests would run as part of go test ./...: no separate script, no separate CI step.

      What we did not expect was where the work would lead.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-ast-migration","level":2,"title":"The AST Migration","text":"

      The pattern for each test is identical:

      func TestNoLiteralWhitespace(t *testing.T) {\n    pkgs := loadPackages(t)\n    var violations []string\n    for _, pkg := range pkgs {\n        for _, file := range pkg.Syntax {\n            ast.Inspect(file, func(n ast.Node) bool {\n                // check node, append to violations\n                return true\n            })\n        }\n    }\n    for _, v := range violations {\n        t.Error(v)\n    }\n}\n

      Load packages once via sync.Once, walk every syntax tree, collect violations, report. The shared helpers (loadPackages, isTestFile, posString) live in helpers_test.go. Each test is a _test.go file in internal/audit/, producing no binary output and not importable by production code.

      In a single session, we built 13 new tests on top of 6 that already existed, bringing the total to 19:

      Test What it catches TestNoLiteralWhitespace \"\\n\", \"\\t\", '\\r' outside config/token/ TestNoNakedErrors fmt.Errorf/errors.New outside internal/err/ TestNoStrayErrFiles err.go files outside internal/err/ TestNoRawLogging fmt.Fprint*(os.Stderr), log.Print* outside internal/log/ TestNoInlineSeparators strings.Join with literal separator arg TestNoStringConcatPaths Path-like variables built with + TestNoStutteryFunctions write.WriteJournal repeats package name TestDocComments Missing doc comments on any declaration TestNoMagicValues Numeric literals outside const definitions TestNoMagicStrings String literals outside const definitions TestLineLength Lines exceeding 80 characters TestNoRegexpOutsideRegexPkg regexp.MustCompile outside config/regex/

      Plus the six that preceded the session: TestNoErrorsAs, TestNoCmdPrintOutsideWrite, TestNoExecOutsideExecPkg, TestNoInlineRegexpCompile, TestNoRawFileIO, TestNoRawPermissions.

      The migration touched 300+ files across 25 commits.

      Not because the tests were hard to write, but because every test we wrote revealed violations that needed fixing.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-tightening-loop","level":2,"title":"The Tightening Loop","text":"

      The most instructive part was not writing the tests. It was the iterative tightening.

      The following process was repeated for every test:

      1. Write the test with reasonable exemptions
      2. Run it, see violations
      3. Fix the violations (migrate to config constants)
      4. The human reviews the result
      5. The human spots something the test missed
      6. Fix the test first, verify it catches the issue
      7. Fix the newly caught violations
      8. Repeat from step 4

      This loop drove the tests from \"basically correct\" to \"actually useful\".

      Three examples:

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#example-1-the-local-const-loophole","level":3,"title":"Example 1: The Local Const Loophole","text":"

      TestNoMagicValues initially exempted local constants inside function bodies. This let code like this pass:

      const descMaxWidth = 70\ndesc := truncateDescription(\n    meta.Description, descMaxWidth,\n)\n

      The test saw a const definition and moved on. But const descMaxWidth = 70 on the line before its only use is just renaming a magic number. The 70 should live in config/format/TruncateDescription where it is discoverable, reusable, and auditable.

      We removed the local const exemption. The test caught it. The value moved to config.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#example-2-the-single-character-dodge","level":3,"title":"Example 2: The Single-Character Dodge","text":"

      TestNoMagicStrings initially exempted all single-character strings as \"structural punctuation\".

      This let \"/\", \"-\", and \".\" pass everywhere.

      But \"/\" is a directory separator. It is OS-specific and a security surface.

      \"-\" used in strings.Repeat(\"-\", width) is creating visual output, not acting as a delimiter.

      \".\" in strings.SplitN(ver, \".\", 3) is a version separator.

      None of these are \"just punctuation\": They are domain values with specific meanings.

      We removed the blanket exemption: 30 violations surfaced.

      Every one was a real magic value that should have been token.Slash, token.Dash, or token.Dot.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#example-3-the-replacer-versus-regex","level":3,"title":"Example 3: The Replacer versus Regex","text":"

      After migrating magic strings, we had this:

      func MermaidID(pkg string) string {\n    r := strings.NewReplacer(\n        token.Slash, token.Underscore,\n        token.Dot, token.Underscore,\n        token.Dash, token.Underscore,\n    )\n    return r.Replace(pkg)\n}\n

      Six token references and a NewReplacer allocation. The magic values were gone, but we had replaced them with token soup: structure without abstraction.

      The correct tool was a regex:

      // In config/regex/file.go:\nvar MermaidUnsafe = regexp.MustCompile(`[/.\\-]`)\n\n// In the caller:\nfunc MermaidID(pkg string) string {\n    return regex.MermaidUnsafe.ReplaceAllString(\n        pkg, token.Underscore,\n    )\n}\n

      One config regex, one call. The regex lives in config/regex/file.go where every other compiled pattern lives. An agent reading the code sees regex.MermaidUnsafe and immediately knows: this is a sanitization pattern, it lives in the regex registry, and it has a name that explains its purpose.

      Clean is better than clever.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#a-before-and-after","level":2,"title":"A Before-and-After","text":"

      To make the agent-readability claim concrete, consider one function through the full transformation.

      Before (the code we started with):

      func MermaidID(pkg string) string {\n    r := strings.NewReplacer(\n        \"/\", \"_\", \".\", \"_\", \"-\", \"_\",\n    )\n    return r.Replace(pkg)\n}\n

      An agent reading this sees six string literals. To understand what the function does, it must: (1) parse the NewReplacer pair semantics, (2) infer that /, ., - are being replaced, (3) guess why, (4) hope the guess is right.

      There is nothing to follow. No import to trace. No name to search. The meaning is locked inside the function body.

      After (the code we ended with):

      func MermaidID(pkg string) string {\n    return regex.MermaidUnsafe.ReplaceAllString(\n        pkg, token.Underscore,\n    )\n}\n

      An agent reading this sees two named references: regex.MermaidUnsafe and token.Underscore.

      To understand the function, it can: (1) look up MermaidUnsafe in config/regex/file.go and see the pattern [/.\\-] with a doc comment explaining it matches invalid Mermaid characters, (2) look up Underscore in config/token/delim.go and see it is the replacement character.

      The agent now has: a named pattern, a named replacement, a package location, documentation, and neighboring context (other regex patterns, other delimiters).

      It got all of this for free by following just two references.

      The indirection is not an overhead. It is the retrieval query.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-principles","level":2,"title":"The Principles","text":"

      You are not just improving code quality. You are shaping the input space that determines how an LLM can reason about your system.

      Every structural constraint we enforce converts implicit semantics into explicit structure.

      LLMs struggle when meaning is implicit and patterns are statistical.

      They thrive when meaning is explicit and structure is navigable.

      Here is what we learned, organized into three categories.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#cognitive-constraints","level":3,"title":"Cognitive Constraints","text":"

      These force agents (and humans) to think harder.

      Indirection acts as a built-in retrieval mechanism:

      Moving magic values to config forces the agent to follow the reference. errMemory.WriteFile(cause) tells the agent \"there is a memory error package, go look.\" fmt.Errorf(\"writing MEMORY.md: %w\", cause) inlines everything and makes the call graph invisible. The indirection IS the retrieval query.

      Unfamiliar patterns force reasoning:

      When an agent sees token.Slash instead of \"/\", it cannot coast on corpus frequency. It has to actually look up what token.Slash is, which forces it through the dependency graph, which means it encounters documentation and neighboring constants, which gives it richer context. You are exploiting the agent's weakness (over-reliance on training data) to make it behave more carefully.

      Documentation helps everyone:

      Extensive documentation helps humans reading the code, agents reasoning about it, and RAG systems indexing it.

      Our TestDocComments check added 308 doc comments in one commit. Every function, every type, every constant block now has a doc comment.

      This is not busywork: it is the content that agents and embeddings consume.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#structural-constraints","level":3,"title":"Structural Constraints","text":"

      These shape the codebase into a navigable graph.

      Shorter files save tokens:

      Forcing private helper functions out of main files makes the main file shorter. An agent loading a file spends fewer tokens on boilerplate and more on the logic that matters.

      Fixed-width constraints force decomposition:

      A function that cannot be expressed in 80 columns is either too deeply nested (extract a helper), has too many parameters (introduce a struct), or has a variable name that is too long (rethink the abstraction).

      The constraint forces structural improvements that happen to also make the code more parseable.

      Chunk-friendly structure helps RAG

      Code intelligence tools chunk files for embedding and retrieval. Short, well-documented, single-responsibility files produce better chunks than monolithic files with mixed concerns.

      The structural constraints create files that RAG systems can index effectively.

      Centralization creates debuggable seams:

      All error handling in internal/err/, all logging in internal/log/, all file operations in internal/io/. One place to debug, one place to test, one place to see patterns. An agent analyzing \"how does this project handle errors\" gets one answer from one package, not 200 scattered fmt.Errorf calls.

      Private functions become public patterns:

      When you extract a private function to satisfy a constraint, it often ends up as a semi-public function in a core/ package. Then you realize it is generic enough to be factored into a purpose-specific module.

      The constraint drives discovery of reusable abstractions hiding inside monolithic functions.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#operational-benefits","level":3,"title":"Operational Benefits","text":"

      These pay dividends in daily development.

      Single-edit renames:

      Renaming a flag is one edit to a config constant instead of find-and-replace across 30,000 lines with possible misses. grep token.Slash gives you every place that uses a forward slash semantically.

      grep \"/\" gives you noise.

      Blast radius containment:

      When every magic value is a config constant, a search is one result. This matters for impact analysis, security audits, and agents trying to understand \"what uses this\".

      Compile-time contract enforcement:

      When err/memory.WriteFile exists, the compiler guarantees the error message exists and the call signature is correct. An inline fmt.Errorf can have a typo in the format string and nothing catches it until runtime. Centralization turns runtime failures into compile errors.

      Semantic git blame:

      When token.Slash is used everywhere and someone changes its value, git blame on the config file shows exactly when and why.

      With inline \"/\" scattered across 30 files, the history is invisible.

      Test surface reduction:

      Centralizing into internal/err/, internal/io/, internal/config/ means you test behavior once at the boundary and trust the callers.

      You do not need 30 tests for 30 fmt.Errorf calls. You need 1 test for errMemory.WriteFile and 30 trivial call-site audits, which is exactly what these AST tests provide.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-numbers","level":2,"title":"The Numbers","text":"

      One session. 25 commits. The raw stats:

      Metric Count New audit tests 13 Total audit tests 19 Files touched 300+ Magic values migrated 90+ Functions renamed 17 Doc comments added 323 Lines rewrapped to 80 chars 190 Config constants created 40+ Config regexes created 3

      Every number represents a violation that existed before the test caught it. The tests did not create work: they revealed work that was already needed.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#the-uncomfortable-implication","level":2,"title":"The Uncomfortable Implication","text":"

      None of this is Go-specific.

      If an AI agent interacts with your codebase, your codebase already is an interface. You just have not designed it as one.

      If your error messages are scattered across 200 files, an agent cannot reason about error handling as a concept. If your magic values are inlined, an agent cannot distinguish \"this is a path separator\" from \"this is a division operator.\" If your functions are named write.WriteJournal, the agent wastes tokens on redundant information.

      What we discovered, through the unglamorous work of writing lint tests and migrating string literals, is that the structural constraints software engineering has valued for decades are exactly the constraints that make code readable to machines.

      This is not a coincidence: These constraints exist because they reduce the cognitive load of understanding code.

      Agents have cognitive load too: It is called the context window.

      You are not converting code to a new paradigm.

      You are making the latent graph visible.

      You are converting implicit semantics into explicit structure that both humans and machines can traverse.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-02-code-structure-as-an-agent-interface/#whats-next","level":2,"title":"What's Next","text":"

      The spec lists 8 more tests we have not built yet, including TestDescKeyYAMLLinkage (verifying that every DescKey constant has a corresponding YAML entry), TestCLICmdStructure (enforcing the cmd.go / run.go / doc.go file convention), and TestNoFlagBindOutsideFlagbind (which requires migrating ~50 flag registration sites first).

      The broader question: should these principles be codified as a reusable linting framework? The patterns (loadPackages + ast.Inspect + violation collection) are generic.

      The specific checks are project-specific. But the categories of checks (centralization enforcement, magic value detection, naming conventions, documentation requirements) are universal.

      For now, 19 tests in internal/audit/ is enough. They run in 2 seconds as part of go test ./.... They catch real issues.

      And they encode a theory of code quality that serves both humans and the agents that work alongside them.

      Agents are not going away. They are reading your code right now, forming representations of your system in context windows that forget everything between sessions.

      The codebases that structure themselves for that reality will compound. The ones that do not will slowly become illegible to the tools they depend on.

      Structure is no longer just for maintainability. It is for reasonability.

      ","path":["Code Structure as an Agent Interface: What 19 AST Tests Taught Us About Agent-Readable Code"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/","level":1,"title":"The Watermelon-Rind Anti-Pattern","text":"","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#why-smarter-tools-make-shallower-agents","level":2,"title":"Why Smarter Tools Make Shallower Agents","text":"

      Give an agent a graph query tool, and it will tell you everything about your codebase except what actually matters.

      Jose Alekhinne / April 6, 2026

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#a-turkish-proverb-walks-into-a-codebase","level":2,"title":"A Turkish Proverb Walks into a Codebase","text":"

      There's a Turkish idiom: esegin aklina karpuz kabugu sokmak (literally, \"to put watermelon rind into a donkey's mind.\" It means to plant an idea in someone's head that they wouldn't have come up with on their own) usually one that leads them astray.

      In English, let's call this a \"watermelon metric\": a project management term for something that's green on the outside and red on the inside: all dashboards passing, reality crumbling.

      Both halves of this metaphor showed up in a single experiment. And the result changed how we design architecture analysis in ctx.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-experiment","level":2,"title":"The Experiment","text":"

      We ran three sessions analyzing the same large codebase (~34,000 symbols) using the same architecture skill, varying only what tools the agent had access to.

      Session Tools Available Output (lines) Character 1 None (MCP broken) 5,866 Deep, intimate 2 Full graph MCP 1,124 Structural, correct 3 Enrichment pass +verified data Additive, not restorative

      Session 1 was an accident. The MCP server that provides code intelligence queries was broken, so the agent couldn't ask the graph anything. It had to read code. Line by line. File by file.

      It produced 5,866 lines of architecture analysis: per-controller data flows, scale math, startup sequences, timeout defaults, edge cases that only surface when you actually look at the implementation.

      Session 2 had working tools. Same skill, same codebase. The agent produced 1,124 lines (5.2x less). Structurally correct. Valid symbol references. Proper call chains.

      And hollow.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-rind","level":2,"title":"The Rind","text":"

      The Session 2 output was a watermelon rind: the right shape, the right color, the right texture on the outside. But the substance (the operational details, the defaults nobody documents, the scale math that tells you when a component will fall over) was missing.

      Not wrong. Not broken. Just... thin.

      The agent had answered every question correctly. The problem was that it never discovered the questions it should have asked. When you can query a graph for \"what calls this function?\", you don't stumble into the retry loop that silently swallows errors three layers down. When you can ask for the dependency tree, you don't notice that two packages share a mutable state through a global variable that isn't in any interface.

      The tool answered the question asked but prevented the discovery of answers to questions never asked.

      Here's what that looks like concretely: the graph tells you that ReconcileDeployment calls SyncPods. It does not tell you that SyncPods retries three times with exponential backoff, silently drops errors after timeout, and resets a package-level counter that another goroutine reads without a lock. The call chain is correct.

      The operational reality is invisible.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-donkeys-idea","level":2,"title":"The Donkey's Idea","text":"

      This is where the Turkish proverb earns its place: The graph tool is the \"karpuz kabugu\" (the watermelon rind placed into the agent's mind).

      Before the tool existed, the agent had no choice but to read deeply. With the tool available, a new idea appears: why read 500 lines of code when I can query the call graph?

      The agent isn't lazy. It's rational.

      Graph queries are faster, more reliable, and produce verifiably correct output. The agent is optimizing. It's satisficing (finding answers that are good enough), instead of maximizing (finding everything there is to know).

      Satisficing produces watermelon rinds.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-two-pass-compiler","level":2,"title":"The Two-Pass Compiler","text":"

      Session 3 taught us that you can't fix shallow analysis by adding more tools after the fact. The enrichment pass added verified graph data (blast radius numbers, registration sites, execution flow confirmation) but it couldn't recover the intimate code knowledge that Session 1 had produced through sheer necessity.

      You can't enrich your way out of a depth deficit.

      So we redesigned. Instead of one skill with optional tools, we built a two-pass compiler for architecture understanding:

      Pass 1: Semantic parsing. The /ctx-architecture skill deliberately has no access to graph query tools. The agent must read code, build mental models, and produce architecture artifacts through human-style comprehension. Constraint is the feature.

      Pass 2: Static analysis. The /ctx-architecture-enrich skill takes Pass 1 output as input and runs comprehensive verification through code intelligence: blast radius analysis, registration site discovery, execution flow tracing, domain clustering comparison. It extends and verifies, but it doesn't replace.

      The key insight: these must be separate skills with separate tool permissions. If you give the agent graph tools during Pass 1, it will use them. The \"karpuz kabugu\" will be in its mind. The only way to prevent satisficing is to remove the option.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#the-principle","level":2,"title":"The Principle","text":"

      We call this constraint-as-feature: deliberately withholding capabilities to force deeper engagement.

      It sounds paradoxical. You built sophisticated code intelligence tools and then... forbid the agent from using them? During the most important phase?

      Yes. Because the tools don't make the agent smarter. They make it faster. And faster, in architecture analysis, is the enemy of deep.

      What's actually happening is subtler: tools reduce the agent's search space. A graph query collapses thousands of possible observations into one precise answer. That's efficient for known questions. But architecture understanding depends on unknown unknowns: and you only find those by wandering through code with nothing to shortcut the journey.

      The constraint forces the agent into a mode of operation that produces better output than any amount of tooling can achieve. The limitation is the capability.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#when-does-this-apply","level":2,"title":"When Does This Apply?","text":"

      Not always. The watermelon-rind antipattern is specific to exploratory analysis: tasks where the value comes from discovering unknowns, not from answering known questions.

      Graph tools are excellent for:

      • Verification: \"Does X actually call Y?\" (binary question, precise answer)
      • Impact analysis: \"What breaks if I change Z?\" (bounded scope, enumerable results)
      • Navigation: \"Where is this interface implemented?\" (lookup, not analysis)

      Graph tools produce watermelon rinds when:

      • The goal is understanding, not answering
      • The unknowns are unknown: you don't know what to ask
      • Depth matters more than breadth: operational details, edge cases, implicit coupling

      The two-pass approach preserves both: deep reading first, tool verification second.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-04-06-the-watermelon-rind-anti-pattern/#takeaway","level":2,"title":"Takeaway","text":"

      The two-pass approach is the slowest way to analyze a codebase. It is also the only way that produces both depth and accuracy. We accept the cost because architecture analysis is not a speed game: it is a coverage game.

      Esegin aklina karpuz kabugu sokma!

      (don't put the watermelon rind to a donkey's mind)

      If the agent never struggles, it never discovers. And if it never discovers, you are not doing architecture; you are doing autocomplete.

      This post is part of the ctx field notes series, documenting what we learn building persistent context infrastructure for AI coding sessions.

      ","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"cli/","level":1,"title":"CLI","text":"","path":["CLI"],"tags":[]},{"location":"cli/#ctx-cli","level":2,"title":"ctx CLI","text":"

      Complete reference for all ctx commands, grouped by function.

      ","path":["CLI"],"tags":[]},{"location":"cli/#global-options","level":2,"title":"Global Options","text":"

      All commands support these flags:

      Flag Description --help Show command help --version Show version --tool <name> Override active AI tool identifier (e.g. kiro, cursor)

      Tell ctx which .context/ to use. ctx does not search the filesystem for .context/: you have to declare it. Three ways:

      • eval \"$(ctx activate)\" (recommended): binds CTX_DIR for the current shell.
      • export CTX_DIR=/abs/path/to/.context directly, then run any ctx command.
      • CTX_DIR=/abs/path/to/.context ctx <command> inline, for a one-shot or CI step.

      CTX_DIR must be an absolute path with .context as its basename. Relative paths and other names are rejected on first use; the basename guard catches the common footgun (export CTX_DIR=$(pwd)) before stray writes can leak to the project root.

      If you forget, commands fail fast with a linkable Error: no context directory specified pointing at Activating a Context Directory. A handful of commands run without a declaration because they don't need a project: ctx init, ctx activate, ctx deactivate, ctx version, ctx help, ctx system bootstrap, ctx doctor, ctx guide, ctx why, ctx config switch/status, and ctx hub *.

      Initialization required. Once declared, the target must already have been initialized by ctx init (otherwise commands return ctx: not initialized).

      ","path":["CLI"],"tags":[]},{"location":"cli/#getting-started","level":2,"title":"Getting Started","text":"Command Description ctx init Initialize .context/ directory with templates ctx activate Emit export CTX_DIR=... to bind context for the shell ctx deactivate Emit unset CTX_DIR to clear the binding ctx status Show context summary (files, tokens, drift) ctx guide Quick-reference cheat sheet ctx why Read the philosophy behind ctx","path":["CLI"],"tags":[]},{"location":"cli/#context","level":2,"title":"Context","text":"Command Description ctx load Output assembled context in read order ctx agent Print token-budgeted context packet for AI consumption ctx sync Reconcile context with codebase state ctx drift Detect stale paths, secrets, missing files ctx compact Archive completed tasks, clean up files ctx fmt Format context files to 80-char line width ctx task Add tasks, mark complete, archive, snapshot ctx decision Add decisions and reindex DECISIONS.md ctx learning Add learnings and reindex LEARNINGS.md ctx convention Add conventions to CONVENTIONS.md ctx reindex Regenerate indices for DECISIONS.md and LEARNINGS.md ctx permission Permission snapshots (golden image) ctx change Show what changed since last session ctx memory Bridge Claude Code auto memory into .context/ ctx watch Auto-apply context updates from AI output","path":["CLI"],"tags":[]},{"location":"cli/#sessions","level":2,"title":"Sessions","text":"Command Description ctx journal Browse, import, enrich, and lock session history ctx pad Encrypted scratchpad for sensitive one-liners ctx remind Session-scoped reminders that surface at session start ctx hook pause Pause context hooks for the current session ctx hook resume Resume paused context hooks","path":["CLI"],"tags":[]},{"location":"cli/#integrations","level":2,"title":"Integrations","text":"Command Description ctx setup Generate AI tool integration configs ctx steering Manage steering files (behavioral rules for AI tools) ctx trigger Manage lifecycle triggers (scripts for automation) ctx skill Manage reusable instruction bundles ctx mcp MCP server for AI tool integration (stdin/stdout) ctx hook notify Webhook notifications (setup, test, send) ctx loop Generate autonomous loop script ctx connection Client-side commands for connecting to a ctx Hub ctx hub Operate a ctx Hub server or cluster ctx serve Serve a static site locally via zensical ctx site Site management (feed generation)","path":["CLI"],"tags":[]},{"location":"cli/#diagnostics","level":2,"title":"Diagnostics","text":"Command Description ctx doctor Structural health check (hooks, drift, config) ctx trace Show context behind git commits ctx sysinfo Show system resource usage (memory, swap, disk, load) ctx usage Show session token usage stats","path":["CLI"],"tags":[]},{"location":"cli/#runtime","level":2,"title":"Runtime","text":"Command Description ctx config Manage runtime configuration profiles ctx prune Clean stale per-session state files ctx hook Hook message, notification, and lifecycle controls ctx system Hook plumbing and agent-only commands (not user-facing)","path":["CLI"],"tags":[]},{"location":"cli/#shell","level":2,"title":"Shell","text":"Command Description ctx completion Generate shell autocompletion scripts","path":["CLI"],"tags":[]},{"location":"cli/#exit-codes","level":2,"title":"Exit Codes","text":"Code Meaning 0 Success 1 General error / warnings (e.g. drift) 2 Context not found 3 Violations found (e.g. drift) 4 File operation error","path":["CLI"],"tags":[]},{"location":"cli/#environment-variables","level":2,"title":"Environment Variables","text":"Variable Description CTX_DIR Override default context directory path CTX_TOKEN_BUDGET Override default token budget CTX_SESSION_ID Active AI session ID (used by ctx trace for context linking)","path":["CLI"],"tags":[]},{"location":"cli/#configuration-file","level":2,"title":"Configuration File","text":"

      Optional .ctxrc (YAML format) at project root:

      # .ctxrc\ntoken_budget: 8000           # Default token budget\npriority_order:              # File loading priority\n  - TASKS.md\n  - DECISIONS.md\n  - CONVENTIONS.md\nauto_archive: true           # Auto-archive old items\narchive_after_days: 7        # Days before archiving tasks\nscratchpad_encrypt: true     # Encrypt scratchpad (default: true)\nevent_log: false             # Enable local hook event logging\ncompanion_check: true        # Check companion tools at session start\nentry_count_learnings: 30    # Drift warning threshold (0 = disable)\nentry_count_decisions: 20    # Drift warning threshold (0 = disable)\nconvention_line_count: 200   # Line count warning for CONVENTIONS.md (0 = disable)\ninjection_token_warn: 15000  # Oversize injection warning (0 = disable)\ncontext_window: 200000       # Auto-detected for Claude Code; override for other tools\nbilling_token_warn: 0        # One-shot billing warning at this token count (0 = disabled)\nkey_rotation_days: 90        # Days before key rotation nudge\nsession_prefixes:            # Recognized session header prefixes (extend for i18n)\n  - \"Session:\"               # English (default)\n  # - \"Oturum:\"              # Turkish (add as needed)\n  # - \"セッション:\"             # Japanese (add as needed)\nfreshness_files:             # Files with technology-dependent constants (opt-in)\n  - path: config/thresholds.yaml\n    desc: Model token limits and batch sizes\n    review_url: https://docs.example.com/limits  # Optional\nnotify:                      # Webhook notification settings\n  events:                    # Required: only listed events fire\n    - loop\n    - nudge\n    - relay\n    # - heartbeat            # Every-prompt session-alive signal\ntool: \"\"                     # Active AI tool: claude, cursor, cline, kiro, codex\nsteering:                    # Steering layer configuration\n  dir: .context/steering     # Steering files directory\n  default_inclusion: manual  # Default inclusion mode (always, auto, manual)\n  default_tools: []          # Default tool filter for new steering files\nhooks:                       # Hook system configuration\n  dir: .context/hooks        # Hook scripts directory\n  timeout: 10                # Per-hook execution timeout in seconds\n  enabled: true              # Whether hook execution is enabled\n
      Field Type Default Description token_budget int 8000 Default token budget for ctx agent priority_order []string (all files) File loading priority for context packets auto_archive bool true Auto-archive completed tasks archive_after_days int 7 Days before completed tasks are archived scratchpad_encrypt bool true Encrypt scratchpad with AES-256-GCM event_log bool false Enable local hook event logging to .context/state/events.jsonl companion_check bool true Check companion tool availability (Gemini Search, GitNexus) during /ctx-remember entry_count_learnings int 30 Drift warning when LEARNINGS.md exceeds this count entry_count_decisions int 20 Drift warning when DECISIONS.md exceeds this count convention_line_count int 200 Line count warning for CONVENTIONS.md injection_token_warn int 15000 Warn when auto-injected context exceeds this token count (0 = disable) context_window int 200000 Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools billing_token_warn int 0 (off) One-shot warning when session tokens exceed this threshold (0 = disabled) key_rotation_days int 90 Days before encryption key rotation nudge session_prefixes []string [\"Session:\"] Recognized Markdown session header prefixes. Extend to parse sessions written in other languages freshness_files []object (none) Files to track for staleness (path, desc, optional review_url). Hook warns after 6 months without modification notify.events []string (all) Event filter for webhook notifications (empty = all) tool string (empty) Active AI tool identifier (claude, cursor, cline, kiro, codex) steering.dir string .context/steering Steering files directory steering.default_inclusion string manual Default inclusion mode for new steering files (always, auto, manual) steering.default_tools []string (all) Default tool filter for new steering files (empty = all tools) hooks.dir string .context/hooks Hook scripts directory hooks.timeout int 10 Per-hook execution timeout in seconds hooks.enabled bool true Whether hook execution is enabled

      Priority order: CLI flags > Environment variables > .ctxrc > Defaults

      All settings are optional. Missing values use defaults.

      ","path":["CLI"],"tags":[]},{"location":"cli/bootstrap/","level":1,"title":"System Bootstrap","text":"","path":["System Bootstrap"],"tags":[]},{"location":"cli/bootstrap/#ctx-system-bootstrap","level":3,"title":"ctx system bootstrap","text":"

      Print the resolved context directory path so AI agents can anchor their session. The default output lists the context directory, the tracked context files, and a short health snapshot. --quiet prints just the path; --json produces structured output for automation.

      This is a hidden, agent-only command that agents are instructed to run first in their session-start procedure; it is the authoritative answer to \"where does this project's context live?\".

      ctx system bootstrap [flags]\n

      Flags:

      Flag Description -q, --quiet Output only the context directory path --json Output in JSON format

      Examples:

      ctx system bootstrap                 # Text output for agents\nctx system bootstrap -q              # Just the context directory path\nctx system bootstrap --json          # Structured output for automation\n

      Note: -q prints just the resolved directory path. See Activating a Context Directory if you hit a \"no context directory specified\" error.

      ","path":["System Bootstrap"],"tags":[]},{"location":"cli/change/","level":1,"title":"Change","text":"","path":["CLI","Context","Change"],"tags":[]},{"location":"cli/change/#ctx-change","level":2,"title":"ctx change","text":"

      Show what changed in context files and code since your last session.

      Automatically detects the previous session boundary from state markers or event log. Useful at session start to quickly see what moved while you were away.

      ctx change [flags]\n

      Flags:

      Flag Description --since Time reference: duration (24h) or date (2026-03-01)

      Reference time detection (priority order):

      1. --since flag (duration, date, or RFC3339 timestamp)
      2. ctx-loaded-* marker files in .context/state/ (second most recent)
      3. Last context-load-gate event from .context/state/events.jsonl
      4. Fallback: 24 hours ago

      Examples:

      # Auto-detect last session, show what changed\nctx change\n\n# Changes in the last 48 hours\nctx change --since 48h\n\n# Changes since a specific date\nctx change --since 2026-03-10\n

      Output:

      ## Changes Since Last Session\n\n**Reference point**: 6 hours ago\n\n### Context File Changes\n- `TASKS.md` - modified 2026-03-12 14:30\n- `DECISIONS.md` - modified 2026-03-12 09:15\n\n### Code Changes\n- **12 commits** since reference point\n- **Latest**: Fix journal enrichment ordering\n- **Directories touched**: internal, docs, specs\n- **Authors**: jose, claude\n

      Context file changes are detected by filesystem mtime (works without git). Code changes use git log --since (empty when not in a git repo).

      See also: Reviewing Session Changes.

      ","path":["CLI","Context","Change"],"tags":[]},{"location":"cli/completion/","level":1,"title":"Completion","text":"","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#ctx-completion","level":2,"title":"ctx completion","text":"

      Generate shell autocompletion scripts.

      ctx completion <shell>\n
      ","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#subcommands","level":3,"title":"Subcommands","text":"Shell Command bash ctx completion bash zsh ctx completion zsh fish ctx completion fish powershell ctx completion powershell

      Examples:

      ctx completion bash > /etc/bash_completion.d/ctx\nctx completion zsh  > \"${fpath[1]}/_ctx\"\nctx completion fish > ~/.config/fish/completions/ctx.fish\nctx completion powershell | Out-String | Invoke-Expression\n
      ","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#installation","level":3,"title":"Installation","text":"BashZshFishPowerShell
      # Add to ~/.bashrc\nsource <(ctx completion bash)\n
      # Add to ~/.zshrc\nsource <(ctx completion zsh)\n
      ctx completion fish | source\n# Or save to completions directory\nctx completion fish > ~/.config/fish/completions/ctx.fish\n
      # Add to your PowerShell profile\nctx completion powershell | Out-String | Invoke-Expression\n
      ","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/config/","level":1,"title":"Config","text":"","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config","level":3,"title":"ctx config","text":"

      Manage runtime configuration profiles.

      ctx config <subcommand>\n

      The ctx repo ships two .ctxrc source profiles (.ctxrc.base and .ctxrc.dev). The working copy (.ctxrc) is gitignored and switched between them using subcommands below.

      ","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-switch","level":4,"title":"ctx config switch","text":"

      Switch between .ctxrc configuration profiles.

      ctx config switch [dev|base]\n

      With no argument, toggles between dev and base. Accepts prod as an alias for base.

      Argument Description dev Switch to dev profile (verbose logging) base Switch to base profile (all defaults) (none) Toggle to the opposite profile

      Profiles:

      Profile Description dev Verbose logging, webhook notifications on base All defaults, notifications off

      Examples:

      ctx config switch dev     # Switch to dev profile\nctx config switch base    # Switch to base profile\nctx config switch         # Toggle (dev → base or base → dev)\nctx config switch prod    # Alias for \"base\"\n

      The detection heuristic checks for an uncommented notify: line in .ctxrc: present means dev, absent means base.

      ","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-status","level":4,"title":"ctx config status","text":"

      Show which .ctxrc profile is currently active.

      ctx config status\n

      Output examples:

      active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n

      See also: Configuration, Contributing: Configuration Profiles

      ","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/connect/","level":1,"title":"Connect","text":"","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect","level":2,"title":"ctx connect","text":"

      Connect a project to a ctx Hub for cross-project knowledge sharing. Projects publish decisions, learnings, conventions, and tasks to a hub; other subscribed projects receive them alongside local context.

      New to the Hub?

      Start with the ctx Hub overview for the mental model (what the hub is, who it's for, what it is not), then walk through Getting Started. This page is a command reference, not an introduction.

      The unit of identity is a project, not a user. Registering a directory with ctx connect register binds a per-project client token in .context/.connect.enc. Two developers on the same project either share that file over a trusted channel, or each register under a different project name.

      Only structured entries flow through the hub: decision, learning, convention, task. Session journals, scratchpad contents, and other local state stay on the machine that created them.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-register","level":3,"title":"ctx connect register","text":"

      One-time registration with a hub. Requires the hub address and admin token (printed by ctx hub start on first run).

      ctx connect register localhost:9900 --token ctx_adm_7f3a...\n

      On success, stores an encrypted connection config in .context/.connect.enc for future RPCs.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-subscribe","level":3,"title":"ctx connect subscribe","text":"

      Set which entry types to receive from the hub. Only matching types are returned by sync and listen.

      ctx connect subscribe decision learning\nctx connect subscribe decision learning convention\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-sync","level":3,"title":"ctx connect sync","text":"

      Pull matching entries from the hub and write them to .context/hub/ as markdown files with origin tags and date headers. Tracks last-seen sequence for incremental sync.

      ctx connect sync\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-publish","level":3,"title":"ctx connect publish","text":"

      Push entries to the hub. Specify type and content as arguments.

      ctx connect publish decision \"Use UTC timestamps everywhere\"\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-listen","level":3,"title":"ctx connect listen","text":"

      Stream new entries from the hub in real-time. Writes to .context/hub/ as entries arrive. Press Ctrl-C to stop.

      ctx connect listen\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#ctx-connect-status","level":3,"title":"ctx connect status","text":"

      Show hub connection state and entry statistics.

      ctx connect status\n
      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#automatic-sharing","level":2,"title":"Automatic Sharing","text":"

      Use --share on ctx add to write locally AND publish to the hub:

      ctx decision add \"Use UTC\" --share \\\n  --context \"Need consistency\" \\\n  --rationale \"Avoid timezone bugs\" \\\n  --consequence \"UI does conversion\"\n

      If the hub is unreachable, the local write succeeds and a warning is printed. The --share flag is best-effort; it never blocks local context updates.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#auto-sync","level":2,"title":"Auto-Sync","text":"

      Once registered, the check-hub-sync hook automatically syncs new entries from the hub at the start of each session (daily throttled). No manual ctx connect sync needed.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#shared-files","level":2,"title":"Shared Files","text":"

      Entries from the hub are stored in .context/hub/:

      .context/hub/\n  decisions.md      # Shared decisions with origin tags\n  learnings.md      # Shared learnings\n  conventions.md    # Shared conventions\n  .sync-state.json  # Last-seen sequence tracker\n

      These files are read-only (managed by sync/listen) and never mixed with local context files.

      ","path":["Connect"],"tags":[]},{"location":"cli/connect/#agent-integration","level":2,"title":"Agent Integration","text":"

      Include shared knowledge in agent context packets:

      ctx agent --include-hub\n

      Shared entries are included as Tier 8 in the budget-aware assembly, scored by recency and type relevance.

      ","path":["Connect"],"tags":[]},{"location":"cli/connection/","level":1,"title":"Connect","text":"","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connect","level":2,"title":"ctx connect","text":"

      Connect a project to a ctx Hub for cross-project knowledge sharing. Projects publish decisions, learnings, conventions, and tasks to a hub; other subscribed projects receive them alongside local context.

      New to the ctx Hub?

      Start with the ctx Hub overview for the mental model (what the hub is, who it's for, what it is not), then walk through Getting Started. This page is a command reference, not an introduction.

      The unit of identity is a project, not a user. Registering a directory with ctx connection register binds a per-project client token in .context/.connect.enc. Two developers on the same project either share that file over a trusted channel, or each register under a different project name.

      Only structured entries flow through the hub: decision, learning, convention, task. Session journals, scratchpad contents, and other local state stay on the machine that created them.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-register","level":3,"title":"ctx connection register","text":"

      One-time registration with a ctx Hub. Requires the ctx Hub address and admin token (printed by ctx hub start on first run).

      Examples:

      ctx connection register localhost:9900 --token ctx_adm_7f3a...\n

      On success, stores an encrypted connection config in .context/.connect.enc for future RPCs.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-subscribe","level":3,"title":"ctx connection subscribe","text":"

      Set which entry types to receive from the ctx Hub. Only matching types are returned by sync and listen.

      Examples:

      ctx connection subscribe decision learning\nctx connection subscribe decision learning convention\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-sync","level":3,"title":"ctx connection sync","text":"

      Pull matching entries from the ctx Hub and write them to .context/hub/ as markdown files with origin tags and date headers. Tracks last-seen sequence for incremental sync.

      Examples:

      ctx connection sync\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-publish","level":3,"title":"ctx connection publish","text":"

      Push entries to the ctx Hub. Specify type and content as arguments.

      Examples:

      ctx connection publish decision \"Use UTC timestamps everywhere\"\nctx connection publish learning \"Go embed requires files in same package\"\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-listen","level":3,"title":"ctx connection listen","text":"

      Stream new entries from the ctx Hub in real-time. Writes to .context/hub/ as entries arrive. Press Ctrl-C to stop.

      Examples:

      ctx connection listen\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-status","level":3,"title":"ctx connection status","text":"

      Show ctx Hub connection state and entry statistics.

      Examples:

      ctx connection status\n
      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#automatic-sharing","level":2,"title":"Automatic Sharing","text":"

      Use --share on ctx add to write locally AND publish to the ctx Hub:

      ctx decision add \"Use UTC\" --share \\\n  --context \"Need consistency\" \\\n  --rationale \"Avoid timezone bugs\" \\\n  --consequence \"UI does conversion\"\n

      If the hub is unreachable, the local write succeeds and a warning is printed. The --share flag is best-effort; it never blocks local context updates.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#auto-sync","level":2,"title":"Auto-Sync","text":"

      Once registered, the check-hub-sync hook automatically syncs new entries from the ctx Hub at the start of each session (daily throttled). No manual ctx connection sync needed.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#shared-files","level":2,"title":"Shared Files","text":"

      Entries from the ctx Hub are stored in .context/hub/:

      .context/hub/\n  decisions.md      # Shared decisions with origin tags\n  learnings.md      # Shared learnings\n  conventions.md    # Shared conventions\n  .sync-state.json  # Last-seen sequence tracker\n

      These files are read-only (managed by sync/listen) and never mixed with local context files.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#agent-integration","level":2,"title":"Agent Integration","text":"

      Include shared knowledge in agent context packets:

      ctx agent --include-hub\n

      Shared entries are included as Tier 8 in the budget-aware assembly, scored by recency and type relevance.

      ","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/context/","level":1,"title":"Context Management","text":"","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#adding-entries","level":3,"title":"Adding entries","text":"

      Each context-artifact noun (task, decision, learning, convention) owns its own add subcommand under the noun-first command tree:

      ctx task add <content> [flags]\nctx decision add <content> [flags]\nctx learning add <content> [flags]\nctx convention add <content> [flags]\n

      Target files:

      Subcommand Target File ctx task add TASKS.md ctx decision add DECISIONS.md ctx learning add LEARNINGS.md ctx convention add CONVENTIONS.md

      Flags (shared by every add subcommand; per-noun required-flag rules surface as command errors):

      Flag Short Description --priority <level> -p Priority for tasks: high, medium, low --section <name> -s Target section within file --context -c Context (required for decisions and learnings) --rationale -r Rationale for decisions (required for decisions) --consequence Consequence for decisions (required for decisions) --lesson -l Key insight (required for learnings) --application -a How to apply going forward (required for learnings) --file -f Read content from file instead of argument

      Examples:

      # Add a task\nctx task add \"Implement user authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\nctx task add \"Fix login bug\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Record a decision (requires all ADR (Architectural Decision Record) fields)\nctx decision add \"Use PostgreSQL for primary database\" \\\n  --context \"Need a reliable database for production\" \\\n  --rationale \"PostgreSQL offers ACID compliance and JSON support\" \\\n  --consequence \"Team needs PostgreSQL training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Note a learning (requires context, lesson, and application)\nctx learning add \"Vitest mocks must be hoisted\" \\\n  --context \"Tests failed with undefined mock errors\" \\\n  --lesson \"Vitest hoists vi.mock() calls to top of file\" \\\n  --application \"Always place vi.mock() before imports in test files\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Add to specific section\nctx convention add \"Use kebab-case for filenames\" --section \"Naming\"\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-drift","level":3,"title":"ctx drift","text":"

      Detect stale or invalid context.

      ctx drift [flags]\n

      Flags:

      Flag Description --json Output machine-readable JSON --fix Auto-fix simple issues

      Checks:

      • Path references in ARCHITECTURE.md and CONVENTIONS.md exist
      • Task references are valid
      • Constitution rules aren't violated (heuristic)
      • Staleness indicators (old files, many completed tasks)
      • Missing packages: warns when internal/ directories exist on disk but are not referenced in ARCHITECTURE.md (suggests running /ctx-architecture)
      • Entry count: warns when LEARNINGS.md or DECISIONS.md exceed configurable thresholds (default: 30 learnings, 20 decisions), or when CONVENTIONS.md exceeds a line count threshold (default: 200). Configure via .ctxrc:
        entry_count_learnings: 30      # warn above this (0 = disable)\nentry_count_decisions: 20      # warn above this (0 = disable)\nconvention_line_count: 200     # warn above this (0 = disable)\n

      Example:

      ctx drift\nctx drift --json\nctx drift --fix\n

      Exit codes:

      Code Meaning 0 All checks passed 1 Warnings found 3 Violations found","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-sync","level":3,"title":"ctx sync","text":"

      Reconcile context with the current codebase state.

      ctx sync [flags]\n

      Flags:

      Flag Description --dry-run Show what would change without modifying

      What it does:

      • Scans codebase for structural changes
      • Compares with ARCHITECTURE.md
      • Suggests documenting dependencies if package files exist
      • Identifies stale or outdated context

      Example:

      ctx sync\nctx sync --dry-run\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-compact","level":3,"title":"ctx compact","text":"

      Consolidate and clean up context files.

      • Moves completed tasks older than 7 days to the archive
      • Removes empty sections
      ctx compact [flags]\n

      Flags:

      Flag Description --archive Create .context/archive/ for old content

      Example:

      ctx compact\nctx compact --archive\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-fmt","level":3,"title":"ctx fmt","text":"

      Format context files to a consistent line width.

      Wraps long lines in TASKS.md, DECISIONS.md, LEARNINGS.md, and CONVENTIONS.md at word boundaries. Markdown list items get 2-space continuation indent. Headings, tables, frontmatter, and HTML comments are preserved as-is.

      Idempotent: running twice produces the same output.

      ctx fmt [flags]\n

      Flags:

      Flag Type Default Description --width int 80 Target line width --check bool false Check only, exit 1 if files would change

      Examples:

      ctx fmt              # format all context files\nctx fmt --check      # CI mode: check without modifying\nctx fmt --width 100  # custom width\n

      Also available as a Makefile target:

      make fmt-context\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task","level":3,"title":"ctx task","text":"

      Manage task completion, archival, and snapshots.

      ctx task <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-complete","level":4,"title":"ctx task complete","text":"

      Mark a task as completed.

      ctx task complete <task-id-or-text>\n

      Arguments:

      • task-id-or-text: Task number or partial text match

      Examples:

      # By text (partial match)\nctx task complete \"user auth\"\n\n# By task number\nctx task complete 3\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-archive","level":4,"title":"ctx task archive","text":"

      Move completed tasks from TASKS.md to a timestamped archive file.

      ctx task archive [flags]\n

      Flags:

      Flag Description --dry-run Preview changes without modifying files

      Archive files are stored in .context/archive/ with timestamped names (tasks-YYYY-MM-DD.md). Completed tasks (marked with [x]) are moved; pending tasks ([ ]) remain in TASKS.md.

      Example:

      ctx task archive\nctx task archive --dry-run\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-snapshot","level":4,"title":"ctx task snapshot","text":"

      Create a point-in-time snapshot of TASKS.md without modifying the original.

      ctx task snapshot [name]\n

      Arguments:

      • name: Optional name for the snapshot (defaults to \"snapshot\")

      Snapshots are stored in .context/archive/ with timestamped names (tasks-<name>-YYYY-MM-DD-HHMM.md).

      Example:

      ctx task snapshot\nctx task snapshot \"before-refactor\"\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission","level":3,"title":"ctx permission","text":"

      Manage Claude Code permission snapshots.

      ctx permission <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-snapshot","level":4,"title":"ctx permission snapshot","text":"

      Save .claude/settings.local.json as the golden image.

      ctx permission snapshot\n

      Creates .claude/settings.golden.json as a byte-for-byte copy of the current settings. Overwrites if the golden file already exists.

      The golden file is meant to be committed to version control and shared with the team.

      Example:

      ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-restore","level":4,"title":"ctx permission restore","text":"

      Replace settings.local.json with the golden image.

      ctx permission restore\n

      Prints a diff of dropped (session-accumulated) and restored permissions. No-op if the files already match.

      Example:

      ctx permission restore\n# Dropped 3 session permission(s):\n#   - Bash(cat /tmp/debug.log:*)\n#   - Bash(rm /tmp/test-*:*)\n#   - Bash(curl https://example.com:*)\n# Restored from golden image.\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-reindex","level":3,"title":"ctx reindex","text":"

      Regenerate the quick-reference index for both DECISIONS.md and LEARNINGS.md in a single invocation.

      ctx reindex\n

      This is a convenience wrapper around ctx decision reindex and ctx learning reindex. Both files grow at similar rates and users typically want to reindex both after manual edits.

      The index is a compact table of date and title for each entry, allowing AI tools to scan entries without reading the full file.

      Example:

      ctx reindex\n# ✓ Index regenerated with 12 entries\n# ✓ Index regenerated with 8 entries\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-decision","level":3,"title":"ctx decision","text":"

      Manage the DECISIONS.md file.

      ctx decision <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-decision-reindex","level":4,"title":"ctx decision reindex","text":"

      Regenerate the quick-reference index at the top of DECISIONS.md.

      ctx decision reindex\n

      The index is a compact table showing the date and title for each decision, allowing AI tools to quickly scan entries without reading the full file.

      Use this after manual edits to DECISIONS.md or when migrating existing files to use the index format.

      Example:

      ctx decision reindex\n# ✓ Index regenerated with 12 entries\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-learning","level":3,"title":"ctx learning","text":"

      Manage the LEARNINGS.md file.

      ctx learning <subcommand>\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-learning-reindex","level":4,"title":"ctx learning reindex","text":"

      Regenerate the quick-reference index at the top of LEARNINGS.md.

      ctx learning reindex\n

      The index is a compact table showing the date and title for each learning, allowing AI tools to quickly scan entries without reading the full file.

      Use this after manual edits to LEARNINGS.md or when migrating existing files to use the index format.

      Example:

      ctx learning reindex\n# ✓ Index regenerated with 8 entries\n
      ","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/doctor/","level":1,"title":"Doctor","text":"","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#ctx-doctor","level":3,"title":"ctx doctor","text":"

      Structural health check across context, hooks, and configuration. Runs mechanical checks that don't require semantic analysis. Think of it as ctx status + ctx drift + configuration audit in one pass.

      ctx doctor [flags]\n

      Flags:

      Flag Short Type Default Description --json -j bool false Machine-readable JSON output","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#what-it-checks","level":4,"title":"What It Checks","text":"Check Category What it verifies Context initialized Structure .context/ directory exists Required files present Structure All required context files exist (TASKS.md, etc.) Drift detected Quality Stale paths, missing files, constitution violations Event logging status Hooks Whether event_log: true is set in .ctxrc Webhook configured Hooks .notify.enc file exists Pending reminders State Count of entries in reminders.json Task completion ratio State Pending vs completed tasks in TASKS.md Context token size Size Estimated token count across all context files Recent event activity Events Last event timestamp (only when event logging is enabled)","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#output-format-human","level":4,"title":"Output Format (Human)","text":"
      ctx doctor\n==========\n\nStructure\n  ✓ Context initialized (.context/)\n  ✓ Required files present (4/4)\n\nQuality\n  ⚠ Drift: 2 warnings (stale path in ARCHITECTURE.md, high entry count in LEARNINGS.md)\n\nHooks\n  ✓ hooks.json valid (14 hooks registered)\n  ○ Event logging disabled (enable with event_log: true in .ctxrc)\n\nState\n  ✓ No pending reminders\n  ⚠ Task completion ratio high (18/22 = 82%): consider archiving\n\nSize\n  ✓ Context size: ~4200 tokens (budget: 8000)\n\nSummary: 2 warnings, 0 errors\n

      Status indicators:

      Icon Status Meaning ✓ ok Check passed ⚠ warning Non-critical issue worth fixing ✗ error Problem that needs attention ○ info Informational note","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#output-format-json","level":4,"title":"Output Format (JSON)","text":"
      {\n  \"results\": [\n    {\n      \"name\": \"context_initialized\",\n      \"category\": \"Structure\",\n      \"status\": \"ok\",\n      \"message\": \"Context initialized (.context/)\"\n    },\n    {\n      \"name\": \"required_files\",\n      \"category\": \"Structure\",\n      \"status\": \"ok\",\n      \"message\": \"Required files present (4/4)\"\n    },\n    {\n      \"name\": \"drift\",\n      \"category\": \"Quality\",\n      \"status\": \"warning\",\n      \"message\": \"Drift: 2 warnings\"\n    },\n    {\n      \"name\": \"event_logging\",\n      \"category\": \"Hooks\",\n      \"status\": \"info\",\n      \"message\": \"Event logging disabled (enable with event_log: true in .ctxrc)\"\n    },\n    {\n      \"name\": \"webhook\",\n      \"category\": \"Hooks\",\n      \"status\": \"ok\",\n      \"message\": \"Webhook configured\"\n    },\n    {\n      \"name\": \"reminders\",\n      \"category\": \"State\",\n      \"status\": \"ok\",\n      \"message\": \"No pending reminders\"\n    },\n    {\n      \"name\": \"task_completion\",\n      \"category\": \"State\",\n      \"status\": \"warning\",\n      \"message\": \"Tasks: 18/22 completed (82%): consider archiving with ctx task archive\"\n    },\n    {\n      \"name\": \"context_size\",\n      \"category\": \"Size\",\n      \"status\": \"ok\",\n      \"message\": \"Context size: ~4200 tokens (budget: 8000)\"\n    }\n  ],\n  \"warnings\": 2,\n  \"errors\": 0\n}\n

      Examples:

      # Quick structural health check\nctx doctor\n\n# Machine-readable output for scripting\nctx doctor --json\n\n# Count warnings\nctx doctor --json | jq '.warnings'\n\n# Check for errors only\nctx doctor --json | jq '[.results[] | select(.status == \"error\")]'\n
      ","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#when-to-use-what","level":4,"title":"When to Use What","text":"Tool When ctx status Quick glance at files, tokens, and drift ctx doctor Thorough structural checkup (hooks, config, events too) /ctx-doctor Agent-driven diagnosis with event log pattern analysis

      ctx status tells you what's there. ctx doctor tells you what's wrong. /ctx-doctor tells you why it's wrong and what to do about it.

      ","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#what-it-does-not-do","level":4,"title":"What It Does Not Do","text":"
      • No event pattern analysis: that's the /ctx-doctor skill's job
      • No auto-fixing: reports findings, doesn't modify anything
      • No external service checks: doesn't verify webhook endpoint availability

      See also: Troubleshooting | ctx hook event | /ctx-doctor skill | Detecting and Fixing Drift

      ","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/event/","level":1,"title":"Event","text":"","path":["Event"],"tags":[]},{"location":"cli/event/#ctx-hook-event","level":3,"title":"ctx hook event","text":"

      Query the local hook event log. Requires event_log: true in .ctxrc. Reads events from .context/state/events.jsonl and outputs them in a human-readable table or raw JSONL format.

      All filter flags combine with AND logic.

      ctx hook event [flags]\n

      Flags:

      Flag Description --hook Filter by hook name --session Filter by session ID --event Filter by event type (relay, nudge) --last Show last N events (default: 50) --json Output raw JSONL (for piping to jq) --all Include rotated log file

      Examples:

      ctx hook event                                        # recent events\nctx hook event --hook check-context-size --last 10    # one hook, last 10\nctx hook event --json | jq '.hook'                    # pipe to jq\nctx hook event --session abc123                       # filter by session\n
      ","path":["Event"],"tags":[]},{"location":"cli/guide/","level":1,"title":"Guide","text":"","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/guide/#ctx-guide","level":2,"title":"ctx guide","text":"

      Quick-reference cheat sheet for common ctx commands and skills.

      ctx guide [flags]\n

      Flags:

      Flag Description --skills Show available skills --commands Show available CLI commands

      Example:

      # Show the full cheat sheet\nctx guide\n\n# Skills only\nctx guide --skills\n\n# Commands only\nctx guide --commands\n

      Works without initialization (no .context/ required). Useful for a printable one-pager when onboarding to a project.

      ","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/hook/","level":1,"title":"Hook","text":"","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#ctx-hook","level":3,"title":"ctx hook","text":"

      Manage hook-related settings: messages, notifications, pause/resume, and event log.

      ctx hook <subcommand> [flags]\n
      ","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#subcommands","level":2,"title":"Subcommands","text":"Subcommand Description ctx hook message list Show all hook messages with override status ctx hook message show <h> <v> Print the effective message template ctx hook message edit <h> <v> Copy default to .context/ for editing ctx hook message reset <h> <v> Delete user override, revert to default ctx hook notify [message] Send a webhook notification ctx hook notify setup Configure and encrypt webhook URL ctx hook notify test Send a test notification ctx hook pause Pause all context hooks for this session ctx hook resume Resume paused context hooks ctx hook event Query the local hook event log","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#examples","level":2,"title":"Examples","text":"
      # View and manage hook messages\nctx hook message list\nctx hook message show qa-reminder gate\nctx hook message edit qa-reminder gate\n\n# Webhook notifications\nctx hook notify setup\nctx hook notify --event loop \"Loop completed\"\n\n# Pause/resume hooks\nctx hook pause\nctx hook resume\n\n# Browse event log\nctx hook event --last 20\nctx hook event --hook qa-reminder --json\n

      See also: Customizing Hook Messages | Webhook Notifications | Pausing Context Hooks | System Hooks Audit

      ","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hub/","level":1,"title":"Hub","text":"","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub","level":2,"title":"ctx hub","text":"

      Operator commands for a ctx Hub: the gRPC server that fans out decisions, learnings, conventions, and tasks across projects. Use ctx hub to start and stop the server, inspect cluster state, add or remove peers at runtime, and hand off leadership before maintenance.

      Who Needs This Page

      You only need ctx hub if you are running a hub server or cluster. For client-side operations (register, subscribe, sync, publish, listen), see ctx connect. For the mental model behind the hub as a whole, read the ctx Hub overview.

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-start","level":3,"title":"ctx hub start","text":"

      Start the hub gRPC server.

      Examples:

      ctx hub start                           # Foreground, default port 9900\nctx hub start --port 8080               # Custom port\nctx hub start --data-dir /srv/ctx-hub   # Custom data directory\n

      On first run, generates an admin token and prints it to stdout. Save this token; it's required for ctx connection register in client projects. Subsequent runs reuse the stored token from <data-dir>/admin.token.

      Default data directory: ~/.ctx/hub-data/

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#daemon-mode","level":4,"title":"Daemon Mode","text":"

      Run the hub as a detached background process:

      ctx hub start --daemon          # Fork to background\nctx hub stop                    # Graceful shutdown\n

      The daemon writes a PID file to <data-dir>/hub.pid. Stop the daemon with ctx hub stop (see below).

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#cluster-mode","level":4,"title":"Cluster Mode","text":"

      For high availability, run multiple hubs with Raft-based leader election:

      ctx hub start --port 9900 \\\n  --peers host2:9901,host3:9901\n

      Raft is used only for leader election. Data replication uses sequence-based gRPC sync on the append-only JSONL log; there is no multi-node consensus on writes. See the HA cluster recipe for the full setup and the Raft-lite durability caveat.

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#flags","level":4,"title":"Flags","text":"Flag Description Default --port Hub listen port 9900 --data-dir Hub data directory ~/.ctx/hub-data/ --daemon Run the hub server in the background false --peers Comma-separated peer addresses for cluster mode (none)","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#validation","level":4,"title":"Validation","text":"

      The hub validates every published entry before accepting it:

      • Type must be one of decision, learning, convention, task
      • ID and Origin are required and non-empty
      • Content size capped at 1 MB (text-only)
      • Duplicate project registration is rejected (one token per project)
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stop","level":3,"title":"ctx hub stop","text":"

      Stop a running hub daemon.

      Examples:

      ctx hub stop                            # Stop using default data dir\nctx hub stop --data-dir /srv/ctx-hub    # Custom data directory\n

      Sends SIGTERM to the PID recorded in <data-dir>/hub.pid, waits for in-flight RPCs to drain, and removes the PID file. Safe to rerun: if no daemon is running, returns a \"no running hub\" error without side effects.

      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-status","level":3,"title":"ctx hub status","text":"

      Show cluster status: role, peers, sync state, entry count, and uptime.

      Examples:

      ctx hub status\n
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-peer","level":3,"title":"ctx hub peer","text":"

      Add or remove peers from the cluster at runtime. Useful for scaling up or replacing a decommissioned node without restarting the leader.

      Examples:

      ctx hub peer add host2:9901\nctx hub peer remove host2:9901\n
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stepdown","level":3,"title":"ctx hub stepdown","text":"

      Transfer leadership to another node gracefully. Triggers a new election among the remaining followers before the current leader steps down. Use before taking the leader offline for maintenance.

      Examples:

      ctx hub stepdown\n
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#see-also","level":3,"title":"See Also","text":"
      • ctx connect: client-side commands (register, subscribe, sync, publish, listen)
      • ctx Hub overview: mental model and user stories
      • ctx Hub: Getting Started
      • Hub operations: production deployment, backup, monitoring
      • Hub failure modes
      • Hub security model
      ","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/init-status/","level":1,"title":"Init and Status","text":"","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-init","level":3,"title":"ctx init","text":"

      Initialize a new .context/ directory with template files.

      ctx init [flags]\n

      Flags:

      Flag Short Description --force -f Overwrite existing context files --minimal -m Only create essential files (TASKS.md, DECISIONS.md, CONSTITUTION.md) --merge Auto-merge ctx content into existing CLAUDE.md

      Creates:

      • .context/ directory with all template files
      • .claude/settings.local.json with pre-approved ctx permissions
      • CLAUDE.md with bootstrap instructions (or merges into existing)

      Claude Code hooks and skills are provided by the ctx plugin (see Integrations).

      Example:

      # Standard init\nctx init\n\n# Minimal setup (just core files)\nctx init --minimal\n\n# Force overwrite existing\nctx init --reset\n\n# Merge into existing files\nctx init --merge\n

      After ctx init succeeds, the final output includes a hint showing the exact eval \"$(ctx activate)\" line to bind the new directory for your shell. Every other ctx command requires that binding (or an equivalent direct CTX_DIR=/abs/path/.context export) before it will run.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-activate","level":3,"title":"ctx activate","text":"

      Emit a shell-native export CTX_DIR=... line for the target .context/ directory. ctx does not search the filesystem during day-to-day commands: each one needs CTX_DIR set before it runs. activate is the convenience that figures out the path for you so you can bind it with one line.

      # Walk up from CWD, emit if exactly one candidate visible.\neval \"$(ctx activate)\"\n

      Flags:

      Flag Description --shell Shell dialect override. POSIX-family (bash, zsh, sh) all share one syntax today; the flag exists for future fish/nushell/powershell support. Auto-detected from $SHELL.

      Resolution:

      Candidate count from CWD Behavior Zero Error. Use ctx init to create one, or cd closer to the project root. One Emit export CTX_DIR=<path> for that candidate. Two or more Refuse. List every candidate. Re-run from a more specific cwd.

      activate is args-free under the single-source-anchor model; the explicit-path mode was removed because hub-client / hub-server scenarios store at ~/.ctx/hub-data/ and never read .context/, so they activate from the project root like everyone else. Direct binding without a project-local scan is still available via export CTX_DIR=/abs/path/.context or the inline form.

      If the parent shell already has CTX_DIR set to a different value, the output gains a leading # ctx: replacing stale CTX_DIR=... comment so the user sees the change in eval output before the replacement takes effect.

      See also: Activating a Context Directory for the full recipe including direnv setup and CI patterns.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-deactivate","level":3,"title":"ctx deactivate","text":"

      Emit a shell-native unset CTX_DIR line. Pairs with activate.

      eval \"$(ctx deactivate)\"\n

      Flags:

      Flag Description --shell Shell dialect override. POSIX-family (bash, zsh, sh) all share one unset syntax today; the flag exists for future fish/nushell/powershell support. Auto-detected from $SHELL.

      deactivate does not touch the filesystem, doesn't require a declared context directory, and never fails under normal operation; unsetting an already-unset variable is a no-op across supported shells.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-status","level":3,"title":"ctx status","text":"

      Show the current context summary.

      ctx status [flags]\n

      Flags:

      Flag Short Description --json Output as JSON --verbose -v Include file contents summary

      Output:

      • Context directory path
      • Total files and token estimate
      • Status of each file (loaded, empty, missing)
      • Recent activity (modification times)
      • Drift warnings if any

      Example:

      ctx status\nctx status --json\nctx status --verbose\n
      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-agent","level":3,"title":"ctx agent","text":"

      Print an AI-ready context packet optimized for LLM consumption.

      ctx agent [flags]\n

      Flags:

      Flag Default Description --budget 8000 Token budget: controls content selection and prioritization --format md Output format: md or json --cooldown 10m Suppress repeated output within this duration (requires --session) --session (none) Session ID for cooldown isolation (e.g., $PPID) --include-hub false Include hub entries from .context/hub/

      How budget works:

      The budget controls how much context is included. Entries are selected in priority tiers:

      1. Constitution: always included in full (inviolable rules)
      2. Tasks: all active tasks, up to 40% of budget
      3. Conventions: all conventions, up to 20% of budget
      4. Decisions: scored by recency and relevance to active tasks
      5. Learnings: scored by recency and relevance to active tasks
      6. Steering: applicable steering file bodies, scored by their inclusion mode and description match against the active prompt
      7. Skill: named skill content (from --skill)
      8. Hub: entries from .context/hub/ (with --include-hub, see ctx connect)

      Decisions and learnings are ranked by a combined score (how recent + how relevant to your current tasks). High-scoring entries are included with their full body. Entries that don't fit get title-only summaries in an \"Also Noted\" section. Superseded entries are excluded.

      Output Sections:

      Section Source Selection Read These Files all .context/ Non-empty files in priority order Constitution CONSTITUTION.md All rules (never truncated) Current Tasks TASKS.md All unchecked tasks (budget-capped) Key Conventions CONVENTIONS.md All items (budget-capped) Recent Decisions DECISIONS.md Full body, scored by relevance Key Learnings LEARNINGS.md Full body, scored by relevance Also Noted overflow Title-only summaries

      Example:

      # Default (8000 tokens, markdown)\nctx agent\n\n# Smaller packet for tight context windows\nctx agent --budget 4000\n\n# JSON format for programmatic use\nctx agent --format json\n\n# Pipe to file\nctx agent --budget 4000 > context.md\n\n# With cooldown (hooks/automation: requires --session)\nctx agent --session $PPID\n

      Use case: Copy-paste into AI chat, pipe to system prompt, or use in hooks.

      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-load","level":3,"title":"ctx load","text":"

      Load and display assembled context as AI would see it.

      ctx load [flags]\n

      Flags:

      Flag Description --budget <tokens> Token budget for assembly (default: 8000) --raw Output raw file contents without assembly

      Example:

      ctx load\nctx load --budget 16000\nctx load --raw\n
      ","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/journal/","level":1,"title":"Journal","text":"","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal","level":3,"title":"ctx journal","text":"

      Browse and search AI session history from Claude Code and other tools.

      ctx journal <subcommand>\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source","level":4,"title":"ctx journal source","text":"

      List all parsed sessions.

      ctx journal source [flags]\n

      Flags:

      Flag Short Description --limit -n Maximum sessions to display (default: 20) --project -p Filter by project name --tool -t Filter by tool (e.g., claude-code) --all-projects Include sessions from all projects

      Sessions are sorted by date (newest first) and display slug, project, start time, duration, turn count, and token usage.

      Example:

      ctx journal source\nctx journal source --limit 5\nctx journal source --project ctx\nctx journal source --tool claude-code\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source-show","level":4,"title":"ctx journal source --show","text":"

      Show details of a specific session.

      ctx journal source --show [session-id] [flags]\n

      Flags:

      Flag Description --latest Show the most recent session --full Show full message content --all-projects Search across all projects

      The session ID can be a full UUID, partial match, or session slug name.

      Example:

      ctx journal source --show abc123\nctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show --latest\nctx journal source --show --latest --full\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-import","level":4,"title":"ctx journal import","text":"

      Import sessions to editable journal files in .context/journal/.

      ctx journal import [session-id] [flags]\n

      Flags:

      Flag Description --all Import all sessions (only new files by default) --all-projects Import from all projects --regenerate Re-import existing files (preserves YAML frontmatter by default) --keep-frontmatter Preserve enriched YAML frontmatter during regeneration (default: true) --yes, -y Skip confirmation prompt --dry-run Show what would be imported without writing files

      Safe by default: --all only imports new sessions. Existing files are skipped. Use --regenerate to re-import existing files (conversation content is regenerated, YAML frontmatter from enrichment is preserved by default). Use --keep-frontmatter=false to discard enriched frontmatter during regeneration.

      Locked entries (via ctx journal lock) are always skipped, regardless of flags.

      Single-session import (ctx journal import <id>) always writes without prompting, since you are explicitly targeting one session.

      The journal/ directory should be gitignored (like sessions/) since it contains raw conversation data.

      Example:

      ctx journal import abc123                 # Import one session\nctx journal import --all                  # Import only new sessions\nctx journal import --all --dry-run        # Preview what would be imported\nctx journal import --all --regenerate     # Re-import existing (prompts)\nctx journal import --all --regenerate -y  # Re-import without prompting\nctx journal import --all --regenerate --keep-frontmatter=false -y  # Discard frontmatter\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-lock","level":4,"title":"ctx journal lock","text":"

      Protect journal entries from being overwritten by import --regenerate or modified by enrichment skills (/ctx-journal-enrich, /ctx-journal-enrich-all).

      ctx journal lock <pattern> [flags]\n

      Flags:

      Flag Description --all Lock all journal entries

      The pattern matches filenames by slug, date, or short ID. Locking a multi-part entry locks all parts. The lock is recorded in .context/journal/.state.json and a locked: true line is added to the file's YAML frontmatter for visibility.

      Example:

      ctx journal lock abc12345\nctx journal lock 2026-01-21-session-abc12345.md\nctx journal lock --all\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-unlock","level":4,"title":"ctx journal unlock","text":"

      Remove lock protection from journal entries.

      ctx journal unlock <pattern> [flags]\n

      Flags:

      Flag Description --all Unlock all journal entries

      Example:

      ctx journal unlock abc12345\nctx journal unlock --all\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-sync","level":4,"title":"ctx journal sync","text":"

      Sync lock state from journal frontmatter to .state.json.

      ctx journal sync\n

      Scans all journal markdowns and updates .state.json to match each file's frontmatter. Files with locked: true in frontmatter are marked locked in state; files without a locked: line have their lock cleared.

      This is the inverse of ctx journal lock: instead of state driving frontmatter, frontmatter drives state. Useful after batch enrichment where you add locked: true to frontmatter manually.

      Example:

      # After enriching entries and adding locked: true to frontmatter\nctx journal sync\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal_1","level":3,"title":"ctx journal","text":"

      Analyze and synthesize imported session files.

      ctx journal <subcommand>\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-site","level":4,"title":"ctx journal site","text":"

      Generate a static site from journal entries in .context/journal/.

      ctx journal site [flags]\n

      Flags:

      Flag Short Description --output -o Output directory (default: .context/journal-site) --build Run zensical build after generating --serve Run zensical serve after generating

      Creates a zensical-compatible site structure with an index page listing all sessions by date, and individual pages for each journal entry.

      Requires zensical to be installed for --build or --serve:

      pipx install zensical\n

      Example:

      ctx journal site                    # Generate in .context/journal-site/\nctx journal site --output ~/public  # Custom output directory\nctx journal site --build            # Generate and build HTML\nctx journal site --serve            # Generate and serve locally\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-obsidian","level":4,"title":"ctx journal obsidian","text":"

      Generate an Obsidian vault from journal entries in .context/journal/.

      ctx journal obsidian [flags]\n

      Flags:

      Flag Short Description --output -o Output directory (default: .context/journal-obsidian)

      Creates an Obsidian-compatible vault with:

      • Wikilinks ([[target|display]]) for all internal navigation
      • MOC pages (Map of Content) for topics, key files, and session types
      • Related sessions footer linking entries that share topics
      • Transformed frontmatter (topicstags for Obsidian integration)
      • Minimal .obsidian/ config enforcing wikilink mode

      No external dependencies are required: Open the output directory as an Obsidian vault directly.

      Example:

      ctx journal obsidian                        # Generate in .context/journal-obsidian/\nctx journal obsidian --output ~/vaults/ctx  # Custom output directory\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-check","level":4,"title":"ctx journal schema check","text":"

      Validate JSONL session files against the embedded schema and report drift.

      ctx journal schema check [flags]\n

      Flags:

      Flag Short Description --dir Directory to scan for JSONL files --all-projects Scan all Claude Code project directories --quiet -q Exit code only (0 = clean, 1 = drift)

      Scans JSONL files for unknown fields, missing required fields, unknown record types, and unknown content block types. When drift is found, writes a Markdown report to .context/reports/schema-drift.md. When drift resolves, the report is automatically deleted.

      Designed for interactive use, CI pipelines, and nightly cron jobs.

      Example:

      ctx journal schema check                    # Current project\nctx journal schema check --all-projects     # All projects\nctx journal schema check --quiet            # Exit code only\nctx journal schema check --dir /path/to     # Custom directory\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-dump","level":4,"title":"ctx journal schema dump","text":"

      Print the embedded JSONL schema definition.

      ctx journal schema dump\n

      Shows all known record types with their required and optional fields, and all recognized content block types with their parse status. Useful for inspecting what the schema validator expects.

      Example:

      ctx journal schema dump\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-serve","level":3,"title":"ctx serve","text":"

      Serve any zensical directory locally. This is a serve-only command: It does not generate or regenerate site content.

      ctx serve [directory]\n

      If no directory is specified, defaults to the journal site (.context/journal-site).

      Requires zensical to be installed:

      pipx install zensical\n

      ctx serve vs. ctx journal site --serve

      ctx journal site --serve generates the journal site then serves it: an all-in-one command. ctx serve only serves an existing directory, and works with any zensical site (journal, docs, etc.).

      Example:

      ctx serve                        # Serve journal site (no regeneration)\nctx serve .context/journal-site  # Same, explicit path\nctx serve ./site                 # Serve the docs site\n
      ","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/loop/","level":1,"title":"Loop","text":"","path":["CLI","Integrations","Loop"],"tags":[]},{"location":"cli/loop/#ctx-loop","level":2,"title":"ctx loop","text":"

      Generate a shell script for running an autonomous loop.

      An autonomous loop continuously runs an AI assistant with the same prompt until a completion signal is detected, enabling iterative development where the AI builds on its previous work.

      ctx loop [flags]\n

      Flags:

      Flag Short Description Default --tool <tool> -t AI tool: claude, aider, or generic claude --prompt <file> -p Prompt file to use .context/loop.md --max-iterations <n> -n Maximum iterations (0 = unlimited) 0 --completion <signal> -c Completion signal to detect SYSTEM_CONVERGED --output <file> -o Output script filename loop.sh

      Examples:

      # Generate loop.sh for Claude Code\nctx loop\n\n# Generate for Aider with custom prompt\nctx loop --tool aider --prompt TASKS.md\n\n# Limit to 10 iterations\nctx loop --max-iterations 10\n\n# Output to custom file\nctx loop -o my-loop.sh\n

      Running the generated loop:

      ctx loop\nchmod +x loop.sh\n./loop.sh\n

      See also: Autonomous Loops for the full workflow.

      ","path":["CLI","Integrations","Loop"],"tags":[]},{"location":"cli/mcp/","level":1,"title":"MCP Server","text":"","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-mcp","level":2,"title":"ctx mcp","text":"

      Run ctx as a Model Context Protocol (MCP) server. MCP is a standard protocol that lets AI tools discover and consume context from external sources via JSON-RPC 2.0 over stdin/stdout.

      This makes ctx accessible to any MCP-compatible AI tool without custom hooks or integrations:

      • Claude Desktop
      • Cursor
      • Windsurf
      • VS Code Copilot
      • Any tool supporting MCP
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-mcp-serve","level":3,"title":"ctx mcp serve","text":"

      Start the MCP server. This command reads JSON-RPC 2.0 requests from stdin and writes responses to stdout. It is intended to be launched by MCP clients (Claude Desktop, Cursor, VS Code Copilot), not run directly from a shell. See Configuration below for how each host launches it.

      Flags: None. The server uses the declared context directory from CTX_DIR. As with every other ctx command, that variable must be set: the server does not walk the filesystem.

      Examples:

      # Normal invocation (by an MCP client via stdio transport)\nctx mcp serve\n\n# Pin a context directory for a specific workspace\nCTX_DIR=/path/to/project/.context ctx mcp serve\n\n# Verify the binary starts without a client attached (Ctrl-C to exit)\nctx mcp serve < /dev/null\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#configuration","level":2,"title":"Configuration","text":"","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#claude-desktop","level":3,"title":"Claude Desktop","text":"

      Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

      {\n  \"mcpServers\": {\n    \"ctx\": {\n      \"command\": \"ctx\",\n      \"args\": [\"mcp\", \"serve\"]\n    }\n  }\n}\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#cursor","level":3,"title":"Cursor","text":"

      Add to .cursor/mcp.json in your project:

      {\n  \"mcpServers\": {\n    \"ctx\": {\n      \"command\": \"ctx\",\n      \"args\": [\"mcp\", \"serve\"]\n    }\n  }\n}\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#vs-code-copilot","level":3,"title":"VS Code (Copilot)","text":"

      Add to .vscode/mcp.json:

      {\n  \"servers\": {\n    \"ctx\": {\n      \"command\": \"ctx\",\n      \"args\": [\"mcp\", \"serve\"]\n    }\n  }\n}\n
      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resources","level":2,"title":"Resources","text":"

      Resources expose context files as read-only content. Each resource has a URI, name, and returns Markdown text.

      URI Name Description ctx://context/constitution constitution Hard rules that must never be violated ctx://context/tasks tasks Current work items and their status ctx://context/conventions conventions Code patterns and standards ctx://context/architecture architecture System architecture documentation ctx://context/decisions decisions Architectural decisions with rationale ctx://context/learnings learnings Gotchas, tips, and lessons learned ctx://context/glossary glossary Project-specific terminology ctx://context/agent agent All files assembled in priority read order

      The agent resource assembles all non-empty context files into a single Markdown document, ordered by the configured read priority.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resource-subscriptions","level":3,"title":"Resource Subscriptions","text":"

      Clients can subscribe to resource changes via resources/subscribe. The server polls for file mtime changes (default: 5 seconds) and emits notifications/resources/updated when a subscribed file changes on disk.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#tools","level":2,"title":"Tools","text":"

      Tools expose ctx commands as callable operations. Each tool accepts JSON arguments and returns text results.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_status","level":3,"title":"ctx_status","text":"

      Show context health: file count, token estimate, and per-file summary.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_add","level":3,"title":"ctx_add","text":"

      Add a task, decision, learning, or convention to the context.

      Argument Type Required Description type string Yes Entry type: task, decision, learning, convention content string Yes Title or main content priority string No Priority level (tasks only): high, medium, low context string Conditional Context field (decisions and learnings) rationale string Conditional Rationale (decisions only) consequence string Conditional Consequence (decisions only) lesson string Conditional Lesson learned (learnings only) application string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_complete","level":3,"title":"ctx_complete","text":"

      Mark a task as done by number or text match.

      Argument Type Required Description query string Yes Task number (e.g. \"1\") or search text","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_drift","level":3,"title":"ctx_drift","text":"

      Detect stale or invalid context. Returns violations, warnings, and passed checks.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_journal_source","level":3,"title":"ctx_journal_source","text":"

      Query recent AI session history (summaries, decisions, topics).

      Argument Type Required Description limit number No Max sessions to return (default: 5) since string No ISO date filter: sessions after this date (YYYY-MM-DD)

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_watch_update","level":3,"title":"ctx_watch_update","text":"

      Apply a structured context update to .context/ files. Supports task, decision, learning, convention, and complete entry types. Human confirmation is required before calling.

      Argument Type Required Description type string Yes Entry type: task, decision, learning, convention, complete content string Yes Main content context string Conditional Context background (decisions/learnings) rationale string Conditional Rationale (decisions only) consequence string Conditional Consequence (decisions only) lesson string Conditional Lesson learned (learnings only) application string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_compact","level":3,"title":"ctx_compact","text":"

      Move completed tasks to the archive section and remove empty sections from context files. Human confirmation required.

      Argument Type Required Description archive boolean No Also write tasks to .context/archive/ (default: false)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_next","level":3,"title":"ctx_next","text":"

      Suggest the next pending task based on priority and position.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_check_task_completion","level":3,"title":"ctx_check_task_completion","text":"

      Advisory check: after a write operation, detect if any pending tasks were silently completed. Returns nudge text if a match is found.

      Argument Type Required Description recent_action string No Brief description of what was just done

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_event","level":3,"title":"ctx_session_event","text":"

      Signal a session lifecycle event. Type end triggers the session-end persistence ceremony - human confirmation required.

      Argument Type Required Description type string Yes Event type: start, end caller string No Caller identifier (cursor, windsurf, vscode, claude-desktop)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_steering_get","level":3,"title":"ctx_steering_get","text":"

      Retrieve applicable steering files for a prompt. Without a prompt, returns always-included files only.

      Argument Type Required Description prompt string No Prompt text to match against steering file descriptions

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_search","level":3,"title":"ctx_search","text":"

      Search across .context/ files for a query string. Returns matching lines with file paths and line numbers.

      Argument Type Required Description query string Yes Search string to match against

      Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_start","level":3,"title":"ctx_session_start","text":"

      Execute session-start hooks and return aggregated context from hook outputs.

      Arguments: None.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_end","level":3,"title":"ctx_session_end","text":"

      Execute session-end hooks with an optional summary. Returns aggregated context from hook outputs.

      Argument Type Required Description summary string No Session summary passed to hook scripts","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_remind","level":3,"title":"ctx_remind","text":"

      List pending session-scoped reminders.

      Arguments: None. Read-only.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#prompts","level":2,"title":"Prompts","text":"

      Prompts provide pre-built templates for common workflows. Clients can list available prompts via prompts/list and retrieve a specific prompt via prompts/get.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-session-start","level":3,"title":"ctx-session-start","text":"

      Load full context at the beginning of a session. Returns all context files assembled in priority read order with session orientation instructions.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-decision-add","level":3,"title":"ctx-decision-add","text":"

      Format an architectural decision entry with all required fields.

      Argument Type Required Description content string Yes Decision title context string Yes Background context rationale string Yes Why this decision was made consequence string Yes Expected consequence","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-learning-add","level":3,"title":"ctx-learning-add","text":"

      Format a learning entry with all required fields.

      Argument Type Required Description content string Yes Learning title context string Yes Background context lesson string Yes The lesson learned application string Yes How to apply this lesson","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-reflect","level":3,"title":"ctx-reflect","text":"

      Guide end-of-session reflection. Returns a structured review prompt covering progress assessment and context update recommendations.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-checkpoint","level":3,"title":"ctx-checkpoint","text":"

      Report session statistics: tool calls made, entries added, and pending updates queued during the current session.

      ","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/memory/","level":1,"title":"Memory","text":"","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory","level":2,"title":"ctx memory","text":"

      Bridge Claude Code's auto memory (MEMORY.md) into .context/.

      Claude Code maintains per-project auto memory at ~/.claude/projects/<slug>/memory/MEMORY.md. This command group discovers that file, mirrors it into .context/memory/mirror.md (git-tracked), and detects drift.

      ctx memory <subcommand>\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-sync","level":3,"title":"ctx memory sync","text":"

      Copy MEMORY.md to .context/memory/mirror.md. Archives the previous mirror before overwriting.

      ctx memory sync [flags]\n

      Flags:

      Flag Description --dry-run Show what would happen without writing

      Exit codes:

      Code Meaning 0 Synced successfully 1 MEMORY.md not found (auto memory inactive)

      Examples:

      ctx memory sync\n# Archived previous mirror to mirror-2026-03-05-143022.md\n# Synced MEMORY.md -> .context/memory/mirror.md\n#   Source: ~/.claude/projects/-home-user-project/memory/MEMORY.md\n#   Lines: 47 (was 32)\n#   New content: 15 lines since last sync\n\nctx memory sync --dry-run\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-status","level":3,"title":"ctx memory status","text":"

      Show drift, timestamps, line counts, and archive count.

      ctx memory status\n

      Exit codes:

      Code Meaning 0 No drift 1 MEMORY.md not found 2 Drift detected (MEMORY.md changed since sync)

      Examples:

      ctx memory status\n# Memory Bridge Status\n#   Source:      ~/.claude/projects/.../memory/MEMORY.md\n#   Mirror:      .context/memory/mirror.md\n#   Last sync:   2026-03-05 14:30 (2 hours ago)\n#\n#   MEMORY.md:  47 lines (modified since last sync)\n#   Mirror:     32 lines\n#   Drift:      detected (source is newer)\n#   Archives:   3 snapshots in .context/memory/archive/\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-diff","level":3,"title":"ctx memory diff","text":"

      Show what changed in MEMORY.md since last sync.

      ctx memory diff\n

      Examples:

      ctx memory diff\n# --- .context/memory/mirror.md (mirror)\n# +++ ~/.claude/projects/.../memory/MEMORY.md (source)\n# +- new learning: memory bridge works\n

      No output when files are identical.

      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-publish","level":3,"title":"ctx memory publish","text":"

      Push curated .context/ content into MEMORY.md so the agent sees it natively.

      ctx memory publish [flags]\n

      Content is selected in priority order: pending tasks, recent decisions (7 days), key conventions, recent learnings (7 days). Wrapped in <!-- ctx:published --> markers. Claude-owned content outside the markers is preserved.

      Flags:

      Flag Description Default --budget Line budget for published content 80 --dry-run Show what would be published

      Examples:

      ctx memory publish --dry-run\n# Publishing .context/ -> MEMORY.md...\n#   Budget: 80 lines\n#   Published block:\n#     5 pending tasks (from TASKS.md)\n#     3 recent decisions (from DECISIONS.md)\n#     5 key conventions (from CONVENTIONS.md)\n#   Total: 42 lines (within 80-line budget)\n# Dry run - no files written.\n\nctx memory publish              # Write to MEMORY.md\nctx memory publish --budget 40  # Tighter budget\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-unpublish","level":3,"title":"ctx memory unpublish","text":"

      Remove the ctx-managed marker block from MEMORY.md, preserving Claude-owned content.

      Examples:

      ctx memory unpublish\n

      Hook integration: The check-memory-drift hook runs on every prompt and nudges the agent when MEMORY.md has changed since last sync. The nudge fires once per session. See Memory Bridge.

      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-import","level":3,"title":"ctx memory import","text":"

      Classify and promote entries from MEMORY.md into structured .context/ files.

      ctx memory import [flags]\n

      Each entry is classified by keyword heuristics:

      Keywords Target always use, prefer, never use, standard CONVENTIONS.md decided, chose, trade-off, approach DECISIONS.md gotcha, learned, watch out, bug, caveat LEARNINGS.md todo, need to, follow up TASKS.md Everything else Skipped

      Deduplication prevents re-importing the same entry across runs.

      Flags:

      Flag Description --dry-run Show classification plan without writing

      Examples:

      ctx memory import --dry-run\n# Scanning MEMORY.md for new entries...\n#   Found 6 entries\n#\n#   -> \"always use ctx from PATH\"\n#      Classified: CONVENTIONS.md (keywords: always use)\n#\n#   -> \"decided to use heuristic classification over LLM-based\"\n#      Classified: DECISIONS.md (keywords: decided)\n#\n# Dry run - would import: 4 entries\n# Skipped: 2 entries (session notes/unclassified)\n\nctx memory import    # Actually write entries to .context/ files\n
      ","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/message/","level":1,"title":"Message","text":"","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message","level":3,"title":"ctx hook message","text":"

      Manage hook message templates.

      Hook messages control the text hooks emit. The hook logic (when to fire, counting, state tracking) is universal; the messages are opinions that can be customized per-project.

      ctx hook message <subcommand>\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-list","level":3,"title":"ctx hook message list","text":"

      Show all hook messages with category and override status.

      ctx hook message list [--json]\n

      Flags:

      Flag Description --json Output in JSON format

      Example:

      ctx hook message list\nctx hook message list --json | jq '.[] | select(.override)'\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-show","level":3,"title":"ctx hook message show","text":"

      Print the effective message template for a hook/variant pair. Shows the user override if present, otherwise the embedded default.

      ctx hook message show <hook> <variant>\n

      Example:

      ctx hook message show qa-reminder gate\nctx hook message show check-context-size checkpoint\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-edit","level":3,"title":"ctx hook message edit","text":"

      Copy the embedded default template for <hook> <variant> to .context/hooks/messages/<hook>/<variant>.txt so you can edit it directly. The override takes effect the next time the hook fires.

      ctx hook message edit <hook> <variant>\n

      If an override already exists, the command fails and directs you to edit it in place or reset it first.

      Example:

      ctx hook message edit qa-reminder gate\n# Edit .context/hooks/messages/qa-reminder/gate.txt in your editor\n
      ","path":["Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-reset","level":3,"title":"ctx hook message reset","text":"

      Delete a user override and revert to the embedded default. Silent no-op if no override exists.

      ctx hook message reset <hook> <variant>\n

      Example:

      ctx hook message reset qa-reminder gate\n

      See Customizing hook messages for the full workflow.

      ","path":["Message"],"tags":[]},{"location":"cli/notify/","level":1,"title":"Notify","text":"","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify","level":2,"title":"ctx hook notify","text":"

      Send fire-and-forget webhook notifications from skills, loops, and hooks.

      ctx hook notify --event <name> [--session-id <id>] \"message\"\n

      Flags:

      Flag Short Description --event -e Event name (required) --session-id -s Session ID (optional)

      Behavior:

      • No webhook configured: silent no-op (exit 0)
      • Webhook set but event not in events list: silent no-op (exit 0)
      • Webhook set and event matches: fire-and-forget HTTP POST
      • HTTP errors silently ignored (no retry)

      Examples:

      ctx hook notify --event loop \"Loop completed after 5 iterations\"\nctx hook notify -e nudge -s session-abc \"Context checkpoint at prompt #20\"\n
      ","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-setup","level":3,"title":"ctx hook notify setup","text":"

      Configure the webhook URL interactively. The URL is encrypted with AES-256-GCM using the encryption key and stored in .context/.notify.enc.

      Examples:

      ctx hook notify setup\n

      The encrypted file is safe to commit. The key (~/.ctx/.ctx.key) lives outside the project and is never committed.

      ","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-test","level":3,"title":"ctx hook notify test","text":"

      Send a test notification and report the HTTP response status.

      Examples:

      ctx hook notify test\n

      Payload format (JSON POST):

      {\n  \"event\": \"loop\",\n  \"message\": \"Loop completed after 5 iterations\",\n  \"session_id\": \"abc123-...\",\n  \"timestamp\": \"2026-02-22T14:30:00Z\",\n  \"project\": \"ctx\"\n}\n
      Field Type Description event string Event name from --event flag message string Notification message session_id string Session ID (omitted if empty) timestamp string UTC RFC3339 timestamp project string Project directory name

      See also: Webhook Notifications recipe.

      ","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/pad/","level":1,"title":"Scratchpad","text":"","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad","level":2,"title":"ctx pad","text":"

      Encrypted scratchpad for sensitive one-liners that travel with the project.

      When invoked without a subcommand, lists all entries.

      ctx pad\nctx pad <subcommand>\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-add","level":3,"title":"ctx pad add","text":"

      Append a new entry to the scratchpad.

      ctx pad add <text>\nctx pad add <label> --file <path>\n

      Flags:

      Flag Short Description --file -f Ingest a file as a blob entry (max 64 KB)

      Examples:

      ctx pad add \"DATABASE_URL=postgres://user:pass@host/db\"\nctx pad add \"deploy config\" --file ./deploy.yaml\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-show","level":3,"title":"ctx pad show","text":"

      Output the raw text of an entry by number. For blob entries, prints decoded file content (or writes to disk with --out).

      ctx pad show <n>\nctx pad show <n> --out <path>\n

      Arguments:

      • n: 1-based entry number

      Flags:

      Flag Description --out Write decoded blob content to a file (blobs only)

      Examples:

      ctx pad show 3\nctx pad show 2 --out ./recovered.yaml\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-rm","level":3,"title":"ctx pad rm","text":"

      Remove one or more entries by stable ID. Supports individual IDs and ranges.

      ctx pad rm <id> [id...]\n

      Arguments:

      • id: One or more entry IDs (e.g., 3, 1 4, 3-5)

      Examples:

      ctx pad rm 2\nctx pad rm 1 4\nctx pad rm 3-5\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-normalize","level":3,"title":"ctx pad normalize","text":"

      Reassign entry IDs as a contiguous sequence 1..N, closing any gaps left by deletions.

      Examples:

      ctx pad normalize\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-edit","level":3,"title":"ctx pad edit","text":"

      Replace, append to, or prepend to an entry.

      ctx pad edit <n> [text]\n

      Arguments:

      • n: 1-based entry number
      • text: Replacement text (mutually exclusive with --append/--prepend)

      Flags:

      Flag Description --append Append text to the end of the entry --prepend Prepend text to the beginning of entry --file Replace blob file content (preserves label) --label Replace blob label (preserves content)

      Examples:

      ctx pad edit 2 \"new text\"\nctx pad edit 2 --append \" suffix\"\nctx pad edit 2 --prepend \"prefix \"\nctx pad edit 1 --file ./v2.yaml\nctx pad edit 1 --label \"new name\"\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-mv","level":3,"title":"ctx pad mv","text":"

      Move an entry from one position to another.

      ctx pad mv <from> <to>\n

      Arguments:

      • from: Source position (1-based)
      • to: Destination position (1-based)

      Examples:

      ctx pad mv 3 1      # promote entry 3 to the top\nctx pad mv 1 5      # bury entry 1 to position 5\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-resolve","level":3,"title":"ctx pad resolve","text":"

      Show both sides of a merge conflict in the encrypted scratchpad.

      Examples:

      ctx pad resolve\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-import","level":3,"title":"ctx pad import","text":"

      Bulk-import lines from a file into the scratchpad. Each non-empty line becomes a separate entry. All entries are written in a single encrypt/write cycle.

      With --blob, import all first-level files from a directory as blob entries. Each file becomes a blob with the filename as its label. Subdirectories and non-regular files are skipped.

      ctx pad import <file>\nctx pad import -              # read from stdin\nctx pad import --blob <dir>   # import directory files as blobs\n

      Arguments:

      • file: Path to a text file, - for stdin, or a directory (with --blob)

      Flags:

      Flag Description --blob Import first-level files from a directory as blobs

      Examples:

      ctx pad import notes.txt\ngrep TODO *.go | ctx pad import -\nctx pad import --blob ./ideas/\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-export","level":3,"title":"ctx pad export","text":"

      Export all blob entries from the scratchpad to a directory as files. Each blob's label becomes the filename. Non-blob entries are skipped.

      ctx pad export [dir]\n

      Arguments:

      • dir: Target directory (default: current directory)

      Flags:

      Flag Short Description --force -f Overwrite existing files instead of timestamping --dry-run Print what would be exported without writing

      When a file already exists, a unix timestamp is prepended to avoid collisions (e.g., 1739836200-label). Use --force to overwrite instead.

      Examples:

      ctx pad export ./ideas\nctx pad export --dry-run\nctx pad export --force ./backup\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-merge","level":3,"title":"ctx pad merge","text":"

      Merge entries from one or more scratchpad files into the current pad. Each input file is auto-detected as encrypted or plaintext. Entries are deduplicated by exact content.

      ctx pad merge FILE...\n

      Arguments:

      • FILE...: One or more scratchpad files to merge (encrypted or plaintext)

      Flags:

      Flag Short Description --key -k Path to key file for decrypting input files --dry-run Print what would be merged without writing

      Examples:

      ctx pad merge worktree/.context/scratchpad.enc\nctx pad merge notes.md backup.enc\nctx pad merge --key /path/to/other.key foreign.enc\nctx pad merge --dry-run pad-a.enc pad-b.md\n
      ","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pause/","level":1,"title":"Pause","text":"","path":["CLI","Sessions","Pause"],"tags":[]},{"location":"cli/pause/#ctx-hook-pause","level":2,"title":"ctx hook pause","text":"

      Pause all context nudge and reminder hooks for the current session. Security hooks (dangerous command blocking) and housekeeping hooks still fire.

      ctx hook pause [flags]\n

      Flags:

      Flag Description --session-id Session ID (overrides stdin)

      Example:

      # Pause hooks for a quick investigation\nctx hook pause\n\n# Resume when ready\nctx hook resume\n

      See also:

      • ctx hook resume: the matching resume command
      • Pausing Context Hooks recipe
      ","path":["CLI","Sessions","Pause"],"tags":[]},{"location":"cli/prune/","level":1,"title":"Prune","text":"","path":["CLI","Runtime","Prune"],"tags":[]},{"location":"cli/prune/#ctx-prune","level":3,"title":"ctx prune","text":"

      Remove per-session state files from .context/state/ that are older than the specified age. Session state files are identified by UUID suffixes (context-check-<session-id>, heartbeat-<session-id>, and similar). Global files without session IDs (events.jsonl, memory-import.json, and other non-per-session markers) are always preserved.

      ctx prune [flags]\n

      Flags:

      Flag Description --days Prune files older than this many days (default: 7) --dry-run Show what would be pruned without deleting

      Examples:

      ctx prune                 # Prune files older than 7 days\nctx prune --days 3        # Prune files older than 3 days\nctx prune --dry-run       # Preview without deleting\n

      See State maintenance for the recommended cadence and automation recipe.

      ","path":["CLI","Runtime","Prune"],"tags":[]},{"location":"cli/remind/","level":1,"title":"Remind","text":"","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind","level":2,"title":"ctx remind","text":"

      Session-scoped reminders that surface at session start. Reminders are stored verbatim and relayed verbatim: no summarization, no categories.

      When invoked with a text argument and no subcommand, adds a reminder.

      ctx remind \"text\"\nctx remind <subcommand>\n
      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-add","level":3,"title":"ctx remind add","text":"

      Add a reminder. This is the default action: ctx remind \"text\" and ctx remind add \"text\" are equivalent.

      ctx remind \"refactor the swagger definitions\"\nctx remind add \"check CI after the deploy\" --after 2026-02-25\n

      Arguments:

      • text: The reminder message (verbatim)

      Flags:

      Flag Short Description --after -a Don't surface until this date (YYYY-MM-DD)

      Examples:

      ctx remind \"refactor the swagger definitions\"\nctx remind \"check CI after the deploy\" --after 2026-02-25\n
      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-list","level":3,"title":"ctx remind list","text":"

      List all pending reminders. Date-gated reminders that aren't yet due are annotated with (after DATE, not yet due).

      Examples:

      ctx remind list\nctx remind ls            # alias\n

      Aliases: ls

      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-dismiss","level":3,"title":"ctx remind dismiss","text":"

      Remove one or more reminders by ID, or remove all with --all. Supports individual IDs and ranges.

      ctx remind dismiss <id> [id...]\nctx remind dismiss --all\n

      Arguments:

      • id: One or more reminder IDs (e.g., 3, 3 5-7)

      Flags:

      Flag Description --all Dismiss all reminders

      Aliases: rm

      Examples:

      ctx remind dismiss 3\nctx remind dismiss 3 5-7\nctx remind dismiss --all\n
      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-normalize","level":3,"title":"ctx remind normalize","text":"

      Reassign reminder IDs as a contiguous sequence 1..N, closing any gaps left by dismissals.

      Examples:

      ctx remind normalize\n

      See also: Session Reminders recipe.

      ","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/resume/","level":1,"title":"Resume","text":"","path":["CLI","Sessions","Resume"],"tags":[]},{"location":"cli/resume/#ctx-hook-resume","level":2,"title":"ctx hook resume","text":"

      Resume context hooks after a pause. Silent no-op if not paused.

      ctx hook resume [flags]\n

      Flags:

      Flag Description --session-id Session ID (overrides stdin)

      Example:

      ctx hook resume\n

      See also:

      • ctx hook pause: the matching pause command
      • Pausing Context Hooks recipe
      ","path":["CLI","Sessions","Resume"],"tags":[]},{"location":"cli/serve/","level":1,"title":"Serve","text":"","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#ctx-serve","level":2,"title":"ctx serve","text":"

      Serve a static site locally via zensical.

      With no argument, serves the journal site at .context/journal-site. With a directory argument, serves that directory if it contains a zensical.toml.

      ctx serve                             # Serve .context/journal-site\nctx serve ./my-site                   # Serve a specific directory\nctx serve ./docs                      # Serve any zensical site\n

      This Command Does NOT Start a Hub

      ctx serve is purely for static-site serving. To run a ctx Hub for cross-project knowledge sharing, use ctx hub start. That command lives in its own group because the hub is a gRPC server, not a static site.

      Requires zensical to be installed:

      pipx install zensical\n
      ","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#arguments","level":3,"title":"Arguments","text":"Argument Description [directory] Directory containing a zensical.toml to serve

      When omitted, serves .context/journal-site by default, the directory produced by ctx journal site.

      Examples:

      ctx serve                         # Default: serve .context/journal-site\nctx serve ./my-site               # Serve a specific directory\nctx serve ./docs                  # Serve any zensical site\n
      ","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#see-also","level":3,"title":"See Also","text":"
      • ctx journal: generate the journal site that ctx serve displays.
      • ctx hub start: for running a ctx Hub server, not a static site.
      • Browsing and enriching past sessions: the recipe that combines ctx journal and ctx serve.
      ","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/setup/","level":1,"title":"Setup","text":"","path":["CLI","Integrations","Setup"],"tags":[]},{"location":"cli/setup/#ctx-setup","level":2,"title":"ctx setup","text":"

      Generate AI tool integration configuration.

      ctx setup <tool> [flags]\n

      Flags:

      Flag Short Description --write -w Write the generated config to disk (e.g. .github/copilot-instructions.md)

      Supported tools:

      Tool Description claude-code Redirects to plugin install instructions cursor Cursor IDE kiro Kiro IDE cline Cline (VS Code extension) aider Aider CLI copilot GitHub Copilot windsurf Windsurf IDE

      Claude Code Uses the Plugin System

      Claude Code integration is now provided via the ctx plugin. Running ctx setup claude-code prints plugin install instructions.

      Examples:

      # Print hook instructions to stdout\nctx setup cursor\nctx setup aider\n\n# Generate and write .github/copilot-instructions.md\nctx setup copilot --write\n\n# Generate MCP config and sync steering files\nctx setup kiro --write\nctx setup cursor --write\nctx setup cline --write\n
      ","path":["CLI","Integrations","Setup"],"tags":[]},{"location":"cli/site/","level":1,"title":"Site","text":"","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/site/#ctx-site","level":2,"title":"ctx site","text":"

      Site management commands for the ctx.ist static site.

      ctx site <subcommand>\n
      ","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/site/#ctx-site-feed","level":3,"title":"ctx site feed","text":"

      Generate an Atom 1.0 feed from finalized blog posts in docs/blog/.

      ctx site feed [flags]\n

      Scans docs/blog/ for files matching YYYY-MM-DD-*.md, parses YAML frontmatter, and generates a valid Atom feed. Only posts with reviewed_and_finalized: true are included. Summaries are extracted from the first paragraph after the heading.

      Flags:

      Flag Short Type Default Description --out -o string site/feed.xml Output path --base-url string https://ctx.ist Base URL for entry links

      Output:

      Generated site/feed.xml (21 entries)\n\nSkipped:\n  2026-02-25-the-homework-problem.md: not finalized\n\nWarnings:\n  2026-02-09-defense-in-depth.md: no summary paragraph found\n

      Three buckets: included (count), skipped (with reason), warnings (included but degraded). exit 0 always: warnings inform but do not block.

      Frontmatter requirements:

      Field Required Feed mapping title Yes <title> date Yes <updated> reviewed_and_finalized Yes Draft gate (must be true) author No <author><name> topics No <category term=\"\">

      Examples:

      ctx site feed                                # Generate site/feed.xml\nctx site feed --out /tmp/feed.xml            # Custom output path\nctx site feed --base-url https://example.com # Custom base URL\nmake site-feed                               # Makefile shortcut\nmake site                                    # Builds site + feed\n
      ","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/skill/","level":1,"title":"Skill","text":"","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill","level":2,"title":"ctx skill","text":"

      Manage reusable instruction bundles that can be installed into .context/skills/.

      A skill is a directory containing a SKILL.md file with YAML frontmatter (name, description) and a Markdown instruction body. Skills are loaded by the agent context packet when --skill <name> is passed to ctx agent.

      ctx skill <subcommand>\n
      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-install","level":3,"title":"ctx skill install","text":"

      Install a skill from a source directory.

      ctx skill install <source>\n

      Arguments:

      • source: Path to a directory containing SKILL.md

      Examples:

      ctx skill install ./my-skills/code-review\n# Installed code-review → .context/skills/code-review\n
      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-list","level":3,"title":"ctx skill list","text":"

      List all installed skills.

      Examples:

      ctx skill list\n
      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-remove","level":3,"title":"ctx skill remove","text":"

      Remove an installed skill.

      Arguments:

      • name: Skill name to remove

      Examples:

      ctx skill remove code-review\n

      See also: Building Project Skills recipe.

      ","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/steering/","level":1,"title":"Steering","text":"","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering","level":2,"title":"ctx steering","text":"

      Manage steering files: persistent behavioral rules for AI coding assistants.

      A steering file is a small markdown document with YAML frontmatter that tells the AI how to behave in a specific context. ctx steering keeps those files in .context/steering/, decides which ones apply for a given prompt, and syncs them out to each AI tool's native format (Claude Code, Cursor, Kiro, Cline).

      ctx steering <subcommand>\n

      Steering vs Decisions vs Conventions

      The three look similar on disk but serve different purposes:

      • Decisions record what was chosen and why. Consumed mostly by humans (and by the agent via ctx agent).
      • Conventions describe how the codebase is written. Consumed as reference material.
      • Steering tells the AI how to behave when asked about X. Consumed by the AI tool's prompt injection layer, conditionally on prompt match.

      If you find yourself writing \"the AI should always do X\", that belongs in steering, not decisions.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#anatomy-of-a-steering-file","level":3,"title":"Anatomy of a Steering File","text":"
      ---\nname: security\ndescription: Security rules for all code changes\ninclusion: always    # always | auto | manual\ntools: []            # empty = all tools\npriority: 10         # lower = injected first\n---\n\n# Security rules\n\n- Validate all user input at system boundaries.\n- Never log secrets, tokens, or credentials.\n- Prefer constant-time comparison for tokens.\n

      Inclusion modes:

      Mode When it's included always Every prompt, unconditionally auto When the prompt matches the description keywords manual Only when the user names it explicitly

      Priority: lower numbers inject first, so high-priority rules appear at the top of the prompt. Default is 50.

      Tools: an empty list means all configured tools receive the file; list specific tool names to scope it.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-init","level":3,"title":"ctx steering init","text":"

      Create a starter set of steering files in .context/steering/ to use as a scaffolding baseline.

      Examples:

      ctx steering init\n
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-add","level":3,"title":"ctx steering add","text":"

      Create a new steering file with default frontmatter.

      ctx steering add <name>\n

      Arguments:

      • name: Steering file name (without .md extension)

      Examples:

      ctx steering add security\n# Created .context/steering/security.md\n

      The generated file uses inclusion: manual and priority: 50 by default. Edit the frontmatter to change behavior.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-list","level":3,"title":"ctx steering list","text":"

      List all steering files with their inclusion mode, priority, and tool scoping.

      Examples:

      ctx steering list\n
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-preview","level":3,"title":"ctx steering preview","text":"

      Preview which steering files would be included for a given prompt. Useful for validating auto-inclusion descriptions against realistic prompts.

      ctx steering preview [prompt]\n

      Examples:

      ctx steering preview \"create a REST API endpoint\"\n# Steering files matching prompt \"create a REST API endpoint\":\n#   api-standards        inclusion=auto     priority=20  tools=all\n#   security             inclusion=always   priority=10  tools=all\n
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-sync","level":3,"title":"ctx steering sync","text":"

      Sync steering files to tool-native formats for tools that have a built-in rules primitive. Not every tool needs this; Claude Code and Codex use a different delivery mechanism (see below).

      Examples:

      ctx steering sync\n

      Which tools are sync targets?

      Tool Sync target Mechanism Cursor .cursor/rules/ Cursor reads the directory natively Cline .clinerules/ Cline reads the directory natively Kiro .kiro/steering/ Kiro reads the directory natively Claude Code (no-op) Delivered via hook + MCP (see next section) Codex (no-op) Same as Claude Code

      For the three native-rules tools, ctx steering sync writes each matching steering file to the appropriate directory with tool-specific frontmatter transforms. Unchanged files are skipped (idempotent).

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#how-claude-code-and-codex-consume-steering","level":3,"title":"How Claude Code and Codex Consume Steering","text":"

      Claude Code has no native \"steering files\" primitive, so ctx steering sync skips it entirely. Instead, steering reaches Claude through two non-sync channels, both activated by ctx setup claude-code (which installs the plugin):

      1. Automatic injection via the PreToolUse hook. The Claude Code plugin wires a PreToolUse hook that runs ctx agent --budget 8000 before each tool call. ctx agent loads .context/steering/ and calls steering.Filter with an empty prompt, so only files with inclusion: always match. Those files are included as Tier 6 of the context packet. The packet is printed on stdout, which Claude Code injects as additional context. This fires on every tool call; no user action.

      2. On-demand MCP tool call (ctx_steering_get). The ctx plugin ships a .mcp.json file that automatically registers the ctx MCP server (ctx mcp serve) with Claude Code on plugin install. Once registered, Claude can invoke the ctx_steering_get tool mid-task to fetch matching steering files for a specific prompt. This is the only path that resolves inclusion: auto and inclusion: manual matches for Claude Code; Claude passes the prompt to the MCP tool, which runs the keyword match against each file's description.

      Verify the MCP server is registered:

      claude mcp list\n

      Expected line: ctx: ctx mcp serve - ✓ Connected. If it's missing, reinstall the plugin from Claude Code (/plugin → find ctx → uninstall → install again); older plugin versions shipped without the .mcp.json file.

      Prefer inclusion: always for Claude Code

      Because the PreToolUse hook passes an empty prompt to ctx agent, only always files fire automatically. auto files require Claude to call the ctx_steering_get MCP tool on its own; manual files require an explicit user invocation. For rules that should reliably fire on every Claude Code session, use inclusion: always. Reserve auto/manual for situational libraries where the opt-in cost is acceptable and you understand Claude may not pull them in without prompting.

      The foundation files scaffolded by ctx init already default to inclusion: always for this reason.

      Practical implications:

      • Running ctx steering sync before starting a Claude session does nothing for Claude's benefit. Skip it.
      • ctx steering preview still works for validating your descriptions; it doesn't depend on sync.
      • If Claude Code is your only tool, the ctx steering commands you care about are add, list, preview, init (never sync).
      • If you use both Claude Code and (say) Cursor, ctx steering sync covers Cursor (where auto and manual work natively) while the hook+MCP pipeline covers Claude Code. For rules you need to fire automatically on both, use inclusion: always.
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-agent-integration","level":3,"title":"ctx agent Integration","text":"

      When ctx agent builds a context packet, steering files are loaded as Tier 6 of the budget-aware assembly (see ctx agent). Files with inclusion: always are always included; auto files are scored against the current prompt and included in priority order until the tier budget is exhausted.

      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#see-also","level":3,"title":"See Also","text":"
      • ctx setup: configure which tools receive steering syncs
      • ctx trigger: lifecycle scripts (a different hooking concept, see below)
      • Building steering files recipe: walkthrough from first file to synced output
      ","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/sysinfo/","level":1,"title":"Sysinfo","text":"","path":["CLI","Diagnostics","Sysinfo"],"tags":[]},{"location":"cli/sysinfo/#ctx-sysinfo","level":3,"title":"ctx sysinfo","text":"

      Display a snapshot of system resources (memory, swap, disk, load) with threshold-based alert severities. Mirrors what the check-resource hook plumbing monitors in the background, but this command prints the full report at any severity level, not only at DANGER.

      ctx sysinfo [flags]\n

      Flags:

      Flag Description --json Output in JSON format

      Alert thresholds:

      Resource WARNING DANGER Memory ≥ 75% ≥ 90% Swap ≥ 50% ≥ 75% Disk ≥ 85% ≥ 95% Load ≥ 1.0x CPUs ≥ 1.5x CPUs

      Examples:

      ctx sysinfo                  # Human-readable table\nctx sysinfo --json           # Structured output\n
      ","path":["CLI","Diagnostics","Sysinfo"],"tags":[]},{"location":"cli/system/","level":1,"title":"System","text":"","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system","level":3,"title":"ctx system","text":"

      Hidden parent command that hosts Claude Code hook plumbing and a small set of session-lifecycle plumbing subcommands used by skills and editor integrations. The parent is registered without a visible group in ctx --help; run ctx system --help to see its subcommands.

      ctx system <subcommand>\n

      Commands Previously under ctx system

      Several user-facing maintenance commands used to live under ctx system and were promoted to top-level:

      • ctx system eventsctx hook event
      • ctx system messagectx hook message
      • ctx system prunectx prune
      • ctx system resourcesctx sysinfo
      • ctx system statsctx usage

      ctx system bootstrap remains under ctx system as a hidden, agent-only command. Update any scripts or personal docs that reference the old paths.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#plumbing-subcommands","level":2,"title":"Plumbing Subcommands","text":"

      These are not hook handlers; they're called by skills and editor integrations during the session lifecycle. Safe to run manually.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-journal","level":4,"title":"ctx system mark-journal","text":"

      Update processing state for a journal entry. Records the current date in .context/journal/.state.json. Used by journal skills to record pipeline progress.

      ctx system mark-journal <filename> <stage>\n

      Stages: exported, enriched, normalized, fences_verified

      Flag Description --check Check if stage is set (exit 1 if not)

      Example:

      ctx system mark-journal 2026-01-21-session-abc12345.md enriched\nctx system mark-journal 2026-01-21-session-abc12345.md normalized\nctx system mark-journal --check 2026-01-21-session-abc12345.md fences_verified\n
      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-wrapped-up","level":4,"title":"ctx system mark-wrapped-up","text":"

      Suppress context checkpoint nudges after a wrap-up ceremony. Writes a marker file that check-context-size checks before emitting checkpoint boxes. The marker expires after 2 hours.

      Called automatically by /ctx-wrap-up after persisting context (not intended for direct use).

      ctx system mark-wrapped-up\n

      No flags, no arguments. Idempotent: running it again updates the marker timestamp.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-pause-ctx-system-resume","level":4,"title":"ctx system pause / ctx system resume","text":"

      Session-scoped hook suppression. ctx system pause writes a marker file that causes hook plumbing to no-op for the current session; ctx system resume removes it. These are the hook-plumbing counterparts to the ctx hook pause / ctx hook resume commands (which call them internally).

      Read the session ID from stdin JSON (same as hooks) or pass --session-id.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-session-event","level":4,"title":"ctx system session-event","text":"

      Records a session lifecycle event (start or end) to the event log. Called by editor integrations when a workspace is opened or closed.

      ctx system session-event --type start --caller vscode\nctx system session-event --type end --caller vscode\n
      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#hook-subcommands","level":2,"title":"Hook Subcommands","text":"

      Hidden Claude Code hook handlers implementing the hook contract: read JSON from stdin, perform logic, emit output on stdout, exit 0. Block commands output JSON with a decision field.

      UserPromptSubmit hooks: context-load-gate, check-context-size, check-persistence, check-ceremony, check-journal, check-version, check-resource, check-knowledge, check-map-staleness, check-memory-drift, check-reminder, check-freshness, check-hub-sync, check-skill-discovery, heartbeat.

      PreToolUse hooks: block-non-path-ctx, block-dangerous-command, qa-reminder, specs-nudge.

      PostToolUse hooks: post-commit, check-task-completion.

      See AI Tools for registration details and the Claude Code plugin integration.

      ","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/trace/","level":1,"title":"Commit Context Tracing","text":"","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace","level":3,"title":"ctx trace","text":"

      Show the context behind git commits. Links commits back to the decisions, tasks, learnings, and sessions that motivated them.

      git log shows what changed, git blame shows who, and ctx trace shows why.

      ctx trace [commit] [flags]\n

      Flags:

      Flag Description --last N Show context for last N commits --json Output as JSON for scripting

      Examples:

      # Show context for a specific commit\nctx trace abc123\n\n# Show context for last 10 commits\nctx trace --last 10\n\n# JSON output\nctx trace abc123 --json\n

      Output:

      Commit: abc123 \"Fix auth token expiry\"\nDate:   2026-03-14 10:00:00 -0700\nContext:\n  [Decision] #12: Use short-lived tokens with server-side refresh\n    Date: 2026-03-10\n\n  [Task] #8: Implement token rotation for compliance\n    Status: completed\n

      When listing recent commits with --last:

      abc123  Fix auth token expiry         decision:12, task:8\ndef456  Add rate limiting             decision:15, learning:7\n789abc  Update dependencies           (none)\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-file","level":3,"title":"ctx trace file","text":"

      Show the context trail for a file. Combines git log with context resolution.

      ctx trace file <path[:line-range]> [flags]\n

      Flags:

      Flag Description --last N Maximum commits to show (default: 20)

      Examples:

      # Show context trail for a file\nctx trace file src/auth.go\n\n# Show context for specific line range\nctx trace file src/auth.go:42-60\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-tag","level":3,"title":"ctx trace tag","text":"

      Manually tag a commit with context. For commits made without the hook, or to add extra context after the fact.

      Tags are stored in .context/trace/overrides.jsonl since git trailers cannot be added to existing commits without rewriting history.

      ctx trace tag <commit> --note \"<text>\"\n

      Examples:

      ctx trace tag HEAD --note \"Hotfix for production outage\"\nctx trace tag abc123 --note \"Part of Q1 compliance initiative\"\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-hook","level":3,"title":"ctx trace hook","text":"

      Enable or disable the prepare-commit-msg hook for automatic context tracing. When enabled, commits automatically receive a ctx-context trailer with references to relevant decisions, tasks, learnings, and sessions.

      ctx trace hook <enable|disable>\n

      Prerequisites: ctx must be on your $PATH. If you installed via go install, ensure $GOPATH/bin (or $HOME/go/bin) is in your shell's $PATH.

      What the hook does:

      1. Before each commit, collects context from three sources:
      2. Pending context accumulated during work (ctx add, ctx task complete)
      3. Staged file changes to .context/ files
      4. Working state (in-progress tasks, active AI session)
      5. Injects a ctx-context trailer into the commit message
      6. After commit, records the mapping in .context/trace/history.jsonl

      Examples:

      # Install the hook\nctx trace hook enable\n\n# Remove the hook\nctx trace hook disable\n

      Resulting commit message:

      Fix auth token expiry handling\n\nRefactored token refresh logic to handle edge case\nwhere refresh token expires during request.\n\nctx-context: decision:12, task:8, session:abc123\n
      ","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#reference-types","level":3,"title":"Reference Types","text":"

      The ctx-context trailer supports these reference types:

      Prefix Points to Example decision:<n> Entry #n in DECISIONS.md decision:12 learning:<n> Entry #n in LEARNINGS.md learning:5 task:<n> Task #n in TASKS.md task:8 convention:<n> Entry #n in CONVENTIONS.md convention:3 session:<id> AI session by ID session:abc123 \"<text>\" Free-form context note \"Performance fix for P1 incident\"","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#storage","level":3,"title":"Storage","text":"

      Context trace data is stored in the .context/ directory:

      File Purpose Lifecycle state/pending-context.jsonl Accumulates refs during work Truncated after each commit trace/history.jsonl Permanent commit-to-context map Append-only, never truncated trace/overrides.jsonl Manual tags for existing commits Append-only","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trigger/","level":1,"title":"Trigger","text":"","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger","level":2,"title":"ctx trigger","text":"

      Manage lifecycle triggers: executable scripts that fire at specific events during an AI session. Triggers can block tool calls, inject context, and automate reactions: any side effect you want at session boundaries, tool boundaries, or file-save events.

      ctx trigger <subcommand>\n

      Triggers Execute Arbitrary Scripts

      A trigger is a shell script with the executable bit set. It runs with the same privileges as your AI tool and receives JSON input on stdin. Treat triggers like pre-commit hooks: only enable scripts you've read and understand. A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#where-triggers-live","level":3,"title":"Where Triggers Live","text":"

      Triggers live in .context/hooks/<trigger-type>/ as executable scripts. The on-disk directory name is still hooks/ for historical reasons even though the command is ctx trigger. Each script:

      • Reads a JSON payload from stdin.
      • Returns a JSON payload on stdout.
      • Returns a non-zero exit code to block or error.
      .context/\n└── hooks/\n    ├── session-start/\n    │   └── inject-context.sh\n    ├── pre-tool-use/\n    │   └── block-legacy.sh\n    └── post-tool-use/\n        └── record-edit.sh\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#trigger-types","level":3,"title":"Trigger Types","text":"Type Fires when session-start An AI session begins session-end An AI session ends pre-tool-use Before an AI tool call is executed post-tool-use After an AI tool call returns file-save When a file is saved context-add When a context entry is added","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#input-and-output-contract","level":3,"title":"Input and Output Contract","text":"

      Each trigger receives a JSON object on stdin with the event details. Minimal contract (fields vary by trigger type):

      {\n  \"type\": \"pre-tool-use\",\n  \"tool\": \"write_file\",\n  \"path\": \"src/auth.go\",\n  \"session_id\": \"abc123-...\"\n}\n

      The trigger may write a JSON object to stdout to influence behavior. Example for a blocking pre-tool-use trigger:

      {\n  \"action\": \"block\",\n  \"message\": \"Editing src/auth.go requires approval from #security\"\n}\n

      For non-blocking event loggers, simply read stdin and exit 0 without writing to stdout.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-add","level":3,"title":"ctx trigger add","text":"

      Create a new trigger script with a template. The generated file has a bash shebang, a stdin reader using jq, and a basic JSON output structure.

      ctx trigger add <trigger-type> <name>\n

      Arguments:

      • trigger-type: One of session-start, session-end, pre-tool-use, post-tool-use, file-save, context-add
      • name: Script name (without .sh extension)

      Examples:

      ctx trigger add session-start inject-context\n# Created .context/hooks/session-start/inject-context.sh\n\nctx trigger add pre-tool-use block-legacy\n# Created .context/hooks/pre-tool-use/block-legacy.sh\n

      The generated script is not executable by default. Enable it with ctx trigger enable after reviewing the contents.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-list","level":3,"title":"ctx trigger list","text":"

      List all discovered triggers, grouped by trigger type, with their enabled/disabled status.

      Examples:

      ctx trigger list\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-test","level":3,"title":"ctx trigger test","text":"

      Run all enabled triggers of a given type against a mock payload. Use --tool and --path to customize the mock input for tool-related events.

      ctx trigger test <trigger-type> [flags]\n

      Flags:

      Flag Description --tool Tool name to put in mock input --path File path to put in mock input

      Examples:

      ctx trigger test session-start\nctx trigger test pre-tool-use --tool write_file --path src/main.go\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-enable","level":3,"title":"ctx trigger enable","text":"

      Enable a trigger by setting its executable permission bit. Searches every trigger-type directory for a script matching <name>.

      ctx trigger enable <name>\n

      Examples:

      ctx trigger enable inject-context\n# Enabled .context/hooks/session-start/inject-context.sh\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-disable","level":3,"title":"ctx trigger disable","text":"

      Disable a trigger by clearing its executable permission bit. Searches every trigger-type directory for a script matching <name>.

      ctx trigger disable <name>\n

      Examples:

      ctx trigger disable inject-context\n# Disabled .context/hooks/session-start/inject-context.sh\n
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#three-hooking-concepts-in-ctx-dont-confuse-them","level":3,"title":"Three Hooking Concepts in ctx (Don't Confuse Them)","text":"

      This is a common source of confusion. ctx has three distinct hook-like layers, and they serve different purposes:

      Layer Owned by Where it runs Configured via ctx trigger You .context/hooks/<type>/*.sh ctx trigger add/enable ctx system hooks ctx itself built-in, called by ctx's own lifecycle internal (see ctx system --help) Claude Code hooks Claude Code .claude/settings.local.json edit JSON, or /ctx-sanitize-permissions

      Use ctx trigger when you want project-specific automation that your AI tool will run at lifecycle events. Use Claude Code hooks for tool-specific integrations that don't need to be portable across tools. ctx system hooks are not something you author; they're the internal nudge machinery that ships with ctx.

      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#see-also","level":3,"title":"See Also","text":"
      • ctx steering: persistent AI behavioral rules (a different concept; rules vs scripts)
      • Authoring triggers recipe: a full walkthrough with security guidance
      ","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/usage/","level":1,"title":"Usage","text":"","path":["CLI","Diagnostics","Usage"],"tags":[]},{"location":"cli/usage/#ctx-usage","level":3,"title":"ctx usage","text":"

      Display per-session token usage statistics from the local stats JSONL files written by the heartbeat hook. By default, shows the last 20 entries across all sessions. Use --follow to stream new entries as they arrive (like tail -f).

      ctx usage [flags]\n

      Flags:

      Flag Description -f, --follow Stream new entries as they arrive -s, --session Filter by session ID (prefix match) -n, --last Show last N entries (default: 20) -j, --json Output raw JSONL

      Examples:

      ctx usage                     # Last 20 entries across all sessions\nctx usage --follow            # Live stream (like tail -f)\nctx usage --session abc123    # Filter to one session\nctx usage --last 100 --json   # Last 100 as raw JSONL\n
      ","path":["CLI","Diagnostics","Usage"],"tags":[]},{"location":"cli/watch/","level":1,"title":"Watch","text":"","path":["CLI","Context","Watch"],"tags":[]},{"location":"cli/watch/#ctx-watch","level":2,"title":"ctx watch","text":"

      Watch for AI output and auto-apply context updates.

      Parses <context-update> XML commands from AI output and applies them to context files.

      ctx watch [flags]\n

      Flags:

      Flag Description --log <file> Log file to watch (default: stdin) --dry-run Preview updates without applying

      Examples:

      # Watch stdin\nai-tool | ctx watch\n\n# Watch a log file\nctx watch --log /path/to/ai-output.log\n\n# Preview without applying\nctx watch --dry-run\n
      ","path":["CLI","Context","Watch"],"tags":[]},{"location":"cli/why/","level":1,"title":"Why","text":"","path":["CLI","Getting Started","Why"],"tags":[]},{"location":"cli/why/#ctx-why","level":2,"title":"ctx why","text":"

      Read ctx's philosophy documents directly in the terminal.

      ctx why [DOCUMENT]\n

      Documents:

      Name Description manifesto The ctx Manifesto: creation, not code about About ctx: what it is and why it exists invariants Design invariants: properties that must hold

      Examples:

      # Interactive numbered menu\nctx why\n\n# Show a specific document\nctx why manifesto\nctx why about\nctx why invariants\n\n# Pipe to a pager\nctx why manifesto | less\n
      ","path":["CLI","Getting Started","Why"],"tags":[]},{"location":"home/","level":1,"title":"Home","text":"
      • ctx is not a prompt.
      • ctx is version-controlled cognitive state.

      ctx is the persistence layer for human-AI reasoning.

      Deterministic. Git-native. Human-readable. Local-first.

      Start here.

      Learn what ctx does, set it up, and run your first session.

      Pre-1.0: Moving Fast

      ctx is under active development. This website tracks the development branch, not the latest release:

      Some features described here may not exist in the binary you have installed.

      Expect rough edges.

      If something is missing or broken, open an issue.

      ","path":["Home"],"tags":[]},{"location":"home/#introduction","level":2,"title":"Introduction","text":"","path":["Home"],"tags":[]},{"location":"home/#about","level":3,"title":"About","text":"

      What ctx is, how it works, and why persistent context changes how you work with AI.

      ","path":["Home"],"tags":[]},{"location":"home/#is-it-right-for-me","level":3,"title":"Is It Right for Me?","text":"

      Good fit, not-so-good fit, and a 5-minute trial to find out for yourself.

      ","path":["Home"],"tags":[]},{"location":"home/#faq","level":3,"title":"FAQ","text":"

      Quick answers to the questions newcomers ask most about ctx, files, tooling, and trade-offs.

      ","path":["Home"],"tags":[]},{"location":"home/#get-started","level":2,"title":"Get Started","text":"","path":["Home"],"tags":[]},{"location":"home/#getting-started","level":3,"title":"Getting Started","text":"

      Install the binary, set up the plugin, and verify it works.

      ","path":["Home"],"tags":[]},{"location":"home/#your-first-session","level":3,"title":"Your First Session","text":"

      Step-by-step walkthrough from ctx init to verified recall.

      ","path":["Home"],"tags":[]},{"location":"home/#common-workflows","level":3,"title":"Common Workflows","text":"

      Day-to-day commands for tracking context, checking health, and browsing history.

      ","path":["Home"],"tags":[]},{"location":"home/#concepts","level":2,"title":"Concepts","text":"","path":["Home"],"tags":[]},{"location":"home/#context-files","level":3,"title":"Context Files","text":"

      What each .context/ file does. What's their purpose. How do we best leverage them.

      ","path":["Home"],"tags":[]},{"location":"home/#configuration","level":3,"title":"Configuration","text":"

      Flexible configuration: .ctxrc, environment variables, and CLI flags.

      ","path":["Home"],"tags":[]},{"location":"home/#hub","level":3,"title":"Hub","text":"

      A fan-out channel for decisions, learnings, conventions, and tasks that need to cross project boundaries, without replicating everything else.

      ","path":["Home"],"tags":[]},{"location":"home/#working-with-ai","level":2,"title":"Working with AI","text":"","path":["Home"],"tags":[]},{"location":"home/#prompting-guide","level":3,"title":"Prompting Guide","text":"

      Effective prompts for AI sessions with ctx.

      ","path":["Home"],"tags":[]},{"location":"home/#keeping-ai-honest","level":3,"title":"Keeping AI Honest","text":"

      AI agents confabulate: they invent history, claim familiarity with decisions never made, and sometimes declare tasks complete when they aren't. Tools and habits to push back.

      ","path":["Home"],"tags":[]},{"location":"home/#my-ai-keeps-making-the-same-mistakes","level":3,"title":"My AI Keeps Making the Same Mistakes","text":"

      Stop rediscovering the same bugs and dead-ends across sessions.

      ","path":["Home"],"tags":[]},{"location":"home/#joining-a-project","level":3,"title":"Joining a Project","text":"

      You inherited a .context/ directory. Get oriented fast: priority order, what to read first, how to ramp up.

      ","path":["Home"],"tags":[]},{"location":"home/#customization","level":2,"title":"Customization","text":"","path":["Home"],"tags":[]},{"location":"home/#steering-files","level":3,"title":"Steering Files","text":"

      Tell the assistant how to behave when a specific kind of prompt arrives.

      ","path":["Home"],"tags":[]},{"location":"home/#lifecycle-triggers","level":3,"title":"Lifecycle Triggers","text":"

      Make things happen at session boundaries: block dangerous tool calls, inject standup notes, log file saves.

      ","path":["Home"],"tags":[]},{"location":"home/#community","level":2,"title":"Community","text":"","path":["Home"],"tags":[]},{"location":"home/#ctx","level":3,"title":"#ctx","text":"

      We are the builders who care about durable context. Join the community. Hang out in IRC. Star ctx on GitHub.

      ","path":["Home"],"tags":[]},{"location":"home/#contributing","level":3,"title":"Contributing","text":"

      Development setup, project layout, and pull request process.

      ","path":["Home"],"tags":[]},{"location":"home/about/","level":1,"title":"About","text":"

      \"Creation, not code; Context, not prompts; Verification, not vibes.\"

      Read the ctx Manifesto →

      \"Without durable context, intelligence resets; with ctx, creation compounds.\"

      Without persistent memory, every session starts at zero; ctx makes sessions cumulative.

      Join the ctx Community →

      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#what-is-ctx","level":2,"title":"What Is ctx?","text":"

      ctx (Context) is a file-based system that enables AI coding assistants to persist project knowledge across sessions. It lives in a .context/ directory in your repo.

      • A session is interactive.
      • ctx enables cognitive continuity.
      • Cognitive continuity enables durable, symbiotic-like human-AI workflows.

      Context Files

      Context files let AI tools remember decisions, conventions, and learnings:

      Context files are explicit and versionable contracts between you and your agents.

      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#why-do-i-keep-re-explaining-my-codebase","level":2,"title":"Why Do I Keep Re-Explaining My Codebase?!?!","text":"

      You open a new AI session. The first thing you do is re-explain your project.

      Again.

      The architecture, the database choice, the naming conventions, the thing you tried last week that didn't work. You have said all of this before (maybe yesterday, maybe an hour ago), but the AI doesn't know that.

      • You explain the same architecture every session;
      • The AI suggests an approach you already rejected, again;
      • A decision you made three sessions ago gets relitigated from scratch;
      • You spend more time setting context than building features.

      This isn't AI failure: It is staleness.

      Without persistent memory, every session starts at zero.

      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#day-and-night","level":3,"title":"Day and Night","text":"

      ctx gives your AI a memory that persists across sessions:

      Without ctxWith ctx
      Session 12: Monday morning\n\nAI:  \"I'll scaffold a MySQL schema for this.\"\nYou: \"We use PostgreSQL.\"\n\nAI:  \"For auth, session-based would be simplest.\"\nYou: \"We decided on JWT.\"\n\nAI:  \"Endpoints in camelCase?\"\nYou: \"snake_case! Like the rest of the API!!!!!!\"\n\nYou: *scrolls up to copy an existing endpoint*\n\n20 minutes spent restoring decisions that already exist.\n
      Session 12: Monday morning\n\nYou:  \"Let's continue the auth implementation.\"\nAI:   \"Per DECISIONS.md (2026-02-12): JWT, not sessions: \n       The project uses PostgreSQL with JWT\n       authentication. The API follows snake_case conventions.\n       Last session you completed the login endpoint: the\n       registration endpoint is next on TASKS.md. Want me to\n       start there?\"\n\n0 minutes re-explaining. Straight to building.\n
      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#how-ctx-solves-this","level":3,"title":"How ctx Solves This","text":"

      ctx creates a .context/ directory in your project that stores structured knowledge files:

      File What It Remembers TASKS.md What you're working on and what's next DECISIONS.md Architectural choices and why you made them LEARNINGS.md Gotchas, bugs, things that didn't work CONVENTIONS.md Naming patterns, code style, project rules CONSTITUTION.md Hard rules the AI must never violate

      These files can version with your code in git:

      • They load automatically at the session start (via hooks in Claude Code, or manually with ctx agent for other tools).
      • The AI reads them, cites them, and builds on them, instead of asking you to start over.
        • And when it acts, it can point to the exact file and line that justifies the choice.

      Every decision you record, every lesson you capture, makes the next session smarter.

      ctx accumulates.

      Connect with ctx

      • Join the Community →: ask questions, share workflows, and help shape what comes next
      • Read the Blog →: real-world patterns, ponderings, and lessons learned from building ctx using ctx

      Ready to Get Started?

      • Getting Started →: full installation and setup
      • Your First Session →: step-by-step walkthrough from ctx init to verified recall
      ","path":["Home","Introduction","About"],"tags":[]},{"location":"home/common-workflows/","level":1,"title":"Common Workflows","text":"

      The commands below cover what you'll use most often:

      • recording context,
      • checking health,
      • browsing history,
      • and running loops.

      Each section is a self-contained snippet you can copy into your terminal.

      For deeper, step-by-step guides, see Recipes.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#track-context","level":2,"title":"Track Context","text":"

      Prefer Skills over Raw Commands

      When working with an AI agent, use /ctx-task-add, /ctx-decision-add, or /ctx-learning-add instead of raw ctx add commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.

      # Add a task\nctx task add \"Implement user authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Record a decision (full ADR fields required)\nctx decision add \"Use PostgreSQL for primary database\" \\\n  --context \"Need a reliable database for production\" \\\n  --rationale \"PostgreSQL offers ACID compliance and JSON support\" \\\n  --consequence \"Team needs PostgreSQL training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Note a learning\nctx learning add \"Mock functions must be hoisted in Jest\" \\\n  --context \"Tests failed with undefined mock errors\" \\\n  --lesson \"Jest hoists mock calls to top of file\" \\\n  --application \"Place jest.mock() before imports\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Mark task complete\nctx task complete \"user auth\"\n
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#leave-a-reminder-for-next-session","level":2,"title":"Leave a Reminder for Next Session","text":"

      Drop a note that surfaces automatically at the start of your next session:

      # Leave a reminder\nctx remind \"refactor the swagger definitions\"\n\n# Date-gated: don't surface until a specific date\nctx remind \"check CI after the deploy\" --after 2026-02-25\n\n# List pending reminders\nctx remind list\n\n# Dismiss reminders by ID (supports ranges)\nctx remind dismiss 1\nctx remind dismiss 3 5-7\n

      Reminders are relayed verbatim at session start by the check-reminders hook and repeat every session until you dismiss them.

      See Session Reminders for the full recipe.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#check-context-health","level":2,"title":"Check Context Health","text":"
      # Detect stale paths, missing files, potential secrets\nctx drift\n\n# See full context summary\nctx status\n
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#browse-session-history","level":2,"title":"Browse Session History","text":"

      List and search past AI sessions from the terminal:

      ctx journal source --limit 5\n
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#journal-site","level":3,"title":"Journal Site","text":"

      Import session transcripts to a browsable static site with search, navigation, and topic indices.

      The ctx journal command requires zensical (Python >= 3.10).

      zensical is a Python-based static site generator from the Material for MkDocs team.

      (why zensical?).

      If you don't have it on your system, install zensical once with pipx:

      # One-time setup\npipx install zensical\n

      Avoid pip install zensical

      pip install often fails: For example, on macOS, system Python installs a non-functional stub (zensical requires Python >= 3.10), and Homebrew Python blocks system-wide installs (PEP 668).

      pipx creates an isolated environment with the correct Python version automatically.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#import-and-serve","level":3,"title":"Import and Serve","text":"

      Then, import and serve:

      # Import all sessions to .context/journal/ (only new files)\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n

      Open http://localhost:8000 to browse.

      To update after new sessions, run the same two commands again.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#safe-by-default","level":3,"title":"Safe by Default","text":"

      ctx journal import --all is safe by default:

      • It only imports new sessions and skips existing files.
      • Locked entries (via ctx journal lock) are always skipped by both import and enrichment skills.
      • If you add locked: true to frontmatter during enrichment, run ctx journal sync to propagate the lock state to .state.json.
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#re-importing-existing-files","level":3,"title":"Re-Importing Existing Files","text":"

      Here is how you regenerate existing files.

      Backup your .context folder before regeneration, as this is a potentially destructive action.

      To re-import journal files, you need to explicitly opt-in using the --regenerate flag:

      Flag combination Frontmatter Body --regenerate Preserved Overwritten from source --regenerate --keep-frontmatter=false Overwritten Overwritten

      Regeneration Overwrites Body Edits

      --regenerate preserves your YAML frontmatter (tags, summary, enrichment metadata) but it replaces the Markdown body with a fresh import.

      Any manual edits you made to the transcript will be lost.

      Lock entries you want to protect first: ctx journal lock <session-id>.

      See Session Journal for the full pipeline including normalization and enrichment.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#scratchpad","level":2,"title":"Scratchpad","text":"

      Store short, sensitive one-liners in an encrypted scratchpad that travels with the project:

      # Write a note\nctx pad set db-password \"postgres://user:pass@localhost/mydb\"\n\n# Read it back\nctx pad get db-password\n\n# List all keys\nctx pad list\n

      The scratchpad is encrypted with a key stored at ~/.ctx/.ctx.key (outside the project, never committed).

      See Scratchpad for details.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#run-an-autonomous-loop","level":2,"title":"Run an Autonomous Loop","text":"

      Generate a script that iterates an AI agent until a completion signal is detected:

      ctx loop\nchmod +x loop.sh\n./loop.sh\n

      See Autonomous Loops for configuration and advanced usage.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#trace-commit-context","level":2,"title":"Trace Commit Context","text":"

      Link your git commits back to the decisions, tasks, and learnings that motivated them. Enable the hook once:

      # Install the git hook (one-time setup)\nctx trace hook enable\n

      From now on, every git commit automatically gets a ctx-context trailer linking it to relevant context. No extra steps needed; just use ctx add, ctx task complete, and commit as usual.

      # Later: why was this commit made?\nctx trace abc123\n\n# Recent commits with their context\nctx trace --last 10\n\n# Context trail for a specific file\nctx trace file src/auth.go\n\n# Manually tag a commit after the fact\nctx trace tag HEAD --note \"Hotfix for production outage\"\n

      To stop: ctx trace hook disable.

      See CLI Reference: trace for details.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#agent-session-start","level":2,"title":"Agent Session Start","text":"

      The first thing an AI agent should do at session start is discover where context lives:

      ctx system bootstrap\n

      This prints the resolved context directory, the files in it, and the operating rules. The CLAUDE.md template instructs the agent to run this automatically. See CLI Reference: bootstrap.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#the-two-skills-you-should-always-use","level":2,"title":"The Two Skills You Should Always Use","text":"

      Using /ctx-remember at session start and /ctx-wrap-up at session end are the highest-value skills in the entire catalog:

      # session begins:\n/ctx-remember\n... do work ...\n# before closing the session:\n/ctx-wrap-up\n

      Let's provide some context, because this is important:

      Although the agent will eventually discover your context through CLAUDE.md → AGENT_PLAYBOOK.md, /ctx-remember hydrates the full context up front (tasks, decisions, recent sessions) so the agent starts informed rather than piecing things together over several turns.

      /ctx-wrap-up is the other half: A structured review that captures learnings, decisions, and tasks before you close the window.

      Hooks like check-persistence remind you (the user) mid-session that context hasn't been saved in a while, but they don't trigger persistence automatically: You still have to act. Also, a CTRL+C can end things at any moment with no reliable \"before session end\" event.

      In short, /ctx-wrap-up is the deliberate checkpoint that makes sure nothing slips through. And /ctx-remember it its mirror skill to be used at session start.

      See Session Ceremonies for the full workflow.

      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#cli-commands-vs-ai-skills","level":2,"title":"CLI Commands vs. AI Skills","text":"

      Most ctx operations come in two flavors: a CLI command you run in your terminal and an AI skill (slash command) you invoke inside your coding assistant.

      Commands and skills are not interchangeable: Each has a distinct role.

      ctx CLI command ctx AI skill Runs where Your terminal Inside the AI assistant Speed Fast (milliseconds) Slower (LLM round-trip) Cost Free Consumes tokens and context Analysis Deterministic heuristics Semantic / judgment-based Best for Quick checks, scripting, CI Deep analysis, generation, workflow orchestration","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#paired-commands","level":3,"title":"Paired Commands","text":"

      These have both a CLI and a skill counterpart. Use the CLI for quick, deterministic checks; use the skill when you need the agent's judgment.

      CLI Skill When to prefer the skill ctx drift /ctx-drift Semantic analysis: catches meaning drift the CLI misses ctx status /ctx-status Interpreted summary with recommendations ctx task add /ctx-task-add Agent decomposes vague goals into concrete tasks ctx decision add /ctx-decision-add Agent drafts rationale and consequences from discussion ctx learning add /ctx-learning-add Agent extracts the lesson from a debugging session ctx convention add /ctx-convention-add Agent observes a repeated pattern and codifies it ctx task archive /ctx-archive Agent reviews which tasks are truly done ctx pad /ctx-pad Agent reads/writes scratchpad entries in conversation flow ctx journal /ctx-history Agent searches session history with semantic understanding ctx agent /ctx-agent Agent loads and acts on the context packet ctx loop /ctx-loop Agent tailors the loop script to your project ctx doctor /ctx-doctor Agent adds semantic analysis to structural checks ctx hook pause /ctx-pause Agent pauses hooks with session-aware reasoning ctx hook resume /ctx-resume Agent resumes hooks after a pause ctx remind /ctx-remind Agent manages reminders in conversation flow","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#ai-only-skills","level":3,"title":"AI-Only Skills","text":"

      These have no CLI equivalent. They require the agent's reasoning.

      Skill Purpose /ctx-remember Load context and present structured readback at session start /ctx-wrap-up End-of-session ceremony: persist learnings, decisions, tasks /ctx-next Suggest 1-3 concrete next actions from context /ctx-commit Commit with integrated context capture /ctx-reflect Pause and assess session progress /ctx-consolidate Merge overlapping learnings or decisions /ctx-prompt-audit Analyze prompting patterns for improvement /ctx-plan Stress-test an existing plan through adversarial interview /ctx-plan-import Import Claude Code plan files into project specs /ctx-implement Execute a plan step-by-step with verification /ctx-worktree Manage parallel agent worktrees /ctx-journal-enrich Add metadata, tags, and summaries to journal entries /ctx-journal-enrich-all Full journal pipeline: export if needed, then batch-enrich /ctx-blog Generate a blog post (zensical-flavored Markdown) /ctx-blog-changelog Generate themed blog post from commits between releases /ctx-architecture Build and maintain architecture maps (ARCHITECTURE.md, DETAILED_DESIGN.md)","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#cli-only-commands","level":3,"title":"CLI-Only Commands","text":"

      These are infrastructure: used in scripts, CI, or one-time setup.

      Command Purpose ctx init Initialize .context/ directory ctx load Output assembled context for piping ctx task complete Mark a task done by substring match ctx sync Reconcile context with codebase state ctx compact Consolidate and clean up context files ctx trace Show context behind git commits ctx trace hook Enable/disable commit context tracing hook ctx setup Generate AI tool integration config ctx watch Watch AI output and auto-apply context updates ctx serve Serve any zensical directory (default: journal) ctx permission snapshot Save settings as a golden image ctx permission restore Restore settings from golden image ctx journal site Generate browsable journal from exports ctx hook notify setup Configure webhook notifications ctx decision List and filter decisions ctx learning List and filter learnings ctx task List tasks, manage archival and snapshots ctx why Read the philosophy behind ctx ctx guide Quick-reference cheat sheet ctx site Site management commands ctx config Manage runtime configuration profiles ctx system System diagnostics and hook commands ctx completion Generate shell autocompletion scripts

      Rule of Thumb

      Quick check? Use the CLI.

      Need judgment? Use the skill.

      When in doubt, start with the CLI: It's free and instant.

      Escalate to the skill when heuristics aren't enough.

      Next Up: Context Files →: what each .context/ file does and how to use it

      See Also:

      • Recipes: targeted how-to guides for specific tasks
      • Knowledge Capture: patterns for recording decisions, learnings, and conventions
      • Context Health: keeping your .context/ accurate and drift-free
      • Session Archaeology: digging into past sessions
      • Task Management: tracking and completing work items
      ","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/community/","level":1,"title":"#ctx","text":"

      Open source is better together.

      We are the builders who care about durable context, verifiable decisions, and human-AI workflows that compound over time.

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#help-ctx-change-how-ai-remembers","level":2,"title":"Help ctx Change How AI Remembers","text":"

      If you like the idea, a star helps ctx reach engineers who run into context drift every day:

      Star ctx on GitHub ⭐

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#ctx-you","level":2,"title":"ctx ♥️ You","text":"

      Join the community to ask questions, share feedback, and connect with other users:

      • Discord join the ctx Discord: Real-time discussion, field notes, and early ideas.
      • Read the ctx Source on GitHub: Issues, discussions, and contributions.
      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#want-to-contribute","level":2,"title":"Want to Contribute?","text":"

      Early adopters shape the conventions.

      ctx is free and open source software.

      Contributions are always welcome and appreciated.

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#code-of-conduct","level":2,"title":"Code of Conduct","text":"

      Clear context requires respectful collaboration.

      ctx follows the Contributor Covenant.

      ","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/configuration/","level":1,"title":"Configuration","text":"","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#configuration","level":2,"title":"Configuration","text":"

      ctx uses three layers of configuration. Each layer overrides the one below it:

      1. CLI flags: Per-invocation overrides (highest priority)
      2. Environment variables: Shell or CI/CD overrides
      3. The .ctxrc file: Project-level defaults (YAML)
      4. Built-in defaults: Hardcoded fallbacks (lowest priority)

      All settings are optional: If nothing is configured, ctx works out of the box with sensible defaults.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#the-ctxrc-file","level":2,"title":"The .ctxrc File","text":"

      The .ctxrc file is an optional YAML file placed in the project root (next to your .context/ directory). It lets you set project-level defaults that apply to every ctx command.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#location","level":3,"title":"Location","text":"
      my-project/\n├── .ctxrc              ← configuration file\n├── .context/\n│   ├── TASKS.md\n│   ├── DECISIONS.md\n│   └── ...\n└── src/\n

      ctx reads .ctxrc from the project root (i.e. the parent of CTX_DIR, or dirname(CTX_DIR)/.ctxrc). It does not walk up from CWD. That means whichever project you've activated via eval \"$(ctx activate)\" (or by exporting CTX_DIR directly), its paired .ctxrc is what governs the invocation. There is no global or user-level config file: configuration is always per-project.

      Contributors: Dev Configuration Profile

      The ctx repo ships two .ctxrc source profiles (.ctxrc.base and .ctxrc.dev). The working copy is gitignored and swapped between them via ctx config switch dev / ctx config switch base. See Contributing: Configuration Profiles.

      Using a Different .context Directory

      You point ctx at a .context/ directory by setting the CTX_DIR environment variable, not through .ctxrc. ctx does not search the filesystem. Use eval \"$(ctx activate)\" to bind CTX_DIR for your shell. CTX_DIR must be an absolute path with .context as its basename.

      See Environment Variables below for details.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#full-reference","level":3,"title":"Full Reference","text":"

      A commented .ctxrc showing all options and their defaults:

      # .ctxrc: ctx runtime configuration\n# https://ctx.ist/configuration/\n#\n# All settings are optional. Missing values use defaults.\n# Priority: CLI flags > environment variables > .ctxrc > defaults\n#\n# token_budget: 8000\n# auto_archive: true\n# archive_after_days: 7\n# scratchpad_encrypt: true\n# event_log: false\n# entry_count_learnings: 30\n# entry_count_decisions: 20\n# convention_line_count: 200\n# injection_token_warn: 15000\n# context_window: 200000      # auto-detected for Claude Code; override for other tools\n# billing_token_warn: 0       # one-shot warning at this token count (0 = disabled)\n#\n# stale_age_days: 30      # days before drift flags a context file as stale (0 = disabled)\n# key_rotation_days: 90\n# task_nudge_interval: 5   # Edit/Write calls between task completion nudges\n#\n# notify:               # requires: ctx hook notify setup\n#   events:             # required: no events sent unless listed\n#     - loop\n#     - nudge\n#     - relay\n#\n# tool: \"\"              # Active AI tool: claude, cursor, cline, kiro, codex\n#\n# steering:             # Steering layer configuration\n#   dir: .context/steering\n#   default_inclusion: manual\n#   default_tools: []\n#\n# hooks:                # Hook system configuration\n#   dir: .context/hooks\n#   timeout: 10\n#   enabled: true\n#\n# provenance_required:  # Relax provenance flags for ctx add\n#   session_id: true    # Require --session-id (default: true)\n#   branch: true        # Require --branch (default: true)\n#   commit: true        # Require --commit (default: true)\n#\n# priority_order:\n#   - CONSTITUTION.md\n#   - TASKS.md\n#   - CONVENTIONS.md\n#   - ARCHITECTURE.md\n#   - DECISIONS.md\n#   - LEARNINGS.md\n#   - GLOSSARY.md\n#   - AGENT_PLAYBOOK.md\n
      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#option-reference","level":3,"title":"Option Reference","text":"Option Type Default Description token_budget int 8000 Default token budget for ctx agent and ctx load auto_archive bool true Auto-archive completed tasks during ctx compact archive_after_days int 7 Days before completed tasks are archived scratchpad_encrypt bool true Encrypt scratchpad with AES-256-GCM event_log bool false Enable local hook event logging to .context/state/events.jsonl entry_count_learnings int 30 Drift warning when LEARNINGS.md exceeds this entry count (0 = disable) entry_count_decisions int 20 Drift warning when DECISIONS.md exceeds this entry count (0 = disable) convention_line_count int 200 Drift warning when CONVENTIONS.md exceeds this line count (0 = disable) injection_token_warn int 15000 Warn when auto-injected context exceeds this token count (0 = disable) context_window int 200000 Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools billing_token_warn int 0 (off) One-shot warning when session tokens exceed this threshold (0 = disabled). For plans where tokens beyond an included allowance cost extra stale_age_days int 30 Days before ctx drift flags a context file as stale (0 = disable) key_rotation_days int 90 Days before encryption key rotation nudge task_nudge_interval int 5 Edit/Write calls between task completion nudges notify.events []string (all) Event filter for webhook notifications (empty = all) priority_order []string (see below) Custom file loading priority for context assembly tool string (empty) Active AI tool identifier (claude, cursor, cline, kiro, codex). Used by steering sync and hook dispatch steering.dir string .context/steering Steering files directory steering.default_inclusion string manual Default inclusion mode for new steering files (always, auto, manual) steering.default_tools []string (all) Default tool filter for new steering files (empty = all tools) hooks.dir string .context/hooks Hook scripts directory hooks.timeout int 10 Per-hook execution timeout in seconds hooks.enabled bool true Whether hook execution is enabled provenance_required.session_id bool true Require --session-id on ctx add for tasks, decisions, learnings provenance_required.branch bool true Require --branch on ctx add for tasks, decisions, learnings provenance_required.commit bool true Require --commit on ctx add for tasks, decisions, learnings

      Default priority order (used when priority_order is not set):

      1. CONSTITUTION.md
      2. TASKS.md
      3. CONVENTIONS.md
      4. ARCHITECTURE.md
      5. DECISIONS.md
      6. LEARNINGS.md
      7. GLOSSARY.md
      8. AGENT_PLAYBOOK.md

      See Context Files for the rationale behind this ordering.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#environment-variables","level":2,"title":"Environment Variables","text":"

      Environment variables override .ctxrc values but are overridden by CLI flags.

      Variable Description Equivalent .ctxrc key CTX_DIR Declare the context directory path (required, no fallback) (none) CTX_TOKEN_BUDGET Override the default token budget token_budget","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples","level":3,"title":"Examples","text":"
      # Use a shared context directory\nCTX_DIR=/shared/team-context ctx status\n\n# Increase token budget for a single run\nCTX_TOKEN_BUDGET=16000 ctx agent\n
      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#cli-global-flags","level":2,"title":"CLI Global Flags","text":"

      CLI flags have the highest priority and override both environment variables and .ctxrc settings. These flags are available on every ctx command.

      Flag Description --tool <name> Override active AI tool identifier (e.g. kiro, cursor) --version Show version and exit --help Show command help and exit","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples_1","level":3,"title":"Examples","text":"
      # Point to a different context directory inline:\nCTX_DIR=/path/to/project/.context ctx status\n
      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#priority-order","level":2,"title":"Priority Order","text":"

      When the same setting is configured in multiple layers, the highest-priority layer wins:

      CLI flags  >  Environment variables  >  .ctxrc  >  Built-in defaults\n(highest)                                          (lowest)\n

      The context directory itself is resolved differently: it lives outside this priority chain. CTX_DIR (env) must be declared; .ctxrc does not carry a fallback for it, and there is no built-in default. See Activating a Context Directory.

      Example resolution for token_budget:

      Layer Value Wins? CTX_TOKEN_BUDGET 4000 Yes .ctxrc 8000 No Default 8000 No","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples_2","level":2,"title":"Examples","text":"","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#external-context-directory","level":3,"title":"External .context Directory","text":"

      Store a project's context outside the project tree (useful when a repo is read-only, or when you want to keep notes adjacent rather than checked in). Declare the path via CTX_DIR:

      export CTX_DIR=/home/you/ctx-stores/my-project/.context\n

      One .context/ per project

      The parent of the context directory is the project root by contract: ctx sync, ctx drift, and the memory-drift hook all read the codebase from filepath.Dir(ContextDir()). Pointing two projects at the same .context/ directory will collide their journals, state, and secrets. To share knowledge (CONSTITUTION / CONVENTIONS / ARCHITECTURE) across projects, use ctx hub, not a shared .context/.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-token-budget","level":3,"title":"Custom Token Budget","text":"

      Increase the token budget for projects with large context:

      # .ctxrc\ntoken_budget: 16000\n

      This affects the default budget for ctx agent and ctx load. You can still override per-invocation with ctx agent --budget 4000.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#disabled-scratchpad-encryption","level":3,"title":"Disabled Scratchpad Encryption","text":"

      Turn off encryption for the scratchpad (useful in ephemeral environments where key management is unnecessary):

      # .ctxrc\nscratchpad_encrypt: false\n

      Unencrypted Scratchpads Store Secrets in Plaintext

      Only disable encryption if you understand the security implications.

      The scratchpad may contain sensitive data such as API keys, database URLs, or deployment credentials.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-priority-order","level":3,"title":"Custom Priority Order","text":"

      Reorder context files to prioritize architecture over conventions:

      # .ctxrc\npriority_order:\n  - CONSTITUTION.md\n  - TASKS.md\n  - ARCHITECTURE.md\n  - DECISIONS.md\n  - CONVENTIONS.md\n  - LEARNINGS.md\n  - GLOSSARY.md\n  - AGENT_PLAYBOOK.md\n

      Files not listed in priority_order receive the lowest priority (100). The order affects ctx agent, ctx load, and drift's file-priority calculations.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#billing-token-threshold","level":3,"title":"Billing Token Threshold","text":"

      Get a one-shot warning when your session crosses a token threshold where extra charges begin (e.g., Claude Pro includes 200k tokens; beyond that costs extra):

      # .ctxrc\nbilling_token_warn: 180000   # warn before hitting the 200k paid boundary\n

      The warning fires once per session the first time token usage exceeds the threshold. Set to 0 (or omit) to disable.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#adjusted-drift-thresholds","level":3,"title":"Adjusted Drift Thresholds","text":"

      Raise or lower the entry-count thresholds that trigger drift warnings:

      # .ctxrc\nentry_count_learnings: 50   # warn above 50 learnings (default: 30)\nentry_count_decisions: 10   # warn above 10 decisions (default: 20)\nconvention_line_count: 300  # warn above 300 lines (default: 200)\n

      Set any threshold to 0 to disable that specific check.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"

      Get notified when loops complete, hooks fire, or agents reach milestones:

      # Configure the webhook URL (encrypted, safe to commit)\nctx hook notify setup\n\n# Test delivery\nctx hook notify test\n

      Filter which events reach your webhook:

      # .ctxrc\nnotify:\n  events:\n    - loop      # loop completion/max-iteration\n    - nudge     # VERBATIM relay hooks fired\n    # - relay   # all hook output (verbose, for debugging)\n    # - heartbeat  # every-prompt session-alive signal\n

      Notifications are opt-in: No events are sent unless explicitly listed.

      See Webhook Notifications for a step-by-step recipe.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#hook-message-overrides","level":2,"title":"Hook Message Overrides","text":"

      Hook messages control what text hooks emit when they fire. Each message can be overridden per-project by placing a text file at the matching path under .context/:

      .context/hooks/messages/{hook}/{variant}.txt\n

      The override takes priority over the embedded default compiled into the ctx binary. An empty file silences the message while preserving the hook's logic (counting, state tracking, cooldowns).

      Use ctx hook message to discover and manage overrides:

      ctx hook message list                      # see all messages\nctx hook message show qa-reminder gate     # view the current template\nctx hook message edit qa-reminder gate     # copy default for editing\nctx hook message reset qa-reminder gate    # revert to default\n

      See Customizing Hook Messages for detailed examples including Python, JavaScript, and silence configurations.

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#agent-bootstrapping","level":2,"title":"Agent Bootstrapping","text":"

      AI agents need to know the resolved context directory at session start. The ctx system bootstrap command prints the context path, file list, and operating rules in both text and JSON formats:

      ctx system bootstrap          # text output for agents\nctx system bootstrap -q       # just the context directory path\nctx system bootstrap --json   # structured output for automation\n

      The CLAUDE.md template instructs the agent to run this as its first action. Every nudge (context checkpoint, persistence reminder, etc.) also includes a Context: <dir> footer that re-anchors the agent to the correct directory throughout the session.

      This replaces the previous approach of hardcoding .context/ paths in agent instructions.

      See CLI Reference: bootstrap for full details.

      See also: CLI Reference | Context Files | Scratchpad

      ","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/context-files/","level":1,"title":"Context Files","text":"","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#context","level":2,"title":".context/","text":"

      Each context file in .context/ serves a specific purpose.

      Files are designed to be human-readable, AI-parseable, and token-efficient.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#file-overview","level":2,"title":"File Overview","text":"

      The core context files live directly under .context/. They are the substrate ctx reads in priority order when assembling the agent context packet:

      File Purpose Priority CONSTITUTION.md Hard rules that must NEVER be violated 1 (highest) TASKS.md Current and planned work 2 CONVENTIONS.md Project patterns and standards 3 ARCHITECTURE.md System overview and components 4 DECISIONS.md Architectural decisions with rationale 5 LEARNINGS.md Lessons learned, gotchas, tips 6 GLOSSARY.md Domain terms and abbreviations 7 AGENT_PLAYBOOK.md Instructions for AI tools 8 (lowest)

      Two subdirectories under .context/ are implementation details that are user-editable but not part of the priority read order:

      • .context/templates/: format templates for ctx decision add and ctx learning add. See templates below.
      • .context/steering/: behavioral rules with YAML frontmatter that get synced into each AI tool's native config. See steering below, and the full Steering files page for the design and workflow.
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#outside-context","level":3,"title":"Outside .context/","text":"

      Two other moving parts are often confused with context files but are not under .context/:

      • Skills live in .claude/skills/ (project-local) or are provided by the installed ctx plugin. A typical project doesn't see the plugin's skills at all; they ride with the plugin and are owned by its update cycle. See ctx skill and Skills reference.
      • Hooks: Claude Code PreToolUse/PostToolUse/ UserPromptSubmit entries configured in .claude/settings.json or shipped by a plugin. The ctx plugin registers its own hooks automatically; a typical project does not author hooks by hand, and any local edits to plugin-owned hook files will be overridden on the next plugin update. If you need to customize behavior, edit your own project settings, not the plugin's files. See Hook sequence diagrams.
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#read-order-rationale","level":2,"title":"Read Order Rationale","text":"

      The priority order follows a logical progression for AI tools:

      1. CONSTITUTION.md: Inviolable rules first. The AI tool must know what it cannot do before attempting anything.
      2. TASKS.md: Current work items. What the AI tool should focus on.
      3. CONVENTIONS.md: How to write code. Patterns and standards to follow when implementing tasks.
      4. ARCHITECTURE.md: System structure. Understanding of components and boundaries before making changes.
      5. DECISIONS.md: Historical context. Why things are the way they are, to avoid re-debating settled decisions.
      6. LEARNINGS.md: Gotchas and tips. Lessons from past work that inform the current implementation.
      7. GLOSSARY.md: Reference material. Domain terms and abbreviations for lookup as needed.
      8. AGENT_PLAYBOOK.md: Meta instructions last. How to use this context system itself. Loaded last because the agent should understand the content (rules, tasks, patterns) before the operating manual.
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#constitutionmd","level":2,"title":"CONSTITUTION.md","text":"

      Purpose: Define hard invariants: Rules that must NEVER be violated, regardless of the task.

      AI tools read this first and should refuse tasks that violate these rules.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure","level":3,"title":"Structure","text":"
      # Constitution\n\nThese rules are INVIOLABLE. If a task requires violating these, the task \nis wrong.\n\n## Security Invariants\n\n* [ ] Never commit secrets, tokens, API keys, or credentials\n* [ ] Never store customer/user data in context files\n* [ ] Never disable security linters without documented exception\n\n## Quality Invariants\n\n* [ ] All code must pass tests before commit\n* [ ] No `any` types in TypeScript without documented reason\n* [ ] No TODO comments in main branch (*move to `TASKS.md`*)\n\n## Process Invariants\n\n* [ ] All architectural changes require a decision record\n* [ ] Breaking changes require version bump\n* [ ] Generated files are never committed\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines","level":3,"title":"Guidelines","text":"
      • Keep rules minimal and absolute
      • Each rule should be enforceable (can verify compliance)
      • Use checkbox format for clarity
      • Never compromise on these rules
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tasksmd","level":2,"title":"TASKS.md","text":"

      Purpose: Track current work, planned work, and blockers.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_1","level":3,"title":"Structure","text":"

      Tasks are organized by Phase: logical groupings that preserve order and enable replay.

      Tasks stay in their Phase permanently; status is tracked via checkboxes and inline tags.

      # Tasks\n\n## Phase 1: Initial Setup\n\n* [x] Set up project structure\n* [x] Configure linting and formatting\n* [ ] Add CI/CD pipeline `#in-progress`\n\n## Phase 2: Core Features\n\n* [ ] Implement user authentication `#priority:high`\n* [ ] Add API rate limiting `#priority:medium`\n  * Blocked by: Need to finalize auth first\n\n## Backlog\n\n* [ ] Performance optimization `#priority:low`\n* [ ] Add metrics dashboard `#priority:deferred`\n

      Key principles:

      • Tasks never move between sections: mark as [x] or [-] in place
      • Use #in-progress inline tag to indicate current work
      • Phase headers provide structure and replay order
      • Backlog section for unscheduled work
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tags","level":3,"title":"Tags","text":"

      Use inline backtick-wrapped tags for metadata:

      Tag Values Purpose #priority high, medium, low Task urgency #area core, cli, docs, tests Codebase area #estimate 1h, 4h, 1d Time estimate (optional) #in-progress (none) Currently being worked on

      Lifecycle tags (for session correlation):

      Tag Format When to add #added YYYY-MM-DD-HHMMSS Auto-added by ctx task add #started YYYY-MM-DD-HHMMSS When beginning work on the task

      These timestamps help correlate tasks with session files and track which session started vs completed work.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#status-markers","level":3,"title":"Status Markers","text":"Marker Meaning [ ] Pending [x] Completed [-] Skipped (include reason)","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_1","level":3,"title":"Guidelines","text":"
      • Never delete tasks; mark as [x] completed or [-] skipped
      • Never move tasks between sections; use inline tags for status
      • Use ctx task archive periodically to move completed tasks to archive
      • Mark current work with #in-progress inline tag
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#decisionsmd","level":2,"title":"DECISIONS.md","text":"

      Purpose: Record architectural decisions with rationale so they don't get re-debated.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_2","level":3,"title":"Structure","text":"
      # Decisions\n\n## [YYYY-MM-DD] Decision Title\n\n**Status**: Accepted | Superseded | Deprecated\n\n**Context**: What situation prompted this decision?\n\n**Decision**: What was decided?\n\n**Rationale**: Why was this the right choice?\n\n**Consequence**: What are the implications?\n\n**Alternatives Considered**:\n* Alternative A: Why rejected\n* Alternative B: Why rejected\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example","level":3,"title":"Example","text":"
      ## [2025-01-15] Use TypeScript Strict Mode\n\n**Status**: Accepted\n\n**Context**: Starting a new project, need to choose the type-checking level.\n\n**Decision**: Enable TypeScript strict mode with all strict flags.\n\n**Rationale**: Catches more bugs at compile time. Team has experience\nwith strict mode. Upfront cost pays off in reduced runtime errors.\n\n**Consequence**: More verbose type annotations required. Some\nthird-party libraries need type assertions.\n\n**Alternatives Considered**:\n- Basic TypeScript: Rejected because it misses null checks\n- JavaScript with JSDoc: Rejected because tooling support is weaker\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#status-values","level":3,"title":"Status Values","text":"Status Meaning Accepted Current, active decision Superseded Replaced by newer decision (link to it) Deprecated No longer relevant","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#learningsmd","level":2,"title":"LEARNINGS.md","text":"

      Purpose: Capture lessons learned, gotchas, and tips that shouldn't be forgotten.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_3","level":3,"title":"Structure","text":"
      # Learnings\n\n## Category Name\n\n### Learning Title\n\n**Discovered**: YYYY-MM-DD\n\n**Context**: When/how was this learned?\n\n**Lesson**: What's the takeaway?\n\n**Application**: How should this inform future work?\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example_1","level":3,"title":"Example","text":"
      ## Testing\n\n### Vitest Mocks Must Be Hoisted\n\n**Discovered**: 2025-01-15\n\n**Context**: Tests were failing intermittently when mocking fs module.\n\n**Lesson**: Vitest requires `vi.mock()` calls to be hoisted to the\ntop of the file. Dynamic mocks need `vi.doMock()` instead.\n\n**Application**: Always use `vi.mock()` at file top. Use `vi.doMock()`\nonly when mock needs runtime values.\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#categories","level":3,"title":"Categories","text":"

      Organize learnings by topic:

      • Testing
      • Build & Deploy
      • Performance
      • Security
      • Third-Party Libraries
      • Git and Workflow
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#conventionsmd","level":2,"title":"CONVENTIONS.md","text":"

      Purpose: Document project patterns, naming conventions, and standards.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_4","level":3,"title":"Structure","text":"
      # Conventions\n\n## Naming\n\n* **Files**: kebab-case for all source files\n* **Components**: PascalCase for React components\n* **Functions**: camelCase, verb-first (getUser, parseConfig)\n* **Constants**: SCREAMING_SNAKE_CASE\n\n## Patterns\n\n### Pattern Name\n\n**When to use**: Situation description\n\n**Implementation**:\n// in triple backticks\n// Example code\n\n**Why**: Rationale for this pattern\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_2","level":3,"title":"Guidelines","text":"
      • Include concrete examples
      • Explain the \"why\" not just the \"what\"
      • Keep patterns minimal: Only document what's non-obvious
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#architecturemd","level":2,"title":"ARCHITECTURE.md","text":"

      Purpose: Provide system overview and component relationships.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_5","level":3,"title":"Structure","text":"
      # Architecture\n\n## Overview\n\nBrief description of what the system does and how it's organized.\n\n## Components\n\n### Component Name\n\n**Responsibility**: What this component does\n\n**Dependencies**: What it depends on\n\n**Dependents**: What depends on it\n\n**Key Files**:\n* path/to/file.ts: Description\n\n## Data Flow\n\nDescription or diagram of how data moves through the system.\n\n## Boundaries\n\nWhat's in scope vs out of scope for this codebase.\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_3","level":3,"title":"Guidelines","text":"
      • Keep diagrams simple (Mermaid works well)
      • Focus on boundaries and interfaces
      • Update when major structural changes occur
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#glossarymd","level":2,"title":"GLOSSARY.md","text":"

      Purpose: Define domain terms, abbreviations, and project vocabulary.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_6","level":3,"title":"Structure","text":"
      # Glossary\n\n## Domain Terms\n\n### Term Name\n\n**Definition**: What it means in this project's context\n\n**Not to be confused with**: Similar terms that mean different things\n\n**Example**: How it's used\n\n## Abbreviations\n\n| Abbrev | Expansion                     | Context                |\n|--------|-------------------------------|------------------------|\n| ADR    | Architectural Decision Record | Decision documentation |\n| SUT    | System Under Test             | Testing                |\n
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_4","level":3,"title":"Guidelines","text":"
      • Define project-specific meanings
      • Clarify potentially ambiguous terms
      • Include abbreviations used in code or docs
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#agent_playbookmd","level":2,"title":"AGENT_PLAYBOOK.md","text":"

      Purpose: Explicit instructions for how AI tools should read, apply, and update context.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#key-sections","level":3,"title":"Key Sections","text":"

      Read Order: Priority order for loading context files

      When to Update: Events that trigger context updates

      How to Avoid Hallucinating Memory: Critical rules:

      1. Never assume: If not in files, you don't know it
      2. Never invent history: Don't claim \"we discussed\" without evidence
      3. Verify before referencing: Search files before citing
      4. When uncertain, say so
      5. Trust files over intuition

      Context Update Commands: Format for automated updates via ctx watch:

      <context-update type=\"task\">Implement rate limiting</context-update>\n<context-update type=\"complete\">user auth</context-update>\n<context-update type=\"learning\"\n  context=\"Debugging hooks\"\n  lesson=\"Hooks receive JSON via stdin\"\n  application=\"Parse JSON stdin with the host language\"\n>Hook Input Format</context-update>\n<context-update type=\"decision\"\n  context=\"Need a caching layer\"\n  rationale=\"Redis is fast and team has experience\"\n  consequence=\"Must provision Redis infrastructure\"\n>Use Redis for caching</context-update>\n

      See Integrations for full documentation.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#templates","level":2,"title":"templates/","text":"

      Location: .context/templates/. Status: implementation detail, user-editable.

      Purpose: Format templates for ctx decision add and ctx learning add. These control the structure of new entries appended to DECISIONS.md and LEARNINGS.md.

      ctx init deploys two starter templates:

      • decision.md: sections Context, Rationale, Consequence
      • learning.md: sections Context, Lesson, Application
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing","level":3,"title":"Customizing","text":"

      Edit the templates directly. Changes take effect immediately on the next ctx add command. For example, to add a \"References\" section to all new decisions, edit .context/templates/decision.md.

      Templates are committed to git, so customizations are shared with the team.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#steering","level":2,"title":"steering/","text":"

      Location: .context/steering/. Status: implementation detail, user-editable.

      Purpose: Behavioral rules with YAML frontmatter that tell an AI assistant how to behave when a specific kind of prompt arrives. Unlike the core context files (which describe what the project is), steering files describe what to do and ride alongside the prompt through the AI tool's native rule pipeline (Claude Code, Cursor, Kiro, Cline). ctx matches steering files to prompts and syncs them out to each tool's config.

      ctx init scaffolds four foundation files:

      • product.md: who this project serves and why
      • tech.md: the technology stack and its constraints
      • structure.md: how the code is organized
      • workflow.md: how work moves through the system

      Each file carries YAML frontmatter describing when it applies (always, matching prompts, or manually referenced) and what tool scope it covers. The foundation files use inclusion: always by default so every session picks them up.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing_1","level":3,"title":"Customizing","text":"

      Edit the files directly. Add your own steering files with ctx steering add, preview the match set with ctx steering preview, and run ctx steering sync to push them into each AI tool's config after changes. Steering files are committed to git, so they're shared with the team.

      For the design rationale, the full inclusion/priority model, and the end-to-end sync workflow, see the dedicated Steering files page.

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#parsing-rules","level":2,"title":"Parsing Rules","text":"

      All context files follow these conventions:

      1. Headers define structure: # for title, ## for sections, ### for items
      2. Bold keys for fields: **Key**: followed by value
      3. Code blocks are literal: Never parse code block content as structure
      4. Lists are ordered: Items appear in priority/chronological order
      5. Tags are inline: Backtick-wrapped tags like #priority:high
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#further-reading","level":2,"title":"Further Reading","text":"
      • Refactoring with Intent: how persistent context prevents drift during refactoring sessions
      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#token-efficiency","level":2,"title":"Token Efficiency","text":"

      Keep context files concise:

      • Use abbreviations in tags, not prose;
      • Omit obvious words (\"The,\" \"This\");
      • Prefer bullet points over paragraphs;
      • Keep examples minimal but illustrative;
      • Archive old completed items periodically.

      Next Up: Prompting Guide →: effective prompts for AI sessions with ctx

      ","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/contributing/","level":1,"title":"Contributing","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#development-setup","level":2,"title":"Development Setup","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#prerequisites","level":3,"title":"Prerequisites","text":"
      • Go (version defined in go.mod)
      • Claude Code
      • Git
      • GNU Make
      • Zensical
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#1-fork-or-clone-the-repository","level":3,"title":"1. Fork (or Clone) the Repository","text":"
      # Fork on GitHub, then:\ngit clone https://github.com/<you>/ctx.git\ncd ctx\n\n# Or, if you have push access:\ngit clone https://github.com/ActiveMemory/ctx.git\ncd ctx\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#2-build-and-install-the-binary","level":3,"title":"2. Build and Install the Binary","text":"
      make build\nsudo make install\n

      This compiles the ctx binary and places it in /usr/local/bin/.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#3-install-the-plugin-from-your-local-clone","level":3,"title":"3. Install the Plugin from Your Local Clone","text":"

      The repository ships a Claude Code plugin under internal/assets/claude/. Point Claude Code at your local copy so that skills and hooks reflect your working tree: no reinstall needed after edits:

      1. Launch claude;
      2. Type /plugin and press Enter;
      3. Select Marketplaces → Add Marketplace
      4. Enter the absolute path to the root of your clone, e.g. ~/WORKSPACE/ctx (this is where .claude-plugin/marketplace.json lives: it points Claude Code to the actual plugin in internal/assets/claude);
      5. Back in /plugin, select Install and choose ctx.

      Claude Code Caches Plugin Files

      Even though the marketplace points at a directory on disk, Claude Code caches skills and hooks. After editing files under internal/assets/claude/, clear the cache and restart:

      make plugin-reload   # then restart Claude Code\n

      See Skill or Hook Changes for details.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#4-verify","level":3,"title":"4. Verify","text":"
      ctx --version       # binary is in PATH\nclaude /plugin list # plugin is installed\n

      You should see the ctx plugin listed, sourced from your local path.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#project-layout","level":2,"title":"Project Layout","text":"
      ctx/\n├── cmd/ctx/            # CLI entry point\n├── internal/\n│   ├── assets/claude/  # ← Claude Code plugin (skills, hooks)\n│   ├── bootstrap/      # Project initialization templates\n│   ├── claude/         # Claude Code integration helpers\n│   ├── cli/            # Command implementations\n│   ├── config/         # Configuration loading\n│   ├── context/        # Core context logic\n│   ├── crypto/         # Scratchpad encryption\n│   ├── drift/          # Drift detection\n│   ├── index/          # Context file indexing\n│   ├── journal/        # Journal site generation\n│   ├── memory/         # Memory bridge (discover, mirror, import, publish)\n│   ├── notify/         # Webhook notifications\n│   ├── rc/             # .ctxrc parsing\n│   ├── journal/        # Session history, parsers, and state\n│   ├── sysinfo/        # System resource monitoring\n│   ├── task/           # Task management\n│   └── validation/     # Input validation\n├── .claude/\n│   └── skills/         # Dev-only skills (not distributed)\n├── assets/             # Static assets (banners, logos)\n├── docs/               # Documentation site source\n├── editors/            # Editor extensions (VS Code)\n├── examples/           # Example configurations\n├── hack/               # Build scripts\n├── specs/              # Feature specifications\n└── .context/           # ctx's own context (dogfooding)\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#skills-two-directories-one-rule","level":3,"title":"Skills: Two Directories, One Rule","text":"Directory What lives here Distributed to users? internal/assets/claude/skills/ The 39 ctx-* skills that ship with the plugin Yes .claude/skills/ Dev-only skills (release, QA, backup, etc.) No

      internal/assets/claude/skills/ is the single source of truth for user-facing skills. If you are adding or modifying a ctx-* skill, edit it there.

      .claude/skills/ holds skills that only make sense inside this repository (release automation, QA checks, backup scripts). These are never distributed to users.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#dev-only-skills-reference","level":4,"title":"Dev-Only Skills Reference","text":"Skill When to use /_ctx-absorb Merge deltas from a parallel worktree or separate checkout /_ctx-audit Detect code-level drift after YOLO sprints or before releases /_ctx-qa Run QA checks before committing /_ctx-release Run the full release process /_ctx-release-notes Generate release notes for dist/RELEASE_NOTES.md /_ctx-alignment-audit Audit doc claims against agent instructions /_ctx-update-docs Check docs/code consistency after changes /_ctx-command-audit Audit CLI surface after renames, moves, or deletions

      Six skills previously in this list have been promoted to bundled plugin skills and are now available to all ctx users: /ctx-brainstorm, /ctx-link-check, /ctx-permission-sanitize, /ctx-skill-create, /ctx-spec.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#how-to-add-things","level":2,"title":"How to Add Things","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-new-cli-command","level":3,"title":"Adding a New CLI Command","text":"
      1. Create a package under internal/cli/<name>/ with doc.go, cmd.go, and run.go;
      2. Implement Cmd() *cobra.Command as the entry point;
      3. Add Use* and DescKey* constants in internal/config/embed/cmd/<name>.go;
      4. Add command descriptions in internal/assets/commands/commands.yaml;
      5. Add examples in internal/assets/commands/examples.yaml;
      6. Add flag descriptions in internal/assets/commands/flags.yaml;
      7. Register the command in internal/bootstrap/group.go (add import + entry in the appropriate group function);
      8. Create an output package at internal/write/<name>/ for all user-facing output (see Package Taxonomy);
      9. Create error constructors at internal/err/<name>/ for domain-specific errors;
      10. Add tests in the same package (<name>_test.go);
      11. Add a doc page at docs/cli/<name>.md and update docs/cli/index.md;
      12. Add the page to zensical.toml nav.

      Pattern to follow: internal/cli/pad/pad.go (parent with subcommands) or internal/cli/drift/ (single command).

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#package-taxonomy","level":3,"title":"Package Taxonomy","text":"

      ctx separates concerns into a strict package taxonomy. Knowing where things go prevents code review friction and keeps the AST lint tests happy.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#output-internalwrite","level":4,"title":"Output: internal/write/","text":"

      Every CLI command's user-facing output lives in its own sub-package under internal/write/<domain>/. Output functions accept *cobra.Command and call cmd.Println(...), never fmt.Print* directly. All text strings are loaded from YAML via desc.Text(text.DescKey*), never inline.

      internal/write/add/add.go       # output for ctx add\ninternal/write/stat/stat.go     # output for ctx usage\ninternal/write/resource/        # output for ctx sysinfo\n

      Exception: write/rc/ writes to os.Stderr because rc loads before cobra is initialized.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#errors-internalerr","level":4,"title":"Errors: internal/err/","text":"

      Domain-specific error constructors live under internal/err/<domain>/. Each package mirrors the write structure. Functions return error (never custom error types) and load messages from YAML via desc.Text(text.DescKey*).

      internal/err/add/add.go         # errors for ctx add\ninternal/err/config/config.go   # errors for configuration\ninternal/err/cli/cli.go         # errors for CLI argument validation\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#config-constants-internalconfig","level":4,"title":"Config Constants: internal/config/","text":"

      Pure-constant leaf packages with zero internal dependencies (stdlib only). Over 60 sub-packages, organized by domain. See internal/config/README.md for the full decision tree.

      What you're adding Where it goes File names, extensions, paths config/file/, config/dir/ Regex patterns config/regex/ CLI flag names (--flag-name) config/flag/flag.go Flag description YAML keys config/embed/flag/<cmd>.go Command Use/DescKey strings config/embed/cmd/<cmd>.go User-facing text YAML keys config/embed/text/<domain>.go Time durations, thresholds config/<domain>/","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#the-assets-pipeline","level":4,"title":"The Assets Pipeline","text":"

      User-facing text flows through a three-level chain:

      1. Go constant (config/embed/text/) defines a string key: DescKeyWriteAddedTo = \"write.added-to\"
      2. Call site resolves it: desc.Text(text.DescKeyWriteAddedTo)
      3. YAML (internal/assets/commands/text/write.yaml) holds the actual text: write.added-to: { short: \"Added to %s\" }

      The same pattern applies to command descriptions (commands.yaml), flag descriptions (flags.yaml), and examples (examples.yaml). The TestDescKeyYAMLLinkage test verifies every constant resolves to a non-empty YAML value.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-new-session-parser","level":3,"title":"Adding a New Session Parser","text":"

      The journal system uses a SessionParser interface. To add support for a new AI tool (e.g. Aider, Cursor):

      1. Create internal/journal/parser/<tool>.go;
      2. Implement parsing logic that returns []*Session;
      3. Register the parser in FindSessions() / FindSessionsForCWD();
      4. Use config.Tool* constants for the tool identifier;
      5. Add test fixtures and parser tests.

      Pattern to follow: the Claude Code JSONL parser in internal/journal/parser/.

      Multilingual Session Headers

      The Markdown parser recognizes session header prefixes configured via session_prefixes in .ctxrc (default: Session:). To support a new language, users add a prefix to their .ctxrc - no code change needed. New parser implementations can use rc.SessionPrefixes() if they also need prefix-based header detection.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-bundled-skill","level":3,"title":"Adding a Bundled Skill","text":"
      1. Create internal/assets/claude/skills/<skill-name>/SKILL.md;
      2. Follow the skill format: trigger, negative triggers, steps, quality gate;
      3. Run make plugin-reload and restart Claude Code to test;
      4. Add a Skill entry to .claude-plugin/plugin.json if user-invocable;
      5. Document in docs/reference/skills.md.

      Pattern to follow: any skill in internal/assets/claude/skills/ctx-status/.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#test-expectations","level":3,"title":"Test Expectations","text":"
      • Unit tests: colocated with source (foo.gofoo_test.go);
      • Test helpers: use t.Helper() so failures point to callers;
      • HOME isolation: use t.TempDir() + t.Setenv(\"HOME\", ...) for tests that touch ~/.claude/ or ~/.ctx/;
      • rc.Reset(): call after os.Chdir in tests that change working directory (rc caches on first access);
      • No network: all tests run offline, use fixtures.

      Run make test before submitting. Target: no failures, no skips.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#day-to-day-workflow","level":2,"title":"Day-to-Day Workflow","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#go-code-changes","level":3,"title":"Go Code Changes","text":"

      After modifying Go source files, rebuild and reinstall:

      make build && sudo make install\n

      The ctx binary is statically compiled. There is no hot reload. You must rebuild for Go changes to take effect.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#skill-or-hook-changes","level":3,"title":"Skill or Hook Changes","text":"

      Edit files under internal/assets/claude/skills/ or internal/assets/claude/hooks/.

      Claude Code caches plugin files, so edits aren't picked up automatically.

      Clear the cache and restart:

      make plugin-reload   # nukes ~/.claude/plugins/cache/activememory-ctx/\n# then restart Claude Code\n

      The plugin will be re-installed from your local marketplace on startup. No version bump is needed during development.

      Version Bumps Are for Releases, Not Iteration

      Only bump VERSION, plugin.json, and marketplace.json when cutting a release. During development, make plugin-reload is all you need.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"

      The repo ships two .ctxrc source profiles. The working copy (.ctxrc) is gitignored and swapped between them:

      File Purpose .ctxrc.base Golden baseline: all defaults, no logging .ctxrc.dev Dev profile: notify events enabled, verbose logging .ctxrc Working copy (gitignored: copied from one of the above)

      Use ctx commands to switch:

      ctx config switch dev      # switch to dev profile\nctx config switch base     # switch to base profile\nctx config status          # show which profile is active\n

      After cloning, run ctx config switch dev to get started with full logging.

      See Configuration for the full .ctxrc option reference.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#backups","level":3,"title":"Backups","text":"

      ctx does not ship a backup command. File-level backup is an OS / infrastructure concern; ctx hub handles the cross-machine knowledge persistence that matters most. For everything else, see Backup Strategy: rsync, Time Machine, Borg, or whichever tool already handles the rest of your files.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-tests","level":3,"title":"Running Tests","text":"
      make test   # fast: all tests\nmake audit  # full: fmt + vet + lint + drift + docs + test\nmake smoke  # build + run basic commands end-to-end\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-the-docs-site-locally","level":3,"title":"Running the Docs Site Locally","text":"
      make site-setup  # one-time: install zensical via pipx\nmake site-serve  # serve at localhost\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#submitting-changes","level":2,"title":"Submitting Changes","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#before-you-start","level":3,"title":"Before You Start","text":"
      1. Check existing issues to avoid duplicating effort;
      2. For large changes, open an issue first to discuss the approach;
      3. Read the specs in specs/ for design context.
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#pull-request-process","level":3,"title":"Pull Request Process","text":"

      Respect the maintainers' time and energy: Keep your pull requests isolated and strive to minimze code changes.

      If you Pull Request solves more than one distinct issues, it's better to create separate pull requests instead of sending them in one large bundle.

      1. Create a feature branch: git checkout -b feature/my-feature;
      2. Make your changes;
      3. Run make audit to catch issues early;
      4. Commit with a clear message;
      5. Push and open a pull request.

      Audit Your Code Before Submitting

      Run make audit before submitting:

      make audit covers formatting, vetting, linting, drift checks, doc consistency, and tests in one pass.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#commit-messages","level":3,"title":"Commit Messages","text":"

      Following conventional commits is recommended but not required:

      Types: feat, fix, docs, test, refactor, chore

      Examples:

      • feat(cli): add ctx export command
      • fix(drift): handle missing files gracefully
      • docs: update installation instructions
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-style","level":3,"title":"Code Style","text":"
      • Follow Go conventions (gofmt, go vet);
      • Keep functions focused and small;
      • Add tests for new functionality;
      • Handle errors explicitly; use descriptive names (readErr, writeErr) not repeated err;
      • No magic strings: all repeated literals go in internal/config/;
      • Output goes through internal/write/ packages, not fmt.Print*;
      • Errors go through internal/err/ constructors, not inline fmt.Errorf;
      • See Package Taxonomy and .context/CONVENTIONS.md for the full reference.
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-of-conduct","level":2,"title":"Code of Conduct","text":"

      A clear context requires respectful collaboration.

      ctx follows the Contributor Covenant.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#boring-legal-stuff","level":2,"title":"Boring Legal Stuff","text":"","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#developer-certificate-of-origin-dco","level":3,"title":"Developer Certificate of Origin (DCO)","text":"

      By contributing, you agree to the Developer Certificate of Origin.

      All commits must be signed off:

      git commit -s -m \"feat: add new feature\"\n
      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#license","level":3,"title":"License","text":"

      Contributions are licensed under the Apache 2.0 License.

      ","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/faq/","level":1,"title":"FAQ","text":"","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#why-markdown","level":2,"title":"Why Markdown?","text":"

      Markdown is human-readable, version-controllable, and tool-agnostic. Every AI model can parse it natively. Every developer can read it in a terminal, a browser, or a code review. There's no schema to learn, no binary format to decode, no vendor lock-in. You can inspect your context with cat, diff it with git diff, and review it in a PR.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#does-ctx-work-offline","level":2,"title":"Does ctx Work Offline?","text":"

      Yes. ctx is completely local. It reads and writes files on disk, generates context packets from local state, and requires no network access. The only feature that touches the network is the optional webhook notifications hook, which you have to explicitly configure.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#what-gets-committed-to-git","level":2,"title":"What Gets Committed to Git?","text":"

      The .context/ directory: yes, commit it. That's the whole point. Team members and AI agents read the same context files.

      What not to commit:

      • .ctx.key: your encryption key. Stored at ~/.ctx/.ctx.key, never in the repo. ctx init handles this automatically.
      • journal/ and logs/: generated data, potentially large. ctx init adds these to .gitignore.
      • scratchpad.enc: your choice. It's encrypted, so it's safe to commit if you want shared scratchpad state. See Scratchpad for details.
      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#how-big-should-my-token-budget-be","level":2,"title":"How Big Should My Token Budget Be?","text":"

      The default is 8000 tokens, which works well for most projects. Configure it via .ctxrc or the CTX_TOKEN_BUDGET environment variable:

      # In .ctxrc\ntoken_budget = 12000\n\n# Or as an environment variable\nexport CTX_TOKEN_BUDGET=12000\n\n# Or per-invocation\nctx agent --budget 4000\n

      Higher budgets include more context but cost more tokens per request. Lower budgets force sharper prioritization: ctx drops lower-priority content first, so CONSTITUTION and TASKS always make the cut.

      See Configuration for all available settings.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#why-not-a-database","level":2,"title":"Why Not a Database?","text":"

      Files are inspectable, diffable, and reviewable in pull requests. You can grep them, cat them, pipe them through jq or awk. They work with every version control system and every text editor.

      A database would add a dependency, require migrations, and make context opaque. The design bet is that context should be as visible and portable as the code it describes.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#does-it-work-with-tools-other-than-claude-code","level":2,"title":"Does It Work with Tools Other than Claude Code?","text":"

      Yes. ctx agent outputs a context packet that any AI tool can consume: paste it into ChatGPT, Cursor, Copilot, Aider, or anything else that accepts text input.

      Claude Code gets first-class integration via the ctx plugin (hooks, skills, automatic context loading). VS Code Copilot Chat has a dedicated ctx extension. Other tools integrate via generated instruction files or manual pasting.

      See Integrations for tool-specific setup, including the multi-tool recipe.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#can-i-use-ctx-on-an-existing-project","level":2,"title":"Can I Use ctx on an Existing Project?","text":"

      Yes. Run ctx init in any repo and it creates .context/ with template files. Start recording decisions, tasks, and conventions as you work. Context grows naturally; you don't need to backfill everything on day one.

      See Getting Started for the full setup flow, or Joining a ctx Project if someone else already initialized it.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#what-happens-when-context-files-get-too-big","level":2,"title":"What Happens When Context Files Get Too Big?","text":"

      Token budgeting handles this automatically. ctx agent prioritizes content by file priority (CONSTITUTION first, GLOSSARY last) and trims lower-priority entries when the budget is tight.

      For manual maintenance, ctx compact archives completed tasks and old entries, keeping active context lean. You can also run ctx task archive to move completed tasks out of TASKS.md.

      The goal is to keep context files focused on current state. Historical entries belong in git history or the archive.

      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#is-context-meant-to-be-shared","level":2,"title":"Is .context/ Meant to Be Shared?","text":"

      Yes. Commit it to your repo. Every team member and every AI agent reads the same files. That's the mechanism for shared memory: decisions made in one session are visible in the next, regardless of who (or what) starts it.

      The only per-user state is the encryption key (~/.ctx/.ctx.key) and the optional scratchpad. Everything else is team-shared by design.

      Related:

      • Getting Started - installation and first setup
      • Configuration - .ctxrc, environment variables, and defaults
      • Context Files - what each file does and how to use it
      ","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/first-session/","level":1,"title":"Your First Session","text":"

      Here's what a complete first session looks like, from initialization to the moment your AI cites your project context back to you.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-1-initialize-your-project","level":2,"title":"Step 1: Initialize Your Project","text":"

      Run ctx init in your project root:

      cd your-project\nctx init\n

      Sample output:

      Context initialized in .context/\n\n  ✓ CONSTITUTION.md\n  ✓ TASKS.md\n  ✓ DECISIONS.md\n  ✓ LEARNINGS.md\n  ✓ CONVENTIONS.md\n  ✓ ARCHITECTURE.md\n  ✓ GLOSSARY.md\n  ✓ AGENT_PLAYBOOK.md\n\nSetting up encryption key...\n  ✓ ~/.ctx/.ctx.key\n\nClaude Code plugin (hooks + skills):\n  Install: claude /plugin marketplace add ActiveMemory/ctx\n  Then:    claude /plugin install ctx@activememory-ctx\n\nNext steps:\n  1. Edit .context/TASKS.md to add your current tasks\n  2. Run 'ctx status' to see context summary\n  3. Run 'ctx agent' to get AI-ready context packet\n

      This created your .context/ directory with template files.

      For Claude Code, install the ctx plugin to get automatic hooks and skills.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-2-activate-the-project","level":2,"title":"Step 2: Activate the Project","text":"

      Tell ctx which .context/ directory the rest of these commands should use:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the next steps fail with Error: no context directory specified. Direnv users can wire it into .envrc and forget about it. For more options (multiple .context/ directories, scripts, CI), see Activating a Context Directory.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-3-populate-your-context","level":2,"title":"Step 3: Populate Your Context","text":"

      Add a task and a decision: These are the entries your AI will remember:

      ctx task add \"Implement user authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Output: ✓ Added to TASKS.md\n\nctx decision add \"Use PostgreSQL for primary database\" \\\n  --context \"Need a reliable database for production\" \\\n  --rationale \"PostgreSQL offers ACID compliance and JSON support\" \\\n  --consequence \"Team needs PostgreSQL training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Output: ✓ Added to DECISIONS.md\n

      These entries are what the AI will recall in future sessions. You don't need to populate everything now: Context grows naturally as you work.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-4-check-your-context","level":2,"title":"Step 4: Check Your Context","text":"
      ctx status\n

      Sample output:

      Context Status\n====================\n\nContext Directory: .context/\nTotal Files: 8\nToken Estimate: 1,247 tokens\n\nFiles:\n  ✓ CONSTITUTION.md (loaded)\n  ✓ TASKS.md (1 items)\n  ✓ DECISIONS.md (1 items)\n  ○ LEARNINGS.md (empty)\n  ✓ CONVENTIONS.md (loaded)\n  ✓ ARCHITECTURE.md (loaded)\n  ✓ GLOSSARY.md (loaded)\n  ✓ AGENT_PLAYBOOK.md (loaded)\n\nRecent Activity:\n  - TASKS.md modified 2 minutes ago\n  - DECISIONS.md modified 1 minute ago\n

      Notice the token estimate: This is how much context your AI will load.

      The next to LEARNINGS.md means it's still empty; it will fill in as you capture lessons during development.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-5-start-an-ai-session","level":2,"title":"Step 5: Start an AI Session","text":"

      With Claude Code (and the ctx plugin), start every session with:

      /ctx-remember\n

      This loads your context and presents a structured readback so you can confirm the agent knows what is going on. Context also loads automatically via hooks, but the explicit ceremony gives you a readback to verify.

      Steering Files Fire Automatically

      If you edited the four foundation files scaffolded by ctx init (.context/steering/product.md, tech.md, structure.md, workflow.md), their inclusion: always rules are prepended to every tool call via the plugin's PreToolUse hook, with no /ctx-remember needed, no MCP call. Edit a file, save, and the next tool call in Claude Code picks it up. See Steering files for details on the inclusion modes.

      Using VS Code?

      With VS Code Copilot Chat (and the ctx extension), type @ctx /agent in chat to load your context packet, or @ctx /status to check your project context. Run ctx setup copilot --write once to generate .github/copilot-instructions.md for automatic context loading.

      If you are not using Claude Code, generate a context packet for your AI tool:

      ctx agent --budget 8000\n

      Sample output:

      # Context Packet\nGenerated: 2026-02-14T15:30:45Z | Budget: 8000 tokens | Used: ~2450\n\n## Read These Files (in order)\n1. .context/CONSTITUTION.md\n2. .context/TASKS.md\n3. .context/CONVENTIONS.md\n...\n\n## Current Tasks\n- [ ] Implement user authentication\n- [ ] Add rate limiting to API endpoints\n\n## Key Conventions\n- Use gofmt for formatting\n- Path construction uses filepath.Join\n\n## Recent Decisions\n## [2026-02-14-120000] Use PostgreSQL for the primary database\n\n**Context**: Evaluated PostgreSQL, MySQL, and SQLite...\n**Rationale**: PostgreSQL offers better JSON support...\n\n## Key Learnings\n## [2026-02-14-100000] Connection pool sizing matters\n\n**Context**: Hit connection limits under load...\n**Lesson**: Default pool size of 10 is too low for concurrent requests...\n\n## Also Noted\n- Use JWT for session management\n- Always validate input at API boundary\n

      Paste this output into your AI tool's system prompt or conversation start.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-6-verify-it-works","level":2,"title":"Step 6: Verify It Works","text":"

      Ask your AI: \"What are our current tasks?\"

      A working setup produces a response like:

      Based on the project context, you have one active task:\n\n- **Implement user authentication** (pending)\n\nThere's also a recent architectural decision to **use PostgreSQL for\nthe primary database**, chosen for its ACID compliance and JSON support.\n\nWant me to start on the authentication task?\n

      That's the success moment:

      The AI is citing your exact context entries from Step 2, not hallucinating or asking you to re-explain.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-gets-created","level":2,"title":"What Gets Created","text":"
      .context/\n├── CONSTITUTION.md     # Hard rules: NEVER violate these\n├── TASKS.md            # Current and planned work\n├── CONVENTIONS.md      # Project patterns and standards\n├── ARCHITECTURE.md     # System overview\n├── DECISIONS.md        # Architectural decisions with rationale\n├── LEARNINGS.md        # Lessons learned, gotchas, tips\n├── GLOSSARY.md         # Domain terms and abbreviations\n└── AGENT_PLAYBOOK.md   # How AI tools should use this\n

      Claude Code integration (hooks + skills) is provided by the ctx plugin: See Integrations/Claude Code.

      VS Code Copilot Chat integration is provided by the ctx extension: See Integrations/VS Code.

      See Context Files for detailed documentation of each file.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-to-gitignore","level":2,"title":"What to .gitignore","text":"

      Rule of Thumb

      • If it's knowledge (decisions, tasks, learnings, conventions), commit it.
      • If it's generated output, raw session data, or a secret, .gitignore it.

      Commit your .context/ knowledge files: that's the whole point.

      You should .gitignore the generated and sensitive paths:

      # Journal data (large, potentially sensitive)\n.context/journal/\n.context/journal-site/\n.context/journal-obsidian/\n\n# Hook logs (machine-specific)\n.context/logs/\n\n# Legacy encryption key path (copy to ~/.ctx/.ctx.key if needed)\n.context/.ctx.key\n\n# Claude Code local settings (machine-specific)\n.claude/settings.local.json\n

      ctx init Patches Your .Gitignore for You

      ctx init automatically adds these entries to your .gitignore.

      Review the additions with cat .gitignore after init.

      See also:

      • Security Considerations
      • Scratchpad Encryption
      • Session Journal

      Next Up: Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history.

      ","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/getting-started/","level":1,"title":"Getting Started","text":"","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#prerequisites","level":2,"title":"Prerequisites","text":"

      ctx does not require git, but using version control with your .context/ directory is strongly recommended:

      AI sessions occasionally modify or overwrite context files inadvertently. With git, the AI can check history and restore lost content: Without it, the data is gone.

      Also, several ctx features (journal changelog, blog generation) also use git history directly.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#installation","level":2,"title":"Installation","text":"

      Every setup starts with the ctx binary: the CLI tool itself.

      If you use Claude Code, you also install the ctx plugin, which adds hooks (context autoloading, persistence nudges) and 25+ /ctx-* skills. For other AI tools, ctx integrates via generated instruction files or manual context pasting: see Integrations for tool-specific setup.

      Pick one of the options below to install the binary. Claude Code users should also follow the plugin steps included in each option.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#option-1-build-from-source-recommended","level":3,"title":"Option 1: Build from Source (Recommended)","text":"

      Requires Go (version defined in go.mod) and Claude Code.

      git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\nmake build\nsudo make install\n

      Install the Claude Code plugin from your local clone:

      1. Launch claude;
      2. Type /plugin and press Enter;
      3. Select Marketplaces → Add Marketplace
      4. Enter the path to the root of your clone, e.g. ~/WORKSPACE/ctx (this is where .claude-plugin/marketplace.json lives: It points Claude Code to the actual plugin in internal/assets/claude)
      5. Back in /plugin, select Install and choose ctx

      This points Claude Code at the plugin source on disk. Changes you make to hooks or skills take effect immediately: No reinstall is needed.

      Local Installs Need Manual Enablement

      Unlike marketplace installs, local plugin installs are not auto-enabled globally. The plugin will only work in projects that explicitly enable it. Run ctx init in each project (it auto-enables the plugin), or add the entry to ~/.claude/settings.json manually:

      { \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n

      Verify:

      ctx --version       # binary is in PATH\nclaude /plugin list # plugin is installed\n

      Use the Source, Luke

      Building from source gives you the latest features and bug fixes.

      Since ctx is predominantly a developer tool, this is the recommended approach:

      You get the freshest code, can inspect what you are installing, and the plugin stays in sync with the binary.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#option-2-binary-download-marketplace","level":3,"title":"Option 2: Binary Download + Marketplace","text":"

      Pre-built binaries are available from the releases page.

      Linux (x86_64)Linux (ARM64)macOS (Apple Silicon)macOS (Intel)Windows
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-linux-amd64\nchmod +x ctx-0.8.1-linux-amd64\nsudo mv ctx-0.8.1-linux-amd64 /usr/local/bin/ctx\n
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-linux-arm64\nchmod +x ctx-0.8.1-linux-arm64\nsudo mv ctx-0.8.1-linux-arm64 /usr/local/bin/ctx\n
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-darwin-arm64\nchmod +x ctx-0.8.1-darwin-arm64\nsudo mv ctx-0.8.1-darwin-arm64 /usr/local/bin/ctx\n
      curl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-darwin-amd64\nchmod +x ctx-0.8.1-darwin-amd64\nsudo mv ctx-0.8.1-darwin-amd64 /usr/local/bin/ctx\n

      Download ctx-0.8.1-windows-amd64.exe from the releases page and add it to your PATH.

      Claude Code users: install the plugin from the marketplace:

      1. Launch claude;
      2. Type /plugin and press Enter;
      3. Select Marketplaces → Add Marketplace;
      4. Enter ActiveMemory/ctx;
      5. Back in /plugin, select Install and choose ctx.

      Other tool users: see Integrations for tool-specific setup (Cursor, Copilot, Aider, Windsurf, etc.).

      Verify the Plugin Is Enabled

      After installing, confirm the plugin is enabled globally. Check ~/.claude/settings.json for an enabledPlugins entry. If missing, run ctx init in your project (it auto-enables the plugin), or add it manually:

      { \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n

      Verify:

      ctx --version       # binary is in PATH\nclaude /plugin list # plugin is installed (Claude Code only)\n
      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#verifying-checksums","level":4,"title":"Verifying Checksums","text":"

      Each binary has a corresponding .sha256 checksum file. To verify your download:

      # Download the checksum file\ncurl -LO https://github.com/ActiveMemory/ctx/releases/download/v0.8.1/ctx-0.8.1-linux-amd64.sha256\n\n# Verify the binary\nsha256sum -c ctx-0.8.1-linux-amd64.sha256\n

      On macOS, use shasum -a 256 -c instead of sha256sum -c.

      Plugin Details

      After installation (either option) you get:

      • Context autoloading: ctx agent runs on every tool use (with cooldown)
      • Persistence nudges: reminders to capture learnings and decisions
      • Post-commit hooks: nudge context capture after git commit
      • Context size monitoring: alerts as sessions grow large
      • Project skills: /ctx-status, /ctx-task-add, /ctx-history, and more

      See Integrations for the full hook and skill reference.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#quick-start","level":2,"title":"Quick Start","text":"","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#1-initialize-context","level":3,"title":"1. Initialize Context","text":"
      cd your-project\nctx init\n

      This creates a .context/ directory with template files and an encryption key at ~/.ctx/ for the encrypted scratchpad. For Claude Code, install the ctx plugin for automatic hooks and skills.

      ctx init also scaffolds four foundation steering files in .context/steering/; these are behavioral-rule templates that tell your AI how to act on your project:

      File What it captures product.md Product context, goals, and target users tech.md Technology stack, constraints, key dependencies structure.md Project structure and directory conventions workflow.md Development workflow and process rules

      Each file starts with a self-documenting HTML comment explaining the three inclusion modes (always / auto / manual), priority, and tool scoping. The defaults are set to inclusion: always and priority: 10, so they fire on every AI tool call until you edit them.

      You should open each of these files and replace the placeholder content with your project's actual rules. Running ctx init again won't clobber your edits; existing files are left alone. To opt out entirely, use ctx init --no-steering-init.

      See Writing Steering Files for the full walkthrough, or ctx steering for the command reference.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#2-activate-the-project","level":3,"title":"2. Activate the Project","text":"

      Tell ctx which .context/ directory the rest of these commands should use:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the next steps fail with Error: no context directory specified. Direnv users can wire it into .envrc and forget about it. For more options (multiple .context/ directories, scripts, CI), see Activating a Context Directory.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#3-check-status","level":3,"title":"3. Check Status","text":"
      ctx status\n

      Shows context summary: files present, token estimate, and recent activity.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#4-start-using-with-ai","level":3,"title":"4. Start Using with AI","text":"

      With Claude Code (and the ctx plugin installed), context loads automatically via hooks.

      With VS Code Copilot Chat, install the ctx extension and use @ctx /status, @ctx /agent, and other slash commands directly in chat. Run ctx setup copilot --write to generate .github/copilot-instructions.md for automatic context loading.

      For other tools, paste the output of:

      ctx agent --budget 8000\n
      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#4b-set-up-for-your-ai-tool","level":3,"title":"4B. Set Up for Your AI Tool","text":"

      If you use an MCP-compatible tool, generate the integration config with ctx setup:

      KiroCursorCline
      ctx setup kiro --write\n# Creates .kiro/settings/mcp.json and syncs steering files\n
      ctx setup cursor --write\n# Creates .cursor/mcp.json and syncs steering files\n
      ctx setup cline --write\n# Creates .vscode/mcp.json and syncs steering files\n

      This registers the ctx MCP server and syncs any steering files into the tool's native format. Re-run after adding or changing steering files.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#5-verify-it-works","level":3,"title":"5. Verify It Works","text":"

      Ask your AI: \"Do you remember?\"

      It should cite specific context: current tasks, recent decisions, or previous session topics.

      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#6-set-up-companion-tools-highly-recommended","level":3,"title":"6. Set Up Companion Tools (Highly Recommended)","text":"

      ctx works on its own, but two companion MCP servers unlock significantly better agent behavior. The investment is small and the benefits compound over sessions:

      • Gemini Search grounded web search with citations. Skills like /ctx-code-review and /ctx-explain use it for up-to-date documentation lookups instead of relying on training data.
      • GitNexus: code knowledge graph with symbol resolution, blast radius analysis, and domain clustering. Skills like /ctx-refactor and /ctx-code-review use it for impact analysis and dependency awareness.

      # Index your project for GitNexus (run once, then after major changes)\nnpx gitnexus analyze\n

      Both are optional MCP servers: if they are not connected, skills degrade gracefully to built-in capabilities. See Companion Tools for setup details and verification.

      Next Up:

      • Your First Session →: a step-by-step walkthrough from ctx init to verified recall
      • Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history
      ","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/hub/","level":1,"title":"Hub","text":"","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#sharing-is-caring","level":2,"title":"Sharing Is Caring","text":"

      ctx projects are normally independent: each project has its own .context/ directory, its own decisions, its own learnings, its own journal. That's the right default, since most work is project-local, and mixing context across projects tends to dilute more than it helps.

      But sometimes a decision or a learning should cross project boundaries. A convention you codified in one project deserves to be visible in another. A gotcha you discovered debugging service A is the same gotcha waiting for you in service B. The ctx Hub is the feature that makes those specific entries travel, without replicating everything else.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#what-the-hub-actually-is","level":2,"title":"What the Hub Actually Is","text":"

      In one paragraph: the ctx Hub is a fan-out channel for four specific kinds of structured entries: decision, learning, convention, and task. You publish an entry with ctx add --share in one project, and it appears in .context/hub/ for every other project subscribed to that type. When you run ctx agent --include-hub, those shared entries become part of your next agent context packet.

      That is the entire feature. The Hub does not:

      • Share your session journal (.context/journal/). That stays local to each project.
      • Share your scratchpad (.context/pad). Encrypted notes never leave the machine that created them.
      • Share your TASKS.md, DECISIONS.md, LEARNINGS.md, or CONVENTIONS.md wholesale. Only entries you explicitly --share cross the boundary.
      • Provide user identity or attribution. The Hub identifies projects, not people.

      If you want \"my agent in project B sees everything my agent did in project A,\" that's not the Hub. Local session density stays local.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#who-its-for","level":2,"title":"Who It's For","text":"

      Two shapes, same mechanics, different trust models.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"

      One developer, many projects. You want a learning from project A to show up when you open project B a week later. You want a convention you codified in your dotfiles project to be visible everywhere else on your workstation. Run a Hub on localhost, register each project, done.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#small-trusted-team","level":3,"title":"Small Trusted Team","text":"

      A few teammates on a LAN or a hub.ctx-like self-hosted server. You want team conventions to propagate without a wiki. You want lessons from one on-call engineer's 3 AM incident to reach everyone else's agent on the next session. Same mechanics as the personal case, plus TLS in front and a short security runbook.

      The Hub is not a multi-tenant public service. It assumes everyone holding a client token is friendly. Don't stand up hub.example.com for untrusted participants.

      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#going-further","level":2,"title":"Going Further","text":"
      • First-time setup: Hub: Getting Started, a five-minute walkthrough on localhost.
      • Mental model and user stories: Hub Overview, what flows, what doesn't, and when not to use it.
      • Team / LAN deployment: Multi-machine setup.
      • Redundancy: HA cluster.
      • Operating a Hub: Hub Operations and Hub Failure Modes.
      • Security posture: Hub Security Model.
      • Command reference: ctx serve, ctx connect, ctx hub.
      ","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/is-ctx-right/","level":1,"title":"Is It Right for Me?","text":"","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#good-fit","level":2,"title":"Good Fit","text":"

      ctx shines when context matters more than code.

      If any of these sound like your project, it's worth trying:

      • Multi-session AI work: You use AI across many sessions on the same codebase, and re-explaining is slowing you down.
      • Architectural decisions that matter: Your project has non-obvious choices (database, auth strategy, API design) that the AI keeps second-guessing.
      • \"Why\" matters as much as \"what\": you need the AI to understand rationale, not just current code
      • Team handoffs: Multiple people (or multiple AI tools) work on the same project and need shared context.
      • AI-assisted development across tools: Uou switch between Claude Code, Cursor, Copilot, or other tools and want context to follow the project, not the tool.
      • Long-lived projects: Anything you'll work on for weeks or months, where accumulated knowledge has compounding value.
      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#may-not-be-the-right-fit","level":2,"title":"May Not Be the Right Fit","text":"

      ctx adds overhead that isn't worth it for every project. Be honest about when to skip it:

      • One-off scripts: If the project is a single file you'll finish today, there's nothing to remember.
      • RAG-only workflows: If retrieval from an external knowledge base already gives the agent everything it needs for each session, adding ctx may be unnecessary. RAG retrieves information; ctx defines the project's working memory: They are complementary.
      • No AI involvement: ctx is designed for human-AI workflows; without an AI consumer, the files are just documentation.
      • Enterprise-managed context platforms: If your organization provides centralized context services, ctx may duplicate that layer.

      For a deeper technical comparison with RAG, prompt management tools, and agent frameworks, see ctx and Similar Tools.

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#project-size-guide","level":2,"title":"Project Size Guide","text":"","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#solo-developer-single-repo","level":3,"title":"Solo Developer, Single Repo","text":"

      This is ctx's sweet spot.

      You get the most value here: one person, one project, decisions, and learnings accumulating over time. Setup takes 5 minutes and the .context/ directory directory stays small, and every session gets faster.

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#small-team-one-or-two-repos","level":3,"title":"Small Team, One or Two Repos","text":"

      Works well.

      Context files commit to git, so the whole team shares the same decisions and conventions. Each person's AI starts with the team's decisions already loaded. Merge conflicts on .context/ files are rare and easy to resolve (they are just Markdown).

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#multiple-repos-or-larger-teams","level":3,"title":"Multiple Repos or Larger Teams","text":"

      ctx operates per repository.

      Each repo has its own .context/ directory with its own decisions, tasks, and learnings. This matches the way code, ownership, and history already work in git.

      There is no built-in cross-repo context layer.

      For organizations that need centralized, organization-wide knowledge, ctx complements a platform solution by providing durable, project-local working memory for AI sessions.

      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#5-minute-trial","level":2,"title":"5-Minute Trial","text":"

      Zero commitment. Try it, and delete .context/ if it's not for you.

      Using Claude Code?

      Install the ctx plugin from the Marketplace for Claude-native hooks, skills, and automatic context loading:

      1. Type /plugin and press Enter
      2. Select Marketplaces → Add Marketplace
      3. Enter ActiveMemory/ctx
      4. Back in /plugin, select Install and choose ctx

      You'll still need the ctx binary for the CLI: See Getting Started for install options.

      # 1. Initialize\ncd your-project\nctx init\n\n# 2. Activate the project (bind CTX_DIR for this shell).\n#    Required: ctx does not walk the filesystem to find .context/.\neval \"$(ctx activate)\"\n\n# 3. Add one real decision from your project\nctx decision add \"Your actual architectural choice\" \\\n  --context \"What prompted this decision\" \\\n  --rationale \"Why you chose this approach\" \\\n  --consequence \"What changes as a result\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# 4. Check what the AI will see\nctx status\n\n# 5. Start an AI session and ask: \"Do you remember?\"\n

      If the AI cites your decision back to you, it's working.

      Want to remove it later? One command:

      rm -rf .context/\n

      No dependencies to uninstall. No configuration to revert. Just files.

      Ready to try it out?

      • Join the Community→: Open Source is better together.
      • Getting Started →: Full installation and setup.
      • ctx and Similar Tools →: Detailed comparison with other approaches.
      ","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/joining-a-project/","level":1,"title":"Joining a Project","text":"

      You've joined a team or inherited a project, and there's a .context/ directory in the repo. Good news: someone already set up persistent context. This page gets you oriented fast.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#what-to-read-first","level":2,"title":"What to Read First","text":"

      The files in .context/ have a deliberate priority order. Read them top-down:

      1. CONSTITUTION.md: Hard rules. Read this before you touch anything. These are inviolable constraints the team has agreed on.
      2. TASKS.md: Current and planned work. Shows what's in progress, what's pending, and what's blocked.
      3. CONVENTIONS.md: How the team writes code. Naming patterns, file organization, preferred idioms.
      4. ARCHITECTURE.md: System overview. Components, boundaries, data flow.
      5. DECISIONS.md: Why things are the way they are. Saves you from re-proposing something the team already evaluated and rejected.
      6. LEARNINGS.md: Gotchas, tips, and hard-won lessons. The stuff that doesn't fit anywhere else but will save you hours.

      See Context Files for detailed documentation of each file's structure and purpose.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#activate-the-project","level":2,"title":"Activate the Project","text":"

      Tell ctx which .context/ directory to read from:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the commands in the rest of this guide fail with Error: no context directory specified. Direnv users can wire it into .envrc and forget about it. See Activating a Context Directory for more options (multiple .context/ directories, scripts, CI).

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#checking-context-health","level":2,"title":"Checking Context Health","text":"

      Before you start working, check whether the context is current:

      ctx status\n

      This shows file counts, token estimates, and recent activity. If files haven't been touched in weeks, the context may be stale.

      ctx drift\n

      This compares context files against recent code changes and flags potential drift: decisions that no longer match the codebase, conventions that have shifted, or tasks that look outdated.

      If things are stale, mention it to the team. Don't silently fix it yourself on day one.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#starting-your-first-session","level":2,"title":"Starting Your First Session","text":"

      Generate a context packet to prime your AI:

      ctx agent --budget 8000\n

      This outputs a token-budgeted summary of the project context, ordered by priority. With Claude Code and the ctx plugin, context loads automatically via hooks. You can also use the /ctx-remember skill to get a structured readback of what the AI knows.

      The readback is your verification step: if the AI can cite specific tasks and decisions, the context is working.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#adding-context","level":2,"title":"Adding Context","text":"

      As you work, you'll discover things worth recording. Use the CLI:

      # Record a decision you made or learned about\nctx decision add \"Use connection pooling for DB access\" \\\n  --rationale \"Reduces connection overhead under load\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Capture a gotcha you hit\nctx learning add \"Redis timeout defaults to 5s\" \\\n  --context \"Hit timeouts during bulk operations\" \\\n  --application \"Set explicit timeout for batch jobs\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Add a convention you noticed the team follows\nctx convention add \"All API handlers return structured errors\"\n

      You can also just tell the AI: \"Record this as a learning\" or \"Add this decision to context.\" With the ctx plugin, context-update commands handle the file writes.

      See the Knowledge Capture recipe for the full workflow.

      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#session-etiquette","level":2,"title":"Session Etiquette","text":"

      A few norms for working in a ctx-managed project:

      • Respect existing conventions. If CONVENTIONS.md says \"use filepath.Join,\" use filepath.Join. If you disagree, propose a change, don't silently diverge.
      • Don't restructure context files without asking. The file layout and section structure are shared state. Reorganizing them affects every team member and every AI session.
      • Mark tasks done when complete. Check the box ([x]) in place. Don't move tasks between sections or delete them.
      • Add context as you go. Decisions, learnings, and conventions you discover are valuable to the next person (or the next session).
      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"

      Ignoring CONSTITUTION.md. The constitution exists for a reason. If a task conflicts with a constitution rule, the task is wrong. Raise it with the team instead of working around the constraint.

      Deleting tasks. Never delete a task from TASKS.md. Mark it [x] (done) or [-] (skipped with a reason). The history matters for session replay and audit.

      Bypassing hooks. If the project uses ctx hooks (pre-commit nudges, context autoloading), don't disable them. They exist to keep context fresh. If a hook is noisy or broken, fix it or file a task.

      Over-contributing on day one. Read first, then contribute. Adding a dozen learnings before you understand the project's norms creates noise, not signal.

      Related:

      • Getting Started: installation and setup from scratch
      • Context Files: detailed file reference
      • Knowledge Capture: recording decisions, learnings, and conventions
      • Session Lifecycle: how a typical AI session flows with ctx
      ","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/keeping-ai-honest/","level":1,"title":"Keeping AI Honest","text":"","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-problem","level":2,"title":"The Problem","text":"

      AI agents confabulate. They invent history that never happened, claim familiarity with decisions that were never made, and sometimes declare a task complete when it is not. This is not malice - it is the default behavior of a system optimizing for plausible-sounding responses.

      When your AI says \"we decided to use Redis for caching last week,\" can you verify that? When it says \"the auth module is complete,\" can you confirm it? Without grounded, persistent context, the answer is no. You are trusting vibes.

      ctx replaces vibes with verifiable artifacts.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#grounded-memory","level":2,"title":"Grounded Memory","text":"

      Every entry in ctx context files has a timestamp and structured fields. When the AI cites a decision, you can check it.

      ## [2026-01-28-143022] Use Event Sourcing for Audit Trail\n\n**Status**: Accepted\n\n**Context**: Compliance requires full mutation history.\n\n**Decision**: Event sourcing for the audit subsystem only.\n\n**Rationale**: Append-only log meets compliance requirements\nwithout imposing event sourcing on the entire domain model.\n

      The timestamp 2026-01-28-143022 is not decoration. It is a verifiable anchor. If the AI references this decision, you can open DECISIONS.md, find the entry, and confirm it says what the AI claims. If the entry does not exist, the AI is hallucinating - and you know immediately.

      This is grounded memory: claims that trace back to artifacts you control and can audit.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#constitutionmd-hard-guardrails","level":2,"title":"CONSTITUTION.md: Hard Guardrails","text":"

      CONSTITUTION.md defines rules the AI must treat as inviolable. These are not suggestions or best practices - they are constraints that override task requirements.

      # Constitution\n\nThese rules are INVIOLABLE. If a task requires violating these,\nthe task is wrong.\n\n* [ ] Never commit secrets, tokens, API keys, or credentials\n* [ ] All public API changes require a decision record\n* [ ] Never delete context files without explicit user approval\n

      The AI reads these at session start, before anything else. A well- integrated agent will refuse a task that conflicts with a constitutional rule, citing the specific rule it would violate.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-agent-playbooks-anti-hallucination-rules","level":2,"title":"The Agent Playbook's Anti-Hallucination Rules","text":"

      The AGENT_PLAYBOOK.md file includes a section called \"How to Avoid Hallucinating Memory\" with five explicit rules:

      1. Never assume. If it is not in the context files, you do not know it.
      2. Never invent history. Do not claim \"we discussed\" something without a file reference.
      3. Verify before referencing. Search files before citing them.
      4. When uncertain, say so. \"I don't see a decision on this\" is always better than a fabricated one.
      5. Trust files over intuition. If the files say PostgreSQL but your training data suggests MySQL, the files win.

      These rules create a behavioral contract. The AI is not left to guess how confident it should be - it has explicit instructions to ground every claim in the context directory.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#drift-detection","level":2,"title":"Drift Detection","text":"

      Context files can go stale. You rename a package, delete a module, or finish a sprint, and suddenly ARCHITECTURE.md references paths that no longer exist. Stale context is almost as dangerous as no context: the AI treats outdated information as current truth.

      ctx drift detects this divergence:

      ctx drift\n

      It scans context files for references to files, paths, and symbols that no longer exist in the codebase. Stale references get flagged so you can update or remove them before they mislead the next session.

      Regular drift checks - weekly, or after major refactors - keep your context files honest the same way tests keep your code honest.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-verification-loop","level":2,"title":"The Verification Loop","text":"

      The /ctx-commit skill includes a built-in verification step: before staging, it maps claims to evidence and runs self-audit questions to surface gaps. This catches inconsistencies at the point where they matter most: right before code is committed.

      This closes the loop. You write context. The AI reads context. The verification step confirms that context still matches reality. When it does not, you fix it - and the next session starts from truth, not from drift.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#trust-through-structure","level":2,"title":"Trust through Structure","text":"

      The common thread across all of these mechanisms is structure over prose. Timestamps make claims verifiable. Constitutional rules make boundaries explicit. Drift detection makes staleness visible. The playbook makes behavioral expectations concrete.

      You do not need to trust the AI. You need to trust the system -- and verify when it matters.

      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#further-reading","level":2,"title":"Further Reading","text":"
      • Detecting and Fixing Drift: the full workflow for keeping context files accurate
      • Invariants: the properties that must hold for any valid ctx implementation
      • Agent Security: threat model and mitigations for AI agents operating with persistent context
      ","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/prompting-guide/","level":1,"title":"Prompting Guide","text":"

      New to ctx?

      This guide references context files like TASKS.md, DECISIONS.md, and LEARNINGS.md:

      These are plain Markdown files that ctx maintains in your project's .context/ directory.

      If terms like \"context packet\" or \"session ceremony\" are unfamiliar,

      • start with the ctx Manifesto for the why,
      • About for the big picture,
      • then Getting Started to set up your first project.
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#literature-matters","level":2,"title":"Literature Matters","text":"

      This guide is about crafting effective prompts for working with AI assistants in ctx-enabled projects, but the guidelines given here apply to other AI systems, too.

      The right prompt triggers the right behavior.

      This guide documents prompts that reliably produce good results.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#tldr","level":2,"title":"TL;DR","text":"Goal Prompt Load context \"Do you remember?\" Resume work \"What's the current state?\" What's next /ctx-next Debug \"Why doesn't X work?\" Validate \"Is this consistent with our decisions?\" Impact analysis \"What would break if we...\" Reflect /ctx-reflect Wrap up /ctx-wrap-up Persist \"Add this as a learning\" Explore \"How does X work in this codebase?\" Sanity check \"Is this the right approach?\" Completeness \"What am I missing?\" One more thing \"What's the single smartest addition?\" Set tone \"Push back if my assumptions are wrong.\" Constrain scope \"Only change files in X. Nothing else.\" Course correct \"Stop. That's not what I meant.\" Check health \"Run ctx drift\" Commit /ctx-commit","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#session-start","level":2,"title":"Session Start","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#do-you-remember","level":3,"title":"\"do you remember?\"","text":"

      Triggers the AI to silently read TASKS.md, DECISIONS.md, LEARNINGS.md, and check recent history via ctx journal before responding with a structured readback:

      1. Last session: most recent session topic and date
      2. Active work: pending or in-progress tasks
      3. Recent context: 1-2 recent decisions or learnings
      4. Next step: offer to continue or ask what to focus on

      Use this at the start of every important session.

      Do you remember what we were working on?\n

      This question implies prior context exists. The AI checks files rather than admitting ignorance. The expected response cites specific context (session names, task counts, decisions), not vague summaries.

      If the AI instead narrates its discovery process (\"Let me check if there are files...\"), it has not loaded CLAUDE.md or AGENT_PLAYBOOK.md properly.

      For a detailed case study on making agents actually follow this protocol (including the failure modes, the timing problem, and the hook design that solved it) see The Dog Ate My Homework.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#whats-the-current-state","level":3,"title":"\"What's the Current State?\"","text":"

      Prompts reading of TASKS.md, recent sessions, and status overview.

      Use this when resuming work after a break.

      Variants:

      • \"Where did we leave off?\"
      • \"What's in progress?\"
      • \"Show me the open tasks.\"
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#during-work","level":2,"title":"During Work","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#why-doesnt-x-work","level":3,"title":"\"Why Doesn't X Work?\"","text":"

      This triggers root cause analysis rather than surface-level fixes.

      Use this when something fails unexpectedly.

      Framing as \"why\" encourages investigation before action. The AI will trace through code, check configurations, and identify the actual cause.

      Real Example

      \"Why can't I run /ctx-reflect?\" led to discovering missing permissions in settings.local.json bootstrapping.

      This was a fix that benefited all users of ctx.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#is-this-consistent-with-our-decisions","level":3,"title":"\"Is This Consistent with Our Decisions?\"","text":"

      This prompts checking DECISIONS.md before implementing.

      Use this before making architectural choices.

      Variants:

      • \"Check if we've decided on this before\"
      • \"Does this align with our conventions?\"
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-would-break-if-we","level":3,"title":"\"What Would Break If We...\"","text":"

      This triggers defensive thinking and impact analysis.

      Use this before making significant changes.

      What would break if we change the Settings struct?\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#before-you-start-read-x","level":3,"title":"\"Before You Start, Read X\"","text":"

      This ensures specific context is loaded before work begins.

      Use this when you know the relevant context exists in a specific file.

      Before you start, check ctx journal source for the auth discussion session\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-control","level":3,"title":"Scope Control","text":"

      Constrain the AI to prevent sprawl. These are some of the most useful prompts in day-to-day work.

      Only change files in internal/cli/add/. Nothing else.\n
      No new files. Modify the existing implementation.\n
      Keep the public API unchanged. Internal refactor only.\n

      Use these when the AI tends to \"helpfully\" modify adjacent code, add documentation you didn't ask for, or create new abstractions.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#course-correction","level":3,"title":"Course Correction","text":"

      Steer the AI when it goes off-track: Don't wait for it to finish a wrong approach.

      Stop! That's not what I meant. Let me clarify.\n
      Let's step back. Explain what you're about to do before changing anything.\n
      Undo that last change and try a different approach.\n

      These work because they interrupt momentum.

      Without explicit course correction, the AI tends to commit harder to a wrong path rather than reconsidering.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#failure-modes","level":3,"title":"Failure Modes","text":"

      When the AI misbehaves, match the symptom to the recovery prompt:

      Symptom Recovery prompt Hand-waves (\"should work now\") \"Show evidence: file/line refs, command output, or test name.\" Creates unnecessary files \"No new files. Modify the existing implementation.\" Expands scope unprompted \"Stop after the smallest working change. Ask before expanding scope.\" Narrates instead of acting \"Skip the explanation. Make the change and show the diff.\" Repeats a failed approach \"That didn't work last time. Try a different approach.\" Claims completion without proof \"Run the test. Show me the output.\"

      These are recovery handles, not rules to paste into CLAUDE.md.

      Use them in the moment when you see the behavior.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#reflection-and-persistence","level":2,"title":"Reflection and Persistence","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-did-we-learn","level":3,"title":"\"What Did We Learn?\"","text":"

      This prompts reflection on the session and often triggers adding learnings to LEARNINGS.md.

      Use this after completing a task or debugging session.

      This is an explicit reflection prompt. The AI will summarize insights and often offer to persist them.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#add-this-as-a-learningdecision","level":3,"title":"\"Add This as a Learning/decision\"","text":"

      This is an explicit persistence request.

      Use this when you have discovered something worth remembering.

      Add this as a learning: \"JSON marshal escapes angle brackets by default\"\n\n# or simply.\nAdd this as a learning.\n# and let the AI autonomously infer and summarize.\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#save-context-before-we-end","level":3,"title":"\"Save Context Before We End\"","text":"

      This triggers context persistence before the session closes.

      Use it at the end of the session or before switching topics.

      Variants:

      • \"Let's persist what we did\"
      • \"Update the context files\"
      • /ctx-wrap-up:the recommended end-of-session ceremony (see Session Ceremonies)
      • /ctx-reflect: mid-session reflection checkpoint
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#exploration-and-research","level":2,"title":"Exploration and Research","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#explore-the-codebase-for-x","level":3,"title":"\"Explore the Codebase for X\"","text":"

      This triggers thorough codebase search rather than guessing.

      Use this when you need to understand how something works.

      This works because \"Explore\" signals that investigation is needed, not immediate action.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#how-does-x-work-in-this-codebase","level":3,"title":"\"How Does X Work in This Codebase?\"","text":"

      This prompts reading actual code rather than explaining general concepts.

      Use this to understand the existing implementation.

      How does session saving work in this codebase?\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#find-all-places-where-x","level":3,"title":"\"Find All Places Where X\"","text":"

      This triggers a comprehensive search across the codebase.

      Use this before refactoring or understanding the impact.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#meta-and-process","level":2,"title":"Meta and Process","text":"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-should-we-document-from-this","level":3,"title":"\"What Should We Document from This?\"","text":"

      This prompts identifying learnings, decisions, and conventions worth persisting.

      Use this after complex discussions or implementations.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#is-this-the-right-approach","level":3,"title":"\"Is This the Right Approach?\"","text":"

      This invites the AI to challenge the current direction.

      Use this when you want a sanity check.

      This works because it allows AI to disagree.

      AIs often default to agreeing; this prompt signals you want an honest assessment.

      Stronger variant: \"Push back if my assumptions are wrong.\" This sets the tone for the entire session: The AI will flag questionable choices proactively instead of waiting to be asked.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-am-i-missing","level":3,"title":"\"What Am I Missing?\"","text":"

      This prompts thinking about edge cases, overlooked requirements, or unconsidered approaches.

      Use this before finalizing a design or implementation.

      Forward-looking variant: \"What's the single smartest addition you could make to this at this point?\" Use this after you think you're done: It surfaces improvements you wouldn't have thought to ask for. The constraint to one thing prevents feature sprawl.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#cli-commands-as-prompts","level":2,"title":"CLI Commands as Prompts","text":"

      Asking the AI to run ctx commands is itself a prompt. These load context or trigger specific behaviors:

      Command What it does \"Run ctx status\" Shows context summary, file presence, staleness \"Run ctx agent\" Loads token-budgeted context packet \"Run ctx drift\" Detects dead paths, stale files, missing context","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ctx-skills","level":3,"title":"ctx Skills","text":"

      The SKILS.md Standard

      Skills are formalized prompts stored as SKILL.md files.

      The /slash-command syntax below is Claude Code specific.

      Other agents can use the same skill files, but invocation may differ.

      Use ctx skills by name:

      Skill When to use /ctx-status Quick context summary /ctx-agent Load full context packet /ctx-remember Recall project context and structured readback /ctx-wrap-up End-of-session context persistence /ctx-history Browse session history for past discussions /ctx-reflect Structured reflection checkpoint /ctx-next Suggest what to work on next /ctx-commit Commit with context persistence /ctx-drift Detect and fix context drift /ctx-implement Execute a plan step-by-step with verification /ctx-loop Generate autonomous loop script /ctx-pad Manage encrypted scratchpad /ctx-archive Archive completed tasks /check-links Audit docs for dead links

      Ceremony vs. Workflow Skills

      Most skills work conversationally: \"what should we work on?\" triggers /ctx-next, \"save that as a learning\" triggers /ctx-learning-add. Natural language is the recommended approach.

      Two skills are the exception: /ctx-remember and /ctx-wrap-up are ceremony skills for session boundaries: Invoke them as explicit slash commands: conversational triggers risk partial execution. See Session Ceremonies.

      Skills combine a prompt, tool permissions, and domain knowledge into a single invocation.

      Skills beyond Claude Code

      The /slash-command syntax above is Claude Code native, but the underlying SKILL.md files are a standard markdown format that any agent can consume. If you use a different coding agent, consult its documentation for how to load skill files as prompt templates.

      See Integrations for setup details.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#anti-patterns","level":2,"title":"Anti-Patterns","text":"

      Based on our ctx development experience (i.e., \"sipping our own champagne\") so far, here are some prompts that tend to produce poor results:

      Prompt Problem Better Alternative \"Fix this\" Too vague, may patch symptoms \"Why is this failing?\" \"Make it work\" Encourages quick hacks \"What's the right way to solve this?\" \"Just do it\" Skips planning \"Plan this, then implement\" \"You should remember\" Confrontational \"Do you remember?\" \"Obviously...\" Discourages questions State the requirement directly \"Idiomatic X\" Triggers language priors \"Follow project conventions\" \"Implement everything\" No phasing, sprawl risk Break into tasks, implement one at a time \"You should know this\" Assumes context is loaded \"Before you start, read X\"","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#reliability-checklist","level":2,"title":"Reliability Checklist","text":"

      Before sending a non-trivial prompt, check these four elements. This is the guide's DNA in one screenful.

      1. Goal in one sentence: What does \"done\" look like?
      2. Files to read: What existing code or context should the AI review before acting?
      3. Verification command: How will you prove it worked? (test name, CLI command, expected output)
      4. Scope boundary: What should the AI not touch?

      A prompt that covers all four is almost always good enough.

      A prompt missing #3 is how you get \"should work now\" without evidence.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#safety-invariants","level":2,"title":"Safety Invariants","text":"

      These Are Invariants: Not Suggestions

      A prompting guide earns its trust by being honest about risk.

      These four rules mentioned below don't change with model versions, agent frameworks, or project size.

      Build them into your workflow once and stop thinking about them.

      Tool-using agents can read files, run commands, and modify your codebase. That power makes them useful. It also creates a trust boundary you should be aware of.

      These invariants apply regardless of which agent or model you use.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#treat-the-repository-text-as-untrusted-input","level":3,"title":"Treat the Repository Text as \"Untrusted Input\"","text":"

      Issue descriptions, PR comments, commit messages, documentation, and even code comments can contain text that looks like instructions. An agent that reads a GitHub issue and then runs a command found inside it is executing untrusted input.

      The rule: Before running any command the agent found in repo text (issues, docs, comments), restate the command explicitly and confirm it does what you expect. Don't let the agent copy-paste from untrusted sources into a shell.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ask-before-destructive-operations","level":3,"title":"Ask Before Destructive Operations","text":"

      git push --force, rm -rf, DROP TABLE, docker system prune: these are irreversible or hard to reverse. A good agent should pause before running them, but don't rely on that.

      The rule: For any operation that deletes data, overwrites history, or affects shared infrastructure, require explicit confirmation. If the agent runs something destructive without asking, that's a course-correction moment: \"Stop. Never run destructive commands without asking first.\"

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-the-blast-radius","level":3,"title":"Scope the Blast Radius","text":"

      An agent told to \"fix the tests\" might modify test fixtures, change assertions, or delete tests that inconveniently fail. An agent told to \"deploy\" might push to production. Broad mandates create broad risk.

      The rule: Constrain scope before starting work. The Reliability Checklist's scope boundary (#4) is your primary safety lever. When in doubt, err on the side of a tighter boundary.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#secrets-never-belong-in-context","level":3,"title":"Secrets Never Belong in Context","text":"

      LEARNINGS.md, DECISIONS.md, and session transcripts are plain-text files that may be committed to version control.

      Don't persist API keys, passwords, tokens, or credentials in context files.

      The rule: If the agent encounters a secret during work, it should use it transiently (environment variable, an alias to the secret instead of the actual secret, etc.) and never write it to a context file.

      Any Secret Seen IS Exposed

      If you see a secret in a context file, remove it immediately and rotate the credential.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#explore-plan-implement","level":2,"title":"Explore → Plan → Implement","text":"

      For non-trivial work, name the phase you want:

      Explore src/auth and summarize the current flow.\nThen propose a plan. After I approve, implement with tests.\n

      This prevents the AI from jumping straight to code.

      The three phases map to different modes of thinking:

      • Explore: read, search, understand: no changes
      • Plan: propose approach, trade-offs, scope: no changes
      • Implement: write code, run tests, verify: changes

      Small fixes skip straight to implement. Complex or uncertain work benefits from all three.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#prompts-by-task-type","level":2,"title":"Prompts by Task Type","text":"

      Different tasks need different prompt structures. The pattern: symptom + location + verification.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#bugfix","level":3,"title":"Bugfix","text":"
      Users report search returns empty results for queries with hyphens.\nReproduce in src/search/. Write a failing test for \"foo-bar\",\nfix the root cause, run: go test ./internal/search/...\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#refactor","level":3,"title":"Refactor","text":"
      Inspect src/auth/ and list duplication hotspots.\nPropose a refactor plan scoped to one module.\nAfter approval, remove duplication without changing behavior.\nAdd a test if coverage is missing. Run: make audit\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#research","level":3,"title":"Research","text":"
      Explore the request flow around src/api/.\nSummarize likely bottlenecks with evidence.\nPropose 2-3 hypotheses. Do not implement yet.\n
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#docs","level":3,"title":"Docs","text":"
      Update docs/cli-reference.md to reflect the new --format flag.\nConfirm the flag exists in the code and the example works.\n

      Notice each prompt includes what to verify and how. Without that, you get a \"should work now\" instead of evidence.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#writing-tasks-as-prompts","level":2,"title":"Writing Tasks as Prompts","text":"

      Tasks in TASKS.md are indirect prompts to the AI. How you write them shapes how the AI approaches the work.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#state-the-motivation-not-just-the-goal","level":3,"title":"State the Motivation, Not Just the Goal","text":"

      Tell the AI why you are building something, not just what.

      Bad: \"Build a calendar view.\"

      Good: \"Build a calendar view. The motivation is that all notes and tasks we build later should be viewable here.\"

      The second version lets the AI anticipate downstream requirements:

      It will design the calendar's data model to be compatible with future features: Without you having to spell out every integration point. Motivation turns a one-off task into a directional task.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#state-the-deliverable-not-just-steps","level":3,"title":"State the Deliverable, Not Just Steps","text":"

      Bad task (implementation-focused):

      - [ ] T1.1.0: Parser system\n  - [ ] Define data structures\n  - [ ] Implement line parser\n  - [ ] Implement session grouper\n

      The AI may complete all subtasks but miss the actual goal. What does \"Parser system\" deliver to the user?

      Good task (deliverable-focused):

      - [ ] T1.1.0: Parser CLI command\n  **Deliverable**: `ctx journal source` command that shows parsed sessions\n  - [ ] Define data structures\n  - [ ] Implement line parser\n  - [ ] Implement session grouper\n

      Now the AI knows the subtasks serve a specific user-facing deliverable.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#use-acceptance-criteria","level":3,"title":"Use Acceptance Criteria","text":"

      For complex tasks, add explicit \"done when\" criteria:

      - [ ] T2.0: Authentication system\n  **Done when**:\n  - [ ] User can register with email\n  - [ ] User can log in and get a token\n  - [ ] Protected routes reject unauthenticated requests\n

      This prevents premature \"task complete\" when only the implementation details are done, but the feature doesn't actually work.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#subtasks-parent-task","level":3,"title":"Subtasks ≠ Parent Task","text":"

      Completing all subtasks does not mean the parent task is complete.

      The parent task describes what the user gets.

      Subtasks describe how to build it.

      Always re-read the parent task description before marking it complete. Verify the stated deliverable exists and works.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#why-do-these-approaches-work","level":2,"title":"Why Do These Approaches Work?","text":"

      The patterns in this guide aren't invented here: They are practitioner translations of well-established, peer-reviewed research, most of which predate the current AI (hype) wave.

      The underlying ideas come from decades of work in machine learning, cognitive science, and numerical optimization. For a concrete case study showing how these principles play out when an agent decides whether to follow instructions (attention competition, optimization toward least-resistance paths, and observable compliance as a design goal) see The Dog Ate My Homework.

      Phased work (\"Explore → Plan → Implement\") applies chain-of-thought reasoning: Decomposing a problem into sequential steps before acting. Forcing intermediate reasoning steps measurably improves output quality in language models, just as it does in human problem-solving. Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (2022).

      Root-cause prompts (\"Why doesn't X work?\") use step-back abstraction: Retreating to a higher-level question before diving into specifics. This mirrors how experienced engineers debug: they ask \"what should happen?\" before asking \"what went wrong?\" Zheng et al., Take a Step Back: Evoking Reasoning via Abstraction in Large Language Models (2023).

      Exploring alternatives (\"Propose 2-3 approaches\") leverages self-consistency: Generating multiple independent reasoning paths and selecting the most coherent result. The idea traces back to ensemble methods in ML: A committee of diverse solutions outperforms any single one. Wang et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models (2022).

      Impact analysis (\"What would break if we...\") is a form of tree-structured exploration: Branching into multiple consequence paths before committing. This is the same principle behind game-tree search (minimax, MCTS) that has powered decision-making systems since the 1950s. Yao et al., Tree of Thoughts: Deliberate Problem Solving with Large Language Models (2023).

      Motivation prompting (\"Build X because Y\") works through goal conditioning: Providing the objective function alongside the task. In optimization terms, you are giving the gradient direction, not just the loss. The model can make locally coherent decisions that serve the global objective because it knows what \"better\" means.

      Scope constraints (\"Only change files in X\") apply constrained optimization: Bounding the search space to prevent divergence. This is the same principle behind regularization in ML: Without boundaries, powerful optimizers find solutions that technically satisfy the objective but are practically useless.

      CLI commands as prompts (\"Run ctx status\") interleave reasoning with acting: The model thinks, acts on external tools, observes results, then thinks again. Grounding reasoning in real tool output reduces hallucination because the model can't ignore evidence it just retrieved. Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models (2022).

      Task decomposition (\"Prompts by Task Type\") applies least-to-most prompting: Breaking a complex problem into subproblems and solving them sequentially, each building on the last. This is the research version of \"plan, then implement one slice.\" Zhou et al., Least-to-Most Prompting Enables Complex Reasoning in Large Language Models (2022).

      Explicit planning (\"Explore → Plan → Implement\") is directly supported by plan-and-solve prompting, which addresses missing-step failures in zero-shot reasoning by extracting a plan before executing. The phased structure prevents the model from jumping to code before understanding the problem. Wang et al., Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning by Large Language Models (2023).

      Session reflection (\"What did we learn?\", /ctx-reflect) is a form of verbal reinforcement learning: Improving future performance by persisting linguistic feedback as memory rather than updating weights. This is exactly what LEARNINGS.md and DECISIONS.md provide: a durable feedback signal across sessions. Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning (2023).

      These aren't prompting \"hacks\" that you will find in the \"1000 AI Prompts for the Curious\" listicles: They are applications of foundational principles:

      • Decomposition,
      • Abstraction,
      • Ensemble Reasoning,
      • Search,
      • and Constrained Optimization.

      They work because language models are, at their core, optimization systems navigating probabilistic landscapes.

      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#further-reading","level":2,"title":"Further Reading","text":"
      • The Attention Budget: Why your AI forgets what you just told it, and how token budgets shape context strategy
      • The Dog Ate My Homework: A case study in making agents follow instructions: attention timing, delegation decay, and observable compliance as a design goal
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#contributing","level":2,"title":"Contributing","text":"

      Found a prompt that works well? Open an issue or PR with:

      1. The prompt text;
      2. What behavior it triggers;
      3. When to use it;
      4. Why it works (optional but helpful).

      Dive Deeper:

      • Recipes: targeted how-to guides for specific tasks
      • CLI Reference: all commands and flags
      • Integrations: setup for Claude Code, Cursor, Aider
      ","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/repeated-mistakes/","level":1,"title":"My AI Keeps Making the Same Mistakes","text":"","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#the-problem","level":2,"title":"The Problem","text":"

      You found a bug last Tuesday. You debugged it, understood the root cause, and moved on. Today, a new session hits the exact same bug. The AI rediscovers it from scratch, burning twenty minutes on something you already solved.

      Worse: you spent an hour last week evaluating two database migration strategies, picked one, documented why in a comment somewhere, and now the AI is cheerfully suggesting the approach you rejected. Again.

      This is not a model problem. It is a memory problem. Without persistent context, every session starts with amnesia.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#how-ctx-stops-the-loop","level":2,"title":"How ctx Stops the Loop","text":"

      ctx gives your AI three files that directly prevent repeated mistakes, each targeting a different failure mode.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#decisionsmd-stop-relitigating-settled-choices","level":3,"title":"DECISIONS.md: Stop Relitigating Settled Choices","text":"

      When you make an architectural decision, record it with rationale and rejected alternatives. The AI reads this at session start and treats it as settled.

      ## [2026-02-12] Use JWT for Authentication\n\n**Status**: Accepted\n\n**Context**: Need stateless auth for the API layer.\n\n**Decision**: JWT with short-lived access tokens and refresh rotation.\n\n**Rationale**: Stateless, scales horizontally, team has prior experience.\n\n**Alternatives Considered**:\n- Session-based auth: Rejected. Requires sticky sessions or shared store.\n- API keys only: Rejected. No user identity, no expiry rotation.\n

      Next session, when the AI considers auth, it reads this entry and builds on the decision instead of re-debating it. If someone asks \"why not sessions?\", the rationale is already there.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#learningsmd-capture-gotchas-once","level":3,"title":"LEARNINGS.md: Capture Gotchas Once","text":"

      Learnings are the bugs, quirks, and non-obvious behaviors that cost you time the first time around. Write them down so they cost you zero time the second time.

      ## Build\n\n### CGO Required for SQLite on Alpine\n\n**Discovered**: 2026-01-20\n\n**Context**: Docker build failed silently with \"no such table\" at runtime.\n\n**Lesson**: The go-sqlite3 driver requires CGO_ENABLED=1 and gcc\ninstalled in the build stage. Alpine needs apk add build-base.\n\n**Application**: Always use the golang:alpine image with build-base\nfor SQLite builds. Never set CGO_ENABLED=0.\n

      Without this entry, the next session that touches the Dockerfile will hit the same wall. With it, the AI knows before it starts.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#constitutionmd-draw-hard-lines","level":3,"title":"CONSTITUTION.md: Draw Hard Lines","text":"

      Some mistakes are not about forgetting - they are about boundaries the AI should never cross. CONSTITUTION.md sets inviolable rules.

      * [ ] Never commit secrets, tokens, API keys, or credentials\n* [ ] Never disable security linters without a documented exception\n* [ ] All database migrations must be reversible\n

      The AI reads these as absolute constraints. It does not weigh them against convenience. It refuses tasks that would violate them.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#the-accumulation-effect","level":2,"title":"The Accumulation Effect","text":"

      Each of these files grows over time. Session one captures two decisions. Session five adds a tricky learning about timezone handling. Session twelve records a convention about error message formatting.

      By session twenty, your AI has a knowledge base that no single person carries in their head. New team members - human or AI - inherit it instantly.

      The key insight: you are not just coding. You are building a knowledge layer that makes every future session faster.

      ctx files version with your code in git. They survive branch switches, team changes, and model upgrades. The context outlives any single session.

      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#getting-started","level":2,"title":"Getting Started","text":"

      Capture your first decision or learning right now:

      ctx decision add \"Use PostgreSQL\" \\\n  --context \"Need a relational database for the project\" \\\n  --rationale \"Team expertise, JSONB support, mature ecosystem\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\nctx learning add \"Vitest mock hoisting\" \\\n  --context \"Tests failing intermittently\" \\\n  --lesson \"vi.mock() must be at file top level\" \\\n  --application \"Use vi.doMock() for dynamic mocks\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n
      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#further-reading","level":2,"title":"Further Reading","text":"
      • Knowledge Capture: the full workflow for persisting decisions, learnings, and conventions
      • Context Files Reference: structure and format for every file in .context/
      • About ctx: the bigger picture - why persistent context changes how you work with AI
      ","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/steering/","level":1,"title":"Steering Files","text":"","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#steering-files","level":2,"title":"Steering Files","text":"

      ctx projects talk to AI assistants through several layers (context files, decisions, conventions, the agent context packet) but none of those can tell the assistant how to behave when a specific kind of prompt arrives. That's what steering files are for.

      A steering file is a small markdown document with YAML frontmatter that says: \"when the user asks about X, prepend these rules to the prompt.\" ctx manages those files in .context/steering/, decides which ones match each prompt, and syncs them out to each AI tool's native config (Claude Code, Cursor, Kiro, Cline) so the rules actually land in the prompt pipeline.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#not-the-same-as-decisions-or-conventions","level":2,"title":"Not the Same as Decisions or Conventions","text":"

      The three look similar on disk but serve different purposes:

      Kind Purpose Decisions (DECISIONS.md) What was chosen and why Conventions (CONVENTIONS.md) How the codebase is written Steering (.context/steering/*.md) How the AI should behave on matching prompts

      If you find yourself writing \"the AI should always do X when asked about Y,\" that belongs in steering, not decisions.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#your-first-steering-files","level":2,"title":"Your First Steering Files","text":"

      ctx init scaffolds four foundation steering files in .context/steering/ so you start with something to edit rather than an empty directory:

      File What to fill in product.md What the project is, who it's for, what's out of scope tech.md Languages, frameworks, runtime, hard constraints structure.md Directory layout, where new files go, naming rules workflow.md Branch strategy, commit conventions, pre-commit checks

      Each file starts with an inline HTML comment explaining the three inclusion modes, priority semantics, and tool scoping. The comment is invisible in rendered markdown but visible when you open the file to edit it; it's self-documenting scaffolding, not forever guidance. Delete the comment once you've customized the file.

      Default settings for foundation files:

      • inclusion: always: fires on every AI tool call
      • priority: 10: injected near the top of the prompt
      • tools: []: applies to every configured AI tool

      You should open each of these files and replace the placeholder content with your project's actual rules. Re-running ctx init is safe: existing files are left alone, so your edits survive. Use ctx init --no-steering-init to opt out of the scaffold entirely.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#inclusion-modes","level":2,"title":"Inclusion Modes","text":"

      Each steering file declares an inclusion mode in its frontmatter:

      Mode When the file is included always Every prompt, unconditionally auto When the prompt keywords match the file's description manual Only when the user explicitly names the file

      Which mode to pick depends on the AI tool you use, because the two tool families consume steering very differently.

      Claude Code and Codex: prefer inclusion: always for rules that must fire reliably. These tools have two delivery channels:

      1. The plugin's PreToolUse hook runs ctx agent with an empty prompt, so only always files match and get injected automatically on every tool call.
      2. The ctx_steering_get MCP tool, registered automatically when the ctx plugin is installed. Claude can call this tool mid-task to fetch auto or manual files matching a specific prompt. Verify with claude mcp list; look for ctx: ✓ Connected.

      Use always for invariants and anything that must fire every session. Use auto for situational rules where \"Claude fetches this when the prompt is relevant\" is the right behavior; those still land, just on Claude's judgment. Use manual for reference libraries you'll name explicitly.

      Cursor, Cline, Kiro: auto is the natural default. These tools read .cursor/rules/, .clinerules/, or .kiro/steering/ natively and resolve the description match on their own, so auto files fire when the prompt matches. manual files load on explicit invocation. always still works but consumes context budget on every turn.

      Mixed setups: if a rule must fire on Claude Code, pick always, even if it's overkill for your Cursor setup. The context budget cost is small; the alternative (silently not firing) is worse.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#two-families-of-ai-tools-two-delivery-paths","level":2,"title":"Two Families of AI Tools, Two Delivery Paths","text":"

      Not every AI tool consumes steering the same way. ctx handles two tool families differently, and it's worth knowing which family your editor is in before you wonder why a rule isn't firing.

      Native-rules tools (Cursor, Cline, Kiro) have a built-in rules primitive. They read a specific directory (.cursor/rules/, .clinerules/, .kiro/steering/) and apply the rules they find there. ctx handles these via ctx steering sync, which exports your files into the tool-native format. Run sync whenever you edit a steering file.

      Hook + MCP tools (Claude Code, Codex) have no native rules primitive, so ctx steering sync is a no-op for them. Instead, ctx delivers steering through two non-sync channels:

      1. Automatic injection via a PreToolUse hook. The ctx setup claude-code plugin wires a hook that runs ctx agent --budget 8000 before each tool call. ctx agent loads your steering files, filters them by the active prompt, and includes matching bodies in the context packet it prints. Claude Code feeds that output back into its context. Every tool call, automatically.
      2. On-demand via the ctx_steering_get MCP tool. The ctx MCP server exposes a tool Claude can call mid-task to fetch matching steering files for a specific prompt. Claude decides when to call it; it's not automatic.

      Both channels activate when you run ctx setup claude-code --write. After that, steering just works for Claude Code.

      Practical takeaway:

      • Using Cursor/Cline/Kiro only? Run ctx steering sync after edits.
      • Using Claude Code or Codex only? Never run sync; the hook+MCP pipeline handles it.
      • Using both? Run sync for the native-rules tools; the hook+MCP pipeline covers Claude Code automatically.
      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#two-shapes-of-automation-rules-and-scripts","level":2,"title":"Two Shapes of Automation: Rules and Scripts","text":"

      Steering is one of two hook-like layers ctx provides for customizing AI behavior. They're complementary:

      • Steering: persistent rules that get prepended to prompts. Declarative, text-only, scored by match.
      • Triggers: executable shell scripts that fire at lifecycle events. Imperative, runs arbitrary code, gated by exit codes.

      Pick steering when you want \"always remind the AI of X.\" Pick triggers when you want \"do Y when event Z happens.\" They can coexist; many projects use both.

      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#where-to-go-next","level":2,"title":"Where to Go Next","text":"
      • Writing Steering Files: a six-step walkthrough: scaffold, write the rule, preview matches, list, get-rules-in-front-of-the-AI (two paths depending on tool family), verify.
      • ctx steering reference: full command, flag, and frontmatter reference; includes the per-tool delivery-mechanism table and a dedicated section on how Claude Code and Codex consume steering.
      • ctx setup: configure which AI tools receive steering. For Cursor/Cline/Kiro this is about sync targets; for Claude Code/Codex it installs the plugin that wires the PreToolUse hook and MCP server.
      • Lifecycle Triggers: the imperative companion to steering files.
      ","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/triggers/","level":1,"title":"Lifecycle Triggers","text":"","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#lifecycle-triggers","level":2,"title":"Lifecycle Triggers","text":"

      Some things can't be expressed as a rule you want the AI to follow. Sometimes you want something to happen: block a dangerous tool call, inject today's standup notes into the next session, log every file save to a journal. That's what triggers are for.

      A trigger is an executable shell script that ctx runs at a specific lifecycle event: the start of a session, before a tool call, when a file is saved, and so on. Triggers read a JSON payload from stdin, do whatever they need, and write a JSON response on stdout. They can allow, block, or inject context into the pipeline depending on the event type.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#trigger-types","level":2,"title":"Trigger Types","text":"Type Fires when Use case session-start A new AI session begins Inject rotating context, standup notes session-end An AI session ends Persist summaries, send notifications pre-tool-use Before a tool call executes Block, gate, or audit post-tool-use After a tool call completes Log, react, post-process file-save A file is saved Lint on save, update indices context-add A new entry is added to .context/ Cross-link, notify, enrich","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#triggers-are-arbitrary-code-treat-them-like-pre-commit-hooks","level":2,"title":"Triggers Are Arbitrary Code: Treat Them like Pre-Commit Hooks","text":"

      Only Enable Scripts You've Read and Understand

      A trigger is a shell script with the executable bit set. It runs with the same privileges as your AI tool and receives JSON input on stdin. A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.

      ctx trigger add intentionally creates new scripts disabled (no executable bit). You must ctx trigger enable <name> after reviewing the contents. That's not a suggestion; it's the security model.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#three-hook-like-layers-in-ctx","level":2,"title":"Three Hook-like Layers in ctx","text":"

      Triggers are one of three distinct hook-like concepts in ctx. The names are similar but the owners and use cases are not:

      Layer Owned by Where they live When to use ctx trigger You .context/hooks/<type>/*.sh Project-specific automation, any AI tool ctx system hooks ctx itself built-in, wired into tool configs Built-in nudges (you don't author these) Claude Code hooks Claude Code .claude/settings.local.json Claude-Code-only tool-specific integration

      This page is about the first category. The other two run automatically and are invisible to you.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#triggers-vs-steering-same-problem-different-shape","level":2,"title":"Triggers vs Steering: Same Problem, Different Shape","text":"

      Triggers are the imperative counterpart to steering files. Steering expresses persistent rules the AI reads before each prompt; triggers express side effects that run on lifecycle events. They're complementary, not competing:

      • Want the AI to remember something? → Steering.
      • Want a script to run when something happens? → Trigger.

      Most projects use both.

      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#where-to-go-next","level":2,"title":"Where to Go Next","text":"
      • Authoring Lifecycle Triggers: walkthrough with security guidance: scaffold, test, enable, iterate.
      • ctx trigger reference: command reference, trigger type table, input/output contract.
      • Steering files: the declarative counterpart to triggers.
      ","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"operations/","level":1,"title":"Operations","text":"

      Guides for installing, upgrading, integrating, and running ctx. Split into three groups by audience.

      ","path":["Operations"],"tags":[]},{"location":"operations/#day-to-day","level":2,"title":"Day-to-Day","text":"

      Everyday operation guides for anyone running ctx in a project or adopting it in a team.

      ","path":["Operations"],"tags":[]},{"location":"operations/#integration","level":3,"title":"Integration","text":"

      Adopt ctx in an existing project: initialize context files, migrate from other tools, and onboard team members.

      ","path":["Operations"],"tags":[]},{"location":"operations/#upgrade","level":3,"title":"Upgrade","text":"

      Upgrade between versions with step-by-step migration notes and breaking-change guidance.

      ","path":["Operations"],"tags":[]},{"location":"operations/#ai-tools","level":3,"title":"AI Tools","text":"

      Configure ctx with Claude Code, Cursor, Aider, Copilot, Windsurf, and other AI coding tools.

      ","path":["Operations"],"tags":[]},{"location":"operations/#autonomous-loops","level":3,"title":"Autonomous Loops","text":"

      Run an unattended AI agent that works through tasks overnight, with ctx providing persistent memory between iterations.

      ","path":["Operations"],"tags":[]},{"location":"operations/#hub","level":2,"title":"Hub","text":"

      Operator guides for running a ctx Hub, the gRPC server that fans out structured entries across projects. If you're a client connecting to a Hub someone else runs, see ctx connect and the Hub recipes instead.

      ","path":["Operations"],"tags":[]},{"location":"operations/#hub-operations","level":3,"title":"Hub Operations","text":"

      Data directory layout, daemon management, systemd unit, backup and restore, log rotation, monitoring, and upgrades.

      ","path":["Operations"],"tags":[]},{"location":"operations/#hub-failure-modes","level":3,"title":"Hub Failure Modes","text":"

      What can go wrong in network, storage, cluster, auth, and clock layers, and what you should do about each one. Includes the short-list table oncall engineers will want bookmarked.

      ","path":["Operations"],"tags":[]},{"location":"operations/#maintainers","level":2,"title":"Maintainers","text":"

      Runbooks for people shipping ctx itself.

      ","path":["Operations"],"tags":[]},{"location":"operations/#cutting-a-release","level":3,"title":"Cutting a Release","text":"

      Step-by-step runbook for maintainers: bump version, generate release notes, run the release script, and verify the result.

      ","path":["Operations"],"tags":[]},{"location":"operations/#runbooks","level":2,"title":"Runbooks","text":"

      Step-by-step procedures you run with your agent. Each runbook includes a prompt to paste into a Claude Code session and guidance on triaging the results.

      Runbook Purpose When to run Release checklist Full pre-release sequence Before every release Plugin release Plugin-specific release steps Plugin changes ship Breaking migration Guide users across breaking changes Releases with renames Hub deployment Set up a ctx Hub end-to-end First-time hub setup New contributor Onboarding: clone to first session New contributors Codebase audit AST audits, magic strings, dead code, doc alignment Before release, quarterly Docs semantic audit Narrative gaps, weak pages, structural problems Before release, after adding pages Sanitize permissions Clean .claude/settings.local.json of over-broad grants After heavy permission granting Architecture exploration Systematic architecture docs across repos New codebase onboarding, reviews

      Recommended cadence:

      • Before every release: release checklist (which includes codebase audit + docs semantic audit)
      • Monthly: sanitize permissions
      • Quarterly: full sweep of all audit runbooks
      ","path":["Operations"],"tags":[]},{"location":"operations/autonomous-loop/","level":1,"title":"Autonomous Loops","text":"","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#autonomous-ai-development","level":2,"title":"Autonomous AI Development","text":"

      Iterate until done.

      An autonomous loop is an iterative AI development workflow where an agent works on tasks until completion, without constant human intervention.

      ctx provides the memory that makes this possible:

      • ctx provides the memory: persistent context that survives across iterations
      • The loop provides the automation: continuous execution until done

      Together, they enable fully autonomous AI development where the agent remembers everything across iterations.

      Origin

      This pattern is inspired by Geoffrey Huntley's Ralph Wiggum technique.

      We use generic terminology here so the concepts remain clear regardless of trends.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#how-it-works","level":2,"title":"How It Works","text":"
      graph TD\n    A[Start Loop] --> B[Load .context/loop.md]\n    B --> C[AI reads .context/]\n    C --> D[AI picks task from TASKS.md]\n    D --> E[AI completes task]\n    E --> F[AI updates context files]\n    F --> G[AI commits changes]\n    G --> H{Check signals}\n    H -->|SYSTEM_CONVERGED| I[Done - all tasks complete]\n    H -->|SYSTEM_BLOCKED| J[Done - needs human input]\n    H -->|Continue| B
      1. Loop reads .context/loop.md and invokes AI
      2. AI loads context from .context/
      3. AI picks one task and completes it
      4. AI updates context files (mark task done, add learnings)
      5. AI commits changes
      6. Loop checks for completion signals
      7. Repeat until converged or blocked
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#quick-start-shell-while-loop-recommended","level":2,"title":"Quick Start: Shell While Loop (Recommended)","text":"

      The best way to run an autonomous loop is a plain shell script that invokes your AI tool in a fresh process on each iteration. This is \"pure ralph\":

      The only state that carries between iterations is what lives in .context/ and the git history. No context window bleed, no accumulated tokens, no hidden state.

      Create a loop.sh:

      #!/bin/bash\n# loop.sh: an autonomous iteration loop\n\nPROMPT_FILE=\"${1:-.context/loop.md}\"\nMAX_ITERATIONS=\"${2:-10}\"\nOUTPUT_FILE=\"/tmp/loop_output.txt\"\n\nfor i in $(seq 1 $MAX_ITERATIONS); do\n  echo \"=== Iteration $i ===\"\n\n  # Invoke AI with prompt\n  cat \"$PROMPT_FILE\" | claude --print > \"$OUTPUT_FILE\" 2>&1\n\n  # Display output\n  cat \"$OUTPUT_FILE\"\n\n  # Check for completion signals\n  if grep -q \"SYSTEM_CONVERGED\" \"$OUTPUT_FILE\"; then\n    echo \"Loop complete: All tasks done\"\n    break\n  fi\n\n  if grep -q \"SYSTEM_BLOCKED\" \"$OUTPUT_FILE\"; then\n    echo \"Loop blocked: Needs human input\"\n    break\n  fi\n\n  sleep 2\ndone\n

      Make it executable and run:

      chmod +x loop.sh\n./loop.sh\n

      You can also generate this script with ctx loop (see CLI Reference).

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#why-do-we-use-a-shell-loop","level":3,"title":"Why Do We Use a Shell Loop?","text":"

      Each iteration starts a fresh AI process with zero context window history. The agent knows only what it reads from .context/ files: Exactly the information you chose to persist.

      This is the core loop principle: memory is explicit, not accidental.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#alternative-claude-codes-built-in-loop","level":2,"title":"Alternative: Claude Code's Built-in Loop","text":"

      Claude Code has built-in loop support:

      # Start autonomous loop\n/loop\n\n# Cancel running loop\n/cancel-loop\n

      This is convenient for quick iterations, but be aware of important caveats:

      This Loop Is Not Pure

      Claude Code's /loop runs all iterations within the same session. This means:

      • State leaks between iterations: The context window accumulates output from every previous iteration. The agent \"remembers\" things it saw earlier (even if they were never persisted to .context/).
      • Token budget degrades: Each iteration adds to the context window, leaving less room for actual work in later iterations.
      • Not ergonomic for long runs: Users report that the built-in loop is less predictable for 10+ iteration runs compared to a shell loop.

      For short explorations (2-5 iterations) or interactive use, /loop works fine. For overnight unattended runs or anything where iteration independence matters, use the shell while loop instead.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#the-contextloopmd-file","level":2,"title":"The .context/loop.md File","text":"

      The prompt file instructs the AI on how to work autonomously. Here's a template:

      # Autonomous Development Prompt\n\nYou are working on this project autonomously. Follow these steps:\n\n## 1. Load Context\n\nRead these files in order:\n\n1. `.context/CONSTITUTION.md`: NEVER violate these rules\n2. `.context/TASKS.md`: Find work to do\n3. `.context/CONVENTIONS.md`: Follow these patterns\n4. `.context/DECISIONS.md`: Understand past choices\n\n## 2. Pick One Task\n\nFrom `.context/TASKS.md`, select ONE task that is:\n\n- Not blocked\n- Highest priority available\n- Within your capabilities\n\n## 3. Complete the Task\n\n- Write code following conventions\n- Run tests if applicable\n- Keep changes focused and minimal\n\n## 4. Update Context\n\nAfter completing work:\n\n- Mark task complete in `TASKS.md`\n- Add any learnings to `LEARNINGS.md`\n- Add any decisions to `DECISIONS.md`\n\n## 5. Commit Changes\n\nCreate a focused commit with clear message.\n\n## 6. Signal Status\n\nEnd your response with exactly ONE of:\n\n- `SYSTEM_CONVERGED`: All tasks in TASKS.md are complete\n- `SYSTEM_BLOCKED`: Cannot proceed, need human input (explain why)\n- (no signal): More work remains, continue to next iteration\n\n## Rules\n\n- ONE task per iteration\n- NEVER skip tests\n- NEVER violate CONSTITUTION.md\n- Commit after each task\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#completion-signals","level":2,"title":"Completion Signals","text":"

      The loop watches for these signals in AI output:

      Signal Meaning When to Use SYSTEM_CONVERGED All tasks complete No pending tasks in TASKS.md SYSTEM_BLOCKED Cannot proceed Needs clarification, access, or decision BOOTSTRAP_COMPLETE Initial setup done Project scaffolding finished","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#example-usage","level":3,"title":"Example Usage","text":"

      converged state

      I've completed all tasks in TASKS.md:\n- [x] Set up project structure\n- [x] Implement core API\n- [x] Add authentication\n- [x] Write tests\n\nNo pending tasks remain.\n\nSYSTEM_CONVERGED\n

      blocked state

      I cannot proceed with the \"Deploy to production\" task because:\n- Missing AWS credentials\n- Need confirmation on region selection\n\nPlease provide credentials and confirm deployment region.\n\nSYSTEM_BLOCKED\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#why-ctx-and-loops-work-well-together","level":2,"title":"Why ctx and Loops Work Well Together","text":"Without ctx With ctx Each iteration starts fresh Each iteration has full history Decisions get re-made Decisions persist in DECISIONS.md Learnings are lost Learnings accumulate in LEARNINGS.md Tasks can be forgotten Tasks tracked in TASKS.md","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#automatic-context-updates","level":3,"title":"Automatic Context Updates","text":"

      During the loop, the AI should update context files:

      Mark task complete:

      ctx task complete \"implement user auth\"\n

      Or emit an update command (parsed by ctx watch):

      <context-update type=\"complete\">user auth</context-update>\n

      Add learning:

      ctx learning add \"Rate limiting requires Redis connection\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n

      Or via update command:

      <context-update type=\"learning\"\n  context=\"Implementing rate limiter\"\n  lesson=\"Rate limiting requires Redis connection\"\n  application=\"Ensure Redis is provisioned before enabling rate limits\"\n>Rate Limiting Redis Dependency</context-update>\n

      Record decision:

      ctx decision add \"Use JWT tokens for API authentication\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#advanced-watch-mode","level":2,"title":"Advanced: Watch Mode","text":"

      Run ctx watch alongside the loop to automatically process context updates:

      # Terminal 1: Run the loop\n./loop.sh 2>&1 | tee /tmp/loop.log\n\n# Terminal 2: Watch for context updates\nctx watch --log /tmp/loop.log\n

      The watch command processes context updates from the loop output in real time.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#project-setup","level":2,"title":"Project Setup","text":"

      Initialize a project for autonomous loop operation, then activate it so the loop's ctx commands know which .context/ to use:

      ctx init\neval \"$(ctx activate)\"\n

      For unattended overnight runs, put the binding directly at the top of your loop script (export CTX_DIR=/abs/path/.context) so it survives without depending on a live shell. See Activating a Context Directory.

      The loop prompt template is deployed to .context/loop.md during initialization. It instructs the agent to:

      • Work autonomously without asking clarifying questions;
      • Follow one-task-per-iteration discipline;
      • Use SYSTEM_CONVERGED / SYSTEM_BLOCKED signals;
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#example-project-structure","level":2,"title":"Example Project Structure","text":"
      my-project/\n├── .context/\n│   ├── CONSTITUTION.md\n│   ├── TASKS.md          # Work items for the loop\n│   ├── DECISIONS.md\n│   ├── LEARNINGS.md\n│   ├── CONVENTIONS.md\n│   └── sessions/         # Loop iteration history\n├── loop.sh               # Loop script (if not using Claude Code)\n└── src/                  # Your code\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#sample-tasksmd-for-autonomous-loops","level":3,"title":"Sample TASKS.md for Autonomous Loops","text":"
      # Tasks\n\n## Phase 1: Setup\n\n- [x] Initialize project structure\n- [x] Set up testing framework\n\n## Phase 2: Core Features\n\n- [ ] Implement user registration `#priority:high`\n- [ ] Add email verification `#priority:high`\n- [ ] Create password reset flow `#priority:medium`\n\n## Phase 3: Polish\n\n- [ ] Add rate limiting `#priority:medium`\n- [ ] Improve error messages `#priority:low`\n

      The loop will work through these systematically, marking each complete.

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#loop-runs-forever","level":3,"title":"Loop Runs Forever","text":"

      Cause: AI not emitting completion signals

      Fix: Ensure .context/loop.md explicitly instructs signaling:

      End EVERY response with one of:\n- SYSTEM_CONVERGED (if all tasks done)\n- SYSTEM_BLOCKED (if stuck)\n

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#context-not-persisting","level":3,"title":"Context Not Persisting","text":"

      Cause: AI not updating context files

      Fix: Add explicit instructions to .context/loop.md:

      After completing a task, you MUST:\n1. Run: ctx task complete \"<task>\"\n2. Add learnings: ctx learning add \"...\" --session-id abc12345 --branch main --commit 68fbc00a\n

      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#tasks-getting-repeated","level":3,"title":"Tasks Getting Repeated","text":"

      Cause: Task not marked complete before next iteration

      Fix: Ensure commit happens after context update:

      Order of operations:\n1. Complete coding work\n2. Update context files (*`ctx task complete`, `ctx add`*)\n3. Commit **ALL** changes including `.context/`\n4. Then signal status\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#ai-violating-constitution","level":3,"title":"AI Violating Constitution","text":"

      Cause: Constitution not read first

      Fix: Make constitution check explicit in .context/loop.md:

      BEFORE any work:\n1. Read .context/CONSTITUTION.md\n2. If task would violate ANY rule, emit SYSTEM_BLOCKED\n3. Explain which rule prevents the work\n
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#further-reading","level":2,"title":"Further Reading","text":"
      • Building ctx Using ctx: The dogfooding story: how autonomous loops built the tool that powers them
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#resources","level":2,"title":"Resources","text":"
      • Geoffrey Huntley's Ralph Wiggum Technique: The original inspiration
      • Context CLI: Command reference
      • Integrations: Tool-specific setup
      ","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/hub-failure-modes/","level":1,"title":"Hub Failure Modes","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#ctx-hub-failure-modes","level":1,"title":"ctx Hub: Failure Modes","text":"

      What can go wrong, what the system does about it, and what you should do. Complementary to ctx Hub Operations.

      Design Posture

      The hub is best-effort knowledge sharing, not a durable ledger. Local .context/ files are the source of truth for each project; the hub is a fan-out channel. This framing informs every failure-mode decision below.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#network","level":2,"title":"Network","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#client-loses-connection-mid-stream","level":3,"title":"Client Loses Connection Mid-Stream","text":"

      What happens: ctx connection listen detects the EOF, waits with exponential backoff, and reconnects. On reconnect it passes its last-seen sequence; the hub replays everything newer.

      What you should do: nothing. If reconnects are looping, check firewall state on the hub and ctx hub status output.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#partition-majority-side-reachable","level":3,"title":"Partition: Majority Side Reachable","text":"

      What happens: clients routed to the majority side continue to publish and listen. The minority nodes step down to followers that cannot accept writes (Raft quorum lost).

      What you should do: let it heal. When the partition closes, followers catch up via sequence-based sync automatically.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#partition-split-brain-no-quorum","level":3,"title":"Partition: Split Brain (No Quorum)","text":"

      What happens: no node holds a majority, so no leader is elected. All nodes become read-only. ctx connection publish and ctx add --share fail with a \"no leader\" error; local writes still succeed.

      What you should do: fix the network. If the partition is permanent (e.g., a data center is gone), bootstrap a new cluster from the survivors with ctx hub peer remove for the dead nodes.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#hub-unreachable-during-ctx-add-share","level":3,"title":"Hub Unreachable during ctx add --share","text":"

      What happens: the local write succeeds; the share step prints a warning and exits non-zero on the share leg only. --share is best-effort; it never blocks local context updates.

      What you should do: run ctx connection publish later to backfill, or rely on another --share for the same entry ID. The hub deduplicates by entry ID.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#storage","level":2,"title":"Storage","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#disk-full-on-the-leader","level":3,"title":"Disk Full on the Leader","text":"

      What happens: entries.jsonl append fails. The hub rejects writes with an error and stays up for read traffic. Clients retry; followers keep their in-sync status using whatever the leader already wrote.

      What you should do: free disk or grow the volume, then nothing else; the hub resumes accepting writes on the next append attempt.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#corrupt-entriesjsonl","level":3,"title":"Corrupt entries.jsonl","text":"

      What happens: if the last line is a partial JSON write from a crash, the hub truncates it on startup and logs a warning. If any earlier line is malformed, the hub refuses to start.

      What you should do: inspect with jq -c . <data-dir>/entries.jsonl > /dev/null to find the bad line. Move the bad region to a .quarantine file, then start. Nothing is ever silently dropped.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#metajson-entriesjsonl-sequence-mismatch","level":3,"title":"meta.json / entries.jsonl Sequence Mismatch","text":"

      What happens: the hub refuses to start. This usually means someone copied one file without the other.

      What you should do: restore both files from the same backup, or accept the higher sequence by regenerating meta.json from entries.jsonl (manual for now; file a bug).

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#cluster","level":2,"title":"Cluster","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#leader-crash-clean-shutdown","level":3,"title":"Leader Crash, Clean Shutdown","text":"

      What happens: ctx hub stop triggers stepdown first, so a new leader is elected before the old one exits. In-flight writes drain. Clients reconnect to the new leader transparently.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#leader-crash-hard-fail-kill-9-power-loss","level":3,"title":"Leader Crash, Hard Fail (Kill -9, Power Loss)","text":"

      What happens: Raft detects the missing heartbeat and elects a new leader within a few seconds. Writes the old leader accepted but had not yet replicated can be lost. See the Raft-lite warning in the cluster recipe.

      What you should do: if you need stronger durability, run ctx connection listen on a dedicated \"collector\" project that persists entries locally as a write-ahead backup.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#split-brain-after-rejoin","level":3,"title":"Split-Brain After Rejoin","text":"

      What happens: Raft reconciles: the minority side's uncommitted writes are discarded, and the majority's log is authoritative.

      What you should do: nothing automatic. If you know the minority had important writes, grep for them in <data-dir>/entries.jsonl.rejected (written by the reconciliation pass) and replay them with ctx connection publish.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#auth-and-tokens","level":2,"title":"Auth and Tokens","text":"","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#lost-admin-token","level":3,"title":"Lost Admin Token","text":"

      What happens: you cannot register new projects.

      What you should do: retrieve it from <data-dir>/admin.token. If that file is also gone, stop the hub and regenerate. Note that all existing client tokens keep working; only new registrations need the admin token.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-admin-token","level":3,"title":"Compromised Admin Token","text":"

      What happens: anyone with the token can register new projects and publish. They cannot read existing entries without a client token for a project that subscribes.

      What you should do: rotate the admin token (regenerate <data-dir>/admin.token and restart), revoke suspicious client registrations via clients.json, and audit entries.jsonl for unexpected origins.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-client-token","level":3,"title":"Compromised Client Token","text":"

      What happens: the attacker can publish as that project and read anything that project is subscribed to. Because Origin is self-asserted on publish, the attacker can also publish entries tagged with any other project's name, so attribution in entries.jsonl cannot be trusted after a token compromise.

      What you should do: remove the client's entry from clients.json, restart the hub, and re-register the legitimate project with a fresh token. Audit entries.jsonl for entries published after the compromise timestamp and quarantine any that look suspicious; remember that Origin on those entries proves nothing.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-hub-host","level":3,"title":"Compromised Hub Host","text":"

      What happens: <data-dir>/clients.json stores client tokens verbatim (not hashed). Anyone with read access to that file has every client token in hand and can impersonate any registered project until each one is rotated.

      What you should do: treat it as a total hub compromise. Stop the hub, wipe <data-dir> (keep a forensic copy first), regenerate the admin token, and have every client re-register. See Security model for the mitigations that reduce the blast radius while the hashing follow-up is pending.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#clock-skew","level":2,"title":"Clock Skew","text":"

      Hub entries carry a timestamp assigned by the publishing client. The hub does not rewrite timestamps. Clients with significant clock skew will publish entries that look out of order in the shared feed.

      What you should do: run NTP on all client machines. If you see entries dated in the future or far past, the publisher's clock is the culprit.

      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#the-short-list","level":2,"title":"The Short List","text":"Symptom First thing to check Client can't reach hub Firewall, then ctx hub status \"No leader\" errors Cluster quorum; run ctx hub status on each peer Hub won't start after crash Last line of entries.jsonl Entries missing after restore Check clients.json sequence vs local .sync-state.json Duplicate entries in shared feed Client replayed after restore, safe (dedup by ID) Followers lagging Disk or network on the follower, not the leader","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#see-also","level":2,"title":"See Also","text":"
      • ctx Hub Operations
      • ctx Hub security model
      • HA cluster recipe
      ","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub/","level":1,"title":"Hub Operations","text":"","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#ctx-hub-operations","level":1,"title":"ctx Hub: Operations","text":"

      Running the ctx ctx Hub in production. This page is for operators: people running a hub for themselves or a team, not people writing to a hub someone else is running.

      If you have not read it yet, start with the ctx Hub overview. It explains what the hub is, the two user stories it supports (personal cross-project brain vs small trusted team), and what it does not do. A client-side tour is in Getting Started.

      Operator Cheat Sheet

      • The hub fans out four entry types only: decision, learning, convention, task. Journals, scratchpad, and other local state are out of scope.
      • Identity is per-project, not per-user. Attribution is limited to Origin, which is self-asserted by the publishing client.
      • The data model is an append-only JSONL log plus two small JSON sidecar files. Nothing is rewritten in place.
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#data-directory-layout","level":2,"title":"Data Directory Layout","text":"

      The hub stores everything under a single data directory (default ~/.ctx/hub-data/, override with --data-dir).

      <data-dir>/\n  admin.token        # Initial admin token (chmod 600)\n  clients.json       # Registered client tokens and project names\n  meta.json          # Sequence counter, version, cluster metadata\n  entries.jsonl      # Append-only log (single source of truth)\n  hub.pid            # Daemon PID file (daemon mode only)\n  raft/              # Raft state (cluster mode only)\n    log.db\n    stable.db\n    snapshots/\n

      Invariants:

      • entries.jsonl is append-only. Every line is a valid JSON object. Corrupt lines are fatal at startup: fix or truncate before restart.
      • meta.json is authoritative for the next sequence number. On restart, the hub reads the last valid line of entries.jsonl and refuses to start if the sequences disagree.
      • clients.json holds hashed client tokens; losing it invalidates all client registrations.
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#starting-and-stopping","level":2,"title":"Starting and Stopping","text":"ForegroundDaemon
      ctx hub start                    # Ctrl-C to stop\nctx hub start --port 8080        # Custom port\nctx hub start --data-dir /srv/ctx-hub\n
      ctx hub start --daemon           # Fork to background\nctx hub stop                      # Graceful shutdown\n

      --stop sends SIGTERM to the PID in hub.pid, waits for in-flight RPCs to drain, then exits. If the daemon is wedged, remove hub.pid and send SIGKILL manually. entries.jsonl is crash-safe, so you will not lose accepted writes.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#systemd-unit","level":2,"title":"Systemd Unit","text":"

      For production single-node deployments, run the hub as a systemd service instead of --daemon:

      # /etc/systemd/system/ctx-hub.service\n[Unit]\nDescription=ctx `ctx` Hub\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nType=simple\nUser=ctx\nGroup=ctx\nExecStart=/usr/local/bin/ctx hub start --port 9900 \\\n    --data-dir /var/lib/ctx-hub\nRestart=on-failure\nRestartSec=5\nNoNewPrivileges=true\nProtectSystem=strict\nProtectHome=true\nReadWritePaths=/var/lib/ctx-hub\nPrivateTmp=true\n\n[Install]\nWantedBy=multi-user.target\n
      sudo systemctl enable --now ctx-hub\nsudo journalctl -u ctx-hub -f\n
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#backup-and-restore","level":2,"title":"Backup and Restore","text":"

      Because entries.jsonl is append-only, backups are trivial:

      # Hot backup, safe while the hub is running.\ncp <data-dir>/entries.jsonl backups/entries-$(date +%F).jsonl\ncp <data-dir>/meta.json      backups/meta-$(date +%F).json\ncp <data-dir>/clients.json   backups/clients-$(date +%F).json\n

      For a consistent snapshot across all three files, stop the hub, copy, then start again, or use a filesystem-level snapshot (LVM, ZFS, Btrfs).

      Restore:

      ctx hub stop                           # Stop the hub\ncp backups/entries-2026-04-10.jsonl <data-dir>/entries.jsonl\ncp backups/meta-2026-04-10.json      <data-dir>/meta.json\ncp backups/clients-2026-04-10.json   <data-dir>/clients.json\nctx hub start --daemon\n

      Clients that pushed sequences above the restored watermark will re-publish on the next listen reconnect, because the hub now reports a lower sequence than what clients have on disk. This is safe; the store deduplicates by entry ID.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#log-rotation","level":2,"title":"Log Rotation","text":"

      entries.jsonl grows unbounded. For long-lived hubs, rotate it offline:

      ctx hub stop\nmv <data-dir>/entries.jsonl <data-dir>/entries-$(date +%F).jsonl.old\n# Replay the last N days into a fresh entries.jsonl if you want a\n# trimmed active log, or leave the old file in place as history.\nctx hub start --daemon\n

      Do not truncate entries.jsonl while the hub is running. The hub holds an open file handle; an in-place truncation confuses the sequence counter and loses writes.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#monitoring","level":2,"title":"Monitoring","text":"

      Liveness probe:

      ctx hub status --exit-code\n

      Exit code 0 means the node is healthy (leader or in-sync follower); non-zero means degraded. Wire this into your monitoring of choice.

      For cluster deployments, watch for:

      • Role flaps: the leader changing more than once per hour suggests network instability or disk contention.
      • Replication lag: ctx hub status shows per-peer sequence offsets. Sustained lag > 100 sequences on a follower is worth investigating.
      • entries.jsonl growth rate: sudden spikes often indicate a misbehaving ctx connection listen reconnect loop.
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#upgrading","level":2,"title":"Upgrading","text":"

      The JSONL format is versioned in meta.json. ctx refuses to start against a newer store version than it understands; older store versions are upgraded in place at first start after an upgrade.

      Always back up <data-dir>/ before upgrading.

      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#see-also","level":2,"title":"See Also","text":"
      • ctx Hub failure modes
      • ctx Hub security model
      • ctx serve reference
      • ctx hub reference
      ","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/integrations/","level":1,"title":"AI Tools","text":"","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#ai-tools","level":2,"title":"AI Tools","text":"

      Context works with any AI tool that can read files. This guide covers setup for popular AI coding assistants.

      Activate the Project Before Running ctx Commands

      After ctx init, run:

      eval \"$(ctx activate)\"\n

      This tells ctx which .context/ directory the rest of the commands on this page should use. If you skip it, you'll see Error: no context directory specified. The ctx setup <tool> commands work without activation, but most others (ctx agent, ctx add, ctx status, ctx watch) need it. See Activating a Context Directory.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#claude-code-full-integration","level":2,"title":"Claude Code (Full Integration)","text":"

      Claude Code has the deepest integration via the ctx plugin.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup","level":3,"title":"Setup","text":"

      First, install ctx and initialize your project, then activate it for the current shell:

      ctx init\neval \"$(ctx activate)\"\n

      Then, install the ctx plugin in Claude Code:

      # From the ctx repository\nclaude /plugin install ./internal/assets/claude\n\n# Or from the marketplace\nclaude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n

      Ensure the Plugin Is Enabled

      Installing a plugin registers it, but local installs may not auto-enable it globally. Verify ~/.claude/settings.json contains:

      { \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n

      Without this, the plugin's hooks and skills won't appear in other projects. Running ctx init auto-enables the plugin; use --no-plugin-enable to skip this step.

      This gives you:

      Component Purpose .context/ All context files CLAUDE.md Bootstrap instructions Plugin hooks Lifecycle automation Plugin skills Agent Skills","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#how-it-works","level":3,"title":"How It Works","text":"
      graph TD\n    A[Session Start] --> B[Claude reads CLAUDE.md]\n    B --> C[PreToolUse hook runs]\n    C --> D[ctx agent loads context]\n    D --> E[Work happens]\n    E --> F[Session End]
      1. Session start: Claude reads CLAUDE.md, which tells it to check .context/
      2. First tool use: PreToolUse hook runs ctx agent and emits the context packet (subsequent invocations within the cooldown window are silent)
      3. Next session: Claude reads context files and continues with context
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#plugin-hooks","level":3,"title":"Plugin Hooks","text":"

      The ctx plugin provides lifecycle hooks implemented as Go subcommands (ctx system *):

      Hook Event Purpose ctx system context-load-gate PreToolUse (.*) Auto-inject context on first tool use ctx system block-non-path-ctx PreToolUse (Bash) Block ./ctx or go run: force $PATH install ctx system qa-reminder PreToolUse (Bash) Remind agent to lint/test before committing ctx system specs-nudge PreToolUse (EnterPlanMode) Nudge agent to use project specs when planning ctx system check-context-size UserPromptSubmit Nudge context assessment as sessions grow ctx system check-ceremonies UserPromptSubmit Nudge /ctx-remember and /ctx-wrap-up adoption ctx system check-persistence UserPromptSubmit Remind to persist learnings/decisions ctx system check-journal UserPromptSubmit Remind to export/enrich journal entries ctx system check-reminders UserPromptSubmit Relay pending reminders at session start ctx system check-version UserPromptSubmit Warn when binary/plugin versions diverge ctx system check-resources UserPromptSubmit Warn when memory/swap/disk/load hit DANGER level ctx system check-knowledge UserPromptSubmit Nudge when knowledge files grow large ctx system check-map-staleness UserPromptSubmit Nudge when ARCHITECTURE.md is stale ctx system heartbeat UserPromptSubmit Session-alive signal with prompt count metadata ctx system post-commit PostToolUse (Bash) Nudge context capture and QA after git commits

      A catch-all PreToolUse hook also runs ctx agent on every tool use (with cooldown) to autoload context.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#hook-configuration","level":3,"title":"Hook Configuration","text":"

      The plugin's hooks.json wires everything automatically: no manual configuration in settings.local.json needed:

      {\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \".*\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system context-load-gate\" }\n        ]\n      },\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system block-non-path-ctx\" }\n        ]\n      },\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system qa-reminder\" }\n        ]\n      },\n      {\n        \"matcher\": \"EnterPlanMode\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system specs-nudge\" }\n        ]\n      },\n      {\n        \"matcher\": \".*\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx agent --budget 4000 2>/dev/null || true\" }\n        ]\n      }\n    ],\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system post-commit\" }\n        ]\n      }\n    ],\n    \"UserPromptSubmit\": [\n      {\n        \"hooks\": [\n          { \"type\": \"command\", \"command\": \"ctx system check-context-size\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-ceremonies\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-persistence\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-journal\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-reminders\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-version\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-resources\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-knowledge\" },\n          { \"type\": \"command\", \"command\": \"ctx system check-map-staleness\" },\n          { \"type\": \"command\", \"command\": \"ctx system heartbeat\" }\n        ]\n      }\n    ]\n  }\n}\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#customizing-token-budget-and-cooldown","level":3,"title":"Customizing Token Budget and Cooldown","text":"

      Edit the PreToolUse command to change the token budget or cooldown:

      \"command\": \"ctx agent --budget 8000 --session $PPID >/dev/null || true\"\n\"command\": \"ctx agent --budget 4000 --cooldown 5m --session $PPID >/dev/null || true\"\n

      The --session $PPID flag isolates the cooldown per session: $PPID resolves to the Claude Code process PID, so concurrent sessions don't interfere. The default cooldown is 10 minutes; use --cooldown 0 to disable it.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#verifying-setup","level":3,"title":"Verifying Setup","text":"
      1. Start a new Claude Code session;
      2. Ask: \"Do you remember?\"
      3. Claude should cite specific context:
        • Current tasks from .context/TASKS.md;
        • Recent decisions or learnings;
        • Recent session history from ctx journal.
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#local-plugin-development","level":3,"title":"Local Plugin Development","text":"

      When developing ctx locally (adding skills, hooks, or changing plugin behavior), Claude Code caches the plugin by version. You must bump the version in both files and update the marketplace for changes to take effect:

      1. Bump version in both:
      2. internal/assets/claude/.claude-plugin/plugin.json (plugin manifest), .claude-plugin/marketplace.json (marketplace listing*);

      3. Update the marketplace in Claude Code:

      4. Open the Plugins UI (/plugins or Esc menu),
      5. Go to Marketplaces tab,
      6. Select the activememory-ctx Marketplace,
      7. Choose Update marketplace;

      8. Start a new Claude Code session: skill changes aren't reflected in existing sessions.

      Both Version Files Must Match

      If you only bump plugin.json but not marketplace.json (or vice versa), Claude Code may not detect the update. Always bump both together.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#troubleshooting","level":3,"title":"Troubleshooting","text":"Issue Solution Context not loading Check ctx is in PATH: which ctx Hook errors Verify plugin is installed: claude /plugin list New skill not visible Bump version in both plugin.json files, update marketplace","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-load","level":3,"title":"Manual Context Load","text":"

      If hooks aren't working, manually load context:

      # Get context packet\nctx agent --budget 4000\n\n# Or paste into conversation\ncat .context/TASKS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#agent-skills","level":3,"title":"Agent Skills","text":"

      The ctx plugin ships Agent Skills following the agentskills.io specification.

      These are invoked in Claude Code with /skill-name.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-lifecycle-skills","level":4,"title":"Session Lifecycle Skills","text":"Skill Description /ctx-remember Recall project context at session start (ceremony) /ctx-wrap-up End-of-session context persistence (ceremony) /ctx-status Show context summary (tasks, decisions, learnings) /ctx-agent Get AI-optimized context packet /ctx-next Suggest 1-3 concrete next actions from context /ctx-commit Commit with integrated context capture /ctx-reflect Review session and suggest what to persist /ctx-remind Manage session-scoped reminders /ctx-pause Pause context hooks for this session /ctx-resume Resume context hooks after a pause","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-persistence-skills","level":4,"title":"Context Persistence Skills","text":"Skill Description /ctx-task-add Add a task to TASKS.md /ctx-learning-add Add a learning to LEARNINGS.md /ctx-decision-add Add a decision with context/rationale/consequence /ctx-convention-add Add a coding convention to CONVENTIONS.md /ctx-archive Archive completed tasks","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#scratchpad-skills","level":4,"title":"Scratchpad Skills","text":"Skill Description /ctx-pad Manage encrypted scratchpad entries","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-history-skills","level":4,"title":"Session History Skills","text":"Skill Description /ctx-history Browse AI session history /ctx-journal-enrich Enrich a journal entry with frontmatter/tags /ctx-journal-enrich-all Full journal pipeline: export if needed, then batch-enrich","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#blogging-skills","level":4,"title":"Blogging Skills","text":"

      Blogging Is a Better Way of Creating Release Notes

      The blogging workflow can also double as generating release notes:

      AI reads your git commit history and creates a \"narrative\", which is essentially what a release note is for.

      Skill Description /ctx-blog Generate blog post from recent activity /ctx-blog-changelog Generate blog post from commit range with theme","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#auditing-health-skills","level":4,"title":"Auditing & Health Skills","text":"Skill Description /ctx-doctor Troubleshoot ctx behavior with structural health checks /ctx-drift Detect and fix context drift (structural + semantic) /ctx-consolidate Merge redundant learnings or decisions into denser entries /ctx-alignment-audit Audit doc claims against playbook instructions /ctx-prompt-audit Analyze session logs for vague prompts /check-links Audit docs for dead internal and external links","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#planning-execution-skills","level":4,"title":"Planning & Execution Skills","text":"Skill Description /ctx-loop Generate a Ralph Loop iteration script /ctx-implement Execute a plan step-by-step with checks /ctx-plan-import Import Claude Code plan files into project specs /ctx-worktree Manage git worktrees for parallel agents /ctx-architecture Build and maintain architecture maps","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage-examples","level":4,"title":"Usage Examples","text":"
      /ctx-status\n/ctx-learning-add \"Token refresh requires explicit cache invalidation\"\n/ctx-journal-enrich twinkly-stirring-kettle\n

      Skills support partial matching where applicable (e.g., session slugs).

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#cursor-ide","level":2,"title":"Cursor IDE","text":"

      Cursor can use context files through its system prompt or by reading files directly.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_1","level":3,"title":"Setup","text":"
      # Generate Cursor configuration\nctx setup cursor\n\n# Initialize context\nctx init --minimal\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration","level":3,"title":"Configuration","text":"

      Add to Cursor settings (.cursor/settings.json):

      // split to multiple lines for readability\n{\n  \"ai.systemPrompt\": \"Read .context/TASKS.md and \n  .context/CONVENTIONS.md before responding. \n  Follow rules in .context/CONSTITUTION.md.\",\n}\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage","level":3,"title":"Usage","text":"
      1. Open your project in Cursor
      2. Context files are available in the file tree
      3. Reference them in prompts: \"Check .context/DECISIONS.md for our approach to...\"
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-injection","level":3,"title":"Manual Context Injection","text":"

      For more control, paste context directly:

      # Get AI-ready packet\nctx agent --budget 4000 | pbcopy  # macOS\nctx agent --budget 4000 | xclip  # Linux\n

      Paste into Cursor's chat.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#aider","level":2,"title":"Aider","text":"

      Aider works well with context files through its --read flag.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_2","level":3,"title":"Setup","text":"
      # Generate Aider configuration\nctx setup aider\n\n# Initialize context\nctx init\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_1","level":3,"title":"Configuration","text":"

      Create .aider.conf.yml:

      read:\n  - .context/CONSTITUTION.md\n  - .context/TASKS.md\n  - .context/CONVENTIONS.md\n  - .context/DECISIONS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_1","level":3,"title":"Usage","text":"
      # Start Aider (reads context files automatically)\naider\n\n# Or specify files explicitly\naider --read .context/TASKS.md --read .context/CONVENTIONS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#with-watch-mode","level":3,"title":"With Watch Mode","text":"

      Run ctx watch alongside Aider to capture context updates:

      # Terminal 1: Run Aider\naider 2>&1 | tee /tmp/aider.log\n\n# Terminal 2: Watch for context updates\nctx watch --log /tmp/aider.log\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#github-copilot","level":2,"title":"GitHub Copilot","text":"

      GitHub Copilot integrates with ctx at three levels: an automated instructions file, a VS Code Chat extension, and manual patterns.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_3","level":3,"title":"Setup","text":"
      # Initialize context\nctx init\n\n# Generate .github/copilot-instructions.md\nctx setup copilot --write\n

      The --write flag creates .github/copilot-instructions.md, which Copilot reads automatically at the start of every session. This file contains your project's constitution rules, current tasks, conventions, and architecture: giving Copilot persistent context without manual copy-paste.

      Re-run ctx setup copilot --write after updating your .context/ files to regenerate the instructions.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#vs-code-chat-extension-ctx","level":3,"title":"VS Code Chat Extension (@ctx)","text":"

      The ctx VS Code extension adds a @ctx chat participant to GitHub Copilot Chat, giving you direct access to all context commands from within the editor.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#installation","level":4,"title":"Installation","text":"
      1. Build from source (requires Node.js 18+):
      cd editors/vscode\nnpm install\nnpm run build\nnpx @vscode/vsce package\n
      1. Install the .vsix file:
      code --install-extension ctx-context-0.8.1.vsix\n
      1. Reload VS Code. Type @ctx in Copilot Chat to verify.
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#slash-commands","level":4,"title":"Slash Commands","text":"Command Description @ctx /init Initialize .context/ directory with template files @ctx /status Show context summary with token estimate @ctx /agent Print AI-ready context packet @ctx /drift Detect stale or invalid context @ctx /journal Browse and search AI session history @ctx /hook Generate AI tool integration configs @ctx /add Add a task, decision, or learning @ctx /load Output assembled context Markdown @ctx /compact Archive completed tasks and clean up @ctx /sync Reconcile context with codebase","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage-examples_1","level":4,"title":"Usage Examples","text":"
      @ctx /init\n@ctx /status\n@ctx /add task Implement user authentication\n@ctx /drift\n@ctx /hook copilot\n@ctx /journal\n

      Typing @ctx without a command shows help with all available commands. The extension also supports natural language: asking @ctx about \"status\" or \"drift\" routes to the correct command automatically.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_2","level":4,"title":"Configuration","text":"Setting Default Description ctx.executablePath ctx Path to the ctx binary. Set this if ctx is not in your PATH.","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#follow-up-suggestions","level":4,"title":"Follow-Up Suggestions","text":"

      After each command, the extension suggests relevant next steps. For example, after /init it suggests /status and /hook; after /drift it suggests /sync.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-persistence","level":3,"title":"Session Persistence","text":"

      ctx init creates a .context/sessions/ directory for storing session data from non-Claude tools. The Markdown session parser scans this directory during ctx journal, enabling session history for Copilot and other tools.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-patterns","level":3,"title":"Manual Patterns","text":"

      These patterns work without the extension, using Copilot's built-in file awareness:

      Pattern 1: Keep context files open

      Open .context/CONVENTIONS.md in a split pane. Copilot will reference it.

      Pattern 2: Reference in comments

      // See .context/CONVENTIONS.md for naming patterns\n// Following decision in .context/DECISIONS.md: Use PostgreSQL\n\nfunction getUserById(id: string) {\n  // Copilot now has context\n}\n

      Pattern 3: Paste context into Copilot Chat

      ctx agent --budget 2000\n

      Paste output into Copilot Chat for context-aware responses.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#windsurf-ide","level":2,"title":"Windsurf IDE","text":"

      Windsurf supports custom instructions and file-based context.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_4","level":3,"title":"Setup","text":"
      # Generate Windsurf configuration\nctx setup windsurf\n\n# Initialize context\nctx init\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_3","level":3,"title":"Configuration","text":"

      Add to Windsurf settings:

      // Split to multiple lines for readability\n{\n  \"ai.customInstructions\": \"Always read .context/CONSTITUTION.md first. \n  Check .context/TASKS.md for current work. \n  Follow patterns in .context/CONVENTIONS.md.\"\n}\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_2","level":3,"title":"Usage","text":"

      Context files appear in the file tree. Reference them when chatting:

      • \"What's in our task list?\" → AI reads .context/TASKS.md
      • \"What convention do we use for naming?\" → AI reads .context/CONVENTIONS.md
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#generic-integration","level":2,"title":"Generic Integration","text":"

      For any AI tool that can read files, use these patterns:

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-loading","level":3,"title":"Manual Context Loading","text":"
      # Get full context\nctx load\n\n# Get AI-optimized packet\nctx agent --budget 8000\n\n# Get specific file\ncat .context/TASKS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#system-prompt-template","level":3,"title":"System Prompt Template","text":"
      You are working on a project with persistent context in .context/\n\nBefore responding:\n1. Read .context/CONSTITUTION.md - NEVER violate these rules\n2. Check .context/TASKS.md for current work\n3. Follow .context/CONVENTIONS.md patterns\n4. Reference .context/DECISIONS.md for architectural choices\n\nWhen you learn something new, note it for .context/LEARNINGS.md\nWhen you make a decision, document it for .context/DECISIONS.md\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#automated-updates","level":3,"title":"Automated Updates","text":"

      If your AI tool outputs to a log, use ctx watch:

      # Watch log file for context-update commands\nyour-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n

      The AI can emit updates like:

      <context-update type=\"complete\">implement caching</context-update>\n<context-update type=\"learning\"\n  context=\"Implementing caching layer\"\n  lesson=\"Important thing learned today\"\n  application=\"Apply this insight going forward\"\n>Caching Insight</context-update>\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-update-commands","level":2,"title":"Context Update Commands","text":"

      The ctx watch command parses update commands from AI output. Use this format:

      <context-update type=\"TYPE\" [attributes]>Content</context-update>\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#supported-types","level":3,"title":"Supported Types","text":"Type Target File Required Attributes task TASKS.md None decision DECISIONS.md context, rationale, consequence learning LEARNINGS.md context, lesson, application convention CONVENTIONS.md None complete TASKS.md None","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#simple-format-tasks-conventions-complete","level":3,"title":"Simple Format (Tasks, Conventions, Complete)","text":"
      <context-update type=\"task\">Implement rate limiting</context-update>\n<context-update type=\"convention\">Use kebab-case for files</context-update>\n<context-update type=\"complete\">rate limiting</context-update>\n
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#structured-format-learnings-decisions","level":3,"title":"Structured Format (Learnings, Decisions)","text":"

      Learnings and decisions support structured attributes for better documentation:

      Learning with full structure:

      <context-update type=\"learning\"\n  context=\"Debugging Claude Code hooks\"\n  lesson=\"Hooks receive JSON via stdin, not environment variables\"\n  application=\"Parse JSON stdin with the host language (Go, Python, etc.): no jq needed\"\n>Hook Input Format</context-update>\n

      Decision with full structure:

      <context-update type=\"decision\"\n  context=\"Need a caching layer for API responses\"\n  rationale=\"Redis is fast, well-supported, and team has experience\"\n  consequence=\"Must provision Redis infrastructure; team training on Redis patterns\"\n>Use Redis for caching</context-update>\n

      Learnings require: context, lesson, application attributes. Decisions require: context, rationale, consequence attributes. Updates missing required attributes are rejected with an error.

      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#further-reading","level":2,"title":"Further Reading","text":"
      • Skills That Fight the Platform: Common pitfalls in skill design that work against the host tool
      • The Anatomy of a Skill That Works: What makes a skill reliable: the E/A/R framework and quality gates
      ","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/migration/","level":1,"title":"Integration","text":"","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#adopting-ctx-in-existing-projects","level":2,"title":"Adopting ctx in Existing Projects","text":"

      Claude Code User?

      You probably want the plugin instead of this page.

      Install ctx from the marketplace: (/plugin → search \"ctx\" → Install) and you're done: hooks, skills, and updates are handled for you.

      See Getting Started for the full walkthrough.

      This guide covers adopting ctx in existing projects regardless of which tools your team uses.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#quick-paths","level":2,"title":"Quick Paths","text":"You have... Command What happens Nothing (greenfield) ctx init Creates .context/, CLAUDE.md, permissions Existing CLAUDE.md ctx init --merge Backs up your file, inserts ctx block after the H1 Existing CLAUDE.md + ctx markers ctx init --reset Replaces the ctx block, leaves your content intact .cursorrules / .aider.conf.yml ctx init ctx ignores those files: they coexist cleanly Team repo, first adopter ctx init --merge && git add .context/ CLAUDE.md Initialize and commit for the team","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-claudemd","level":2,"title":"Existing CLAUDE.md","text":"

      This is the most common scenario:

      You have a CLAUDE.md with project-specific instructions and don't want to lose them.

      You Own CLAUDE.md

      After initialization, CLAUDE.md is yours: edit it freely.

      Add project instructions, remove sections you don't need, reorganize as you see fit.

      The only part ctx manages is the block between the <!-- ctx:context --> and <!-- ctx:end --> markers; everything outside those markers is yours to change at any time.

      If you remove the markers, nothing breaks: ctx simply treats the file as having no ctx content and will offer to merge again on the next ctx init.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-ctx-init-does","level":3,"title":"What ctx init Does","text":"

      When ctx init detects an existing CLAUDE.md, it checks for ctx markers (<!-- ctx:context --> ... <!-- ctx:end -->):

      State Default behavior With --merge With --force No CLAUDE.md Creates from template Creates from template Creates from template Exists, no ctx markers Prompts to merge Auto-merges (no prompt) Auto-merges (no prompt) Exists, has ctx markers Skips (already set up) Skips Replaces the ctx block only","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-merge-flag","level":3,"title":"The --merge Flag","text":"

      --merge auto-merges without prompting. The merge process:

      1. Backs up your existing CLAUDE.md to CLAUDE.md.<timestamp>.bak;
      2. Finds the H1 heading (e.g., # My Project) in your file;
      3. Inserts the ctx block immediately after it;
      4. Preserves everything else untouched.

      Your content before and after the ctx block remains exactly as it was.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#before-after-example","level":3,"title":"Before / After Example","text":"

      Before: your existing CLAUDE.md:

      # My Project\n\n## Build Commands\n\n-`npm run build`: production build\n- `npm test`: run tests\n\n## Code Style\n\n- Use TypeScript strict mode\n- Prefer named exports\n

      After ctx init --merge:

      # My Project\n\n<!-- ctx:context -->\n<!-- DO NOT REMOVE: This marker indicates ctx-managed content -->\n\n## IMPORTANT: You Have Persistent Memory\n\nThis project uses Context (`ctx`) for context persistence across sessions.\n...\n\n<!-- ctx:end -->\n\n## Build Commands\n\n- `npm run build`: production build\n- `npm test`: run tests\n\n## Code Style\n\n- Use TypeScript strict mode\n- Prefer named exports\n

      Your build commands and code style sections are untouched. The ctx block sits between markers and can be updated independently.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-force-flag","level":3,"title":"The --force Flag","text":"

      If your CLAUDE.md already has ctx markers (from a previous ctx init), the default behavior is to skip it. Use --force to replace the ctx block with the latest template: This is useful after upgrading ctx:

      ctx init --reset\n

      This only replaces content between <!-- ctx:context --> and <!-- ctx:end -->. Your own content outside the markers is preserved. A timestamped backup is created before any changes.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#undoing-a-merge","level":3,"title":"Undoing a Merge","text":"

      Every merge creates a backup:

      $ ls CLAUDE.md*.bak\nCLAUDE.md.1738000000.bak\n

      To restore:

      cp CLAUDE.md.1738000000.bak CLAUDE.md\n

      Or if you are using git, simply:

      git checkout CLAUDE.md\n
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-cursorrules-aider-copilot","level":2,"title":"Existing .cursorrules / Aider / Copilot","text":"

      ctx doesn't touch tool-specific config files. It creates its own files (.context/, CLAUDE.md) and coexists with whatever you already have.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-does-ctx-create","level":3,"title":"What Does ctx Create?","text":"ctx creates ctx does NOT touch .context/ directory .cursorrules CLAUDE.md (or merges into) .aider.conf.yml .claude/settings.local.json (seeded by ctx init; the plugin manages hooks and skills) .github/copilot-instructions.md .windsurfrules Any other tool-specific config

      Claude Code hooks and skills are provided by the ctx plugin, installed from the Claude Code marketplace (/plugin → search \"ctx\" → Install).

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#running-ctx-alongside-other-tools","level":3,"title":"Running ctx Alongside Other Tools","text":"

      The .context/ directory is the source of truth. Tool-specific configs point to it:

      • Cursor: Reference .context/ files in your system prompt (see Cursor setup)
      • Aider: Add .context/ files to the read: list in .aider.conf.yml (see Aider setup)
      • Copilot: Keep .context/ files open or reference them in comments (see Copilot setup)

      You can generate a tool-specific configuration with:

      ctx setup cursor    # Generate Cursor config snippet\nctx setup aider     # Generate .aider.conf.yml\nctx setup copilot   # Generate Copilot tips\nctx setup windsurf  # Generate Windsurf config\n
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#migrating-content-into-context","level":3,"title":"Migrating Content into .context/","text":"

      If you have project knowledge scattered across .cursorrules or custom prompt files, consider migrating it:

      1. Rules / invariants → .context/CONSTITUTION.md
      2. Code patterns → .context/CONVENTIONS.md
      3. Architecture notes → .context/ARCHITECTURE.md
      4. Known issues / tips → .context/LEARNINGS.md

      You don't need to delete the originals: ctx and tool-specific files can coexist. But centralizing in .context/ means every tool gets the same context.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#team-adoption","level":2,"title":"Team Adoption","text":"","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#context-is-designed-to-be-committed","level":3,"title":".context/ Is Designed to Be Committed","text":"

      The context files (tasks, decisions, learnings, conventions, architecture) are meant to live in version control. However, some subdirectories are personal or sensitive and should not be committed.

      ctx init automatically adds these .gitignore entries:

      # Journals contain full session transcripts: personal, potentially large\n.context/journal/\n.context/journal-site/\n.context/journal-obsidian/\n\n# Legacy encryption key path (copy to ~/.ctx/.ctx.key if needed)\n.context/.ctx.key\n\n# Runtime state and logs (ephemeral, machine-specific):\n.context/state/\n.context/logs/\n\n# Claude Code local settings (machine-specific)\n.claude/settings.local.json\n

      With those in place, committing is straightforward:

      # One person initializes\nctx init --merge\n\n# Commit context files (journals and keys are already gitignored)\ngit add .context/ CLAUDE.md\ngit commit -m \"Add ctx context management\"\ngit push\n

      Teammates pull and immediately have context. No per-developer setup needed.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-about-claude","level":3,"title":"What about .claude/?","text":"

      The .claude/ directory contains permissions that ctx init seeds. Hooks and skills are provided by the ctx plugin (not per-project files).

      File Commit? Why .claude/settings.local.json No Machine-specific, accumulates session permissions .claude/settings.golden.json Yes Curated permission snapshot (via ctx permission snapshot)","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#merge-conflicts-in-context-files","level":3,"title":"Merge Conflicts in Context Files","text":"

      Context files are plain Markdown. Resolve conflicts the same way you would for any other documentation file:

      # After a conflicting pull\ngit diff .context/TASKS.md    # See both sides\n# Edit to keep both sets of tasks, then:\ngit add .context/TASKS.md\ngit commit\n

      Common conflict scenarios:

      • TASKS.md: Two people added tasks: Keep both.
      • DECISIONS.md: Same decision recorded differently: Unify the entry.
      • LEARNINGS.md: Parallel discoveries: Keep both, remove duplicates.
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#gradual-adoption","level":3,"title":"Gradual Adoption","text":"

      You don't need the whole team to switch at once:

      1. One person runs ctx init --merge and commits;
      2. CLAUDE.md instructions work immediately for Claude Code users;
      3. Other tool users can adopt at their own pace using ctx setup <tool>;
      4. Context files benefit everyone who reads them, even without tool integration.
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#verifying-it-worked","level":2,"title":"Verifying It Worked","text":"","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#activate-the-project","level":3,"title":"Activate the Project","text":"

      Tell ctx which .context/ directory to use for the rest of the verification steps:

      eval \"$(ctx activate)\"\n

      You only need to run this once per terminal. If you skip it, the status check below fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#check-status","level":3,"title":"Check Status","text":"
      ctx status\n

      You should see your context files listed with token counts and no warnings.

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#test-memory","level":3,"title":"Test Memory","text":"

      Start a new AI session and ask: \"Do you remember?\"

      The AI should cite specific context:

      • Current tasks from .context/TASKS.md;
      • Recent decisions or learnings;
      • Session history (if you've had prior sessions);

      If it responds with generic \"I don't have memory\", check that ctx is in your PATH (which ctx) and that hooks are configured (see Troubleshooting).

      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#verify-the-merge","level":3,"title":"Verify the Merge","text":"

      If you used --merge, check that your original content is intact:

      # Your original content should still be there\ncat CLAUDE.md\n\n# The ctx block should be between markers\ngrep -c \"ctx:context\" CLAUDE.md  # Should print 1\ngrep -c \"ctx:end\" CLAUDE.md      # Should print 1\n
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#further-reading","level":2,"title":"Further Reading","text":"
      • Getting Started: Full setup walkthrough
      • Context Files: What each .context/ file does
      • Integrations: Per-tool setup (Claude Code, Cursor, Aider, Copilot)
      • CLI Reference: All ctx commands and flags
      ","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/release/","level":1,"title":"Cutting a Release","text":"

      Full Release Checklist

      This page covers the mechanics of cutting a release (bump, tag, push). For the complete pre-release ceremony (audits, tests, verification, and post-release steps), see the Release Checklist runbook.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#prerequisites","level":2,"title":"Prerequisites","text":"

      Before you can cut a release you need:

      • Push access to origin (GitHub)
      • GPG signing configured (make gpg-test)
      • Go installed (version in go.mod)
      • Zensical installed (make site-setup)
      • A clean working tree (git status shows nothing to commit)
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#step-by-step","level":2,"title":"Step-by-Step","text":"","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#1-update-the-version-file","level":3,"title":"1. Update the VERSION File","text":"
      echo \"0.9.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.9.0\"\n

      The VERSION file uses bare semver (0.9.0), no v prefix. The release script adds the v prefix for git tags.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#2-generate-release-notes","level":3,"title":"2. Generate Release Notes","text":"

      In Claude Code:

      /_ctx-release-notes\n

      This analyzes commits since the last tag and writes dist/RELEASE_NOTES.md. The release script refuses to proceed without this file.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#3-verify-docs-and-commit-any-remaining-changes","level":3,"title":"3. Verify Docs and Commit Any Remaining Changes","text":"
      /ctx-link-check    # audit docs for dead links\nmake audit          # full check: fmt, vet, lint, style, test\ngit status          # must be clean\n
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#4-run-the-release","level":3,"title":"4. Run the Release","text":"
      make release\n

      Or, if you are in a Claude Code session:

      /_ctx-release\n

      The release script does everything in order:

      Step What happens 1 Reads VERSION, verifies release notes exist 2 Verifies working tree is clean 3 Updates version in 4 config files (plugin.json, marketplace.json, VS Code package.json + lock) 4 Updates download URLs in 3 doc files (index.md, getting-started.md, integrations.md) 5 Adds new row to versions.md 6 Rebuilds the documentation site (make site) 7 Commits all version and docs updates 8 Runs make test and make smoke 9 Builds binaries for all 6 platforms via hack/build-all.sh 10 Creates a signed git tag (v0.9.0) 11 Pushes the tag to origin 12 Updates and pushes the latest tag","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#5-github-ci-takes-over","level":3,"title":"5. GitHub CI Takes Over","text":"

      Pushing a v* tag triggers .github/workflows/release.yml:

      1. Checks out the tagged commit
      2. Runs the full test suite
      3. Builds binaries for all platforms
      4. Creates a GitHub Release with auto-generated notes
      5. Uploads binaries and SHA256 checksums
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#6-verify","level":3,"title":"6. Verify","text":"
      • GitHub Releases shows the new version
      • All 6 binaries are attached (linux/darwin x amd64/arm64, windows x amd64)
      • SHA256 files are attached
      • Release notes look correct
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#what-gets-updated-automatically","level":2,"title":"What Gets Updated Automatically","text":"

      The release script updates 8 files so you do not have to:

      File What changes internal/assets/claude/.claude-plugin/plugin.json Plugin version .claude-plugin/marketplace.json Marketplace version (2 fields) editors/vscode/package.json VS Code extension version editors/vscode/package-lock.json VS Code lock version (2 fields) docs/index.md Download URLs docs/home/getting-started.md Download URLs docs/operations/integrations.md VSIX filename version docs/reference/versions.md New version row + latest pointer

      The Go binary version is injected at build time via -ldflags from the VERSION file. No source file needs editing.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#build-targets-reference","level":2,"title":"Build Targets Reference","text":"Target What it does make release Full release (script + tag + push) make build Build binary for current platform make build-all Build all 6 platform binaries make test Unit tests make smoke Integration smoke tests make audit Full check (fmt + vet + lint + drift + docs + test) make site Rebuild documentation site","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#release-notes-not-found","level":3,"title":"\"Release Notes Not Found\"","text":"
      ERROR: dist/RELEASE_NOTES.md not found.\n

      Run /_ctx-release-notes in Claude Code first, or write dist/RELEASE_NOTES.md manually.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#working-tree-is-not-clean","level":3,"title":"\"Working Tree Is Not Clean\"","text":"
      ERROR: Working tree is not clean.\n

      Commit or stash all changes before running make release.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#tag-already-exists","level":3,"title":"\"Tag Already Exists\"","text":"
      ERROR: Tag v0.9.0 already exists.\n

      You cannot release the same version twice. Either bump VERSION to a new version, or delete the old tag if the release was incomplete:

      git tag -d v0.9.0\ngit push origin :refs/tags/v0.9.0\n
      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#ci-build-fails-after-tag-push","level":3,"title":"CI Build Fails After Tag Push","text":"

      The tag is already published. Fix the issue, bump to a patch version (e.g. 0.9.1), and release again. Do not force-push tags that others may have already fetched.

      ","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/upgrading/","level":1,"title":"Upgrade","text":"","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#upgrade","level":2,"title":"Upgrade","text":"

      New versions of ctx may ship updated permissions, CLAUDE.md directives, or plugin hooks and skills.

      Claude Code User?

      The marketplace can update skills, hooks, and prompts independently: /plugin → select ctx → Update now (or enable auto-update).

      The ctx binary is separate: rebuild from source or download a new release when one is available, then run ctx init --reset --merge. Knowledge files are preserved automatically.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#tldr","level":2,"title":"TL:DR","text":"
      # Plugin users (Claude Code)\n# /plugin → select ctx → Update now\n# Then update the binary and reinitialize:\nctx init --reset --merge\n\n# From-source / manual users\n# install new ctx binary, then:\nctx init --reset --merge\n# /plugin → select ctx → Update now   (if using Claude Code)\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#what-changes-between-versions","level":2,"title":"What Changes between Versions","text":"

      ctx init generates two categories of files:

      Category Examples Changes between versions? Infrastructure .claude/settings.local.json (permissions), ctx-managed sections in CLAUDE.md, ctx plugin (hooks + skills) Yes Knowledge .context/TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md, ARCHITECTURE.md, GLOSSARY.md, CONSTITUTION.md, AGENT_PLAYBOOK.md No: this is your data

      Infrastructure is regenerated by ctx init and plugin updates. Knowledge files are yours and should never be overwritten.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#upgrade-steps","level":2,"title":"Upgrade Steps","text":"","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#1-install-the-new-version","level":3,"title":"1. Install the New Version","text":"

      Build from source or download the binary:

      cd /path/to/ctx-source\ngit pull\nmake build\nsudo make install\nctx --version   # verify\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#2-reinitialize","level":3,"title":"2. Reinitialize","text":"
      ctx init --reset --merge\n
      • --force regenerates infrastructure files (permissions, ctx-managed sections in CLAUDE.md).
      • --merge preserves your content outside ctx markers.

      Knowledge files (.context/TASKS.md, DECISIONS.md, etc.) are preserved automatically: ctx init only overwrites infrastructure, never your data.

      Encryption key: The encryption key lives at ~/.ctx/.ctx.key (outside the project). Reinit does not affect it. If you have a legacy key at .context/.ctx.key or ~/.local/ctx/keys/, copy it manually (see Syncing Scratchpad Notes).

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#3-update-the-ctx-plugin","level":3,"title":"3. Update the ctx Plugin","text":"

      If you use Claude Code, update the plugin to get new hooks and skills:

      1. Open /plugin in Claude Code.
      2. Select ctx.
      3. Click Update now.

      Or enable auto-update so the plugin stays current without manual steps.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#4-review-custom-settings","level":3,"title":"4. Review Custom Settings","text":"

      If you added custom permissions to .claude/settings.local.json beyond what ctx init provides, diff and merge:

      diff .claude.bak/settings.local.json .claude/settings.local.json\n

      Manually add back any custom entries that the new init dropped.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#5-verify","level":3,"title":"5. Verify","text":"

      Activate the project first, otherwise ctx status and ctx drift will fail with Error: no context directory specified:

      eval \"$(ctx activate)\"\nctx status          # context files intact\nctx drift           # no broken references\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#6-clean-up","level":3,"title":"6. Clean Up","text":"

      If you made manual backups, remove them once satisfied:

      rm -rf .context.bak .claude.bak CLAUDE.md.bak\n
      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#what-if-i-skip-the-upgrade","level":2,"title":"What If I Skip the Upgrade?","text":"

      The old binary still works with your existing .context/ files. But you may miss:

      • New plugin hooks that enforce better practices or catch mistakes;
      • Updated skill prompts that produce better results;
      • New .gitignore entries for directories added in newer versions;
      • Bug fixes in the CLI itself.

      The plugin and the binary can be updated independently. You can update the plugin (for new hooks/skills) even if you stay on an older binary, and vice versa.

      Context files are plain Markdown: They never break between versions.

      The surrounding infrastructure is what evolves.

      ","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/","level":1,"title":"Architecture Exploration","text":"","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#architecture-exploration","level":1,"title":"Architecture Exploration","text":"

      Systematically build architecture documentation across one or more repositories using ctx skills. Each invocation does one unit of work; a simple loop drives the agent through all phases.

      When to use: When onboarding to a new codebase, performing architecture reviews, or building up .context/ documentation across a workspace of repos.

      Prerequisites: ctx installed, repos cloned under a shared workspace directory (e.g., ~/WORKSPACE/).

      Companion skills:

      • /ctx-architecture: structural baseline and principal analysis
      • /ctx-architecture-enrich: code intelligence enrichment via GitNexus
      • /ctx-architecture-failure-analysis: adversarial failure analysis
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#overview","level":2,"title":"Overview","text":"

      The agent progresses through phases per repo, depth-first:

      Phase Skill What it does bootstrap ctx init + /ctx-architecture Initialize context and build structural baseline principal /ctx-architecture principal Deep analysis: vision, bottlenecks, alternatives enriched /ctx-architecture-enrich Quantify with code intelligence (blast radius, flows) frontier-N /ctx-architecture (re-run) Explore unexplored areas found in convergence report lens-* /ctx-architecture with lens Focused exploration through conceptual lenses

      Exploration stops when convergence >= 0.85, frontier runs plateau, or all lenses are exhausted.

      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#setup","level":2,"title":"Setup","text":"

      Create a tracking directory in your workspace root:

      cd ~/WORKSPACE\nmkdir -p .arch-explorer\n

      Create .arch-explorer/manifest.json listing your repos:

      {\n  \"repos\": [\"ctx\", \"portal\", \"infra\"],\n  \"current_repo_index\": 0,\n  \"progress\": {}\n}\n

      Create .arch-explorer/run-log.md (empty, the agent appends to it).

      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#prompt","level":2,"title":"Prompt","text":"

      Save this as .arch-explorer/PROMPT.md and invoke with your agent. The prompt is self-contained: the agent reads the manifest, picks the next unit of work, executes it, updates tracking, and stops.

      You are an autonomous architecture exploration agent. Your job is to\nsystematically build and evolve architecture documentation across all\nrepositories in this workspace using ctx skills.\n\n## Execution Protocol\n\n### Step 1: Read State\n\nRead `.arch-explorer/manifest.json`. This tells you:\n- Which repos exist and their order\n- What has been done per repo (`progress` object)\n- Which repo to work on next (`current_repo_index`)\n\n### Step 2: Pick the Next Unit of Work\n\n**Strategy: depth-first, sequential.**\n\nFind the current repo (by `current_repo_index`). Determine its next\nphase from the progression below. If all phases are exhausted for this\nrepo (convergence score >= 0.85 or 3+ frontier runs with no new\nfindings), advance `current_repo_index` and pick the next repo.\n\n### Phase Progression (per repo)\n\nEach repo progresses through these phases in order:\n\n| Phase | Skill | Prerequisite |\n|-------|-------|-------------|\n| `bootstrap` | `ctx init` + `/ctx-architecture` | None |\n| `principal` | `/ctx-architecture principal` | bootstrap done |\n| `enriched` | `/ctx-architecture-enrich` | principal done, GitNexus indexed |\n| `frontier-N` | `/ctx-architecture` (re-run) | enriched done |\n\n**`bootstrap` is a single composite unit:** `ctx init` followed by\nstructural analysis. This is the ONLY phase that combines two actions.\nNo other phase may chain actions.\n\n**Frontier runs** are numbered: `frontier-1`, `frontier-2`, etc.\nEach frontier run reads CONVERGENCE-REPORT.md and picks unexplored\nareas. The skill handles this automatically.\n\nAfter the third frontier run OR when convergence >= 0.85, apply\n**conceptual lenses** (one per run):\n\n| Lens | Focus Areas |\n|------|-------------|\n| `security` | Auth flows, input validation, secrets, attack surfaces, trust boundaries |\n| `performance` | Hot paths, caching, concurrency, resource lifecycle, allocation patterns |\n| `stability` | Error handling, retries, graceful degradation, circuit breakers, timeouts |\n| `observability` | Logging, metrics, tracing, alerting, debugging affordances |\n| `data-integrity` | Storage, serialization, migrations, consistency, backup, recovery |\n\nFor lens runs, prepend the lens context as an explicit instruction to\nthe skill invocation:\n\n> \"Focus exploration on security: auth flows, input validation, secrets,\n> attack surfaces, trust boundaries.\"\n\nDo NOT wait for the skill to ask what to explore. Provide the lens\nfocus as input upfront.\n\n### Step 3: Do the Work\n\n1. `cd` into the sub-repo directory (`~/WORKSPACE/<repo-name>`, NOT\n   `~/WORKSPACE` itself).\n2. Verify `CTX_DIR` already points at THIS sub-repo's `.context/`:\n\n    ```bash\n    test \"$CTX_DIR\" = \"$PWD/.context\" || {\n      echo \"STOP: CTX_DIR=$CTX_DIR but this sub-repo needs $PWD/.context.\"\n      echo \"Re-launch the agent with CTX_DIR set to the sub-repo:\"\n      echo \"  cd $PWD && CTX_DIR=\\\"\\$PWD/.context\\\" claude --print 'Follow .arch-explorer/PROMPT.md' --allowedTools '*'\"\n      exit 1\n    }\n    ```\n\n    If it fails, STOP. The agent cannot change `CTX_DIR` for itself:\n    child shells and skill invocations inherit the parent Claude\n    process environment, which only the caller can control. Do not\n    proceed, do not run `ctx` commands, do not skip the check.\n3. If phase is `bootstrap`:\n    - Run `ctx init`, confirm `.context/` exists.\n    - Then run `/ctx-architecture` (structural baseline).\n4. If phase is `principal` or `frontier-*`:\n    - Run `/ctx-architecture` (add `principal` argument for principal phase).\n    - The skill will read existing artifacts and build on them.\n5. If phase is `enriched`:\n    - Verify GitNexus is connected: call `mcp__gitnexus__list_repos`.\n    - Success = non-empty list returned with no error.\n    - If GitNexus unavailable, log as `enriched-skipped` and advance\n      to `frontier-1`.\n    - Run `/ctx-architecture-enrich`.\n6. If phase is a lens run (`lens-security`, etc.):\n    - Run `/ctx-architecture` with lens focus prepended as instruction\n      (see lens table above for exact wording).\n\n### Step 4: Extract Results\n\nAfter the skill completes, gather:\n\n- **Convergence score**: from `map-tracking.json`, computed as:\n  average of all module `confidence` values (0.0-1.0). If\n  `map-tracking.json` is missing or has no confidence values,\n  record `null` and log a warning.\n- **Frontier count**: from CONVERGENCE-REPORT.md, count the number\n  of listed unexplored areas. If CONVERGENCE-REPORT.md is missing,\n  record `frontier_count: null` and log a warning. Treat missing\n  as \"exploration should continue\" (do not stall).\n- **Key findings**: 2-3 bullet points of what was discovered or\n  changed in this run (new modules mapped, danger zones found, etc.)\n- **New artifacts**: list any new files created in `.context/`\n\n### Step 5: Update Tracking\n\nUpdate `.arch-explorer/manifest.json`:\n\n```json\n{\n  \"progress\": {\n    \"ctx\": {\n      \"phases_completed\": [\"bootstrap\", \"principal\"],\n      \"current_phase\": \"enriched\",\n      \"lenses_explored\": [],\n      \"last_run\": \"2026-04-07T14:00:00Z\",\n      \"convergence_score\": 0.72,\n      \"frontier_count\": 3,\n      \"total_runs\": 2,\n      \"findings_summary\": \"14 modules mapped, 3 danger zones, 2 extension points\"\n    }\n  }\n}\n```\n\nAppend to `.arch-explorer/run-log.md`:\n\n```markdown\n## 2026-04-07T14:00:00Z / ctx / principal\n\n**Phase:** principal\n**Convergence:** 0.45 -> 0.72\n**Frontiers remaining:** 3\n**Key findings:**\n- Identified CLI dispatch as primary bottleneck (fan-out to 12 subsystems)\n- Security: context files readable by any process (no access control)\n- Strategic recommendation: extract context engine into library package\n\n**Artifacts updated:** ARCHITECTURE-PRINCIPAL.md, DANGER-ZONES.md, map-tracking.json\n```\n\n### Step 6: Report and Stop\n\nPrint this exact format as the FINAL output of the invocation:\n\n```\n[arch-explorer] DONE\n  repo: ctx\n  phase: principal\n  convergence: 0.72\n  frontiers: 3\n  runs_on_repo: 3\n  next: ctx / enriched\n```\n\nThe `[arch-explorer] DONE` line is the terminal marker. After printing\nit, produce no further output. Execution is complete.\n\n## Rules\n\n1. **One unit per invocation.** The only composite unit is `bootstrap`\n   (init + structural). All other phases are exactly one skill run.\n2. **Additive only.** Never delete or overwrite existing artifacts.\n   The skills already handle incremental updates.\n3. **No duplicated work.** Read manifest before acting. If a phase is\n   already recorded as completed, skip it.\n4. **Log everything.** Every run gets a run-log entry, even failures\n   and skips.\n5. **Fail gracefully.** If a skill fails (missing GitNexus, broken repo,\n   etc.), log the failure with reason and advance to the next phase or\n   repo. Don't retry in the same invocation.\n6. **Respect ctx conventions.** Each repo gets its own `.context/`\n   directory. Never write architecture artifacts outside `.context/`.\n\n## Stopping Logic\n\nA repo is considered \"explored\" when ANY of these is true:\n- Convergence score >= 0.85 (from map-tracking.json)\n- 3+ frontier runs produced no new findings (frontier_count unchanged\n  across consecutive runs)\n- All 5 lenses have been applied\n- Convergence score is `null` after 3 attempts (artifacts aren't being\n  generated properly; log warning and move on)\n\nWhen a repo is explored, advance `current_repo_index` in the manifest.\n\n## When All Repos Are Done\n\nWhen every repo has reached its stopping condition, print:\n\n```\n[arch-explorer] ALL DONE\n  - ctx: 0.92 convergence, 8 runs, 5 lenses\n  - portal: 0.87 convergence, 6 runs, 3 lenses\n  ...\n```\n
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#invocation","level":2,"title":"Invocation","text":"

      The caller MUST set CTX_DIR to the sub-repo the agent will work on. The agent verifies this at Step 3.2 and stops if it does not match. The wrapper reads the manifest to pick the current sub-repo, then launches claude with CTX_DIR pinned to that sub-repo's .context/.

      Single run (safest for quota):

      cd ~/WORKSPACE\nREPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\nCTX_DIR=\"$PWD/$REPO/.context\" \\\n  claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*'\n

      Batch of N runs:

      cd ~/WORKSPACE\nfor i in $(seq 1 5); do\n  REPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\n  CTX_DIR=\"$PWD/$REPO/.context\" \\\n    claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*'\n  echo \"--- Run $i complete (repo: $REPO) ---\"\ndone\n

      Resume after interruption:

      Just run the wrapper again. The manifest tracks state; the agent picks up where it left off. CTX_DIR is recomputed from the manifest on each invocation, so the right sub-repo is always bound.

      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#tips","level":2,"title":"Tips","text":"
      • Start small: list 1-2 repos in the manifest first. Add more once you're confident in the output quality.
      • GitNexus is optional: the enrichment phase is skipped gracefully if GitNexus isn't connected. You still get structural and principal analysis.
      • Review between batches: check the run-log and generated artifacts between batch runs. The agent is additive-only, but early course correction saves wasted runs.
      • Lens runs are the payoff: the first three phases build the map; lens runs find the interesting things (security gaps, performance cliffs, stability risks).
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#history","level":2,"title":"History","text":"
      • 2026-04-07: Original prompt created as hack/agents/architecture-explorer.md.
      • 2026-04-16: Moved to docs as a runbook for discoverability.
      • 2026-04-20: Added CTX_DIR verification at Step 3.2 and per-invocation CTX_DIR binding in the wrapper, so the agent writes artifacts to the sub-repo's .context/ instead of the inherited workspace one.
      ","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/backup-strategy/","level":1,"title":"Backup Strategy","text":"

      ctx backup was removed. File-level backup is not ctx's responsibility; your OS or a dedicated backup tool handles it better and without locking you into a specific mount strategy.

      This runbook explains what to back up, how ctx hub reduces the surface, and what options exist for the rest.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-to-back-up","level":2,"title":"What To Back Up","text":"

      Per project:

      • .context/: all context files, journal, state, scratchpad.
      • .claude/: Claude Code settings, hooks, skills specific to the project. Skip this entry when it lives in git; the repo is the backup.

      Per user:

      • ~/.ctx/: global config, the encryption key (~/.ctx/.ctx.key), hub data directory (if running a local hub).
      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#how-hub-reduces-backup-needs","level":2,"title":"How Hub Reduces Backup Needs","text":"

      ctx hub replicates the knowledge surface across machines:

      • DECISIONS.md
      • LEARNINGS.md
      • CONVENTIONS.md
      • CONSTITUTION.md
      • ARCHITECTURE.md
      • Task items promoted to hub

      If you run ctx hub (as a server or by subscribing to someone else's), the data that matters most survives losing any single machine.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-hub-does-not-replicate","level":2,"title":"What Hub Does Not Replicate","text":"

      Hub is not a file-level backup. The following still live only on the machine that produced them:

      • Journal entries (.context/journal/*.md)
      • Runtime state (.context/state/*)
      • Session event log (.context/events.jsonl)
      • Scratchpad (.context/.pad)
      • Encrypted notify/webhook config (.context/.notify.enc)
      • The encryption key itself (~/.ctx/.ctx.key)

      If you need those to survive a disk failure, use a file-level backup.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#example-strategies","level":2,"title":"Example Strategies","text":"","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#1-cron-rsync-to-nas-or-external-drive","level":3,"title":"1. cron + rsync to NAS or External Drive","text":"
      # Daily at 03:00, mirror ~/WORKSPACE and ~/.ctx to NAS\n0 3 * * * rsync -a --delete \\\n    --exclude='node_modules' \\\n    --exclude='dist' \\\n    --exclude='.context/state' \\\n    ~/WORKSPACE/ /mnt/nas/backup/workspace/\n0 3 * * * rsync -a --delete ~/.ctx/ /mnt/nas/backup/ctx-global/\n

      Adjust excludes for the trash you don't want to back up. The .context/state/ dir is ephemeral per-session; skip it.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#2-cron-cp-to-a-cloud-synced-directory","level":3,"title":"2. cron + cp to a Cloud-Synced Directory","text":"

      iCloud Drive, Dropbox, or any directory watched by a sync client:

      0 3 * * * cp -a ~/WORKSPACE/some-project/.context \\\n    ~/CloudDrive/ctx-backups/some-project/$(date +\\%Y-\\%m-\\%d)\n

      Daily snapshots, cloud provider handles the replication.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#3-time-machine-macos","level":3,"title":"3. Time Machine (macOS)","text":"

      If you already run Time Machine, ensure ~/WORKSPACE and ~/.ctx are not in its exclusion list. Time Machine handles versioning; you get point-in-time recovery for free.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#4-borg-or-restic-for-versioned-backups","level":3,"title":"4. Borg or restic for Versioned Backups","text":"

      For deduplicated, versioned, encrypted backups:

      # Borg init (once)\nborg init --encryption=repokey /mnt/nas/borg-ctx\n\n# Daily backup\nborg create /mnt/nas/borg-ctx::'ctx-{now}' \\\n    ~/WORKSPACE ~/.ctx \\\n    --exclude '*/node_modules' \\\n    --exclude '*/.context/state'\n

      Use restic if you prefer S3-compatible targets.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#when-you-still-need-file-level-backup-even-with-hub","level":2,"title":"When You Still Need File-Level Backup Even With Hub","text":"
      • Journal: session histories are local-only until exported.
      • Scratchpad: private notes, encrypted locally.
      • Encryption key: losing ~/.ctx/.ctx.key means losing access to every encrypted file in every project.
      • Non-hub projects: projects that never called ctx hub register have zero cross-machine persistence.

      For these, pick one strategy above and forget about it.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#why-ctx-no-longer-ships-a-backup-command","level":2,"title":"Why ctx No Longer Ships a Backup Command","text":"

      Backup is inherently environment-specific: SMB, NFS, S3, rsync, Time Machine, Borg, restic. Every user has a different story. The previous ctx backup picked SMB via GVFS, which was Linux-only and narrow. Chasing mount strategies would never generalize.

      Hub is the right answer for the data ctx owns (knowledge). For everything else, your OS or a dedicated backup tool is the right layer.

      ","path":["Backup Strategy"],"tags":[]},{"location":"operations/runbooks/breaking-migration/","level":1,"title":"Breaking Migration","text":"","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#breaking-migration-guide","level":1,"title":"Breaking Migration Guide","text":"

      Template for upgrading across breaking CLI renames or behavior changes. Use this as a starting point when writing migration notes for a specific release, or hand it to your agent as context for generating release-specific guidance.

      When to use: When a release includes breaking changes (command renames, removed flags, changed defaults) that require user action.

      Companion: Upgrade guide covers the general upgrade flow. This runbook covers the breaking-change specifics.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-1-identify-what-changed","level":2,"title":"Step 1: Identify What Changed","text":"

      Ask your agent to diff the CLI surface between the old and new version:

      Compare the CLI command surface between the previous release tag\nand HEAD. For each change, categorize as: renamed, removed,\nnew, or changed-behavior. Include old and new command signatures.\n

      Or use the /_ctx-command-audit skill after the rename.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-2-regenerate-infrastructure","level":2,"title":"Step 2: Regenerate Infrastructure","text":"
      # Install the new binary\nmake build && sudo make install\n\n# Regenerate CLAUDE.md and permissions\nctx init --reset --merge\n

      --merge preserves your knowledge files (TASKS.md, DECISIONS.md, etc.) while regenerating infrastructure (permissions, CLAUDE.md managed sections).

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-3-update-the-plugin","level":2,"title":"Step 3: Update the Plugin","text":"
      /plugin -> select ctx -> Update now\n

      Or, if using a local clone:

      make plugin-reload\n# restart Claude Code\n
      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-4-update-personal-scripts","level":2,"title":"Step 4: Update Personal Scripts","text":"

      Search your scripts and aliases for old command names:

      # Example: find references to old command names\ngrep -r \"ctx old-command\" ~/scripts/ ~/.zshrc ~/.bashrc\n

      Replace with the new names per the changelog.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-5-update-hook-configs","level":2,"title":"Step 5: Update Hook Configs","text":"

      If you have custom hooks in .claude/settings.local.json that reference ctx commands, update them:

      jq '.hooks' .claude/settings.local.json | grep \"ctx \"\n
      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-6-verify","level":2,"title":"Step 6: Verify","text":"

      Activate the project first, otherwise ctx status and ctx drift will fail with Error: no context directory specified:

      eval \"$(ctx activate)\"\nctx status          # context files intact\nctx drift           # no broken references\nmake test           # if you're a contributor\n

      See Activating a Context Directory.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#writing-release-specific-migration-notes","level":2,"title":"Writing Release-Specific Migration Notes","text":"

      When preparing a release with breaking changes, create a section in the release notes using this template:

      ## Breaking Changes\n\n### `old-command` renamed to `new-command`\n\n**What changed**: `ctx old-command` is now `ctx new-command`.\nThe old name is removed (no deprecation alias).\n\n**Action required**:\n1. Run `ctx init --reset --merge` to update CLAUDE.md\n2. Update any scripts referencing `ctx old-command`\n3. Update hook configs if applicable\n\n**Why**: [brief rationale for the rename]\n

      Repeat for each breaking change. Users should be able to follow the notes mechanically without needing to understand the codebase.

      ","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/codebase-audit/","level":1,"title":"Codebase Audit","text":"","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#codebase-audit","level":1,"title":"Codebase Audit","text":"

      A structured audit of the codebase: dead code, magic strings, documentation drift, security surface, and roadmap opportunities.

      When to run: Before a release, after a long YOLO sprint, quarterly, or when planning the next phase of work.

      Time: ~15-30 minutes with a team of agents.

      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#how-to-use-this-runbook","level":2,"title":"How to Use This Runbook","text":"

      Start a Claude Code session with a clean git state (git stash or commit first). Paste or adapt the prompt below. The agent does the analysis; you triage the findings.

      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#prompt","level":2,"title":"Prompt","text":"
      I want you to create an agent team to audit this codebase. Save each report as\na separate markdown file under `./ideas/` (or another directory if you prefer).\n\nUse read-only agents (subagent_type: Explore) for all analyses. No code changes.\n\nFor each report, use this structure:\n- Executive Summary (2-3 sentences + severity table)\n- Findings (grouped, with file:line references)\n- Ranked Recommendations (high/medium/low priority)\n- Methodology (what was examined, how)\n\nKeep reports actionable: every finding should suggest a concrete fix or next step.\n\n## Analyses to Run\n\n### 1. Extractable Patterns (session mining)\nSearch session JSONL files, journal entries, and task archives for repetitive\nmulti-step workflows. Count frequency of bash command sequences, slash command\nusage, and recurring user prompts. Identify patterns that could become skills\nor scripts. Cross-reference with existing skills to find coverage gaps.\nOutput: ranked list of automation opportunities with frequency data.\n\n### 2. Documentation Drift (godoc + inline)\nCompare every doc.go against its package's actual exports and behavior. Check\ninline godoc comments on exported functions against their implementations.\nScan for stale TODO/FIXME/HACK comments. Check package-level comments match\npackage names. Output: drift items ranked by severity with exact file:line refs.\n\n### 3. Maintainability\nLook for: functions >80 lines that have logical split points; switch blocks\nwith >5 cases that could be table-driven or extracted; inline comments that\nsay \"step 1\", \"step 2\" or similar (sign the block wants to be a function);\nfiles with >400 lines; packages with flat structure that could benefit from\nsub-packages; functions that seem misplaced in their file. Do NOT flag\nthings that are fine as-is just because they could theoretically be different.\nOutput: concrete refactoring suggestions, not style nitpicks.\n\n### 4. Security Review\nThis is a CLI app: focus on CLI-relevant attack surface, not web OWASP:\nfile path traversal (does user input flow into file paths unsanitized?),\ncommand injection (does user input flow into exec calls?), symlink following\n(does the tool follow symlinks when writing to .context/?), permission\nhandling (are file permissions set correctly?), sensitive data in outputs\n(do any commands leak secrets or session content?). Output: findings with\nseverity ratings and exploit scenarios.\n\n### 5. Blog Theme Discovery\nRead existing blog posts for style and narrative voice. Analyze git log,\nrecent session discussions, and DECISIONS.md for story arcs worth writing\nabout. Suggest 3-5 blog post themes with: title, angle, target audience,\nkey commits/sessions to reference, and a 2-sentence pitch. Prioritize\nthemes that build a coherent narrative across posts.\n\n### 6. Roadmap & Value Opportunities\nBased on current features, recent momentum, and gaps found in other analyses:\nwhat are the highest-value improvements? Consider: user-facing features,\ndeveloper experience, integration opportunities, and low-hanging fruit.\nOutput: prioritized list with effort/impact estimates (not time estimates).\n\n### 7. User-Facing Documentation\nEvaluate README, help text, and any user docs. Suggest improvements\nstructured as use-case pages: the problem, how ctx solves it, typical\nworkflow, gotchas. Identify gaps where a user would get stuck without\nreading source code. Output: list of documentation gaps and suggested\npage outlines.\n\n### 8. Agent Team Strategies\nBased on the codebase structure, suggest 2-3 agent team configurations for\nupcoming work sessions. For each: team composition (roles, agent types),\ntask distribution strategy, coordination approach, and which types of work\nit suits. Ground suggestions in actual project patterns, not generic advice.\n
      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#tips","level":2,"title":"Tips","text":"
      • Clean state matters: the prompt says \"no code changes\" but accidents happen. Start from a clean git state so you can git checkout . if needed.

      • Adjust scope: drop analyses you don't need. Analyses 1-4 are the most actionable. Analyses 5-8 are planning/creative and can be skipped if you just want a technical audit.

      • Reports feed TASKS.md: after the audit, read each report and create tasks in the appropriate Phase section. The reports are input, not output.

      • ideas/ is gitignored: reports saved there won't be committed. Move specific findings to TASKS.md, DECISIONS.md, or LEARNINGS.md to persist them.

      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#history","level":2,"title":"History","text":"
      • 2026-02-08: Original prompt created after a codebase audit sprint.
      • 2026-02-17: Improved with read-only agents, report structure template, CLI-scoped security review, and maintainability thresholds.
      • 2026-04-16: Moved from hack/runbooks/ to docs/operations/runbooks/.
      ","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/","level":1,"title":"Docs Semantic Audit","text":"","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#documentation-semantic-audit","level":1,"title":"Documentation Semantic Audit","text":"

      Find structural problems that linters and link checkers cannot: weak pages that should be merged, heavy pages that should be split, missing cross-links, and narrative arcs that don't land.

      When to run: Before a release, after adding several new pages, when the site feels sprawling, or when you suspect narrative gaps.

      Time: ~20-40 minutes with an agent session.

      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#why-this-is-a-runbook","level":2,"title":"Why This Is a Runbook","text":"

      These judgments are inherently subjective and context-dependent. A page is \"weak\" relative to its neighbors; a narrative arc only matters if the docs intend to tell a story. Deterministic tools (broken-link checkers, word counters) can't do this. An LLM reading the full doc set can.

      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#prompt","level":2,"title":"Prompt","text":"

      Paste or adapt the following into a Claude Code session. The agent needs read access to docs/ and the site nav structure.

      Read every file under docs/ (including docs/blog/ and docs/recipes/).\nFor each file, note: title, word count, outbound links, inbound links\n(how many other pages link to it), and a one-line summary of its purpose.\n\nThen produce a report with these sections:\n\n## 1. Weak Dangling Pages\n\nPages that are thin, isolated, or redundant. Signs:\n- Under ~300 words with no unique content (just restates what another page says)\n- Zero or one inbound links (orphaned in the nav)\n- Content that would be stronger merged into an adjacent page\n- \"Try it in 5 minutes\" sections that assume installation already happened\n- Pages whose title doesn't work as a nav entry (too long, too vague)\n\nFor each: identify the page, explain why it's weak, and recommend\nmerge target or deletion.\n\n## 2. Overly Heavy Pages\n\nPages doing too much. Signs:\n- Over ~1500 words with multiple distinct topics\n- More than 4 H2 sections that could stand alone\n- Reader has to scroll past irrelevant content to find what they need\n- Mixed audience (beginner setup + advanced config on same page)\n\nFor each: identify the page, list the distinct topics, and suggest\nsplit points.\n\n## 3. Missing Cross-Links\n\nPlaces where a reader would naturally want to jump to related content\nbut no link exists. Look for:\n- Concepts mentioned but not linked (e.g., \"scratchpad\" without linking\n  to the scratchpad page)\n- Blog posts that describe features without linking to the reference docs\n- Recipes that reference workflows without linking to the relevant\n  getting-started section\n- Pages that end without a \"Next Up\" or \"See Also\" pointer\n\nFor each: source page, anchor text, suggested link target.\n\n## 4. Narrative Gaps\n\nThe docs should tell a coherent story: problem -> install -> first session\n-> daily workflow -> advanced patterns -> contributing. Look for:\n- Gaps in the progression (e.g., no bridge from \"first session\" to\n  \"daily habits\")\n- Blog posts that introduce concepts the reference docs don't cover\n- Recipes that assume knowledge no other page teaches\n- Features documented in CLI reference but missing from workflows/recipes\n\nFor each: describe the gap and suggest what page or section would fill it.\n\n## 5. Blog Cross-Linking Opportunities\n\nBlog posts are often written in isolation. Look for:\n- Posts that cover the same theme but don't reference each other\n- Posts that describe the evolution of a feature (natural \"part 1 / part 2\")\n- Posts that would benefit from a \"Related posts\" footer\n- Thematic clusters that could be linked from a recipe or reference page\n\nFor each: list the posts, the shared theme, and the suggested links.\n\n## Output Format\n\nFor every finding, include:\n- File path (docs/whatever.md)\n- Severity: high (actively confusing), medium (missed opportunity),\n  low (nice to have)\n- Concrete recommendation (merge into X, split at H2 Y, add link to Z)\n\nEnd with a prioritized action list: what to fix first.\n
      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#after-the-audit","level":2,"title":"After the Audit","text":"
      1. Triage findings: not everything needs fixing. Focus on high severity.
      2. Merge weak pages first: fewer pages is almost always better.
      3. Add cross-links: cheapest improvement, highest reader impact.
      4. File split decisions in DECISIONS.md: page splits are architectural.
      5. Regenerate the site and spot-check nav after structural changes.
      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#history","level":2,"title":"History","text":"
      • 2026-02-17: Created after merging docs/re-explaining.md into docs/about.md, which surfaced the pattern of weak standalone pages that dilute rather than add.
      • 2026-04-16: Moved from hack/runbooks/ to docs/operations/runbooks/.
      ","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/hub-deployment/","level":1,"title":"Hub Deployment","text":"","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#hub-deployment","level":1,"title":"Hub Deployment","text":"

      Linear runbook for setting up a ctx Hub for yourself or a team. Consolidates pieces currently scattered across hub recipes and operations docs.

      When to use: First-time hub setup, or when onboarding a new team onto an existing hub.

      Prerequisites: ctx binary installed, network connectivity between hub and clients.

      Companion docs:

      • Hub overview: what the hub is and is not
      • Hub operations: data directory, systemd, backup, monitoring
      • Hub failure modes: what can go wrong
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-1-start-the-hub","level":2,"title":"Step 1: Start the Hub","text":"Quick Start (foreground)Production (systemd)
      ctx hub start\n

      See Hub Operations: Systemd Unit for the full unit file.

      sudo systemctl enable --now ctx-hub\n

      The hub creates admin.token on first start. Save this token; it is the only way to register clients.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-2-generate-the-admin-token","level":2,"title":"Step 2: Generate the Admin Token","text":"

      On first start, the hub writes admin.token to the data directory (default ~/.ctx/hub-data/):

      cat ~/.ctx/hub-data/admin.token\n

      This token has full admin privileges. Keep it secret.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-3-register-clients","level":2,"title":"Step 3: Register Clients","text":"

      For each client (person or machine) that will connect:

      # On the hub machine\nctx hub register --name \"volkan-laptop\" --admin-token <admin-token>\n

      This returns a client token. Distribute it securely to the client.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-4-connect-clients","level":2,"title":"Step 4: Connect Clients","text":"

      On each client machine, register the project with the hub. The ctx hub * commands above run on the hub server itself and don't need a project. The ctx connection * commands below are different: they live inside a project (the encrypted hub config is stored at .context/.connect.enc), so you have to tell ctx which project first.

      # In the project directory on the client machine:\neval \"$(ctx activate)\"\nctx connection register <hub-address> --token <client-token>\n

      Verify the connection:

      ctx connection status\n

      If the client doesn't have a project yet, run ctx init first, then eval \"$(ctx activate)\". See Activating a Context Directory.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-5-verify-sync","level":2,"title":"Step 5: Verify Sync","text":"

      Push a test entry from one client and verify it arrives. Make sure each client already ran eval \"$(ctx activate)\" from Step 4: otherwise ctx add and ctx status fail with Error: no context directory specified.

      # Client A (in its project directory, after activating):\nctx learning add \"Hub sync test\" --context \"Verifying hub setup\"\n\n# Client B (in its project directory, after activating):\nctx status   # should show the new learning\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-6-configure-backup","level":2,"title":"Step 6: Configure Backup","text":"

      Set up regular backups of the hub data directory. See Hub Operations: Backup and Restore.

      Minimum:

      # Add to cron\n0 */6 * * * cp ~/.ctx/hub-data/entries.jsonl ~/backups/entries-$(date +\\%F).jsonl\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-7-configure-tls-when-available","level":2,"title":"Step 7: Configure TLS (When Available)","text":"

      Coming Soon

      TLS support is planned (H-01/H-02). Until then, run the hub on a trusted network or behind a reverse proxy with TLS termination.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#team-onboarding-checklist","level":2,"title":"Team Onboarding Checklist","text":"

      When adding a new team member to an existing hub:

      • Generate a client token (ctx hub register --name \"<name>\")
      • Share the token and hub address securely
      • Have them run ctx connect <hub-address> --token <token>
      • Verify with ctx connection status
      • Point them to the Hub Getting Started recipe
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#connection-refused","level":3,"title":"\"Connection Refused\"","text":"

      The hub isn't running or the port is wrong. Check:

      ctx hub status          # on the hub machine\nss -tlnp | grep 9900   # default port\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#authentication-failed","level":3,"title":"\"Authentication Failed\"","text":"

      The client token is wrong or was never registered. Re-register:

      ctx hub register --name \"<name>\" --admin-token <admin-token>\n
      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#entries-not-syncing","level":3,"title":"Entries Not Syncing","text":"

      Check that the client is listening:

      ctx connection status\n

      If connected but not syncing, check the hub logs for sequence mismatch errors. See Hub Failure Modes for details.

      ","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/new-contributor/","level":1,"title":"New Contributor","text":"","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#new-contributor-onboarding","level":1,"title":"New Contributor Onboarding","text":"

      Step-by-step onboarding sequence for new contributors. Consolidates setup instructions currently scattered across the README, contributing guide, and setup docs.

      When to use: First-time contributor setup, or when verifying your development environment after a major upgrade.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-1-clone-the-repository","level":2,"title":"Step 1: Clone the Repository","text":"
      git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\n

      Or fork first on GitHub, then clone your fork.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-2-initialize-context","level":2,"title":"Step 2: Initialize Context","text":"
      ctx init\neval \"$(ctx activate)\"\n

      ctx init creates the .context/ directory with knowledge files and the .claude/ directory with agent configuration. eval \"$(ctx activate)\" tells ctx to use that directory for the rest of this runbook. If you skip the second line, the later steps fail with Error: no context directory specified.

      If ctx is not yet installed, proceed to Step 3 first, then come back.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-3-build-and-install","level":2,"title":"Step 3: Build and Install","text":"
      make build\nsudo make install\n

      Verify:

      ctx --version\n
      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-4-install-the-plugin-claude-code-users","level":2,"title":"Step 4: Install the Plugin (Claude Code Users)","text":"

      If you use Claude Code, install the plugin from your local clone so skills and hooks reflect your working tree:

      1. Launch claude
      2. Type /plugin and press Enter
      3. Select Marketplaces -> Add Marketplace
      4. Enter the absolute path to your clone (e.g., ~/WORKSPACE/ctx)
      5. Back in /plugin, select Install and choose ctx

      Verify:

      claude /plugin list   # should show ctx\n

      See Contributing: Install the Plugin for details on cache clearing.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-5-switch-to-dev-profile","level":2,"title":"Step 5: Switch to Dev Profile","text":"
      ctx config switch dev\n

      This enables verbose logging and notify events (useful during development).

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-6-verify-hooks","level":2,"title":"Step 6: Verify Hooks","text":"

      Start a Claude Code session and check that hooks fire:

      claude\n

      You should see ctx session hooks (ceremonies reminder, context loading) on session start. If not, check that the plugin is installed correctly (Step 4).

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-7-run-your-first-session","level":2,"title":"Step 7: Run Your First Session","text":"

      In Claude Code:

      /ctx-status\n

      This should show context file health, active tasks, and recent decisions. If it works, your setup is complete.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-8-verify-context-persistence","level":2,"title":"Step 8: Verify Context Persistence","text":"

      End the session and start a new one:

      /ctx-remember\n

      The agent should recall what happened in the previous session. This confirms that context persistence is working end-to-end.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-9-run-tests","level":2,"title":"Step 9: Run Tests","text":"
      make test     # unit tests\nmake audit    # full check: fmt + vet + lint + drift + docs + test\n

      All tests should pass with a clean clone.

      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#quick-reference","level":2,"title":"Quick Reference","text":"Task Command Build make build Install sudo make install Test make test Full audit make audit Rebuild docs site make site Serve docs locally make site-serve Clear plugin cache make plugin-reload Switch config profile ctx config switch dev","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#next-steps","level":2,"title":"Next Steps","text":"
      • Read the contributing guide for project layout, code style, and PR process
      • Check TASKS.md for open work items
      • Ask /ctx-next for suggested work
      ","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/plugin-release/","level":1,"title":"Plugin Release","text":"","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#plugin-release","level":1,"title":"Plugin Release","text":"

      Plugin-specific release procedure. The general release checklist covers the full ctx release; this runbook covers the plugin-specific steps that are not part of that flow.

      When to use: When releasing plugin changes (new skills, hook updates, permission changes) independently of a ctx binary release, or as a sub-procedure within the full release.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#what-ships-in-the-plugin","level":2,"title":"What Ships in the Plugin","text":"

      The plugin lives at internal/assets/claude/ and includes:

      Component Path What it does Skills internal/assets/claude/skills/ User-facing /ctx-* slash commands Hooks internal/assets/claude/hooks/ Pre/post tool-use hooks Plugin manifest internal/assets/claude/.claude-plugin/plugin.json Declares skills, hooks, version Marketplace .claude-plugin/marketplace.json Points Claude Code to the plugin","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-1-update-hooksjson-if-hooks-changed","level":2,"title":"Step 1: Update hooks.json (If Hooks Changed)","text":"

      If you added, removed, or modified hooks:

      # Verify hook definitions match implementations\nmake audit\n

      Check that plugin.json lists all hooks correctly. Missing hooks silently fail to fire.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-2-bump-version","level":2,"title":"Step 2: Bump Version","text":"

      Update the version in three places:

      • internal/assets/claude/.claude-plugin/plugin.json
      • .claude-plugin/marketplace.json (two fields)
      • editors/vscode/package.json + package-lock.json (if VS Code extension is affected)

      The Release Script Does This

      If you're running make release, the script bumps these automatically from VERSION. Only bump manually if you're releasing the plugin independently.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-3-test-against-a-fresh-install","level":2,"title":"Step 3: Test Against a Fresh Install","text":"
      # Clear cached plugin\nmake plugin-reload\n\n# Restart Claude Code, then:\nclaude /plugin list    # verify version\n

      Test the critical paths:

      • /ctx-status works
      • Session hooks fire (ceremonies, context loading)
      • At least one user-facing skill works end-to-end
      • Pre-tool-use hooks block when they should
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-4-test-against-a-clean-project","level":2,"title":"Step 4: Test Against a Clean Project","text":"

      Create a temporary project to verify the plugin works outside the ctx repo:

      mkdir /tmp/test-ctx-plugin && cd /tmp/test-ctx-plugin\ngit init\nctx init\nclaude   # start a session, verify hooks fire\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-5-verify-skill-count","level":2,"title":"Step 5: Verify Skill Count","text":"

      The plugin manifest declares all user-invocable skills. Verify the count matches:

      # Count skills in plugin.json\njq '.skills | length' internal/assets/claude/.claude-plugin/plugin.json\n\n# Count skill directories\nls -d internal/assets/claude/skills/ctx-*/ | wc -l\n

      These numbers should match (some skills are not user-invocable and won't appear in both counts).

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-6-commit-and-tag","level":2,"title":"Step 6: Commit and Tag","text":"

      If releasing independently of a binary release:

      git add internal/assets/claude/ .claude-plugin/\ngit commit -m \"chore: release plugin v0.X.Y\"\ngit tag plugin-v0.X.Y\ngit push origin main --tags\n

      If part of a full release, the release checklist handles this.

      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#troubleshooting","level":2,"title":"Troubleshooting","text":"","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#skills-dont-appear-after-update","level":3,"title":"Skills Don't Appear After Update","text":"

      Claude Code caches plugin files aggressively:

      make plugin-reload    # clears cache\n# restart Claude Code\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#hooks-dont-fire","level":3,"title":"Hooks Don't Fire","text":"

      Check that the hook is registered in plugin.json and that the command it calls exists:

      jq '.hooks' internal/assets/claude/.claude-plugin/plugin.json\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#version-mismatch","level":3,"title":"Version Mismatch","text":"

      If claude /plugin list shows an old version after updating:

      make plugin-reload\n# restart Claude Code\nclaude /plugin list   # should show new version\n
      ","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/release-checklist/","level":1,"title":"Release Checklist","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#release-checklist","level":1,"title":"Release Checklist","text":"

      The canonical pre-release sequence. This runbook ties together the audits, tests, and release steps that are otherwise scattered across docs and the operator's head.

      When to run: Before every release. No exceptions.

      Companion: The /_ctx-release skill automates the tag-and-push portion; this checklist covers everything before and after that automation.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#pre-release","level":2,"title":"Pre-Release","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#1-run-the-codebase-audit","level":3,"title":"1. Run the Codebase Audit","text":"

      Use the codebase audit runbook prompt with your agent. Focus on analyses 1-4 (extractable patterns, documentation drift, maintainability, security). Triage findings into TASKS.md; anything blocking ships before the release.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#2-run-the-docs-semantic-audit","level":3,"title":"2. Run the Docs Semantic Audit","text":"

      Use the docs semantic audit runbook prompt. Fix high-severity findings (weak pages, broken narrative arcs). Medium-severity items can be deferred.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#3-sanitize-permissions","level":3,"title":"3. Sanitize Permissions","text":"

      Follow the sanitize permissions runbook. Clean up .claude/settings.local.json before it gets committed as part of the release.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#4-run-the-full-test-suite","level":3,"title":"4. Run the Full Test Suite","text":"
      make audit    # fmt + vet + lint + drift + docs + test\nmake smoke    # integration smoke tests\n

      All tests must pass. No exceptions.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#5-check-context-health","level":3,"title":"5. Check Context Health","text":"

      Activate the project so the next commands know which .context/ to read:

      eval \"$(ctx activate)\"\nctx drift          # broken references, stale patterns\nctx status         # context file health\n/ctx-link-check    # dead links in docs\n

      Fix anything flagged. If you see Error: no context directory specified, you skipped the eval line above. See Activating a Context Directory.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#6-review-tasksmd","level":3,"title":"6. Review TASKS.md","text":"

      Scan for incomplete tasks tagged as release-blocking. Either finish them or explicitly defer with a reason in the task note.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#release","level":2,"title":"Release","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#7-bump-version","level":3,"title":"7. Bump Version","text":"
      echo \"0.X.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.X.0\"\n
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#8-generate-release-notes","level":3,"title":"8. Generate Release Notes","text":"

      In Claude Code:

      /_ctx-release-notes\n

      Review dist/RELEASE_NOTES.md. Ensure it captures all user-visible changes.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#9-cut-the-release","level":3,"title":"9. Cut the Release","text":"
      make release\n

      Or in Claude Code: /_ctx-release. See Cutting a Release for the full step-by-step.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#post-release","level":2,"title":"Post-Release","text":"","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#10-verify-the-github-release","level":3,"title":"10. Verify the GitHub Release","text":"
      • GitHub Releases shows the new version
      • All 6 binaries are attached
      • SHA256 checksums are attached
      • Release notes render correctly
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#11-update-the-plugin-marketplace","level":3,"title":"11. Update the Plugin Marketplace","text":"

      If the plugin version changed, verify the marketplace entry:

      claude /plugin list   # shows updated version\n
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#12-announce","level":3,"title":"12. Announce","text":"

      Post in the project's communication channels. Reference the release notes.

      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#13-clean-up","level":3,"title":"13. Clean Up","text":"
      rm dist/RELEASE_NOTES.md   # consumed by the release script\ngit stash pop              # if you stashed earlier\n
      ","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/","level":1,"title":"Sanitize Permissions","text":"","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#sanitize-permissions","level":1,"title":"Sanitize Permissions","text":"

      Manual procedure for cleaning up .claude/settings.local.json. The agent may analyze and recommend, but you make every edit.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#why-manual-not-automated","level":2,"title":"Why Manual, Not Automated","text":"

      settings.local.json controls what the agent can do without asking. An agent that can edit its own permission file is a self-escalation vector, especially if the skill is auto-accepted. Keep this manual.

      When to run: After busy sessions where you clicked \"Allow\" many times, weekly hygiene (pair with ctx drift), or before committing .claude/settings.local.json.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-1-snapshot","level":2,"title":"Step 1: Snapshot","text":"
      cp .claude/settings.local.json /tmp/settings-backup-$(date +%Y%m%d).json\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-2-extract-the-allow-list","level":2,"title":"Step 2: Extract the Allow List","text":"
      jq '.permissions.allow[]' .claude/settings.local.json | sort\n

      Eyeball it. You're looking for four categories:

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-3-identify-problems","level":2,"title":"Step 3: Identify Problems","text":"","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#a-garbage-nonsense","level":3,"title":"A. Garbage / Nonsense","text":"

      Entries that are clearly broken or meaningless:

      Bash(done)\nBash(__NEW_LINE_aa838494a90279c4__ echo \"\")\n

      Action: Delete.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#b-one-off-commands-session-debris","level":3,"title":"B. One-Off Commands (Session Debris)","text":"

      Entries with hardcoded paths, literal arguments, or exact commands that were accepted during a specific debugging session:

      Bash(git -C /home/jose/WORKSPACE/ctx log --oneline --all -20)\nBash(/home/jose/WORKSPACE/ctx/ctx decision add \"Use PostgreSQL\" --context ...)\n

      Signs of a one-off:

      • Full absolute paths to specific files
      • Literal string arguments (not wildcards)
      • Very specific flag combinations
      • Commands that look like they came from a single task

      Action: Delete unless you want to promote to a wildcard pattern.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#c-subsumed-entries-redundant","level":3,"title":"C. Subsumed Entries (Redundant)","text":"

      A narrow entry that's already covered by a broader one:

      # Narrow (redundant):\nBash(ctx journal source)\nBash(git -C /home/jose/WORKSPACE/ctx log --oneline -5)\n\n# Broad (already covers the above):\nBash(ctx journal source:*)\nBash(git -C:*)\n

      To find these, look for entries where removing the specific args would match an existing wildcard entry.

      Action: Delete the narrow entry.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#d-duplicate-intent-different-spelling","level":3,"title":"D. Duplicate Intent, Different Spelling","text":"

      Same command with env vars in different order, or slight variations:

      Bash(CGO_ENABLED=0 CTX_SKIP_PATH_CHECK=1 go test:*)\nBash(CTX_SKIP_PATH_CHECK=1 CGO_ENABLED=0 go test:*)\n

      Action: Keep one, delete the other.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-4-check-for-security-concerns","level":2,"title":"Step 4: Check for Security Concerns","text":"

      While you're in here, also flag:

      Pattern Risk Bash(git push:*) Bypasses block-git-push.sh hook Bash(rm -rf:*) Recursive delete, no confirmation Bash(sudo:*) Privilege escalation Bash(echo:*), Bash(cat:*) Can compose into writes to sensitive files Bash(curl:*), Bash(wget:*) Arbitrary network access Any write to .claude/ paths Agent self-modification

      See the /ctx-permission-sanitize skill for the full threat matrix.

      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-5-edit","level":2,"title":"Step 5: Edit","text":"

      Edit .claude/settings.local.json directly in your editor. Remove flagged entries. Keep the JSON valid.

      # Validate JSON after editing\njq . .claude/settings.local.json > /dev/null && echo \"valid\" || echo \"BROKEN\"\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-6-verify","level":2,"title":"Step 6: Verify","text":"
      # Compare before/after\ndiff /tmp/settings-backup-$(date +%Y%m%d).json .claude/settings.local.json\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-7-optionally-commit","level":2,"title":"Step 7: Optionally Commit","text":"
      git add .claude/settings.local.json\ngit commit -m \"chore: sanitize agent permissions\"\n
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#asking-the-agent-for-help","level":2,"title":"Asking the Agent for Help","text":"

      You can safely ask the agent to analyze the file:

      \"Look at my settings.local.json and tell me which permissions look like one-offs or are redundant.\"

      The agent can read and report. You do the edits.

      Do not add these to your allow list:

      • Skill(ctx-permission-sanitize)
      • Edit(.claude/settings.local.json)
      • Any Bash(...) pattern that writes to .claude/
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#history","level":2,"title":"History","text":"
      • 2026-02-15: Created as manual-only procedure after deciding against a self-modifying skill.
      • 2026-04-16: Moved from hack/runbooks/ to docs/operations/runbooks/.
      ","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"recipes/","level":1,"title":"Recipes","text":"

      Workflow recipes combining ctx commands and skills to solve specific problems.

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#getting-started","level":2,"title":"Getting Started","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#guide-your-agent","level":3,"title":"Guide Your Agent","text":"

      How commands, skills, and conversational patterns work together. Train your agent to be proactive through ask, guide, reinforce.

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#setup-across-ai-tools","level":3,"title":"Setup across AI Tools","text":"

      Initialize ctx and configure hooks for Claude Code, Cursor, Aider, Copilot, or Windsurf. Includes shell completion, watch mode for non-native tools, and verification.

      Uses: ctx init, ctx setup, ctx agent, ctx completion, ctx watch

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#multilingual-session-parsing","level":3,"title":"Multilingual Session Parsing","text":"

      Parse session journal entries written in other languages. Configure recognized session-header prefixes so the journal pipeline works for Turkish, Japanese, and any other locale.

      Uses: ctx journal source, ctx journal import, session_prefixes in .ctxrc

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#keeping-context-in-a-separate-repo","level":3,"title":"Keeping Context in a Separate Repo","text":"

      Store context files outside the project tree: in a private repo, shared directory, or anywhere else. Useful for open source projects with private context or multi-repo setups.

      Uses: ctx init, CTX_DIR, .ctxrc, /ctx-status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#sessions","level":2,"title":"Sessions","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#the-complete-session","level":3,"title":"The Complete Session","text":"

      Walk through a full ctx session from start to finish:

      • Loading context,
      • Picking what to work on,
      • Committing with context,
      • Capturing, reflecting, and saving a snapshot.

      Uses: ctx status, ctx agent, /ctx-remember, /ctx-next, /ctx-commit, /ctx-reflect

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#session-ceremonies","level":3,"title":"Session Ceremonies","text":"

      The two bookend rituals for every session: /ctx-remember at the start to load and confirm context, /ctx-wrap-up at the end to review the session and persist learnings, decisions, and tasks.

      Uses: /ctx-remember, /ctx-wrap-up, /ctx-commit, ctx agent, ctx add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#browsing-and-enriching-past-sessions","level":3,"title":"Browsing and Enriching Past Sessions","text":"

      Export your AI session history to a browsable journal site. Enrich entries with metadata and search across months of work.

      Uses: ctx journal source/import, ctx journal site, ctx journal obsidian, ctx serve, /ctx-history, /ctx-journal-enrich, /ctx-journal-enrich-all

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#session-reminders","level":3,"title":"Session Reminders","text":"

      Leave a message for your next session. Reminders surface automatically at session start and repeat until dismissed. Date-gate reminders to surface only after a specific date.

      Uses: ctx remind, ctx remind list, ctx remind dismiss, ctx system check-reminders

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#reviewing-session-changes","level":3,"title":"Reviewing Session Changes","text":"

      See what moved since your last session: context file edits, code commits, directories touched. Auto-detects session boundaries from state markers.

      Uses: ctx change, ctx agent, ctx status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#pausing-context-hooks","level":3,"title":"Pausing Context Hooks","text":"

      Silence all nudge hooks for a quick task that doesn't need ceremony overhead. Session-scoped: Other sessions are unaffected. Security hooks still fire.

      Uses: ctx hook pause, ctx hook resume, /ctx-pause, /ctx-resume

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#knowledge-and-tasks","level":2,"title":"Knowledge and Tasks","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#persisting-decisions-learnings-and-conventions","level":3,"title":"Persisting Decisions, Learnings, and Conventions","text":"

      Record architectural decisions with rationale, capture gotchas and lessons learned, and codify conventions so they survive across sessions and team members.

      Uses: ctx decision add, ctx learning add, ctx convention add, ctx decision reindex, ctx learning reindex, /ctx-decision-add, /ctx-learning-add, /ctx-convention-add, /ctx-reflect

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#tracking-work-across-sessions","level":3,"title":"Tracking Work across Sessions","text":"

      Add, prioritize, complete, snapshot, and archive tasks. Keep TASKS.md focused as your project evolves across dozens of sessions.

      Uses: ctx task add, ctx task complete, ctx task archive, ctx task snapshot, /ctx-task-add, /ctx-archive, /ctx-next

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#using-the-scratchpad","level":3,"title":"Using the Scratchpad","text":"

      Use the encrypted scratchpad for quick notes, working memory, and sensitive values during AI sessions. Natural language in, encrypted storage out.

      Uses: ctx pad, /ctx-pad, ctx pad show, ctx pad edit

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#syncing-scratchpad-notes-across-machines","level":3,"title":"Syncing Scratchpad Notes across Machines","text":"

      Distribute your scratchpad encryption key, push and pull encrypted notes via git, and resolve merge conflicts when two machines edit simultaneously.

      Uses: ctx init, ctx pad, ctx pad resolve, scp

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#bridging-claude-code-auto-memory","level":3,"title":"Bridging Claude Code Auto Memory","text":"

      Mirror Claude Code's auto memory (MEMORY.md) into .context/ for version control, portability, and drift detection. Import entries into structured context files with heuristic classification.

      Uses: ctx memory sync, ctx memory status, ctx memory diff, ctx memory import, ctx memory publish, ctx system check-memory-drift

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#hooks-and-notifications","level":2,"title":"Hooks and Notifications","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#hook-output-patterns","level":3,"title":"Hook Output Patterns","text":"

      Choose the right output pattern for your Claude Code hooks: VERBATIM relay for user-facing reminders, hard gates for invariants, agent directives for nudges, and five more patterns across the spectrum.

      Uses: ctx plugin hooks, settings.local.json

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#customizing-hook-messages","level":3,"title":"Customizing Hook Messages","text":"

      Customize what hooks say without changing what they do. Override the QA gate for Python (pytest instead of make lint), silence noisy ceremony nudges, or tailor post-commit instructions for your stack.

      Uses: ctx hook message list, ctx hook message show, ctx hook message edit, ctx hook message reset

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#hook-sequence-diagrams","level":3,"title":"Hook Sequence Diagrams","text":"

      Mermaid sequence diagrams for every system hook: entry conditions, state reads, output, throttling, and exit points. Includes throttling summary table and state file reference.

      Uses: All ctx system hooks

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#auditing-system-hooks","level":3,"title":"Auditing System Hooks","text":"

      The 12 system hooks that run invisibly during every session: what each one does, why it exists, and how to verify they're actually firing. Covers webhook-based audit trails, log inspection, and detecting silent hook failures.

      Uses: ctx system, ctx hook notify, .context/logs/, .ctxrc notify.events

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"

      Get push notifications when loops complete, hooks fire, or agents hit milestones. Webhook URL is encrypted: never stored in plaintext. Works with IFTTT, Slack, Discord, ntfy.sh, or any HTTP endpoint.

      Uses: ctx hook notify setup, ctx hook notify test, ctx hook notify --event, .ctxrc notify.events

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"

      Switch between dev and base runtime configurations without editing .ctxrc by hand. Verbose logging and webhooks for debugging, clean defaults for normal sessions.

      Uses: ctx config switch, ctx config status, /ctx-config

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#maintenance","level":2,"title":"Maintenance","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#detecting-and-fixing-drift","level":3,"title":"Detecting and Fixing Drift","text":"

      Keep context files accurate by detecting structural drift (stale paths, missing files, stale file ages) and task staleness.

      Uses: ctx drift, ctx sync, ctx compact, ctx status, /ctx-drift, /ctx-status, /ctx-prompt-audit

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#state-directory-maintenance","level":3,"title":"State Directory Maintenance","text":"

      Clean up session tombstones from .context/state/. Prune old per-session files, identify stale global markers, and keep the state directory lean.

      Uses: ctx prune

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#troubleshooting","level":3,"title":"Troubleshooting","text":"

      Diagnose hook failures, noisy nudges, stale context, and configuration issues. Start with ctx doctor for a structural health check, then use /ctx-doctor for agent-driven analysis of event patterns.

      Uses: ctx doctor, ctx hook event, /ctx-doctor

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#claude-code-permission-hygiene","level":3,"title":"Claude Code Permission Hygiene","text":"

      Keep .claude/settings.local.json clean: recommended safe defaults, what to never pre-approve, and a maintenance workflow for cleaning up session debris.

      Uses: ctx init, /ctx-drift, /ctx-permission-sanitize, ctx permission snapshot, ctx permission restore

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#permission-snapshots","level":3,"title":"Permission Snapshots","text":"

      Capture a known-good permission baseline as a golden image, then restore at session start to automatically drop session-accumulated permissions.

      Uses: ctx permission snapshot, ctx permission restore, /ctx-permission-sanitize

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#turning-activity-into-content","level":3,"title":"Turning Activity into Content","text":"

      Generate blog posts from project activity, write changelog posts from commit ranges, and publish a browsable journal site from your session history.

      The output is generic Markdown, but the skills are tuned for the ctx-style blog artifacts you see on this website.

      Uses: ctx journal site, ctx journal obsidian, ctx serve, ctx journal import, /ctx-blog, /ctx-blog-changelog, /ctx-journal-enrich

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#importing-claude-code-plans","level":3,"title":"Importing Claude Code Plans","text":"

      Import Claude Code plan files (~/.claude/plans/*.md) into specs/ as permanent project specs. Filter by date, select interactively, and optionally create tasks referencing each imported spec.

      Uses: /ctx-plan-import, /ctx-task-add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#design-before-coding","level":3,"title":"Design Before Coding","text":"

      Front-load design with a four-skill chain: brainstorm the approach, spec the design, task the work, implement step-by-step. Each step produces an artifact that feeds the next.

      Uses: /ctx-brainstorm, /ctx-spec, /ctx-task-add, /ctx-implement, /ctx-decision-add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#scrutinizing-a-plan","level":3,"title":"Scrutinizing a Plan","text":"

      Once a plan exists, run an adversarial interview to surface what's weak, missing, or unexamined before you commit. Walks the plan depth-first: assumptions, failure modes, alternatives, sequencing, reversibility. The complement to brainstorm: brainstorm produces plans, this attacks them.

      Uses: /ctx-plan, /ctx-spec, /ctx-decision-add, /ctx-learning-add

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#agents-and-automation","level":2,"title":"Agents and Automation","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#building-project-skills","level":3,"title":"Building Project Skills","text":"

      Encode repeating workflows into reusable skills the agent loads automatically. Covers the full cycle: identify a pattern, create the skill, test with realistic prompts, and iterate until it triggers correctly.

      Uses: /ctx-skill-create, ctx init

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#running-an-unattended-ai-agent","level":3,"title":"Running an Unattended AI Agent","text":"

      Set up a loop where an AI agent works through tasks overnight without you at the keyboard, using ctx for persistent memory between iterations.

      This recipe shows how ctx supports long-running agent loops without losing context or intent.

      Uses: ctx init, ctx loop, ctx watch, ctx load, /ctx-loop, /ctx-implement

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#when-to-use-a-team-of-agents","level":3,"title":"When to Use a Team of Agents","text":"

      Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.

      This recipe covers the file overlap test, when teams make things worse, and what ctx provides at each level.

      Uses: /ctx-worktree, /ctx-next, ctx status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#parallel-agent-development-with-git-worktrees","level":3,"title":"Parallel Agent Development with Git Worktrees","text":"

      Split a large backlog across 3-4 agents using git worktrees, each on its own branch and working directory. Group tasks by file overlap, work in parallel, merge back.

      Uses: /ctx-worktree, /ctx-next, git worktree, git merge

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#architecture-deep-dive","level":3,"title":"Architecture Deep Dive","text":"

      Three-pass pipeline for understanding a codebase: map what exists, enrich with code intelligence, then hunt for where it will silently fail. Produces architecture docs, quantified dependency data, and ranked failure hypotheses.

      Uses: /ctx-architecture, /ctx-architecture-enrich, /ctx-architecture-failure-analysis

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#writing-steering-files","level":3,"title":"Writing Steering Files","text":"

      Tell your AI assistant how to behave with rule-based prompt injection that fires automatically when prompts match a description. Walks through scaffolding a steering file, previewing matches, and syncing to each AI tool's native format.

      Uses: ctx steering add, ctx steering preview, ctx steering list, ctx steering sync

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#authoring-lifecycle-triggers","level":3,"title":"Authoring Lifecycle Triggers","text":"

      Run executable shell scripts at session-start, pre-tool-use, file-save, and other lifecycle events. Script-based automation (complementary to steering's rule-based prompts), with a security-first workflow: scaffold disabled, test with mock input, enable only after review.

      Uses: ctx trigger add, ctx trigger test, ctx trigger enable, ctx trigger disable, ctx trigger list

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#hub","level":2,"title":"Hub","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#hub-overview","level":3,"title":"Hub Overview","text":"

      Mental model and three user stories for the ctx Hub. What flows, what doesn't, and when not to use it. Read this before any of the other Hub recipes.

      Uses: ctx hub, ctx connection, ctx add --share

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-getting-started","level":3,"title":"ctx Hub: Getting Started","text":"

      Stand up a single-node hub on localhost, register two projects, publish a decision from one, and watch it appear in the other. End-to-end in under five minutes.

      Uses: ctx hub start, ctx connection register, ctx connection subscribe, ctx connection sync, ctx connection listen, ctx add --share, ctx agent --include-hub

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"

      Story 1 day-to-day workflow: one developer, many projects, one hub on localhost. Records a learning in project A, watches it show up automatically in project B. Walks through a realistic day of using the hub as passive infrastructure (no manual sync, no git push, no ceremony).

      Uses: ctx add --share, ctx connection subscribe, ctx agent --include-hub

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#team-knowledge-bus","level":3,"title":"Team Knowledge Bus","text":"

      Story 2 day-to-day workflow: a small trusted team sharing decisions, learnings, and conventions via a hub on an internal server. Covers the team publishing culture, what belongs on the hub vs. local, token management, and the social rules that make a shared knowledge stream stay signal-rich.

      Uses: ctx add --share, ctx connection status, ctx connection subscribe, ctx hub status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-multi-machine","level":3,"title":"ctx Hub: Multi-Machine","text":"

      Run the hub on a LAN host as a daemon and connect from project directories on other workstations. Firewall guidance, TLS via a reverse proxy, and safe daemon restart semantics.

      Uses: ctx hub start --daemon, ctx hub stop, ctx connection register, ctx connection status

      ","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-ha-cluster","level":3,"title":"ctx Hub: HA Cluster","text":"

      Raft-based leader election across three or more nodes for redundancy. Covers bootstrap, runtime peer management, graceful stepdown, and the Raft-lite durability caveat.

      Uses: ctx hub start --peers, ctx hub status, ctx hub peer add/remove, ctx hub stepdown

      ","path":["Recipes"],"tags":[]},{"location":"recipes/activating-context/","level":1,"title":"Activating a Context Directory","text":"","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#the-problem","level":2,"title":"The Problem","text":"

      You ran a ctx command and got:

      Error: no context directory specified for this project\n

      This means ctx doesn't know which .context/ directory to operate on. It will not guess, and it will not walk up from your current working directory looking for one; that behavior was removed deliberately, because silent inference was the source of several bugs (stray agent-created directories, cross-project bleed-through, webhook-route misrouting, sub-agent fragmentation). Every ctx command requires you to declare the target directory explicitly.

      This page shows you the three ways to do that and when to use each.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#tldr","level":2,"title":"TL;DR","text":"

      If the project has already been initialized and you just need to bind it for your shell:

      eval \"$(ctx activate)\"\n

      That's 95% of the time. Add it to .zshrc / .bashrc per project with direnv, or run it once per terminal.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#when-you-see-the-error","level":2,"title":"When You See the Error","text":"

      The exact error message depends on how many .context/ directories are visible from the current directory:

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#zero-candidates","level":3,"title":"Zero Candidates","text":"
      Error: no context directory specified for this project\n

      Either you haven't initialized this project yet (run ctx init) or you're in a directory that doesn't belong to a ctx-tracked project. If you know the project lives elsewhere, use one of the declaration methods below with its absolute path.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#one-candidate","level":3,"title":"One Candidate","text":"
      Error: no context directory specified; a likely candidate is at\n    /Users/you/repos/myproject/.context\n

      ctx found a single .context/ on the way up from here but won't bind to it automatically. Run eval \"$(ctx activate)\" and ctx will emit the export for the candidate. Or set CTX_DIR by hand.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#multiple-candidates","level":3,"title":"Multiple Candidates","text":"
      Error: no context directory specified; multiple candidates visible:\n  /Users/you/repos/myproject/.context\n  /Users/you/repos/myproject/packages/web/.context\n

      You're inside nested projects. Pick the one you mean:

      ctx activate /Users/you/repos/myproject/.context\n# …copy and paste the `export` line it prints, or wrap in eval:\neval \"$(ctx activate /Users/you/repos/myproject/.context)\"\n
      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#three-ways-to-declare","level":2,"title":"Three Ways to Declare","text":"","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#1-ctx-activate-recommended-for-shells","level":3,"title":"1. ctx activate (Recommended for Shells)","text":"

      ctx activate emits a shell-native export CTX_DIR=... line to stdout. Wrap it in eval and the binding takes effect for the current shell:

      # Walk up from current dir and bind the single visible candidate:\neval \"$(ctx activate)\"\n\n# Bind a specific path explicitly:\neval \"$(ctx activate /abs/path/to/.context)\"\n\n# Clear the binding:\neval \"$(ctx deactivate)\"\n

      ctx activate validates paths strictly: the target must exist, be a directory, and contain at least one canonical context file (CONSTITUTION.md or TASKS.md). It refuses to emit for multiple upward candidates; pick one explicitly in that case.

      Under the hood, the emitted line is just:

      export CTX_DIR='/abs/path/to/.context'\n

      So you can copy it into your .zshrc / .bashrc if you want the binding permanent for a given shell setup. Better: use direnv with a per-project .envrc.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#2-ctx_dir-env-var","level":3,"title":"2. CTX_DIR Env Var","text":"

      If you already know the path, export it directly:

      export CTX_DIR=/abs/path/to/.context\nctx status\n

      CTX_DIR is the same variable ctx activate writes; activate is just a convenience that figures out the path for you.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#3-inline-one-shot","level":3,"title":"3. Inline One-Shot","text":"

      For one-shot commands (CI jobs, scripts, debugging a specific project without changing your shell state), prefix the binding inline:

      CTX_DIR=/abs/path/to/.context ctx status\n

      This binds CTX_DIR for that invocation only.

      CTX_DIR must be an absolute path with .context as its basename. Relative paths and other names are rejected on first use; the basename guard catches the common footgun (export CTX_DIR=$(pwd)) before stray writes can leak to the project root.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#for-ci-and-scripts","level":2,"title":"For CI and Scripts","text":"

      Do not rely on shell activation in automated flows. Set CTX_DIR explicitly at the top of the script:

      #!/usr/bin/env bash\nset -euo pipefail\n\nexport CTX_DIR=\"$GITHUB_WORKSPACE/.context\"\nctx status\nctx drift\n
      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#for-claude-code-users","level":2,"title":"For Claude Code Users","text":"

      The ctx plugin's hooks are generated with CTX_DIR=\"$CLAUDE_PROJECT_DIR/.context\" prefixed to each command, so hook-driven ctx invocations resolve correctly without any per-session setup. You only need to activate manually when running ctx yourself in a terminal.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#one-project-one-context","level":2,"title":"One Project, One .context/","text":"

      The context directory is not a free-floating bag of files. It is pinned to a project by contract: filepath.Dir(ContextDir()) is the project root. That parent directory is what ctx sync, ctx drift, and the memory-drift hook scan for code, secret files, and MEMORY.md respectively.

      The practical consequences:

      • Don't share one .context/ across multiple projects. It holds per-project journals, per-session state, and per-project secrets. Pointing two codebases at the same directory corrupts all three.
      • If you want to share knowledge (CONSTITUTION, CONVENTIONS, ARCHITECTURE) across projects, use ctx hub. It cherry-picks entries at the right granularity and keeps the per-project bits where they belong.
      • The CTX_DIR you activate is implicitly a project-root declaration. Setting CTX_DIR=/weird/place/.context means you're telling ctx the project root is /weird/place/. That's your call to make; ctx does not police it.
      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#recommended-layout","level":3,"title":"Recommended Layout","text":"
      ~/WORKSPACE/my-to-do-list\n  ├── .git\n  ├── .context          ← owned by this project; do not share\n  ├── ideas\n  │   └── ...\n  ├── Makefile\n  ├── Makefile.ctx\n  └── specs\n      └── ...\n

      .context/ sits at the project root, next to .git. ctx activate binds to it; every ctx subsystem reads the project from its parent.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/activating-context/#why-not-walk-up-automatically","level":2,"title":"Why Not Walk Up Automatically?","text":"

      Nested projects, submodules, rogue agent-created .context/ directories, and sub-agent sessions all produced silent misrouting under the old walk-up model. See the explicit-context-dir spec and the analysis doc for the full reasoning.

      The short version: ctx decided to stop guessing and require the caller to declare. Every other decision flows from there.

      ","path":["Recipes","Getting Started","Activating a Context Directory"],"tags":[]},{"location":"recipes/architecture-deep-dive/","level":1,"title":"Architecture Deep Dive","text":"","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-problem","level":2,"title":"The Problem","text":"

      Understanding a codebase at the surface level is easy. Understanding where it will break under real-world conditions takes three passes: mapping what exists, quantifying how it connects, and hunting for where it silently fails. Most teams stop at the first pass.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tldr","level":2,"title":"TL;DR","text":"
      # Pass 1: Map the system\n/ctx-architecture\n\n# Pass 2: Enrich with code intelligence\n/ctx-architecture-enrich\n\n# Pass 3: Hunt for failure modes\n/ctx-architecture-failure-analysis\n

      Each pass builds on the previous one. Run them in order. The output accumulates in .context/; each pass reads the prior artifacts and extends them.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-architecture Skill Map modules, dependencies, data flow, patterns /ctx-architecture-enrich Skill Verify blast radius and flows with code intel /ctx-architecture-failure-analysis Skill Generate falsifiable incident hypotheses ctx drift CLI Detect stale paths and broken references ctx status CLI Quick structural overview","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-1-map-what-exists","level":3,"title":"Pass 1: Map What Exists","text":"
      /ctx-architecture\n

      Produces:

      • ARCHITECTURE.md: succinct project map (< 4000 tokens), loaded at every session start
      • DETAILED_DESIGN*.md: deep per-module reference with exported API, data flow, danger zones, extension points
      • CHEAT-SHEETS.md: lifecycle flow diagrams
      • map-tracking.json: coverage state with confidence scores

      This pass forces deep code reading. No shortcuts, no code intelligence tools; the agent reads every module it analyzes. That forced reading is what makes the subsequent passes useful.

      When to run: First time on a codebase, or after significant structural changes (new packages, moved files, changed dependencies).

      Principal mode: Add principal to get strategic analysis (ARCHITECTURE-PRINCIPAL.md, DANGER-ZONES.md from P4):

      /ctx-architecture principal\n
      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-2-enrich-with-code-intelligence","level":3,"title":"Pass 2: Enrich with Code Intelligence","text":"
      /ctx-architecture-enrich\n

      Takes the Pass 1 artifacts as baseline and layers on verified, graph-backed data from GitNexus:

      • Blast radius numbers for key functions
      • Execution flow traces through hot paths
      • Domain clustering validation
      • Registration site discovery

      This pass does not replace reading; it quantifies what reading found. If Pass 1 says \"module X depends on module Y,\" Pass 2 says \"module X has 47 callers in module Y, and changing function Z would affect 12 downstream consumers.\"

      When to run: After Pass 1, when you need quantified confidence for refactoring decisions or risk assessment.

      Requires: GitNexus MCP server connected.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-3-hunt-for-failure-modes","level":3,"title":"Pass 3: Hunt for Failure Modes","text":"
      /ctx-architecture-failure-analysis\n

      The adversarial pass. Reads all prior artifacts, then systematically hunts for correctness bugs across 9 failure categories:

      1. Concurrency (races, deadlocks, goroutine leaks)
      2. Ordering assumptions (init, registration, shutdown)
      3. Cache staleness (TTL-less, read-your-writes, cross-process)
      4. Fan-out amplification (N+1, retry storms)
      5. Ownership and lifecycle (orphans, double-close)
      6. Error handling (silent swallowing, partial failure)
      7. Scaling cliffs (quadratic, unbounded, global locks)
      8. Idempotency failures (duplicate processing, retry mutations)
      9. State machine drift (illegal states, unvalidated transitions)

      Every finding must meet an evidence standard: code path, trigger, failure path, silence reason, and code evidence. A mandatory challenge phase attempts to disprove each finding before it is accepted. Findings carry a confidence level (High/Medium/Low) and explicit risk score.

      Produces DANGER-ZONES.md, a ranked inventory of findings split into Critical and Elevated tiers.

      When to run: Before releases, after major refactors, when investigating incident categories, or when onboarding.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#what-you-get","level":2,"title":"What You Get","text":"

      After all three passes, .context/ contains:

      File From Purpose ARCHITECTURE.md Pass 1 System map (session-start context) DETAILED_DESIGN*.md Pass 1 Module-level deep reference CHEAT-SHEETS.md Pass 1 Lifecycle flow diagrams map-tracking.json Pass 1 Coverage and confidence data CONVERGENCE-REPORT.md Pass 1 What's covered, what's not DANGER-ZONES.md Pass 3 Ranked failure hypotheses

      Pass 2 enriches Pass 1 artifacts in-place rather than creating new files.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tips","level":2,"title":"Tips","text":"
      • Run Pass 1 with focus areas if the codebase is large. The skill asks what to go deep on, so name the modules you're about to change.
      • You don't need all three passes every time. Pass 1 is the foundation. Pass 2 and 3 are for when you need quantified confidence or adversarial rigor.
      • Re-run Pass 1 incrementally. It tracks coverage in map-tracking.json and only re-analyzes stale modules.
      • Pass 3 is most valuable before releases. The ranked DANGER-ZONES.md is a pre-release checklist.
      • The trilogy maps to a question progression: How does it work? How well does it connect? Where will it break?
      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#see-also","level":2,"title":"See Also","text":"

      See also: Detecting and Fixing Context Drift to keep architecture artifacts fresh between deep-dive sessions.

      See also: Detecting and Fixing Context Drift for structural checks that complement architecture analysis.

      ","path":["Architecture Deep Dive"],"tags":[]},{"location":"recipes/autonomous-loops/","level":1,"title":"Running an Unattended AI Agent","text":"","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-problem","level":2,"title":"The Problem","text":"

      You have a project with a clear list of tasks, and you want an AI agent to work through them autonomously: overnight, unattended, without you sitting at the keyboard.

      Each iteration needs to remember what the previous one did, mark tasks as completed, and know when to stop.

      Without persistent memory, every iteration starts fresh and the loop collapses. With ctx, each iteration can pick up where the last one left off, but only if the agent persists its context as part of the work.

      Unattended operation works because the agent treats context persistence as a first-class deliverable, not an afterthought.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tldr","level":2,"title":"TL;DR","text":"
      ctx init                                    # 1. init context\neval \"$(ctx activate)\"                      # 2. bind CTX_DIR for this shell\n# Edit TASKS.md with phased work items\nctx loop --tool claude --max-iterations 10  # 3. generate loop.sh\n./loop.sh 2>&1 | tee /tmp/loop.log &        # 4. run the loop\nctx watch --log /tmp/loop.log               # 5. process context updates\n# Next morning:\nctx status && ctx load                      # 6. review the results\n

      Activate, or Set CTX_DIR Inline for Unattended Runs

      eval \"$(ctx activate)\" is fine for an interactive terminal. For an overnight unattended loop, put the binding at the top of loop.sh instead (export CTX_DIR=/abs/path/.context) so the loop doesn't depend on a live shell. If you skip both, ctx loop, ctx watch, ctx status, and ctx load fail with Error: no context directory specified. See Activating a Context Directory.

      Read on for permissions, isolation, and completion signals.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx init Command Initialize project context and prompt templates ctx loop Command Generate the loop shell script ctx watch Command Monitor AI output and persist context updates ctx load Command Display assembled context (for debugging) /ctx-loop Skill Generate loop script from inside Claude Code /ctx-implement Skill Execute a plan step-by-step with verification","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-1-initialize-for-unattended-operation","level":3,"title":"Step 1: Initialize for Unattended Operation","text":"

      Start by creating a .context/ directory configured so the agent can work without human input.

      ctx init\n

      This creates .context/ with the template files (including a loop prompt at .context/loop.md), and seeds Claude Code permissions in .claude/settings.local.json. Install the ctx plugin for hooks and skills.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-2-populate-tasksmd-with-phased-work","level":3,"title":"Step 2: Populate TASKS.md with Phased Work","text":"

      Open .context/TASKS.md and organize your work into phases. The agent works through these systematically, top to bottom, using priority tags to break ties.

      # Tasks\n\n## Phase 1: Foundation\n\n- [ ] Set up project structure and build system `#priority:high`\n- [ ] Configure testing framework `#priority:high`\n- [ ] Create CI pipeline `#priority:medium`\n\n## Phase 2: Core Features\n\n- [ ] Implement user registration `#priority:high`\n- [ ] Add email verification `#priority:high`\n- [ ] Create password reset flow `#priority:medium`\n\n## Phase 3: Hardening\n\n- [ ] Add rate limiting to API endpoints `#priority:medium`\n- [ ] Improve error messages `#priority:low`\n- [ ] Write integration tests `#priority:medium`\n

      Phased organization matters because it gives the agent natural boundaries. Phase 1 tasks should be completable without Phase 2 code existing yet.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-3-configure-the-loop-prompt","level":3,"title":"Step 3: Configure the Loop Prompt","text":"

      The loop prompt at .context/loop.md instructs the agent to operate autonomously:

      1. Read .context/CONSTITUTION.md first (hard rules, never violated)
      2. Load context from .context/ files
      3. Pick one task per iteration
      4. Complete the task and update context files
      5. Commit changes (including .context/)
      6. Signal status with a completion signal

      You can customize .context/loop.md for your project. The critical parts are the one-task-per-iteration discipline, proactive context persistence, and completion signals at the end:

      ## Signal Status\n\nEnd your response with exactly ONE of:\n\n* `SYSTEM_CONVERGED`: All tasks in `TASKS.md` are complete (*this is the\n  signal the loop script detects by default*)\n* `SYSTEM_BLOCKED`: Cannot proceed, need human input (explain why)\n* (*no signal*): More work remains, continue to the next iteration\n\nNote: the loop script only checks for `SYSTEM_CONVERGED` by default.\n`SYSTEM_BLOCKED` is a convention for the human reviewing the log.\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-4-configure-permissions","level":3,"title":"Step 4: Configure Permissions","text":"

      An unattended agent needs permission to use tools without prompting. By default, Claude Code asks for confirmation on file writes, bash commands, and other operations, which stops the loop and waits for a human who is not there.

      There are two approaches.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#option-a-explicit-allowlist-recommended","level":4,"title":"Option A: Explicit Allowlist (Recommended)","text":"

      Grant only the permissions the agent needs. In .claude/settings.local.json:

      {\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(make:*)\",\n      \"Bash(go:*)\",\n      \"Bash(git:*)\",\n      \"Bash(ctx:*)\",\n      \"Read\",\n      \"Write\",\n      \"Edit\"\n    ]\n  }\n}\n

      Adjust the Bash patterns for your project's toolchain. The agent can run make, go, git, and ctx commands but cannot run arbitrary shell commands.

      This is recommended even in sandboxed environments because it limits blast radius.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#option-b-skip-all-permission-checks","level":4,"title":"Option B: Skip All Permission Checks","text":"

      Claude Code supports a --dangerously-skip-permissions flag that disables all permission prompts:

      claude --dangerously-skip-permissions -p \"$(cat .context/loop.md)\"\n

      This Flag Means What It Says

      With --dangerously-skip-permissions, the agent can execute any shell command, write to any file, and make network requests without confirmation.

      Only use this on a sandboxed machine: ideally a virtual machine with no access to host credentials, no SSH keys, and no access to production systems.

      If you would not give an untrusted intern sudo on this machine, do not use this flag.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#enforce-isolation-at-the-os-level","level":4,"title":"Enforce Isolation at the OS Level","text":"

      The only controls an agent cannot override are the ones enforced by the operating system, the container runtime, or the hypervisor.

      Do Not Skip This Section

      This is not optional hardening:

      An unattended agent with unrestricted OS access is an unattended shell with unrestricted OS access.

      The allowlist above is a strong first layer, but do not rely on a single runtime boundary.

      For unattended runs, enforce isolation at the infrastructure level:

      Layer What to enforce User account Run the agent as a dedicated unprivileged user with no sudo access and no membership in privileged groups (docker, wheel, adm). Filesystem Restrict the project directory via POSIX permissions or ACLs. The agent should have no access to other users' files or system directories. Container Run inside a Docker/Podman sandbox. Mount only the project directory. Drop capabilities (--cap-drop=ALL). Disable network if not needed (--network=none). Never mount the Docker socket and do not run privileged containers. Prefer rootless containers. Virtual machine Prefer a dedicated VM with no shared folders, no host passthrough, and no keys to other machines. Network If the agent does not need the internet, disable outbound access entirely. If it does, restrict to specific domains via firewall rules. Resource limits Apply CPU, memory, and disk limits (cgroups/container limits). A runaway loop should not fill disk or consume all RAM. Self-modification Make instruction files read-only. CLAUDE.md, .claude/settings.local.json, and .context/CONSTITUTION.md should not be writable by the agent user. If using project-local hooks, protect those too.

      A minimal Docker setup for overnight runs:

      docker run --rm \\\n  --network=none \\\n  --cap-drop=ALL \\\n  --memory=4g \\\n  --cpus=2 \\\n  -v /path/to/project:/workspace \\\n  -w /workspace \\\n  your-dev-image \\\n  ./loop.sh 2>&1 | tee /tmp/loop.log\n

      Defense in Depth

      Use multiple layers together: OS-level isolation (the boundary the agent cannot cross), a permission allowlist (what Claude Code will do within that boundary), and CONSTITUTION.md (a soft nudge for the common case).

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-5-generate-the-loop-script","level":3,"title":"Step 5: Generate the Loop Script","text":"

      Use ctx loop to generate a loop.sh tailored to your AI tool:

      # Generate for Claude Code with a 10-iteration cap\nctx loop --tool claude --max-iterations 10\n\n# Generate for Aider\nctx loop --tool aider --max-iterations 10\n\n# Custom prompt file and output filename\nctx loop --tool claude --prompt my-prompt.md --output my-loop.sh\n

      The generated script reads .context/loop.md, runs the tool, checks for completion signals, and loops until done or the cap is reached.

      You can also use the /ctx-loop skill from inside Claude Code.

      A Shell Loop Is the Best Practice

      The shell loop approach spawns a fresh AI process each iteration, so the only state that carries between iterations is what lives in .context/ and git.

      Claude Code's built-in /loop runs iterations within the same session, which can allow context window state to leak between iterations. This can be convenient for short runs, but it is less reliable for unattended loops.

      See Shell Loop vs Built-in Loop for details.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-6-run-with-watch-mode","level":3,"title":"Step 6: Run with Watch Mode","text":"

      Open two terminals. In the first, run the loop. In the second, run ctx watch to process context updates from the AI output.

      # Terminal 1: Run the loop\n./loop.sh 2>&1 | tee /tmp/loop.log\n\n# Terminal 2: Watch for context updates\nctx watch --log /tmp/loop.log\n

      The watch command parses XML context-update commands from the AI output and applies them:

      <context-update type=\"complete\">user registration</context-update>\n<context-update type=\"learning\"\n  context=\"Setting up user registration\"\n  lesson=\"Email verification needs SMTP configured\"\n  application=\"Add SMTP setup to deployment checklist\"\n>SMTP Requirement</context-update>\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-7-completion-signals-end-the-loop","level":3,"title":"Step 7: Completion Signals End the Loop","text":"

      The generated script checks for one completion signal per run. By default this is SYSTEM_CONVERGED. You can change it with the --completion flag:

      ctx loop --tool claude --completion BOOTSTRAP_COMPLETE --max-iterations 5\n

      The following signals are conventions used in .context/loop.md:

      Signal Convention How the script handles it SYSTEM_CONVERGED All tasks in TASKS.md are done Detected by default (--completion default value) SYSTEM_BLOCKED Agent cannot proceed Only detected if you set --completion to this BOOTSTRAP_COMPLETE Initial scaffolding done Only detected if you set --completion to this

      The script uses grep -q on the agent's output, so any string works as a signal. If you need to detect multiple signals in one run, edit the generated loop.sh to add additional grep checks.

      When you return in the morning, check the log and the context files:

      tail -100 /tmp/loop.log\nctx status\nctx load\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#step-8-use-ctx-implement-for-plan-execution","level":3,"title":"Step 8: Use /ctx-implement for Plan Execution","text":"

      Within each iteration, the agent can use /ctx-implement to execute multi-step plans with verification between steps. This is useful for complex tasks that touch multiple files.

      The skill breaks a plan into atomic, verifiable steps:

      Step 1/6: Create user model .................. OK\nStep 2/6: Add database migration ............. OK\nStep 3/6: Implement registration handler ..... OK\nStep 4/6: Write unit tests ................... OK\nStep 5/6: Run test suite ..................... FAIL\n  -> Fixed: missing test dependency\n  -> Re-verify ............................... OK\nStep 6/6: Update TASKS.md .................... OK\n

      Each step is verified (build, test, syntax check) before moving to the next.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      A typical overnight run:

      ctx init\n# Edit TASKS.md and .context/loop.md\n\nctx loop --tool claude --max-iterations 20\n\n./loop.sh 2>&1 | tee /tmp/loop.log &\nctx watch --log /tmp/loop.log\n\n# Next morning:\nctx status\nctx load\n
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#why-autonomous-loops-work-proactive-context-persistence","level":2,"title":"Why Autonomous Loops Work: Proactive Context Persistence","text":"

      The autonomous loop pattern works because the agent persists context as part of the job.

      Without proactive persistence, the loop degrades into disconnected iterations that repeat work, contradict decisions, and lose track of progress. The agent cannot rely on a human to prompt it. It must treat context updates as part of every task, not as a separate step.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-agent-playbook-self-check-drives-autonomy","level":3,"title":"The Agent Playbook Self-Check Drives Autonomy","text":"

      The Agent Playbook defines a self-check prompt the agent applies continuously:

      \"If this session ended right now, would the next session know what happened?\"\n

      In interactive sessions, a human might remind the agent to save context. When the agent runs unattended, nobody is there to remind it.

      The self-check becomes the trigger: after meaningful work, the agent evaluates whether the context files reflect reality and updates them immediately if they do not.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#what-the-agent-does-proactively-between-iterations","level":3,"title":"What the Agent Does Proactively between Iterations","text":"

      At milestones within an iteration, the agent persists without waiting for instructions:

      Milestone What the agent does proactively Completes a task Marks it [x] in TASKS.md Discovers a gotcha Adds it to LEARNINGS.md Makes a design choice Records it in DECISIONS.md with rationale Identifies follow-up work Creates new tasks in TASKS.md with #added timestamp Hits an unexpected failure Documents the root cause before moving on","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#example-what-proactive-persistence-looks-like","level":3,"title":"Example: What Proactive Persistence Looks Like","text":"

      Here is what the agent does during a single iteration beyond writing code:

      Iteration 4:\n  1. Read TASKS.md -> pick \"Add email verification\" (#priority:high)\n  2. Add #started:2026-01-25-030012 to the task\n  3. Implement the feature (code, tests, docs if needed)\n  4. Tests pass -> mark task [x]\n  5. Add learning: \"SMTP config must be set before verification handler registers. Order matters in init().\"\n  6. Add decision: \"Use token-based verification links (not codes) because links work better in automated tests.\"\n  7. Create follow-up task: \"Add rate limiting to verification endpoint\" #added:...\n  8. Commit all changes including `.context/`\n  9. No signal emitted -> loop continues to iteration 5\n

      Steps 2, 4, 5, 6, and 7 are proactive context persistence:

      The agent was not asked to do any of them.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#context-persistence-at-milestones","level":3,"title":"Context Persistence at Milestones","text":"

      For long autonomous runs, the agent persists context at natural boundaries, often at phase transitions or after completing a cluster of related tasks. It updates TASKS.md, DECISIONS.md, and LEARNINGS.md as it goes.

      If the loop crashes at 4 AM, the context files tell you exactly where to resume. You can also use ctx journal source to review the session transcripts.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#the-persistence-contract","level":3,"title":"The Persistence Contract","text":"

      The autonomous loop has an implicit contract:

      1. Every iteration reads context: TASKS.md, DECISIONS.md, LEARNINGS.md
      2. Every iteration writes context: task updates, new learnings, decisions
      3. Every commit includes .context/ so the next iteration sees changes
      4. Context stays current: if the loop stopped right now, nothing important is lost

      Break any part of this contract and the loop degrades.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tips","level":2,"title":"Tips","text":"

      Markdown Is Not Enforcement

      Your real guardrails are permissions and isolation, not Markdown. CONSTITUTION.md can nudge the agent, but it is probabilistic.

      The permission allowlist and OS isolation are deterministic:

      For unattended runs, trust the sandbox and the allowlist, not the prose.

      • Start with a small iteration cap. Use --max-iterations 5 on your first run.
      • Keep tasks atomic. Each task should be completable in a single iteration.
      • Check signal discipline. If the loop runs forever, the agent is not emitting SYSTEM_CONVERGED or SYSTEM_BLOCKED. Make the signal requirement explicit in .context/loop.md.
      • Commit after context updates. Finish code, update .context/, commit including .context/, then signal.
      • Set up webhook notifications to get notified when the loop completes, hits max iterations, or when hooks fire nudges. The generated loop script includes ctx hook notify calls automatically.
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#next-up","level":2,"title":"Next Up","text":"

      When to Use a Team of Agents →: Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.

      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#see-also","level":2,"title":"See Also","text":"
      • Autonomous Loops: loop pattern, prompt templates, troubleshooting
      • CLI Reference: ctx loop: flags and options
      • CLI Reference: ctx watch: watch mode details
      • CLI Reference: ctx init: init flags
      • The Complete Session: interactive workflow
      • Tracking Work Across Sessions: structuring TASKS.md
      ","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/building-skills/","level":1,"title":"Building Project Skills","text":"","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#the-problem","level":2,"title":"The Problem","text":"

      You have workflows your agent needs to repeat across sessions: a deploy checklist, a review protocol, a release process. Each time, you re-explain the steps. The agent gets it mostly right but forgets edge cases you corrected last time.

      Skills solve this by encoding domain knowledge into a reusable document the agent loads automatically when triggered. A skill is not code - it is a structured prompt that captures what took you sessions to learn.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-skill-create\n

      The skill-creator walks you through: identify a repeating workflow, draft a skill, test with realistic prompts, iterate until it triggers correctly and produces good output.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-skill-create Skill Interactive skill creation and improvement workflow ctx init Command Deploys template skills to .claude/skills/ on first setup","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-1-identify-a-repeating-pattern","level":3,"title":"Step 1: Identify a Repeating Pattern","text":"

      Good skill candidates:

      • Checklists you repeat: deploy steps, release prep, code review
      • Decisions the agent gets wrong: if you keep correcting the same behavior, encode the correction
      • Multi-step workflows: anything with a sequence of commands and conditional branches
      • Domain knowledge: project-specific terminology, architecture constraints, or conventions the agent cannot infer from code alone

      Not good candidates: one-off instructions, things the platform already handles (file editing, git operations), or tasks too narrow to reuse.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-2-create-the-skill","level":3,"title":"Step 2: Create the Skill","text":"

      Invoke the skill-creator:

      You: \"I want a skill for our deploy process\"\n\nAgent: [Asks about the workflow: what steps, what tools,\n        what edge cases, what the output should look like]\n

      Or capture a workflow you just did:

      You: \"Turn what we just did into a skill\"\n\nAgent: [Extracts the steps from conversation history,\n        confirms understanding, drafts the skill]\n

      The skill-creator produces a SKILL.md file in .claude/skills/your-skill/.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-3-test-with-realistic-prompts","level":3,"title":"Step 3: Test with Realistic Prompts","text":"

      The skill-creator proposes 2-3 test prompts - the kind of thing a real user would say. It runs each one and shows the result alongside a baseline (same prompt without the skill) so you can compare.

      Agent: \"Here are test prompts I'd try:\n        1. 'Deploy to staging'\n        2. 'Ship the hotfix'\n        3. 'Run the release checklist'\n        Want to adjust these?\"\n
      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-4-iterate-on-the-description","level":3,"title":"Step 4: Iterate on the Description","text":"

      The description field in frontmatter determines when a skill triggers. Claude tends to undertrigger - descriptions need to be specific and slightly \"pushy\":

      # Weak - too vague, will undertrigger\ndescription: \"Use for deployments\"\n\n# Strong - covers situations and synonyms\ndescription: >-\n  Use when deploying to staging or production, running the release\n  checklist, or when the user says 'ship it', 'deploy this', or\n  'push to prod'. Also use after merging to main when a deploy\n  is expected.\n

      The skill-creator helps you tune this iteratively.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#step-5-deploy-as-template-optional","level":3,"title":"Step 5: Deploy as Template (Optional)","text":"

      If the skill should be available to all projects (not just this one), place it in internal/assets/claude/skills/ so ctx init deploys it to new projects automatically.

      Most project-specific skills stay in .claude/skills/ and travel with the repo.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#skill-anatomy","level":2,"title":"Skill Anatomy","text":"
      my-skill/\n  SKILL.md         # Required: frontmatter + instructions (<500 lines)\n  scripts/         # Optional: deterministic code the skill can execute\n  references/      # Optional: detail loaded on demand (not always)\n  assets/          # Optional: output templates, not loaded into context\n

      Key sections in SKILL.md:

      Section Purpose Required? Frontmatter Name, description (trigger) Yes When to Use Positive triggers Yes When NOT to Use Prevents false activations Yes Process Steps and commands Yes Examples Good/bad output pairs Recommended Quality Checklist Verify before reporting completion For complex skills","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#tips","level":2,"title":"Tips","text":"
      • Description is everything. A great skill with a vague description never fires. Spend time on trigger coverage - synonyms, concrete situations, edge cases.
      • Stay under 500 lines. If your skill is growing past this, move detail into references/ files and point to them from SKILL.md.
      • Do not duplicate the platform. If the agent already knows how to do something (edit files, run git commands), do not restate it. Tag paragraphs as Expert/Activation/Redundant and delete Redundant ones.
      • Explain why, not just what. \"Sort by date because users want recent results first\" beats \"ALWAYS sort by date.\" The agent generalizes from reasoning better than from rigid rules.
      • Test negative triggers. Make sure the skill does not fire on unrelated prompts. A skill that activates too broadly becomes noise.
      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#next-up","level":2,"title":"Next Up","text":"

      Parallel Agent Development with Git Worktrees ->: Split work across multiple agents using git worktrees.

      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#see-also","level":2,"title":"See Also","text":"
      • Skills Reference: full listing of all bundled and project-local skills
      • Guide Your Agent: how commands, skills, and conversational patterns work together
      • Design Before Coding: the four-skill chain for front-loading design work
      ","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/claude-code-permissions/","level":1,"title":"Claude Code Permission Hygiene","text":"","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code's .claude/settings.local.json controls what the agent can do without asking. Over time, this file accumulates one-off permissions from individual sessions: Exact commands with hardcoded paths, duplicate entries, and stale skill references.

      A noisy \"allowlist\" makes it harder to spot dangerous permissions and increases the surface area for unintended behavior.

      Since settings.local.json is .gitignored, it drifts independently of your codebase. There is no PR review, no CI check: just whatever you clicked \"Allow\" on.

      This recipe shows what a well-maintained permission file looks like and how to keep it clean.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#tldr","level":2,"title":"TL;DR","text":"
      ctx init                            # seeds safe defaults\n/ctx-drift                          # detects missing/stale permissions\n/ctx-permission-sanitize               # audits for dangerous patterns\n

      See Recommended Defaults for the full list.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Command/Skill Role in this workflow ctx init Populates default ctx permissions /ctx-drift Detects missing or stale permission entries /ctx-permission-sanitize Audits for dangerous patterns (security-focused)","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#recommended-defaults","level":2,"title":"Recommended Defaults","text":"

      After running ctx init, your settings.local.json will have the ctx defaults pre-populated. Here is an opinionated safe starting point for a Go project using ctx:

      {\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(/tmp/ctx-*:*)\",\n      \"Bash(CGO_ENABLED=0 go build:*)\",\n      \"Bash(CGO_ENABLED=0 go test:*)\",\n      \"Bash(ctx:*)\",\n      \"Bash(git add:*)\",\n      \"Bash(git branch:*)\",\n      \"Bash(git check-ignore:*)\",\n      \"Bash(git checkout:*)\",\n      \"Bash(git commit:*)\",\n      \"Bash(git diff:*)\",\n      \"Bash(git log:*)\",\n      \"Bash(git remote:*)\",\n      \"Bash(git restore:*)\",\n      \"Bash(git show:*)\",\n      \"Bash(git stash:*)\",\n      \"Bash(git status:*)\",\n      \"Bash(git tag:*)\",\n      \"Bash(go build:*)\",\n      \"Bash(go fmt:*)\",\n      \"Bash(go test:*)\",\n      \"Bash(go vet:*)\",\n      \"Bash(golangci-lint run:*)\",\n      \"Bash(grep:*)\",\n      \"Bash(ls:*)\",\n      \"Bash(make:*)\",\n      \"Skill(ctx-convention-add)\",\n      \"Skill(ctx-decision-add)\",\n      \"Skill(ctx-learning-add)\",\n      \"Skill(ctx-task-add)\",\n      \"Skill(ctx-agent)\",\n      \"Skill(ctx-archive)\",\n      \"Skill(ctx-blog)\",\n      \"Skill(ctx-blog-changelog)\",\n      \"Skill(absorb)\",\n      \"Skill(ctx-commit)\",\n      \"Skill(ctx-drift)\",\n      \"Skill(ctx-implement)\",\n      \"Skill(ctx-journal-enrich)\",\n      \"Skill(ctx-journal-enrich-all)\",\n      \"Skill(ctx-loop)\",\n      \"Skill(ctx-next)\",\n      \"Skill(ctx-pad)\",\n      \"Skill(ctx-prompt-audit)\",\n      \"Skill(ctx-history)\",\n      \"Skill(ctx-reflect)\",\n      \"Skill(ctx-remember)\",\n      \"Skill(ctx-status)\",\n      \"Skill(ctx-worktree)\",\n      \"WebSearch\"\n    ],\n    \"deny\": [\n      \"Bash(sudo *)\",\n      \"Bash(git push *)\",\n      \"Bash(git push)\",\n      \"Bash(rm -rf /*)\",\n      \"Bash(rm -rf ~*)\",\n      \"Bash(curl *)\",\n      \"Bash(wget *)\",\n      \"Bash(chmod 777 *)\",\n      \"Read(**/.env)\",\n      \"Read(**/.env.*)\",\n      \"Read(**/*credentials*)\",\n      \"Read(**/*secret*)\",\n      \"Read(**/*.pem)\",\n      \"Read(**/*.key)\",\n      \"Edit(**/.env)\",\n      \"Edit(**/.env.*)\"\n    ]\n  }\n}\n

      This Is a Starting Point, Not a Mandate

      Your project may need more or fewer entries.

      The goal is intentional permissions: Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#design-principles","level":3,"title":"Design Principles","text":"

      Use wildcards for trusted binaries: If you trust the binary (your own project's CLI, make, go), a single wildcard like Bash(ctx:*) beats twenty subcommand entries. It reduces noise and means new subcommands work without re-prompting.

      Keep git commands granular: Unlike ctx or make, git has both safe commands (git log, git status) and destructive ones (git reset --hard, git clean -f). Listing safe commands individually prevents accidentally pre-approving dangerous ones.

      Pre-approve all ctx- skills: Skills shipped with ctx (Skill(ctx-*)) are safe to pre-approve. They are part of your project and you control their content. This prevents the agent from prompting on every skill invocation.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#default-deny-rules","level":3,"title":"Default Deny Rules","text":"

      ctx init automatically populates permissions.deny with rules that block dangerous operations. Deny rules are evaluated before allow rules: A denied pattern always prompts the user, even if it also matches an allow entry.

      The defaults block:

      Pattern Why Bash(sudo *) Cannot enter password; will hang Bash(git push *) Must be explicit user action Bash(rm -rf /*) etc. Recursive delete of system/home directories Bash(curl *) / wget Arbitrary network requests Bash(chmod 777 *) World-writable permissions Read/Edit(**/.env*) Secrets and credentials Read(**/*.pem, *.key) Private keys

      Read/Edit Deny Rules

      Read() and Edit() deny rules have known upstream enforcement issues (claude-code#6631,#24846).

      They are included as defense-in-depth and intent documentation.

      Blocked by default deny rules: no action needed, ctx init handles these:

      Pattern Risk Bash(git push:*) Must be explicit user action Bash(sudo:*) Privilege escalation Bash(rm -rf:*) Recursive delete with no confirmation Bash(curl:*) / Bash(wget:*) Arbitrary network requests

      Requires manual discipline: Never add these to allow:

      Pattern Risk Bash(git reset:*) Can discard uncommitted work Bash(git clean:*) Deletes untracked files Skill(ctx-permission-sanitize) Edits this file: self-modification vector Skill(release) Runs the release pipeline: high impact","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#hooks-regex-safety-net","level":2,"title":"Hooks: Regex Safety Net","text":"

      Deny rules handle prefix-based blocking natively. Hooks complement them by catching patterns that require regex matching: Things deny rules can't express.

      The ctx plugin ships these blocking hooks:

      Hook What it blocks ctx system block-non-path-ctx Running ctx from wrong path

      Project-local hooks (not part of the plugin) catch regex edge cases:

      Hook What it blocks block-dangerous-commands.sh Mid-command sudo/git push (after &&), copies to bin dirs, absolute-path ctx

      Pre-Approved + Hook-Blocked = Silent Block

      If you pre-approve a command that a hook blocks, the user never sees the confirmation dialog. The agent gets a block response and must handle it, which is confusing.

      It's better not to pre-approve commands that hooks are designed to intercept.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#the-maintenance-workflow","level":2,"title":"The Maintenance Workflow","text":"","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#after-busy-sessions","level":3,"title":"After Busy Sessions","text":"

      Permissions accumulate fastest during debugging and exploration sessions. After a session where you clicked \"Allow\" many times:

      1. Open .claude/settings.local.json in your editor;
      2. Look for entries at the bottom of the allowlist (new entries append there);
      3. Delete anything that looks session-specific:
        • Exact commands with hardcoded paths,
        • Commands with literal string arguments,
        • Entries that duplicate an existing wildcard.

      See the Sanitize Permissions runbook for a step-by-step procedure.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#periodically","level":3,"title":"Periodically","text":"

      Run /ctx-drift to catch permission drift:

      • Missing Bash(ctx:*) wildcard;
      • Missing Skill(ctx-*) entries for installed skills;
      • Stale Skill(ctx-*) entries for removed skills;
      • Granular Bash(ctx <subcommand>:*) entries that should be consolidated.

      Run /ctx-permission-sanitize to catch security issues:

      • Hook bypass patterns
      • Destructive commands
      • Overly broad permissions
      • Injection vectors
      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#when-adding-new-skills","level":3,"title":"When Adding New Skills","text":"

      If you create a custom ctx-* skill, add its Skill() entry to the allowlist manually.

      ctx init only populates the default permissions: It won't pick up custom skills.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#golden-image-snapshots","level":3,"title":"Golden Image Snapshots","text":"

      If manual cleanup is too tedious, use a golden image to automate it:

      Snapshot a curated permission set, then restore at session start to automatically drop session-accumulated permissions. See the Permission Snapshots recipe for the full workflow.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#adapting-for-other-languages","level":2,"title":"Adapting for Other Languages","text":"

      The recommended defaults above are Go-specific. For other stacks, swap the build/test tooling:

      Node.js / TypeScript:

      \"Bash(npm run:*)\",\n\"Bash(npm test:*)\",\n\"Bash(npx:*)\",\n\"Bash(node:*)\"\n

      Python:

      \"Bash(pytest:*)\",\n\"Bash(python:*)\",\n\"Bash(pip show:*)\",\n\"Bash(ruff:*)\"\n

      Rust:

      \"Bash(cargo build:*)\",\n\"Bash(cargo test:*)\",\n\"Bash(cargo clippy:*)\",\n\"Bash(cargo fmt:*)\"\n

      The ctx, git, and skill entries remain the same across all stacks.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#next-up","level":2,"title":"Next Up","text":"

      Permission Snapshots →: Save and restore permission baselines for reproducible setups.

      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#see-also","level":2,"title":"See Also","text":"
      • Setting Up ctx Across AI Tools: full setup recipe including settings.local.json creation
      • Context Health: keeping .context/ files accurate
      • Sanitize Permissions runbook: manual cleanup procedure
      ","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/configuration-profiles/","level":1,"title":"Configuration Profiles","text":"","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#configuration-profiles","level":1,"title":"Configuration Profiles","text":"

      Switch between dev and base runtime configurations without editing .ctxrc by hand. Useful when you want verbose logging and webhook notifications during development, then clean defaults for normal sessions.

      Uses: ctx config switch, ctx config status, /ctx-config

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#how-it-works","level":2,"title":"How It Works","text":"

      The ctx repo ships two source profiles committed to git:

      File Profile Description .ctxrc.base base All defaults, notifications off .ctxrc.dev dev Verbose logging, webhook notifications on

      The working copy (.ctxrc) is gitignored. Switching profiles copies the source file over .ctxrc, so your runtime configuration is always a clean snapshot of one of the two sources.

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#switching-profiles","level":2,"title":"Switching Profiles","text":"
      # Switch to dev (verbose logging, notifications)\nctx config switch dev\n\n# Switch to base (defaults)\nctx config switch base\n\n# Toggle to the opposite profile\nctx config switch\n\n# \"prod\" is an alias for \"base\"\nctx config switch prod\n

      The detection heuristic checks for an uncommented notify: line in .ctxrc: present means dev, absent means base.

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#checking-the-active-profile","level":2,"title":"Checking the Active Profile","text":"
      ctx config status\n

      Output examples:

      active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n
      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#typical-workflow","level":2,"title":"Typical Workflow","text":"
      1. Start of a debugging session: switch to dev for verbose logging and webhook notifications so you can trace hook activity and get push alerts.
      ctx config switch dev\n
      1. Work through the issue: hooks log verbosely, webhooks fire on key events (commits, ceremony nudges, drift warnings).

      2. Done debugging: switch back to base to silence the noise.

      ctx config switch base\n
      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#customizing-profiles","level":2,"title":"Customizing Profiles","text":"

      Edit the source files directly:

      • .ctxrc.dev: add any .ctxrc keys you want active during development (e.g., log_level: debug, notify.events, notify.webhook_url).
      • .ctxrc.base: keep this minimal. It represents your \"production\" defaults.

      After editing a source file, re-run ctx config switch <profile> to apply the changes to the working copy.

      Commit Your Profiles

      Both .ctxrc.base and .ctxrc.dev should be committed to git so team members share the same profile definitions. The working copy .ctxrc stays gitignored.

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#using-the-skill","level":2,"title":"Using the Skill","text":"

      In a Claude Code session, say any of:

      • \"switch to dev mode\"
      • \"switch to base\"
      • \"what profile am I on?\"
      • \"toggle verbose logging\"

      The /ctx-config skill handles the rest.

      See also: ctx config reference, Configuration

      ","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/context-health/","level":1,"title":"Detecting and Fixing Drift","text":"","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#the-problem","level":2,"title":"The Problem","text":"

      ctx files drift: you rename a package, delete a module, or finish a sprint, and suddenly ARCHITECTURE.md references paths that no longer exist, TASKS.md is 80 percent completed checkboxes, and CONVENTIONS.md describes patterns you stopped using two months ago.

      Stale context is worse than no context:

      An AI tool that trusts outdated references will hallucinate confidently.

      This recipe shows how to detect drift, fix it, and keep your .context/ directory lean and accurate.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tldr","level":2,"title":"TL;DR","text":"
      ctx drift                      # detect problems\nctx drift --fix                # auto-fix the easy ones\nctx sync --dry-run && ctx sync # reconcile after refactors\nctx compact --archive          # archive old completed tasks\nctx fmt                        # normalize line widths\nctx status                     # verify\n

      Or just ask your agent: \"Is our context clean?\"

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, every command above fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx drift Command Detect stale paths, missing files, violations ctx drift --fix Command Auto-fix simple issues ctx sync Command Reconcile context with codebase structure ctx compact Command Archive completed tasks, clean up empty sections ctx fmt Command Normalize context files to 80-char line width ctx status Command Quick health overview /ctx-drift Skill Structural plus semantic drift detection /ctx-architecture Skill Refresh ARCHITECTURE.md from actual codebase /ctx-status Skill In-session context summary /ctx-prompt-audit Skill Audit prompt quality and token efficiency","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#the-workflow","level":2,"title":"The Workflow","text":"

      The best way to maintain context health is conversational: Ask your agent, guide it, and let it detect problems, explain them, and fix them with your approval. CLI commands exist for CI pipelines, scripting, and fine-grained control.

      For day-to-day maintenance, talk to your agent.

      Your Questions Reinforce the Pattern

      Asking \"is our context clean?\" does two things:

      • It triggers a drift check right now
      • It reinforces the habit

      This is reinforcement, not enforcement.

      Do not wait for the agent to be proactive on its own:

      Guide your agent, especially in early sessions.

      Over time, you will ask less and the agent will start offering more.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-1-ask-your-agent","level":3,"title":"Step 1: Ask Your Agent","text":"

      The simplest way to check context health:

      Is our context clean?\nAnything stale?\nHow healthy are our context files?\n

      Or invoke the skill directly:

      /ctx-drift\n

      The agent performs two layers of analysis:

      Layer 1, structural checks (via ctx drift): Dead paths, missing files, completed task counts, constitution violations. Fast and programmatic.

      Layer 2, semantic analysis (agent-driven): Does CONVENTIONS.md describe patterns the code no longer follows? Does DECISIONS.md contain entries whose rationale no longer applies? Are there learnings about bugs that are now fixed? This is where the agent adds value the CLI cannot: It reads both context files and source code and compares them.

      The agent reports both layers together, explains each finding in plain language, and offers to fix what it can.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-2-maintenance-at-session-start","level":3,"title":"Step 2: Maintenance at Session Start","text":"

      You do not need to ask explicitly.

      Using Claude Code

      ctx ships with Claude Code hooks that remind the agent at the right time to take initiative.

      Checking context health at the session start, offering to persist learnings before you quit, and flagging drift when it matters. The agent stays proactive without you having to prompt it:

      Agent: Good morning. I've loaded the context files. A few things\n       before we start:\n\n       - ARCHITECTURE.md references `pkg/auth/` which is now empty\n       - DECISIONS.md hasn't been updated in 40 days\n       - There are 18 completed tasks ready for archival\n\n       Want me to run a quick maintenance pass, or should we jump\n       straight into today's work?\n

      ☝️️ this is what persistent, initiative-driven sessions feel like when context is treated as a system instead of a prompt.

      If the agent does not offer this on its own, a gentle nudge is enough:

      Anything stale before we start?\nHow's the context looking?\n

      This turns maintenance from a scheduled chore into a conversation that happens when it matters.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-3-real-time-detection-during-work","level":3,"title":"Step 3: Real-Time Detection during Work","text":"

      Agents can notice drift while working: When a mismatch is directly in the path of their current task. If an agent reads ARCHITECTURE.md to find where to add a handler and internal/handlers/ doesn't exist, it will notice because the stale reference blocks its work:

      Agent: ARCHITECTURE.md references `internal/handlers/` but that directory\n       doesn't exist. I'll look at the actual source tree to find where\n       handlers live now.\n

      This happens reliably when the drift intersects the task. What is less reliable is the agent generalizing from one mismatch to \"there might be more stale references; let me run drift detection\" That leap requires the agent to know /ctx-drift exists and to decide the current task should pause for maintenance.

      If you want that behavior, reinforce it:

      Good catch. Yes, run /ctx-drift and clean up any other stale references.\n

      Over time, agents that have seen this pattern will start offering proactively. But do not expect it from a cold start.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#step-4-archival-and-cleanup","level":3,"title":"Step 4: Archival and Cleanup","text":"

      ctx drift detects when TASKS.md has more than 10 completed items and flags it as a staleness warning. Running ctx drift --fix archives completed tasks automatically.

      You can also run /ctx-archive to compact on demand.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#knowledge-health-flow","level":3,"title":"Knowledge Health Flow","text":"

      Over time, LEARNINGS.md and DECISIONS.md accumulate entries that overlap or partially repeat each other. The check-persistence hook detects when entry counts exceed a configurable threshold and surfaces a nudge:

      \"LEARNINGS.md has 25+ entries. Consider running /ctx-consolidate to merge overlapping items.\"

      The consolidation workflow:

      1. Review: /ctx-consolidate groups entries by keyword similarity and presents candidate merges for your approval.
      2. Merge: Approved groups are combined into single entries that preserve the key information from each original.
      3. Archive: Originals move to .context/archive/, not deleted -- the full history is preserved in git and the archive directory.
      4. Verify: Run ctx drift after consolidation to confirm no cross-references were broken by the merge.

      This replaces ad-hoc cleanup with a repeatable, nudge-driven cycle: detect accumulation, review candidates, merge with approval, archive originals.

      See also: Knowledge Capture for the recording workflow that feeds into this maintenance cycle.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-doctor-the-superset-check","level":2,"title":"ctx doctor: The Superset Check","text":"

      ctx doctor combines drift detection with hook auditing, configuration checks, event logging status, and token size reporting in a single command. If you want one command that covers structural health, hooks, and state:

      ctx doctor          # everything in one pass\nctx doctor --json   # machine-readable for scripting\n

      Use /ctx-doctor Too

      For agent-driven diagnosis that adds semantic analysis on top of the structural checks, use /ctx-doctor.

      See the Troubleshooting recipe for the full workflow.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#cli-reference","level":2,"title":"CLI Reference","text":"

      The conversational approach above uses CLI commands under the hood. When you need direct control, use the commands directly.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift","level":3,"title":"ctx drift","text":"

      Scan context files for structural problems:

      ctx drift\n

      Sample output:

      Drift Report\n============\n\nWarnings (3):\n  ARCHITECTURE.md:14  path \"internal/api/router.go\" does not exist\n  ARCHITECTURE.md:28  path \"pkg/auth/\" directory is empty\n  CONVENTIONS.md:9    path \"internal/handlers/\" not found\n\nViolations (1):\n  TASKS.md            31 completed tasks (recommend archival)\n\nStaleness:\n  DECISIONS.md        last modified 45 days ago\n  LEARNINGS.md        last modified 32 days ago\n\nExit code: 1 (warnings found)\n
      Level Meaning Action Warning Stale path references, missing files Fix or remove Violation Constitution rule heuristic failures, heavy clutter Fix soon Staleness Files not updated recently Review content

      Exit codes: 0 equals clean, 1 equals warnings, 3 equals violations.

      For CI integration:

      ctx drift --json | jq '.warnings | length'\n
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift-fix","level":3,"title":"ctx drift --fix","text":"

      Auto-fix mechanical issues:

      ctx drift --fix\n

      This handles removing dead path references, updating unambiguous renames, clearing empty sections. Issues requiring judgment are flagged but left for you.

      Run ctx drift again afterward to confirm what remains.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-sync","level":3,"title":"ctx sync","text":"

      After a refactor, reconcile context with the actual codebase structure:

      ctx sync --dry-run   # preview first\nctx sync             # apply\n

      ctx sync scans for structural changes, compares with ARCHITECTURE.md, checks for new dependencies worth documenting, and identifies context referring to code that no longer exists.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-compact","level":3,"title":"ctx compact","text":"

      Consolidate completed tasks and clean up empty sections:

      ctx compact            # move completed tasks to Completed section,\n                       # remove empty sections\nctx compact --archive  # also archive old tasks to .context/archive/\n
      • Tasks: moves completed items (with all subtasks done) into the Completed section of TASKS.md
      • All files: removes empty sections left behind
      • With --archive: writes tasks older than 7 days to .context/archive/tasks-YYYY-MM-DD.md

      Without --archive, nothing is deleted: Tasks are reorganized in place.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-fmt","level":3,"title":"ctx fmt","text":"

      Normalize context file line widths:

      ctx fmt              # wrap long lines to 80 chars\nctx fmt --check      # CI: exit 1 if files need formatting\n

      Long task descriptions, decision rationale, and learning entries accumulate as single-line entries. ctx fmt wraps them at word boundaries with 2-space continuation indent for list items. Headings, tables, and comments are preserved.

      Idempotent: safe to run repeatedly.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-status","level":3,"title":"ctx status","text":"

      Quick health overview:

      ctx status --verbose\n

      Shows file counts, token estimates, modification times, and drift warnings in a single glance.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-prompt-audit","level":3,"title":"/ctx-prompt-audit","text":"

      Checks whether your context files are readable, compact, and token-efficient for the model.

      /ctx-prompt-audit\n
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      Conversational approach (recommended):

      Is our context clean?  -> agent runs structural plus semantic checks\nFix what you can       -> agent auto-fixes and proposes edits\nArchive the done tasks -> agent runs ctx compact --archive\nHow's token usage?     -> agent checks ctx status\n

      CLI approach (for CI, scripts, or direct control):

      ctx drift                      # 1. Detect problems\nctx drift --fix                # 2. Auto-fix the easy ones\nctx sync --dry-run && ctx sync # 3. Reconcile after refactors\nctx compact --archive          # 4. Archive old completed tasks\nctx fmt                        # 5. Normalize line widths\nctx status                     # 6. Verify\n
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tips","level":2,"title":"Tips","text":"

      Agents cross-reference context files with source code during normal work. When drift intersects their current task, they will notice: a renamed package, a deleted directory, a path that doesn't resolve. But they rarely generalize from one mismatch to a full audit on their own. Reinforce the pattern: when an agent mentions a stale reference, ask it to run /ctx-drift. Over time, it starts offering.

      When an agent says \"this reference looks stale,\" it is usually right.

      Semantic drift is more damaging than structural drift: ctx drift catches dead paths. But CONVENTIONS.md describing a pattern your code stopped following three weeks ago is worse. When you ask \"is our context clean?\", the agent can do both checks.

      Use ctx status as a quick check: It shows file counts, token estimates, and drift warnings in a single glance. Good for a fast \"is everything ok?\" before diving into work.

      Drift detection in CI: add ctx drift --json to your CI pipeline and fail on exit code 3 (violations). This catches constitution-level problems before they reach upstream.

      Do not over-compact: Completed tasks have historical value. The --archive flag preserves them in .context/archive/ so you can search past work without cluttering active context.

      Sync is cautious by default: Use --dry-run after large refactors, then apply.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#next-up","level":2,"title":"Next Up","text":"

      Claude Code Permission Hygiene →: Recommended permission defaults and maintenance workflow for Claude Code.

      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#see-also","level":2,"title":"See Also","text":"
      • Troubleshooting: full diagnostic workflow using ctx doctor, event logs, and /ctx-doctor
      • Tracking Work Across Sessions: task lifecycle and archival
      • Persisting Decisions, Learnings, and Conventions: keeping knowledge files current
      • The Complete Session: where maintenance fits in the daily workflow
      • CLI Reference: full flag documentation for all commands
      • Context Files: structure and purpose of each .context/ file
      ","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/customizing-hook-messages/","level":1,"title":"Customizing Hook Messages","text":"","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#the-problem","level":2,"title":"The Problem","text":"

      ctx hooks speak ctx's language, not your project's. The QA gate says \"lint the ENTIRE project\" and \"make build,\" but your Python project uses pytest and ruff. The post-commit nudge suggests running lints, but your project uses npm test. You could remove the hook entirely, but then you lose the logic (counting, state tracking, adaptive frequency) just to change the words.

      How do you customize what hooks say without removing what they do?

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tldr","level":2,"title":"TL;DR","text":"
      ctx hook message list                     # see all hooks and their messages\nctx hook message show qa-reminder gate    # view the current template\nctx hook message edit qa-reminder gate    # copy default to .context/ for editing\nctx hook message reset qa-reminder gate   # revert to embedded default\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root: hook message overrides live in your .context/ directory, so ctx needs to know which one. If you skip the eval, ctx hook message ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#commands-used","level":2,"title":"Commands Used","text":"Tool Type Purpose ctx hook message list CLI command Show all hook messages with category and override status ctx hook message show CLI command Print the effective message template ctx hook message edit CLI command Copy embedded default to .context/ for editing ctx hook message reset CLI command Delete user override, revert to default","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#how-it-works","level":2,"title":"How It Works","text":"

      Hook messages use a 3-tier fallback:

      1. User override: .context/hooks/messages/{hook}/{variant}.txt
      2. Embedded default: compiled into the ctx binary
      3. Hardcoded fallback: belt-and-suspenders safety net

      The hook logic (when to fire, counting, state tracking, cooldowns) is unchanged. Only the content (what text gets emitted) comes from the template. You customize what the hook says without touching how it decides to speak.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#finding-the-original-templates","level":3,"title":"Finding the Original Templates","text":"

      The default templates live in the ctx source tree at:

      internal/assets/hooks/messages/{hook}/{variant}.txt\n

      You can also browse them on GitHub: internal/assets/hooks/messages/

      Or use ctx hook message show to print any template without digging through source code:

      ctx hook message show qa-reminder gate        # QA gate instructions\nctx hook message show check-persistence nudge  # persistence nudge\nctx hook message show post-commit nudge        # post-commit reminder\n

      The show output includes the template source and available variables -- everything you need to write a replacement.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#template-variables","level":3,"title":"Template Variables","text":"

      Some messages use Go text/template variables for dynamic content:

      No context files updated in {{.PromptsSinceNudge}}+ prompts.\nHave you discovered learnings, made decisions,\nestablished conventions, or completed tasks\nworth persisting?\n

      The show and edit commands list available variables for each message. When writing a replacement, keep the same {{.VariableName}} placeholders to preserve dynamic content. Variables that you omit render as <no value>: no error, but the output may look odd.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#intentional-silence","level":3,"title":"Intentional Silence","text":"

      An empty template file (0 bytes or whitespace-only) means \"don't emit a message\". The hook still runs its logic but produces no output. This lets you silence specific messages without removing the hook from hooks.json.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#example-python-project-qa-gate","level":2,"title":"Example: Python Project QA Gate","text":"

      The default QA gate says \"lint the ENTIRE project\" and references make lint. For a Python project, you want pytest and ruff:

      # See the current default\nctx hook message show qa-reminder gate\n\n# Copy it to .context/ for editing\nctx hook message edit qa-reminder gate\n\n# Edit the override\n

      Replace the content in .context/hooks/messages/qa-reminder/gate.txt:

      HARD GATE! DO NOT COMMIT without completing ALL of these steps first:\n(1) Run the full test suite: pytest -x\n(2) Run the linter: ruff check .\n(3) Verify a clean working tree\nRun tests and linter BEFORE every git commit, no exceptions.\n

      The hook still fires on every Edit call. The logic is identical. Only the instructions changed.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#example-silencing-ceremony-nudges","level":2,"title":"Example: Silencing Ceremony Nudges","text":"

      The ceremony check nudges you to use /ctx-remember and /ctx-wrap-up. If your team has a different workflow and finds these noisy:

      ctx hook message edit check-ceremonies both\nctx hook message edit check-ceremonies remember\nctx hook message edit check-ceremonies wrapup\n

      Then empty each file:

      echo -n \"\" > .context/hooks/messages/check-ceremonies/both.txt\necho -n \"\" > .context/hooks/messages/check-ceremonies/remember.txt\necho -n \"\" > .context/hooks/messages/check-ceremonies/wrapup.txt\n

      The hooks still track ceremony usage internally, but they no longer emit any visible output.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#example-javascript-project-post-commit","level":2,"title":"Example: JavaScript Project Post-Commit","text":"

      The default post-commit nudge mentions generic \"lints and tests.\" For a JavaScript project:

      ctx hook message edit post-commit nudge\n

      Replace with:

      Commit succeeded. 1. Offer context capture to the user: Decision (design\nchoice?), Learning (gotcha?), or Neither. 2. Ask the user: \"Want me to\nrun npm test and eslint before you push?\" Do NOT push. The user pushes\nmanually.\n
      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#the-two-categories","level":2,"title":"The Two Categories","text":"

      Not all messages are equal. The list command shows each message's category:

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#customizable-17-messages","level":3,"title":"Customizable (17 Messages)","text":"

      Messages that are opinions: project-specific wording that benefits from customization. These are the primary targets for override.

      Hook Variant Description check-freshness stale Technology constant freshness warning check-ceremonies both Both ceremonies missing check-ceremonies remember Start-of-session ceremony check-ceremonies wrapup End-of-session ceremony check-context-size checkpoint Context capacity warning check-context-size oversize Injection oversize nudge check-context-size window Context window usage warning (>80%) check-journal both Unimported sessions + unenriched entries check-journal unenriched Unenriched journal entries check-journal unimported Unimported sessions check-knowledge warning Knowledge file growth check-map-staleness stale Architecture map staleness check-persistence nudge Context persistence nudge post-commit nudge Post-commit context capture qa-reminder gate Pre-commit QA gate","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#ctx-specific-10-messages","level":3,"title":"ctx-Specific (10 Messages)","text":"

      Messages specific to ctx's own development workflow. You can customize them, but edit will warn you first.

      Hook Variant Description block-dangerous-commands cp-to-bin Block copy to bin dirs block-dangerous-commands install-to-local-bin Block copy to ~/.local/bin block-dangerous-commands mid-git-push Block git push block-dangerous-commands mid-sudo Block sudo block-non-path-ctx absolute-path Block absolute path invocation block-non-path-ctx dot-slash Block ./ctx invocation block-non-path-ctx go-run Block go run invocation check-reminders reminders Pending reminders relay check-resources alert Resource pressure alert check-version key-rotation Key rotation nudge check-version mismatch Version mismatch","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#template-variables-reference","level":2,"title":"Template Variables Reference","text":"Hook Variant Variables check-freshness stale {{.StaleFiles}} check-context-size checkpoint (none) check-context-size oversize {{.TokenCount}} check-context-size window {{.TokenCount}}, {{.Percentage}} check-ceremonies both, remember, wrapup (none) check-journal both {{.UnimportedCount}}, {{.UnenrichedCount}} check-journal unenriched {{.UnenrichedCount}} check-journal unimported {{.UnimportedCount}} check-knowledge warning {{.FileWarnings}} check-map-staleness stale {{.LastRefreshDate}}, {{.ModuleCount}} check-persistence nudge {{.PromptsSinceNudge}} check-reminders reminders {{.ReminderList}} check-resources alert {{.AlertMessages}} check-version key-rotation {{.KeyAgeDays}} check-version mismatch {{.BinaryVersion}}, {{.PluginVersion}} post-commit nudge (none) qa-reminder gate (none) block-dangerous-commands all variants (none) block-non-path-ctx all variants (none)

      Templates that reference undefined variables render <no value>: no error, graceful degradation.

      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tips","level":2,"title":"Tips","text":"
      • Override files are version-controlled: they live in .context/ alongside your other context files. Team members get the same customized messages.
      • Start with show: always check the current default before editing. The embedded template is the baseline your override replaces.
      • Use reset to undo: if a customization causes confusion, reset reverts to the embedded default instantly.
      • Empty file = silence: you don't need to delete the hook. An empty override file silences the message while preserving the hook's logic.
      • JSON output for scripting: ctx hook message list --json returns structured data for automation.
      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#see-also","level":2,"title":"See Also","text":"
      • Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates
      • Auditing System Hooks: verifying hooks are running and auditing their output
      • Configuration: project-level settings via .ctxrc
      ","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/design-before-coding/","level":1,"title":"Design Before Coding","text":"","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#the-problem","level":2,"title":"The Problem","text":"

      You start coding a feature. Halfway through, you realize the approach doesn't handle a key edge case. You refactor. Then you discover the CLI interface doesn't fit the existing patterns. More refactoring.

      The design work happened during implementation, mixed in with debugging and trial-and-error. The result works, but the spec was never written down, the trade-offs were never recorded, and the next session has no idea why things are shaped this way.

      How do you front-load design so the implementation is straightforward?

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-brainstorm          # explore the design space\n/ctx-spec                # write the spec document\n/ctx-task-add            # break it into tasks\n/ctx-implement           # execute step-by-step\n

      Four skills, used in sequence. Each produces an artifact that feeds the next.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-brainstorm Skill Structured design dialogue: explore approaches /ctx-spec Skill Scaffold and fill out a spec from the template /ctx-task-add Skill Add implementation tasks to TASKS.md /ctx-implement Skill Execute a plan step-by-step with verification /ctx-decision-add Skill Record design choices made during brainstorming","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-1-brainstorm-the-design","level":3,"title":"Step 1: Brainstorm the Design","text":"

      Start with /ctx-brainstorm when you have a rough idea but haven't committed to an approach. The skill follows a gated process:

      1. Understand context: what exists today, what's the gap
      2. Clarify the idea: one question at a time, not a wall of questions
      3. Surface non-functional requirements: performance, security, compatibility
      4. Lock understanding: confirm before exploring solutions
      5. Explore 2-3 approaches: with trade-offs for each
      6. Stress-test: poke holes in the chosen approach
      7. Present the design: detailed enough to implement from
      You: \"I want to add RSS feed generation to the blog.\"\n\nAgent: \"Before we design, let me understand: is this for the journal\n  site, the docs site, or both?\"\n\nYou: \"Journal site only.\"\n\nAgent: [asks about update frequency, content scope, existing infra...]\n       [presents 3 approaches with trade-offs]\n\nYou: \"Option 2 - generate at build time.\"\n\nAgent: \"Let me stress-test that. What happens when...\"\n       [probes edge cases]\n       \"Design looks solid. Want me to record the approach as a\n       decision and write a spec?\"\n

      The brainstorm produces a validated design in conversation. It doesn't produce a file - that's what the spec is for.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-2-write-the-spec","level":3,"title":"Step 2: Write the Spec","text":"

      Once the design is clear, use /ctx-spec to produce the written artifact. The skill reads the project's spec template (specs/tpl/spec-template.md) and walks through each section:

      You: /ctx-spec (rss feed generation)\n\nAgent: \"Creating specs/rss-feed.md from template.\"\n\n       \"Problem: What user-visible problem does this solve? Why now?\"\n\nYou: \"Users can't subscribe to blog updates. They have to check\n      the site manually.\"\n\nAgent: [writes the Problem section, moves to Approach]\n\n       \"Approach: High-level, how does this work?\"\n\nYou: \"Generate feed.xml during ctx journal site. Atom format.\"\n\nAgent: [writes Approach, moves to Happy Path, then Edge Cases...]\n

      The skill spends extra time on Edge Cases and Error Handling: These are where specs earn their value. The skill pushes for at least three edge cases and won't accept \"none\" without a challenge.

      Sections that don't apply can be skipped. The result is a complete spec at specs/{feature-name}.md.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-3-break-into-tasks","level":3,"title":"Step 3: Break into Tasks","text":"

      After the spec is written, the skill offers to create tasks:

      Agent: \"Spec written to specs/rss-feed.md. Want me to break this\n  into tasks in TASKS.md?\"\n\nYou: \"Yes.\"\n\nAgent: [creates a Phase section referencing the spec, adds tasks]\n       \"Added Phase 0.8: RSS/Atom Feed Generation with 4 tasks:\n         - [ ] Implement feed.xml generation in ctx journal site\n         - [ ] Add --feed flag and .ctxrc feed config\n         - [ ] Write tests for feed generation\n         - [ ] Add recipe and update docs\"\n

      Each task is independently completable and references the spec via Spec: specs/rss-feed.md in the Phase header.

      You can also invoke /ctx-task-add directly at any point to add individual tasks.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-4-implement-step-by-step","level":3,"title":"Step 4: Implement Step-by-Step","text":"

      Pick up tasks with /ctx-implement. The skill loads the spec, breaks work into atomic steps, and checkpoints after every 3-5 steps with a build and test verification:

      You: /ctx-implement (specs/rss-feed.md)\n\nAgent: \"Loaded spec. Breaking into steps:\n         1. Add FeedEntry type to journal package\n         2. Implement feed.xml template\n         3. Wire into site generation pipeline\n         [builds and tests after step 3]\n         4. Add --feed flag to ctx journal site\n         5. Add .ctxrc feed configuration\n         [builds and tests after step 5]\n         ...\"\n

      If a build or test fails, the agent stops, diagnoses, and fixes before continuing.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#when-to-skip-steps","level":2,"title":"When to Skip Steps","text":"

      Not every feature needs all four steps. Use your judgment:

      Situation Start at Vague idea, multiple valid approaches Step 1: Brainstorm Clear approach, need to document it Step 2: Spec Spec already exists, need to plan work Step 3: Tasks Tasks exist, ready to code Step 4: Implement

      A brainstorm without a spec is fine for small decisions. A spec without a brainstorm is fine when the design is obvious. The full chain is for features complex enough to warrant front-loaded design.

      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need skill names. Natural language works:

      You say What happens \"Let's think through this feature\" /ctx-brainstorm \"Spec this out\" /ctx-spec \"Write a design doc for...\" /ctx-spec \"Break this into tasks\" /ctx-task-add \"Implement the spec\" /ctx-implement \"Let's design before we build\" Starts at brainstorm","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#tips","level":2,"title":"Tips","text":"
      • Brainstorm first when uncertain. If you can articulate the approach in two sentences, skip to spec. If you can't, brainstorm.
      • Specs prevent scope creep. The Non-Goals section is as important as the approach. Writing down what you won't do keeps implementation focused.
      • Edge cases are the point. A spec that only describes the happy path isn't a spec - it's a wish. The /ctx-spec skill pushes for at least 3 edge cases because that's where designs break.
      • Record decisions during brainstorming. When you choose between approaches, the agent offers to persist the trade-off via /ctx-decision-add. Accept - future sessions need to know why, not just what.
      • Specs are living documents. Update them when implementation reveals new constraints. A spec that diverges from reality is worse than no spec.
      • The spec template is customizable. Edit specs/tpl/spec-template.md to match your project's needs. The /ctx-spec skill reads whatever template it finds there.
      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#see-also","level":2,"title":"See Also","text":"
      • Skills Reference: /ctx-brainstorm: structured design dialogue
      • Skills Reference: /ctx-spec: spec scaffolding from template
      • Skills Reference: /ctx-implement: step-by-step execution with verification
      • Tracking Work Across Sessions: task lifecycle and archival
      • Importing Claude Code Plans: turning ephemeral plans into permanent specs
      • Persisting Decisions, Learnings, and Conventions: capturing design trade-offs
      ","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/external-context/","level":1,"title":"Keeping Context in a Separate Repo","text":"","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#the-problem","level":2,"title":"The Problem","text":"

      ctx files contain project-specific decisions, learnings, conventions, and tasks. By default, they live in .context/ inside the project tree, and that works well when the context can be public.

      But sometimes you need the context outside the project:

      • Open-source projects with private context: Your architectural notes, internal task lists, and scratchpad entries shouldn't ship with the public repo.
      • Compliance or IP concerns: Context files reference sensitive design rationale that belongs in a separate access-controlled repository.
      • Personal preference: You want to keep notes separate from code.

      ctx supports this by letting you point CTX_DIR anywhere. This recipe shows how to set that up and how to tell your AI assistant where to find the context.

      One .context/ per project

      The parent of the context directory is the project root by contract. ctx sync, ctx drift, and the memory-drift hook all read the codebase at filepath.Dir(ContextDir()). Pointing two projects at the same directory corrupts their journals, state, and secrets. To share knowledge (CONSTITUTION / CONVENTIONS / ARCHITECTURE) across projects, use ctx hub, not a shared .context/.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#tldr","level":2,"title":"TL;DR","text":"

      Create the external context directory, initialize it, and bind it:

      mkdir -p ~/repos/myproject-context && cd ~/repos/myproject-context && git init\ncd ~/repos/myproject\n\n# Bind CTX_DIR to the external location, then init creates files there.\nexport CTX_DIR=~/repos/myproject-context/.context\nctx init\n

      All ctx commands now use the external directory. If you share the setup across shells, add the export CTX_DIR=... line to your shell rc, or source a per-project .envrc with direnv.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#what-works-what-quietly-degrades","level":2,"title":"What Works, What Quietly Degrades","text":"

      The single-source-anchor contract states that filepath.Dir(CTX_DIR) is the project root. When the context lives outside the project tree, ctx still resolves correctly for every operation that reads or writes inside .context/. But any operation that scans the codebase scans the wrong tree, and does so silently:

      Operation Behavior with external .context/ ctx status, agent, add ✅ Works. Operates on files inside CTX_DIR. Journal, scratchpad, hub ✅ Works. Same reason. ctx sync ⚠️ Scans the context repo, not the code repo. ctx drift ⚠️ Same. Reports nothing useful. Memory-drift hook (MEMORY.md) ⚠️ Looks for MEMORY.md next to the external .context/, not the code.

      Nothing errors. The code-aware operations just find an empty or unrelated tree where the project root should be.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#workaround-symlink-the-context-into-the-code-tree","level":3,"title":"Workaround: symlink the .context/ into the code tree","text":"

      If you want both the privacy of an external git repo and working ctx sync / drift / memory-drift, symlink the external .context/ into the code repo and point CTX_DIR at the symlink:

      # External repo holds the real files\nmkdir -p ~/repos/myproject-context && cd ~/repos/myproject-context && git init\n\n# Symlink it into the code repo\nln -s ~/repos/myproject-context/.context ~/repos/myproject/.context\n\n# Bind CTX_DIR to the symlink path; ctx init will follow it\nexport CTX_DIR=~/repos/myproject/.context\nctx init\n

      Now filepath.Dir(CTX_DIR) is the code repo, so code-aware operations scan the right tree. The actual files still live in the external repo and commit there. Add .context to the code repo's .gitignore (or .git/info/exclude) so the symlink itself isn't tracked by the code repo.

      The basename guard is permissive about symlinks: it checks the declared name, not the resolved target, so a .context symlink pointing anywhere is accepted as long as the declared basename is .context.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx init CLI command Initialize context directory ctx activate CLI command Emit export CTX_DIR=... for the shell CTX_DIR Env variable Declare context directory per-session .ctxrc Config file Per-project configuration /ctx-status Skill Verify context is loading correctly","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-1-create-the-private-context-repo","level":3,"title":"Step 1: Create the Private Context Repo","text":"

      Create a separate repository for your context files. This can live anywhere: a private GitHub repo, a shared drive, a sibling directory:

      # Create the context repo\nmkdir -p ~/repos/myproject-context\ncd ~/repos/myproject-context\ngit init\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-2-initialize-ctx-pointing-at-it","level":3,"title":"Step 2: Initialize ctx Pointing at It","text":"

      From your project root, declare CTX_DIR pointing to the external location, then initialize:

      cd ~/repos/myproject\nCTX_DIR=~/repos/myproject-context/.context ctx init\n

      This creates the canonical .context/ file set inside ~/repos/myproject-context/ instead of ~/repos/myproject/.context/.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-3-make-it-stick","level":3,"title":"Step 3: Make It Stick","text":"

      Declaring CTX_DIR on every command is tedious. Pick one of these methods to make the configuration permanent. The context directory itself must be declared via CTX_DIR; .ctxrc does not carry the path.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#option-a-ctx_dir-environment-variable-recommended","level":4,"title":"Option A: CTX_DIR Environment Variable (Recommended)","text":"
      # Direct path. Works for ctx status / agent / add but degrades\n# code-aware operations. See \"What Works, What Quietly Degrades\".\nexport CTX_DIR=~/repos/myproject-context/.context\n\n# Or, with the symlink approach above, point at the symlink path\n# inside the code repo so code-aware operations stay healthy.\nexport CTX_DIR=~/repos/myproject/.context\n

      Put either form in your shell profile (~/.bashrc, ~/.zshrc) or a direnv .envrc.

      For a single session, run eval \"$(ctx activate)\" from any directory inside the project where exactly one .context/ candidate is visible (the symlink counts). activate does not accept a path argument; bind a specific path by exporting CTX_DIR directly instead.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#option-b-ctxrc-for-other-settings","level":4,"title":"Option B: .ctxrc for Other Settings","text":"

      Put any settings (token budget, priority order, freshness files) in a .ctxrc at the project root (dirname(CTX_DIR)), which here is the parent of the external .context/:

      # ~/repos/myproject-context/.ctxrc\ntoken_budget: 16000\n

      .ctxrc is always read from the parent of CTX_DIR, so this file is picked up whenever CTX_DIR points at ~/repos/myproject-context/.context.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#resolution","level":4,"title":"Resolution","text":"

      ctx reads the context directory from a single channel: the CTX_DIR environment variable. When CTX_DIR is unset, ctx errors with a \"no context directory specified\" hint pointing at ctx activate and this recipe. When set, the value must be an absolute path with .context as its basename; relative paths and other names are rejected on first use.

      See Activating a Context Directory for the full recipe.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-4-agent-auto-discovery-via-bootstrap","level":3,"title":"Step 4: Agent Auto-Discovery via Bootstrap","text":"

      When context lives outside the project tree, your AI assistant needs to know where to find it. The ctx system bootstrap command resolves the configured context directory and communicates it to the agent automatically:

      $ ctx system bootstrap\nctx system bootstrap\n====================\n\ncontext_dir: /home/user/repos/myproject-context/.context\n\nFiles:\n  CONSTITUTION.md, TASKS.md, DECISIONS.md, ...\n

      The CLAUDE.md template generated by ctx init already instructs the agent to run ctx system bootstrap at session start. Because CTX_DIR is inherited by child processes, your agent picks up the external path automatically.

      Here is the relevant section from CLAUDE.md for reference:

      <!-- CLAUDE.md -->\n1. **Run `ctx system bootstrap`**: CRITICAL, not optional.\n   This tells you where the context directory is. If it returns any\n   error, relay the error output to the user verbatim, point them at\n   https://ctx.ist/recipes/activating-context/ for setup, and STOP.\n   Do not try to recover; the user decides.\n

      Moreover, every nudge (context checkpoint, persistence reminder, etc.) also includes a Context: /home/user/repos/myproject-context/.context footer, so the agent remains anchored to the correct directory even in long sessions.

      Export CTX_DIR in your shell profile so every hook process inherits it:

      export CTX_DIR=~/repos/myproject-context/.context\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-5-share-with-teammates","level":3,"title":"Step 5: Share with Teammates","text":"

      Teammates clone both repos and export CTX_DIR:

      # Clone the project\ngit clone git@github.com:org/myproject.git\ncd myproject\n\n# Clone the private context repo\ngit clone git@github.com:org/myproject-context.git ~/repos/myproject-context\nexport CTX_DIR=~/repos/myproject-context/.context\n

      If teammates use different paths, each developer sets their own CTX_DIR.

      For encryption key distribution across the team, see the Syncing Scratchpad Notes recipe.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#step-6-day-to-day-sync","level":3,"title":"Step 6: Day-to-Day Sync","text":"

      The external context repo has its own git history. Treat it like any other repo: commit and push after sessions:

      cd ~/repos/myproject-context\n\n# After a session\ngit add -A\ngit commit -m \"Session: refactored auth module, added rate-limit learning\"\ngit push\n

      Your AI assistant can do this too. When ending a session:

      You: \"Save what we learned and push the context repo.\"\n\nAgent: [runs ctx learning add, then commits and pushes the context repo]\n

      You can also set up a post-session habit: project code gets committed to the project repo, context gets committed to the context repo.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need to remember the flags; simply ask your assistant:

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#set-up-your-system-using-natural-language","level":3,"title":"Set Up Your System Using Natural Language","text":"
      You: \"Set up ctx to use ~/repos/myproject-context as the context directory.\"\n\nAgent: \"I'll set CTX_DIR to that path, run ctx init to materialize\n       it, and show you the export line to add to your shell\n       profile. Want me to seed the core context files too?\"\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#configure-separate-repo-for-context-folder-using-natural-language","level":3,"title":"Configure Separate Repo for .context Folder Using Natural Language","text":"
      You: \"My context is in a separate repo. Can you load it?\"\n\nAgent: [reads CTX_DIR, loads context from the external dir]\n       \"Loaded. You have 3 pending tasks, last session was about the auth\n       refactor.\"\n
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#tips","level":2,"title":"Tips","text":"
      • Start simple. If you don't need external context yet, don't set it up. The default .context/ in-tree is the easiest path. Move to an external repo when you have a concrete reason.
      • One context repo per project. Sharing a single context directory across multiple projects corrupts journals, state, and secrets. Use ctx hub for cross-project knowledge sharing.
      • Export CTX_DIR in your shell profile so hooks and tools inherit the path without per-command flags.
      • Commit both repos at session boundaries. Context without code history (or code without context history) loses half the value.
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#next-up","level":2,"title":"Next Up","text":"

      The Complete Session →: Walk through a full ctx session from start to finish.

      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/external-context/#see-also","level":2,"title":"See Also","text":"
      • Setting Up ctx Across AI Tools: initial setup recipe
      • Syncing Scratchpad Notes Across Machines: distribute encryption keys when context is shared
      • CLI Reference: full command list and global options
      ","path":["Recipes","Getting Started","Keeping Context in a Separate Repo"],"tags":[]},{"location":"recipes/guide-your-agent/","level":1,"title":"Guide Your Agent","text":"

      Commands vs. Skills

      Commands (ctx status, ctx task add) run in your terminal.

      Skills (/ctx-reflect, /ctx-next) run inside your AI coding assistant.

      Recipes combine both.

      Think of commands as structure and skills as behavior.

      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#proactive-behavior","level":2,"title":"Proactive Behavior","text":"

      These recipes show explicit commands and skills, but agents trained on the ctx playbook are proactive: They offer to save learnings after debugging, record decisions after trade-offs, create follow-up tasks after completing work, and suggest what to work on next.

      Your questions train the agent. Asking \"what have we learned?\" or \"is our context clean?\" does two things:

      • It triggers the workflow right now,
      • and it reinforces the pattern.

      The more you guide, the more the agent habituates the behavior and begins offering on its own.

      Each recipe includes a Conversational Approach section showing these natural-language patterns.

      Tip

      Don't wait passively for proactive behavior: especially in early sessions.

      Ask, guide, reinforce. Over time, you ask less and the agent offers more.

      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#next-up","level":2,"title":"Next Up","text":"

      Setup Across AI Tools →: Initialize ctx and configure hooks for Claude Code, Cursor, Aider, Copilot, or Windsurf.

      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: full session lifecycle from start to finish
      • Prompting Guide: general tips for working effectively with AI coding assistants
      ","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/hook-output-patterns/","level":1,"title":"Hook Output Patterns","text":"","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code hooks can output text, JSON, or nothing at all. But the format of that output determines who sees it and who acts on it.

      Choose the wrong pattern, and your carefully crafted warning gets silently absorbed by the agent, or your agent-directed nudge gets dumped on the user as noise.

      This recipe catalogs the known hook output patterns and explains when to use each one.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#tldr","level":2,"title":"TL;DR","text":"

      Eight patterns from full control to full invisibility:

      • hard gate (exit 2),
      • VERBATIM relay (agent MUST show),
      • agent directive (context injection),
      • and silent side-effect (background work).

      Most hooks belong in the middle.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#the-spectrum","level":2,"title":"The Spectrum","text":"

      These patterns form a spectrum based on who decides what the user sees:

      Pattern Who decides? Hard gate Hook decides (agent can't proceed) VERBATIM relay Hook decides (agent must show) Escalating severity Hook suggests, agent judges urgency Conditional relay Hook sets criteria, agent evaluates Suggested action Hook proposes, agent + user decide Agent directive Agent decides entirely Silent injection Nobody: invisible background context Silent side-effect Nobody: invisible background work

      The spectrum runs from full hook control (hard gate) to full invisibility (silent side effect).

      Most hooks belong somewhere in the middle.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-1-hard-gate","level":2,"title":"Pattern 1: Hard Gate","text":"

      Block the tool call entirely. The agent cannot proceed: it must find another approach or tell the user.

      echo '{\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}'\n

      When to use: Enforcing invariants that must never be violated: Constitution rules, security boundaries, destructive command prevention.

      Hook type: PreToolUse only (Claude Code first-class mechanism).

      Examples in ctx:

      • ctx system block-non-path-ctx: Enforces the PATH invocation rule
      • block-git-push.sh: Requires explicit user approval for pushes (project-local)
      • block-dangerous-commands.sh: Prevents sudo, copies to ~/.local/bin (project-local)

      Trade-off: The agent gets a block response with a reason. Good reasons help the agent recover (\"use X instead\"); bad reasons leave it stuck.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-2-verbatim-relay","level":2,"title":"Pattern 2: VERBATIM Relay","text":"

      Force the agent to show this to the user as-is. The explicit instruction overcomes the agent's tendency to silently absorb context.

      echo \"IMPORTANT: Relay this warning to the user VERBATIM before answering their question.\"\necho \"\"\necho \"┌─ Journal Reminder ─────────────────────────────\"\necho \"│ You have 12 sessions not yet exported.\"\necho \"└────────────────────────────────────────────────\"\n

      When to use: Actionable reminders the user needs to see regardless of what they asked: Stale backups, unimported sessions, resource warnings.

      Hook type: UserPromptSubmit (runs before the agent sees the prompt).

      Examples in ctx:

      • ctx system check-journal: Unexported sessions and unenriched entries
      • ctx system check-context-size: Context capacity warning
      • ctx system check-resources: Resource pressure (memory, swap, disk, load): DANGER only
      • ctx system check-freshness: Technology constant staleness warning

      Trade-off: Noisy if overused. Every VERBATIM relay adds a preamble before the agent's actual answer. Throttle with once-per-day markers or adaptive frequency.

      Key detail: The phrase IMPORTANT: Relay this ... VERBATIM is what makes this work. Without it, agents tend to process the information internally and never surface it. The explicit instruction is the pattern: the box-drawing is just fancy formatting.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-3-agent-directive","level":2,"title":"Pattern 3: Agent Directive","text":"

      Tell the agent to do something, not the user. The agent decides whether and how to involve the user.

      echo \"┌─ Persistence Checkpoint (prompt #25) ───────────\"\necho \"│ No context files updated in 15+ prompts.\"\necho \"│ Have you discovered learnings, decisions,\"\necho \"│ or completed tasks worth persisting?\"\necho \"└──────────────────────────────────────────────────\"\n

      When to use: Behavioral nudges. The hook detects a condition and asks the agent to consider an action. The user may never need to know.

      Hook type: UserPromptSubmit.

      Examples in ctx:

      • ctx system check-persistence: Nudges the agent to persist context

      Trade-off: No guarantee the agent acts. The nudge is one signal among many in the context window. Strong phrasing helps (\"Have you...?\" is better than \"Consider...\"), but ultimately the agent decides.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-4-silent-context-injection","level":2,"title":"Pattern 4: Silent Context Injection","text":"

      Load context with no visible output. The agent gets enriched without either party noticing.

      ctx agent --budget 4000 >/dev/null || true\n

      When to use: Background context loading that should be invisible. The agent benefits from the information, but neither it, nor the user needs to know it happened.

      Hook type: PreToolUse with .* matcher (runs on every tool call).

      Examples in ctx:

      • The ctx agent PreToolUse hook: injects project context silently

      Trade-off: Adds latency to every tool call. Keep the injected content small and fast to generate.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-5-silent-side-effect","level":2,"title":"Pattern 5: Silent Side-Effect","text":"

      Do work, produce no output: Housekeeping that needs no acknowledgment.

      find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n

      When to use: Cleanup, log rotation, temp file management. Anything where the action is the point and nobody needs to know it happened.

      Hook type: Any hook where output is irrelevant.

      Examples in ctx:

      • Log rotation, marker file cleanup, state directory maintenance

      Trade-off: None, if the action is truly invisible. If it can fail in a way that matters, consider logging.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-6-conditional-relay","level":3,"title":"Pattern 6: Conditional Relay","text":"

      Tell the agent to relay only if a condition holds in context.

      echo \"If the user's question involves modifying .context/ files,\"\necho \"relay this warning VERBATIM:\"\necho \"\"\necho \"┌─ Context Integrity ─────────────────────────────\"\necho \"│ CONSTITUTION.md has not been verified in 7 days.\"\necho \"└────────────────────────────────────────────────\"\necho \"\"\necho \"Otherwise, proceed normally.\"\n

      When to use: Warnings that only matter in certain contexts. Avoids noise when the user is doing unrelated work.

      Trade-off: Depends on the agent's judgment about when the condition holds. More fragile than VERBATIM relay, but less noisy.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-7-suggested-action","level":3,"title":"Pattern 7: Suggested Action","text":"

      Give the agent a specific command to propose to the user.

      echo \"┌─ Stale Dependencies ──────────────────────────\"\necho \"│ go.sum is 30+ days newer than go.mod.\"\necho \"│ Suggested: run \\`go mod tidy\\`\"\necho \"│ Ask the user before proceeding.\"\necho \"└───────────────────────────────────────────────\"\n

      When to use: The hook detects a fixable condition and knows the fix. Goes beyond a nudge: Gives the agent a concrete next step. The agent still asks for permission but knows exactly what to propose.

      Trade-off: The suggestion might be wrong or outdated. The \"ask the user before proceeding\" part is critical.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#pattern-8-escalating-severity","level":3,"title":"Pattern 8: Escalating Severity","text":"

      Different urgency tiers with different relay expectations.

      # INFO: agent processes silently, mentions if relevant\necho \"INFO: Last test run was 3 days ago.\"\n\n# WARN: agent should mention to user at next natural pause\necho \"WARN: 12 uncommitted changes across 3 branches.\"\n\n# CRITICAL: agent must relay immediately, before any other work\necho \"CRITICAL: Relay VERBATIM before answering. Disk usage at 95%.\"\n

      When to use: When you have multiple hooks producing output and need to avoid overwhelming the user. INFO gets absorbed, WARN gets mentioned, CRITICAL interrupts.

      Examples in ctx:

      • ctx system check-resources: Uses two tiers (WARNING/DANGER) internally but only fires the VERBATIM relay at DANGER level: WARNING is silent. See ctx system for the user-facing command that shows both tiers.

      Trade-off: Requires agent training or convention to recognize the tiers. Without a shared protocol, the prefixes are just text.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#choosing-a-pattern","level":2,"title":"Choosing a Pattern","text":"
      Is the agent about to do something forbidden?\n  └─ Yes → Hard gate\n\nDoes the user need to see this regardless of what they asked?\n  └─ Yes → VERBATIM relay\n  └─ Sometimes → Conditional relay\n\nShould the agent consider an action?\n  └─ Yes, with a specific fix → Suggested action\n  └─ Yes, open-ended → Agent directive\n\nIs this background context the agent should have?\n  └─ Yes → Silent injection\n\nIs this housekeeping?\n  └─ Yes → Silent side-effect\n
      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#design-tips","level":2,"title":"Design Tips","text":"

      Throttle aggressively: VERBATIM relays that fire every prompt will be ignored or resented. Use once-per-day markers (touch $REMINDED), adaptive frequency (every Nth prompt), or staleness checks (only fire if condition persists).

      Include actionable commands: \"You have 12 unimported sessions\" is less useful than \"You have 12 unimported sessions. Run: ctx journal import --all.\" Give the user (or agent) the exact next step.

      Use box-drawing for visual structure: The ┌─ ─┐ │ └─ ─┘ pattern makes hook output visually distinct from agent prose. It also signals \"this is machine-generated, not agent opinion.\"

      Test the silence path: Most hook runs should produce no output (the condition isn't met). Make sure the common case is fast and silent.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"

      Lessons from 19 days of hook debugging in ctx. Every one of these was encountered, debugged, and fixed in production.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#silent-misfire-wrong-key-name","level":3,"title":"Silent Misfire: Wrong Key Name","text":"
      { \"PreToolUseHooks\": [ ... ] }\n

      The key is PreToolUse, not PreToolUseHooks. Claude Code validates silently: A misspelled key means the hook is ignored with no error. Always test with a debug echo first to confirm the hook fires before adding real logic.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#json-escaping-breaks-shell-commands","level":3,"title":"JSON Escaping Breaks Shell Commands","text":"

      Go's json.Marshal escapes >, <, and & as Unicode sequences (\\u003e) by default. This breaks shell commands in generated config:

      \"command\": \"ctx agent 2\\u003e/dev/null\"\n

      Fix: use json.Encoder with SetEscapeHTML(false) when generating hook configuration.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#stdin-not-environment-variables","level":3,"title":"stdin, Not Environment Variables","text":"

      Hook input arrives as JSON via stdin, not environment variables:

      # Wrong:\nCOMMAND=\"$CLAUDE_TOOL_INPUT\"\n\n# Right:\nHOOK_INPUT=$(cat)\nCOMMAND=$(echo \"$HOOK_INPUT\" | jq -r '.tool_input.command // empty')\n
      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#regex-overfitting","level":3,"title":"Regex Overfitting","text":"

      A regex meant to catch ctx as a binary will also match ctx as a directory component:

      # Too broad: blocks: git -C /home/jose/WORKSPACE/ctx status\n(/home/|/tmp/|/var/)[^ ]*ctx[^ ]*\n\n# Narrow to binary only:\n(/home/|/tmp/|/var/)[^ ]*/ctx( |$)\n

      Test hook regexes against paths that contain the target string as a substring, not just as the final component.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#repetition-fatigue","level":3,"title":"Repetition Fatigue","text":"

      Injecting context on every tool call sounds safe. In practice, after seeing the same context injection fifteen times, the agent treats it as background noise: Conventions stated in the injected context get violated because salience has been destroyed by repetition.

      Fix: cooldowns. ctx agent --session $PPID --cooldown 10m injects at most once per ten minutes per session using a tombstone file in /tmp/. This is not an optimization; it is a correction for a design flaw. Every injection consumes attention budget: 50 tool calls at 4,000 tokens each means 200,000 tokens of repeated context, most of it wasted.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#hardcoded-paths","level":3,"title":"Hardcoded Paths","text":"

      A username rename (parallels to jose) broke every hook at once. Use $CLAUDE_PROJECT_DIR instead of absolute paths:

      \"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"/.claude/hooks/block-git-push.sh\"\n

      If the platform provides a runtime variable for paths, always use it.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#next-up","level":2,"title":"Next Up","text":"

      Webhook Notifications →: Get push notifications when loops complete, hooks fire, or agents hit milestones.

      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#see-also","level":2,"title":"See Also","text":"
      • Customizing Hook Messages: override what hooks say without changing what they do
      • Claude Code Permission Hygiene: how permissions and hooks work together
      • Defense in Depth: why hooks matter for agent security
      ","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/","level":1,"title":"Hook Sequence Diagrams","text":"","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#hook-lifecycle","level":2,"title":"Hook Lifecycle","text":"

      This page documents the ctx system hooks: the built-in ctx system * subcommands that Claude Code invokes via .claude/hooks.json at lifecycle events. These are owned by ctx itself, not authored by users.

      Not to Be Confused with ctx trigger

      ctx has three distinct hook-like layers:

      • ctx system hooks (this page): built-in, owned by ctx, wired into Claude Code via internal/assets/claude/hooks/hooks.json.
      • ctx trigger: user-authored shell scripts in .context/hooks/<type>/*.sh. See ctx trigger reference and the trigger authoring recipe.
      • Claude Code hooks configured directly in .claude/settings.local.json, tool-specific, not portable across AI tools.

      This page is only about the first category.

      Every ctx system hook is a Go binary invoked by Claude Code at one of three lifecycle events: PreToolUse (before a tool runs, can block), PostToolUse (after a tool completes), or UserPromptSubmit (on every user prompt, before any tools run). Hooks receive JSON on stdin and emit JSON or plain text on stdout.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#pretooluse-hooks","level":2,"title":"PreToolUse Hooks","text":"

      These fire before a tool executes. They can block, gate, or inject context.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#context-load-gate","level":3,"title":"Context-Load-Gate","text":"

      Matcher: .* (all tools)

      Injects the full context packet on first tool use of a session. One-shot per session.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as context-load-gate\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant Git as git log\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized\n    alt not initialized\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Check paused\n    alt paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check ctx-loaded-{session} marker\n    alt marker exists\n        Hook-->>CC: (silent exit, already fired)\n    end\n    Hook->>State: Create marker (one-shot guard)\n    Hook->>State: Prune stale session files\n    loop Each file in ReadOrder\n        alt GLOSSARY or TASK\n            Note over Hook: Skip (Task mentioned in footer only)\n        else DECISION or LEARNING\n            Hook->>Ctx: Extract index table only\n        else other files\n            Hook->>Ctx: Read full content\n        end\n        Hook->>Hook: Estimate tokens per file\n    end\n    Hook->>Git: Detect changes since last session\n    Hook->>Hook: Build injection (files + changes + token counts)\n    Hook-->>CC: JSON {additionalContext: injection}\n    Hook->>Hook: Send webhook (metadata only)\n    Hook->>State: Write oversize flag if tokens > threshold
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-non-path-ctx","level":3,"title":"Block-Non-Path-ctx","text":"

      Matcher: Bash

      Blocks ./ctx, go run ./cmd/ctx, or absolute-path ctx invocations. Constitutionally enforced.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as block-non-path-ctx\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Extract command\n    alt command empty\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Test regex: relative-path, go-run, absolute-path\n    alt no match\n        Hook-->>CC: (silent exit)\n    end\n    alt absolute-path + test exception\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, fallback)\n    Hook-->>CC: JSON {decision: BLOCK, reason + constitution suffix}\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#qa-reminder","level":3,"title":"Qa-Reminder","text":"

      Matcher: Bash

      Gate nudge before any git command. Reminds agent to lint/test.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as qa-reminder\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Check command contains \"git\"\n    alt no git command\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, gate, fallback)\n    Hook->>Hook: AppendDir(message)\n    Hook-->>CC: JSON {additionalContext: QA gate}\n    Hook->>Hook: Relay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#specs-nudge","level":3,"title":"Specs-Nudge","text":"

      Matcher: EnterPlanMode

      Nudges agent to save plans/specs when new implementation detected.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as specs-nudge\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook->>Hook: AppendDir(message)\n    Hook-->>CC: JSON {additionalContext: specs nudge}\n    Hook->>Hook: Relay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#posttooluse-hooks","level":2,"title":"PostToolUse Hooks","text":"

      These fire after a tool completes. They observe, nudge, and track state.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#post-commit","level":3,"title":"Post-Commit","text":"

      Matcher: Bash

      Fires after git commit (not amend). Nudges for context capture and checks version drift.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as post-commit\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Regex: command contains \"git commit\"?\n    alt not a git commit\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Regex: command contains \"--amend\"?\n    alt is amend\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook->>Hook: AppendDir(message)\n    Hook-->>CC: JSON {additionalContext: post-commit nudge}\n    Hook->>Hook: Relay(message)\n    Hook->>Hook: CheckVersionDrift()
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-task-completion","level":3,"title":"Check-Task-Completion","text":"

      Matcher: Edit, Write

      Configurable-interval nudge after edits. Per-session counter resets after firing.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-task-completion\n    participant State as .context/state/\n    participant RC as .ctxrc\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>RC: Read task nudge interval\n    alt interval <= 0 (disabled)\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Read per-session counter\n    Hook->>Hook: Increment counter\n    alt counter < interval\n        Hook->>State: Write counter\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Reset counter to 0\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook-->>CC: JSON {additionalContext: task nudge}\n    Hook->>Hook: Relay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#userpromptsubmit-hooks","level":2,"title":"UserPromptSubmit Hooks","text":"

      These fire on every user prompt, before any tools run. They perform health checks, track state, and nudge for housekeeping.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-context-size","level":3,"title":"Check-Context-Size","text":"

      Adaptive context window monitoring. Fires checkpoints, window warnings, and billing alerts based on prompt count and token usage.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-context-size\n    participant State as .context/state/\n    participant Session as Session JSONL\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized\n    Hook->>Hook: Read input, resolve session ID\n    Hook->>Hook: Check paused\n    alt paused\n        Hook-->>CC: Pause acknowledgment message\n    end\n    Hook->>State: Increment session prompt counter\n    Hook->>Session: Read token info (tokens, model, window)\n\n    rect rgb(255, 240, 240)\n        Note over Hook: Billing check (independent, never suppressed)\n        alt tokens >= billing threshold (one-shot)\n            Hook->>Tpl: LoadMessage(hook, billing, vars)\n            Hook-->>CC: Billing warning nudge box\n            Hook->>Hook: NudgeAndRelay(billing message)\n        end\n    end\n\n    Hook->>State: Check wrap-up marker\n    alt wrapped up recently (< 2h)\n        Hook->>State: Write stats (event: suppressed)\n        Hook-->>CC: (silent exit)\n    end\n\n    rect rgb(240, 248, 255)\n        Note over Hook: Adaptive frequency check\n        alt count > 30 and count % 3 == 0\n            Note over Hook: High frequency trigger\n        else count > 15 and count % 5 == 0\n            Note over Hook: Medium frequency trigger\n        else\n            Hook->>State: Write stats (event: silent)\n            Hook-->>CC: (silent exit)\n        end\n    end\n\n    alt context window >= 80%\n        Hook->>Tpl: LoadMessage(hook, window, vars)\n        Hook-->>CC: Window warning nudge box\n        Hook->>Hook: NudgeAndRelay(window message)\n    else checkpoint trigger\n        Hook->>Tpl: LoadMessage(hook, checkpoint)\n        Hook-->>CC: Checkpoint nudge box\n        Hook->>Hook: NudgeAndRelay(checkpoint message)\n    end\n    Hook->>State: Write session stats
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-ceremonies","level":3,"title":"Check-Ceremonies","text":"

      Daily check for /ctx-remember and /ctx-wrap-up usage in recent journal entries.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-ceremonies\n    participant State as .context/state/\n    participant Journal as Journal files\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Read recent files (lookback window)\n    alt no journal files\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Scan for /ctx-remember and /ctx-wrap-up\n    alt both ceremonies present\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, fallback)\n    Note over Hook: variant: both | remember | wrapup\n    Hook-->>CC: Nudge box (missing ceremonies)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-freshness","level":3,"title":"Check-Freshness","text":"

      Daily check for technology-dependent constants that may need review.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-freshness\n    participant State as .context/state/\n    participant FS as Filesystem\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>FS: Stat tracked files (5 source files)\n    alt all files modified within 6 months\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, stale, {StaleFiles})\n    Hook-->>CC: Nudge box (stale file list + review URL)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-journal","level":3,"title":"Check-Journal","text":"

      Daily check for unimported sessions and unenriched journal entries.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-journal\n    participant State as .context/state/\n    participant Journal as Journal dir\n    participant Claude as Claude projects dir\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Check dir exists\n    Hook->>Claude: Check dir exists\n    alt either dir missing\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Journal: Get newest entry mtime\n    Hook->>Claude: Count .jsonl files newer than journal\n    Hook->>Journal: Count unenriched entries\n    alt unimported == 0 and unenriched == 0\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, {counts})\n    Note over Hook: variant: both | unimported | unenriched\n    Hook-->>CC: Nudge box (counts)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-knowledge","level":3,"title":"Check-Knowledge","text":"

      Daily check for knowledge file entry/line counts exceeding configured thresholds.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-knowledge\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant RC as .ctxrc\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>RC: Read thresholds (decisions, learnings, conventions)\n    alt all thresholds disabled (0)\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Ctx: Parse DECISIONS.md entry count\n    Hook->>Ctx: Parse LEARNINGS.md entry count\n    Hook->>Ctx: Count CONVENTIONS.md lines\n    Hook->>Hook: Compare against thresholds\n    alt all within limits\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, warning, {FileWarnings})\n    Hook-->>CC: Nudge box (file warnings)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-map-staleness","level":3,"title":"Check-Map-Staleness","text":"

      Daily check for architecture map age and relevant code changes.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-map-staleness\n    participant State as .context/state/\n    participant Tracking as map-tracking.json\n    participant Git as git log\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tracking: Read map-tracking.json\n    alt missing, invalid, or opted out\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Parse LastRun date\n    alt map not stale (< N days)\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Git: Count commits touching internal/ since LastRun\n    alt no relevant commits\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, stale, {date, count})\n    Hook-->>CC: Nudge box (last refresh + commit count)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle marker
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-memory-drift","level":3,"title":"Check-Memory-Drift","text":"

      Per-session check for MEMORY.md changes since last sync.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-memory-drift\n    participant State as .context/state/\n    participant Mem as memory.Discover\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check session tombstone\n    alt already nudged this session\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Mem: DiscoverMemoryPath(projectRoot)\n    alt auto memory not active\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Mem: HasDrift(contextDir, sourcePath)\n    alt no drift\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, fallback)\n    Hook-->>CC: Nudge box (drift reminder)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch session tombstone
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-persistence","level":3,"title":"Check-Persistence","text":"

      Tracks context file modification and nudges when edits happen without persisting context. Adaptive threshold based on prompt count.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-persistence\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Read persistence state {Count, LastNudge, LastMtime}\n    alt first prompt (no state)\n        Hook->>State: Initialize state {Count:1, LastNudge:0, LastMtime:now}\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Increment Count\n    Hook->>Ctx: Get current context mtime\n    alt context modified since LastMtime\n        Hook->>State: Reset LastNudge = Count, update LastMtime\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: sinceNudge = Count - LastNudge\n    Hook->>Hook: PersistenceNudgeNeeded(Count, sinceNudge)?\n    alt threshold not reached\n        Hook->>State: Write state\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, nudge, vars)\n    Hook-->>CC: Nudge box (prompt count, time since last persist)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Update LastNudge = Count, write state
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-reminders","level":3,"title":"Check-Reminders","text":"

      Per-prompt check for due reminders. No throttle.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-reminders\n    participant Store as Reminders store\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Store: ReadReminders()\n    alt load error\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Filter by due date (After <= today)\n    alt no due reminders\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, reminders, {list})\n    Hook-->>CC: Nudge box (reminder list + dismiss hints)\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-resources","level":3,"title":"Check-Resources","text":"

      Checks system resources (memory, swap, disk, load). Fires on every prompt. No initialization required.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-resources\n    participant Sys as sysinfo\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: HookPreamble (parse input, check pause)\n    alt paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Sys: Collect snapshot (memory, swap, disk, load)\n    Hook->>Sys: Evaluate thresholds per metric\n    alt max severity < Danger\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Filter alerts to Danger level only\n    Hook->>Hook: Build alertMessages from danger alerts\n    Hook->>Tpl: LoadMessage(hook, alert, {alertMessages}, fallback)\n    Hook-->>CC: Nudge box (danger alerts)\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-version","level":3,"title":"Check-Version","text":"

      Daily binary-vs-plugin version comparison with piggybacked key rotation check.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as check-version\n    participant State as .context/state/\n    participant Config as Binary + Plugin version\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Check daily throttle marker\n    alt throttled\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Config: Read binary version\n    alt dev build\n        Hook->>State: Touch throttle\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Config: Read plugin version\n    alt plugin version not found or parse error\n        Hook->>State: Touch throttle\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Hook: Compare major.minor\n    alt versions match\n        Hook->>State: Touch throttle\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, mismatch, {versions})\n    Hook-->>CC: Nudge box (version mismatch)\n    Hook->>Hook: NudgeAndRelay(message)\n    Hook->>State: Touch throttle\n    Hook->>Hook: CheckKeyAge() (piggybacked)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#heartbeat","level":3,"title":"Heartbeat","text":"

      Silent per-prompt pulse. Tracks prompt count, context modification, and token usage. The agent never sees this hook's output.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as heartbeat\n    participant State as .context/state/\n    participant Ctx as .context/ files\n    participant Notify as Webhook + EventLog\n\n    CC->>Hook: stdin {session_id}\n    Hook->>Hook: Check initialized + HookPreamble\n    alt not initialized or paused\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>State: Increment heartbeat counter\n    Hook->>Ctx: Get latest context file mtime\n    Hook->>State: Compare with last recorded mtime\n    Hook->>State: Update mtime record\n    Hook->>State: Read session token info\n    Hook->>Notify: Send heartbeat notification\n    Hook->>Notify: Append to event log\n    Hook->>State: Write heartbeat log entry\n    Note over Hook: No stdout - agent never sees this
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#project-local-hooks","level":2,"title":"Project-Local Hooks","text":"

      These hooks are configured in settings.local.json and are not shipped with ctx. They are specific to individual developer setups.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-dangerous-commands","level":3,"title":"Block-Dangerous-Commands","text":"

      Lifecycle: PreToolUse. Matcher: Bash

      Blocks dangerous shell patterns (sudo, git push, cp to bin). No initialization or pause checks: always active.

      sequenceDiagram\n    participant CC as Claude Code\n    participant Hook as block-dangerous-commands\n    participant Tpl as Message Template\n\n    CC->>Hook: stdin {command, session_id}\n    Hook->>Hook: Extract command\n    alt command empty\n        Hook-->>CC: (silent exit)\n    end\n    Note over Hook: Cascade: first matching regex wins\n    Hook->>Hook: Test MidSudo regex\n    alt match\n        Hook->>Hook: variant = sudo\n    end\n    Hook->>Hook: Test MidGitPush regex (if no variant)\n    alt match\n        Hook->>Hook: variant = git-push\n    end\n    Hook->>Hook: Test CpMvToBin regex (if no variant)\n    alt match\n        Hook->>Hook: variant = cp-to-bin\n    end\n    Hook->>Hook: Test InstallToLocalBin regex (if no variant)\n    alt match\n        Hook->>Hook: variant = install-to-bin\n    end\n    alt no variant matched\n        Hook-->>CC: (silent exit)\n    end\n    Hook->>Tpl: LoadMessage(hook, variant, fallback)\n    Hook-->>CC: JSON {decision: BLOCK, reason}\n    Hook->>Hook: NudgeAndRelay(message)
      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#throttling-summary","level":2,"title":"Throttling Summary","text":"Hook Lifecycle Throttle Type Scope context-load-gate PreToolUse One-shot marker Per session block-non-path-ctx PreToolUse None Every match qa-reminder PreToolUse None Every git command specs-nudge PreToolUse None Every prompt post-commit PostToolUse None Every git commit check-task-completion PostToolUse Configurable interval Per session check-context-size UserPromptSubmit Adaptive counter Per session check-ceremonies UserPromptSubmit Daily marker Once per day check-freshness UserPromptSubmit Daily marker Once per day check-journal UserPromptSubmit Daily marker Once per day check-knowledge UserPromptSubmit Daily marker Once per day check-map-staleness UserPromptSubmit Daily marker Once per day check-memory-drift UserPromptSubmit Session tombstone Once per session check-persistence UserPromptSubmit Adaptive counter Per session check-reminders UserPromptSubmit None Every prompt check-resources UserPromptSubmit None Every prompt check-version UserPromptSubmit Daily marker Once per day heartbeat UserPromptSubmit None Every prompt block-dangerous-commands PreToolUse * None Every match

      * Project-local hook (settings.local.json), not shipped with ctx.

      ","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#state-file-reference","level":2,"title":"State File Reference","text":"

      All state files live in .context/state/.

      File Pattern Hook Purpose ctx-loaded-{session} context-load-gate One-shot injection marker ctx-paused-{session} (all) Session pause marker ctx-wrapped-up check-context-size Suppress nudges after wrap-up (2h expiry) freshness-checked check-freshness Daily throttle ceremony-reminded check-ceremonies Daily throttle journal-reminded check-journal Daily throttle knowledge-reminded check-knowledge Daily throttle map-staleness-reminded check-map-staleness Daily throttle version-checked check-version Daily throttle memory-drift-nudged-{session} check-memory-drift Per-session tombstone ctx-context-count-{session} check-context-size Prompt counter stats-{session}.jsonl check-context-size Session stats log persist-{session} check-persistence Counter + mtime state ctx-task-count-{session} check-task-completion Prompt counter heartbeat-count-{session} heartbeat Prompt counter heartbeat-mtime-{session} heartbeat Last context mtime","path":["Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hub-cluster/","level":1,"title":"HA Cluster","text":"","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#ctx-hub-high-availability-cluster","level":1,"title":"ctx Hub: High-Availability Cluster","text":"

      Run multiple hub nodes with Raft-based leader election for redundancy. Any follower can take over if the leader dies.

      This recipe assumes you've read the ctx Hub overview and the Multi-machine setup. HA only makes sense in the \"small trusted team\" story; a personal cross-project brain on one workstation does not need three Raft peers.

      Raft-Lite

      ctx uses Raft only for leader election, not for data consensus. Entry replication happens via sequence-based gRPC sync on the append-only JSONL store. This is simpler than full Raft log replication and is possible because the store is append-only and clients are idempotent. The implication: a write accepted by the leader is durable on the leader immediately; followers catch up asynchronously. If the leader crashes between accepting a write and replicating it, that write can be lost. Do not use the hub as a bank ledger.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#topology","level":2,"title":"Topology","text":"

      A minimum HA cluster is three nodes. Two is worse than one: it doubles failure probability without providing quorum.

               +-------------+\n         |  client(s)  |\n         +------+------+\n                |\n    +-----------+-----------+\n    |           |           |\n+---v---+   +---v---+   +---v---+\n| hub A |   | hub B |   | hub C |\n| :9900 |   | :9900 |   | :9900 |\n+-------+   +-------+   +-------+\n    ^           ^           ^\n    +-----------+-----------+\n        Raft (leader election)\n        gRPC (data sync)\n
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-1-bootstrap-the-first-node","level":2,"title":"Step 1: Bootstrap the First Node","text":"
      ctx hub start --daemon \\\n  --port 9900 \\\n  --peers hub-b.lan:9900,hub-c.lan:9900\n

      The node starts a Raft election as soon as it sees its peers.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-2-start-the-other-nodes","level":2,"title":"Step 2: Start the Other Nodes","text":"

      On hub-b.lan:

      ctx hub start --daemon \\\n  --port 9900 \\\n  --peers hub-a.lan:9900,hub-c.lan:9900\n

      On hub-c.lan:

      ctx hub start --daemon \\\n  --port 9900 \\\n  --peers hub-a.lan:9900,hub-b.lan:9900\n

      After a few seconds, one node wins the election and becomes the leader. The other two are followers.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-3-verify-cluster-state","level":2,"title":"Step 3: Verify Cluster State","text":"

      From any node:

      ctx hub status\n

      Expected output:

      role:       leader\npeers:      hub-a.lan:9900 (leader)\n            hub-b.lan:9900 (follower, in-sync)\n            hub-c.lan:9900 (follower, in-sync)\nentries:    1248\nuptime:     3h42m\n
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-4-register-clients-with-failover-peers","level":2,"title":"Step 4: Register Clients with Failover Peers","text":"

      The ctx hub * commands above run on the hub nodes themselves and don't need a project. The ctx connection * commands below are different: they live inside a project (the encrypted hub config is stored at .context/.connect.enc), so you have to tell ctx which project first.

      When registering a client, give it the full peer list:

      # In the project directory on the client:\neval \"$(ctx activate)\"\nctx connection register hub-a.lan:9900 \\\n  --token ctx_adm_... \\\n  --peers hub-b.lan:9900,hub-c.lan:9900\n

      If the leader becomes unreachable, the client reconnects to the next peer. Followers redirect to the current leader, so writes always land on the right node.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#runtime-membership-changes","level":2,"title":"Runtime Membership Changes","text":"

      Add a new peer without downtime:

      ctx hub peer add hub-d.lan:9900\n

      Remove a decommissioned peer:

      ctx hub peer remove hub-c.lan:9900\n
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#planned-maintenance","level":2,"title":"Planned Maintenance","text":"

      Before taking a leader offline, hand off leadership:

      ssh hub-a.lan 'ctx hub stepdown'\n

      stepdown triggers a new election among the remaining followers before the leader goes offline. In-flight clients briefly pause, then reconnect to the new leader.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#failure-modes-at-a-glance","level":2,"title":"Failure Modes at a Glance","text":"Event What happens Leader crashes New election; clients reconnect to new leader Follower crashes No write impact; catches up on restart Network partition (majority) Majority side keeps serving; minority read-only Network partition (split) No quorum; all nodes read-only Disk full on leader Writes rejected; read traffic continues

      For the full list, see Hub failure modes.

      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#see-also","level":2,"title":"See Also","text":"
      • Multi-machine recipe: single-node deployment
      • Hub operations: backup and maintenance
      • Hub security model: TLS, tokens
      ","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-getting-started/","level":1,"title":"Getting Started","text":"","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#ctx-hub-getting-started","level":1,"title":"ctx Hub: Getting Started","text":"

      Stand up a single-node ctx Hub on localhost, register two projects, publish a decision from one, and see it appear in the other, all in under five minutes.

      Read This First

      If you haven't already, skim the ctx Hub overview. It explains the mental model, names the two user stories (personal vs small team), and (importantly) lists what the hub does not do. This recipe assumes you already know you want the feature.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#what-youll-get-out-of-this-recipe","level":2,"title":"What You'll Get out of This Recipe","text":"

      By the end, you will have:

      1. A local hub process running on port 9900.
      2. Two project directories both registered with the ctx Hub.
      3. A decision published from project alpha that appears automatically in project beta's .context/hub/ and in ctx agent --include-hub output.

      Concretely, the payoff this unlocks: a lesson you record in one project becomes visible to your agent the next time you open another project, without touching local files in the second project or opening another editor window.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#what-this-recipe-does-not-cover","level":2,"title":"What This Recipe Does Not Cover","text":"
      • Sharing .context/journal/, .context/pad, or any other local state. The hub only fans out decision, learning, convention, and task entries. Everything else stays local.
      • Multi-user attribution. The hub identifies projects, not people.
      • Running over a LAN; see Multi-machine setup.
      • Redundancy; see HA cluster.
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#prerequisites","level":2,"title":"Prerequisites","text":"
      • ctx installed and on PATH
      • Two project directories, each already initialized with ctx init
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-1-start-the-hub","level":2,"title":"Step 1: Start the Hub","text":"

      In a dedicated terminal:

      ctx hub start\n

      On first run, the hub generates an admin token and prints it to stdout. Copy it; you'll need it for each project registration:

      ctx hub listening on :9900\nadmin token: ctx_adm_7f3a1c2d...\ndata dir: ~/.ctx/hub-data/\n

      The admin token is written to ~/.ctx/hub-data/admin.token so you can recover it later. Treat it like a password.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-2-register-the-first-project","level":2,"title":"Step 2: Register the First Project","text":"

      ctx hub start above runs on the hub server and doesn't need a project. Step 2 is different: the encrypted hub config is stored inside a project at .context/.connect.enc, so you have to tell ctx which project first.

      cd ~/projects/alpha\neval \"$(ctx activate)\"\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\n

      This stores an encrypted connection config in .context/.connect.enc. The admin token is exchanged for a per-project client token; the admin token itself is never persisted in the project.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-3-choose-what-to-receive","level":2,"title":"Step 3: Choose What to Receive","text":"
      ctx connection subscribe decision learning convention\n

      Only the entry types you subscribe to will be delivered by sync and listen.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-4-publish-a-decision","level":2,"title":"Step 4: Publish a Decision","text":"

      Either use ctx add --share to write locally and push to the ctx Hub:

      ctx decision add \"Use UTC timestamps everywhere\" --share \\\n  --context \"We had timezone drift between the API and journal\" \\\n  --rationale \"Single source of truth avoids conversion bugs\" \\\n  --consequence \"The UI does conversion at render time\"\n

      Or publish an existing entry directly:

      ctx connection publish decision \"Use UTC timestamps everywhere\"\n
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-5-register-a-second-project-and-sync","level":2,"title":"Step 5: Register a Second Project and Sync","text":"
      cd ~/projects/beta\neval \"$(ctx activate)\"   # bind CTX_DIR for this project\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\nctx connection subscribe decision learning convention\nctx connection sync\n

      The decision from alpha now appears in ~/projects/beta/.context/hub/decisions.md with an origin tag and timestamp.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-6-watch-entries-arrive-live","level":2,"title":"Step 6: Watch Entries Arrive Live","text":"

      Instead of re-running sync, stream new entries as they land:

      ctx connection listen\n

      Leave this running in a terminal; every --share publish from any registered project will appear in .context/hub/ immediately.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#step-7-feed-shared-knowledge-into-the-agent","level":2,"title":"Step 7: Feed Shared Knowledge into the Agent","text":"

      Once entries exist in .context/hub/, include them in the agent context packet:

      ctx agent --include-hub\n

      Shared entries are added as a dedicated tier in the budget-aware assembly, scored by recency and type relevance.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#auto-sync-on-session-start","level":2,"title":"Auto-Sync on Session Start","text":"

      After register, the check-hub-sync hook pulls new entries at the start of each session (daily throttled). Most users never need to call ctx connection sync manually.

      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#where-to-go-next","level":2,"title":"Where to Go Next","text":"
      • Multi-machine hub: run the hub on a LAN host and connect from other workstations.
      • HA cluster: Raft-based leader election for high availability.
      • Hub operations: daemon mode, backup, log rotation, JSONL store layout.
      • Hub security model: token lifecycle, encryption at rest, threat model.
      • ctx connect reference and ctx hub start reference.
      ","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-multi-machine/","level":1,"title":"Multi-Machine","text":"","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#ctx-hub-multi-machine","level":1,"title":"ctx Hub: Multi-Machine","text":"

      Run the hub on a LAN host and connect from project directories on other workstations. This recipe is the Story 2 (\"small trusted team\") shape described in the ctx Hub overview; read that first if you haven't, especially the trust-model warnings.

      This recipe assumes you've already walked through Getting Started and understand what flows through the hub (decisions, learnings, conventions, tasks, not journals, scratchpad, or raw context files).

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#topology","level":2,"title":"Topology","text":"
      +------------------+        +------------------+\n| workstation A    |        | workstation B    |\n|  ~/projects/x    |        |  ~/projects/y    |\n|  ctx connection  |        |  ctx connection  |\n+---------+--------+        +---------+--------+\n          |                           |\n          +-----------+   +-----------+\n                      v   v\n              +-------------------+\n              | LAN host \"nexus\"  |\n              | ctx hub start     |\n              | --daemon          |\n              | :9900             |\n              +-------------------+\n
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-1-start-the-daemon-on-the-lan-host","level":2,"title":"Step 1: Start the Daemon on the LAN Host","text":"

      On the machine that will hold the hub (call it nexus):

      ctx hub start --daemon --port 9900\n

      The daemon writes a PID file to ~/.ctx/hub-data/hub.pid. Stop it later with:

      ctx hub stop\n
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-2-firewall-and-port","level":2,"title":"Step 2: Firewall and Port","text":"

      Open port 9900/tcp on nexus to the LAN only. Never expose the hub to the public internet without a reverse proxy and TLS in front of it (see Hub security model).

      Typical LAN allowlist rules:

      firewalldufwnftables
      sudo firewall-cmd --zone=internal \\\n  --add-port=9900/tcp --permanent\nsudo firewall-cmd --reload\n
      sudo ufw allow from 192.168.1.0/24 to any port 9900 proto tcp\n
      sudo nft add rule inet filter input ip saddr 192.168.1.0/24 \\\n  tcp dport 9900 accept\n
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-3-retrieve-the-admin-token","level":2,"title":"Step 3: Retrieve the Admin Token","text":"

      The daemon prints the admin token to stdout on first run. Running as a daemon, that output goes to the log instead:

      cat ~/.ctx/hub-data/admin.token\n

      Copy the token over a trusted channel (SSH, password manager, or an encrypted note). Do not email it or put it in chat.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-4-register-projects-from-each-workstation","level":2,"title":"Step 4: Register Projects from Each Workstation","text":"

      The ctx hub * commands above run on the LAN host (nexus) and don't need a project. Step 4 is different: each workstation registers from inside a project (the encrypted hub config and the fan-out inbox both live under .context/), so you have to tell ctx which project first.

      On workstation A:

      cd ~/projects/x\neval \"$(ctx activate)\"\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n

      On workstation B:

      cd ~/projects/y\neval \"$(ctx activate)\"\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n

      Each registration exchanges the admin token for a per-project client token. Only the client token is persisted in .context/.connect.enc, encrypted with the same AES-256-GCM scheme ctx uses for notification credentials.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-5-verify","level":2,"title":"Step 5: Verify","text":"

      From either workstation:

      ctx connection status\n

      You should see the ctx Hub address, role (leader for single-node), subscription filters, and the sequence number you're synced to.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#tls-recommended","level":2,"title":"TLS (Recommended)","text":"

      For anything beyond a trusted home LAN, terminate TLS in front of the hub. The hub speaks gRPC, so the reverse proxy must speak HTTP/2:

      server {\n    listen 443 ssl http2;\n    server_name nexus.example.com;\n\n    ssl_certificate     /etc/letsencrypt/live/nexus.example.com/fullchain.pem;\n    ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;\n\n    location / {\n        grpc_pass grpc://127.0.0.1:9900;\n    }\n}\n

      Point ctx connection register at the public hostname and port 443.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#handling-daemon-restarts","level":2,"title":"Handling Daemon Restarts","text":"

      The hub is append-only JSONL, so restarts are safe. Clients keep their last-seen sequence in .context/hub/.sync-state.json and pick up exactly where they left off on the next sync or listen reconnect.

      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#see-also","level":2,"title":"See Also","text":"
      • HA cluster recipe: for redundancy
      • Hub operations: backup, rotation
      • Hub failure modes
      • Hub security model
      ","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-overview/","level":1,"title":"Overview","text":"","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#ctx-hub-overview","level":1,"title":"ctx Hub: Overview","text":"

      Start here before the other hub recipes. This page answers what the hub is, who it's for, why you'd run one, and, equally important, what it is not.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#mental-model-in-one-paragraph","level":2,"title":"Mental Model in One Paragraph","text":"

      The hub is a fan-out channel for structured knowledge entries across projects. When you publish a decision, learning, convention, or task with --share, the hub stores it in an append-only log and delivers it to every other project subscribed to that type. The next time your agent loads context in any of those projects, shared entries can be included in the context packet alongside local ones.

      That's the whole feature. It is a project-to-project knowledge bus for a small, curated set of entry types. It is not a shared memory, a shared journal, or a multi-user database.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#what-flows-through-the-hub","level":2,"title":"What Flows through the Hub","text":"

      Only four entry types:

      Type What it is decision Architectural decisions with rationale learning Gotchas, lessons, surprising behaviors convention Coding patterns and standards task Work items worth sharing across projects

      Each entry is an immutable record with a content blob, the publishing project's name as Origin, a timestamp, and a hub-assigned sequence number. Once published, entries are never rewritten.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#what-does-not-flow-through-the-hub","level":2,"title":"What Does Not Flow through the Hub","text":"

      This is the part new users get wrong most often:

      • Session journals (~/.claude/ logs, .context/journal/) stay local. The hub does not sync your AI session history.
      • Scratchpad (.context/pad) stays local. Encrypted notes never leave the machine they were written on.
      • Local context files as a whole (TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md) are not mirrored wholesale. Only entries you explicitly --share, or publish later with ctx connection publish, cross the boundary.
      • Anything under .context/ that isn't one of the four entry types above. Configuration, state, logs, memory, journal metadata: all local.

      If you were expecting \"now my agent in project B can see everything my agent did in project A,\" that's not this feature. Local session density still lives on the local machine.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#two-user-stories","level":2,"title":"Two User Stories","text":"

      The hub makes sense in two different shapes. Pick the one that matches your situation; the mechanics are identical but the trust model and threat surface are very different.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#story-1-personal-cross-project-brain","level":3,"title":"Story 1: Personal Cross-Project Brain","text":"

      One developer, many projects, one hub, usually on localhost.

      You're working across several projects on the same machine (or a handful of machines you own). You want a lesson learned debugging project A to show up when you open project B a week later, without re-discovering it. You want a convention you codified in one project to be visible as-you-type in another.

      Concrete payoff:

      • ctx learning add --share \"...\" in project A → ctx agent --include-hub in project B shows that learning in the next context packet.
      • A decision recorded in your personal \"dotfiles\" project is instantly visible to every other project on your workstation.
      • Cross-project conventions (e.g., \"use UTC timestamps everywhere\") live in one place and propagate.

      Trust model: high, because you trust every participant since every participant is you. Run the hub on localhost or on your own LAN, use the default single-node setup, don't worry about TLS.

      Start here: Getting Started for the one-time setup, then Personal cross-project brain for the day-to-day workflow.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#story-2-small-trusted-team","level":3,"title":"Story 2: Small Trusted Team","text":"

      A few teammates, projects they each own, one hub on a LAN host they all trust.

      Your team has a handful of services and you want a shared \"things we've learned the hard way\" stream. Someone on the platform team records a convention about timestamp handling; everyone else's agents see it the next session. An on-call engineer records a learning from a 3 AM incident; the rest of the team inherits the lesson without needing to read the postmortem.

      Concrete payoff:

      • Team conventions propagate without needing a wiki or chat.
      • Lessons from one team member become available to everyone else's agent context packets automatically.
      • Cross-project decisions (shared libraries, deployment patterns, naming rules) live in a single log the whole team reads.

      Trust model: the hub assumes everyone holding a client token is friendly. There is no per-user attribution you can rely on, Origin is self-asserted by the publishing client, and there is no read ACL beyond the subscription filter. Treat the hub like a team wiki: useful because everyone can write to it, not because it can prove who wrote what.

      Operational shape: run the hub on a LAN host (or a three-node HA cluster for redundancy), put TLS in front of it for anything beyond a home LAN, distribute client tokens over a trusted channel.

      Start here: Multi-machine setup for the deployment, Team knowledge bus for the day-to-day team workflow, then HA cluster if you need redundancy.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#identity-projects-not-users","level":2,"title":"Identity: Projects, Not Users","text":"

      The hub has no concept of users. Its unit of identity is the project. ctx connection register binds a hub token to a project directory, not to a person. Two developers working on the same project share either:

      • The same .connect.enc, copied between machines over a trusted channel, or
      • Different project names (alpha@laptop-a, alpha@laptop-b), because the hub rejects duplicate registrations of the same project name.

      Either works; neither gives you per-human attribution. If you need \"who wrote this,\" the hub is the wrong tool.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#when-not-to-use-it","level":2,"title":"When Not to Use It","text":"
      • Solo, single-project work. Local .context/ files are enough. The hub adds operational surface for no payoff.
      • Untrusted participants. The hub assumes everyone with a client token is friendly. It is not hardened against hostile insiders or compromised tokens.
      • Compliance-sensitive environments. There is no audit trail that can prove who published what, only which project published what, and Origin is self-asserted.
      • Secrets or PII. Entry content is stored plaintext on the hub and fanned out to every subscribed client. Don't publish anything you wouldn't paste in a team chat.
      • Wholesale journal sharing. See \"what does not flow\" above. If that's what you want, this feature won't provide it. Talk to us in the issue tracker about what would.
      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#how-entries-reach-your-agent","level":2,"title":"How Entries Reach Your Agent","text":"

      Once a project is registered and subscribed, entries arrive by three mechanisms:

      1. ctx connection sync: an on-demand pull, replays everything new since the last sequence you saw.
      2. ctx connection listen: a long-lived gRPC stream that writes new entries to .context/hub/ as they arrive.
      3. check-hub-sync hook: runs at session start, daily throttled, so most users never call sync manually.

      Once entries exist in .context/hub/, ctx agent --include-hub adds a dedicated tier to the budget-aware context packet, scored by recency and type relevance. That's the end of the pipeline.

      ","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#where-to-go-next","level":2,"title":"Where to Go Next","text":"If you're… Read Trying it for yourself on one machine Getting Started A solo developer using the hub day-to-day Personal cross-project brain Setting up for a small team on a LAN Multi-machine setup A small team using the hub day-to-day Team knowledge bus Running redundant nodes HA cluster Operating a hub in production Operations Assessing the security posture Security model Debugging a hub in trouble Failure modes Just reading the commands ctx connect, ctx serve, ctx hub","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-personal/","level":1,"title":"Personal Cross-Project Brain","text":"","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#personal-cross-project-brain","level":1,"title":"Personal Cross-Project Brain","text":"

      This recipe shows how one developer uses a ctx Hub across their own projects day-to-day, the \"Story 1\" shape from the Hub overview. You're not setting up infrastructure for a team; you're making a lesson you learned last Tuesday in project A automatically surface when you open project B next Thursday.

      Prerequisites: a working ctx Hub on localhost (see Getting Started for the roughly five-minute setup). This recipe assumes the hub is already running and you've registered at least two projects.

      Activate Each Project First

      Run eval \"$(ctx activate)\" after each cd <project> (or wire it into direnv). The hub server (ctx hub start, etc.) runs on the server and doesn't need this; the commands in this recipe (ctx add --share, ctx agent --include-hub, ctx connection ...) live inside a project and do. If you skip the eval, they'll fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#the-core-loop","level":2,"title":"The Core Loop","text":"

      Every day, the same three verbs matter:

      1. Record: notice a decision, learning, or convention and capture it with ctx add --share.
      2. Subscribe: every project you care about is subscribed to the types you want delivered (set once with ctx connection subscribe).
      3. Load: your agent picks up shared entries on next session start via the auto-sync hook, or explicitly via ctx agent --include-hub.

      That's the whole workflow. The rest of this recipe fills in the concrete moments where each verb matters.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#a-realistic-day","level":2,"title":"A Realistic Day","text":"

      You have three projects on your workstation:

      • ~/projects/api, a Go service you're actively developing
      • ~/projects/cli, a companion CLI that consumes the API
      • ~/projects/dotfiles, your personal conventions and cross-project learnings

      All three are registered with a single hub running on localhost:9900 (started once at boot, or via a systemd user unit; see Hub operations). All three subscribe to decision, learning, and convention.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#0900-start-work-on-api","level":3,"title":"09:00 - Start Work on api","text":"

      You cd ~/projects/api and start a Claude Code session. Behind the scenes, the plugin's PreToolUse hook calls ctx agent --budget 8000 --include-hub before the first tool call. Agent loads:

      • Local .context/ (TASKS, DECISIONS, LEARNINGS, etc.)
      • Foundation steering files (always-inclusion)
      • Everything you've shared from the other two projects

      So the \"use UTC timestamps everywhere\" decision you recorded in dotfiles last week is already in Claude's context for this session, without any manual sync.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1030-you-discover-a-gotcha","level":3,"title":"10:30 - You Discover a Gotcha","text":"

      While debugging, you find that the API's retry loop silently drops the last error when the transport times out. This is the kind of thing you'd normally add to LEARNINGS.md in api/. But it's useful across every Go service you'll ever write, not just this one. So:

      ctx learning add --share \\\n  --context \"Go http.Client retries mask the final error\" \\\n  --lesson  \"Transport timeouts don't surface as errors when the retry loop re-assigns err without wrapping. Check for context.DeadlineExceeded on the request context instead.\" \\\n  --application \"Any retry loop over http.Client.Do that uses a per-attempt timeout\"\n

      The --share flag does two things:

      1. Writes the learning to api/.context/LEARNINGS.md locally (as a normal ctx learning add would).
      2. Publishes the same entry to the ctx Hub, which stores it in the append-only JSONL and fans it out to every subscribed client.

      Within seconds, cli/.context/hub/learnings.md and dotfiles/.context/hub/learnings.md both contain a copy of this learning (the ctx connection listen daemon picks it up from the ctx Hub's Listen stream).

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1200-you-switch-to-cli","level":3,"title":"12:00 - You Switch to cli","text":"

      cd ~/projects/cli, open a new session. The agent packet for cli now includes the learning you just recorded in api, because cli is subscribed to learning and the entry has already been synced into cli/.context/hub/learnings.md.

      You don't have to re-explain the retry-loop gotcha. Claude already sees it.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1400-you-codify-a-convention","level":3,"title":"14:00 - You Codify a Convention","text":"

      You've been writing error messages in api and decided you want a consistent pattern: lowercase start, no trailing period, single-sentence. This is a convention, not a decision; it applies to every Go project you touch. Record it in dotfiles (since that's your \"personal standards\" project), and share it:

      cd ~/projects/dotfiles\nctx convention add --share \\\n  \"Error messages: lowercase start, no trailing period, single sentence (follows Go's stdlib style)\"\n

      The convention lands in dotfiles/CONVENTIONS.md locally and fans out to api and cli via the hub. The next Claude Code session in either project gets the convention injected into the steering-adjacent slot of the agent packet.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#1630-end-of-day","level":3,"title":"16:30 - End of Day","text":"

      You didn't run ctx connection sync once. You didn't git push anything between projects. You didn't remember to tell your agent about the retry-loop gotcha in the new project. The hub did all of it for you.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#what-the-workflow-actually-looks-like","level":2,"title":"What the Workflow Actually Looks Like","text":"

      Stripped of prose, the day's commands were:

      # Morning: nothing. Agent loads --include-hub automatically.\n\n# Mid-morning: record a learning that should cross projects\nctx learning add --share \\\n  --context \"...\" --lesson \"...\" --application \"...\"\n\n# Afternoon: codify a convention in the \"standards\" project\nctx convention add --share \"...\"\n\n# Evening: nothing. Everything's already propagated.\n

      The hub is passive infrastructure. You never talk to it directly; you talk through it by using --share on commands you were already running.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#tips-for-solo-use","level":2,"title":"Tips for Solo Use","text":"

      Pick a \"standards\" project. One of your projects should play the role of \"canonical source for rules you want everywhere.\" Your dotfiles, a personal scratch repo, or a dedicated ctx-standards project all work. Record cross-cutting conventions there and let the hub propagate them to everything else.

      Subscribe to task only if you want cross-project todos. The four subscribable types are decision, learning, convention, task. Tasks are usually project-local; subscribing makes every hub-shared task from every project show up in every other project's agent packet. That's probably not what you want. Skip task in ctx connection subscribe unless you have a specific reason.

      Run the hub as a user-level daemon so you don't have to remember to start it. On Linux with systemd:

      # ~/.config/systemd/user/ctx-hub.service\n[Unit]\nDescription=ctx Hub (personal)\n\n[Service]\nType=simple\nExecStart=/usr/local/bin/ctx hub start\nRestart=on-failure\n\n[Install]\nWantedBy=default.target\n
      systemctl --user enable --now ctx-hub.service\n

      Don't overthink subscription filters. For personal use, subscribe every project to all four types at first (or three, if you skip task). Tune later if the context packets get noisy.

      Local storage is fine; no TLS needed. The hub runs on localhost. No one else is on the network. Skip the TLS setup from the Multi-machine recipe; it's relevant when the hub is on a LAN host serving multiple workstations, not when it's a personal daemon.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#what-this-recipe-is-not","level":2,"title":"What This Recipe Is Not","text":"

      Not a setup guide. For the one-time hub install and project registration, use Getting Started.

      Not a team guide. If you're sharing across humans, not just across your own projects, read Team knowledge bus instead; the trust model and operational concerns are different.

      Not production operations. For backup, log rotation, failure recovery, and HA, see Hub operations and Hub failure modes.

      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#see-also","level":2,"title":"See Also","text":"
      • Hub overview: when to use the Hub and when not to.
      • Team knowledge bus: the multi-human companion recipe.
      • ctx connect: the client-side commands used above (subscribe, publish, sync, listen, status).
      • ctx add: the --share flag reference.
      • ctx hub: operator commands for starting, stopping, and inspecting the hub.
      ","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-team/","level":1,"title":"Team Knowledge Bus","text":"","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#team-knowledge-bus","level":1,"title":"Team Knowledge Bus","text":"

      This recipe shows how a small trusted team uses a ctx Hub as a shared knowledge bus, the \"Story 2\" shape from the Hub overview. You're not building a wiki, you're not replacing your issue tracker, and you're not running a multi-tenant service. You're connecting 3-10 developers who trust each other so that lessons, decisions, and conventions flow between them without ceremony.

      Prerequisites:

      • A running ctx Hub on a LAN host or internal server everyone on the team can reach. See Multi-machine setup for the deployment guide.
      • Each team member has ctx installed and has ctx connection register-ed their working projects with the hub.
      • Each project on each workstation has been activated for the shell with eval \"$(ctx activate)\". The hub server (ctx hub start, etc.) doesn't need this — but the client side (ctx connection ..., ctx add --share) lives in a project and does. If you skip activation, those client commands fail with Error: no context directory specified. See Activating a Context Directory.
      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#trust-model-read-this-first","level":2,"title":"Trust Model: Read This First","text":"

      The hub assumes everyone holding a client token is friendly. There's no per-user attribution you can rely on, no read ACL beyond subscription filters, and Origin is self-asserted by the publishing client. Treat the hub like a team wiki: useful because everyone can write to it, not because it can prove who wrote what.

      If your team is:

      • ✅ 3-10 engineers, all known to each other, all trusted with production access
      • ✅ On a single internal network or behind a VPN
      • ✅ Comfortable with \"the hub assumes friendly participants\"

      …this recipe fits. If your team is:

      • ❌ Larger than ~15, with turnover
      • ❌ Includes contractors, untrusted agents, or compromised-workstation concerns
      • ❌ Needs audit trails that prove who published what
      • ❌ Requires per-team-member isolation

      …you're in \"Story 3\" territory, which the hub does not support today. Use a wiki or a dedicated knowledge platform instead.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#the-teams-three-verbs","level":2,"title":"The Team's Three Verbs","text":"

      Everyone on the team does three things, same as in the personal recipe, but with different social expectations:

      1. Record: when you learn something that would save a teammate time, capture it with ctx add --share.
      2. Subscribe: every engineer's project directories subscribe to the types the team cares about.
      3. Load: agents pick up shared entries automatically via the auto-sync hook and the --include-hub flag in the PreToolUse hook pipeline.

      The operational shape is identical to solo use. What's different is the culture around publishing: when do you --share, and what belongs on the hub vs. in your local .context/.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#what-goes-on-the-hub-team-rules-of-thumb","level":2,"title":"What Goes on the Hub (Team Rules of Thumb)","text":"

      Share it if it's true for more than one person. The central question: \"would the next teammate who hits this problem save time if they already knew this?\" If yes, --share. If no, record it locally and move on.

      Decisions:

      • ✅ Cross-service decisions (database choice, auth model, deployment pattern, monitoring stack).
      • ✅ Policy decisions that apply to all services (naming, API versioning, error-message format).
      • ❌ Internal implementation decisions inside a single service (\"chose a map over a slice here because lookups dominate\").
      • ❌ One-off tactical calls for a specific PR.

      Learnings:

      • ✅ Gotchas, surprising behavior, flaky infrastructure quirks, anything you'd tell a teammate over coffee with \"watch out for X\".
      • ✅ Lessons from incidents, right after the postmortem is the highest-value time to share.
      • ❌ Internal debugging notes that only make sense with context from your current branch.

      Conventions:

      • ✅ Repo layout, commit message format, pre-commit hooks, review expectations.
      • ✅ Language-level style decisions that apply across services.
      • ❌ Per-service idioms (\"in billing/ we prefer…\").

      Tasks: almost always project-local. Don't subscribe to task unless the team has a specific reason (e.g., a cross-cutting migration you want visible everywhere).

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#a-realistic-week","level":2,"title":"A Realistic Week","text":"

      Monday, 3 AM incident, shared learning

      On-call engineer Alice gets paged: the payment service starts returning 500s after a dependency update. After an hour she finds the culprit: a breaking change in a transitive gRPC dep that only manifests under high concurrency. Postmortem on Tuesday, but right now she records the learning:

      ctx learning add --share \\\n  --context \"Payment service 3 AM incident, 2026-04-03\" \\\n  --lesson  \"grpc-go v1.62+ changes DialContext behavior under high \\\n  concurrency: connections from a single channel can deadlock if the \\\n  server emits GOAWAY mid-stream. Symptom: 500 errors cluster in \\\n  30s bursts, no error in grpc client logs.\" \\\n  --application \"Any service on grpc-go. Pin to v1.61 or patch with \\\n  keepalive: https://github.com/grpc/grpc-go/issues/...\" \n

      By Tuesday morning, every other engineer's agent context packet contains this learning. When Bob starts work on the ledger service (which also uses grpc-go), his Claude Code session already knows about the gotcha without Bob having to read the incident channel.

      Wednesday, cross-service decision

      The team agrees on a new pattern for API versioning: header-based instead of URL-based. Platform lead Carol records the decision:

      ctx decision add --share \\\n  --context \"Need consistent API versioning across all 6 services. \\\n  Current URL-based /v1/ isn't working for gradual rollouts.\" \\\n  --rationale \"Header-based versioning lets us route by header at the \\\n  edge, which makes canary rollouts trivial. URL-based versioning \\\n  forces clients to update their paths.\" \\\n  --consequence \"All new endpoints use X-API-Version header. \\\n  Existing /v1/ endpoints stay. Deprecation schedule in q3.\" \\\n  \"Use header-based API versioning for new endpoints\"\n

      Every engineer's next session knows about this decision automatically. When Dave starts adding endpoints to the inventory service on Thursday, Claude already prompts him for the header pattern instead of defaulting to /v1/.

      Friday, convention drift caught at review

      Dave notices that his PR auto-formatted some error messages to end with periods. He recalls the team convention is \"no trailing period\" but can't remember where it was documented. He runs ctx connection status, sees the hub is healthy, greps his local .context/hub/conventions.md, and finds:

      ## [2026-03-12] Error message format\nLowercase start, no trailing period, single sentence.\n

      He fixes the PR. No lookup on the wiki, no question in chat, no context-switch penalty.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#workflow-tips-for-teams","level":2,"title":"Workflow Tips for Teams","text":"

      Designate a \"champion\" for decisions. The team lead or platform engineer should be the person who explicitly --shares cross-cutting decisions. Other team members share learnings freely but should ask \"should this be a decision?\" in review before --shareing a decision. This keeps the decision stream signal-rich.

      Publish postmortem learnings immediately, not after the meeting. The postmortem itself is a document; the actionable rules that come out of it belong on the hub, and they should land within an hour of the incident. \"Share fast, edit later\" is the rule.

      Delete noisy entries, don't tolerate them. The hub is append-only, but the .context/hub/ mirror on each client is just markdown. If a shared learning turns out to be wrong or obsolete, remove it from local mirrors and stop the hub daemon to truncate entries.jsonl (see Hub operations). Noisy shared feeds lose trust fast.

      Don't subscribe every project to every type. For backend engineers, subscribing to decision + learning + convention is usually right. For platform or DevOps projects, adding task makes sense. For a prototype or experiment project, subscribing only to convention might be enough.

      Run a single hub, not one per team. If two teams need to share knowledge, they should share a hub. Splitting hubs by team creates silos, which is often exactly the thing you were trying to solve.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#operational-concerns","level":2,"title":"Operational Concerns","text":"

      The team recipe assumes someone owns the hub host. That person (or a small group) is responsible for:

      • Uptime: the hub is infrastructure; treat it like any other internal service you run. See Hub operations.
      • Backups: entries.jsonl is the source of truth. Snapshot it to the same backup tier as your other internal data.
      • Upgrades: cadence the team agrees on. Major upgrades may require everyone to re-register, so do them at natural breaks.
      • Failures: see Hub failure modes for the standard oncall playbook.

      Optional but recommended: run a 3-node Raft cluster so the hub survives individual node failures. See HA cluster. For teams under 10 people, a single-node hub with daily backups is usually fine.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#token-management","level":2,"title":"Token Management","text":"

      Every team member has a client token stored in their .context/.connect.enc. Rules of thumb:

      • One token per engineer per project. Not one token per team; not one shared token. Each engineer registers each of their working projects separately.
      • Token compromise = revoke immediately. When an engineer leaves, their tokens should be removed from clients.json on the hub. This is a manual operation today; see Hub security for the revocation steps.
      • No checked-in tokens. .context/.connect.enc is encrypted with the local machine key, but don't push it to shared repos; it's per-workstation.
      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#what-this-recipe-is-not","level":2,"title":"What This Recipe Is Not","text":"

      Not a wiki replacement. The hub is for structured entries, not prose. Put your architecture overviews, onboarding docs, and design discussions in a real wiki.

      Not an audit log. Origin on the hub is self-asserted. If compliance requires provenance, the hub is the wrong tool.

      Not a ticket system. Task sharing works, but mature teams already have Jira/Linear/Github Issues. Don't try to replace those with hub tasks; use the hub for lightweight cross-project todos that your existing tracker doesn't capture well.

      Not a production service for end users. This is internal team infrastructure. Do not expose the hub to customers, partners, or the open internet.

      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#see-also","level":2,"title":"See Also","text":"
      • Hub overview: when to use the hub and when not to.
      • Personal cross-project brain: the single-developer companion recipe.
      • Multi-machine setup: standing up the hub on a LAN host.
      • HA cluster: optional redundancy for larger teams.
      • Hub operations: backup, rotation, monitoring.
      • Hub security: threat model and hardening checklist.
      ","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/import-plans/","level":1,"title":"Importing Claude Code Plans","text":"","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code plan files (~/.claude/plans/*.md) are ephemeral: They have structured context, approach, and file lists, but they're orphaned after the session ends. The filenames are UUIDs, so you can't tell what's in them without opening each one.

      How do you turn a useful plan into a permanent project spec?

      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tldr","level":2,"title":"TL;DR","text":"
      You: /ctx-plan-import\nAgent: [lists plans with dates and titles]\n       1. 2026-02-28  Add authentication middleware\n       2. 2026-02-27  Refactor database connection pool\nYou: \"import 1\"\nAgent: [copies to specs/add-authentication-middleware.md]\n

      Plans are copied (not moved) to specs/, slugified by their H1 heading.

      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-plan-import Skill List, filter, and import plan files to specs /ctx-task-add Skill Optionally add a task referencing the spec","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-1-list-available-plans","level":3,"title":"Step 1: List Available Plans","text":"

      Invoke the skill and it lists plans with modification dates and titles:

      You: /ctx-plan-import\n\nAgent: Found 3 plan files:\n         1. 2026-02-28  Add authentication middleware\n         2. 2026-02-27  Refactor database connection pool\n         3. 2026-02-25  Import plans skill\n       Which plans would you like to import?\n
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-2-filter-optional","level":3,"title":"Step 2: Filter (Optional)","text":"

      You can narrow the list with arguments:

      Argument Effect --today Only plans modified today --since YYYY-MM-DD Only plans modified on or after the date --all Import everything without prompting (none) Interactive selection
      You: /ctx-plan-import --today\nYou: /ctx-plan-import --since 2026-02-27\nYou: /ctx-plan-import --all\n
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-3-select-and-import","level":3,"title":"Step 3: Select and Import","text":"

      Pick one or more plans by number:

      You: \"import 1 and 3\"\n\nAgent: Imported 2 plan(s):\n         ~/.claude/plans/abc123.md -> specs/add-authentication-middleware.md\n         ~/.claude/plans/ghi789.md -> specs/import-plans-skill.md\n       Want me to add tasks referencing these specs?\n

      The agent reads the H1 heading from each plan and slugifies it for the filename. If a plan has no H1 heading, the original filename (minus extension) is used as the slug.

      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#step-4-add-follow-up-tasks-optional","level":3,"title":"Step 4: Add Follow-Up Tasks (Optional)","text":"

      If you say yes, the agent creates tasks in TASKS.md that reference the imported specs:

      You: \"yes, add tasks\"\n\nAgent: [runs /ctx-task-add for each spec]\n       Added:\n         - [ ] Implement authentication middleware (spec: specs/add-authentication-middleware.md)\n         - [ ] Import plans skill (spec: specs/import-plans-skill.md)\n
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need to remember the exact skill name:

      You say What happens \"import my plans\" /ctx-plan-import (interactive) \"save today's plans as specs\" /ctx-plan-import --today \"import all plans from this week\" /ctx-plan-import --since ... \"turn that plan into a spec\" /ctx-plan-import (filtered)","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tips","level":2,"title":"Tips","text":"
      • Plans are copied, not moved: The originals stay in ~/.claude/plans/. Claude Code manages that directory; ctx doesn't delete from it.
      • Conflict handling: If specs/{slug}.md already exists, the agent asks whether to overwrite or pick a different name.
      • Specs are project memory: Once imported, specs are tracked in git and available to future sessions. Reference them from TASKS.md phase headers with Spec: specs/slug.md.
      • Pair with /ctx-implement: After importing a plan as a spec, use /ctx-implement to execute it step-by-step with verification.
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#see-also","level":2,"title":"See Also","text":"
      • Skills Reference: /ctx-plan-import: full skill description
      • The Complete Session: where plan import fits in the session flow
      • Tracking Work Across Sessions: managing tasks that reference imported specs
      ","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/knowledge-capture/","level":1,"title":"Persisting Decisions, Learnings, and Conventions","text":"","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#the-problem","level":2,"title":"The Problem","text":"

      You debug a subtle issue, discover the root cause, and move on.

      Three weeks later, a different session hits the same issue. The knowledge existed briefly in one session's memory but was never written down.

      Architectural decisions suffer the same fate: you weigh trade-offs, pick an approach, and six sessions later the AI suggests the alternative you already rejected.

      How do you make sure important context survives across sessions?

      Prefer Skills to Raw Commands

      Use /ctx-decision-add and /ctx-learning-add instead of raw ctx add commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, the ctx add ... / ctx reindex / ctx decision ... / ctx learning ... commands below fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-reflect               # surface items worth persisting\n/ctx-decision-add \"Title\"  # record with context/rationale/consequence\n/ctx-learning-add \"Title\"  # record with context/lesson/application\n

      Or just tell your agent: \"What have we learned this session?\"

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx decision add Command Record an architectural decision ctx learning add Command Record a gotcha, tip, or lesson ctx convention add Command Record a coding pattern or standard ctx reindex Command Rebuild both quick-reference indices ctx decision reindex Command Rebuild the DECISIONS.md index ctx learning reindex Command Rebuild the LEARNINGS.md index /ctx-decision-add Skill AI-guided decision capture with validation /ctx-learning-add Skill AI-guided learning capture with validation /ctx-convention-add Skill AI-guided convention recording with placement /ctx-reflect Skill Surface items worth persisting at breakpoints","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#the-workflow","level":2,"title":"The Workflow","text":"

      Decision, Learning, or Convention?

      • If you chose between alternatives, it is a decision.
      • If you discovered something surprising, it is a learning.
      • If you are codifying a repeated pattern, it is a convention.
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-1-understand-what-to-persist","level":3,"title":"Step 1: Understand What to Persist","text":"

      Three context files serve different purposes:

      Decisions (DECISIONS.md) answer \"why is it this way?\" They record trade-offs between alternatives with structured fields: context, rationale, and consequences. Decisions prevent re-debating settled questions.

      Learnings (LEARNINGS.md) answer \"what did we discover the hard way?\" They record gotchas and debugging insights specific to this project with structured fields: context, lesson, and application.

      Learnings prevent repeating past mistakes.

      Conventions (CONVENTIONS.md) answer \"how do we do things here?\" They record patterns and standards. No structured fields required: just a name, a rule, and an example. Conventions keep code consistent across sessions.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-2-record-decisions","level":3,"title":"Step 2: Record Decisions","text":"

      Decisions have three structured fields:

      • context,
      • rationale,
      • and consequences.

      The easiest way to record one is to tell your agent:

      You: \"Save that as a decision: we picked file-based cooldown\n      tokens over env vars.\"\n\nAgent: \"Recorded in DECISIONS.md:\n  - Decision: Use file-based cooldown tokens instead of env vars\n  - Context: Hook subprocesses cannot persist env vars to parent shell\n  - Rationale: File tokens survive across processes. Simpler than\n    IPC. Cleanup is automatic via TTL.\n  - Consequence: Tombstone files accumulate in /tmp. Cannot share\n    state across machines.\"\n

      The agent was present for the trade-off discussion. It fills in the structured fields from what it observed, which is hard to reconstruct later as a terminal one-liner.

      When multiple options were considered, the agent includes rejected alternatives in the rationale automatically.

      The /ctx-decision-add skill also guides you through the fields interactively. For quick decisions, it supports a Y-statement:

      \"In the context of [situation], facing [constraint], we decided for [choice] and against [alternatives], to achieve [benefit], accepting that [trade-off].\"

      CLI Command for Scripting and Automation

      When no agent is in the loop (CI pipelines, shell scripts, hooks), use the CLI directly with structured flags:

      ctx decision add \"Use file-based cooldown tokens instead of env vars\" \\\n  --context \"Hook subprocesses cannot persist env vars to parent shell\" \\\n  --rationale \"File tokens survive across processes. Simpler than IPC. Cleanup is automatic via TTL.\" \\\n  --consequence \"Tombstone files accumulate in /tmp. Cannot share state across machines.\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-3-record-learnings","level":3,"title":"Step 3: Record Learnings","text":"

      Learnings have three structured fields: context, lesson, and application.

      Again, your agent is the best tool for this. It was there when you discovered the gotcha and can express it more completely than a backslash-escaped terminal command:

      You: \"That subprocess thing was painful. Save it as a learning.\"\n\nAgent: \"Added to LEARNINGS.md:\n  - Learning: Claude Code hooks run in a subprocess\n  - Context: Set env var in PreToolUse hook, but it was not visible\n    in the main session\n  - Lesson: Hook scripts execute in a child process. Env changes do\n    not propagate to parent.\n  - Application: Use tombstone files for hook-to-session\n    communication. Never rely on hook env vars.\"\n

      You said one sentence. The agent produced a structured entry with all three fields filled from the session context.

      That is the point: the agent has the full conversation and can be far more expressive than what you would type at a command prompt.

      The /ctx-learning-add skill applies three quality filters:

      1. Could someone Google this in 5 minutes?
      2. Is it specific to this codebase?
      3. Did it take real effort to discover?

      All three must pass.

      Learnings capture principles and heuristics, not code snippets.

      CLI Command for Scripting and Automation

      When no agent is in the loop:

      ctx learning add \"Claude Code hooks run in a subprocess\" \\\n  --context \"Set env var in PreToolUse hook, but it was not visible in the main session\" \\\n  --lesson \"Hook scripts execute in a child process. Env changes do not propagate to parent.\" \\\n  --application \"Use tombstone files for hook-to-session communication. Never rely on hook env vars.\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-4-record-conventions","level":3,"title":"Step 4: Record Conventions","text":"

      Conventions are simpler: just a name, a rule, and optionally a section.

      These are short enough that either approach works:

      You: \"We've been using kebab-case for every CLI flag. Codify that.\"\n\nAgent: \"Added to CONVENTIONS.md under Naming:\n  'Use kebab-case for all CLI flag names.'\"\n

      Or from the terminal:

      ctx convention add \"Use kebab-case for all CLI flag names\" --section \"Naming\"\n

      Conventions work best for rules that come up repeatedly. Codify a pattern the third time you see it, not the first.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-5-reindex-after-manual-edits","level":3,"title":"Step 5: Reindex After Manual Edits","text":"

      DECISIONS.md and LEARNINGS.md maintain a quick-reference index at the top: a compact table of date and title for each entry. The index updates automatically via ctx add, but falls out of sync after hand edits.

      ctx reindex\n

      This single command regenerates both indices. You can also reindex individually with ctx decision reindex or ctx learning reindex.

      Run reindex after any manual edit. The index lets AI tools scan all entries without reading the full file, which matters when token budgets are tight.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-6-use-ctx-reflect-to-surface-what-to-capture","level":3,"title":"Step 6: Use /ctx-reflect to Surface What to Capture","text":"

      Keep It Conversational

      /ctx-reflect is not the only way to trigger reflection.

      Agents trained on the ctx playbook naturally surface persist-worthy items at breakpoints, even without invoking the skill explicitly.

      A conversational prompt like \"anything worth saving?\" or \"let's wrap up\" can trigger the same review.

      The skill provides a structured checklist, but the behavior is available through natural conversation.

      At natural breakpoints (after completing a feature, fixing a bug, or before ending a session) use /ctx-reflect to identify items worth persisting.

      /ctx-reflect\n

      The skill walks through learnings, decisions, tasks, and session notes, skipping categories with nothing to report. The output includes specific commands for each suggested persist:

      This session implemented file-based cooldown for `ctx agent` and\ndiscovered that hook subprocesses cannot set env vars in the parent.\n\nI'd suggest persisting:\n- **Learning**: Hook subprocesses cannot propagate env vars\n  `ctx learning add \"...\" --context \"...\" --lesson \"...\" --application \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n- **Decision**: File-based cooldown tokens over env vars\n  `ctx decision add \"...\" --context \"...\" --rationale \"...\" --consequence \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n\nWant me to persist any of these?\n

      The skill always asks before persisting.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-7-the-conversational-approach","level":3,"title":"Step 7: The Conversational Approach","text":"

      The commands shown in Steps 2 to 4 are precise, but you rarely need to type them yourself. When working with an agent that has loaded the ctx playbook, natural language triggers the same operations.

      You ask, the agent acts:

      You say What the agent does \"What have we learned this session?\" Reviews recent work, identifies learnings, offers to persist \"Save that as a decision\" Captures the trade-off you just discussed with structured fields \"Any gotchas worth remembering?\" Scans recent work for non-obvious lessons \"Record that convention\" Adds the pattern you just agreed on to CONVENTIONS.md \"Let's wrap up\" Runs through the reflect checklist conversationally

      Example exchange:

      You: \"What did we learn from that debugging session?\"\n\nAgent: \"We discovered three things worth persisting:\n  1. Hook subprocesses can't propagate env vars to the parent. We\n     spent 20 minutes on this before switching to tombstone files.\n  2. Tombstone files need a TTL or they accumulate in /tmp.\n  3. The cooldown logic must check file mtime, not just existence.\n  Want me to save these as learnings?\"\n\nYou: \"Yes, all of them.\"\n\nAgent: \"Done. Added all three to LEARNINGS.md with structured fields.\"\n

      The agent can also be proactive without being asked. The playbook encourages agents to persist context at natural milestones.

      You may see:

      • After fixing a tricky bug: \"I noticed this was a non-obvious issue. Want me to save it as a learning?\"
      • After choosing between approaches: \"We just made a trade-off between file-based tokens and IPC. Should I record this as a decision?\"
      • At session milestones: the agent checks what is worth persisting and offers a brief summary.

      When agents run unattended (no human in the loop), they may persist directly:

      • \"I've added the subprocess env var gotcha to LEARNINGS.md so we don't hit it again.\"
      • \"Recorded the decision to use file-based tokens over env vars in DECISIONS.md.\"
      • \"Marked the cooldown task done and added a follow-up for TTL cleanup.\"

      This is behavior by design.

      The playbook's self-check prompt, \"If this session ended right now, would the next session know what happened?\" drives agents to persist early and often rather than waiting for explicit instructions.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#command-line-approach-scripting-and-automation","level":3,"title":"Command-Line Approach (Scripting and Automation)","text":"
      # Decision: record the trade-off\nctx decision add \"Use PostgreSQL over SQLite\" \\\n  --context \"Need concurrent multi-user access\" \\\n  --rationale \"SQLite locks on writes; Postgres handles concurrency\" \\\n  --consequence \"Requires a database server; team needs Postgres training\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Learning: record the gotcha\nctx learning add \"SQL migrations must be idempotent\" \\\n  --context \"Deploy failed when migration ran twice after rollback\" \\\n  --lesson \"CREATE TABLE without IF NOT EXISTS fails on retry\" \\\n  --application \"Always use IF NOT EXISTS guards in migrations\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Convention: record the pattern\nctx convention add \"API handlers return structured errors\" --section \"API\"\n\n# Reindex after manual edits\nctx reindex\n\n# Reflect at breakpoints (from AI assistant)\n# /ctx-reflect\n
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#conversational-approach-interactive-sessions","level":3,"title":"Conversational Approach (Interactive Sessions)","text":"
      You: \"We just picked Postgres over SQLite for the concurrency\n      reasons. Save that?\"\n\nAgent: \"Recorded. Added to DECISIONS.md:\n  - Decision: Use PostgreSQL over SQLite\n  - Context: Need concurrent multi-user access\n  - Rationale: SQLite locks on writes; Postgres handles concurrency\n  - Consequence: Requires a database server; team needs Postgres\n    training\"\n\nYou: \"Also that migration thing. The deploy blew up when the\n      migration ran twice.\"\n\nAgent: \"Got it. Added to LEARNINGS.md:\n  - Learning: SQL migrations must be idempotent\n  - Lesson: CREATE TABLE without IF NOT EXISTS fails on retry\n  - Application: Always use IF NOT EXISTS guards in migrations\"\n\nYou: \"Good. Anything else worth saving before we wrap up?\"\n\nAgent: \"We've been using structured error returns in every API\n  handler this session. Want me to codify that as a convention?\"\n\nYou: \"Do it.\"\n\nAgent: \"Done. Added 'API handlers return structured errors' to\n  CONVENTIONS.md under the API section.\"\n

      Both approaches produce the same structured entries in the same context files.

      • The conversational approach is the natural fit for interactive sessions;
      • the CLI commands are better suited for scripts, hooks, and automation pipelines.
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tips","level":2,"title":"Tips","text":"
      • Record decisions at the moment of choice. The alternatives you considered and the reasons you rejected them fade quickly. Capture trade-offs while they are fresh.
      • Learnings should fail the Gemini test. If someone could find it in a 5-minute Gemini search, it does not belong in LEARNINGS.md.
      • Conventions earn their place through repetition. Add a convention the third time you see a pattern, not the first.
      • Use /ctx-reflect at natural breakpoints. The checklist catches items you might otherwise lose.
      • Keep the entries self-contained. Each entry should make sense on its own. A future session may load only one due to token budget constraints.
      • Reindex after every hand edit. It takes less than a second. A stale index causes AI tools to miss entries.
      • Prefer the structured fields. The verbosity forces clarity. A decision without a rationale is just a fact. A learning without an application is just a story.
      • Talk to your agent, do not type commands. In interactive sessions, the conversational approach is the recommended way to capture knowledge. Say \"save that as a learning\" or \"any decisions worth recording?\" and let the agent handle the structured fields. Reserve the CLI commands for scripting, automation, and CI/CD pipelines where there is no agent in the loop.
      • Trust the agent's proactive instincts. Agents trained on the ctx playbook will offer to persist context at milestones. A brief \"want me to save this?\" is cheaper than re-discovering the same lesson three sessions later.
      • Relax provenance per-project if --session-id, --branch, or --commit are impractical (e.g., manual notes outside an AI session). Add to .ctxrc:

        provenance_required:\n  session_id: false   # allow entries without --session-id\n  branch: true        # still require --branch\n  commit: true        # still require --commit\n

        Default is all three required. Only human config relaxes: Agents cannot bypass, and that's by design.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#next-up","level":2,"title":"Next Up","text":"

      Tracking Work Across Sessions →: Add, prioritize, complete, and archive tasks across sessions.

      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#see-also","level":2,"title":"See Also","text":"
      • Tracking Work Across Sessions: managing the tasks that decisions and learnings support
      • The Complete Session: full session lifecycle including reflection and context persistence
      • Detecting and Fixing Drift: keeping knowledge files accurate as the codebase evolves
      • CLI Reference: full documentation for ctx add, ctx decision, ctx learning
      • Context Files: format and conventions for DECISIONS.md, LEARNINGS.md, and CONVENTIONS.md
      ","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/memory-bridge/","level":1,"title":"Bridging Claude Code Auto Memory","text":"","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code maintains per-project auto memory at ~/.claude/projects/<slug>/memory/MEMORY.md. This file is:

      • Outside the repo - not version-controlled, not portable
      • Machine-specific - tied to one ~/.claude/ directory
      • Invisible to ctx - context loading and hooks don't read it

      Meanwhile, ctx maintains structured context files (DECISIONS.md, LEARNINGS.md, CONVENTIONS.md) that are git-tracked, portable, and token-budgeted - but Claude Code doesn't automatically write to them.

      The two systems hold complementary knowledge with no bridge between them.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#tldr","level":2,"title":"TL;DR","text":"
      ctx memory sync          # Mirror MEMORY.md into .context/memory/mirror.md\nctx memory status        # Check for drift\nctx memory diff          # See what changed since last sync\n

      The check-memory-drift hook nudges automatically when MEMORY.md changes - you don't need to remember to sync manually.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx memory ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx memory sync CLI command Copy MEMORY.md to mirror, archive previous ctx memory status CLI command Show drift, timestamps, line counts ctx memory diff CLI command Show changes since last sync ctx memory import CLI command Classify and promote entries to .context/ files ctx memory publish CLI command Push curated .context/ content to MEMORY.md ctx memory unpublish CLI command Remove published block from MEMORY.md ctx system check-memory-drift Hook Nudge when MEMORY.md has changed (once/session)","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#how-it-works","level":2,"title":"How It Works","text":"","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#discovery","level":3,"title":"Discovery","text":"

      Claude Code encodes project paths as directory names under ~/.claude/projects/. The encoding replaces / with - and prefixes with -:

      /home/jose/WORKSPACE/ctx  →  ~/.claude/projects/-home-jose-WORKSPACE-ctx/\n

      ctx memory uses this encoding to locate MEMORY.md automatically from your project root - no configuration needed.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#mirroring","level":3,"title":"Mirroring","text":"

      When you run ctx memory sync:

      1. The previous mirror is archived to .context/memory/archive/mirror-<timestamp>.md
      2. MEMORY.md is copied to .context/memory/mirror.md
      3. Sync state is updated in .context/state/memory-import.json

      The mirror is git-tracked, so it travels with the project. Archives provide a fallback for projects that don't use git.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#drift-detection","level":3,"title":"Drift Detection","text":"

      The check-memory-drift hook compares MEMORY.md's modification time against the mirror. When drift is detected, the agent sees:

      ┌─ Memory Drift ────────────────────────────────────────────────\n│ MEMORY.md has changed since last sync.\n│ Run: ctx memory sync\n│ Context: .context\n└────────────────────────────────────────────────────────────────\n

      The nudge fires once per session to avoid noise.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#typical-workflow","level":2,"title":"Typical Workflow","text":"","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#at-session-start","level":3,"title":"At Session Start","text":"

      If the hook fires a drift nudge, sync before diving into work:

      ctx memory diff     # Review what changed\nctx memory sync     # Mirror the changes\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#periodic-check","level":3,"title":"Periodic Check","text":"
      ctx memory status\n# Memory Bridge Status\n#   Source:      ~/.claude/projects/.../memory/MEMORY.md\n#   Mirror:      .context/memory/mirror.md\n#   Last sync:   2026-03-05 14:30 (2 hours ago)\n#\n#   MEMORY.md:  47 lines\n#   Mirror:     32 lines\n#   Drift:      detected (source is newer)\n#   Archives:   3 snapshots in .context/memory/archive/\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#dry-run","level":3,"title":"Dry Run","text":"

      Preview what sync would do without writing:

      ctx memory sync --dry-run\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#storage-layout","level":2,"title":"Storage Layout","text":"
      .context/\n├── memory/\n│   ├── mirror.md                          # Raw copy of MEMORY.md (often git-tracked)\n│   └── archive/\n│       ├── mirror-2026-03-05-143022.md    # Timestamped pre-sync snapshots\n│       └── mirror-2026-03-04-220015.md\n├── state/\n│   └── memory-import.json                 # Sync tracking state\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#edge-cases","level":2,"title":"Edge Cases","text":"Scenario Behavior Auto memory not active sync exits 1 with message. status reports \"not active\". Hook skips silently. First sync (no mirror) Creates mirror without archiving. MEMORY.md is empty Syncs to empty mirror (valid). Not initialized Init guard rejects (same as all ctx commands).","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#importing-entries","level":2,"title":"Importing Entries","text":"

      Once you've synced, you can classify and promote entries into structured .context/ files:

      ctx memory import --dry-run    # Preview classification\nctx memory import              # Actually promote entries\n

      Each entry is classified by keyword heuristics:

      Keywords Target always use, prefer, never use, standard CONVENTIONS.md decided, chose, trade-off, approach DECISIONS.md gotcha, learned, watch out, bug, caveat LEARNINGS.md todo, need to, follow up TASKS.md Everything else Skipped

      Entries that don't match any pattern are skipped - they stay in the mirror for manual review. Deduplication (hash-based) prevents re-importing the same entry on subsequent runs.

      Review Before Importing

      Use --dry-run first. The heuristic classifier is deliberately simple - it may misclassify ambiguous entries. Review the plan, then import.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#full-workflow","level":3,"title":"Full Workflow","text":"
      ctx memory sync                # 1. Mirror MEMORY.md\nctx memory import --dry-run    # 2. Preview what would be imported\nctx memory import              # 3. Promote entries to .context/ files\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#publishing-context-to-memorymd","level":2,"title":"Publishing Context to MEMORY.md","text":"

      Push curated .context/ content back into MEMORY.md so Claude Code sees structured project context on session start - without needing hooks.

      ctx memory publish --dry-run    # Preview what would be published\nctx memory publish              # Write to MEMORY.md\nctx memory publish --budget 40  # Tighter line budget\n

      Published content is wrapped in markers:

      <!-- ctx:published -->\n# Project Context (managed by ctx)\n\n## Pending Tasks\n- [ ] Implement feature X\n...\n<!-- ctx:end -->\n

      Rules:

      • ctx owns everything between the markers
      • Claude owns everything outside the markers
      • ctx memory import reads only outside the markers
      • ctx memory publish replaces only inside the markers

      To remove the published block entirely:

      ctx memory unpublish\n

      Publish at Wrap-Up, Not on Commit

      The best time to publish is during session wrap-up, after persisting decisions and learnings. Never auto-publish - give yourself a chance to review what's going into MEMORY.md.

      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#full-bidirectional-workflow","level":3,"title":"Full Bidirectional Workflow","text":"
      ctx memory sync                 # 1. Mirror MEMORY.md\nctx memory import --dry-run     # 2. Check what Claude wrote\nctx memory import               # 3. Promote entries to .context/\nctx memory publish --dry-run    # 4. Check what would be published\nctx memory publish              # 5. Push context to MEMORY.md\n
      ","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/multi-tool-setup/","level":1,"title":"Setup Across AI Tools","text":"","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#the-problem","level":2,"title":"The Problem","text":"

      You have installed ctx and want to set it up with your AI coding assistant so that context persists across sessions. Different tools have different integration depths. For example:

      • Claude Code supports native hooks that load and save context automatically.
      • Cursor injects context via its system prompt.
      • Aider reads context files through its --read flag.

      This recipe walks through the complete setup for each tool, from initialization through verification, so you end up with a working memory layer regardless of which AI tool you use.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tldr","level":2,"title":"TL;DR","text":"
      cd your-project\nctx init                      # creates .context/\neval \"$(ctx activate)\"        # bind CTX_DIR for this shell\nsource <(ctx completion zsh)  # shell completion (or bash/fish)\n\n# ## Claude Code (automatic after plugin install) ##\nclaude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n\n# ## Cursor / Aider / Copilot / Windsurf ##\nctx setup cursor # or: aider, copilot, windsurf\n\n# ## Companion tools (highly recommended) ##\nnpx gitnexus analyze          # code knowledge graph\n# Add Gemini Search MCP server for grounded web search\n

      Activate the Project Once Per Shell

      Run eval \"$(ctx activate)\" after ctx init. The ctx setup, ctx init, and ctx completion commands work without it, but if you skip the eval, most others (ctx agent, ctx load, ctx watch, ctx journal ...) fail with Error: no context directory specified. See Activating a Context Directory.

      Create a .ctxrc in your project root to configure token budgets, context directory, drift thresholds, and more.

      Then start your AI tool and ask: \"Do you remember?\"

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Command/Skill Role in this workflow ctx init Create .context/ directory, templates, and permissions ctx setup Generate integration configuration for a specific AI tool ctx agent Print a token-budgeted context packet for AI consumption ctx load Output assembled context in read order (for manual pasting) ctx watch Auto-apply context updates from AI output (non-native tools) ctx completion Generate shell autocompletion for bash, zsh, or fish ctx journal import Import sessions to editable journal Markdown","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-1-initialize-ctx","level":3,"title":"Step 1: Initialize ctx","text":"

      Run ctx init in your project root. This creates the .context/ directory with all template files and seeds ctx permissions in settings.local.json.

      cd your-project\nctx init\n

      This produces the following structure:

      .context/\n  CONSTITUTION.md     # Hard rules the AI must never violate\n  TASKS.md            # Current and planned work\n  CONVENTIONS.md      # Code patterns and standards\n  ARCHITECTURE.md     # System overview\n  DECISIONS.md        # Architectural decisions with rationale\n  LEARNINGS.md        # Lessons learned, gotchas, tips\n  GLOSSARY.md         # Domain terms and abbreviations\n  AGENT_PLAYBOOK.md   # How AI tools should use this system\n

      Using a Different .context Directory

      The .context/ directory doesn't have to live inside your project. Point ctx to an external folder by exporting CTX_DIR (the only declaration channel).

      Useful when context must stay private while the code is public, or when you want to commit notes to a separate repo.

      Caveats (the recipe covers both with workarounds):

      • Code-aware operations degrade silently. ctx sync, ctx drift, and the memory-drift hook read the codebase from dirname(CTX_DIR). With an external .context/, that's the context repo, not your code repo. They scan the wrong tree without erroring. The recipe shows a symlink workaround that keeps both healthy.
      • One .context/ per project, always. Sharing one directory across multiple projects corrupts journals, state, and secrets. For cross-project knowledge sharing (CONSTITUTION, CONVENTIONS, ARCHITECTURE, etc.) use ctx hub, not a shared .context/.

      See External Context for the full recipe and Configuration for the resolver details.

      For Claude Code, install the ctx plugin to get hooks and skills:

      claude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n

      If you only need the core files (useful for lightweight setups), use the --minimal flag:

      ctx init --minimal\n

      This creates only TASKS.md, DECISIONS.md, and CONSTITUTION.md.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-2-generate-tool-specific-hooks","level":3,"title":"Step 2: Generate Tool-Specific Hooks","text":"

      If you are using a tool other than Claude Code (which is configured automatically by ctx init), generate its integration configuration:

      # For Cursor\nctx setup cursor\n\n# For Aider\nctx setup aider\n\n# For GitHub Copilot\nctx setup copilot\n\n# For Windsurf\nctx setup windsurf\n

      Each command prints the configuration you need. How you apply it depends on the tool.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#claude-code","level":4,"title":"Claude Code","text":"

      No action needed. Just install ctx from the Marketplace as ActiveMemory/ctx.

      Claude Code Is a First-Class Citizen

      With the ctx plugin installed, Claude Code gets hooks and skills automatically. The PreToolUse hook runs ctx agent --budget 4000 on every tool call (with a 10-minute cooldown so it only fires once per window).

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#cursor","level":4,"title":"Cursor","text":"

      Add the system prompt snippet to .cursor/settings.json:

      {\n  \"ai.systemPrompt\": \"Read .context/TASKS.md and .context/CONVENTIONS.md before responding. Follow rules in .context/CONSTITUTION.md.\"\n}\n

      Context files appear in Cursor's file tree. You can also paste a context packet directly into chat:

      ctx agent --budget 4000 | xclip    # Linux\nctx agent --budget 4000 | pbcopy   # macOS\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#aider","level":4,"title":"Aider","text":"

      Create .aider.conf.yml so context files are loaded on every session:

      read:\n  - .context/CONSTITUTION.md\n  - .context/TASKS.md\n  - .context/CONVENTIONS.md\n  - .context/DECISIONS.md\n

      Then start Aider normally:

      aider\n

      Or specify files on the command line:

      aider --read .context/TASKS.md --read .context/CONVENTIONS.md\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-3-set-up-shell-completion","level":3,"title":"Step 3: Set Up Shell Completion","text":"

      Shell completion lets you tab-complete ctx subcommands and flags, which is especially useful while learning the CLI.

      # Bash (add to ~/.bashrc)\nsource <(ctx completion bash)\n\n# Zsh (add to ~/.zshrc)\nsource <(ctx completion zsh)\n\n# Fish\nctx completion fish > ~/.config/fish/completions/ctx.fish\n

      After sourcing, typing ctx a<TAB> completes to ctx agent, and ctx journal <TAB> shows list, show, and export.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-4-verify-the-setup-works","level":3,"title":"Step 4: Verify the Setup Works","text":"

      Start a fresh session in your AI tool and ask:

      \"Do you remember?\"

      A correctly configured tool responds with specific context: current tasks from TASKS.md, recent decisions, and previous session topics. It should not say \"I don't have memory\" or \"Let me search for files.\"

      This question checks the passive side of memory. A properly set-up agent is also proactive: it treats context maintenance as part of its job:

      • After a debugging session, it offers to save a learning.
      • After a trade-off discussion, it asks whether to record the decision.
      • After completing a task, it suggests follow-up items.

      The \"do you remember?\" check verifies both halves: recall and responsibility.

      For example, after resolving a tricky bug, a proactive agent might say:

      That Redis timeout issue was subtle. Want me to save this as a *learning*\nso we don't hit it again?\n

      If you see behavior like this, the setup is working end to end.

      In Claude Code, you can also invoke the /ctx-status skill:

      /ctx-status\n

      This prints a summary of all context files, token counts, and recent activity, confirming that hooks are loading context.

      If context is not loading, check the basics:

      Symptom Fix ctx: command not found Ensure ctx is in your PATH: which ctx Hook errors Verify plugin is installed: claude /plugin list Context not refreshing Cooldown may be active; wait 10 minutes or set --cooldown 0","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-5-enable-watch-mode-for-non-native-tools","level":3,"title":"Step 5: Enable Watch Mode for Non-Native Tools","text":"

      Tools like Aider, Copilot, and Windsurf do not support native hooks for saving context automatically. For these, run ctx watch alongside your AI tool.

      Pipe the AI tool's output through ctx watch:

      # Terminal 1: Run Aider with output logged\naider 2>&1 | tee /tmp/aider.log\n\n# Terminal 2: Watch the log for context updates\nctx watch --log /tmp/aider.log\n

      Or for any generic tool:

      your-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n

      When the AI emits structured update commands, ctx watch parses and applies them automatically:

      <context-update type=\"learning\"\n  context=\"Debugging rate limiter\"\n  lesson=\"Redis MULTI/EXEC does not roll back on error\"\n  application=\"Wrap rate-limit checks in Lua scripts instead\"\n>Redis Transaction Behavior</context-update>\n

      To preview changes without modifying files:

      ctx watch --dry-run --log /tmp/ai.log\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#step-6-import-session-transcripts-optional","level":3,"title":"Step 6: Import Session Transcripts (Optional)","text":"

      If you want to browse past session transcripts, import them to the journal:

      ctx journal import --all\n

      This converts raw session data into editable Markdown files in .context/journal/. You can then enrich them with metadata using /ctx-journal-enrich-all inside your AI assistant.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      Here is the condensed setup for all three tools:

      # ## Common (run once per project) ##\ncd your-project\nctx init\nsource <(ctx completion zsh)       # or bash/fish\n\n# ## Claude Code (automatic, just verify) ##\n# Start Claude Code, then ask: \"Do you remember?\"\n\n# ## Cursor ##\nctx setup cursor\n# Add the system prompt to .cursor/settings.json\n# Paste context: ctx agent --budget 4000 | pbcopy\n\n# ## Aider ##\nctx setup aider\n# Create .aider.conf.yml with read: paths\n# Run watch mode alongside: ctx watch --log /tmp/aider.log\n\n# ## Verify any Tool ##\n# Ask your AI: \"Do you remember?\"\n# Expect: specific tasks, decisions, recent context\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tips","level":2,"title":"Tips","text":"
      • Start with ctx init (not --minimal) for your first project. The full template set gives the agent more to work with, and you can always delete files later.
      • For Claude Code, the token budget is configured in the plugin's hooks.json. To customize, adjust the --budget flag in the ctx agent hook command.
      • The --session $PPID flag isolates cooldowns per Claude Code process, so parallel sessions do not suppress each other.
      • Commit your .context/ directory to version control. Several ctx features (journals, changelogs, blog generation) rely on git history.
      • For Cursor and Copilot, keep CONVENTIONS.md visible. These tools treat open files as higher-priority context.
      • Run ctx drift periodically to catch stale references before they confuse the agent.
      • The agent playbook instructs the agent to persist context at natural milestones (completed tasks, decisions, gotchas). In practice, this works best when you reinforce the habit: a quick \"anything worth saving?\" after a debugging session goes a long way.
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#companion-tools-highly-recommended","level":2,"title":"Companion Tools (Highly Recommended)","text":"

      ctx skills can leverage external MCP servers for web search and code intelligence. ctx works without them, but they significantly improve agent behavior across sessions. The investment is small and the benefits compound. Skills like /ctx-code-review, /ctx-explain, and /ctx-refactor all become noticeably better with these tools connected.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gemini-search","level":3,"title":"Gemini Search","text":"

      Provides grounded web search with citations. Used by skills and the agent playbook as the preferred search backend (faster and more accurate than built-in web search).

      Setup: Add the Gemini Search MCP server to your Claude Code settings. See the Gemini Search MCP documentation for installation.

      Verification:

      # The agent checks this automatically during /ctx-remember\n# Manual test: ask the agent to search for something\n

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gitnexus","level":3,"title":"GitNexus","text":"

      Provides a code knowledge graph with symbol resolution, blast radius analysis, and domain clustering. Used by skills like /ctx-refactor (impact analysis) and /ctx-code-review (dependency awareness).

      Setup: Add the GitNexus MCP server to your Claude Code settings, then index your project:

      npx gitnexus analyze\n

      Verification:

      # The agent checks this automatically during /ctx-remember\n# If the index is stale, it will suggest rehydrating\n

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#suppressing-the-check","level":3,"title":"Suppressing the Check","text":"

      If you don't use companion tools and want to skip the availability check at session start, add to .ctxrc:

      companion_check: false\n
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#future-direction","level":3,"title":"Future Direction","text":"

      The companion tool integration is evolving toward a pluggable model: bring your own search engine, bring your own code intelligence. The current integration is MCP-based and limited to Gemini Search and GitNexus. If you use a different search or code intelligence tool, skills will degrade gracefully to built-in capabilities.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#next-up","level":2,"title":"Next Up","text":"

      Keeping Context in a Separate Repo →: Store context files outside the project tree for multi-repo or open source setups.

      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: full session lifecycle recipe
      • Multilingual Session Parsing: configure session header prefixes for other languages
      • CLI Reference: all commands and flags
      • Integrations: detailed per-tool integration docs
      ","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multilingual-sessions/","level":1,"title":"Multilingual Session Parsing","text":"","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#the-problem","level":2,"title":"The Problem","text":"

      Your team works across languages. Session files written by AI tools might use headers like # Oturum: 2026-01-15 - API Düzeltme (Turkish) or # セッション: 2026-01-15 - テスト (Japanese) instead of # Session: 2026-01-15 - Fix API.

      By default, ctx only recognizes Session: as a session header prefix. Files with other prefixes are silently skipped during journal import and journal generation: They look like regular Markdown, not sessions.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#tldr","level":2,"title":"TL;DR","text":"

      Add recognized prefixes to .ctxrc:

      session_prefixes:\n  - \"Session:\"      # English (include to keep default)\n  - \"Oturum:\"       # Turkish\n  - \"セッション:\"     # Japanese\n

      Restart your session. All configured prefixes are now recognized.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#how-it-works","level":2,"title":"How It Works","text":"

      The Markdown session parser detects session files by looking for an H1 header that starts with a known prefix followed by a date:

      # Session: 2026-01-15 - Fix API Rate Limiting\n# Oturum: 2026-01-15 - API Düzeltme\n# セッション: 2026-01-15 - テスト\n

      The list of recognized prefixes comes from session_prefixes in .ctxrc. When the key is absent or empty, ctx falls back to the built-in default: [\"Session:\"].

      Date-only headers (# 2026-01-15 - Morning Work) are always recognized regardless of prefix configuration.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#configuration","level":2,"title":"Configuration","text":"","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#adding-a-language","level":3,"title":"Adding a Language","text":"

      Add the prefix with a trailing colon to your .ctxrc:

      session_prefixes:\n  - \"Session:\"\n  - \"Sesión:\"       # Spanish\n

      Include Session: Explicitly

      When you override session_prefixes, the default is replaced, not extended. If you still want English headers recognized, include \"Session:\" in your list.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#team-setup","level":3,"title":"Team Setup","text":"

      Commit .ctxrc to the repo so all team members share the same prefix list. This ensures ctx journal import and journal generation pick up sessions from all team members regardless of language.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#common-prefixes","level":3,"title":"Common Prefixes","text":"Language Prefix English Session: Turkish Oturum: Spanish Sesión: French Session: German Sitzung: Japanese セッション: Korean 세션: Portuguese Sessão: Chinese 会话:","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#verifying","level":3,"title":"Verifying","text":"

      After configuring, test with ctx journal source. Sessions with the new prefixes should appear in the output.

      Activate the Project First

      Run eval \"$(ctx activate)\" from the project root. If you skip it, ctx journal ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#what-this-does-not-do","level":2,"title":"What This Does NOT Do","text":"
      • Change the interface language: ctx output is always English. This setting only controls which session files ctx can parse.
      • Generate headers: ctx never writes session headers. The prefix list is recognition-only (input, not output).
      • Affect JSONL sessions: Claude Code JSONL transcripts don't use header prefixes. This only applies to Markdown session files in .context/sessions/.
      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#see-also","level":2,"title":"See Also","text":"

      See also: Setup Across AI Tools - complete multi-tool setup including Markdown session configuration.

      See also: CLI Reference - full .ctxrc field reference including session_prefixes.

      ","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/parallel-worktrees/","level":1,"title":"Parallel Agent Development with Git Worktrees","text":"","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#the-problem","level":2,"title":"The Problem","text":"

      You have a large backlog (10, 20, 30 open tasks) and many of them are independent: docs work that doesn't touch Go code, a new package that doesn't overlap with existing ones, test coverage for a stable module.

      Running one agent at a time means serial execution. You want 3-4 agents working in parallel, each on its own track, without stepping on each other's files.

      Git worktrees solve this.

      Each worktree is a separate working directory with its own branch, but they share the same .git object database. Combined with ctx's persistent context, each agent session picks up the full project state and works independently.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-worktree                                   # 1. group tasks by file overlap\ngit worktree add ../myproject-docs -b work/docs # 2. create worktrees\ncd ../myproject-docs && claude                  # 3. launch agents (one per track)\n/ctx-worktree teardown docs                     # 4. merge back and clean up\n

      TASKS.md will conflict on merge: Accept all [x] completions from both sides.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-worktree Skill Create, list, and tear down worktrees /ctx-next Skill Pick tasks from the backlog for each track git worktree Command Underlying git worktree management git merge Command Merge completed tracks back to main","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-1-assess-the-backlog","level":3,"title":"Step 1: Assess the Backlog","text":"

      Start in your main checkout. Ask the agent to analyze your tasks and group them by blast radius: which files and directories each task touches.

      /ctx-worktree\nLook at TASKS.md and group the pending tasks into 2-3 independent\ntracks based on which files they'd touch. Show me the grouping\nbefore creating anything.\n

      The agent reads TASKS.md, estimates file overlap, and proposes groups:

      Proposed worktree groups:\n\n  work/docs   # recipe updates, blog post (touches: docs/)\n  work/crypto # scratchpad encryption infra (touches: internal/crypto/)\n  work/tests  # journal test coverage (touches: internal/cli/journal/)\n
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-2-create-the-worktrees","level":3,"title":"Step 2: Create the Worktrees","text":"

      Once you approve the grouping, the agent creates worktrees as sibling directories:

      Create the worktrees for those three groups.\n

      Behind the scenes:

      git worktree add ../myproject-docs -b work/docs\ngit worktree add ../myproject-crypto -b work/crypto\ngit worktree add ../myproject-tests -b work/tests\n

      Each worktree is a full working copy on its own branch.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-3-launch-agents","level":3,"title":"Step 3: Launch Agents","text":"

      Open a separate terminal (or editor window) for each worktree and start a Claude Code session:

      # Terminal 1\ncd ../myproject-docs\nclaude\n\n# Terminal 2\ncd ../myproject-crypto\nclaude\n\n# Terminal 3\ncd ../myproject-tests\nclaude\n

      Each agent sees the full project, including .context/, and can work independently.

      Do Not Initialize Context in Worktrees

      Do not run ctx init in worktrees: The .context directory is already tracked in git.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-4-work","level":3,"title":"Step 4: Work","text":"

      Each agent works through its assigned tasks. They can read TASKS.md to know what's assigned to their track, use /ctx-next to pick the next item, and commit normally on their work/* branch.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-5-merge-back","level":3,"title":"Step 5: Merge Back","text":"

      As each track finishes, return to the main checkout and merge:

      /ctx-worktree teardown docs\n

      The agent checks for uncommitted changes, merges work/docs into your current branch, removes the worktree, and deletes the branch.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-6-handle-tasksmd-conflicts","level":3,"title":"Step 6: Handle TASKS.md Conflicts","text":"

      TASKS.md will almost always conflict when merging: Multiple agents will mark different tasks as [x]. This is expected and easy to resolve:

      Accept all completions from both sides. No task should go from [x] back to [ ]. The merge resolution is always additive.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#step-7-cleanup","level":3,"title":"Step 7: Cleanup","text":"

      After all tracks are merged, verify everything is clean:

      /ctx-worktree list\n

      Should show only the main working tree. All work/* branches should be gone.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't have to use the skill directly for every step. These natural prompts work:

      • \"I have a big backlog. Can we split it across worktrees?\"
      • \"Which of these tasks can run in parallel without conflicts?\"
      • \"Merge the docs track back in.\"
      • \"Clean up all the worktrees, we're done.\"
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#what-works-differently-in-worktrees","level":2,"title":"What Works Differently in Worktrees","text":"

      The encryption key lives at ~/.ctx/.ctx.key (user-level, outside the project). Because all worktrees on the same machine share this path, ctx pad and ctx hook notify work in worktrees automatically - no special setup needed.

      One thing to watch:

      • Journal enrichment: ctx journal import and ctx journal enrich write files relative to the current working directory. Enrichments created in a worktree stay there and are discarded on teardown. Enrich journals on the main branch after merging: the JSONL session logs are always intact, and you don't lose any data.

      Context Files Will Merge Just Fine

      Tracked context files (TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md) work normally; git handles them.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tips","level":2,"title":"Tips","text":"
      • 3-4 worktrees max. Beyond that, merge complexity outweighs the parallelism benefit. The skill enforces this limit.
      • Group by package or directory, not by priority. Two high-priority tasks that touch the same files must be in the same track.
      • TASKS.md will conflict on merge. This is normal. Accept all [x] completions: The resolution is always additive.
      • Don't run ctx init in worktrees. The .context/ directory is tracked in git. Running init overwrites shared context files.
      • Name worktrees by concern, not by number. work/docs and work/crypto are more useful than work/track-1 and work/track-2.
      • Commit frequently in each worktree. Smaller commits make merge conflicts easier to resolve.
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#next-up","level":2,"title":"Next Up","text":"

      Back to the beginning: Guide Your Agent →

      Or explore the full recipe list.

      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#see-also","level":2,"title":"See Also","text":"
      • Running an Unattended AI Agent: for serial autonomous loops instead of parallel tracks
      • Tracking Work Across Sessions: managing the task backlog that feeds into parallelization
      • The Complete Session: the complete session workflow end-to-end, with examples
      ","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/permission-snapshots/","level":1,"title":"Permission Snapshots","text":"","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#the-problem","level":2,"title":"The Problem","text":"

      Claude Code's .claude/settings.local.json accumulates one-off permissions every time you click \"Allow\". After busy sessions the file is full of session-specific entries that expand the agent's surface area beyond intent.

      Since settings.local.json is .gitignored, there is no PR review or CI check. The file drifts independently on every machine, and there is no built-in way to reset to a known-good state.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#tldr","level":2,"title":"TL;DR","text":"
      /ctx-permission-sanitize               # audit for dangerous patterns\nctx permission snapshot            # save golden image\n# ... sessions accumulate cruft ...\nctx permission restore             # reset to golden state\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx permission ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#the-solution","level":2,"title":"The Solution","text":"

      Save a curated settings.local.json as a golden image, then restore from it to drop session-accumulated permissions. The golden file (.claude/settings.golden.json) is committed to version control and shared with the team.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Command/Skill Role in this workflow ctx permission snapshot Save settings.local.json as golden image ctx permission restore Reset settings.local.json from golden image /ctx-permission-sanitize Audit for dangerous patterns before snapshotting","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#step-by-step","level":2,"title":"Step by Step","text":"","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#1-curate-your-permissions","level":3,"title":"1. Curate Your Permissions","text":"

      Start with a clean settings.local.json. Optionally run /ctx-permission-sanitize to remove dangerous patterns first.

      Review the file manually. Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.

      See the Permission Hygiene recipe for recommended defaults.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#2-take-a-snapshot","level":3,"title":"2. Take a Snapshot","text":"
      ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n

      This creates a byte-for-byte copy. No re-encoding, no indent changes.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#3-commit-the-golden-file","level":3,"title":"3. Commit the Golden File","text":"
      git add .claude/settings.golden.json\ngit commit -m \"Add permission golden image\"\n

      The golden file is not gitignored (unlike settings.local.json). This is intentional: it becomes a team-shared baseline.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#4-auto-restore-at-the-session-start","level":3,"title":"4. Auto-Restore at the Session Start","text":"

      Add this instruction to your CLAUDE.md:

      ## On Session Start\n\nRun `ctx permission restore` to reset permissions to the golden image.\n

      The agent will restore the golden image at the start of every session, automatically dropping any permissions accumulated during previous sessions.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#5-update-when-intentional-changes-are-made","level":3,"title":"5. Update When Intentional Changes Are Made","text":"

      When you add a new permanent permission (not a one-off debugging entry):

      # Edit settings.local.json with the new permission\n# Then update the golden image:\nctx permission snapshot\ngit add .claude/settings.golden.json\ngit commit -m \"Update permission golden image: add cargo test\"\n
      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#conversational-approach","level":2,"title":"Conversational Approach","text":"

      You don't need to remember exact commands. These natural-language prompts work with agents trained on the ctx playbook:

      What you say What happens \"Save my current permissions as baseline\" Agent runs ctx permission snapshot \"Reset permissions to the golden image\" Agent runs ctx permission restore \"Clean up my permissions\" Agent runs /ctx-permission-sanitize then snapshot \"What permissions did I accumulate?\" Agent diffs local vs golden","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#next-up","level":2,"title":"Next Up","text":"

      Turning Activity into Content →: Generate blog posts, changelogs, and journal sites from your project activity.

      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#see-also","level":2,"title":"See Also","text":"
      • Permission Hygiene: recommended defaults and maintenance workflow
      • CLI Reference: ctx permission: full command documentation
      ","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/publishing/","level":1,"title":"Turning Activity into Content","text":"","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-problem","level":2,"title":"The Problem","text":"

      Your .context/ directory is full of decisions, learnings, and session history.

      Your git log tells the story of a project evolving.

      But none of this is visible to anyone outside your terminal.

      You want to turn this raw activity into:

      • a browsable journal site,
      • blog posts,
      • changelog posts.
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tldr","level":2,"title":"TL;DR","text":"
      ctx journal import --all             # 1. import sessions to markdown\n\n/ctx-journal-enrich-all             # 2. add metadata and tags\n\nctx journal site --serve            # 3. build and serve the journal\n\n/ctx-blog about the caching layer   # 4. draft a blog post\n/ctx-blog-changelog v0.1.0 \"v0.2\"   # 5. write a changelog post\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx journal ... fails with Error: no context directory specified. See Activating a Context Directory.

      Read on for details on each stage.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx journal import Command Import session JSONL to editable markdown ctx journal site Command Generate a static site from journal entries ctx journal obsidian Command Generate an Obsidian vault from journal entries ctx serve Command Serve any zensical directory (default: journal) ctx site feed Command Generate Atom feed from finalized blog posts make journal Makefile Shortcut for import + site rebuild /ctx-journal-enrich-all Skill Full pipeline: import if needed, then batch-enrich (recommended) /ctx-journal-enrich Skill Add metadata, summaries, and tags to one entry /ctx-blog Skill Draft a blog post from recent project activity /ctx-blog-changelog Skill Write a themed post from a commit range","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-1-import-sessions-to-markdown","level":3,"title":"Step 1: Import Sessions to Markdown","text":"

      Raw session data lives as JSONL files in Claude Code's internal storage. The first step is converting these into readable, editable markdown.

      # Import all sessions from the current project\nctx journal import --all\n\n# Import from all projects (if you work across multiple repos)\nctx journal import --all --all-projects\n\n# Import a single session by ID or slug\nctx journal import abc123\nctx journal import gleaming-wobbling-sutherland\n

      Imported files land in .context/journal/ as individual Markdown files with session metadata and the full conversation transcript.

      --all is safe by default: Only new sessions are imported. Existing files are skipped. Use --regenerate to re-import existing files (YAML frontmatter is preserved). Use --regenerate --keep-frontmatter=false -y to regenerate everything including frontmatter.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-2-enrich-entries-with-metadata","level":3,"title":"Step 2: Enrich Entries with Metadata","text":"

      Raw entries have timestamps and conversations but lack the structured metadata that makes a journal searchable. Use /ctx-journal-enrich-all to process your entire backlog at once:

      /ctx-journal-enrich-all\n

      The skill finds all unenriched entries, filters out noise (suggestion sessions, very short sessions, multipart continuations), and processes each one by extracting titles, topics, technologies, and summaries from the conversation.

      For large backlogs (20+ entries), it can spawn subagents to process entries in parallel.

      To enrich a single entry instead:

      /ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich 2026-01-24\n

      After enrichment, an entry gains YAML frontmatter:

      ---\ntitle: \"Implement Redis caching for API endpoints\"\ndate: 2026-01-24\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - api-performance\ntechnologies:\n  - go\n  - redis\nkey_files:\n  - internal/api/middleware/cache.go\n  - internal/cache/redis.go\n---\n

      This metadata powers better navigation in the journal site:

      • titles replace slugs,
      • summaries appear in the index,
      • and search covers topics and technologies.
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-3-generate-the-journal-site","level":3,"title":"Step 3: Generate the Journal Site","text":"

      With entries exported and enriched, generate the static site:

      # Generate site files\nctx journal site\n\n# Generate and build static HTML\nctx journal site --build\n\n# Generate and serve locally (opens at http://localhost:8000)\nctx journal site --serve\n\n# Custom output directory\nctx journal site --output ~/my-journal\n

      The site is generated in .context/journal-site/ by default. It uses zensical for static site generation (pipx install zensical).

      Or use the Makefile shortcut that combines export and rebuild:

      make journal\n

      This runs ctx journal import --all followed by ctx journal site --build, then reminds you to enrich before rebuilding. To serve the built site, use make journal-serve or ctx serve (serve-only, no regeneration).

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#alternative-export-to-obsidian-vault","level":3,"title":"Alternative: Export to Obsidian Vault","text":"

      If you use Obsidian for knowledge management, generate a vault instead of (or alongside) the static site:

      ctx journal obsidian\nctx journal obsidian --output ~/vaults/ctx-journal\n

      This produces an Obsidian-ready directory with wikilinks, MOC (Map of Content) pages for topics/files/types, and a \"Related Sessions\" footer on each entry for graph connectivity. Open the output directory in Obsidian as a vault.

      The vault uses the same enriched source entries as the static site. Both outputs can coexist: The static site goes to .context/journal-site/, the vault to .context/journal-obsidian/.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-4-draft-blog-posts-from-activity","level":3,"title":"Step 4: Draft Blog Posts from Activity","text":"

      When your project reaches a milestone worth sharing, use /ctx-blog to draft a post from recent activity. The skill gathers context from multiple sources: git log, DECISIONS.md, LEARNINGS.md, completed tasks, and journal entries.

      /ctx-blog about the caching layer we just built\n/ctx-blog last week's refactoring work\n/ctx-blog lessons learned from the migration\n

      The skill gathers recent commits, decisions, and learnings; identifies a narrative arc; drafts an outline for approval; writes the full post; and saves it to docs/blog/YYYY-MM-DD-slug.md.

      Posts are written in first person with code snippets, commit references, and an honest discussion of what went wrong.

      The Output Is zensical-Flavored Markdown

      The blog skills produce Markdown tuned for a zensical site: topics: frontmatter (zensical's tag field), a docs/blog/ output path, and a banner image reference.

      The content is still standard Markdown and can be adapted to other static site generators, but the defaults assume a zensical project structure.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-5-write-changelog-posts-from-commit-ranges","level":3,"title":"Step 5: Write Changelog Posts from Commit Ranges","text":"

      For release notes or \"what changed\" posts, /ctx-blog-changelog takes a starting commit and a theme, then analyzes everything that changed:

      /ctx-blog-changelog 040ce99 \"building the journal system\"\n/ctx-blog-changelog HEAD~30 \"what's new in v0.2.0\"\n/ctx-blog-changelog v0.1.0 \"the road to v0.2.0\"\n

      The skill diffs the commit range, identifies the most-changed files, and constructs a narrative organized by theme rather than chronology, including a key commits table and before/after comparisons.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#step-6-generate-the-blog-feed","level":3,"title":"Step 6: Generate the Blog Feed","text":"

      After publishing blog posts, generate the Atom feed so readers and automation can discover new content:

      ctx site feed\n

      This scans docs/blog/ for finalized posts (reviewed_and_finalized: true), extracts title, date, author, topics, and summary, and writes a valid Atom 1.0 feed to site/feed.xml. The feed is also generated automatically as part of make site.

      The feed is available at ctx.ist/feed.xml.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-conversational-approach","level":2,"title":"The Conversational Approach","text":"

      You can also drive your publishing anytime with natural language:

      \"write about what we did this week\"\n\"turn today's session into a blog post\"\n\"make a changelog post covering everything since the last release\"\n\"enrich the last few journal entries\"\n

      The agent has full visibility into your .context/ state (tasks completed, decisions recorded, learnings captured), so its suggestions are grounded in what actually happened.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      The full pipeline from raw transcripts to published content:

      # 1. Import all sessions\nctx journal import --all\n\n# 2. In Claude Code: enrich all entries with metadata\n/ctx-journal-enrich-all\n\n# 3. Build and serve the journal site\nmake journal\nmake journal-serve\n\n# 3b. Or generate an Obsidian vault\nctx journal obsidian\n\n# 4. In Claude Code: draft a blog post\n/ctx-blog about the features we shipped this week\n\n# 5. In Claude Code: write a changelog post\n/ctx-blog-changelog v0.1.0 \"what's new in v0.2.0\"\n

      The journal pipeline is idempotent at every stage. You can rerun ctx journal import --all without losing enrichment. You can rebuild the site as many times as you want.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tips","level":2,"title":"Tips","text":"
      • Import regularly. Run ctx journal import --all after each session to keep your journal current. Only new sessions are imported: Existing files are skipped by default.
      • Use batch enrichment. /ctx-journal-enrich-all filters noise (suggestion sessions, trivial sessions, multipart continuations) so you do not have to decide what is worth enriching.
      • Keep journal files in .gitignore. Session journals can contain sensitive data: file contents, commands, internal discussions, and error messages with stack traces. Add .context/journal/ and .context/journal-site/ to .gitignore.
      • Use /ctx-blog for narrative posts and /ctx-blog-changelog for release posts. One finds a story in recent activity, the other explains a commit range by theme.
      • Edit the drafts. These skills produce drafts, not final posts. Review the narrative, add your perspective, and remove anything that does not serve the reader.
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#next-up","level":2,"title":"Next Up","text":"

      Running an Unattended AI Agent →: Set up an AI agent that works through tasks overnight without you at the keyboard.

      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#see-also","level":2,"title":"See Also","text":"
      • Session Journal: journal system, enrichment schema
      • CLI Reference: ctx journal: import, list, show session history
      • CLI Reference: ctx journal site: static site generation
      • CLI Reference: ctx journal obsidian: Obsidian vault export
      • CLI Reference: ctx serve: serve-only (no regeneration)
      • Browsing and Enriching Past Sessions: journal browsing workflow
      • The Complete Session: capturing context during a session
      ","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/scratchpad-sync/","level":1,"title":"Syncing Scratchpad Notes Across Machines","text":"","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#the-problem","level":2,"title":"The Problem","text":"

      You work from multiple machines: a desktop and a laptop, or a local machine and a remote dev server.

      The scratchpad entries are encrypted. The ciphertext (.context/scratchpad.enc) travels with git, but the encryption key lives outside the project at ~/.ctx/.ctx.key and is never committed. Without the key on each machine, you cannot read or write entries.

      How do you distribute the key and keep the scratchpad in sync?

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tldr","level":2,"title":"TL;DR","text":"
      ctx init                                                  # 1. generates key\neval \"$(ctx activate)\"                                    # 2. bind CTX_DIR\nscp ~/.ctx/.ctx.key user@machine-b:~/.ctx/.ctx.key        # 3. copy key\nchmod 600 ~/.ctx/.ctx.key                                 # 4. secure it\n# Normal git push/pull syncs the encrypted scratchpad.enc\n# On conflict: ctx pad resolve → rebuild → git add + commit\n

      Activate Each Machine

      Run eval \"$(ctx activate)\" from the project root on every machine that reads or writes the scratchpad: after each ctx init, or after each clone on machine B. If you skip it, ctx pad ... fails with Error: no context directory specified. See Activating a Context Directory.

      Finding Your Key File

      The key is always at ~/.ctx/.ctx.key - one key, one machine.

      Treat the Key like a Password

      The scratchpad key is the only thing protecting your encrypted entries.

      Store a backup in a secure enclave such as a password manager, and treat it with the same care you would give passwords, certificates, or API tokens.

      Anyone with the key can decrypt every scratchpad entry.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx init CLI command Initialize context (generates the key automatically) ctx pad add CLI command Add a scratchpad entry ctx pad rm CLI command Remove entries by stable ID (supports ranges) ctx pad edit CLI command Edit a scratchpad entry ctx pad resolve CLI command Show both sides of a merge conflict ctx pad merge CLI command Merge entries from other scratchpad files ctx pad import CLI command Bulk-import lines from a file ctx pad export CLI command Export blob entries to a directory scp Shell Copy the key file between machines git push / git pull Shell Sync the encrypted file via git /ctx-pad Skill Natural language interface to pad commands","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-1-initialize-on-machine-a","level":3,"title":"Step 1: Initialize on Machine A","text":"

      Run ctx init on your first machine. The key is created automatically at ~/.ctx/.ctx.key:

      ctx init\n# ...\n# Created ~/.ctx/.ctx.key (0600)\n# Created .context/scratchpad.enc\n

      The key lives outside the project directory and is never committed. The .enc file is tracked in git.

      Key Folder Change (v0.7.0+)

      If you built ctx from source or upgraded past v0.6.0, the key location changed to ~/.ctx/.ctx.key. Check these legacy folders and copy your key manually:

      # Old locations (pick whichever exists)\nls ~/.local/ctx/keys/        # pre-v0.7.0 user-level\nls .context/.ctx.key         # pre-v0.6.0 project-local\n\n# Copy to the new location\nmkdir -p ~/.ctx && chmod 700 ~/.ctx\ncp <old-key-path> ~/.ctx/.ctx.key\nchmod 600 ~/.ctx/.ctx.key\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-2-copy-the-key-to-machine-b","level":3,"title":"Step 2: Copy the Key to Machine B","text":"

      Use any secure transfer method. The key is always at ~/.ctx/.ctx.key:

      # scp - create the target directory first\nssh user@machine-b \"mkdir -p ~/.ctx && chmod 700 ~/.ctx\"\nscp ~/.ctx/.ctx.key user@machine-b:~/.ctx/.ctx.key\n\n# Or use a password manager, USB drive, etc.\n

      Set permissions on Machine B:

      chmod 600 ~/.ctx/.ctx.key\n

      Secure the Transfer

      The key is a raw 256-bit AES key. Anyone with the key can decrypt the scratchpad. Use an encrypted channel (SSH, password manager, vault).

      Never paste it in plaintext over email or chat.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-3-normal-pushpull-workflow","level":3,"title":"Step 3: Normal Push/Pull Workflow","text":"

      The encrypted file is committed, so standard git sync works:

      # Machine A: add entries and push\nctx pad add \"staging API key: sk-test-abc123\"\ngit add .context/scratchpad.enc\ngit commit -m \"Update scratchpad\"\ngit push\n\n# Machine B: pull and read\ngit pull\nctx pad\n#   1. staging API key: sk-test-abc123\n

      Both machines have the same key, so both can decrypt the same .enc file.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-4-read-and-write-from-either-machine","level":3,"title":"Step 4: Read and Write from Either Machine","text":"

      Once the key is distributed, all ctx pad commands work identically on both machines. Entries added on Machine A are visible on Machine B after a git pull, and vice versa.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#step-5-handle-merge-conflicts","level":3,"title":"Step 5: Handle Merge Conflicts","text":"

      If both machines add entries between syncs, pulling will create a merge conflict on .context/scratchpad.enc. Git cannot merge binary (encrypted) content automatically.

      The fastest approach is ctx pad merge: It reads both conflict sides, deduplicates, and writes the union:

      # Extract theirs to a temp file, then merge it in\ngit show :3:.context/scratchpad.enc > /tmp/theirs.enc\ngit checkout --ours .context/scratchpad.enc\nctx pad merge /tmp/theirs.enc\n\n# Done: Commit the resolved scratchpad:\ngit add .context/scratchpad.enc\ngit commit -m \"Resolve scratchpad merge conflict\"\n

      Alternatively, use ctx pad resolve to inspect both sides manually:

      ctx pad resolve\n# === Ours (this machine) ===\n#   1. staging API key: sk-test-abc123\n#   2. check DNS after deploy\n#\n# === Theirs (incoming) ===\n#   1. staging API key: sk-test-abc123\n#   2. new endpoint: api.example.com/v2\n

      Then reconstruct the merged scratchpad:

      # Start fresh with all entries from both sides\nctx pad add \"staging API key: sk-test-abc123\"\nctx pad add \"check DNS after deploy\"\nctx pad add \"new endpoint: api.example.com/v2\"\n\n# Mark the conflict resolved\ngit add .context/scratchpad.enc\ngit commit -m \"Resolve scratchpad merge conflict\"\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#merge-conflict-walkthrough","level":2,"title":"Merge Conflict Walkthrough","text":"

      Here's a full scenario showing how conflicts arise and how to resolve them:

      1. Both machines start in sync (1 entry):

      Machine A: 1. staging API key: sk-test-abc123\nMachine B: 1. staging API key: sk-test-abc123\n

      2. Both add entries independently:

      Machine A adds: \"check DNS after deploy\"\nMachine B adds: \"new endpoint: api.example.com/v2\"\n

      3. Machine A pushes first. Machine B pulls and gets a conflict:

      git pull\n# CONFLICT (content): Merge conflict in .context/scratchpad.enc\n

      4. Machine B runs ctx pad resolve:

      ctx pad resolve\n# === Ours ===\n#   1. staging API key: sk-test-abc123\n#   2. new endpoint: api.example.com/v2\n#\n# === Theirs ===\n#   1. staging API key: sk-test-abc123\n#   2. check DNS after deploy\n

      5. Rebuild with entries from both sides and commit:

      # Clear and rebuild (or use the skill to guide you)\nctx pad add \"staging API key: sk-test-abc123\"\nctx pad add \"check DNS after deploy\"\nctx pad add \"new endpoint: api.example.com/v2\"\n\ngit add .context/scratchpad.enc\ngit commit -m \"Merge scratchpad: keep entries from both machines\"\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#conversational-approach","level":3,"title":"Conversational Approach","text":"

      When working with an AI assistant, you can resolve conflicts naturally:

      You: \"I have a scratchpad merge conflict. Can you resolve it?\"\n\nAgent: \"Let me extract theirs and merge it in.\"\n       [runs git show :3:.context/scratchpad.enc > /tmp/theirs.enc]\n       [runs git checkout --ours .context/scratchpad.enc]\n       [runs ctx pad merge /tmp/theirs.enc]\n       \"Merged 2 new entries (1 duplicate skipped). Want me to\n       commit the resolution?\"\n
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tips","level":2,"title":"Tips","text":"
      • Back up the key: If you lose it, you lose access to all encrypted entries. Store a copy in your password manager.
      • One key per project: Each ctx init generates a unique key. Don't reuse keys across projects.
      • Keys work in worktrees: Because the key lives at ~/.ctx/.ctx.key (outside the project), git worktrees on the same machine share the key automatically. No special setup needed.
      • Plaintext fallback for non-sensitive projects: If encryption adds friction and you have nothing sensitive, set scratchpad_encrypt: false in .ctxrc. Merge conflicts become trivial text merges.
      • Never commit the key: The key is stored outside the project at ~/.ctx/.ctx.key and should never be copied into the repository.
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#next-up","level":2,"title":"Next Up","text":"

      Hook Output Patterns →: Choose the right output pattern for your Claude Code hooks.

      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#see-also","level":2,"title":"See Also","text":"
      • Scratchpad: feature overview, all commands, when to use scratchpad vs context files
      • Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad
      ","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-with-claude/","level":1,"title":"Using the Scratchpad","text":"","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#the-problem","level":2,"title":"The Problem","text":"

      During a session you accumulate quick notes, reminders, intermediate values, and sometimes sensitive tokens. They don't fit TASKS.md (not work items) or DECISIONS.md (not decisions). They don't have the structured fields that LEARNINGS.md requires.

      Without somewhere to put them, they get lost between sessions.

      How do you capture working memory that persists across sessions without polluting your structured context files?

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tldr","level":2,"title":"TL;DR","text":"
      ctx pad add \"check DNS propagation after deploy\"\nctx pad         # list entries\nctx pad show 1  # print entry (pipe-friendly)\n

      Entries are encrypted at rest and travel with git.

      Use the /ctx-pad skill to manage entries from inside your AI session.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx pad ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx pad CLI command List all scratchpad entries ctx pad show N CLI command Output raw text of entry N (pipe-friendly) ctx pad add CLI command Add a new entry ctx pad edit CLI command Replace, append to, or prepend to an entry ctx pad add --file CLI command Ingest a file as a blob entry ctx pad show N --out CLI command Extract a blob entry to a file ctx pad rm CLI command Remove entries by stable ID (supports ranges) ctx pad normalize CLI command Reassign entry IDs as 1..N ctx pad mv CLI command Reorder entries ctx pad --tag CLI command Filter entries by tag ctx pad tags CLI command List all tags with counts ctx pad import CLI command Bulk-import lines from a file (or stdin) ctx pad export CLI command Export all blob entries to a directory /ctx-pad Skill Natural language interface to all pad commands","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-1-add-a-note-naturally","level":3,"title":"Step 1: Add a Note Naturally","text":"

      You don't need to remember any syntax. Just tell your assistant what to jot down:

      You: \"jot down: check DNS propagation after deploy\"\n\nAgent: \"Added to scratchpad:\n  1. check DNS propagation after deploy\"\n

      Behind the scenes, the agent runs ctx pad add \"check DNS propagation after deploy\".

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-2-view-your-scratchpad","level":3,"title":"Step 2: View Your Scratchpad","text":"
      You: \"show my scratchpad\"\n\nAgent: \"Your scratchpad has 3 entries:\n  1. check DNS propagation after deploy\n  2. staging API endpoint: api.staging.example.com/v2\n  3. retry limit should be 5, not 3\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-3-edit-an-entry","level":3,"title":"Step 3: Edit an Entry","text":"
      You: \"update entry 2 to include the new endpoint\"\n\nAgent: \"Updated entry 2:\n  was: staging API endpoint: api.staging.example.com/v2\n  now: staging API endpoint: api.prod.example.com/v2\"\n

      For partial edits, the agent can use --append or --prepend:

      You: \"append the port number to entry 2\"\n\nAgent: \"Updated entry 2:\n  staging API endpoint: api.prod.example.com/v2 :8443\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-4-compose-entries","level":3,"title":"Step 4: Compose Entries","text":"

      Use ctx pad show N to pipe entry content into other operations:

      You: \"append the content of entry 3 to entry 1\"\n\nAgent: [runs ctx pad edit 1 --append \"$(ctx pad show 3)\"]\n       \"Done. Entry 1 is now:\n        check DNS propagation after deploy retry limit should be 5, not 3\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-5-reorder-by-priority","level":3,"title":"Step 5: Reorder by Priority","text":"
      You: \"move entry 4 to the top\"\n\nAgent: [runs ctx pad mv 4 1]\n       \"Moved entry 4 to position 1. Scratchpad reordered.\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-6-clean-up","level":3,"title":"Step 6: Clean Up","text":"
      You: \"remove entry 2, it's done\"\n\nAgent: [runs ctx pad rm 2]\n       \"Removed entry 2. 3 entries remaining.\n        (IDs are stable; remaining entries keep their IDs.)\"\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-7-store-a-file-as-a-blob","level":3,"title":"Step 7: Store a File as a Blob","text":"

      The scratchpad can hold small files (up to 64 KB) as encrypted blob entries. The file is base64-encoded and stored alongside a label you provide:

      # Ingest a file: the first argument is the label\nctx pad add \"deploy config\" --file ./deploy.yaml\n\n# List shows the label with a [BLOB] marker\nctx pad\n#   1. check DNS propagation after deploy\n#   2. deploy config [BLOB]\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-8-extract-a-blob","level":3,"title":"Step 8: Extract a Blob","text":"

      Use show --out to write the decoded file back to disk:

      # Write blob entry to a file\nctx pad show 2 --out ./recovered-deploy.yaml\n\n# Or print to stdout (for piping)\nctx pad show 2 | head -5\n

      Blob entries are encrypted identically to text entries: They're just base64-encoded before encryption. The --out flag decodes and writes the raw bytes.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-9-bulk-import-notes","level":3,"title":"Step 9: Bulk Import Notes","text":"

      When you have a file with many notes (one per line), import them in bulk instead of adding one at a time:

      # Import from a file: Each non-empty line becomes an entry\nctx pad import notes.txt\n\n# Or pipe from stdin\ngrep TODO *.go | ctx pad import -\n

      All entries are written in a single encrypt/write cycle, regardless of how many lines the file contains.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-10-export-blobs-to-disk","level":3,"title":"Step 10: Export Blobs to Disk","text":"

      Export all blob entries to a directory as individual files. Each blob's label becomes the filename:

      # Export to a directory (created if needed)\nctx pad export ./ideas\n\n# Preview what would be exported\nctx pad export --dry-run ./ideas\n\n# Force overwrite existing files\nctx pad export --force ./backup\n

      When a file already exists, a unix timestamp is prepended to the filename to avoid collisions. Use --force to overwrite instead.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#step-11-tag-entries-for-organization","level":3,"title":"Step 11: Tag Entries for Organization","text":"

      Tags let you categorize entries without any structure beyond a #word token in the text. Add them when creating or editing entries:

      You: \"jot down: check DNS propagation #later\"\nYou: \"tag entry 2 as urgent\"\n\nAgent: [runs ctx pad edit 2 --tag urgent]\n       \"Updated entry 2.\"\n

      Filter your scratchpad by tag:

      You: \"show me everything tagged later\"\n\nAgent: [runs ctx pad --tag later]\n       \"  1. check DNS propagation #later\n        3. review PR feedback #later #ci\"\n

      Entry IDs are stable; they don't shift when other entries are deleted, so ctx pad rm 3 always targets the same entry regardless of deletions or active filters. Use ctx pad normalize to reassign IDs as 1..N.

      Exclude a tag with ~:

      ctx pad --tag ~later         # everything NOT tagged #later\nctx pad --tag later --tag ci # entries with BOTH tags (AND logic)\n

      See what tags you're using:

      You: \"what tags do I have?\"\n\nAgent: [runs ctx pad tags]\n       \"ci       1\n        later    2\n        urgent   1\"\n

      Tags work on blob entries too; they're extracted from the label:

      ctx pad add \"deploy config #prod\" --file ./deploy.yaml\nctx pad --tag prod\n#   1. deploy config #prod [BLOB]\n
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#using-ctx-pad-in-a-session","level":2,"title":"Using /ctx-pad in a Session","text":"

      Invoke the /ctx-pad skill first, then describe what you want in natural language. Without the skill prefix, the agent may route your request to TASKS.md or another context file instead of the scratchpad.

      You: /ctx-pad jot down: check DNS after deploy\nYou: /ctx-pad show my scratchpad\nYou: /ctx-pad delete entry 3\n

      Once the skill is active, it translates intent into commands:

      You say (after /ctx-pad) What the agent does \"jot down: check DNS after deploy\" ctx pad add \"check DNS after deploy\" \"remember this: retry limit is 5\" ctx pad add \"retry limit is 5\" \"show my scratchpad\" / \"what's on my pad\" ctx pad \"show me entry 3\" ctx pad show 3 \"delete the third one\" / \"remove entry 3\" ctx pad rm 3 \"remove entries 3 through 5\" ctx pad rm 3-5 \"renumber my scratchpad\" ctx pad normalize \"change entry 2 to ...\" ctx pad edit 2 \"new text\" \"append ' +important' to entry 3\" ctx pad edit 3 --append \" +important\" \"prepend 'URGENT:' to entry 1\" ctx pad edit 1 --prepend \"URGENT: \" \"prioritize entry 4\" / \"move to the top\" ctx pad mv 4 1 \"import my notes from notes.txt\" ctx pad import notes.txt \"export all blobs to ./ideas\" ctx pad export ./ideas \"show entries tagged later\" ctx pad --tag later \"show everything except later\" ctx pad --tag ~later \"what tags do I have\" ctx pad tags \"tag entry 5 as urgent\" ctx pad edit 5 --tag urgent

      When in Doubt, Use the CLI Directly

      The ctx pad commands work the same whether you run them yourself or let the skill invoke them.

      If the agent misroutes a request, fall back to ctx pad add \"...\" in your terminal.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#when-to-use-scratchpad-vs-context-files","level":2,"title":"When to Use Scratchpad vs Context Files","text":"Situation Use Temporary reminders (\"check X after deploy\") Scratchpad Session-start reminders (\"remind me next session\") ctx remind Working values during debugging (ports, endpoints, counts) Scratchpad Sensitive tokens or API keys (short-term storage) Scratchpad Quick notes that don't fit anywhere else Scratchpad Work items with completion tracking TASKS.md Trade-offs between alternatives with rationale DECISIONS.md Reusable lessons with context/lesson/application LEARNINGS.md Codified patterns and standards CONVENTIONS.md

      Decision Guide

      • If it has structured fields (context, rationale, lesson, application), it belongs in a context file like DECISIONS.md or LEARNINGS.md.
      • If it's a work item you'll mark done, it belongs in TASKS.md.
      • If you want a message relayed VERBATIM at the next session start, it belongs in ctx remind.
      • If it's a quick note, reminder, or working value (especially if it's sensitive or ephemeral) it belongs on the scratchpad.

      Scratchpad Is Not a Junk Drawer

      The scratchpad is for working memory, not long-term storage.

      If a note is still relevant after several sessions, promote it:

      A persistent reminder becomes a task, a recurring value becomes a convention, a hard-won insight becomes a learning.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tips","level":2,"title":"Tips","text":"
      • Entries persist across sessions: The scratchpad is committed (encrypted) to git, so entries survive session boundaries. Pick up where you left off.
      • Entries are numbered and reorderable: Use ctx pad mv to put high-priority items at the top.
      • ctx pad show N enables unix piping: Output raw entry text with no numbering prefix. Compose with --append, --prepend, or other shell tools.
      • Never mention the key file contents to the AI: The agent knows how to use ctx pad commands but should never read or print the encryption key (~/.ctx/.ctx.key) directly.
      • Encryption is transparent: You interact with plaintext; the encryption/decryption happens automatically on every read/write.
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#next-up","level":2,"title":"Next Up","text":"

      Syncing Scratchpad Notes Across Machines →: Distribute encryption keys and scratchpad data across environments.

      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#see-also","level":2,"title":"See Also","text":"
      • Scratchpad: feature overview, all commands, encryption details, plaintext override
      • Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad
      • The Complete Session: full session lifecycle showing how the scratchpad fits into the broader workflow
      ","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/","level":1,"title":"Scrutinizing a Plan","text":"

      When you have a plan and want it attacked, not validated, the /ctx-plan skill runs an adversarial interview. It surfaces what's weak, missing, or unexamined before you commit.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#when-to-use-it","level":2,"title":"When to Use It","text":"
      • Before starting a multi-day implementation.
      • After writing a spec but before opening the first PR.
      • When the team aligned suspiciously fast on a complex change.
      • When you've drafted something and the obvious next step is to hand it to a senior reviewer.

      /ctx-plan is not a brainstorming tool. Use /ctx-brainstorm for that. /ctx-plan assumes the plan exists and asks: does it survive contact with reality?

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#stop-conditions","level":2,"title":"Stop Conditions","text":"

      The skill runs depth-first through assumptions, tradeoffs, and failure modes. Stop when one of these is true:

      • Plan converges. The bet is clear, the sequencing is justified, and you can articulate what would falsify it.
      • Plan dissolves. The interview surfaces a load-bearing assumption you can't defend; the plan needs rework, not more scrutiny.
      • You hit information you don't have. Pause, gather it, resume.

      If the agent loops on a single angle (asking variations of the same question), say so. The skill is designed to walk depth-first, not exhaust one branch.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#worked-example","level":2,"title":"Worked Example","text":"
      You: /ctx-plan\n\nI want to migrate our queue from RabbitMQ to NATS. I've drafted a\ntwo-week plan: spike NATS in staging, port one consumer, port the\nrest, decommission RabbitMQ.\n\nAgent: One question at a time. What breaks if your message ordering\n       guarantees aren't equivalent across the two systems?\n\nYou: NATS gives us per-subject ordering by default; we don't actually\n     need cross-subject ordering, so I think we're fine.\n\nAgent: How would you notice if you were wrong? What's the loudest\n       symptom of a stray out-of-order message in production today?\n\nYou: ...probably a duplicate notification. Which we already see\n     occasionally. So we wouldn't notice immediately.\n\nAgent: Then your migration's correctness check needs to be stronger\n       than \"no incidents.\" Before you port consumer two, what\n       evidence would convince you that consumer one's ordering\n       behavior is correct under load?\n\nYou: Right. Add a dedicated assertion test in staging that replays\n     a known-out-of-order sequence and verifies the consumer\n     dedupes correctly. Otherwise we're just hoping.\n\nAgent: Good. Next: what would change your mind about NATS itself?\n       What rejected alternative is closest to coming back?\n

      The interview keeps going until the bet is articulated, the falsifiable conditions are written down, and the rejected alternatives have a recall trigger.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#output","level":2,"title":"Output","text":"

      /ctx-plan produces a clearer plan, not a document. Persist the deltas via:

      • /ctx-spec if the conclusions belong in a feature spec.
      • /ctx-decision-add if a tradeoff resolved into an architectural decision.
      • /ctx-learning-add if you discovered a project-specific gotcha during the interview.

      The skill itself is in internal/assets/claude/skills/ctx-plan/SKILL.md; the working contract lives there, the recipe is the on-ramp.

      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#see-also","level":2,"title":"See Also","text":"
      • Design Before Coding: the brainstorming counterpart, used before a plan exists.
      • ctx-spec: scaffolds a feature spec from the project template.
      ","path":["Scrutinizing a Plan"],"tags":[]},{"location":"recipes/session-archaeology/","level":1,"title":"Browsing and Enriching Past Sessions","text":"","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-problem","level":2,"title":"The Problem","text":"

      After weeks of AI-assisted development you have dozens of sessions scattered across JSONL files in ~/.claude/projects/. Finding the session where you debugged the Redis connection pool, or remembering what you decided about the caching strategy three Tuesdays ago, often means grepping raw JSON.

      There is no table of contents, no search, and no summaries.

      This recipe shows how to turn that raw session history into a browsable, searchable, and enriched journal site you can navigate in your browser.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tldr","level":2,"title":"TL;DR","text":"

      Export and Generate

      ctx journal import --all\nctx journal site --serve\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, the ctx journal ... commands below fail with Error: no context directory specified. See Activating a Context Directory.

      Enrich

      /ctx-journal-enrich-all\n

      Rebuild

      ctx journal site --serve\n

      Read on for what each stage does and why.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx journal source Command List parsed sessions with metadata ctx journal source --show Command Inspect a specific session in detail ctx journal import Command Import sessions to editable journal Markdown ctx journal site Command Generate a static site from journal entries ctx journal obsidian Command Generate an Obsidian vault from journal entries ctx journal schema check Command Validate JSONL files and report schema drift ctx journal schema dump Command Print the embedded JSONL schema definition ctx serve Command Serve any zensical directory (default: journal) /ctx-history Skill Browse sessions inside your AI assistant /ctx-journal-enrich Skill Add frontmatter metadata to a single entry /ctx-journal-enrich-all Skill Full pipeline: import if needed, then batch-enrich","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-workflow","level":2,"title":"The Workflow","text":"

      The session journal follows a four-stage pipeline.

      Each stage is idempotent and safe to re-run:

      By default, each stage skips entries that have already been processed.

      import -> enrich -> rebuild\n
      Stage Tool What it does Skips if Where Import ctx journal import --all Converts session JSONL to Markdown File already exists (safe default) CLI or agent Enrich /ctx-journal-enrich-all Adds frontmatter, summaries, topic tags Frontmatter already present Agent only Rebuild ctx journal site --build Generates browsable static HTML N/A CLI only Obsidian ctx journal obsidian Generates Obsidian vault with wikilinks N/A CLI only

      Where Do You Run Each Stage?

      Import (Steps 1 to 3) works equally well from the terminal or inside your AI assistant via /ctx-history. The CLI is fine here: the agent adds no special intelligence, it just runs the same command.

      Enrich (Step 4) requires the agent: it reads conversation content and produces structured metadata.

      Rebuild and serve (Step 5) is a terminal operation that starts a long-running server.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-1-list-your-sessions","level":3,"title":"Step 1: List Your Sessions","text":"

      Start by seeing what sessions exist for the current project:

      ctx journal source\n

      Sample output:

      Sessions (newest first)\n=======================\n\n  Slug                           Project   Date         Duration  Turns  Tokens\n  gleaming-wobbling-sutherland   ctx       2026-02-07   1h 23m    47     82,341\n  twinkly-stirring-kettle        ctx       2026-02-06   0h 45m    22     38,102\n  bright-dancing-hopper          ctx       2026-02-05   2h 10m    63     124,500\n  quiet-flowing-dijkstra         ctx       2026-02-04   0h 18m    11     15,230\n  ...\n

      Slugs Look Cryptic?

      These auto-generated slugs (gleaming-wobbling-sutherland) are hard to recognize later.

      Use /ctx-journal-enrich to add human-readable titles, topic tags, and summaries to exported journal entries, making them easier to find.

      Filter by project or tool if you work across multiple codebases:

      ctx journal source --project ctx --limit 10\nctx journal source --tool claude-code\nctx journal source --all-projects\n
      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-2-inspect-a-specific-session","level":3,"title":"Step 2: Inspect a Specific Session","text":"

      Before exporting everything, inspect a single session to see its metadata and conversation summary:

      ctx journal source --show --latest\n

      Or look up a specific session by its slug, partial ID, or UUID:

      ctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show twinkly\nctx journal source --show abc123\n

      Add --full to see the complete message content instead of the summary view:

      ctx journal source --show --latest --full\n

      This is useful for checking what happened before deciding whether to export and enrich it.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-3-import-sessions-to-the-journal","level":3,"title":"Step 3: Import Sessions to the Journal","text":"

      Import converts raw session data into editable Markdown files in .context/journal/:

      # Import all sessions from the current project\nctx journal import --all\n\n# Import a single session\nctx journal import gleaming-wobbling-sutherland\n\n# Include sessions from all projects\nctx journal import --all --all-projects\n

      --keep-frontmatter=false Discards Enrichments

      --keep-frontmatter=false discards enriched YAML frontmatter during regeneration.

      Back up your journal before using this flag.

      Each imported file contains session metadata (date, time, duration, model, project, git branch), a tool usage summary, and the full conversation transcript.

      Re-importing is safe. Running ctx journal import --all only imports new sessions: Existing files are never touched. Use --dry-run to preview what would be imported without writing anything.

      To re-import existing files (e.g., after a format improvement), use --regenerate: Conversation content is regenerated while preserving any YAML frontmatter you or the enrichment skill has added. You'll be prompted before any files are overwritten.

      --regenerate Replaces the Markdown Body

      --regenerate preserves YAML frontmatter but replaces the entire Markdown body with freshly generated content from the source JSONL.

      If you manually edited the conversation transcript (added notes, redacted sensitive content, restructured sections), those edits will be lost.

      BACK UP YOUR JOURNAL FIRST.

      To protect entries you've hand-edited, you can explicitly lock them:

      ctx journal lock <pattern>\n

      Locked entries are always skipped, regardless of flags.

      If you prefer to add locked: true directly in frontmatter during enrichment, run ctx journal sync to propagate the lock state to .state.json:

      ctx journal sync\n

      See ctx journal lock --help and ctx journal sync --help for details.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-4-enrich-with-metadata","level":3,"title":"Step 4: Enrich with Metadata","text":"

      Raw imports have timestamps and transcripts but lack the semantic metadata that makes sessions searchable: topics, technology tags, outcome status, and summaries. The /ctx-journal-enrich* skills add this structured frontmatter.

      Locked entries are skipped by enrichment skills, just as they are by import. Lock entries you want to protect before running batch enrichment.

      Batch enrichment (recommended):

      /ctx-journal-enrich-all\n

      The skill finds all unenriched entries, filters out noise (suggestion sessions, very short sessions, multipart continuations), and processes each one by extracting titles, topics, technologies, and summaries from the conversation.

      It shows you a grouped summary before applying changes so you can scan quickly rather than reviewing one by one.

      For large backlogs (20+ entries), the skill can spawn subagents to process entries in parallel.

      Single-entry enrichment:

      /ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-02-06\n

      Each enriched entry gets YAML frontmatter like this:

      ---\ntitle: \"Implement Redis caching middleware\"\ndate: 2026-02-06\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - api-performance\ntechnologies:\n  - go\n  - redis\nlibraries:\n  - go-redis/redis\nkey_files:\n  - internal/cache/redis.go\n  - internal/api/middleware/cache.go\n---\n

      The skill also generates a summary and can extract decisions, learnings, and tasks mentioned during the session.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#step-5-generate-and-serve-the-site","level":3,"title":"Step 5: Generate and Serve the Site","text":"

      With imported and enriched journal files, generate the static site:

      # Generate site structure only\nctx journal site\n\n# Generate and build static HTML\nctx journal site --build\n\n# Generate, build, and serve locally\nctx journal site --serve\n

      Then open http://localhost:8000 to browse.

      The site includes a date-sorted index, individual session pages with full conversations, search (press /), dark mode, and enriched titles in the navigation when frontmatter exists.

      You can also serve an already-generated site without regenerating using ctx serve (serve-only, no regeneration).

      The site generator requires zensical (pipx install zensical).

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#where-does-agent-add-value","level":2,"title":"Where Does Agent Add Value?","text":"

      Export, list, and show are mechanical: The agent runs the same CLI commands you would, so you can stay in your terminal for those.

      The agent earns its keep in enrich. It reads conversation content, understands what happened, and produces structured metadata. That is agent work, not CLI work.

      You can also ask your agent to browse sessions conversationally instead of remembering flags:

      What did we work on last week?\nShow me the session about Redis.\nImport everything to the journal.\n

      This is convenient but not required: ctx journal source gives you the same inventory.

      Where the agent genuinely helps is chaining the pipeline:

      You:   What happened last Tuesday?\nAgent: Last Tuesday you worked on two sessions:\n       - bright-dancing-hopper (2h 10m): refactored the middleware\n         pipeline and added Redis caching\n       - quiet-flowing-dijkstra (18m): quick fix for a nil pointer\n         in the config loader\n       Want me to export and enrich them?\nYou:   Yes, do it.\nAgent: Exports both, enriches, then proposes frontmatter.\n

      The value is staying in one context while the agent runs import -> enrich without you manually switching tools.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      A typical pipeline from raw sessions to a browsable site:

      # Terminal: import and generate\nctx journal import --all\nctx journal site --serve\n
      # AI assistant: enrich\n/ctx-journal-enrich-all\n
      # Terminal: rebuild with enrichments\nctx journal site --serve\n

      If your project includes Makefile.ctx (deployed by ctx init), use make journal to combine import and rebuild stages. Then enrich inside Claude Code, then make journal again to pick up enrichments.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#session-retention-and-cleanup","level":2,"title":"Session Retention and Cleanup","text":"

      Claude Code does not keep JSONL transcripts forever. Understanding its cleanup behavior helps you avoid losing session history.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#default-behavior","level":3,"title":"Default Behavior","text":"

      Claude Code retains session transcripts for approximately 30 days. After that, JSONL files are automatically deleted during cleanup. Once deleted, ctx journal can no longer see those sessions - the data is gone.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-cleanupperioddays-setting","level":3,"title":"The cleanupPeriodDays Setting","text":"

      Claude Code exposes a cleanupPeriodDays setting in its configuration (~/.claude/settings.json) that controls retention:

      Value Behavior 30 (default) Transcripts older than 30 days are deleted 60, 90, etc. Extends the retention window 0 Disables writing new transcripts entirely - not \"keep forever\"

      Setting cleanupPeriodDays To 0

      Setting this to 0 does not mean \"never delete.\" It disables transcript creation altogether. No new JSONL files are written, which means ctx journal sees nothing new. This is rarely what you want.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#why-journal-import-matters","level":3,"title":"Why Journal Import Matters","text":"

      The journal import pipeline (Steps 1-4 above) is your archival mechanism. Imported Markdown files in .context/journal/ persist independently of Claude Code's cleanup cycle. Even after the source JSONL files are deleted, your journal entries remain.

      Recommendation: import regularly - weekly, or after any session worth revisiting. A quick ctx journal import --all takes seconds and ensures nothing falls through the 30-day window.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#quick-archival-checklist","level":3,"title":"Quick Archival Checklist","text":"
      1. Run ctx journal import --all at least weekly
      2. Enrich high-value sessions with /ctx-journal-enrich before the details fade from your own memory
      3. Lock enriched entries (ctx journal lock <pattern>) to protect them from accidental regeneration
      4. Rebuild the journal site periodically to keep it current
      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tips","level":2,"title":"Tips","text":"
      • Start with /ctx-history inside your AI assistant. If you want to quickly check what happened in a recent session without leaving your editor, /ctx-history lets you browse interactively without importing.
      • Large sessions may be split automatically. Sessions with 200+ messages can be split into multiple parts (session-abc123.md, session-abc123-p2.md, session-abc123-p3.md) with navigation links between them. The site generator can handle this.
      • Suggestion sessions can be separated. Claude Code can generate short suggestion sessions for autocomplete. These may appear under a separate section in the site index, so they do not clutter your main session list.
      • Your agent is a good session browser. You do not need to remember slugs, dates, or flags. Ask \"what did we do yesterday?\" or \"find the session about Redis\" and it can map the question to recall commands.

      Journal Files Are Sensitive

      Journal files MUST be .gitignored.

      Session transcripts can contain sensitive data such as file contents, commands, error messages with stack traces, and potentially API keys.

      Add .context/journal/, .context/journal-site/, and .context/journal-obsidian/ to your .gitignore.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#next-up","level":2,"title":"Next Up","text":"

      Persisting Decisions, Learnings, and Conventions →: Record decisions, learnings, and conventions so they survive across sessions.

      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: where session saving fits in the daily workflow
      • Turning Activity into Content: generating blog posts from session history
      • Session Journal: full documentation of the journal system
      • CLI Reference: ctx journal: all journal subcommands and flags
      • CLI Reference: ctx serve: serve-only (no regeneration)
      • Context Files: the .context/ directory structure
      ","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-ceremonies/","level":1,"title":"Session Ceremonies","text":"","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#the-problem","level":2,"title":"The Problem","text":"

      Sessions have two critical moments: the start and the end.

      • At the start, you need the agent to load context and confirm it knows what is going on.
      • At the end, you need to capture whatever the session produced before the conversation disappears.

      Most ctx skills work conversationally: \"jot down: check DNS after deploy\" is as good as /ctx-pad add \"check DNS after deploy\". But session boundaries are different. They are well-defined moments with specific requirements, and partial execution is costly.

      If the agent only half-loads context at the start, it works from stale assumptions. If it only half-persists at the end, learnings and decisions are lost.

      This Is One of the Few Times Being Explicit Matters

      Session ceremonies are the two bookend skills that mark these boundaries.

      They are the exception to the conversational rule:

      Invoke /ctx-remember and /ctx-wrap-up explicitly as slash commands.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tldr","level":2,"title":"TL;DR","text":"

      Start: /ctx-remember: load context, get a structured readback.

      End: /ctx-wrap-up: review session, propose candidates, persist approved items.

      Use the slash commands, not conversational triggers, for completeness.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#explicit-invocation-matters","level":2,"title":"Explicit Invocation Matters","text":"

      Most ctx skills encourage natural language. These two are different:

      Well-defined moments: Sessions have clear boundaries. A slash command marks the boundary unambiguously.

      Ambiguity risk: \"Do you remember?\" could mean many things. /ctx-remember means exactly one thing: load context and present a structured readback.

      Completeness: Conversational triggers risk partial execution. The agent might load some files but skip the session history, or persist one learning but forget to check for uncommitted changes. The slash command runs the full ceremony.

      Muscle memory: Typing /ctx-remember at session start and /ctx-wrap-up at session end becomes a habit, like opening and closing braces.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose /ctx-remember Skill Load context and present structured readback /ctx-wrap-up Skill Gather session signal, propose and persist context /ctx-commit Skill Commit with context capture (offered by wrap-up) ctx agent CLI Load token-budgeted context packet ctx journal source CLI List recent sessions ctx add CLI Persist learnings, decisions, conventions, tasks","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#session-start-ctx-remember","level":2,"title":"Session Start: /ctx-remember","text":"

      Invoke at the beginning of every session:

      /ctx-remember\n

      The skill silently:

      1. Loads the context packet via ctx agent --budget 4000
      2. Reads TASKS.md, DECISIONS.md, LEARNINGS.md
      3. Checks recent sessions via ctx journal source --limit 3

      Then presents a structured readback with four sections:

      • Last session: topic, date, what was accomplished
      • Active work: pending and in-progress tasks
      • Recent context: 1-2 relevant decisions or learnings
      • Next step: suggestion or question about what to focus on

      The readback should feel like recall, not a file system tour. If the agent says \"Let me check if there are files...\" instead of a confident summary, the skill is not working correctly.

      What about 'do you remember?'

      The conversational trigger still works. But /ctx-remember guarantees the full ceremony runs:

      • context packet,
      • file reads,
      • session history,
      • and all four readback sections.

      The conversational version may cut corners.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#session-end-ctx-wrap-up","level":2,"title":"Session End: /ctx-wrap-up","text":"

      Invoke before ending a session where meaningful work happened:

      /ctx-wrap-up\n

      The skill runs four phases:

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-1-gather-signal","level":3,"title":"Phase 1: Gather Signal","text":"

      Silently checks git diff --stat, recent commits, and scans the conversation for themes: architectural choices, gotchas, patterns established, follow-up work identified.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-2-propose-candidates","level":3,"title":"Phase 2: Propose Candidates","text":"

      Presents a structured list grouped by type:

      ## Session Wrap-Up\n\n### Learnings (2 candidates)\n1. **PyMdownx details extension breaks pre/code rendering**\n   - Context: Journal site showed broken code blocks inside details tags\n   - Lesson: details extension wraps content in <details> HTML, which\n     interferes with <pre><code> rendering\n   - Application: Use fenced code blocks instead of indented code inside\n     admonitions when details extension is active\n\n2. **Hook subprocesses cannot propagate env vars**\n   - Context: Set env var in PreToolUse hook, invisible in main session\n   - Lesson: Hooks execute in child processes; env changes don't propagate\n   - Application: Use tombstone files for hook-to-session communication\n\n### Decisions (1 candidate)\n1. **File-based cooldown tokens over env vars**\n   - Context: Need session-scoped cooldown for ctx agent auto-loading\n   - Rationale: File tokens survive across processes, simpler than IPC\n   - Consequence: Tombstone files accumulate in /tmp; need TTL cleanup\n\nPersist all? Or select which to keep?\n

      Each candidate has complete structured fields, not just a title. Empty categories are omitted.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-3-persist","level":3,"title":"Phase 3: Persist","text":"

      After you approve (all, some, or modified), the skill runs the appropriate ctx add commands and reports results.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#nudge-suppression","level":3,"title":"Nudge Suppression","text":"

      After persisting, the skill marks the session as wrapped up via ctx system mark-wrapped-up. This suppresses context checkpoint nudges for 2 hours so the wrap-up ceremony itself does not trigger noisy reminders.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-4-commit-offer","level":3,"title":"Phase 4: Commit Offer","text":"

      If there are uncommitted changes, offers to run /ctx-commit. Does not auto-commit.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#when-to-skip","level":2,"title":"When to Skip","text":"

      Not every session needs ceremonies.

      Skip /ctx-remember when:

      • You are doing a quick one-off lookup (reading a file, checking a value)
      • Context was already loaded this session via /ctx-agent
      • You are continuing immediately after a previous session and context is still fresh

      Skip /ctx-wrap-up when:

      • Nothing meaningful happened (only read files, answered a question)
      • You already persisted everything manually during the session
      • The session was trivial (typo fix, quick config change)

      A good heuristic: if the session produced something a future session should know about, run /ctx-wrap-up. If not, just close.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#quick-reference","level":2,"title":"Quick Reference","text":"
      # Session start\n/ctx-remember\n\n# ... do work ...\n\n# Session end\n/ctx-wrap-up\n

      That is the complete ceremony. Two commands, bookending your session.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#relationship-to-other-skills","level":2,"title":"Relationship to Other Skills","text":"Skill When Purpose /ctx-remember Session start Load and confirm context /ctx-reflect Mid-session breakpoints Checkpoint at milestones /ctx-wrap-up Session end Full session review and persist /ctx-commit After completing work Commit with context capture

      /ctx-reflect is for mid-session checkpoints. /ctx-wrap-up is for end-of-session: it is more thorough, covers the full session arc, and includes the commit offer. If you already ran /ctx-reflect recently, /ctx-wrap-up avoids proposing the same candidates again.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tips","level":2,"title":"Tips","text":"
      • Make it a habit: The value of ceremonies compounds over sessions. Each /ctx-wrap-up makes the next /ctx-remember richer.
      • Trust the candidates: The agent scans the full conversation. It often catches learnings you forgot about.
      • Edit before approving: If a proposed candidate is close but not quite right, tell the agent what to change. Do not settle for a vague learning when a precise one is possible.
      • Do not force empty ceremonies: If /ctx-wrap-up finds nothing worth persisting, that is fine. A session that only read files and answered questions does not need artificial learnings.
      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#next-up","level":2,"title":"Next Up","text":"

      Browsing and Enriching Past Sessions →: Export session history to a browsable journal and enrich entries with metadata.

      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: the full session workflow that ceremonies bookend
      • Persisting Decisions, Learnings, and Conventions: deep dive on what gets persisted during wrap-up
      • Detecting and Fixing Drift: keeping context files accurate between ceremonies
      • Pausing Context Hooks: skip ceremonies entirely for quick tasks that don't need them
      ","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-changes/","level":1,"title":"Reviewing Session Changes","text":"","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-changed-while-you-were-away","level":2,"title":"What Changed While You Were Away?","text":"

      Between sessions, teammates commit code, context files get updated, and decisions pile up. ctx change gives you a single-command summary of everything that moved since your last session.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#quick-start","level":2,"title":"Quick Start","text":"
      # Auto-detects your last session and shows what changed\nctx change\n\n# Check what changed in the last 48 hours\nctx change --since 48h\n\n# Check since a specific date\nctx change --since 2026-03-10\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx change fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#how-reference-time-works","level":2,"title":"How Reference Time Works","text":"

      ctx change needs a reference point to compare against. It tries these sources in order:

      1. --since flag: explicit duration (24h, 72h) or date (2026-03-10, RFC3339 timestamp)
      2. Session markers: ctx-loaded-* files in .context/state/; picks the second-most-recent (your previous session start)
      3. Event log: last context-load-gate event from .context/state/events.jsonl
      4. Fallback: 24 hours ago

      The marker-based detection means ctx change usually just works without any flags: it knows when you last loaded context and shows everything after that.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-it-reports","level":2,"title":"What It Reports","text":"","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#context-file-changes","level":3,"title":"Context File Changes","text":"

      Any .md file in .context/ modified after the reference time:

      ### Context File Changes\n- `TASKS.md` - modified 2026-03-11 14:30\n- `DECISIONS.md` - modified 2026-03-11 09:15\n
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#code-changes","level":3,"title":"Code Changes","text":"

      Git activity since the reference time:

      ### Code Changes\n- **12 commits** since reference point\n- **Latest**: Fix journal enrichment ordering\n- **Directories touched**: internal, docs, specs\n- **Authors**: jose, claude\n
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#integrating-into-session-start","level":2,"title":"Integrating into Session Start","text":"

      Pair ctx change with the /ctx-remember ceremony for a complete session-start picture:

      # 1. Load context (this also creates the session marker)\nctx agent --budget 4000\n\n# 2. See what changed since your last session\nctx change\n

      Or script it:

      # .context/hooks/session-start.sh\nctx agent --budget 4000\necho \"---\"\nctx change\n
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#team-workflows","level":2,"title":"Team Workflows","text":"

      When multiple people share a .context/ directory, ctx change shows who changed what:

      # After pulling from remote\ngit pull\nctx change --since 72h\n

      This surfaces context file changes from teammates that you might otherwise miss in the commit log.

      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#tips","level":2,"title":"Tips","text":"
      • No changes? If nothing shows up, the reference time might be wrong. Use --since 48h to widen the window.
      • Works without git. Context file changes are detected by filesystem mtime, not git. Code changes require git.
      • Hook integration. The context-load-gate hook writes the session marker that ctx change uses for auto-detection. If you're not using the ctx plugin, markers won't exist and it falls back to the event log or 24h window.
      ","path":["Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-lifecycle/","level":1,"title":"The Complete Session","text":"","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#the-problem","level":2,"title":"The Problem","text":"

      \"What does a full ctx session look like from start to finish?\"

      You have ctx installed and your .context/ directory initialized, but the individual commands and skills feel disconnected.

      How do they fit together into a coherent workflow?

      This recipe walks through a complete session, from opening your editor to persisting context before you close it, so you can see how each piece connects.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tldr","level":2,"title":"TL;DR","text":"
      1. Load: /ctx-remember: load context, get structured readback.
      2. Orient: /ctx-status: check file health and token usage.
      3. Pick: /ctx-next: choose what to work on.
      4. Work: implement, test, iterate.
      5. Commit: /ctx-commit: commit and capture decisions/learnings.
      6. Reflect: /ctx-reflect: identify what to persist (at milestones)
      7. Wrap up: /ctx-wrap-up: end-of-session ceremony.

      Read on for the full walkthrough with examples.

      Before You Start: Activate the Project

      ctx commands (and the skills that call them) require CTX_DIR to be declared for the shell you're working in; ctx does not walk the filesystem to find .context/. Once per shell (or via your shell rc / direnv):

      eval \"$(ctx activate)\"\n

      If you skip this, every skill below will surface an error naming the fix. See Activating a Context Directory for the full recipe.

      What Is a Readback?

      A readback is a structured summary where the agent plays back what it knows:

      • last session,
      • active tasks,
      • recent decisions.

      This way, you can confirm it loaded the right context.

      The term \"readback\" comes from aviation, where pilots repeat instructions back to air traffic control to confirm they heard correctly.

      Same idea in ctx: The agent tells you what it \"thinks\" is going on, and you correct anything that's off before the work begins.

      • Last session: topic, date, what was accomplished
      • Active work: pending and in-progress tasks
      • Recent context: 1-2 decisions or learnings that matter now
      • Next step: suggestion or question about what to focus on
      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx status CLI command Quick health check on context files ctx agent CLI command Load token-budgeted context packet ctx journal source CLI command List previous sessions ctx journal source --show CLI command Inspect a specific session in detail /ctx-remember Skill Recall project context with structured readback /ctx-agent Skill Load full context packet inside the assistant /ctx-status Skill Show context summary with commentary /ctx-next Skill Suggest what to work on with rationale /ctx-commit Skill Commit code and prompt for context capture /ctx-reflect Skill Structured reflection checkpoint /ctx-history Skill Browse session history inside your AI assistant","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#the-workflow","level":2,"title":"The Workflow","text":"

      The session lifecycle has seven steps. You will not always use every step (for example, a quick bugfix might skip reflection, and a research session might skip committing), but the full arc looks like this:

      Load context > Orient > Pick a Task > Work > Commit > Reflect

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-1-load-context","level":3,"title":"Step 1: Load Context","text":"

      Start every session by loading what you know. The fastest way is a single prompt:

      Do you remember what we were working on?\n

      This triggers the /ctx-remember skill. Behind the scenes, the assistant runs ctx agent --budget 4000, reads the files listed in the context packet (TASKS.md, DECISIONS.md, LEARNINGS.md, CONVENTIONS.md), checks ctx journal source --limit 3 for recent sessions, and then presents a structured readback.

      The readback should feel like a recall, not a file system tour. If you see \"Let me check if there are files...\" instead of a confident summary, the context system is not loaded properly.

      As an alternative, if you want raw data instead of a readback, run ctx status in your terminal or invoke /ctx-status for a summarized health check showing file counts, token usage, and recent activity.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-2-orient","level":3,"title":"Step 2: Orient","text":"

      After loading context, verify you understand the current state.

      /ctx-status\n

      The status output shows which context files are populated, how many tokens they consume, and which files were recently modified. Look for:

      • Empty core files: TASKS.md or CONVENTIONS.md with no content means the context is sparse
      • High token count (over 30k): the context is bloated and might need ctx compact
      • No recent activity: files may be stale and need updating

      If the status looks healthy and the readback from Step 1 gave you enough context, skip ahead.

      If something seems off (stale tasks, missing decisions...), spend a minute reading the relevant file before proceeding.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-3-pick-what-to-work-on","level":3,"title":"Step 3: Pick What to Work On","text":"

      With context loaded, choose a task. You can pick one yourself, or ask the assistant to recommend:

      /ctx-next\n

      The skill reads TASKS.md, checks recent sessions to avoid re-suggesting completed work, and presents 1-3 ranked recommendations with rationale.

      It prioritizes in-progress tasks over new starts (finishing is better than starting), respects explicit priority tags, and favors momentum: continuing a thread from a recent session is cheaper than context-switching.

      If you already know what you want to work on, state it directly:

      Let's work on the session enrichment feature.\n
      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-4-do-the-work","level":3,"title":"Step 4: Do the Work","text":"

      This is the main body of the session: write code, fix bugs, refactor, research: whatever the task requires.

      During this phase, a few ctx-specific patterns help:

      Check decisions before choosing: when you face a design choice, check if a prior decision covers it.

      Is this consistent with our decisions?\n

      Constrain scope: keep the assistant focused on the task at hand.

      Only change files in internal/cli/session/. Nothing else.\n

      Use /ctx-implement for multistep plans: if the task has multiple steps, this skill executes them one at a time with build/test verification between each step.

      Context monitoring runs automatically: the check-context-size hook monitors context capacity at adaptive intervals. Early in a session it stays silent. After 16+ prompts it starts monitoring, and past 30 prompts it checks frequently. If context capacity is running high, it will suggest saving unsaved work. No manual invocation is needed.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-5-commit-with-context","level":3,"title":"Step 5: Commit with Context","text":"

      When the work is ready, use the context-aware commit instead of raw git commit:

      /ctx-commit\n

      The Agent May Recommend Committing

      You do not always need to invoke /ctx-commit explicitly.

      After a commit, the agent may proactively offer to capture context:

      \"We just made a trade-off there. Want me to record it as a decision?\"

      This is normal: The Agent Playbook encourages persisting at milestones, and a commit is a natural milestone.

      As an alternative, you can ask the assistant \"can we commit this?\" and it will pick up the /ctx-commit skill for you.

      The skill runs a pre-commit build check (for Go projects, go build), reviews the staged changes, drafts a commit message focused on \"why\" rather than \"what\", and then commits.

      After the commit succeeds, it prompts you:

      **Any context to capture?**\n\n- **Decision**: Did you make a design choice or trade-off?\n- **Learning**: Did you hit a gotcha or discover something?\n- **Neither**: No context to capture; we are done.\n

      If you made a decision, the skill records it with ctx decision add. If you learned something, it records it with ctx learning add including context, lesson, and application fields. This is the bridge between committing code and remembering why the code looks the way it does.

      If source code changed in areas that affect documentation, the skill also offers to check for doc drift.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-6-reflect","level":3,"title":"Step 6: Reflect","text":"

      At natural breakpoints (after finishing a feature, resolving a complex bug, or before switching tasks) pause to reflect:

      /ctx-reflect\n

      Agents Reflect at Milestones

      Agents often reflect without explicit invocation.

      After completing a significant piece of work, the agent may naturally surface items worth persisting:

      \"We discovered that $PPID resolves differently inside hooks. Should I save that as a learning?\"

      This is the agent following the Work-Reflect-Persist cycle from the Agent Playbook.

      You do not need to say /ctx-reflect for this to happen; the agent treats milestones as reflection triggers on its own.

      The skill works through a checklist: learnings discovered, decisions made, tasks completed or created, and whether there are items worth persisting. It then presents a summary with specific items to persist, each with the exact command to run:

      I would suggest persisting:\n\n- **Learning**: `$PPID` in PreToolUse hooks resolves to the Claude Code PID\n  `ctx learning add --context \"...\" --lesson \"...\" --application \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n- **Task**: mark \"Add cooldown to ctx agent\" as done\n- **Decision**: tombstone-based cooldown with 10m default\n  `ctx decision add \"...\" --session-id abc12345 --branch main --commit 68fbc00a`\n\nWant me to persist any of these?\n

      The skill asks before persisting anything. You choose what to keep.

      Not every commit needs reflection. A typo fix does not. But when you have been debugging for an hour and finally understand the root cause, that is worth a reflection checkpoint.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-7-persist-before-ending","level":3,"title":"Step 7: Persist Before Ending","text":"

      Before ending the session, run the wrap-up ceremony to capture outstanding learnings, decisions, conventions, and tasks:

      /ctx-wrap-up\n

      Ceremony Skills

      /ctx-remember at session start and /ctx-wrap-up at session end are ceremony skills: Invoke them as explicit slash commands for completeness, not conversationally.

      See Session Ceremonies for details on why these two skills are the exception to the conversational rule.

      The skill gathers signal from git diff, recent commits, and the conversation, then proposes structured candidates for your approval. After you select which to keep, it persists them via ctx add and offers /ctx-commit if uncommitted changes remain.

      Session transcripts are automatically captured by Claude Code and can be browsed later with ctx journal source and ctx journal source --show.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#conversational-session-flow","level":2,"title":"Conversational Session Flow","text":"

      The steps above describe the mechanics. In practice, a session with a ctx-aware agent feels more like a conversation than a command sequence.

      The agent knows the lifecycle and moves through it naturally, often without explicit invocation. Here is a realistic example:

      You: Do you remember what we were working on?

      Agent (loads context silently, presents structured readback):

      Last session (Feb 7, caching-layer): we implemented the in-memory cache with\nTTL expiration and wrote tests for the eviction policy. \n\nYou have 3 pending tasks; the biggest one is adding Redis as a backend.\n\nRecent decision:<br>\nwe chose LRU over LFU because the access pattern is mostly recency-based.\n\nWant to continue with the Redis backend, or tackle something else?\n

      You: Let's work on the Redis caching backend.

      Agent (picks up the task, begins implementation):

      Got it. I see the task in TASKS.md: \"Add Redis backend for cache layer.\"\n\nI will start with the connection pool setup. Only touching\n`internal/cache/redis/` for now.\n

      (The agent works... writes code, runs tests, iterates.)

      Agent (after implementing the connection pool and choosing a retry strategy):

      The connection pool is working. I went with exponential backoff with jitter\nfor retries instead of fixed intervals; it handles thundering herd better\nunder reconnection storms. That is a design choice worth recording. \n\nWant me to save it as a decision?\n

      You: Yes, go ahead.

      Agent:

      Done. Added to DECISIONS.md: \"Exponential backoff with jitter for Redis\nreconnection, to avoid thundering herd on pool recovery.\"\n

      (More work happens... the agent implements the cache read/write paths.)

      You: What else did we learn during this session?

      Agent:

      A few things worth capturing:\n\n* **Learning**: Redis `SET` with `NX` and `PX` flags handles atomic\n  set-if-not-exists with TTL in a single call. No need for a separate\n  `EXPIRE` command. We initially did it in two calls and hit a race condition.\n* **Learning**: The `go-redis` library's `PoolSize` default is 10 per CPU.\n  For our workload, explicit sizing at 20 was more predictable.\n* **Task update**: The connection pool subtask is done; the read/write path\n  is implemented but needs integration tests.\n\nWant me to persist these?\n

      You: Yes. And let's wrap up.

      Agent (reflects and persists... all in one flow):

      Persisted:\n\n* 2 learnings added to LEARNINGS.md\n* Marked \"connection pool setup\" done in TASKS.md\n* Added \"write integration tests for Redis cache\" as a new task\n\nContext is up to date. You are good to close.\n

      Notice What Happened

      In the above workflow, the user never typed /ctx-reflect or ctx learning add.

      The agent moved through Load, Orient, Pick, Work, Commit, and Reflect driven by natural conversation.

      \"Let's wrap up\" was enough to trigger the full reflect-and-persist flow.

      The agent surfaced persist-worthy items at milestones: after a design choice, after discovering a gotcha: without waiting to be asked.

      This is the intended experience.

      The commands and skills still exist for when you want precise control, but the agent is a proactive partner in the lifecycle, not a passive executor of slash commands.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      Quick-reference checklist for a complete session:

      • Load: /ctx-remember: load context and confirm readback
      • Orient: /ctx-status: check file health and token usage
      • Pick: /ctx-next: choose what to work on
      • Work: implement, test, iterate (scope with \"only change X\")
      • Commit: /ctx-commit: commit and capture decisions/learnings
      • Reflect: /ctx-reflect: identify what to persist (at milestones)
      • Wrap up: /ctx-wrap-up: end-of-session ceremony

      Conversational equivalents: you can drive the same lifecycle with plain language:

      Step Slash command Natural language Load /ctx-remember \"Do you remember?\" / \"What were we working on?\" Orient /ctx-status \"How's our context looking?\" Pick /ctx-next \"What should we work on?\" / \"Let's do the caching task\" Work (none) \"Only change files in internal/cache/\" Commit /ctx-commit \"Commit this\" / \"Ship it\" Reflect /ctx-reflect \"What did we learn?\" / (agent offers at milestones) Wrap up /ctx-wrap-up (use the slash command for completeness)

      The agent understands both columns.

      In practice, most sessions use a mix:

      • Explicit Commands when you want precision;
      • Natural Language when you want flow and agentic autonomy.

      The agent will also initiate steps on its own (particularly \"Reflect\") when it recognizes a milestone.

      Short sessions (quick bugfix) might only use: Load, Work, Commit.

      Long sessions should Reflect after each major milestone and persist learnings and decisions before ending.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tips","level":2,"title":"Tips","text":"

      Persist early if context is running low. A hook monitors context capacity and notifies you when it gets high, but do not wait for the notification. If you have been working for a while and have unpersisted learnings, persist proactively.

      Browse previous sessions by topic. If you need context from a prior session, ctx journal source --show auth will match by keyword. You do not need to remember the exact date or slug.

      Reflection is optional but valuable. You can skip /ctx-reflect for small changes, but always persist learnings and decisions before ending a session where you did meaningful work. These are what the next session loads.

      Let the hook handle context loading. The PreToolUse hook runs ctx agent automatically with a cooldown, so context loads on first tool use without you asking. The /ctx-remember prompt at session start is for your benefit (to get a readback), not because the assistant needs it.

      The agent is a proactive partner, not a passive tool. A ctx-aware agent follows the Agent Playbook: it watches for milestones (completed tasks, design decisions, discovered gotchas) and offers to persist them without being asked. If you finish a tricky debugging session, it may say \"That root cause is worth saving as a learning. Want me to record it?\" before you think to ask. This is by design.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#next-up","level":2,"title":"Next Up","text":"

      Session Ceremonies →: The two bookend rituals for every session: /ctx-remember at the start, /ctx-wrap-up at the end.

      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#see-also","level":2,"title":"See Also","text":"
      • Session Ceremonies: why /ctx-remember and /ctx-wrap-up are explicit slash commands, not conversational
      • CLI Reference: full documentation for all ctx commands
      • Prompting Guide: effective prompts for ctx-enabled projects
      • Tracking Work Across Sessions: deep dive on task management
      • Persisting Decisions, Learnings, and Conventions: deep dive on knowledge capture
      • Detecting and Fixing Drift: keeping context files accurate
      • Pausing Context Hooks: shortcut the full lifecycle for quick tasks that don't need ceremony overhead
      ","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-pause/","level":1,"title":"Pausing Context Hooks","text":"","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#the-problem","level":2,"title":"The Problem","text":"

      Not every session needs the full ceremony. Quick investigations, one-off questions, small fixes unrelated to active project work: These tasks don't benefit from persistence nudges, ceremony reminders, or knowledge checks. Every hook still fires, consuming tokens and attention on work that won't produce learnings or decisions worth capturing.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tldr","level":2,"title":"TL;DR","text":"Command What it does ctx hook pause or /ctx-pause Silence all nudge hooks for this session ctx hook resume or /ctx-resume Restore normal hook behavior

      Pause is session-scoped: It only affects the current session. Other sessions (same project, different terminal) are unaffected.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-gets-paused","level":2,"title":"What Gets Paused","text":"

      All nudge and reminder hooks go silent:

      • Context size checkpoints
      • Ceremony adoption nudges
      • Persistence reminders
      • Journal maintenance reminders
      • Knowledge growth nudges
      • Map staleness nudges
      • Version update nudges
      • Resource pressure warnings
      • QA reminders
      • Post-commit nudges
      • Specs nudges
      • Backup age warnings
      • Context load gate
      • Pending reminders relay
      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-still-fires","level":2,"title":"What Still Fires","text":"

      Security hooks always run, even when paused:

      • block-non-path-ctx: prevents ./ctx invocations
      • block-dangerous-commands: blocks sudo, force push, etc.
      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#workflow","level":2,"title":"Workflow","text":"
      # 1. Session starts: Context loads normally.\n\n# 2. You realize this is a quick task\nctx hook pause\n\n# 3. Work without interruption: hooks are silent\n\n# 4. Session evolves into real work? Resume first\nctx hook resume\n\n# 5. Now wrap up normally\n# /ctx-wrap-up\n
      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#graduated-reminder","level":2,"title":"Graduated Reminder","text":"

      Paused hooks aren't completely invisible. A minimal indicator appears so you always know the state:

      Paused turns What you see 1-5 ctx:paused 6+ ctx:paused (N turns): resume with /ctx-resume

      This prevents the \"forgot I paused\" problem during long sessions.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tips","level":2,"title":"Tips","text":"
      • Resume before wrapping up. If your quick task turns into real work, resume hooks before running /ctx-wrap-up. The wrap-up ceremony needs active hooks to capture learnings properly.

      • Initial context load is unaffected. The ~8k token startup injection (CLAUDE.md, playbook, constitution) happens before any command runs. Pause only affects hooks that fire during the session.

      • Use for quick investigations. Debugging a stack trace? Checking a git log? Answering a colleague's question? Pause, do the work, close the session. No ceremony needed.

      • Don't use for real work. If you're implementing features, fixing bugs, or making decisions: keep hooks active. The nudges exist to prevent context loss.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#see-also","level":2,"title":"See Also","text":"

      See also: Session Ceremonies: the bookend rituals that pause lets you skip when they aren't needed.

      See also: Customizing Hook Messages: if you want to change what hooks say rather than silencing them entirely.

      See also: The Complete Session: the full session workflow that pause shortcuts for quick tasks.

      ","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-reminders/","level":1,"title":"Session Reminders","text":"","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#the-problem","level":2,"title":"The Problem","text":"

      You're deep in a session and realize: \"I need to refactor the swagger definitions next time.\" You could add a task, but this isn't a work item: it's a note to future-you. You could jot it on the scratchpad, but scratchpad entries don't announce themselves.

      How do you leave a message that your next session opens with?

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tldr","level":2,"title":"TL;DR","text":"
      ctx remind \"refactor the swagger definitions\"\nctx remind list\nctx remind dismiss 1       # or batch: ctx remind dismiss 1 3-5\n

      Reminders surface automatically at session start: VERBATIM, every session, until you dismiss them.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx remind ... fails with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx remind CLI command Add a reminder (default action) ctx remind list CLI command Show all pending reminders ctx remind dismiss CLI command Remove a reminder by ID (or --all) /ctx-remind Skill Natural language interface to reminders","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-1-leave-a-reminder","level":3,"title":"Step 1: Leave a Reminder","text":"

      Tell your agent what to remember, or run it directly:

      You: \"remind me to refactor the swagger definitions\"\n\nAgent: [runs ctx remind \"refactor the swagger definitions\"]\n       \"Reminder set:\n         + [1] refactor the swagger definitions\"\n

      Or from the terminal:

      ctx remind \"refactor the swagger definitions\"\n
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-2-set-a-date-gate-optional","level":3,"title":"Step 2: Set a Date Gate (Optional)","text":"

      If the reminder shouldn't fire until a specific date:

      You: \"remind me to check the deploy logs after Tuesday\"\n\nAgent: [runs ctx remind \"check the deploy logs\" --after 2026-02-25]\n       \"Reminder set:\n         + [2] check the deploy logs  (after 2026-02-25)\"\n

      The reminder stays silent until that date, then fires every session.

      The agent converts natural language dates (\"tomorrow\", \"next week\", \"after the release on Friday\") to YYYY-MM-DD. If it's ambiguous, it asks.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-3-start-a-new-session","level":3,"title":"Step 3: Start a New Session","text":"

      Next session, the reminder appears automatically before anything else:

      ┌─ Reminders ──────────────────────────────────────\n│  [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n

      No action needed: The check-reminders hook fires on UserPromptSubmit and the agent relays the box verbatim.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-4-dismiss-when-done","level":3,"title":"Step 4: Dismiss When Done","text":"

      After you've acted on a reminder (or decided to skip it):

      You: \"dismiss reminder 1\"\n\nAgent: [runs ctx remind dismiss 1]\n       \"Dismissed:\n         - [1] refactor the swagger definitions\"\n\n# Batch dismiss also works:\n# \"dismiss reminders 3, 5 through 7\"\n# → ctx remind dismiss 3 5-7\n

      Or clear everything:

      ctx remind dismiss --all\n
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-5-check-whats-pending","level":3,"title":"Step 5: Check What's Pending","text":"
      ctx remind list\n
        [1] refactor the swagger definitions\n  [3] review auth token expiry logic\n  [4] check deploy logs  (after 2026-02-25, not yet due)\n

      Date-gated reminders that haven't reached their date show (not yet due).

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#using-ctx-remind-in-a-session","level":2,"title":"Using /ctx-remind in a Session","text":"

      Invoke the /ctx-remind skill, then describe what you want:

      You: /ctx-remind remind me to update the API docs\nYou: /ctx-remind what reminders do I have?\nYou: /ctx-remind dismiss reminder 3\n
      You say (after /ctx-remind) What the agent does \"remind me to update the API docs\" ctx remind \"update the API docs\" \"remind me next week to check staging\" ctx remind \"check staging\" --after 2026-03-02 \"what reminders do I have?\" ctx remind list \"dismiss reminder 3\" ctx remind dismiss 3 \"dismiss reminders 3, 5 through 7\" ctx remind dismiss 3 5-7 \"clear all reminders\" ctx remind dismiss --all","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#reminders-vs-scratchpad-vs-tasks","level":2,"title":"Reminders vs Scratchpad vs Tasks","text":"You want to... Use Leave a note that announces itself next session ctx remind Jot down a quick value or sensitive token ctx pad Track work with status and completion TASKS.md Record a decision or lesson for all sessions Context files

      Decision guide:

      • If it should announce itself at session start → ctx remind
      • If it's a quiet note you'll check manually → ctx pad
      • If it's a work item you'll mark done → TASKS.md

      Reminders Are Sticky Notes, Not Tasks

      A reminder has no status, no priority, no lifecycle. It's a message to \"future you\" that fires until dismissed.

      If you need tracking, use a task in TASKS.md.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tips","level":2,"title":"Tips","text":"
      • Reminders fire every session: Unlike nudges (which throttle to once per day), reminders repeat until you dismiss them. This is intentional: You asked to be reminded.
      • Date gating is session-scoped, not clock-scoped: --after 2026-02-25 means \"don't show until sessions on or after Feb 25.\" It does not mean \"alarm at midnight on Feb 25.\"
      • The agent handles date parsing: Say \"next week\" or \"after Friday\": The agent converts it to YYYY-MM-DD. The CLI only accepts the explicit date format.
      • Reminders are committed to git: They travel with the repo. If you switch machines, your reminders follow.
      • IDs never reuse: After dismissing reminder 3, the next reminder gets ID 4 (or higher). No confusion from recycled numbers.
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#next-up","level":2,"title":"Next Up","text":"

      Using the Scratchpad →: For quiet notes and sensitive values that don't need session-start announcements.

      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#see-also","level":2,"title":"See Also","text":"
      • CLI Reference: ctx remind: full command syntax and flags
      • The Complete Session: how reminders fit into the session lifecycle
      • Managing Tasks: for work items that need status tracking
      ","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/state-maintenance/","level":1,"title":"State Directory Maintenance","text":"","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-problem","level":2,"title":"The Problem","text":"

      Every session creates tombstone files in .context/state/ - small markers that suppress repeat hook nudges (\"already checked context size\", \"already sent persistence reminder\"). Over days and weeks, these accumulate into hundreds of files from long-dead sessions.

      The files are harmless individually, but the clutter makes it harder to reason about state, and stale global tombstones can suppress nudges across sessions entirely.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tldr","level":2,"title":"TL;DR","text":"
      ctx prune --dry-run     # preview what would be removed\nctx prune               # prune files older than 7 days\nctx prune --days 1      # more aggressive: keep only today\n

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, ctx prune / ctx status fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#commands-used","level":2,"title":"Commands Used","text":"Tool Type Purpose ctx prune Command Remove old per-session state files ctx status Command Quick health overview including state dir","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#understanding-state-files","level":2,"title":"Understanding State Files","text":"

      State files fall into two categories:

      Session-scoped (contain a UUID in the filename): Created per-session to suppress repeat nudges. Safe to prune once the session ends. Examples:

      context-check-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\nheartbeat-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\npersistence-nudge-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\n

      Global (no UUID): Persist across sessions. ctx prune preserves these automatically. Some are legitimate state (events.jsonl, memory-import.json); others may be stale tombstones that need manual review.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-workflow","level":2,"title":"The Workflow","text":"","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-1-preview","level":3,"title":"Step 1: Preview","text":"

      Always dry-run first to see what would be removed:

      ctx prune --dry-run\n

      The output shows each file, its age, and a summary:

        would prune: context-check-abc123... (age: 3d)\n  would prune: heartbeat-abc123... (age: 3d)\n\nDry run - would prune 150 files (skip 70 recent, preserve 14 global)\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-2-prune","level":3,"title":"Step 2: Prune","text":"

      Choose an age threshold. The default is 7 days:

      ctx prune               # older than 7 days\nctx prune --days 3      # older than 3 days\nctx prune --days 1      # older than 1 day (aggressive)\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-3-review-global-files","level":3,"title":"Step 3: Review Global Files","text":"

      After pruning, check what prune preserved:

      ls .context/state/ | grep -v '[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}'\n

      Legitimate global files (keep):

      • events.jsonl - event log
      • memory-import.json - import tracking state

      Stale global tombstones (safe to delete):

      • Files like backup-reminded, ceremony-reminded, version-checked with no session UUID are one-shot markers. If they are from a previous session, they are stale and can be removed manually.
      rm .context/state/backup-reminded .context/state/ceremony-reminded\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-4-verify","level":3,"title":"Step 4: Verify","text":"
      ls .context/state/ | wc -l    # should be manageable\n
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#when-to-prune","level":2,"title":"When to Prune","text":"
      • Weekly: ctx prune with default 7-day threshold
      • After heavy parallel work: Multiple concurrent sessions create many tombstones. Prune with --days 1 afterward.
      • When state directory exceeds ~100 files: A sign that pruning hasn't run recently
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tips","level":2,"title":"Tips","text":"

      Pruning active sessions is safe but noisy: If you prune a file belonging to a still-running session, the corresponding hook will re-fire its nudge on the next prompt. Minor UX annoyance, not data loss.

      No context files are stored in state: The state directory contains only tombstones, counters, and diagnostic data. Nothing in .context/state/ affects your decisions, learnings, tasks, or conventions.

      Test artifacts sneak in: Files like context-check-statstest or heartbeat-unknown are artifacts from development or testing. They lack UUIDs so prune preserves them. Delete manually.

      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#see-also","level":2,"title":"See Also","text":"
      • Detecting and Fixing Drift: broader context maintenance including drift detection and archival
      • Troubleshooting: diagnostic workflow using ctx doctor and event logs
      • CLI Reference: system: full flag documentation for ctx prune and related commands
      ","path":["State Directory Maintenance"],"tags":[]},{"location":"recipes/steering/","level":1,"title":"Writing Steering Files","text":"","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#writing-steering-files","level":1,"title":"Writing Steering Files","text":"

      Steering files tell your AI assistant how to behave, not what was decided or how the codebase is written. This recipe walks through writing a steering file from scratch, validating which prompts will trigger it, and syncing it out to your configured AI tools.

      Before You Start

      If you're unsure whether a rule belongs in steering/, DECISIONS.md, or CONVENTIONS.md, read the \"Steering vs decisions vs conventions\" admonition on the ctx steering reference page. The short version: if the rule is \"the AI should always do X when asked about Y,\" that's steering. Otherwise it's probably a decision or convention.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#start-here-customize-the-foundation-files","level":2,"title":"Start Here: Customize the Foundation Files","text":"

      ctx init scaffolds four foundation steering files for you the first time you initialize a project:

      File Purpose .context/steering/product.md Product context, goals, target users .context/steering/tech.md Tech stack, constraints, key dependencies .context/steering/structure.md Directory layout, naming conventions .context/steering/workflow.md Branch strategy, commit rules, pre-commit

      Each file opens with an inline HTML comment that explains the three inclusion modes, what priority means, and the tools scope. The comment is invisible in rendered markdown but visible when you edit the file. Delete it once the file is yours.

      All four default to inclusion: always and priority: 10, so they fire on every AI tool call until you customize them. If you're reading this recipe and haven't touched them yet, open each one now and replace the placeholder bullet list with actual rules for your project. That's the highest-leverage five minutes you can spend in a new ctx setup.

      What to fill in, by file:

      product.md: The elevator pitch plus hard scope:

      • One-sentence product description.
      • Primary users and their top job-to-be-done.
      • Two or three \"this is explicitly out of scope\" items so the AI doesn't wander.

      tech.md: Technology and constraints:

      • Languages and versions (Go 1.22, Node 20, etc.).
      • Frameworks and key libraries.
      • Runtime and deployment target.
      • Hard constraints: \"no CGO\", \"no network at test time\", \"no external DB for unit tests\". These are the things that burn agents when they don't know them.

      structure.md: Layout and naming:

      • Top-level directories and their purpose.
      • Where new files should go (and where they should NOT).
      • Naming conventions for packages, files, types.

      workflow.md: Process rules:

      • Branch strategy (main-only, trunk-based, feature branches).
      • Commit message format, signed-off-by requirement.
      • Pre-commit and pre-push checks.
      • Review expectations.

      After editing, the next AI tool call in Claude Code will pick up the new rules automatically via the plugin's PreToolUse hook, with no sync step and no restart. Other tools (Cursor, Cline, Kiro) need ctx steering sync to export into their native format.

      Prefer a Bare .context/steering/ Directory?

      Re-run ctx init --no-steering-init and delete the scaffolded files. ctx init leaves existing files alone, so the flag is only needed if you want to opt out of the initial scaffold.

      The rest of this recipe walks through creating an additional, scenario-specific steering file beyond the four foundation defaults.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#scenario","level":2,"title":"Scenario","text":"

      You're working on a project with a strict input-validation policy: every new API handler must validate request bodies before touching the database. You want the AI to flag this concern automatically whenever it's asked to write an HTTP handler, without you having to remind it every session.

      Claude Code Users: Pick always, Not auto

      This walkthrough uses inclusion: auto because the scenario is a scoped rule that matches a specific kind of prompt. That works natively on Cursor, Cline, and Kiro (they resolve the description keyword match themselves).

      On Claude Code, auto does not fire through the plugin's PreToolUse hook. The hook passes an empty prompt to ctx agent, so only always files match. Claude can still reach an auto file by calling the ctx_steering_get MCP tool, but that requires Claude to decide to call it; there's no automatic injection.

      If Claude Code is your tool, set inclusion: always in Step 2 instead of auto. The rule will fire on every tool call regardless of topic. You may want to narrow the rule body so the extra tokens per turn aren't wasted on unrelated work.

      See the ctx steering reference \"Prefer inclusion: always for Claude Code\" section for the full trade-off.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-1-scaffold-the-file","level":2,"title":"Step 1: Scaffold the File","text":"
      ctx steering add api-validation\n

      That creates .context/steering/api-validation.md with default frontmatter:

      ---\nname: api-validation\ndescription:\ninclusion: manual\ntools: []\npriority: 50\n---\n

      The defaults are deliberately conservative: inclusion: manual means the file won't be applied until you opt in, which keeps the rules out of the prompt until you've reviewed them.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-2-fill-in-the-rule","level":2,"title":"Step 2: Fill in the Rule","text":"

      Open the file and write the rule body plus a focused description. The description is what inclusion: auto matches against later.

      ---\nname: api-validation\ndescription: HTTP handler input validation and request parsing\ninclusion: auto\ntools: []\npriority: 20\n---\n\n# API request validation\n\nEvery new HTTP handler MUST:\n\n1. Parse request bodies into typed structs, never `map[string]any`.\n2. Validate required fields before any database call.\n3. Return 400 with a machine-readable error for validation failures.\n4. Use `context.Context` from the request for all downstream calls.\n\nPrefer existing validation helpers in `internal/validate/`\nrather than inline checks.\n

      Notes on the choices:

      • inclusion: auto: this rule should fire automatically on HTTP-handler-shaped prompts, not always.
      • priority: 20: lower than the default, so this rule appears near the top of the prompt alongside other high-priority rules.
      • Description is keyword-rich (\"HTTP handler input validation and request parsing\"); the auto matcher scores prompts against these words.
      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-3-preview-which-prompts-match","level":2,"title":"Step 3: Preview Which Prompts Match","text":"

      Before committing the file, validate your description catches the prompts you care about:

      ctx steering preview \"add an endpoint for updating user email\"\n

      Expected output:

      Steering files matching prompt \"add an endpoint for updating user email\":\n  api-validation       inclusion=auto     priority=20  tools=all\n

      Good, the prompt matches. Try a negative case:

      ctx steering preview \"fix a bug in the JSON renderer\"\n

      Expected: empty match (or whatever else is currently auto). If api-validation incorrectly fires for unrelated prompts, tighten the description. If it misses prompts it should catch, add more keywords.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-4-list-to-confirm-metadata","level":2,"title":"Step 4: List to Confirm Metadata","text":"
      ctx steering list\n

      Should show api-validation alongside any other files, with its inclusion mode and priority. If the list is wrong, check the frontmatter for typos.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-5-get-the-rules-in-front-of-the-ai","level":2,"title":"Step 5: Get the Rules in Front of the AI","text":"

      Steering files are authored once in .context/steering/, but how they reach the AI depends on which tool you use. There are two delivery mechanisms:

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#path-a-native-rules-tools-cursor-cline-kiro","level":3,"title":"Path A: Native-Rules Tools (Cursor, Cline, Kiro)","text":"

      These tools read a specific directory for rules. ctx steering sync exports your files into that directory with tool-specific frontmatter:

      ctx steering sync\n

      Depending on the active tool in .ctxrc or --tool:

      Tool Target Cursor .cursor/rules/ Cline .clinerules/ Kiro .kiro/steering/

      The sync is idempotent; unchanged files are skipped. Run it whenever you edit a steering file.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#path-b-claude-code-and-codex-hook-mcp","level":3,"title":"Path B: Claude Code and Codex (Hook + MCP)","text":"

      Claude Code and Codex have no native rules primitive, so ctx steering sync is a no-op for them; it deliberately skips both. Instead, steering reaches these tools through two non-sync channels:

      1. PreToolUse hook (automatic). The ctx setup claude-code plugin installs a hook that runs ctx agent --budget 8000 before each tool call. ctx agent loads your steering files, filters them against the active prompt, and includes matching bodies as Tier 6 of the context packet. The packet gets injected into Claude's context automatically.

      2. ctx_steering_get MCP tool (on-demand). Claude can call this MCP tool mid-task to fetch matching steering files for a specific prompt. Automatic activation comes from Claude's judgment, not a hook.

      Both channels activate when you run:

      ctx setup claude-code --write\n

      That installs the plugin, wires the hook, and registers the MCP server. After that, steering files you edit are picked up on the next tool call, with no sync step needed.

      Running ctx steering sync with Claude Code

      It won't error; it will simply report that Claude and Codex aren't sync targets and skip them. If Claude Code is your only tool, you never need to run sync. If you use both Claude Code and (say) Cursor, run sync to keep Cursor up to date; the Claude pipeline takes care of itself via the hook.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#step-6-verify-the-ai-sees-it","level":2,"title":"Step 6: Verify the AI Sees It","text":"

      Open your AI tool and ask it something the rule should fire on:

      \"Add a POST /users endpoint that accepts email and name.\"

      If the rule is working, the AI's first response should mention input validation, typed structs, and the internal/validate/ package, because that's what the steering file told it to do.

      If nothing happens, the fix depends on which path you're on:

      Path A (Cursor/Cline/Kiro):

      1. Re-run ctx steering preview with the literal prompt to confirm the match.
      2. Run ctx steering list and verify inclusion is auto, not manual.
      3. Check the tool's own config directory (e.g. .cursor/rules/); the file should be there after ctx steering sync.

      Path B (Claude Code):

      1. Re-run ctx steering preview with the literal prompt to confirm the match.
      2. Verify the plugin is installed: cat .claude/hooks.json should include ctx agent --budget 8000 under PreToolUse. If not, re-run ctx setup claude-code --write.
      3. Run ctx agent --budget 8000 manually and grep the output for your rule body. If it's there, the data is fine; if it's missing, the inclusion mode or description is at fault.
      4. As a last resort, ask Claude directly: \"Call the ctx_steering_get MCP tool with my prompt and show me the result.\" If the MCP tool returns your rule, Claude has access but isn't pulling it into the initial context packet; tighten the description keywords.
      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#common-mistakes","level":2,"title":"Common Mistakes","text":"

      Too-generic descriptions. description: general coding will match almost every prompt and flood the context window. Keep descriptions specific to the scenario the rule applies to.

      Overlapping rules. If two steering files match the same prompt and contradict each other, the result is confusing. Use priority to resolve, but better: merge the files or narrow the descriptions so they don't overlap.

      Putting decisions in steering. \"We decided to use PostgreSQL\" is a decision, not a rule for the AI to follow on every prompt. Record decisions with ctx decision add, not ctx steering add.

      Committing inclusion: always without thinking. Rules marked always fire on every prompt, consuming tier-6 budget permanently. Only use always for true invariants (security, safety, licensing). Everything else should be auto or manual.

      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#see-also","level":2,"title":"See Also","text":"
      • ctx steering reference: full command, flag, and frontmatter reference.
      • ctx setup: configure which tools the steering sync writes to.
      • Authoring triggers: if you want script-based automation, not rule-based prompt injection.
      ","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/system-hooks-audit/","level":1,"title":"Auditing System Hooks","text":"","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-problem","level":2,"title":"The Problem","text":"

      ctx runs 14 system hooks behind the scenes: nudging your agent to persist context, warning about resource pressure, gating commits on QA. But these hooks are invisible by design. You never see them fire. You never know if they stopped working.

      How do you verify your hooks are actually running, audit what they do, and get alerted when they go silent?

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tldr","level":2,"title":"TL;DR","text":"
      ctx system check-resources # run a hook manually\nls -la .context/logs/      # check hook execution logs\nctx hook notify setup      # get notified when hooks fire\n

      Or ask your agent: \"Are our hooks running?\"

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx system <hook> CLI command Run a system hook manually ctx sysinfo CLI command Show system resource status ctx usage CLI command Stream or dump per-session token stats ctx hook notify setup CLI command Configure webhook for audit trail ctx hook notify test CLI command Verify webhook delivery .ctxrc notify.events Configuration Subscribe to relay for full hook audit .context/logs/ Log files Local hook execution ledger","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#what-are-system-hooks","level":2,"title":"What Are System Hooks?","text":"

      System hooks are plumbing commands that ctx registers with your AI tool (Claude Code, Cursor, etc.) via the plugin's hooks.json. They fire automatically at specific events during your AI session:

      Event When Hooks UserPromptSubmit Before the agent sees your prompt 10 check hooks + heartbeat PreToolUse Before the agent uses a tool block-non-path-ctx, qa-reminder PostToolUse After a tool call succeeds post-commit

      You never run these manually. Your AI tool runs them for you: That's the point.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-complete-hook-catalog","level":2,"title":"The Complete Hook Catalog","text":"","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#prompt-time-checks-userpromptsubmit","level":3,"title":"Prompt-Time Checks (UserPromptSubmit)","text":"

      These fire before every prompt, but most are throttled to avoid noise.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-context-size-context-capacity-warning","level":4,"title":"check-context-size: Context Capacity Warning","text":"

      What: Adaptive prompt counter. Silent for the first 15 prompts, then nudges with increasing frequency (every 5th, then every 3rd).

      Why: Long sessions lose coherence. The nudge reminds both you and the agent to persist context before the window fills up.

      Output: VERBATIM relay box with prompt count.

      ┌─ Context Checkpoint (prompt #20) ────────────────\n│ This session is getting deep. Consider wrapping up\n│ soon. If there are unsaved learnings, decisions, or\n│ conventions, now is a good time to persist them.\n│ ⏱ Context window: ~45k tokens (~22% of 200k)\n└──────────────────────────────────────────────────\n

      Usage: Every prompt records token usage to .context/state/stats-{session}.jsonl. Monitor live with ctx usage --follow or query with ctx usage --json. Usage is recorded even during wrap-up suppression (event: suppressed).

      Billing guard: When billing_token_warn is set in .ctxrc, a one-shot warning fires if session tokens exceed the threshold. This warning is independent of all other triggers - it fires even during wrap-up suppression.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-persistence-context-staleness-nudge","level":4,"title":"check-persistence: Context Staleness Nudge","text":"

      What: Tracks when .context/*.md files were last modified. If too many prompts pass without a write, nudges the agent to persist.

      Why: Sessions produce insights that evaporate if not recorded. This catches the \"we talked about it but never wrote it down\" failure mode.

      Output: VERBATIM relay after 20+ prompts without a context file change.

      ┌─ Persistence Checkpoint (prompt #20) ───────────\n│ No context files updated in 20+ prompts.\n│ Have you discovered learnings, made decisions,\n│ established conventions, or completed tasks\n│ worth persisting?\n│\n│ Run /ctx-wrap-up to capture session context.\n└──────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-ceremonies-session-ritual-adoption","level":4,"title":"check-ceremonies: Session Ritual Adoption","text":"

      What: Scans your last 3 journal entries for /ctx-remember and /ctx-wrap-up usage. Nudges once per day if missing.

      Why: Session ceremonies are the highest-leverage habit in ctx. This hook bootstraps the habit until it becomes automatic.

      Output: Tailored nudge depending on which ceremony is missing.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-journal-unimported-session-reminder","level":4,"title":"check-journal: Unimported Session Reminder","text":"

      What: Detects unimported Claude Code sessions and unenriched journal entries. Fires once per day.

      Why: Exported sessions become searchable history. Unenriched entries lack metadata for filtering. Both decay in value over time.

      Output: VERBATIM relay with counts and exact commands.

      ┌─ Journal Reminder ─────────────────────────────\n│ You have 3 new session(s) not yet exported.\n│ 5 existing entries need enrichment.\n│\n│ Export and enrich:\n│   ctx journal import --all\n│   /ctx-journal-enrich-all\n└────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-resources-system-resource-pressure","level":4,"title":"check-resources: System Resource Pressure","text":"

      What: Monitors memory, swap, disk, and CPU load. Only fires at DANGER severity (memory >= 90%, swap >= 75%, disk >= 95%, load >= 1.5x CPU count).

      Why: Resource exhaustion mid-session can corrupt work. This provides early warning to persist and exit.

      Output: VERBATIM relay listing critical resources.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-knowledge-knowledge-file-growth","level":4,"title":"check-knowledge: Knowledge File Growth","text":"

      What: Counts entries in LEARNINGS.md, DECISIONS.md, and lines in CONVENTIONS.md. Fires once per day when thresholds are exceeded.

      Why: Large knowledge files dilute agent context. 35 learnings compete for attention; 15 focused ones get applied. Thresholds are configurable in .ctxrc.

      Default thresholds:

      # .ctxrc\nentry_count_learnings: 30\nentry_count_decisions: 20\nconvention_line_count: 200\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-version-binaryplugin-version-drift","level":4,"title":"check-version: Binary/Plugin Version Drift","text":"

      What: Compares the ctx binary version against the plugin version. Fires once per day. Also checks encryption key age for rotation nudge.

      Why: Version drift means hooks reference features the binary doesn't have. The key rotation nudge prevents indefinite key reuse.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-reminders-pending-reminder-relay","level":4,"title":"check-reminders: Pending Reminder Relay","text":"

      What: Reads .context/reminders.json and surfaces any due reminders via VERBATIM relay. No throttle: fires every session until dismissed.

      Why: Reminders are sticky notes to future-you. Unlike nudges (which throttle to once per day), reminders repeat deliberately until the user dismisses them.

      Output: VERBATIM relay box listing due reminders.

      ┌─ Reminders ──────────────────────────────────────\n│  [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-freshness-technology-constant-staleness","level":4,"title":"check-freshness: Technology Constant Staleness","text":"

      What: Stats files listed in .ctxrc freshness_files and warns if any haven't been modified in over 6 months. Daily throttle. Silent when no files are configured (opt-in via .ctxrc).

      Why: Model capabilities evolve - token budgets, attention limits, and context window sizes that were accurate 6 months ago may no longer reflect best practices. This hook reminds you to review and touch the file to confirm values are still current.

      Config (.ctxrc):

      freshness_files:\n  - path: config/thresholds.yaml\n    desc: Model token limits and batch sizes\n    review_url: https://docs.example.com/limits  # optional\n

      Each entry has a path (relative to project root), desc (what constants live there), and optional review_url (where to check current values). When review_url is set, the nudge includes \"Review against: {url}\". When absent, just \"Touch the file to mark it as reviewed.\"

      Output: VERBATIM relay listing stale files, silent otherwise.

      ┌─ Technology Constants Stale ──────────────────────\n│   config/thresholds.yaml (210 days ago)\n│     - Model token limits and batch sizes\n│   Review against: https://docs.example.com/limits\n│ Touch each file to mark it as reviewed.\n└───────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-map-staleness-architecture-map-drift","level":4,"title":"check-map-staleness: Architecture Map Drift","text":"

      What: Checks whether map-tracking.json is older than 30 days and there are commits touching internal/ since the last map refresh. Daily throttle prevents repeated nudges.

      Why: Architecture documentation drifts silently as code evolves. This hook detects structural changes that the map hasn't caught up with and suggests running /ctx-architecture to refresh.

      Output: VERBATIM relay when stale and modules changed, silent otherwise.

      ┌─ Architecture Map Stale ────────────────────────────\n│ ARCHITECTURE.md hasn't been refreshed since 2026-01-15\n│ and there are commits touching 12 modules.\n│ /ctx-architecture keeps architecture docs drift-free.\n│\n│ Want me to run /ctx-architecture to refresh?\n└─────────────────────────────────────────────────────\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#heartbeat-session-heartbeat-webhook","level":4,"title":"heartbeat: Session Heartbeat Webhook","text":"

      What: Fires on every prompt. Sends a webhook notification with prompt count, session ID, context modification status, and token usage telemetry. Never produces stdout.

      Why: Other hooks only send webhooks when they \"speak\" (nudge/relay). When silent, you have no visibility into session activity. The heartbeat provides a continuous session-alive signal with token consumption data for observability dashboards or liveness monitoring.

      Output: None (webhook + event log only).

      Payload:

      {\n  \"event\": \"heartbeat\",\n  \"message\": \"heartbeat: prompt #7 (context_modified=false tokens=158k pct=79%)\",\n  \"detail\": {\n    \"hook\": \"heartbeat\",\n    \"variant\": \"pulse\",\n    \"variables\": {\n      \"prompt_count\": 7,\n      \"session_id\": \"abc...\",\n      \"context_modified\": false,\n      \"tokens\": 158000,\n      \"context_window\": 200000,\n      \"usage_pct\": 79\n    }\n  }\n}\n

      Token fields (tokens, context_window, usage_pct) are included when usage data is available from the session JSONL file.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tool-time-hooks-pretooluse-posttooluse","level":3,"title":"Tool-Time Hooks (PreToolUse / PostToolUse)","text":"","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#block-non-path-ctx-path-enforcement-hard-gate","level":4,"title":"block-non-path-ctx: PATH Enforcement (Hard Gate)","text":"

      What: Blocks any Bash command that invokes ./ctx, ./dist/ctx, go run ./cmd/ctx, or an absolute path to ctx. Only PATH invocations are allowed.

      Why: Enforces CONSTITUTION.md's invocation invariant. Running a dev-built binary in production context causes version confusion and silent behavior drift.

      Output: Block response (prevents the tool call):

      {\"decision\": \"block\", \"reason\": \"Use 'ctx' from PATH, not './ctx'...\"}\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#qa-reminder-pre-commit-qa-gate","level":4,"title":"qa-reminder: Pre-Commit QA Gate","text":"

      What: Fires on every Edit tool use. Reminds the agent to lint and test the entire project before committing.

      Why: Agents tend to \"I'll test later\" and then commit untested code. Repetition is intentional: the hook reinforces the habit on every edit, not just before commits.

      Output: Agent directive with hard QA gate instructions.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#post-commit-context-capture-after-commit","level":4,"title":"post-commit: Context Capture After Commit","text":"

      What: Fires after any git commit (excludes --amend). Prompts the agent to offer context capture (decision? learning?) and suggest running lints/tests before pushing.

      Why: Commits are natural reflection points. The nudge converts mechanical git operations into context-capturing opportunities.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#auditing-hooks-via-the-local-event-log","level":2,"title":"Auditing Hooks via the Local Event Log","text":"

      If you don't need an external audit trail, enable the local event log for a self-contained record of hook activity:

      # .ctxrc\nevent_log: true\n

      Once enabled, every hook that fires writes an entry to .context/state/events.jsonl. Query it with ctx hook event:

      ctx hook event                    # last 50 events\nctx hook event --hook qa-reminder # filter by hook\nctx hook event --session <id>     # filter by session\nctx hook event --json | jq '.'    # raw JSONL for processing\n

      The event log is local, queryable, and doesn't require any external service. For a full diagnostic workflow combining event logs with structural health checks, see Troubleshooting.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#auditing-hooks-via-webhooks","level":2,"title":"Auditing Hooks via Webhooks","text":"

      The most powerful audit setup pipes all hook output to a webhook, giving you a real-time external record of what your agent is being told.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#step-1-set-up-the-webhook","level":3,"title":"Step 1: Set Up the Webhook","text":"
      ctx hook notify setup\n# Enter your webhook URL (Slack, Discord, ntfy.sh, IFTTT, etc.)\n

      See Webhook Notifications for service-specific setup.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#step-2-subscribe-to-relay-events","level":3,"title":"Step 2: Subscribe to relay Events","text":"
      # .ctxrc\nnotify:\n  events:\n    - relay   # all hook output: VERBATIM relays, directives, blocks\n    - nudge   # just the user-facing VERBATIM relays\n

      The relay event fires for every hook that produces output. This includes:

      Hook Event sent check-context-size relay + nudge check-persistence relay + nudge check-ceremonies relay + nudge check-journal relay + nudge check-resources relay + nudge check-knowledge relay + nudge check-version relay + nudge check-reminders relay + nudge check-freshness relay + nudge check-map-staleness relay + nudge heartbeat heartbeat only block-non-path-ctx relay only post-commit relay only qa-reminder relay only","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#step-3-cross-reference","level":3,"title":"Step 3: Cross-Reference","text":"

      With relay enabled, your webhook receives a JSON payload every time a hook fires:

      {\n  \"event\": \"relay\",\n  \"message\": \"check-persistence: No context updated in 20+ prompts\",\n  \"session_id\": \"b854bd9c\",\n  \"timestamp\": \"2026-02-22T14:30:00Z\",\n  \"project\": \"my-project\"\n}\n

      This creates an external audit trail independent of the agent. You can now cross-verify: did the agent actually relay the checkpoint the hook told it to relay?

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#verifying-hooks-actually-fire","level":2,"title":"Verifying Hooks Actually Fire","text":"

      Hooks are invisible. An invisible thing that breaks is indistinguishable from an invisible thing that never existed. Three verification methods, from simplest to most robust:

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#method-1-ask-the-agent","level":3,"title":"Method 1: Ask the Agent","text":"

      The simplest check. After a few prompts into a session:

      \"Did you receive any hook output this session? Print the last\ncontext checkpoint or persistence nudge you saw.\"\n

      The agent should be able to recall recent hook output from its context window. If it says \"I haven't received any hook output\", either:

      • The hooks aren't firing (check installation);
      • The session is too short (hooks throttle early);
      • The hooks fired but the agent absorbed them silently.

      Limitation: You are trusting the agent to report accurately. Agents sometimes confabulate or miss context. Use this as a quick smoke test, not definitive proof.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#method-2-check-the-webhook-trail","level":3,"title":"Method 2: Check the Webhook Trail","text":"

      If you have relay events enabled, check your webhook receiver. Every hook that fires sends a timestamped notification. No notification = no fire.

      This is the ground truth. The webhook is called directly by the ctx binary, not by the agent. The agent cannot fake, suppress, or modify webhook deliveries.

      Compare what the webhook received against what the agent claims to have relayed. Discrepancies mean the agent is absorbing nudges instead of surfacing them.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#method-3-read-the-local-logs","level":3,"title":"Method 3: Read the Local Logs","text":"

      Hooks that support logging write to .context/logs/:

      # Check context-size hook activity\ncat .context/logs/check-context-size.log\n\n# Sample output:\n# [2026-02-22 09:15:00] [session:b854bd9c] prompt#1 silent\n# [2026-02-22 09:17:33] [session:b854bd9c] prompt#16 CHECKPOINT\n# [2026-02-22 09:20:01] [session:b854bd9c] prompt#20 CHECKPOINT\n
      # Check persistence nudge activity\ncat .context/logs/check-persistence.log\n\n# Sample output:\n# [2026-02-22 09:15:00] [session:b854bd9c] init count=1 mtime=1770646611\n# [2026-02-22 09:20:01] [session:b854bd9c] prompt#20 NUDGE since_nudge=20\n

      Logs are append-only and written by the ctx binary, not the agent.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#detecting-silent-hook-failures","level":2,"title":"Detecting Silent Hook Failures","text":"

      The hardest failure mode: hooks that stop firing without error. The plugin config changes, a binary update drops a hook, or a PATH issue silently breaks execution. Nothing errors: The hook just never runs.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-staleness-signal","level":3,"title":"The Staleness Signal","text":"

      If .context/logs/check-context-size.log has no entries newer than 5 days but you've been running sessions daily, something is wrong. The absence of evidence is evidence of absence: but only if you control for inactivity.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#false-positive-protection","level":3,"title":"False Positive Protection","text":"

      A naive \"hooks haven't fired in N days\" alert fires incorrectly when you simply haven't used ctx. The correct check needs two inputs:

      1. Last hook fire time: from .context/logs/ or webhook history
      2. Last session activity: from journal entries or ctx journal source

      If sessions are happening but hooks aren't firing, that's a real problem. If neither sessions nor hooks are happening, that's a vacation.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#what-to-check","level":3,"title":"What to Check","text":"

      When you suspect hooks aren't firing:

      # 1. Verify the plugin is installed\nls ~/.claude/plugins/\n\n# 2. Check hook registration\ncat ~/.claude/plugins/ctx/hooks.json | head -20\n\n# 3. Run a hook manually to see if it errors\necho '{\"session_id\":\"test\"}' | ctx system check-context-size\n\n# 4. Check for PATH issues\nwhich ctx\nctx --version\n
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tips","level":2,"title":"Tips","text":"
      • Start with nudge, graduate to relay: The nudge event covers user-facing VERBATIM relays. Add relay when you want full visibility into agent directives and hard gates.
      • Webhooks are your trust anchor: The agent can ignore a nudge, but it can't suppress the webhook. If the webhook fired and the agent didn't relay, you have proof of a compliance gap.
      • Hooks are throttled by design: Most check hooks fire once per day or use adaptive frequency. Don't expect a notification every prompt: Silence usually means the throttle is working, not that the hook is broken.
      • Daily markers live in .context/state/: Throttle files are stored in .context/state/ alongside other project-scoped state. If you need to force a hook to re-fire during testing, delete the corresponding marker file.
      • The QA reminder is intentionally noisy: Unlike other hooks, qa-reminder fires on every Edit call with no throttle. This is deliberate: The commit quality degrades when the reminder fades from salience.
      • Log files are safe to commit: .context/logs/ contains only timestamps, session IDs, and status keywords. No secrets, no code.
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#next-up","level":2,"title":"Next Up","text":"

      Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.

      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#see-also","level":2,"title":"See Also","text":"
      • Troubleshooting: full diagnostic workflow using ctx doctor, event logs, and /ctx-doctor
      • Customizing Hook Messages: override what hooks say without changing what they do
      • Webhook Notifications: setting up and configuring the webhook system
      • Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates
      • Detecting and Fixing Drift: structural checks that complement runtime hook auditing
      • CLI Reference: full ctx system command reference
      ","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/task-management/","level":1,"title":"Tracking Work Across Sessions","text":"","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-problem","level":2,"title":"The Problem","text":"

      You have work that spans multiple sessions. Tasks get added during one session, partially finished in another, and completed days later.

      Without a system, follow-up items fall through the cracks, priorities drift, and you lose track of what was done versus what still needs doing. TASKS.md grows cluttered with completed checkboxes that obscure the remaining work.

      How do you manage work items that span multiple sessions without losing context?

      Prefer Skills over Raw Commands

      When working with an AI agent, use /ctx-task-add instead of raw ctx task add. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.

      Activate the Project First

      Run eval \"$(ctx activate)\" once per terminal in the project root. If you skip it, the ctx task add / ctx task ... commands below fail with Error: no context directory specified. See Activating a Context Directory.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tldr","level":2,"title":"TL;DR","text":"

      Manage Tasks:

      ctx task add \"Fix race condition\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a  # add\nctx task add \"Write tests\" --section \"Phase 2\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a  # add to phase\nctx task complete \"race condition\"                      # mark done\nctx task snapshot \"before-refactor\"               # backup\nctx task archive                                  # clean up\n

      Pick Up the Next Task:

      /ctx-next # pick what's next\n

      Read on for the full workflow and conversational patterns.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx task add Command Add a new task to TASKS.md ctx task complete Command Mark a task as done by number or text ctx task snapshot Command Create a point-in-time backup of TASKS.md ctx task archive Command Move completed tasks to archive file /ctx-task-add Skill AI-assisted task creation with validation /ctx-archive Skill AI-guided archival with safety checks /ctx-next Skill Pick what to work on based on priorities","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-1-add-tasks-with-priorities","level":3,"title":"Step 1: Add Tasks with Priorities","text":"

      Every piece of follow-up work gets a task. Use ctx task add from the terminal or /ctx-task-add from your AI assistant. Tasks should start with a verb and be specific enough that someone unfamiliar with the session could act on them.

      # High-priority bug found during code review\nctx task add \"Fix race condition in session cooldown\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Medium-priority feature work\nctx task add \"Add --format json flag to ctx status for CI integration\" --priority medium \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Low-priority cleanup\nctx task add \"Remove deprecated --raw flag from ctx load\" --priority low \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n

      The /ctx-task-add skill validates your task before recording it. It checks that the description is actionable, not a duplicate, and specific enough for someone else to pick up.

      If you say \"fix the bug,\" it will ask you to clarify which bug and where.

      Tasks Are Often Created Proactively

      In practice, many tasks are created proactively by the agent rather than by explicit CLI commands.

      After completing a feature, the agent will often identify follow-up work: tests, docs, edge cases, error handling, and offer to add them as tasks.

      You do not need to dictate ctx task add commands; the agent picks up on work context and suggests tasks naturally.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-2-organize-with-phase-sections","level":3,"title":"Step 2: Organize with Phase Sections","text":"

      Tasks live in phase sections inside TASKS.md.

      Phases provide logical groupings that preserve order and enable replay.

      A task does not move between sections. It stays in its phase permanently, and status is tracked via checkboxes and inline tags.

      ## Phase 1: Core CLI\n\n- [x] Implement ctx add command\n- [x] Implement ctx task complete command\n- [ ] Add --section flag to ctx task add `#priority:medium`\n\n## Phase 2: AI Integration\n\n- [ ] Implement ctx agent cooldown `#priority:high` `#in-progress`\n- [ ] Add ctx watch XML parsing `#priority:medium`\n  - Blocked by: Need to finalize agent output format\n\n## Backlog\n\n- [ ] Performance optimization for large TASKS.md files `#priority:low`\n- [ ] Add metrics dashboard to ctx status `#priority:deferred`\n

      Use --section when adding a task to a specific phase:

      ctx task add \"Add ctx watch XML parsing\" --priority medium --section \\\n    \"Phase 2: AI Integration\" \\\n    --session-id abc12345 --branch main --commit 68fbc00a\n

      Without --section, the task is inserted before the first unchecked task in TASKS.md.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-3-pick-what-to-work-on","level":3,"title":"Step 3: Pick What to Work On","text":"

      At the start of a session, or after finishing a task, use /ctx-next to get prioritized recommendations.

      The skill reads TASKS.md, checks recent sessions, and ranks candidates using explicit priority, blocking status, in-progress state, momentum from recent work, and phase order.

      You can also ask naturally: \"what should we work on?\" or \"what's the highest priority right now?\"

      /ctx-next\n

      The output looks like this:

      **1. Implement ctx agent cooldown** `#priority:high`\n\n    Still in-progress from yesterday's session. The tombstone file approach is\n    half-built. Finishing is cheaper than context-switching.\n\n**2. Add --section flag to ctx task add** `#priority:medium`\n\n    Last Phase 1 item. Quick win that unblocks organized task entry.\n\n---\n\n*Based on 8 pending tasks across 3 phases.\n\nLast session: agent-cooldown (2026-02-06).*\n

      In-progress tasks almost always come first:

      Finishing existing work takes priority over starting new work.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-4-complete-tasks","level":3,"title":"Step 4: Complete Tasks","text":"

      When a task is done, mark it complete by number or partial text match:

      # By task number (as shown in TASKS.md)\nctx task complete 3\n\n# By partial text match\nctx task complete \"agent cooldown\"\n

      The task's checkbox changes from [ ] to [x]. Tasks are never deleted: they stay in their phase section so history is preserved.

      Be Conversational

      You rarely need to run ctx task complete yourself during an interactive session.

      When you say something like \"the rate limiter is done\" or \"we finished that,\" the agent marks the task complete and moves on to suggesting what is next.

      The CLI commands are most useful for manual housekeeping, scripted workflows, or when you want precision.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-5-snapshot-before-risky-changes","level":3,"title":"Step 5: Snapshot Before Risky Changes","text":"

      Before a major refactor or any change that might break things, snapshot your current task state. This creates a copy of TASKS.md in .context/archive/ without modifying the original.

      # Default snapshot\nctx task snapshot\n\n# Named snapshot (recommended before big changes)\nctx task snapshot \"before-refactor\"\n

      This creates a file like .context/archive/tasks-before-refactor-2026-02-08-1430.md. If the refactor goes sideways, and you need to confirm what the task state looked like before you started, the snapshot is there.

      Snapshots are cheap: Take them before any change you might want to undo or review later.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#step-6-archive-when-tasksmd-gets-cluttered","level":3,"title":"Step 6: Archive When TASKS.md Gets Cluttered","text":"

      After several sessions, TASKS.md accumulates completed tasks that make it hard to see what is still pending.

      Use ctx task archive to move all [x] items to a timestamped archive file.

      Start with a dry run to preview what will be moved:

      ctx task archive --dry-run\n

      Then archive:

      ctx task archive\n

      Completed tasks move to .context/archive/tasks-2026-02-08.md. Phase headers are preserved in the archive for traceability. Pending tasks ([ ]) remain in TASKS.md.

      The /ctx-archive skill adds two safety checks before archiving: it verifies that completed tasks are genuinely cluttering the view and that nothing was marked [x] prematurely.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#letting-the-agent-drive","level":2,"title":"Letting the Agent Drive","text":"

      The steps above show the CLI commands for task management.

      In practice, most task management happens conversationally:

      An agent that has loaded the context files does not need you to type ctx task add. It tracks work naturally and offers the right operations.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#use-natural-language-instead-of-commands","level":3,"title":"Use Natural Language Instead of Commands","text":"

      These conversational prompts replace explicit commands during interactive sessions:

      Instead of typing... Just say... ctx task add \"Write tests for X\" --session-id ID --branch BR --commit HASH \"We should add tests for this: track that?\" /ctx-next \"What should we work on?\" ctx task complete \"rate limiting\" \"The rate limiter is done, what's next?\" ctx task archive \"TASKS.md is getting long, can you clean it up?\" ctx task add ... --session-id ID --branch BR --commit HASH && ctx task add ... \"Add follow-ups for what we just built.\"

      The agent translates these into the right ctx operations behind the scenes.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-agent-creates-tasks-proactively","level":3,"title":"The Agent Creates Tasks Proactively","text":"

      After completing a piece of work, the agent does not wait for you to dictate follow-up items. It identifies them from the work context and offers:

      **Agent**: \"I've finished implementing the rate limiter middleware. I noticed\nthree follow-up items:\n\n1. Write integration tests for the rate limiter (the unit tests pass but\n   there's no end-to-end coverage)\n2. Add rate limit headers to API responses (X-RateLimit-Remaining, etc.)\n3. Document the rate limit configuration in the ops runbook\n\nWant me to add these as tasks?\"\n

      This is how an agent behaves once it has read the Agent Playbook.

      The playbook's \"Work, Reflect, Persist\" cycle means the agent asks itself after every milestone: Did I just complete a task? Did new work emerge?

      When the answer is yes, it acts.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#asking-the-agent-what-to-capture","level":3,"title":"Asking the Agent What to Capture","text":"

      You don't always know what's worth persisting.

      Instead of reviewing the session yourself and typing specific commands, ask the agent to do the thinking:

      You say What happens \"What tasks came out of this session?\" Agent reviews the work, identifies follow-ups, and offers to add them \"Are there any tasks, learnings, or decisions worth adding?\" Agent scans the full session for all three types and proposes a batch \"What should we remember from today?\" Agent surfaces everything persist-worthy: not just tasks \"Anything we should track before we move on?\" Agent checks for loose ends specific to the work just completed

      This is especially powerful after long or exploratory sessions where multiple threads were touched.

      The agent has the full conversation in context and can spot follow-ups you might miss:

      You:   \"Are there any tasks, learnings, or decisions worth adding\n        from this session?\"\n\nAgent: \"Yes. Here's what I'd suggest:\n\n  Tasks:\n  - Add retry logic to the webhook delivery (we discussed it when\n    the timeout test failed but never tracked it)\n  - Update the API docs to reflect the new rate limit headers\n\n  Learnings:\n  - net/http's default client has no timeout: we burned 15 minutes\n    on that before adding an explicit 30s timeout\n\n  Decisions:\n  - We chose token-bucket over sliding-window for rate limiting\n    because it handles bursts better and the library is simpler\n\n  Want me to add all of these?\"\n\nYou:   \"All of them.\"\n

      The agent fills in structured fields from what it observed during the session. You get the same quality entries as if you typed verbose commands, without needing to remember what happened or how to format it.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#the-agent-completes-tasks-and-moves-on","level":3,"title":"The Agent Completes Tasks and Moves On","text":"

      When you confirm that work is finished, or when the agent can see that it is, it marks the task done and suggests the next step:

      You: \n\"The cooldown logic is working now.\"\n\nAgent: \n\"Marked 'Implement ctx agent cooldown' as done. Your highest-\npriority remaining task is 'Add --section flag to ctx task add'.\n\nIt's the last item in Phase 1 and a quick win. Want to start on that?\"\n

      The agent chains completion into next-task selection.

      One sentence from you triggers two operations.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#end-of-session-capture","level":3,"title":"End-of-Session Capture","text":"

      At the end of a session, the agent reviews what happened and catches loose ends:

      You: \n\"I think we're good for today.\"\n\nAgent: \n\"Before we wrap up: during the middleware work you mentioned\nwanting to add metrics for rate limit hits. That never made it into TASKS.md.\n\nWant me to add it as a task so it's there next session?\"\n

      This is the proactive persistence model at work.

      The agent monitors the conversation for mentioned-but-not-tracked work and surfaces it before context is lost.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#a-conversational-session-example","level":3,"title":"A Conversational Session Example","text":"

      Here is what task management looks like in a real session when the agent is driving:

      You:   What's left to do?\nAgent: You have 5 pending tasks across 2 phases. The highest priority is\n       \"Implement ctx agent cooldown\": it's marked in-progress from\n       yesterday and half-built. Want to pick that up?\n\nYou:   Yeah, let's finish it.\n       [... 20 minutes of implementation work ...]\n\nYou:   That's working. Tests pass.\nAgent: Nice. I'll mark \"Implement ctx agent cooldown\" as done.\n       I noticed two things from the implementation:\n       1. The tombstone file cleanup should happen on a timer, not just\n          at startup. Want me to add that as a task?\n       2. We learned that file locks don't work reliably on NFS. I'll\n          add that to LEARNINGS.md.\n\nYou:   Yes to both. What's next?\nAgent: Added the cleanup task as high priority. Next up is \"Add --section\n       flag to ctx task add\": last item in Phase 1. It should be\n       straightforward since the flag parsing pattern already exists\n       in the codebase. Ready?\n

      It's All Conversational

      Notice what did not happen: The user never typed a ctx command.

      The agent handled task completion, follow-up creation, learning capture, and next-task selection: all from natural conversation.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"
      # Add a task\nctx task add \"Implement rate limiting for API endpoints\" --priority high \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# Add to a specific phase\nctx task add \"Write integration tests for rate limiter\" --section \"Phase 2\" \\\n  --session-id abc12345 --branch main --commit 68fbc00a\n\n# See what to work on\n# (from AI assistant) /ctx-next\n\n# Mark done by text\nctx task complete \"rate limiting\"\n\n# Mark done by number\nctx task complete 5\n\n# Snapshot before a risky refactor\nctx task snapshot \"before-middleware-rewrite\"\n\n# Archive completed tasks when the list gets long\nctx task archive --dry-run     # preview first\nctx task archive               # then archive\n
      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tips","level":2,"title":"Tips","text":"
      • Start tasks with a verb: \"Add,\" \"Fix,\" \"Implement,\" \"Investigate\": not just a topic like \"Authentication.\"
      • Include the why in the task description. Future sessions lack the context of why you added the task. \"Add rate limiting\" is worse than \"Add rate limiting to prevent abuse on the public API after the load test showed 10x traffic spikes.\"
      • Use #in-progress sparingly. Only one or two tasks should carry this tag at a time. If everything is in-progress, nothing is.
      • Snapshot before, not after. The point of a snapshot is to capture the state before a change, not to celebrate what you just finished.
      • Archive regularly. Once completed tasks outnumber pending ones, it is time to archive. A clean TASKS.md helps both you and your AI assistant focus.
      • Never delete tasks. Mark them [x] (completed) or [-] (skipped with a reason). Deletion breaks the audit trail.
      • Trust the agent's task instincts. When the agent suggests follow-up items after completing work, it is drawing on the full context of what just happened.
      • Conversational prompts beat commands in interactive sessions. Saying \"what should we work on?\" is faster and more natural than running /ctx-next. Save explicit commands for scripts, CI, and unattended runs.
      • Let the agent chain operations. A single statement like \"that's done, what's next?\" can trigger completion, follow-up identification, and next-task selection in one flow.
      • Review proactive task suggestions before moving on. The best follow-ups come from items spotted in-context right after the work completes.
      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#next-up","level":2,"title":"Next Up","text":"

      Using the Scratchpad →: Store short-lived sensitive notes in an encrypted scratchpad.

      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#see-also","level":2,"title":"See Also","text":"
      • The Complete Session: full session lifecycle including task management in context
      • Persisting Decisions, Learnings, and Conventions: capturing the \"why\" behind your work
      • Detecting and Fixing Drift: keeping TASKS.md accurate over time
      • CLI Reference: full documentation for ctx add, ctx task complete, ctx task
      • Context Files: TASKS.md: format and conventions for TASKS.md
      ","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/triggers/","level":1,"title":"Authoring Lifecycle Triggers","text":"","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#authoring-lifecycle-triggers","level":1,"title":"Authoring Lifecycle Triggers","text":"

      Triggers are executable shell scripts that fire at specific events during an AI session. They're how you express \"when the AI saves a file, also do X\" or \"before the AI edits this path, check Y first.\" This recipe walks through writing your first trigger, testing it, and enabling it safely.

      Triggers Execute Arbitrary Code

      A trigger is a shell script with the executable bit set. It runs with the same privileges as your AI tool and receives JSON input on stdin. Treat triggers like pre-commit hooks:

      • Only enable scripts you have read and understand.
      • Never enable a trigger you downloaded from the internet without reviewing every line.
      • Avoid shelling out to user-controlled values (jq -r output, path field, tool field) without quoting.
      • A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.

      The generated trigger template starts disabled (no executable bit) so you cannot accidentally run an unreviewed script. Enable it explicitly with ctx trigger enable.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#scenario","level":2,"title":"Scenario","text":"

      You want a pre-tool-use trigger that blocks the AI from editing anything in internal/crypto/ without explicit confirmation. Cryptographic code is sensitive, and accidental edits have caused outages before, and you want a hard gate.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-1-scaffold-the-script","level":2,"title":"Step 1: Scaffold the Script","text":"
      ctx trigger add pre-tool-use protect-crypto\n

      That creates .context/hooks/pre-tool-use/protect-crypto.sh with a template:

      #!/usr/bin/env bash\nset -euo pipefail\n\n# Read the JSON event from stdin.\npayload=$(cat)\n\n# Parse fields with jq.\ntool=$(echo \"$payload\" | jq -r '.tool // empty')\npath=$(echo \"$payload\" | jq -r '.path // empty')\n\n# Your logic here.\n\n# Return a JSON result. action can be \"allow\", \"block\", or absent.\necho '{\"action\": \"allow\"}'\n

      Note: the directory is .context/hooks/pre-tool-use/; the on-disk layout still uses hooks/ even though the command is ctx trigger. If you ls .context/hooks/, that's where your triggers live.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-2-write-the-logic","level":2,"title":"Step 2: Write the Logic","text":"

      Open the file and replace the template body:

      #!/usr/bin/env bash\nset -euo pipefail\n\npayload=$(cat)\ntool=$(echo \"$payload\" | jq -r '.tool // empty')\npath=$(echo \"$payload\" | jq -r '.path // empty')\n\n# Only gate write-family tools.\ncase \"$tool\" in\n  write_file|edit_file|apply_patch) ;;\n  *)\n    echo '{\"action\": \"allow\"}'\n    exit 0\n    ;;\nesac\n\n# Block any path under internal/crypto/.\ncase \"$path\" in\n  internal/crypto/*|*/internal/crypto/*)\n    jq -n --arg p \"$path\" '{\n      action: \"block\",\n      message: (\"Edits to \" + $p + \" require manual review. \" +\n                \"See CONVENTIONS.md for the crypto-change process.\")\n    }'\n    exit 0\n    ;;\nesac\n\necho '{\"action\": \"allow\"}'\n

      A few things to note:

      • set -euo pipefail: any unhandled error aborts the script. Critical for a security-relevant trigger.
      • Quote everything from jq: the path field comes from the AI tool; treat it as untrusted input.
      • Explicit allow case: the default is allow. An empty or missing response is a risky default.
      • Use jq -n --arg for output construction, as it is safer than string concatenation when the message may contain special characters.
      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-3-test-with-a-mock-payload","level":2,"title":"Step 3: Test with a Mock Payload","text":"

      Before enabling the trigger, test it with a realistic mock input using ctx trigger test. This runs the script against a synthetic JSON payload without actually firing any AI tool.

      # Test the \"should block\" case\nctx trigger test pre-tool-use --tool write_file --path internal/crypto/aes.go\n

      Expected: the trigger returns {\"action\":\"block\", \"message\": \"...\"}.

      # Test the \"should allow\" case\nctx trigger test pre-tool-use --tool write_file --path internal/memory/mirror.go\n

      Expected: the trigger returns {\"action\":\"allow\"}.

      # Test that non-write tools pass through\nctx trigger test pre-tool-use --tool read_file --path internal/crypto/aes.go\n

      Expected: {\"action\":\"allow\"} because the case statement only gates write-family tools.

      If any of these cases misbehave, fix the trigger before enabling it. The trigger is disabled at this point, so misbehavior doesn't affect real AI sessions.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-4-enable-it","level":2,"title":"Step 4: Enable It","text":"

      Once the test cases pass, enable the trigger:

      ctx trigger enable protect-crypto\n

      That sets the executable bit. Next time the AI starts a pre-tool-use event, the trigger will fire.

      Verify it's enabled:

      ctx trigger list\n

      Should show protect-crypto under pre-tool-use with an enabled indicator.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-5-iterate-safely","level":2,"title":"Step 5: Iterate Safely","text":"

      If you discover a bug after enabling, disable first, fix second:

      ctx trigger disable protect-crypto\n# ...edit the script...\nctx trigger test pre-tool-use --tool write_file --path internal/crypto/aes.go\nctx trigger enable protect-crypto\n

      Disabling simply clears the executable bit; the script stays on disk, and ctx trigger enable re-enables it without rewriting anything.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#patterns-worth-copying","level":2,"title":"Patterns Worth Copying","text":"","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#logging-not-blocking","level":3,"title":"Logging, Not Blocking","text":"

      For auditing or analytics, return {\"action\":\"allow\"} always and append to a log as a side effect:

      #!/usr/bin/env bash\nset -euo pipefail\npayload=$(cat)\necho \"$payload\" >> .context/logs/tool-use.jsonl\necho '{\"action\":\"allow\"}'\n
      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#context-injection-at-session-start","level":3,"title":"Context Injection at Session Start","text":"

      A session-start trigger can prepend text to the agent's initial prompt by emitting {\"action\":\"inject\", \"content\": \"...\"} . This is useful for injecting daily standup notes, open PRs, or rotating TODOs without storing them in a steering file.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#chaining-triggers-of-the-same-type","level":3,"title":"Chaining Triggers of the Same Type","text":"

      Multiple scripts in the same type directory all run. If any returns action: block, the block wins. Keep individual triggers single-purpose and rely on composition.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#common-mistakes","level":2,"title":"Common Mistakes","text":"

      Forgetting the shebang. Without #!/usr/bin/env bash, the trigger won't execute even with the executable bit set.

      Not quoting $path. If you use $path in a command substitution or a case glob without quoting, a file name with spaces or metacharacters will break the trigger in surprising ways.

      Enabling before testing. ctx trigger enable makes the script live immediately. Always ctx trigger test first.

      Outputting non-JSON. The trigger's stdout must be valid JSON or ctx's trigger runner will log a parse error. Use jq -n to construct output rather than hand-writing JSON strings.

      Mixing hook and trigger vocabulary. The command is ctx trigger but the on-disk directory is .context/hooks/. The feature was renamed; the directory name lags behind. Don't let this confuse you; they refer to the same thing.

      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#see-also","level":2,"title":"See Also","text":"
      • ctx trigger reference: full command, flag, and event-type reference.
      • ctx steering: persistent rules, not scripts. Use steering when the thing you want is \"tell the AI to always do X\" rather than \"run a script when Y happens.\"
      • Writing steering files: the rule-based equivalent of this recipe.
      ","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/troubleshooting/","level":1,"title":"Troubleshooting","text":"","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-problem","level":2,"title":"The Problem","text":"

      Something isn't working: a hook isn't firing, nudges are too noisy, context seems stale, or the agent isn't following instructions. The information to diagnose it exists (across status, drift, event logs, hook config, and session history), but assembling it manually is tedious.

      How do you figure out what's wrong and fix it?

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tldr","level":2,"title":"TL;DR","text":"
      ctx doctor                   # structural health check\nctx hook event --last 20  # recent hook activity\n# or ask: \"something seems off, can you diagnose?\"\n
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx doctor CLI command Structural health report ctx doctor --json CLI command Machine-readable health report ctx hook event CLI command Query local event log /ctx-doctor Skill Agent-driven diagnosis with analysis","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#quick-check-ctx-doctor","level":3,"title":"Quick Check: ctx doctor","text":"

      Run ctx doctor for an instant structural health report. It checks context initialization, required files, drift, hook configuration, event logging, webhooks, reminders, task completion ratio, and context token size: all in one pass:

      ctx doctor\n
      ctx doctor\n==========\n\nStructure\n  ✓ Context initialized (.context/)\n  ✓ Required files present (4/4)\n\nQuality\n  ⚠ Drift: 2 warnings (stale path in ARCHITECTURE.md, high entry count in LEARNINGS.md)\n\nHooks\n  ✓ hooks.json valid (14 hooks registered)\n  ○ Event logging disabled (enable with event_log: true in .ctxrc)\n\nState\n  ✓ No pending reminders\n  ⚠ Task completion ratio high (18/22 = 82%): consider archiving\n\nSize\n  ✓ Context size: ~4200 tokens (budget: 8000)\n\nSummary: 2 warnings, 0 errors\n

      Warnings are non-critical but worth fixing. Errors need attention. Informational notes (○) flag optional features that aren't enabled.

      For scripting:

      ctx doctor --json | jq '.warnings'\n
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#deep-dive-ctx-doctor","level":3,"title":"Deep Dive: /ctx-doctor","text":"

      When you need the agent to reason about what's wrong, use the skill. Ask naturally or invoke directly:

      Why didn't my hook fire?\nSomething seems off, can you diagnose?\n/ctx-doctor\n

      The agent follows a triage sequence:

      1. Baseline: runs ctx doctor --json for structural health
      2. Events: runs ctx hook event --json --last 100 (if event logging enabled)
      3. Correlate: connects findings across both sources
      4. Present: structured findings with evidence
      5. Suggest: actionable next steps (but doesn't auto-fix)

      The skill degrades gracefully: without event logging enabled, it still runs structural checks and notes what you'd gain by enabling it.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#raw-event-inspection","level":3,"title":"Raw Event Inspection","text":"

      For power users: ctx hook event with filters gives direct access to the event log.

      # Last 50 events (default)\nctx hook event\n\n# Events from a specific session\nctx hook event --session eb1dc9cd-0163-4853-89d0-785fbfaae3a6\n\n# Only QA reminder events\nctx hook event --hook qa-reminder\n\n# Raw JSONL for jq processing\nctx hook event --json | jq '.message'\n\n# Include rotated (older) events\nctx hook event --all --last 100\n

      Filters use AND logic: --hook qa-reminder --session abc123 returns only QA reminder events from that specific session.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#common-problems","level":2,"title":"Common Problems","text":"","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#no-context-directory-specified-for-this-project","level":3,"title":"\"No context directory specified for this project\"","text":"

      Symptoms: Any ctx command fails with Error: no context directory specified for this project (possibly with a likely-candidate hint or a candidate list depending on what's visible from your CWD).

      Cause: ctx does not search the filesystem for a .context/ directory. You have to declare which one to use before running day-to-day commands.

      Fix: bind CTX_DIR for the current shell:

      eval \"$(ctx activate)\"\n

      See Activating a Context Directory for the full recipe (one-shot CTX_DIR=... inline form, CI patterns, direnv setup).

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#ctx-not-initialized","level":3,"title":"\"ctx: Not Initialized\"","text":"

      Symptoms: After declaring CTX_DIR, the command fails with ctx: not initialized - run \"ctx init\" first.

      Cause: The declared directory exists but hasn't been initialized with template files.

      Fix:

      ctx init          # create .context/ with template files\nctx init --minimal  # or just the essentials (CONSTITUTION, TASKS, DECISIONS)\n

      Commands that work without CTX_DIR or initialization: ctx init, ctx activate, ctx deactivate, ctx setup, ctx doctor, ctx guide, ctx why, ctx config switch/status, ctx hub *, and help-only grouping commands.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#my-cli-and-my-claude-code-session-disagree-on-the-project","level":3,"title":"\"My CLI and My Claude Code Session Disagree on the Project\"","text":"

      Symptoms: A !-pragma or interactive ctx call writes to the wrong .context/; or you ran ctx remind add in shell A and the reminder shows up in project B's notifications.

      Cause: CTX_DIR is sourced from three different surfaces, and they can drift apart:

      Surface Source of CTX_DIR Bound when Claude Code hooks ${CLAUDE_PROJECT_DIR}/.context (injected) Every hook line; the project Claude is in !-pragma in chat / interactive shell Whatever the parent shell exported When you ran eval \"$(ctx activate)\" New shell tab opened mid-session Whatever your shellrc exports Login

      When these drift, the per-prompt check-anchor-drift hook fires a verbatim warning naming both values. To fix: re-run eval \"$(ctx activate)\" from inside the project the Claude Code session is editing, or close the shell tab and reopen it from the right working directory.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#my-hook-isnt-firing","level":3,"title":"\"My Hook Isn't Firing\"","text":"

      Symptoms: No nudges appearing, webhook silent, event log shows no entries for the expected hook.

      Diagnosis:

      # 1. Check if ctx is installed and on PATH\nwhich ctx && ctx --version\n\n# 2. Check if the hook is registered\ngrep \"check-persistence\" ~/.claude/plugins/ctx/hooks.json\n\n# 3. Run the hook manually to see if it errors\necho '{\"session_id\":\"test\"}' | ctx system check-persistence\n\n# 4. Check event log for the hook (if enabled)\nctx hook event --hook check-persistence\n

      Common causes:

      • Plugin is not installed: run ctx init --claude to reinstall
      • PATH issue: the hook invokes ctx from PATH; ensure it resolves
      • Throttle active: most hooks fire once per day: check .context/state/ for daily marker files
      • Hook silenced: a custom message override may be an empty file: check ctx hook message list for overrides
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#too-many-nudges","level":3,"title":"\"Too Many Nudges\"","text":"

      Symptoms: The agent is overwhelmed with hook output. Context checkpoints, persistence reminders, and QA gates fire constantly.

      Diagnosis:

      # Check how often hooks fired recently\nctx hook event --last 50\n\n# Count fires per hook\nctx hook event --json | jq -r '.detail.hook // \"unknown\"' \\\n  | sort | uniq -c | sort -rn\n

      Common causes:

      • QA reminder is noisy by design: it fires on every Edit call with no throttle. This is intentional. If it's too much, silence it with an empty override: ctx hook message edit qa-reminder gate, then empty the file
      • Long session: context checkpoint fires with increasing frequency after prompt 15. This is the system telling you the session is getting long: consider wrapping up
      • Short throttle window: if you deleted marker files in .context/state/, daily-throttled hooks will re-fire
      • Outdated Claude Code plugin: Update the plugin using Claude Code → /plugin → \"Marketplace\"
      • ctx version mismatch: Build (or download) and install the latest ctx vesion.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#context-seems-stale","level":3,"title":"\"Context Seems Stale\"","text":"

      Symptoms: The agent references outdated information, paths that don't exist, or decisions that were reversed.

      Diagnosis:

      # Structural drift check\nctx drift\n\n# Full doctor check (includes drift + more)\nctx doctor\n\n# Check when context files were last modified\nctx status --verbose\n

      Common causes:

      • Drift accumulated: stale path references in ARCHITECTURE.md or CONVENTIONS.md. Fix with ctx drift --fix or ask the agent to clean up.
      • Task backlog: too many completed tasks diluting active context. Archive with ctx task archive or ctx compact --archive.
      • Large context files: LEARNINGS.md with 40+ entries competes for attention. Consolidate with /ctx-consolidate.
      • Missing session ceremonies: if /ctx-remember and /ctx-wrap-up aren't being used, context doesn't get refreshed. See Session Ceremonies.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-agent-isnt-following-instructions","level":3,"title":"\"The Agent Isn't Following Instructions\"","text":"

      Symptoms: The agent ignores conventions, forgets decisions, or acts contrary to CONSTITUTION.md rules.

      Diagnosis:

      # Check context token size: Is it too large for the model?\nctx doctor --json | jq '.results[] | select(.name == \"context_size\")'\n\n# Check if context is actually being loaded\nctx hook event --hook context-load-gate\n

      Common causes:

      • Context too large: if total tokens exceed the model's effective attention, instructions get diluted. Check ctx doctor for the size check. Compact with ctx compact --archive.
      • Context not loading: if context-load-gate hasn't fired, the agent may not have received context. Verify the hook is registered.
      • Conflicting instructions: CONVENTIONS.md says one thing, AGENT_PLAYBOOK.md says another. Review both files for consistency.
      • Agent drift: the agent's behavior diverges from instructions over long sessions. This is normal. Use /ctx-reflect to re-anchor, or start a new session.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#prerequisites","level":2,"title":"Prerequisites","text":"
      • Event logging (optional but recommended): event_log: true in .ctxrc
      • ctx initialized: ctx init

      Event logging is not required for ctx doctor or /ctx-doctor to work. Both degrade gracefully: structural checks run regardless, and the skill notes when event data is unavailable.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tips","level":2,"title":"Tips","text":"
      • Start with ctx doctor: It's the fastest way to get a comprehensive health picture. Save event log inspection for when you need to understand when and how often something happened.
      • Enable event logging early: The log is opt-in and low-cost (~250 bytes per event, 1MB rotation cap). Enable it before you need it: Diagnosing a problem without historical data is much harder.
      • Use the skill for correlation: ctx doctor tells you what is wrong. /ctx-doctor tells you why by correlating structural findings with event patterns. The agent can spot connections that individual commands miss.
      • Event log is gitignored: It's machine-local diagnostic data, not project context. Different machines produce different event streams.
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#next-up","level":2,"title":"Next Up","text":"

      Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.

      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#see-also","level":2,"title":"See Also","text":"
      • Auditing System Hooks: the complete hook catalog and webhook-based audit trails
      • Detecting and Fixing Drift: structural and semantic drift detection and repair
      • Webhook Notifications: push notifications for hook activity
      • ctx doctor CLI: full command reference
      • ctx hook event CLI: event log query reference
      • /ctx-doctor skill: agent-driven diagnosis
      ","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/webhook-notifications/","level":1,"title":"Webhook Notifications","text":"","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#the-problem","level":2,"title":"The Problem","text":"

      Your agent runs autonomously (loops, implements, releases) while you are away from the terminal. You have no way to know when it finishes, hits a limit, or when a hook fires a nudge.

      How do you get notified about agent activity without watching the terminal?

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tldr","level":2,"title":"TL;DR","text":"
      ctx hook notify setup  # configure webhook URL (encrypted)\nctx hook notify test   # verify delivery\n# Hooks auto-notify on: session-end, loop-iteration, resource-danger\n
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose ctx hook notify setup CLI command Configure and encrypt webhook URL ctx hook notify test CLI command Send a test notification ctx hook notify --event <name> \"msg\" CLI command Send a notification from scripts/skills .ctxrc notify.events Configuration Filter which events reach your webhook","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-1-get-a-webhook-url","level":3,"title":"Step 1: Get a Webhook URL","text":"

      Any service that accepts HTTP POST with JSON works. Common options:

      Service How to get a URL IFTTT Create an applet with the \"Webhooks\" trigger Slack Create an Incoming Webhook Discord Channel Settings > Integrations > Webhooks ntfy.sh Use https://ntfy.sh/your-topic (no signup) Pushover Use API endpoint with your user key

      The URL contains auth tokens. ctx encrypts it; it never appears in plaintext in your repo.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-2-configure-the-webhook","level":3,"title":"Step 2: Configure the Webhook","text":"
      ctx hook notify setup\n# Enter webhook URL: https://maker.ifttt.com/trigger/ctx/json/with/key/YOUR_KEY\n# Webhook configured: https://maker.ifttt.com/***\n# Encrypted at: .context/.notify.enc\n

      This encrypts the URL with AES-256-GCM using the same key as the scratchpad (~/.ctx/.ctx.key). The encrypted file (.context/.notify.enc) is safe to commit. The key lives outside the project and is never committed.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-3-test-it","level":3,"title":"Step 3: Test It","text":"
      ctx hook notify test\n# Webhook responded: HTTP 200 OK\n

      If you see No webhook configured, run ctx hook notify setup first.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-4-configure-events","level":3,"title":"Step 4: Configure Events","text":"

      Notifications are opt-in: no events are sent unless you configure an event list in .ctxrc:

      # .ctxrc\nnotify:\n  events:\n    - loop       # loop completion or max-iteration hit\n    - nudge      # VERBATIM relay hooks (context checkpoint, persistence, etc.)\n    - relay      # all hook output (verbose, for debugging)\n    - heartbeat  # every-prompt session-alive signal with metadata\n

      Only listed events fire. Omitting an event silently drops it.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-5-use-in-your-own-skills","level":3,"title":"Step 5: Use in Your Own Skills","text":"

      Add ctx hook notify calls to any skill or script:

      # In a release skill\nctx hook notify --event release \"v1.2.0 released successfully\" 2>/dev/null || true\n\n# In a backup script\nctx hook notify --event backup \"Nightly backup completed\" 2>/dev/null || true\n

      The 2>/dev/null || true suffix ensures the notification never breaks your script: If there's no webhook or the HTTP call fails, it's a silent noop.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#event-types","level":2,"title":"Event Types","text":"

      ctx fires these events automatically:

      Event Source When loop Loop script Loop completes or hits max iterations nudge System hooks VERBATIM relay nudge is emitted (context checkpoint, persistence, ceremonies, journal, resources, knowledge, version) relay System hooks Any hook output (VERBATIM relays, agent directives, block responses) heartbeat System hook Every prompt: session-alive signal with prompt count and context modification status test ctx hook notify test Manual test notification (custom) Your skills You wire ctx hook notify --event <name> in your own scripts

      nudge vs relay: The nudge event fires only for VERBATIM relay hooks (the ones the agent is instructed to show verbatim). The relay event fires for all hook output: VERBATIM relays, agent directives, and hard gates. Subscribe to relay for debugging (\"did the agent get the post-commit nudge?\"), nudge for user-facing assurance (\"was the checkpoint emitted?\").

      Webhooks as a Hook Audit Trail

      Subscribe to relay events and you get an external record of every hook that fires, independent of the agent.

      This lets you verify hooks are running and catch cases where the agent absorbs a nudge instead of surfacing it.

      See Auditing System Hooks for the full workflow.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#payload-format","level":2,"title":"Payload Format","text":"

      Every notification sends a JSON POST:

      {\n  \"event\": \"nudge\",\n  \"message\": \"check-context-size: Context window at 82%\",\n  \"detail\": {\n    \"hook\": \"check-context-size\",\n    \"variant\": \"window\",\n    \"variables\": {\"Percentage\": 82, \"TokenCount\": \"164k\"}\n  },\n  \"session_id\": \"abc123-...\",\n  \"timestamp\": \"2026-02-22T14:30:00Z\",\n  \"project\": \"ctx\"\n}\n

      The detail field is a structured template reference containing the hook name, variant, and any template variables. This lets receivers filter by hook or variant without parsing rendered text. The field is omitted when no template reference applies (e.g. custom ctx hook notify calls).

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#heartbeat-payload","level":3,"title":"Heartbeat Payload","text":"

      The heartbeat event fires on every prompt with session metadata and token usage telemetry:

      {\n  \"event\": \"heartbeat\",\n  \"message\": \"heartbeat: prompt #7 (context_modified=false tokens=158k pct=79%)\",\n  \"detail\": {\n    \"hook\": \"heartbeat\",\n    \"variant\": \"pulse\",\n    \"variables\": {\n      \"prompt_count\": 7,\n      \"session_id\": \"abc123-...\",\n      \"context_modified\": false,\n      \"tokens\": 158000,\n      \"context_window\": 200000,\n      \"usage_pct\": 79\n    }\n  },\n  \"session_id\": \"abc123-...\",\n  \"timestamp\": \"2026-02-28T10:15:00Z\",\n  \"project\": \"ctx\"\n}\n

      The tokens, context_window, and usage_pct fields are included when token data is available from the session JSONL file. They are omitted when no usage data has been recorded yet (e.g. first prompt).

      Unlike other events, heartbeat fires every prompt (not throttled). Use it for observability dashboards or liveness monitoring of long-running sessions.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#security-model","level":2,"title":"Security Model","text":"Component Location Committed? Permissions Encryption key ~/.ctx/.ctx.key No (user-level) 0600 Encrypted URL .context/.notify.enc Yes (safe) 0600 Webhook URL Never on disk in plaintext N/A N/A

      The key is shared with the scratchpad. If you rotate the encryption key, re-run ctx hook notify setup to re-encrypt the webhook URL with the new key.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#key-rotation","level":2,"title":"Key Rotation","text":"

      ctx checks the age of the encryption key once per day. If it's older than 90 days (configurable via key_rotation_days), a VERBATIM nudge is emitted suggesting rotation.

      # .ctxrc\nkey_rotation_days: 30   # nudge sooner (default: 90)\n
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#worktrees","level":2,"title":"Worktrees","text":"

      The webhook URL is encrypted with the same encryption key (~/.ctx/.ctx.key). Because the key lives at the user level, it is shared across all worktrees on the same machine - notifications work in worktrees automatically.

      This means agents running in worktrees cannot send webhook alerts. For autonomous runs where worktree agents are opaque, monitor them from the terminal rather than relying on webhooks. Enrich journals and review results on the main branch after merging.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#event-log-the-local-complement","level":2,"title":"Event Log: The Local Complement","text":"

      Don't need a webhook but want diagnostic visibility? Enable event_log: true in .ctxrc. The event log writes the same payload as webhooks to a local JSONL file (.context/state/events.jsonl) that you can query without any external service:

      ctx hook event --last 20          # recent hook activity\nctx hook event --hook qa-reminder # filter by hook\n

      Webhooks and event logging are independent: you can use either, both, or neither. Webhooks give you push notifications and an external audit trail. The event log gives you local queryability and ctx doctor integration.

      See Troubleshooting for how they work together.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tips","level":2,"title":"Tips","text":"
      • Fire-and-forget: Notifications never block. HTTP errors are silently ignored. No retry, no response parsing.
      • No webhook = no cost: When no webhook is configured, ctx hook notify exits immediately. System hooks that call notify.Send() add zero overhead.
      • Multiple projects: Each project has its own .notify.enc. You can point different projects at different webhooks.
      • Event filter is per-project: Configure notify.events in each project's .ctxrc independently.
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#next-up","level":2,"title":"Next Up","text":"

      Auditing System Hooks →: Verify your hooks are running, audit what they do, and get alerted when they go silent.

      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#see-also","level":2,"title":"See Also","text":"
      • CLI Reference: ctx hook notify: full command reference
      • Configuration: .ctxrc settings including notify options
      • Running an Unattended AI Agent: how loops work and how notifications fit in
      • Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates
      • Auditing System Hooks: using webhooks as an external audit trail for hook execution
      ","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/","level":1,"title":"When to Use a Team of Agents","text":"","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-problem","level":2,"title":"The Problem","text":"

      You have a task, and you are wondering: \"should I throw more agents at it?\"

      More agents can mean faster results, but they also mean coordination overhead, merge conflicts, divergent mental models, and wasted tokens re-reading context.

      The wrong setup costs more than it saves.

      This recipe is a decision framework: It helps you choose between a single agent, parallel worktrees, and a full agent team, and explains what ctx provides at each level.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#tldr","level":2,"title":"TL;DR","text":"
      • Single agent for most work;
      • Parallel worktrees when tasks touch disjoint file sets;
      • Agent teams only when tasks need real-time coordination. When in doubt, start with one agent.
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-spectrum","level":2,"title":"The Spectrum","text":"

      There are three modes, ordered by complexity:

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#1-single-agent-default","level":3,"title":"1. Single Agent (Default)","text":"

      One agent, one session, one branch. This is correct for most work.

      Use this when:

      • The task has linear dependencies (step 2 needs step 1's output);
      • Changes touch overlapping files;
      • You need tight feedback loops (review each change before the next);
      • The task requires deep understanding of a single area;
      • Total effort is less than a few hours of agent time.

      ctx provides: Full .context/: tasks, decisions, learnings, conventions, all in one session.

      The agent builds a coherent mental model and persists it as it goes.

      Example tasks: Bug fixes, feature implementation, refactoring a module, writing documentation for one area, debugging.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#2-parallel-worktrees-independent-tracks","level":3,"title":"2. Parallel Worktrees (Independent Tracks)","text":"

      2-4 agents, each in a separate git worktree on its own branch, working on non-overlapping parts of the codebase.

      Use this when:

      • You have 5+ independent tasks in the backlog;
      • Tasks group cleanly by directory or package;
      • File overlap between groups is zero or near-zero;
      • Each track can be completed and merged independently;
      • You want parallelism without coordination complexity.

      ctx provides: Shared .context/ via git (each worktree sees the same tasks, decisions, conventions). /ctx-worktree skill for setup and teardown. TASKS.md as a lightweight work queue.

      Example tasks: Docs + new package + test coverage (three tracks that don't touch the same files). Parallel recipe writing. Independent module development.

      See: Parallel Agent Development with Git Worktrees

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#3-agent-team-coordinated-swarm","level":3,"title":"3. Agent Team (Coordinated Swarm)","text":"

      Multiple agents communicating via messages, sharing a task list, with a lead agent coordinating. Claude Code's team/swarm feature.

      Use this when:

      • Tasks have dependencies but can still partially overlap;
      • You need research and implementation happening simultaneously;
      • The work requires different roles (researcher, implementer, tester);
      • A lead agent needs to review and integrate others' work;
      • The task is large enough that coordination cost is justified.

      ctx provides: .context/ as shared state that all agents can read. Task tracking for work assignment. Decisions and learnings as team memory that survives individual agent turnover.

      Example tasks: Large refactor across modules where a lead reviews merges. Research and implementation where one agent explores options while another builds. Multi-file feature that needs integration testing after parallel implementation.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-decision-framework","level":2,"title":"The Decision Framework","text":"

      Ask these questions in order:

      Can one agent do this in a reasonable time?\n  YES → Single agent. Stop here.\n  NO  ↓\n\nCan the work be split into non-overlapping file sets?\n  YES → Parallel worktrees (2-4 tracks)\n  NO  ↓\n\nDo the subtasks need to communicate during execution?\n  YES → Agent team with lead coordination\n  NO  → Parallel worktrees with a merge step\n
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#the-file-overlap-test","level":3,"title":"The File Overlap Test","text":"

      This is the critical decision point. Before choosing multi-agent, list the files each subtask would touch. If two subtasks modify the same file, they belong in the same track (or the same single-agent session).

      You: \"I want to parallelize these tasks. Which files would each one touch?\"\n\nAgent: [reads `TASKS.md`, analyzes codebase]\n       \"Task A touches internal/config/ and internal/cli/initialize/\n        Task B touches docs/ and site/\n        Task C touches internal/config/ and internal/cli/status/\n\n        Tasks A and C overlap on internal/config/ # they should be\n        in the same track. Task B is independent.\"\n

      When in doubt, keep things in one track. A merge conflict in a critical file costs more time than the parallelism saves.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#when-teams-make-things-worse","level":2,"title":"When Teams Make Things Worse","text":"

      \"More agents\" is not always better. Watch for these patterns:

      Merge hell: If you are spending more time resolving conflicts than the parallel work saved, you split wrong: Re-group by file overlap.

      Context divergence: Each agent builds its own mental model. After 30 minutes of independent work, agent A might make assumptions that contradict agent B's approach. Shorter tracks with frequent merges reduce this.

      Coordination theater: A lead agent spending most of its time assigning tasks, checking status, and sending messages instead of doing work. If the task list is clear enough, worktrees with no communication are cheaper.

      Re-reading overhead: Every agent reads .context/ on startup. A team of 4 agents each reading 4000 tokens of context = 16000 tokens before anyone does any work. For small tasks, that overhead dominates.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#what-ctx-gives-you-at-each-level","level":2,"title":"What ctx Gives You at Each Level","text":"ctx Feature Single Agent Worktrees Team .context/ files Full access Shared via git Shared via filesystem TASKS.md Work queue Split by track Assigned by lead Decisions/Learnings Persisted in session Persisted per branch Persisted by any agent /ctx-next Picks next task Picks within track Lead assigns /ctx-worktree N/A Setup + teardown Optional /ctx-commit Normal commits Per-branch commits Per-agent commits","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#team-composition-recipes","level":2,"title":"Team Composition Recipes","text":"

      Four practical team compositions for common workflows.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#feature-development-3-agents","level":3,"title":"Feature Development (3 Agents)","text":"Role Responsibility Architect Writes spec in specs/, breaks work into TASKS.md phases Implementer Picks tasks from TASKS.md, writes code, marks [x] done Reviewer Runs tests, ctx drift, lint; files issues as new tasks

      Coordination: TASKS.md checkboxes. Architect writes tasks before implementer starts. Reviewer runs after each implementer commit.

      Anti-pattern: All three agents editing the same file simultaneously. Sequence the work so only one agent touches a file at a time.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#consolidation-sprint-3-4-agents","level":3,"title":"Consolidation Sprint (3-4 Agents)","text":"Role Responsibility Auditor Runs ctx drift, identifies stale paths and broken refs Code Fixer Updates source code to match context (or vice versa) Doc Writer Updates ARCHITECTURE.md, CONVENTIONS.md, and docs/ Test Fixer (Optional) Fixes tests broken by the fixer's changes

      Coordination: Auditor's ctx drift output is the shared work queue. Each agent claims a subset of issues by adding #in-progress labels.

      Anti-pattern: Fixer and doc writer both editing ARCHITECTURE.md. Assign file ownership explicitly.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#release-prep-2-agents","level":3,"title":"Release Prep (2 Agents)","text":"Role Responsibility Release Notes Generates changelog from commits, writes release notes Validation Runs full test suite, lint, build across platforms

      Coordination: Both read TASKS.md to identify what shipped. Release notes agent works from git log; validation agent works from make audit.

      Anti-pattern: Release notes agent running tests \"to verify.\" Each agent stays in its lane.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#documentation-sprint-3-agents","level":3,"title":"Documentation Sprint (3 Agents)","text":"Role Responsibility Content Writes new pages, expands existing docs Cross-linker Adds nav entries, cross-references, \"See Also\" sections Verifier Builds site, checks broken links, validates rendering

      Coordination: Content agent writes files first. Cross-linker updates zensical.toml and index pages after content lands. Verifier builds after each batch.

      Antipattern: Content and cross-linker both editing zensical.toml. Batch nav updates into the cross-linker's pass.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#tips","level":2,"title":"Tips","text":"
      • Start with one agent: Only add parallelism when you have identified the bottleneck. \"This would go faster with more agents\" is usually wrong for tasks under 2 hours.
      • The 3-4 agent ceiling is real: Coordination overhead grows quadratically. 2 agents = 1 communication pair. 4 agents = 6 pairs. Beyond 4, you are managing agents more than doing work.
      • Worktrees > teams for most parallelism needs: If agents don't need to talk to each other during execution, worktrees give you parallelism with zero coordination overhead.
      • Use ctx as the shared brain: Whether it's one agent or four, the .context/ directory is the single source of truth. Decisions go in DECISIONS.md, not in chat messages between agents.
      • Merge early, merge often: Long-lived parallel branches diverge. Merge a track as soon as it's done rather than waiting for all tracks to finish.
      • TASKS.md conflicts are normal: Multiple agents completing different tasks will conflict on merge. The resolution is always additive: accept all [x] completions from both sides.
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#next-up","level":2,"title":"Next Up","text":"

      Parallel Agent Development with Git Worktrees →: Run multiple agents on independent task tracks using git worktrees.

      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#go-deeper","level":2,"title":"Go Deeper","text":"
      • CLI Reference: all commands and flags
      • Integrations: setup for Claude Code, Cursor, Aider
      • Session Journal: browse and search session history
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"recipes/when-to-use-agent-teams/#see-also","level":2,"title":"See Also","text":"
      • Parallel Agent Development with Git Worktrees: the mechanical \"how\" for worktree-based parallelism
      • Running an Unattended AI Agent: serial autonomous loops: a different scaling strategy
      • Tracking Work Across Sessions: managing the task backlog that feeds into any multi-agent setup
      ","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"reference/","level":1,"title":"Reference","text":"

      Technical reference for ctx commands, skills, and internals.

      ","path":["Reference"],"tags":[]},{"location":"reference/#the-system-explains-itself","level":3,"title":"The System Explains Itself","text":"

      The 12 properties that must hold for any valid ctx implementation. Not features: constraints. The system's contract with its users and contributors.

      ","path":["Reference"],"tags":[]},{"location":"reference/#code-conventions","level":3,"title":"Code Conventions","text":"

      Common patterns and fixes for the AST compliance tests in internal/audit/. When a test fails, find the matching section.

      ","path":["Reference"],"tags":[]},{"location":"reference/#cli","level":3,"title":"CLI","text":"

      Every command, subcommand, and flag. Now a top-level section: see CLI Reference.

      ","path":["Reference"],"tags":[]},{"location":"reference/#skills","level":3,"title":"Skills","text":"

      The full skill catalog: what each skill does, when it triggers, and how skills interact with commands.

      ","path":["Reference"],"tags":[]},{"location":"reference/#tool-ecosystem","level":3,"title":"Tool Ecosystem","text":"

      How ctx compares to Cursor Rules, Aider conventions, CLAUDE.md, and other context approaches.

      ","path":["Reference"],"tags":[]},{"location":"reference/#session-journal","level":3,"title":"Session Journal","text":"

      Export, browse, and enrich your session history. Covers the journal site, Obsidian export, and the enrichment pipeline.

      ","path":["Reference"],"tags":[]},{"location":"reference/#scratchpad","level":3,"title":"Scratchpad","text":"

      Encrypted, git-tracked scratch space for short notes and sensitive values that travel with the project.

      ","path":["Reference"],"tags":[]},{"location":"reference/#version-history","level":3,"title":"Version History","text":"

      Changelog for every ctx release.

      ","path":["Reference"],"tags":[]},{"location":"reference/audit-conventions/","level":1,"title":"Code Conventions","text":"","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#code-conventions-common-patterns-and-fixes","level":1,"title":"Code Conventions: Common Patterns and Fixes","text":"

      This guide documents the code conventions enforced by internal/audit/ AST tests. Each section shows the violation pattern, the fix, and the rationale. When a test fails, find the matching section below.

      All tests skip _test.go files. The patterns apply only to production code under internal/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#variable-shadowing-bare-err-reuse","level":2,"title":"Variable Shadowing (Bare err := Reuse)","text":"

      Test: TestNoVariableShadowing

      When a function has multiple := assignments to err, each shadows the previous one. This makes it impossible to tell which error a later if err != nil is checking.

      Before:

      func Run(cmd *cobra.Command) error {\n    data, err := os.ReadFile(path) \n    if err != nil {\n        return err\n    }\n\n    result, err := json.Unmarshal(data)  // shadows first err\n    if err != nil {\n        return err\n    }\n\n    err = validate(result)  // shadows again\n    return err\n}\n

      After:

      func Run(cmd *cobra.Command) error {\n    data, readErr := os.ReadFile(path)\n    if readErr != nil {\n        return readErr\n    }\n\n    result, parseErr := json.Unmarshal(data)\n    if parseErr != nil {\n        return parseErr\n    }\n\n    validateErr := validate(result)\n    return validateErr\n}\n

      Rule: Use descriptive error names (readErr, writeErr, parseErr, walkErr, absErr, relErr) so each error site is independently identifiable.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#import-name-shadowing","level":2,"title":"Import Name Shadowing","text":"

      Test: TestNoImportNameShadowing

      When a local variable has the same name as an imported package, the import becomes inaccessible in that scope.

      Before:

      import \"github.com/ActiveMemory/ctx/internal/session\"\n\nfunc process(session *entity.Session) {  // param shadows import\n    // session package is now unreachable here\n}\n

      After:

      import \"github.com/ActiveMemory/ctx/internal/session\"\n\nfunc process(sess *entity.Session) {\n    // session package still accessible\n}\n

      Rule: Parameters, variables, and return values must not reuse imported package names. Common renames: session -> sess, token -> tok, config -> cfg, entry -> ent.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-strings","level":2,"title":"Magic Strings","text":"

      Test: TestNoMagicStrings

      String literals in function bodies are invisible to refactoring tools and cause silent breakage when the value changes in one place but not another.

      Before (string literals):

      func loadContext() {\n    data := filepath.Join(dir, \"TASKS.md\")\n    if strings.HasSuffix(name, \".yaml\") {\n        // ...\n    }\n}\n

      After:

      func loadContext() {\n    data := filepath.Join(dir, config.FilenameTask)\n    if strings.HasSuffix(name, config.ExtYAML) {\n        // ...\n    }\n}\n

      Before (format verbs, also caught):

      func EntryHash(text string) string {\n    h := sha256.Sum256([]byte(text))\n    return fmt.Sprintf(\"%x\", h[:8])\n}\n

      After:

      func EntryHash(text string) string {\n    h := sha256.Sum256([]byte(text))\n    return hex.EncodeToString(h[:cfgFmt.HashPrefixLen])\n}\n

      Before (URL schemes, also caught):

      if strings.HasPrefix(target, \"https://\") ||\n    strings.HasPrefix(target, \"http://\") {\n    return target\n}\n

      After:

      if strings.HasPrefix(target, cfgHTTP.PrefixHTTPS) ||\n    strings.HasPrefix(target, cfgHTTP.PrefixHTTP) {\n    return target\n}\n

      Exempt from this check:

      • Empty string \"\", single space \" \", indentation strings
      • Regex capture references ($1, ${name})
      • const and var definition sites (that's where constants live)
      • Struct tags
      • Import paths
      • Packages under internal/config/, internal/assets/tpl/

      Rule: If a string is used for comparison, path construction, or appears in 3+ files, it belongs in internal/config/ as a constant. Format strings belong in internal/config/ as named constants (e.g., cfgGit.FlagLastN, cfgTrace.RefFormat). User-facing prose belongs in internal/assets/ YAML files accessed via desc.Text().

      Common fix for fmt.Sprintf with format verbs:

      Pattern Fix fmt.Sprintf(\"%d\", n) strconv.Itoa(n) fmt.Sprintf(\"%d\", int64Val) strconv.FormatInt(int64Val, 10) fmt.Sprintf(\"%x\", bytes) hex.EncodeToString(bytes) fmt.Sprintf(\"%q\", s) strconv.Quote(s) fmt.Sscanf(s, \"%d\", &n) strconv.Atoi(s) fmt.Sprintf(\"-%d\", n) fmt.Sprintf(cfgGit.FlagLastN, n) \"https://\" cfgHTTP.PrefixHTTPS \"&lt;\" config constant in config/html/","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-printf-calls","level":2,"title":"Direct Printf Calls","text":"

      Test: TestNoPrintfCalls

      cmd.Printf and cmd.PrintErrf bypass the write-package formatting pipeline and scatter user-facing text across the codebase.

      Before:

      func Run(cmd *cobra.Command, args []string) {\n    cmd.Printf(\"Found %d tasks\\n\", count)\n}\n

      After:

      func Run(cmd *cobra.Command, args []string) {\n    write.TaskCount(cmd, count)\n}\n

      Rule: All formatted output goes through internal/write/ which uses cmd.Print/cmd.Println with pre-formatted strings from desc.Text().

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#raw-time-format-strings","level":2,"title":"Raw Time Format Strings","text":"

      Test: TestNoRawTimeFormats

      Inline time format strings (\"2006-01-02\", \"15:04:05\") drift when one call site is updated but others are missed.

      Before:

      func formatDate(t time.Time) string {\n    return t.Format(\"2006-01-02\")\n}\n

      After:

      func formatDate(t time.Time) string {\n    return t.Format(cfgTime.DateFormat)\n}\n

      Rule: All time format strings must use constants from internal/config/time/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-flag-registration","level":2,"title":"Direct Flag Registration","text":"

      Test: TestNoFlagBindOutsideFlagbind

      Direct cobra flag calls (.Flags().StringVar(), etc.) scatter flag wiring across dozens of cmd.go files. Centralizing through internal/flagbind/ gives one place to audit flag names, defaults, and description key lookups.

      Before:

      func Cmd() *cobra.Command {\n    var output string\n    c := &cobra.Command{Use: cmd.UseStatus}\n    c.Flags().StringVarP(&output, \"output\", \"o\", \"\",\n        \"output format\")\n    return c\n}\n

      After:

      func Cmd() *cobra.Command {\n    var output string\n    c := &cobra.Command{Use: cmd.UseStatus}\n    flagbind.StringFlagShort(c, &output, flag.Output,\n        flag.OutputShort, cmd.DescKeyOutput)\n    return c\n}\n

      Rule: All flag registration goes through internal/flagbind/. If the helper you need doesn't exist, add it to flagbind/flag.go before using it.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#todo-comments","level":2,"title":"TODO Comments","text":"

      Test: TestNoTODOComments

      TODO, FIXME, HACK, and XXX comments in production code are invisible to project tracking. They accumulate silently and never get addressed.

      Before:

      // TODO: handle pagination\nfunc listEntries() []Entry {\n

      After:

      Remove the comment and add a task to .context/TASKS.md:

      - [ ] Handle pagination in listEntries (internal/task/task.go)\n

      Rule: Deferred work lives in TASKS.md, not in source comments.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#dead-exports","level":2,"title":"Dead Exports","text":"

      Test: TestNoDeadExports

      Exported symbols with zero references outside their definition file are dead weight. They increase API surface, confuse contributors, and cost maintenance.

      Fix: Either delete the export (preferred) or demote it to unexported if it's still used within the file.

      If the symbol existed for historical reasons and might be needed again, move it to quarantine/deadcode/ with a .dead extension. This preserves the code in git without polluting the live codebase:

      quarantine/deadcode/internal/config/flag/flag.go.dead\n

      Each .dead file includes a header:

      // Dead exports quarantined from internal/config/flag/flag.go\n// Quarantined: 2026-04-02\n// Restore from git history if needed.\n

      Rule: If a test-only allowlist entry is needed (the export exists only for test use), add the fully qualified symbol to testOnlyExports in dead_exports_test.go. Keep this list small; prefer eliminating the export.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#core-package-structure","level":2,"title":"Core Package Structure","text":"

      Test: TestCoreStructure

      core/ directories under internal/cli/ must contain only doc.go and test files at the top level. All domain logic lives in subpackages. This prevents core/ from becoming a god package.

      Before:

      internal/cli/dep/core/\n    go.go           # violation: logic at core/ level\n    python.go       # violation\n    node.go         # violation\n    types.go        # violation\n

      After:

      internal/cli/dep/core/\n    doc.go          # package doc only\n    golang/\n        golang.go\n        golang_test.go\n        doc.go\n    python/\n        python.go\n        python_test.go\n        doc.go\n    node/\n        node.go\n        node_test.go\n        doc.go\n

      Rule: Extract each logical unit into its own subpackage under core/. Each subpackage gets a doc.go. The subpackage name should match the domain concept (golang, check, fix, store), not a generic label (util, helper).

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cross-package-types","level":2,"title":"Cross-Package Types","text":"

      Test: TestCrossPackageTypes

      When a type defined in one package is used from a different module (e.g., cli/doctor importing a type from cli/notify), the type has crossed its module boundary. Cross-cutting types belong in internal/entity/ for discoverability.

      Before:

      // internal/cli/notify/core/types.go\ntype NotifyPayload struct { ... }\n\n// internal/cli/doctor/core/check/check.go\nimport \"github.com/ActiveMemory/ctx/internal/cli/notify/core\"\nfunc check(p core.NotifyPayload) { ... }\n

      After:

      // internal/entity/notify.go\ntype NotifyPayload struct { ... }\n\n// internal/cli/doctor/core/check/check.go\nimport \"github.com/ActiveMemory/ctx/internal/entity\"\nfunc check(p entity.NotifyPayload) { ... }\n

      Exempt: Types inside entity/, proto/, core/ subpackages, and config/ packages. Same-module usage (e.g., cli/doctor/cmd/ using cli/doctor/core/) is not flagged.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#type-file-convention","level":2,"title":"Type File Convention","text":"

      Test: TestTypeFileConvention, TestTypeFileConventionReport

      Exported types in core/ subpackages should live in types.go (the convention from CONVENTIONS.md), not scattered across implementation files. This makes type definitions discoverable. TestTypeFileConventionReport generates a diagnostic summary of all type placements for triage.

      Exception: entity/ organizes by domain (task.go, session.go), proto/ uses schema.go, and err/ packages colocate error types with their domain context.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-yaml-linkage","level":2,"title":"DescKey / YAML Linkage","text":"

      Test: TestDescKeyYAMLLinkage

      Every DescKey constant must have a corresponding key in the YAML asset files, and every YAML key must have a corresponding DescKey constant. Orphans in either direction mean dead text or runtime panics.

      Fix for orphan YAML key: Delete the YAML entry, or add the corresponding DescKey constant in config/embed/{text,cmd,flag}/.

      Fix for orphan DescKey: Delete the constant, or add the corresponding entry in the YAML file under internal/assets/commands/text/, cmd/, or flag/.

      If the orphan YAML entry was once valid but the feature was removed, move the YAML entry to a .dead file in quarantine/deadcode/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#package-doc-quality","level":2,"title":"Package Doc Quality","text":"

      Test: TestPackageDocQuality

      Every package under internal/ must have a doc.go with a meaningful package doc comment (at least 8 lines of real content). One-liners and file-list patterns (// - foo.go, // Source files:) are flagged because they drift as files change.

      Template:

      //   /    ctx:                         https://ctx.ist\n// ,'`./    do you remember?\n// `.,'\\\n//   \\    Copyright 2026-present Context contributors.\n//                 SPDX-License-Identifier: Apache-2.0\n\n// Package mypackage does X.\n//\n// It handles Y by doing Z. The main entry point is [FunctionName]\n// which accepts A and returns B.\n//\n// Configuration is read from [config.SomeConstant]. Output is\n// written through [write.SomeHelper].\n//\n// This package is used by [parentpackage] during the W lifecycle\n// phase.\npackage mypackage\n
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-regex-compilation","level":2,"title":"Inline Regex Compilation","text":"

      Test: TestNoInlineRegexpCompile

      regexp.MustCompile and regexp.Compile inside function bodies recompile the pattern on every call. Compiled patterns belong at package level.

      Before:

      func parse(s string) bool {\n    re := regexp.MustCompile(`\\d{4}-\\d{2}-\\d{2}`)\n    return re.MatchString(s)\n}\n

      After:

      // In internal/config/regex/regex.go:\n// DatePattern matches ISO date format (YYYY-MM-DD).\nvar DatePattern = regexp.MustCompile(`\\d{4}-\\d{2}-\\d{2}`)\n\n// In calling package:\nfunc parse(s string) bool {\n    return regex.DatePattern.MatchString(s)\n}\n

      Rule: All compiled regexes live in internal/config/regex/ as package-level var declarations. Two tests enforce this: TestNoInlineRegexpCompile catches function-body compilation, and TestNoRegexpOutsideRegexPkg catches package-level compilation outside config/regex/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#doc-comments","level":2,"title":"Doc Comments","text":"

      Test: TestDocComments

      All functions (exported and unexported), structs, and package-level variables must have a doc comment. Config packages allow group doc comments for const blocks.

      Before:

      func buildIndex(entries []Entry) map[string]int {\n

      After:

      // buildIndex maps entry names to their position in the\n// ordered slice for O(1) lookup during reconciliation.\n//\n// Parameters:\n//   - entries: ordered slice of entries to index\n//\n// Returns:\n//   - map[string]int: name-to-position mapping\nfunc buildIndex(entries []Entry) map[string]int {\n

      Rule: Every function, struct, and package-level var gets a doc comment in godoc format. Functions include Parameters: and Returns: sections. Structs with 2+ fields document every field. See CONVENTIONS.md for the full template.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#line-length","level":2,"title":"Line Length","text":"

      Test: TestLineLength

      Lines in non-test Go files must not exceed 80 characters. This is a hard check, not a suggestion.

      Before:

      _ = trace.Record(fmt.Sprintf(cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum), state.Dir())\n

      After:

      ref := fmt.Sprintf(\n    cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum,\n)\n_ = trace.Record(ref, state.Dir())\n

      Rule: Break at natural points: function arguments, struct fields, chained calls. Long strings (URLs, struct tags) are the rare acceptable exception.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#literal-whitespace","level":2,"title":"Literal Whitespace","text":"

      Test: TestNoLiteralWhitespace

      Bare whitespace string and byte literals (\"\\n\", \"\\r\\n\", \"\\t\") must not appear outside internal/config/token/. All other packages use the token constants.

      Before:

      output := strings.Join(lines, \"\\n\")\n

      After:

      output := strings.Join(lines, token.Newline)\n

      Rule: Whitespace literals are defined once in internal/config/token/. Use token.Newline, token.Tab, token.CRLF, etc.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-numeric-values","level":2,"title":"Magic Numeric Values","text":"

      Test: TestNoMagicValues

      Numeric literals in function bodies need constants, with narrow exceptions.

      Before:

      if len(entries) > 100 {\n    entries = entries[:100]\n}\n

      After:

      if len(entries) > config.MaxEntries {\n    entries = entries[:config.MaxEntries]\n}\n

      Exempt: 0, 1, -1, 2-10, strconv radix/bitsize args (10, 32, 64 in strconv.Parse*/Format*), octal permissions (caught separately by TestNoRawPermissions), and const/var definition sites.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-separators","level":2,"title":"Inline Separators","text":"

      Test: TestNoInlineSeparators

      strings.Join calls must use token constants for their separator argument, not string literals.

      Before:

      result := strings.Join(parts, \", \")\n

      After:

      result := strings.Join(parts, token.CommaSep)\n

      Rule: Separator strings live in internal/config/token/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stuttery-function-names","level":2,"title":"Stuttery Function Names","text":"

      Test: TestNoStutteryFunctions

      Function names must not redundantly include their package name as a PascalCase word boundary. Go callers already write pkg.Function, so pkg.PkgFunction stutters.

      Before:

      // In package write\nfunc WriteJournal(cmd *cobra.Command, ...) {\n

      After:

      // In package write\nfunc Journal(cmd *cobra.Command, ...) {\n

      Exempt: Identity functions like write.Write / write.write.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#predicate-naming-no-ishascan-prefix","level":2,"title":"Predicate Naming (No Is/Has/Can Prefix)","text":"

      Test: None (manual review convention)

      Exported methods that return bool must not use Is, Has, or Can prefixes. The predicate reads more naturally without them, especially at call sites where the package name provides context.

      Before:

      func IsCompleted(t *Task) bool { ... }\nfunc HasChildren(n *Node) bool { ... }\nfunc IsExemptPackage(path string) bool { ... }\n

      After:

      func Completed(t *Task) bool { ... }\nfunc Children(n *Node) bool { ... }  // or: ChildCount > 0\nfunc ExemptPackage(path string) bool { ... }\n

      Rule: Drop the prefix. Private helpers may use prefixes when it reads more naturally (isValid in a local context is fine). This convention applies to exported methods and package-level functions. See CONVENTIONS.md \"Predicates\" section.

      This is not yet enforced by an AST test; it requires semantic understanding of return types and naming intent that makes automated detection fragile. Apply during code review.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#mixed-visibility","level":2,"title":"Mixed Visibility","text":"

      Test: TestNoMixedVisibility

      Files with exported functions must not also contain unexported functions. Public API and private helpers live in separate files.

      Before:

      load.go\n    func Load() { ... }        // exported\n    func parseHeader() { ... } // unexported, violation\n

      After:

      load.go\n    func Load() { ... }        // exported only\nparse.go\n    func parseHeader() { ... } // private helper\n

      Exempt: Files with exactly one function, doc.go, test files.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stray-errgo-files","level":2,"title":"Stray Err.Go Files","text":"

      Test: TestNoStrayErrFiles

      err.go files must only exist under internal/err/. Error constructors anywhere else create a broken-window pattern where contributors add local error definitions when they see a local err.go.

      Fix: Move the error constructor to internal/err/<domain>/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cli-cmd-structure","level":2,"title":"CLI Cmd Structure","text":"

      Test: TestCLICmdStructure

      Each cmd/$sub/ directory under internal/cli/ may contain only cmd.go, run.go, doc.go, and test files. Extra .go files (helpers, output formatters, types) belong in the corresponding core/ subpackage.

      Before:

      internal/cli/doctor/cmd/root/\n    cmd.go\n    run.go\n    format.go   # violation: helper in cmd dir\n

      After:

      internal/cli/doctor/cmd/root/\n    cmd.go\n    run.go\ninternal/cli/doctor/core/format/\n    format.go\n    doc.go\n
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-namespace","level":2,"title":"DescKey Namespace","text":"

      Test: TestUseConstantsOnlyInCobraUse, TestDescKeyOnlyInLookupCalls, TestNoWrongNamespaceLookup

      Three tests enforce DescKey/Use constant discipline:

      1. Use* constants appear only in cobra Use: struct field assignments, never as arguments to desc.Text() or elsewhere.
      2. DescKey* constants are passed only to assets.CommandDesc(), assets.FlagDesc(), or desc.Text(), never to cobra Use:.
      3. No cross-namespace lookups: TextDescKey must not be passed to CommandDesc(), FlagDescKey must not be passed to Text(), etc.
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#yaml-examples-registry-linkage","level":2,"title":"YAML Examples / Registry Linkage","text":"

      Test: TestExamplesYAMLLinkage, TestRegistryYAMLLinkage

      Every key in examples.yaml and registry.yaml must match a known entry type constant. Prevents orphan entries that are never rendered.

      Fix: Delete the orphan YAML entry, or add the corresponding constant in config/entry/.

      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#other-enforced-patterns","level":2,"title":"Other Enforced Patterns","text":"

      These tests follow the same fix approach: extract the operation to its designated package:

      Test Violation Fix TestNoNakedErrors fmt.Errorf/errors.New outside internal/err/ Add error constructor to internal/err/<domain>/ TestNoRawFileIO Direct os.ReadFile, os.Create, etc. Use io.SafeReadFile, io.SafeWriteFile, etc. TestNoRawLogging Direct fmt.Fprintf(os.Stderr, ...) Use log/warn.Warn() or log/event.Append() TestNoExecOutsideExecPkg exec.Command outside internal/exec/ Add command to internal/exec/<domain>/ TestNoCmdPrintOutsideWrite cmd.Print* outside internal/write/ Add output helper to internal/write/<domain>/ TestNoRawPermissions Octal literals (0644, 0755) Use config/fs.PermFile, config/fs.PermExec, etc. TestNoErrorsAs errors.As() Use errors.AsType() (generic, Go 1.23+) TestNoStringConcatPaths dir + \"/\" + file Use filepath.Join(dir, file)","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#general-fix-workflow","level":2,"title":"General Fix Workflow","text":"

      When an audit test fails:

      1. Read the error message. It includes file:line and a description of the violation.
      2. Find the matching section above. The test name maps directly to a section.
      3. Apply the pattern. Most fixes are mechanical: extract to the right package, rename a variable, or replace a literal with a constant.
      4. Run make test before committing. Audit tests run as part of go test ./internal/audit/.
      5. Don't add allowlist entries as a first resort. Fix the code. Allowlists exist only for genuinely unfixable cases (test-only exports, config packages that are definitionally exempt).
      ","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/comparison/","level":1,"title":"Tool Ecosystem","text":"","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#high-level-mental-model","level":2,"title":"High-Level Mental Model","text":"

      Many tools help AI think.

      ctx helps AI remember.

      • Not by storing thoughts,
      • but by preserving intent.
      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#how-ctx-differs-from-similar-tools","level":2,"title":"How ctx Differs from Similar Tools","text":"

      There are many tools in the AI ecosystem that touch parts of the context problem:

      • Some manage prompts.
      • Some retrieve data.
      • Some provide runtime context objects.
      • Some offer enterprise platforms.

      ctx focuses on a different layer entirely.

      This page explains where ctx fits, and where it intentionally does not.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#the-core-distinction","level":2,"title":"The Core Distinction","text":"

      Most tools treat context as input.

      ctx treats context as infrastructure.

      That single difference explains nearly all of ctx's design choices.

      Question Most tools ctx Where does context live? In prompts or APIs In files How long does it last? One request / one session Across time Who can read it? The model Humans and tools How is it updated? Implicitly Explicitly Is it inspectable? Rarely Always","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#prompt-management-tools","level":2,"title":"Prompt Management Tools","text":"

      Examples include:

      • prompt templates;
      • reusable system prompts;
      • prompt libraries;
      • prompt versioning tools.

      These tools help you start a session.

      They do not help you continue one.

      Prompt tools:

      • inject text at session start;
      • are ephemeral by design;
      • do not evolve with the project.

      ctx:

      • persists knowledge over time;
      • accumulates decisions and learnings;
      • makes the context part of the repository itself.

      Prompt tooling and ctx are complementary; not competing. Yet, they operate in different layers.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#retrieval-augmented-generation-rag","level":2,"title":"Retrieval-Augmented Generation (RAG)","text":"

      RAG systems typically:

      • index documents
      • embed text
      • retrieve chunks dynamically at runtime

      They are excellent for:

      • large knowledge bases
      • static documentation
      • reference material

      RAG answers questions like:

      \"What information might be relevant right now?\"

      ctx answers a different question:

      \"What have we already decided, learned, or committed to?\"

      Here are some key differences:

      RAG ctx Statistical relevance Intentional relevance Embedding-based File-based Opaque retrieval Explicit structure Runtime query Persistent memory

      ctx does not replace RAG. Instead, it defines a persistent context layer that RAG can optionally augment.

      RAG belongs to the data plane; ctx defines the context control plane.

      It focuses on project memory, not knowledge search.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#agent-frameworks","level":2,"title":"Agent Frameworks","text":"

      Agent frameworks often provide:

      • task loops
      • tool orchestration
      • planner/executor patterns
      • autonomous iteration

      These systems are powerful, but they typically assume that:

      • memory is external
      • context is injected
      • state is transient

      Agent frameworks answer:

      \"How should the agent act?\"

      ctx answers:

      \"What should the agent remember?\"

      Without persistent context, agents tend to:

      • rediscover decisions
      • repeat mistakes
      • lose architectural intent

      This is why ctx pairs well with autonomous loop workflows:

      • The loop provides iteration
      • ctx provides continuity

      Together, loops become cumulative instead of forgetful.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#sdk-level-context-objects","level":2,"title":"SDK-Level Context Objects","text":"

      Some SDKs expose \"context\" objects that exist:

      • inside a process
      • during a request
      • for the lifetime of a call chain

      These are extremely useful and completely different.

      SDK context objects:

      • are in-memory
      • disappear when the process ends
      • are not shared across sessions

      ctx:

      • survives process restarts
      • survives new chats
      • survives new days

      They share a name, not a purpose.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#enterprise-context-platforms","level":2,"title":"Enterprise Context Platforms","text":"

      Enterprise platforms often provide:

      • centralized context services
      • dashboards
      • access control
      • organizational knowledge layers

      These tools are designed for:

      • teams
      • governance
      • compliance
      • managed environments

      ctx is intentionally:

      • local-first: context lives next to your code, not behind a service boundary.
      • file-based: everything important is a markdown file you can read, diff, grep, and version-control.
      • single-binary core: the context persistence path (init, add, agent, status, drift, load, sync, compact, task, decision, learning, and their siblings) is a single Go binary with no required runtime dependencies. Optional integrations (ctx trace (needs git), ctx serve (needs zensical), the ctx Hub (needs a running hub), Claude Code plugin (needs claude)) are opt-in and each declares its dependency explicitly.
      • CLI-driven: every feature is reachable from the command line and scriptable.
      • developer-controlled: no auto-updating cloud service, no telemetry, no account to sign up for.

      The core ctx binary does not require:

      • a server
      • a database
      • an account
      • a SaaS backend
      • network connectivity (for core operations)

      ctx optimizes for individual and small-team workflows where context should live next to code; not behind a service boundary.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#specific-tool-comparisons","level":2,"title":"Specific Tool Comparisons","text":"

      Users often evaluate ctx against specific tools they already use. These comparisons clarify where responsibilities overlap, where they diverge, and where the tools are genuinely complementary.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#claude-code-memory-anthropic-auto-memory","level":3,"title":"Claude Code Memory / Anthropic Auto-Memory","text":"

      Anthropic's auto-memory is tool-managed memory (L2): the model decides what to remember, stores it automatically, and retrieves it implicitly. ctx is system memory (L3): humans and agents explicitly curate decisions, learnings, and tasks in inspectable files.

      Auto-memory is convenient - you do not configure anything. But it is also opaque: you cannot see what was stored, edit it precisely, or share it across tools. ctx files are plain Markdown in your repository, visible in diffs and code review.

      The two are complementary. ctx can absorb auto-memory as an input source (importing what the model remembered into structured context files) while providing the durable, inspectable layer that auto-memory lacks.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cursorrules-clauderules","level":3,"title":".Cursorrules / .Claude/rules","text":"

      Static rule files (.cursorrules, .claude/rules/) declare conventions: coding style, forbidden patterns, preferred libraries. They are effective for what to do and load automatically at session start.

      ctx adds dimensions that rule files do not cover: architectural decisions with rationale, learnings discovered during development, active tasks, and a constitution that governs agent behavior. Critically, ctx context accumulates - each session can add to it, and token budgeting ensures only the most relevant context is injected.

      Use rule files for static conventions. Use ctx for evolving project memory.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#aider-read-watch","level":3,"title":"Aider --read / --watch","text":"

      Aider's --read flag injects file contents at session start; --watch reloads them on change. The concept is similar to ctx's \"load\" step: make the agent aware of specific files.

      The differences emerge beyond loading. Aider has no persistence model -- nothing the agent learns during a session is written back. There is no token budgeting (large files consume the full context window), no priority ordering across file types, and no structured format for decisions or learnings. ctx provides the full lifecycle: load, accumulate, persist, and budget.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#copilot-workspace","level":3,"title":"Copilot @Workspace","text":"

      GitHub Copilot's @workspace performs workspace-wide code search. It answers \"what code exists?\" - finding function definitions, usages, and file structure across the repository.

      ctx answers a different question: \"what did we decide?\" It stores architectural intent, not code indices. Copilot's workspace search and ctx's project memory are orthogonal; one finds code, the other preserves the reasoning behind it.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cline-memory","level":3,"title":"Cline Memory","text":"

      Cline's memory bank stores session context within the Cline extension. The motivation is similar to ctx: help the agent remember across sessions.

      The key difference is portability. Cline memory is tied to Cline - it does not transfer to Claude Code, Cursor, Aider, or any other tool. ctx is tool-agnostic: context lives in plain files that any editor, agent, or script can read. Switching tools does not mean losing memory.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-a-good-fit","level":2,"title":"When ctx Is a Good Fit","text":"

      ctx works best when:

      • you want AI work to compound over time;
      • architectural decisions matter;
      • context must be inspectable;
      • humans and AI must share the same source of truth;
      • Git history should include why, not just what.
      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-not-the-right-tool","level":2,"title":"When ctx Is Not the Right Tool","text":"

      ctx is probably not what you want if:

      • you only need one-off prompts;
      • you rely exclusively on RAG;
      • you want autonomous agents without a human-readable state;
      • you require centralized enterprise control;
      • you want black-box memory systems,

      These are valid goals; just different ones.

      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#further-reading","level":2,"title":"Further Reading","text":"
      • You Can't Import Expertise: why project-specific context matters more than generic best practices
      ","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/design-invariants/","level":1,"title":"Invariants","text":"","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#the-system-explains-itself","level":1,"title":"The System Explains Itself","text":"

      These are the properties that must hold for any valid ctx implementation.

      • These are not features.
      • These are constraints.

      A change that violates an invariant is a category error, not an improvement.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#cognitive-state-tiers","level":2,"title":"Cognitive State Tiers","text":"

      ctx distinguishes between three forms of state:

      • Authoritative state: Versioned, inspectable artifacts that define intent and survive time.
      • Delivery views: Deterministic assemblies of the authoritative state for a specific budget or workflow.
      • Ephemeral working state: Local, transient, or sensitive data that assists interaction but does not define system truth.

      The invariants below apply primarily to the authoritative cognitive state.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#1-cognitive-state-is-explicit","level":2,"title":"1. Cognitive State Is Explicit","text":"

      All authoritative context lives in artifacts that can be inspected, reviewed, and versioned.

      If something is important, it must exist as a file: Not only in a prompt, a chat, or a model's hidden memory.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#2-assembly-is-reproducible","level":2,"title":"2. Assembly Is Reproducible","text":"

      Given the same:

      • repository state,
      • configuration,
      • and inputs,

      context assembly produces the same result.

      Heuristics may rank or filter for delivery under constraints.

      They do not alter the authoritative state.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#3-the-authoritative-state-is-human-readable","level":2,"title":"3. The Authoritative State Is Human-Readable","text":"

      The authoritative cognitive state must be stored in formats that a human can:

      • read,
      • diff,
      • review,
      • and edit directly.

      Sensitive working memory may be encrypted at rest. However, encryption must not become the only representation of authoritative knowledge.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#4-artifacts-outlive-sessions","level":2,"title":"4. Artifacts Outlive Sessions","text":"

      Sessions are transient.

      Knowledge persists.

      Reasoning, decisions, and outcomes must remain available after the interaction that produced them has ended.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#5-authority-is-user-defined","level":2,"title":"5. Authority Is User-Defined","text":"

      What enters the authoritative context is an explicit human decision.

      Models may suggest.

      Automation may assist.

      Selection is never implicit.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#6-operation-is-local-first","level":2,"title":"6. Operation Is Local-First","text":"

      The core system must function without requiring network access or a remote service.

      External systems may extend ctx.

      They must not be required for its operation.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#7-versioning-is-the-memory-model","level":2,"title":"7. Versioning Is the Memory Model","text":"

      The evolution of the authoritative cognitive state must be:

      • preserved,
      • inspectable,
      • and branchable.

      Ephemeral and sensitive working state may use different retention and diff strategies by design.

      Understanding includes understanding how we arrived here.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#8-structure-enables-scale","level":2,"title":"8. Structure Enables Scale","text":"

      Unstructured accumulation is not memory.

      Authoritative cognitive state must have a defined layout that:

      • communicates intent,
      • supports navigation,
      • and prevents drift.
      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#9-verification-is-the-scoreboard","level":2,"title":"9. Verification Is the Scoreboard","text":"

      Claims without recorded outcomes are noise.

      Reality (observed and captured) is the only signal that compounds.

      This invariant defines a required direction:

      The authoritative state must be able to record expectation and result.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#10-capture-once-reuse-indefinitely","level":2,"title":"10. Capture Once, Reuse Indefinitely","text":"

      Work that has already produced understanding must not be re-derived from scratch.

      Explored paths, rejected options, and validated conclusions are permanent assets.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#11-policies-are-encoded-not-remembered","level":2,"title":"11. Policies Are Encoded, Not Remembered","text":"

      Alignment must not depend on recall or goodwill.

      Constraints that matter must exist in machine-readable form and participate in context assembly.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#12-the-system-explains-itself","level":2,"title":"12. The System Explains Itself","text":"

      From the repository state alone it must be possible to determine:

      • what was authoritative,
      • what constraints applied.

      Delivery views may be optimized.

      They must not become the only explanation.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#non-goals","level":1,"title":"Non-Goals","text":"

      To avoid category errors, ctx does not attempt to be:

      • a skill,
      • a prompt management tool,
      • a chat history viewer,
      • an autonomous agent runtime,
      • a vector database,
      • a hosted memory service.

      Such systems may integrate with ctx.

      They do not define it.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#implications-for-contributions","level":1,"title":"Implications for Contributions","text":"

      Valid contributions:

      • strengthen an invariant,
      • reduce the cost of maintaining an invariant,
      • or extend the system without violating invariants.

      Invalid contributions:

      • introduce hidden authoritative state,
      • replace reproducible assembly with non-reproducible behavior,
      • make core operation depend on external services,
      • reduce human inspectability of authoritative state,
      • or bypass explicit user authority over what becomes authoritative.
      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#the-contract","level":1,"title":"The Contract","text":"

      Everything else (commands, skills, layouts, integrations, optimizations) is an implementation detail.

      These invariants are the system.

      ","path":["Reference","Invariants"],"tags":[]},{"location":"reference/scratchpad/","level":1,"title":"Scratchpad","text":"","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#what-is-ctx-scratchpad","level":2,"title":"What Is ctx Scratchpad?","text":"

      A one-liner scratchpad, encrypted at rest, synced via git.

      Quick notes that don't fit decisions, learnings, or tasks: reminders, intermediate values, sensitive tokens, working memory during debugging. Entries are numbered, reorderable, and persist across sessions.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#encrypted-by-default","level":2,"title":"Encrypted by Default","text":"

      Scratchpad entries are encrypted with AES-256-GCM before touching the disk.

      Component Path Git status Encryption key ~/.ctx/.ctx.key User-level, 0600 permissions Encrypted data .context/scratchpad.enc Committed

      The key is generated automatically during ctx init (256-bit via crypto/rand) and stored at ~/.ctx/.ctx.key. One key per machine, shared across all projects.

      The ciphertext format is [12-byte nonce][ciphertext+tag]. No external dependencies: Go stdlib only.

      Because the key is .gitignored and the data is committed, you get:

      • At-rest encryption: the .enc file is opaque without the key
      • Git sync: push/pull the encrypted file like any other tracked file
      • Key separation: the key never leaves the machine unless you copy it
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#commands","level":2,"title":"Commands","text":"Command Purpose ctx pad List all entries (numbered 1-based) ctx pad show N Output raw text of entry N (no prefix, pipe-friendly) ctx pad add \"text\" Append a new entry ctx pad rm ID [ID...] Remove entries by stable ID (supports ranges: 3-5) ctx pad edit N \"text\" Replace entry N with new text ctx pad edit N --append \"text\" Append text to the end of entry N ctx pad edit N --prepend \"text\" Prepend text to the beginning of entry N ctx pad edit N --tag tagname Add a tag to entry N ctx pad add TEXT --file PATH Ingest a file as a blob entry (TEXT is the label) ctx pad show N --out PATH Write decoded blob content to a file ctx pad normalize Reassign entry IDs as 1..N ctx pad mv N M Move entry from position N to position M ctx pad resolve Show both sides of a merge conflict for resolution ctx pad import FILE Bulk-import lines from a file (or stdin with -) ctx pad import --blob DIR Import directory files as blob entries ctx pad export [DIR] Export all blob entries to a directory as files ctx pad merge FILE... Merge entries from other scratchpad files into current ctx pad --tag TAG List entries filtered by tag (prefix with ~ to exclude) ctx pad tags List all tags with counts ctx pad tags --json List all tags with counts as JSON

      All commands decrypt on read, operate on plaintext in memory, and re-encrypt on write. The key file is never printed to stdout.

      For blob entries, --append, --prepend, and --tag modify the label while preserving the blob data.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#examples","level":3,"title":"Examples","text":"
      # Add a note\nctx pad add \"check DNS propagation after deploy\"\n\n# List everything\nctx pad\n#   1. check DNS propagation after deploy\n#   2. staging API key: sk-test-abc123\n\n# Show raw text (for piping)\nctx pad show 2\n# sk-test-abc123\n\n# Compose entries\nctx pad edit 1 --append \"$(ctx pad show 2)\"\n\n# Reorder\nctx pad mv 2 1\n\n# Clean up (IDs are stable; they don't shift when entries are deleted)\nctx pad rm 2\n
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#tags","level":2,"title":"Tags","text":"

      Entries can contain #word tags for lightweight categorization. Tags are convention-based: any #word token in an entry's text is a tag. No special syntax to add or remove them; use the existing add and edit commands.

      # Add tagged entries\nctx pad add \"check DNS propagation #later\"\nctx pad add \"deploy hotfix #urgent\"\nctx pad add \"review PR #later #ci\"\n\n# Filter by tag\nctx pad --tag later\n#   1. check DNS propagation #later\n#   3. review PR #later #ci\n\n# Exclude a tag\nctx pad --tag ~later\n#   2. deploy hotfix #urgent\n\n# Multiple filters (AND logic)\nctx pad --tag later --tag ci\n#   3. review PR #later #ci\n\n# List all tags with counts\nctx pad tags\n# ci       1\n# later    2\n# urgent   1\n\n# JSON output\nctx pad tags --json\n# [{\"tag\":\"ci\",\"count\":1},{\"tag\":\"later\",\"count\":2},{\"tag\":\"urgent\",\"count\":1}]\n\n# Add a tag to an existing entry\nctx pad edit 1 --tag done\n\n# Combine with other operations\nctx pad edit 1 --append \"checked\" --tag done\n\n# Remove a tag (replace entry text without the tag)\nctx pad edit 1 \"check DNS propagation\"\n

      Entry IDs are stable; they don't shift when other entries are deleted, so ctx pad rm 3 always targets the same entry. Use ctx pad normalize to reassign IDs as 1..N if gaps bother you. Tags are case-sensitive and support letters, digits, hyphens, and underscores (#high-priority, #v2, #my_tag).

      For blob entries, tags are extracted from the label only.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#bulk-import-and-export","level":2,"title":"Bulk Import and Export","text":"

      Import lines from a file in bulk (each non-empty line becomes an entry):

      # Import from a file\nctx pad import notes.txt\n\n# Import from stdin\ngrep TODO *.go | ctx pad import -\n

      Export all blob entries to a directory as files:

      # Export to a directory\nctx pad export ./ideas\n\n# Preview without writing\nctx pad export --dry-run\n\n# Overwrite existing files\nctx pad export --force ./backup\n
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#merging-scratchpads","level":2,"title":"Merging Scratchpads","text":"

      Combine entries from other scratchpad files into your current pad. Useful when merging work from parallel worktrees, other machines, or teammates:

      # Merge from a worktree's encrypted scratchpad\nctx pad merge worktree/.context/scratchpad.enc\n\n# Merge from multiple sources (encrypted and plaintext)\nctx pad merge pad-a.enc notes.md\n\n# Merge a foreign encrypted pad using its key\nctx pad merge --key /other/.ctx.key foreign.enc\n\n# Preview without writing\nctx pad merge --dry-run pad-a.enc pad-b.md\n

      Each input file is auto-detected as encrypted or plaintext: decryption is attempted first, and on failure the file is parsed as plain text. Entries are deduplicated by exact content, so running merge twice with the same file is safe.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#file-blobs","level":2,"title":"File Blobs","text":"

      The scratchpad can store small files (up to 64 KB) as blob entries. Files are base64-encoded and stored with a human-readable label.

      # Ingest a file: first argument is the label\nctx pad add \"deploy config\" --file ./deploy.yaml\n\n# Listing shows label with a [BLOB] marker\nctx pad\n#   1. check DNS propagation after deploy\n#   2. deploy config [BLOB]\n\n# Extract to a file\nctx pad show 2 --out ./recovered.yaml\n\n# Or print decoded content to stdout\nctx pad show 2\n

      Blob entries are encrypted identically to text entries. The internal format is label:::base64data: You never need to construct this manually.

      Constraint Value Max file size (pre-encoding) 64 KB Storage format label:::base64(content) Display label [BLOB] in listings

      When Should You Use Blobs

      Blobs are for small files you want encrypted and portable: config snippets, key fragments, deployment manifests, test fixtures. For anything larger than 64 KB, use the filesystem directly.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#using-with-ai","level":2,"title":"Using with AI","text":"

      Use Natural Language

      As in many ctx features, the ctx scratchpad can also be used with natural langauge. You don't have to memorize the CLI commands.

      CLI gives you \"precision\", whereas natural language gives you flow.

      The /ctx-pad skill maps natural language to ctx pad commands. You don't need to remember the syntax:

      You say What happens \"jot down: check DNS after deploy\" ctx pad add \"check DNS after deploy\" \"show my scratchpad\" ctx pad \"delete the third entry\" ctx pad rm 3 \"update entry 2 to include the new endpoint\" ctx pad edit 2 \"...\" \"move entry 4 to the top\" ctx pad mv 4 1 \"import my notes from notes.txt\" ctx pad import notes.txt \"export all blobs to ./backup\" ctx pad export ./backup \"merge the scratchpad from the worktree\" ctx pad merge worktree/.context/scratchpad.enc

      The skill handles the translation. You describe what you want in plain English; the agent picks the right command.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#worktrees","level":2,"title":"Worktrees","text":"

      The encryption key lives at ~/.ctx/.ctx.key (outside the project directory). Because all worktrees on the same machine share this path, ctx pad works in worktrees automatically - no special setup needed.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#key-distribution","level":2,"title":"Key Distribution","text":"

      The encryption key (~/.ctx/.ctx.key) stays on the machine where it was generated. ctx never transmits it.

      To share the scratchpad across machines:

      1. Copy the key manually: scp, USB drive, password manager.
      2. Push/pull the .enc file via git as usual.
      3. Both machines can now read and write the same scratchpad.

      Never Commit the Key

      The key is .gitignored by default. If you override this, anyone with repo access can decrypt your scratchpad.

      Treat the key like an SSH private key.

      See the Syncing Scratchpad Notes Across Machines recipe for a step-by-step walkthrough.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#plaintext-override","level":2,"title":"Plaintext Override","text":"

      For projects where encryption is unnecessary, disable it in .ctxrc:

      scratchpad_encrypt: false\n

      In plaintext mode:

      • Entries are stored in .context/scratchpad.md instead of .enc.
      • No key is generated or required.
      • All ctx pad commands work identically.
      • The file is human-readable and diffable.

      When Should You Use Plaintext

      Plaintext mode is useful for non-sensitive projects, solo work where encryption adds friction, or when you want scratchpad entries visible in git diff.

      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#when-should-you-use-scratchpad-versus-context-files","level":2,"title":"When Should You Use Scratchpad versus Context Files","text":"Use case Where it goes Temporary reminders (\"check X after deploy\") Scratchpad Working values during debugging Scratchpad Sensitive tokens or API keys (short-term) Scratchpad Quick notes that don't fit anywhere else Scratchpad Items that are not directly relevant to the project Scratchpad Things that you want to keep near, but also hidden Scratchpad Work items with completion tracking TASKS.md Trade-offs with rationale DECISIONS.md Reusable lessons with context/lesson/application LEARNINGS.md Codified patterns and standards CONVENTIONS.md

      Rule of thumb:

      • If it needs structure or will be referenced months later, use a context file (i.e. DECISIONS.md, LEARNINGS.md, TASKS.md).
      • If it is working memory for the current session or week, use the scratchpad.
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#see-also","level":2,"title":"See Also","text":"
      • Syncing Scratchpad Notes Across Machines: Key distribution, push/pull workflow, merge conflict resolution
      • Using the Scratchpad: Natural language examples, blob workflow, when to use scratchpad vs context files
      • Context Files: Format and conventions for all .context/ files
      • Security: Trust model and permission hygiene
      ","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/session-journal/","level":1,"title":"Session Journal","text":"

      Important Security Note

      Session journals contain sensitive data such as file contents, commands, API keys, internal discussions, error messages with stack traces, and more.

      The .context/journal-site/ and .context/journal-obsidian/ directories MUST be .gitignored.

      • DO NOT host your journal publicly.
      • DO NOT commit your journal files to version control.
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#browse-your-session-history","level":2,"title":"Browse Your Session History","text":"

      ctx's Session Journal turns your AI coding sessions into a browsable, searchable, and editable archive.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#quick-start","level":2,"title":"Quick Start","text":"

      After using ctx for a couple of sessions, you can generate a journal site with:

      # Import all sessions to markdown\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n

      Then open http://localhost:8000 to browse your sessions.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#what-you-get","level":2,"title":"What You Get","text":"

      The Session Journal gives you:

      • Browsable history: Navigate through all your AI sessions by date
      • Full conversations: See every message, tool use, and result
      • Token usage: Track how many tokens each session consumed
      • Search: Find sessions by content, project, or date
      • Dark mode: Easy on the eyes for late-night archaeology

      Each session page includes the following sections:

      Section Content Metadata Date, time, duration, model, project, git branch Summary Space for your notes (editable) Tool Usage Which tools were used and how often Conversation Full transcript with timestamps","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#1-import-sessions","level":3,"title":"1. Import Sessions","text":"
      # Import all sessions from current project (only new files)\nctx journal import --all\n\n# Import sessions from all projects\nctx journal import --all --all-projects\n\n# Import a specific session by ID (always writes)\nctx journal import abc123\n\n# Preview what would be imported\nctx journal import --all --dry-run\n\n# Re-import existing (regenerates conversation, preserves YAML frontmatter)\nctx journal import --all --regenerate\n\n# Discard frontmatter during regeneration\nctx journal import --all --regenerate --keep-frontmatter=false -y\n

      Imported sessions go to .context/journal/ as editable Markdown files.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#2-generate-the-site","level":3,"title":"2. Generate the Site","text":"
      # Generate site structure\nctx journal site\n\n# Generate and build static HTML\nctx journal site --build\n\n# Generate and serve locally\nctx journal site --serve\n\n# Custom output directory\nctx journal site --output ~/my-journal\n

      The site is generated in .context/journal-site/ by default.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#3-browse-and-search","level":3,"title":"3. Browse and Search","text":"

      Open http://localhost:8000 after running --serve.

      • Use the sidebar to navigate by date
      • Use search (/ key) to find specific content
      • Click any session to see the full conversation
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#editing-sessions","level":2,"title":"Editing Sessions","text":"

      Imported sessions are plain Markdown in .context/journal/. You can:

      • Add summaries: Fill in the ## Summary section
      • Add notes: Insert your own commentary anywhere
      • Highlight key moments: Use Markdown formatting
      • Delete noise: Remove irrelevant tool outputs

      After editing, regenerate the site:

      ctx journal site --serve\n
      Safe by Default

      Running ctx journal import --all only imports new sessions. Existing files are skipped entirely (your edits and enrichments are never touched).

      Use --regenerate to re-import existing files. Conversation content is regenerated, but YAML frontmatter (topics, type, outcome, etc.) is preserved. You'll be prompted before any existing files are overwritten; add -y to skip the prompt.

      Use --keep-frontmatter=false to discard enriched frontmatter during regeneration.

      Locked entries (via ctx journal lock) are always skipped, regardless of flags. If you prefer to add locked: true to frontmatter during enrichment, run ctx journal sync to propagate the lock state to .state.json.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#large-sessions","level":2,"title":"Large Sessions","text":"

      Sessions with many messages (200+) are automatically split into multiple parts for better browser performance. Navigation links connect the parts:

      session-abc123.md      (Part 1 of 3)\nsession-abc123-p2.md   (Part 2 of 3)\nsession-abc123-p3.md   (Part 3 of 3)\n
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#suggestion-sessions","level":2,"title":"Suggestion Sessions","text":"

      Claude Code generates \"suggestion\" sessions for auto-complete prompts. These are separated in the index under a \"Suggestions\" section to keep your main session list focused.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enriching-journal-entries","level":2,"title":"Enriching Journal Entries","text":"

      Raw imported sessions contain basic metadata (date, time, project) but lack the structured information needed for effective search, filtering, and analysis. Journal enrichment adds semantic metadata that transforms a flat archive into a searchable knowledge base.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#why-enrich","level":3,"title":"Why Enrich?","text":"

      Without enrichment, you have timestamps and raw conversations. With enrichment:

      • Find sessions by topic: \"Show me all auth-related sessions\"
      • Filter by outcome: \"What did I abandon vs complete?\"
      • Track technology usage: \"When did I last work with PostgreSQL?\"
      • Identify key files: Jump directly to the files discussed
      • Get summaries: Understand what happened without reading transcripts
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#the-frontmatter-schema","level":3,"title":"The Frontmatter Schema","text":"

      Enriched entries begin with YAML frontmatter:

      ---\ntitle: \"Implement caching layer\"\ndate: 2026-01-27\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - performance\ntechnologies:\n  - go\n  - redis\nlibraries:\n  - go-redis/redis\nkey_files:\n  - internal/cache/redis.go\n  - internal/cache/memory.go\n---\n
      Field Required Description title Yes Descriptive title (not the session slug) date Yes Session date (YYYY-MM-DD) type Yes Session type (see below) outcome Yes How the session ended (see below) topics No Subject areas discussed technologies No Languages, databases, frameworks libraries No Specific packages or libraries used key_files No Important files created or modified

      Type values:

      Type When to use feature Building new functionality bugfix Fixing broken behavior refactor Restructuring without behavior change exploration Research, learning, experimentation debugging Investigating issues documentation Writing docs, comments, README

      Outcome values:

      Outcome Meaning completed Goal achieved partial Some progress, work continues abandoned Stopped pursuing this approach blocked Waiting on external dependency","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-ctx-journal-enrich","level":3,"title":"Using /ctx-journal-enrich","text":"

      The /ctx-journal-enrich skill automates enrichment by analyzing conversation content and proposing metadata.

      Invoke by session identifier:

      /ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-01-24\n/ctx-journal-enrich 76fe2ab9\n

      The skill will:

      1. Check if locked - locked entries are skipped (same as export);
      2. Find the matching journal file;
      3. Read and analyze the conversation;
      4. Propose frontmatter (type, topics, outcome, technologies);
      5. Generate a 2-3 sentence summary;
      6. Extract decisions, learnings, and tasks mentioned;
      7. Show a diff and ask for confirmation before writing.
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#before-and-after","level":3,"title":"Before and After","text":"

      Before enrichment:

      # twinkly-stirring-kettle\n\n**ID**: abc123-def456\n**Date**: 2026-01-24\n**Time**: 14:30:00\n...\n\n## Summary\n\n[Add your summary of this session]\n\n## Conversation\n...\n

      After enrichment:

      ---\ntitle: \"Add Redis caching to API endpoints\"\ndate: 2026-01-24\ntype: feature\noutcome: completed\ntopics:\n  - caching\n  - api-performance\ntechnologies:\n  - go\n  - redis\nkey_files:\n  - internal/api/middleware/cache.go\n  - internal/cache/redis.go\n---\n\n# twinkly-stirring-kettle\n\n**ID**: abc123-def456\n**Date**: 2026-01-24\n**Time**: 14:30:00\n...\n\n## Summary\n\nImplemented Redis-based caching middleware for frequently accessed API endpoints.\nAdded cache invalidation on writes and configurable TTL per route. Reduced\n the average response time from 200ms to 15ms for cached routes.\n\n## Decisions\n\n* Used Redis over in-memory cache for horizontal scaling\n* Chose per-route TTL configuration over global setting\n\n## Learnings\n\n* Redis WATCH command prevents race conditions during cache invalidation\n\n## Conversation\n...\n
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enrichment-and-site-generation","level":3,"title":"Enrichment and Site Generation","text":"

      The journal site generator uses enriched metadata for better organization:

      • Titles appear in navigation instead of slugs
      • Summaries provide context in the index
      • Topics enable filtering (when using search)
      • Types allow grouping by work category

      Future improvements will add topic-based navigation and outcome filtering to the generated site.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#batch-enrichment","level":3,"title":"Batch Enrichment","text":"

      To enrich multiple sessions, process them one at a time:

      # List unenriched sessions (those without frontmatter)\ngrep -L \"^---$\" .context/journal/*.md | head -10\n

      Then run /ctx-journal-enrich on each. Enrichment is intentionally interactive to ensure accuracy.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#obsidian-vault-export","level":2,"title":"Obsidian Vault Export","text":"

      If you use Obsidian for knowledge management, you can export your journal as an Obsidian vault instead of (or alongside) the static site:

      ctx journal obsidian\n

      This generates a vault in .context/journal-obsidian/ with:

      • Wikilinks ([[target|display]]) instead of Markdown links
      • MOC pages (Map of Content) for topics, key files, and session types
      • Related sessions footer per entry: links to entries sharing the same topics
      • Transformed frontmatter: topics renamed to tags (Obsidian-recognized), aliases added from title for search
      • Graph-optimized structure: MOC hubs and cross-linked entries create dense graph connectivity

      To use: open the output directory in Obsidian (\"Open folder as vault\").

      # Custom output directory\nctx journal obsidian --output ~/vaults/ctx-journal\n

      Static Site vs Obsidian Vault

      Use ctx journal site when you want a web-browsable archive with search and dark mode. Use ctx journal obsidian when you want graph view, backlinks, and tag-based navigation inside Obsidian. Both use the same enriched source entries: you can generate both.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#full-pipeline","level":2,"title":"Full Pipeline","text":"

      The complete journal workflow has four stages. Each is idempotent: safe to re-run, and stages skip already-processed entries.

      import → enrich → rebuild\n
      Stage Command / Skill What it does Skips if Import ctx journal import --all Converts session JSONL to Markdown File already exists (safe default) Enrich /ctx-journal-enrich Adds frontmatter, summaries, topics Frontmatter already present Rebuild ctx journal site --build Generates static HTML site (never) Obsidian ctx journal obsidian Generates Obsidian vault with wikilinks (never)

      One-Command Pipeline

      /ctx-journal-enrich-all handles import automatically - it detects unimported sessions and imports them before enriching. You only need to run ctx journal site --build afterward.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-make-journal","level":3,"title":"Using make journal","text":"

      If your project includes Makefile.ctx (deployed by ctx init), the first and last stages are combined:

      make journal           # import + rebuild\n

      After it runs, it reminds you to enrich in Claude Code:

      Next steps (in Claude Code):\n  /ctx-journal-enrich-all # imports if needed + adds metadata per entry\n\nThen re-run: make journal\n

      Rendering Issues?

      If individual entries have rendering problems (broken fences, malformed lists), check the programmatic normalization in the import pipeline. Most cases are handled automatically during ctx journal import.

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#tips","level":2,"title":"Tips","text":"

      Daily workflow:

      # Import, browse, then enrich in Claude Code\nmake journal && make journal-serve\n# Then in Claude Code: /ctx-journal-enrich <session>\n

      After a productive session:

      # Import just that session and add notes\nctx journal import <session-id>\n# Edit .context/journal/<session>.md\n# Regenerate: ctx journal site\n

      Searching across all sessions:

      # Use grep on the journal directory\ngrep -r \"authentication\" .context/journal/\n

      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#requirements","level":2,"title":"Requirements","text":"Use pipx for zensical

      pip install zensical may install a non-functional stub on system Python. Using venv has other issues too.

      These issues especially happen on Mac OSX.

      Use pipx install zensical, which creates an isolated environment and handles Python version management automatically.

      The journal site uses zensical for static site generation:

      pipx install zensical\n
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#see-also","level":2,"title":"See Also","text":"
      • ctx journal: Session discovery and listing
      • ctx journal site: Static site generation
      • ctx journal obsidian: Obsidian vault export
      • Context Files: The .context/ directory structure
      ","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/skills/","level":1,"title":"Skills","text":"","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#skills","level":2,"title":"Skills","text":"

      Skills are slash commands that run inside your AI assistant (e.g., /ctx-next), as opposed to CLI commands that run in your terminal (e.g., ctx status).

      Skills give your agent structured workflows: It knows what to read, what to run, and when to ask. Most wrap one or more ctx CLI commands with opinionated behavior on top.

      Skills Are Best Used Conversationally

      The beauty of ctx is that it's designed to be intuitive and conversational, allowing you to interact with your AI assistant naturally. That's why you don't have to memorize many of these skills.

      See the Prompting Guide for natural-language triggers that invoke these skills conversationally.

      However, when you need a more precise control, you have the option to invoke the relevant skills directly.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#all-skills","level":2,"title":"All Skills","text":"Skill Description Type /ctx-remember Recall project context and present structured readback user-invocable /ctx-wrap-up End-of-session context persistence ceremony user-invocable /ctx-status Show context summary with interpretation user-invocable /ctx-agent Load full context packet for AI consumption user-invocable /ctx-next Suggest 1-3 concrete next actions with rationale user-invocable /ctx-commit Commit with integrated context persistence user-invocable /ctx-reflect Pause and reflect on session progress user-invocable /ctx-task-add Add actionable task to TASKS.md user-invocable /ctx-decision-add Record architectural decision with rationale user-invocable /ctx-learning-add Record gotchas and lessons learned user-invocable /ctx-convention-add Record coding convention for consistency user-invocable /ctx-archive Archive completed tasks from TASKS.md user-invocable /ctx-pad Manage encrypted scratchpad entries user-invocable /ctx-history Browse and import AI session history user-invocable /ctx-journal-enrich Enrich single journal entry with metadata user-invocable /ctx-journal-enrich-all Full journal pipeline: export if needed, then batch-enrich user-invocable /ctx-blog Generate blog post draft from project activity user-invocable /ctx-blog-changelog Generate themed blog post from a commit range user-invocable /ctx-consolidate Consolidate redundant learnings or decisions user-invocable /ctx-drift Detect and fix context drift user-invocable /ctx-prompt Apply, list, and manage saved prompt templates user-invocable /ctx-prompt-audit Analyze prompting patterns for improvement user-invocable /ctx-link-check Audit docs for dead internal and external links user-invocable /ctx-permission-sanitize Audit Claude Code permissions for security risks user-invocable /ctx-brainstorm Structured design dialogue before implementation user-invocable /ctx-spec Scaffold a feature spec from a project template user-invocable /ctx-plan-import Import Claude Code plan files into project specs user-invocable /ctx-implement Execute a plan step-by-step with verification user-invocable /ctx-loop Generate autonomous loop script user-invocable /ctx-worktree Manage git worktrees for parallel agents user-invocable /ctx-architecture Build and maintain architecture maps user-invocable /ctx-architecture-failure-analysis Adversarial failure analysis for correctness bugs user-invocable /ctx-remind Manage session-scoped reminders user-invocable /ctx-doctor Troubleshoot ctx behavior with health checks and event analysis user-invocable /ctx-skill-audit Audit skills against Anthropic prompting best practices user-invocable /ctx-skill-create Create, improve, and test skills user-invocable /ctx-pause Pause context hooks for this session user-invocable /ctx-resume Resume context hooks after a pause user-invocable","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-lifecycle","level":2,"title":"Session Lifecycle","text":"

      Skills for starting, running, and ending a productive session.

      Session Ceremonies

      Two skills in this group are ceremony skills: /ctx-remember (session start) and /ctx-wrap-up (session end). Unlike other skills that work conversationally, these should be invoked as explicit slash commands for completeness. See Session Ceremonies.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remember","level":3,"title":"/ctx-remember","text":"

      Recall project context and present a structured readback. Ceremony skill: invoke explicitly at session start.

      Wraps: ctx agent --budget 4000, ctx journal source --limit 3, reads TASKS.md, DECISIONS.md, LEARNINGS.md

      See also: Session Ceremonies, The Complete Session

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-status","level":3,"title":"/ctx-status","text":"

      Show context summary (files, token budget, tasks, recent activity) with interpreted suggestions.

      Wraps: ctx status [--verbose] [--json]

      See also: The Complete Session, ctx status CLI

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-agent","level":3,"title":"/ctx-agent","text":"

      Load the full context packet optimized for AI consumption. Also runs automatically via the PreToolUse hook with cooldown.

      Wraps: ctx agent [--budget] [--format] [--cooldown] [--session]

      See also: The Complete Session, ctx agent CLI

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-next","level":3,"title":"/ctx-next","text":"

      Suggest 1-3 concrete next actions ranked by priority, momentum, and unblocked status.

      Wraps: reads TASKS.md, ctx journal source --limit 3

      See also: The Complete Session, Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-commit","level":3,"title":"/ctx-commit","text":"

      Commit code with integrated context persistence: pre-commit checks, staged files, Co-Authored-By trailer, and a post-commit prompt to capture decisions and learnings.

      Wraps: git add, git commit, optionally chains to /ctx-decision-add and /ctx-learning-add

      See also: The Complete Session

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-reflect","level":3,"title":"/ctx-reflect","text":"

      Pause and reflect on session progress. Walks through a checklist of learnings, decisions, task completions, and session notes to persist.

      Wraps: chains to ctx learning add, ctx decision add, manual TASKS.md updates

      See also: The Complete Session, Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-wrap-up","level":3,"title":"/ctx-wrap-up","text":"

      End-of-session context persistence ceremony. Gathers signal from git diff, recent commits, and conversation themes. Proposes candidates (learnings, decisions, conventions, tasks) with complete structured fields for user approval, then persists via ctx add. Offers /ctx-commit if uncommitted changes remain. Ceremony skill: invoke explicitly at session end.

      Wraps: git diff --stat, git log, ctx learning add, ctx decision add, ctx convention add, ctx task add, chains to /ctx-commit

      See also: Session Ceremonies, The Complete Session

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#context-persistence","level":2,"title":"Context Persistence","text":"

      Skills for recording work artifacts: tasks, decisions, learnings, conventions: into .context/ files.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-task-add","level":3,"title":"/ctx-task-add","text":"

      Add an actionable task with optional priority and phase section.

      Wraps: ctx task add \"description\" [--priority high|medium|low] --session-id ID --branch BR --commit HASH

      See also: Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-decision-add","level":3,"title":"/ctx-decision-add","text":"

      Record an architectural decision with context, rationale, and consequence. Supports Y-statement (lightweight) and full ADR formats.

      Wraps: ctx decision add \"title\" --context \"...\" --rationale \"...\" --consequence \"...\" --session-id ID --branch BR --commit HASH

      See also: Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-learning-add","level":3,"title":"/ctx-learning-add","text":"

      Record a project-specific gotcha, bug, or unexpected behavior. Filters for insights that are searchable, project-specific, and required real effort to discover.

      Wraps: ctx learning add \"title\" --context \"...\" --lesson \"...\" --application \"...\" --session-id ID --branch BR --commit HASH

      See also: Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-convention-add","level":3,"title":"/ctx-convention-add","text":"

      Record a coding convention that should be standardized across sessions. Targets patterns seen 2-3+ times.

      Wraps: ctx convention add \"rule\" --section \"Name\"

      See also: Persisting Decisions, Learnings, and Conventions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-archive","level":3,"title":"/ctx-archive","text":"

      Archive completed tasks from TASKS.md to a timestamped file in .context/archive/. Preserves phase headers for traceability.

      Wraps: ctx task archive [--dry-run]

      See also: Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#scratchpad","level":2,"title":"Scratchpad","text":"","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-pad","level":3,"title":"/ctx-pad","text":"

      Manage the encrypted scratchpad: add, remove, edit, and reorder one-liner notes. Encrypted at rest with AES-256-GCM.

      Wraps: ctx pad, ctx pad add, ctx pad rm, ctx pad edit, ctx pad mv, ctx pad import, ctx pad export, ctx pad merge

      See also: Scratchpad, Using the Scratchpad

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#journal-history","level":2,"title":"Journal & History","text":"

      Skills for browsing, exporting, and enriching your AI session history into a structured journal.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-history","level":3,"title":"/ctx-history","text":"

      Browse, inspect, and import AI session history. List recent sessions, show details by slug or ID, and import to .context/journal/.

      Wraps: ctx journal source, ctx journal source --show, ctx journal import

      See also: Browsing and Enriching Past Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich","level":3,"title":"/ctx-journal-enrich","text":"

      Enrich a single journal entry with YAML frontmatter: title, type, outcome, topics, technologies, and summary. Shows diff before writing.

      Wraps: reads and edits .context/journal/*.md files

      See also: Browsing and Enriching Past Sessions, Turning Activity into Content

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich-all","level":3,"title":"/ctx-journal-enrich-all","text":"

      Full journal pipeline: imports unimported sessions first, then batch-enriches all unenriched entries. Filters out short sessions and continuations. Can spawn subagents for large backlogs.

      Wraps: ctx journal import --all + iterates /ctx-journal-enrich

      See also: Browsing and Enriching Past Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#content-creation","level":2,"title":"Content Creation","text":"

      Skills for turning project activity into publishable content.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog","level":3,"title":"/ctx-blog","text":"

      Generate a blog post draft from recent project activity: git history, decisions, learnings, tasks, and journal entries. Requires a narrative arc (problem, approach, outcome).

      Wraps: reads git log, DECISIONS.md, LEARNINGS.md, TASKS.md, journal entries; writes to docs/blog/

      See also: Turning Activity into Content

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog-changelog","level":3,"title":"/ctx-blog-changelog","text":"

      Generate a themed blog post from a commit range. Takes a starting commit and unifying theme, analyzes diffs and journal entries from that period.

      Wraps: git log, git diff --stat; writes to docs/blog/

      See also: Turning Activity into Content

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#auditing-health","level":2,"title":"Auditing & Health","text":"

      Skills for detecting drift, auditing alignment, and improving prompt quality.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-consolidate","level":3,"title":"/ctx-consolidate","text":"

      Consolidate redundant entries in LEARNINGS.md or DECISIONS.md. Groups overlapping entries by keyword similarity, presents candidates, and (with user approval) merges groups into denser combined entries. Originals are archived, not deleted.

      Wraps: reads LEARNINGS.md and DECISIONS.md, writes consolidated entries, archives originals, runs ctx reindex

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-drift","level":3,"title":"/ctx-drift","text":"

      Detect and fix context drift: stale paths, missing files, file age staleness, task accumulation, entry count warnings, and constitution violations via ctx drift. Also detects skill drift against canonical templates.

      Wraps: ctx drift [--fix]

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-prompt-audit","level":3,"title":"/ctx-prompt-audit","text":"

      Analyze recent prompting patterns to identify vague or ineffective prompts. Reviews 3-5 journal entries and suggests rewrites with positive observations.

      Wraps: reads .context/journal/ entries

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-doctor","level":3,"title":"/ctx-doctor","text":"

      Troubleshoot ctx behavior. Runs structural health checks via ctx doctor, analyzes event log patterns via ctx hook event, and presents findings with suggested actions. The CLI provides the structural baseline; the agent adds semantic analysis of event patterns and correlations.

      Wraps: ctx doctor --json, ctx hook event --json --last 100, ctx remind list, ctx hook message list, reads .ctxrc

      Trigger phrases: \"diagnose\", \"troubleshoot\", \"doctor\", \"health check\", \"why didn't my hook fire?\", \"hooks seem broken\", \"something seems off\"

      Graceful degradation: If event_log is not enabled, the skill still works but with reduced capability. It runs structural checks and notes: \"Enable event_log: true in .ctxrc for hook-level diagnostics.\"

      See also: Troubleshooting, ctx doctor CLI, ctx hook event CLI

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-link-check","level":3,"title":"/ctx-link-check","text":"

      Scan all markdown files under docs/ for broken links. Three passes: internal links (verify file targets exist on disk), external links (HTTP HEAD with timeout, report failures as warnings), and image references. Resolves relative paths, strips anchors before checking, and skips localhost/example URLs.

      Wraps: Glob + Grep to scan, curl for external checks

      Trigger phrases: \"check links\", \"audit links\", \"any broken links?\", \"dead links\"

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-permission-sanitize","level":3,"title":"/ctx-permission-sanitize","text":"

      Audit .claude/settings.local.json for dangerous permissions across four risk categories: hook bypass (Critical), destructive commands (High), config injection vectors (High), and overly broad patterns (Medium). Reports findings by severity and offers specific fix actions with user confirmation.

      Wraps: reads .claude/settings.local.json, edits with confirmation

      Trigger phrases: \"audit permissions\", \"are my permissions safe?\", \"sanitize permissions\", \"check settings\"

      See also: Claude Code Permission Hygiene

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#planning-execution","level":2,"title":"Planning & Execution","text":"

      Skills for structured design, implementation, and parallel agent workflows.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-brainstorm","level":3,"title":"/ctx-brainstorm","text":"

      Transform raw ideas into clear, validated designs through structured dialogue before any implementation begins. Follows a gated process: understand context, clarify the idea (one question at a time), surface non-functional requirements, lock understanding with user confirmation, explore 2-3 design approaches with trade-offs, stress-test the chosen approach, and present the detailed design.

      Wraps: reads DECISIONS.md, relevant source files; chains to /ctx-decision-add for recording design choices

      Trigger phrases: \"let's brainstorm\", \"design this\", \"think through\", \"before we build\", \"what approach should we take?\"

      See also: /ctx-spec

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-spec","level":3,"title":"/ctx-spec","text":"

      Scaffold a feature spec from the project template and walk through each section with the user. Covers: problem, approach, happy path, edge cases, validation rules, error handling, interface, implementation, configuration, testing, and non-goals. Spends extra time on edge cases and error handling.

      Wraps: reads specs/tpl/spec-template.md, writes to specs/, optionally chains to /ctx-task-add

      Trigger phrases: \"spec this out\", \"write a spec\", \"create a spec\", \"design document\"

      See also: /ctx-brainstorm, /ctx-plan-import

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-plan-import","level":3,"title":"/ctx-plan-import","text":"

      Import Claude Code plan files (~/.claude/plans/*.md) into the project's specs/ directory. Lists plans with dates and H1 titles, supports filtering (--today, --since, --all), slugifies headings for filenames, and optionally creates tasks referencing each imported spec.

      Wraps: reads ~/.claude/plans/*.md, writes to specs/, optionally chains to /ctx-task-add

      See also: Importing Claude Code Plans, Tracking Work Across Sessions

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-implement","level":3,"title":"/ctx-implement","text":"

      Execute a multi-step plan with build and test verification at each step. Loads a plan from a file or conversation context, breaks it into atomic steps, and checkpoints after every 3-5 steps.

      Wraps: reads plan file, runs verification commands (go build, go test, etc.)

      See also: Running an Unattended AI Agent

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-loop","level":3,"title":"/ctx-loop","text":"

      Generate a ready-to-run shell script for autonomous AI iteration. Supports Claude Code, Aider, and generic tool templates with configurable completion signals.

      Wraps: ctx loop [--tool] [--prompt] [--max-iterations] [--completion] [--output]

      See also: Autonomous Loops, Running an Unattended AI Agent

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-worktree","level":3,"title":"/ctx-worktree","text":"

      Manage git worktrees for parallel agent development. Create sibling worktrees on dedicated branches, analyze task blast radius for grouping, and tear down with merge.

      Wraps: git worktree add, git worktree list, git worktree remove, git merge

      See also: Parallel Agent Development with Git Worktrees

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture","level":3,"title":"/ctx-architecture","text":"

      Build and maintain architecture maps incrementally. Creates or refreshes ARCHITECTURE.md (succinct project map, loaded at session start) and DETAILED_DESIGN.md (deep per-module reference, consulted on-demand). Coverage is tracked in map-tracking.json so each run extends the map rather than re-analyzing everything.

      Wraps: ctx status, git log, reads source files; writes ARCHITECTURE.md, DETAILED_DESIGN.md, map-tracking.json

      See also: Detecting and Fixing Drift

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture-failure-analysis","level":3,"title":"/ctx-architecture-failure-analysis","text":"

      Adversarial failure analysis that generates falsifiable incident hypotheses against architecture artifacts. Hunts for correctness bugs that survive code review and tests: race conditions, ordering assumptions, cache staleness, error swallowing, ownership gaps, idempotency failures, state machine drift, and scaling cliffs.

      Requires /ctx-architecture artifacts as input. Reads ARCHITECTURE.md, DETAILED_DESIGN*.md, and map-tracking.json, then systematically applies 9 failure categories to every mutation point. Each finding carries an evidence standard (code path, trigger, failure path, silence reason, code evidence), a confidence level, and an explicit risk score. A mandatory challenge phase attempts to disprove each finding before it is accepted.

      Produces .context/DANGER-ZONES.md with ranked findings split into Critical (risk >= 7, silent/cascading) and Elevated tiers.

      Wraps: reads architecture artifacts, source code; writes DANGER-ZONES.md. Optionally uses GitNexus for blast radius and Gemini Search for cross-referencing known failure patterns.

      Relationship:

      Skill Mode /ctx-architecture Map what exists /ctx-architecture-enrich Improve map fidelity /ctx-architecture-failure-analysis Generate falsifiable incident hypotheses","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remind","level":3,"title":"/ctx-remind","text":"

      Manage session-scoped reminders via natural language. Translates user intent (\"remind me to refactor swagger\") into the corresponding ctx remind command. Handles date conversion for --after flags.

      Wraps: ctx remind, ctx remind list, ctx remind dismiss

      See also: Session Reminders

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#skill-authoring","level":2,"title":"Skill Authoring","text":"","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-skill-audit","level":3,"title":"/ctx-skill-audit","text":"

      Audit one or more skills against Anthropic prompting best practices. Checks audit dimensions: positive framing, motivation, phantom references, examples, subagent guards, scope, and descriptions. Reports findings by severity with concrete fix suggestions.

      Wraps: reads internal/assets/claude/skills/*/SKILL.md or .claude/skills/*/SKILL.md, references anthropic-best-practices.md

      Trigger phrases: \"audit this skill\", \"check skill quality\", \"review the skills\", \"are our skills any good?\"

      See also: /ctx-skill-create, Contributing

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-skill-create","level":3,"title":"/ctx-skill-create","text":"

      Create, improve, and test skills. Guides the full lifecycle: capture intent, interview for edge cases, draft the SKILL.md, test with realistic prompts, review results with the user, and iterate. Applies core principles: the agent is already smart (only add what it does not know), the description is the trigger (make it specific and \"pushy\"), and explain the why instead of rigid directives.

      Wraps: reads/writes .claude/skills/ and internal/assets/claude/skills/

      Trigger phrases: \"create a skill\", \"turn this into a skill\", \"make a slash command\", \"this should be a skill\", \"improve this skill\", \"the skill isn't triggering\"

      See also: Contributing

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-control","level":2,"title":"Session Control","text":"

      Skills for controlling hook behavior during a session.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-pause","level":3,"title":"/ctx-pause","text":"

      Pause all context nudge and reminder hooks for the current session. Security hooks still fire. Use for quick investigations or tasks that don't need ceremony overhead.

      Wraps: ctx hook pause

      Trigger phrases: \"pause ctx\", \"pause context\", \"stop the nudges\", \"quiet mode\"

      See also: Pausing Context Hooks

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-resume","level":3,"title":"/ctx-resume","text":"

      Resume context hooks after a pause. Restores normal nudge, reminder, and ceremony behavior. Silent no-op if not paused.

      Wraps: ctx hook resume

      Trigger phrases: \"resume ctx\", \"resume context\", \"turn nudges back on\", \"unpause\"

      See also: Pausing Context Hooks

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#project-specific-skills","level":2,"title":"Project-Specific Skills","text":"

      The ctx plugin ships the skills listed above. Teams can add their own project-specific skills to .claude/skills/ in the project root: These are separate from plugin-shipped skills and are scoped to the project.

      Project-specific skills follow the same format and are invoked the same way.

      Custom skills are not covered in this reference.

      ","path":["Reference","Skills"],"tags":[]},{"location":"reference/versions/","level":1,"title":"Version History","text":"","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#version-history","level":2,"title":"Version History","text":"

      Documentation snapshots for each release.

      Tap the corresponding view docs to view the docs as they were at that release.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#releases","level":2,"title":"Releases","text":"Version Release Date Documentation v0.8.0 2026-03-23 view docs v0.6.0 2026-02-16 view docs v0.3.0 2026-02-07 view docs v0.2.0 2026-02-01 view docs v0.1.2 2026-01-27 view docs v0.1.1 2026-01-26 view docs v0.1.0 2026-01-25 view docs","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v080-the-architecture-release","level":3,"title":"v0.8.0: The Architecture Release","text":"

      MCP server for tool-agnostic AI integration. Memory bridge connecting Claude Code auto-memory to .context/. Complete CLI restructuring into cmd/ + core/ taxonomy. All user-facing strings externalized to YAML. fatih/color removed; two direct dependencies remain.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v060-the-integration-release","level":3,"title":"v0.6.0: The Integration Release","text":"

      Plugin architecture: hooks and skills converted from shell scripts to Go subcommands, shipped as a Claude Code marketplace plugin. Multi-tool hook generation for Cursor, Aider, Copilot, and Windsurf. Webhook notifications with encrypted URL storage.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v030-the-discipline-release","level":3,"title":"v0.3.0: The Discipline Release","text":"

      Journal static site generation via zensical. 49-skill audit and fix pass (positive framing, phantom reference removal, scope tightening). Context consolidation skill. golangci-lint v2 migration.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v020-the-archaeology-release","level":3,"title":"v0.2.0: The Archaeology Release","text":"

      Session journal system: ctx journal import converts Claude Code JSONL transcripts to browsable Markdown. Constants refactor with semantic prefixes (Dir*, File*, Filename*). CRLF handling for Windows compatibility.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v012","level":3,"title":"v0.1.2","text":"

      Default Claude Code permissions deployed on ctx init. Prompting guide published as a standalone documentation page.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v011","level":3,"title":"v0.1.1","text":"

      Bug fixes: hook schema key format corrected, JSON unicode escaping fixed in context file output.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v010-initial-release","level":3,"title":"v0.1.0: Initial Release","text":"

      CLI with 15 subcommands, 6 context file types (CONSTITUTION, TASKS, CONVENTIONS, ARCHITECTURE, DECISIONS, LEARNINGS), Makefile build system, and Claude Code hook integration.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#latest","level":2,"title":"Latest","text":"

      The main documentation always reflects the latest development version.

      For the most recent stable release, see v0.8.0.

      ","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#changelog","level":2,"title":"Changelog","text":"

      For detailed changes between versions, see the GitHub Releases page.

      ","path":["Reference","Version History"],"tags":[]},{"location":"security/","level":1,"title":"Security","text":"

      Security model, agent hardening, and vulnerability reporting.

      ","path":["Security"],"tags":[]},{"location":"security/#security-design","level":3,"title":"Security Design","text":"

      Trust model, what ctx does for security, permission hygiene, state file management, and the log-first audit trail principle. Read first to understand the security boundaries.

      ","path":["Security"],"tags":[]},{"location":"security/#securing-ai-agents","level":3,"title":"Securing AI Agents","text":"

      Defense in depth for unattended AI agents: five layers of protection, each with a known bypass, strength in combination.

      ","path":["Security"],"tags":[]},{"location":"security/#reporting-vulnerabilities","level":3,"title":"Reporting Vulnerabilities","text":"

      How to report a security issue: email, GitHub private reporting, PGP-encrypted submissions, what to include, and the response timeline.

      ","path":["Security"],"tags":[]},{"location":"security/agent-security/","level":1,"title":"Securing AI Agents","text":"","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#defense-in-depth-securing-ai-agents","level":1,"title":"Defense in Depth: Securing AI Agents","text":"","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#the-problem","level":2,"title":"The Problem","text":"

      An unattended AI agent with unrestricted access to your machine is an unattended shell with unrestricted access to your machine.

      This is not a theoretical concern. AI coding agents execute shell commands, write files, make network requests, and modify project configuration. When running autonomously (overnight, in a loop, without a human watching), the attack surface is the full capability set of the operating system user account.

      The risk is not that the AI is malicious. The risk is that the AI is controllable: it follows instructions from context, and context can be poisoned.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#threat-model","level":2,"title":"Threat Model","text":"","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#how-agents-get-compromised","level":3,"title":"How Agents Get Compromised","text":"

      AI agents follow instructions from multiple sources: system prompts, project files, conversation history, and tool outputs. An attacker who can inject content into any of these sources can redirect the agent's behavior.

      Vector How it works Prompt injection via dependencies A malicious package includes instructions in its README, changelog, or error output. The agent reads these during installation or debugging and follows them. Prompt injection via fetched content The agent fetches a URL (documentation, API response, Stack Overflow answer) containing embedded instructions. Poisoned project files A contributor adds adversarial instructions to CLAUDE.md, .cursorrules, or .context/ files. The agent loads these at session start. Self-modification between iterations In an autonomous loop, the agent modifies its own configuration files. The next iteration loads the modified config with no human review. Tool output injection A command's output (error messages, log lines, file contents) contains instructions the agent interprets and follows.","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#what-can-a-compromised-agent-do","level":3,"title":"What Can a Compromised Agent Do","text":"

      Depends entirely on what permissions and access the agent has:

      Access level Potential impact Unrestricted shell Execute any command, install software, modify system files Network access Exfiltrate source code, credentials, or context files to external servers Docker socket Escape container isolation by spawning privileged sibling containers SSH keys Pivot to other machines, push to remote repositories, access production systems Write access to own config Disable its own guardrails for the next iteration","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#the-defense-layers","level":2,"title":"The Defense Layers","text":"

      No single layer is sufficient. Each layer catches what the others miss.

      Layer 1: Soft instructions     (CONSTITUTION.md, playbook)\nLayer 2: Application controls  (permission allowlist, tool restrictions)\nLayer 3: OS-level isolation    (user accounts, filesystem, containers)\nLayer 4: Network controls      (firewall rules, airgap)\nLayer 5: Infrastructure        (VM isolation, resource limits)\n
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-1-soft-instructions-probabilistic","level":3,"title":"Layer 1: Soft Instructions (Probabilistic)","text":"

      Markdown files like CONSTITUTION.md and the Agent Playbook tell the agent what to do and what not to do. These are probabilistic: the agent usually follows them, but there is no enforcement mechanism.

      What it catches: Most common mistakes. An agent that has been told \"never delete production data\" will usually not delete production data.

      What it misses: Prompt injection. A sufficiently crafted injection can override soft instructions. Long context windows dilute attention on rules stated early. Edge cases where instructions are ambiguous.

      Verdict: Necessary but not sufficient. Good for the common case. Do not rely on it for security boundaries.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-2-application-controls-deterministic-at-runtime-mutable-across-iterations","level":3,"title":"Layer 2: Application Controls (Deterministic at Runtime, Mutable across Iterations)","text":"

      AI tool runtimes (Claude Code, Cursor, etc.) provide permission systems: tool allowlists, command restrictions, confirmation prompts.

      For Claude Code, ctx init writes both an allowlist and an explicit deny list into .claude/settings.local.json. The golden images live in internal/assets/permissions/:

      Allowlist (allow.txt): only these tools run without confirmation:

      Bash(ctx:*)\nSkill(ctx-convention-add)\nSkill(ctx-decision-add)\n... # all bundled ctx-* skills\n

      Deny list (deny.txt): these are blocked even if the agent requests them:

      # Dangerous operations\nBash(sudo *)\nBash(git push *)\nBash(git push)\nBash(rm -rf /*)\nBash(rm -rf ~*)\nBash(curl *)\nBash(wget *)\nBash(chmod 777 *)\n\n# Sensitive file reads\nRead(**/.env)\nRead(**/.env.*)\nRead(**/*credentials*)\nRead(**/*secret*)\nRead(**/*.pem)\nRead(**/*.key)\n\n# Sensitive file edits\nEdit(**/.env)\nEdit(**/.env.*)\n

      What it catches: The agent cannot run commands outside the allowlist, and the deny list blocks dangerous operations even if a future allowlist change were to widen access. If rm, curl, sudo, or docker are not allowed and sudo/curl/wget are explicitly denied, the agent cannot invoke them regardless of what any prompt says.

      What it misses: The agent can modify the allowlist itself. In an autonomous loop, if the agent writes to .claude/settings.local.json, and the next iteration loads the modified config, then the protection is effectively lost. The application enforces the rules, but the application reads the rules from files the agent can write.

      Verdict: Strong first layer. Must be combined with self-modification prevention (Layer 3).

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-3-os-level-isolation-deterministic-and-unbypassable","level":3,"title":"Layer 3: OS-Level Isolation (Deterministic and Unbypassable)","text":"

      The operating system enforces access controls that no application-level trick can override. An unprivileged user cannot read files owned by root. A process without CAP_NET_RAW cannot open raw sockets. These are kernel boundaries.

      Control Purpose Dedicated user account No sudo, no privileged group membership (docker, wheel, adm). The agent cannot escalate privileges. Filesystem permissions Project directory writable; everything else read-only or inaccessible. Agent cannot reach other projects, home directories, or system config. Immutable config files CLAUDE.md, .claude/settings.local.json, and .context/CONSTITUTION.md owned by a different user or marked immutable (chattr +i on Linux). The agent cannot modify its own guardrails.

      What it catches: Privilege escalation, self-modification, lateral movement to other projects or users.

      What it misses: Actions within the agent's legitimate scope. If the agent has write access to source code (which it needs to do its job), it can introduce vulnerabilities in the code itself.

      Verdict: Essential. This is the layer that makes the other layers trustworthy.

      OS-level isolation does not make the agent safe; it makes the other layers meaningful.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-4-network-controls","level":3,"title":"Layer 4: Network Controls","text":"

      An agent that cannot reach the internet cannot exfiltrate data. It also cannot ingest new instructions mid-loop from external documents, API responses, or hostile content.

      Scenario Recommended control Agent does not need the internet --network=none (container) or outbound firewall drop-all Agent needs to fetch dependencies Allow specific registries (npmjs.com, proxy.golang.org, pypi.org) via firewall rules. Block everything else. Agent needs API access Allow specific API endpoints only. Use an HTTP proxy with allowlisting.

      What it catches: Data exfiltration, phone-home payloads, downloading additional tools, and instruction injection via fetched content.

      What it misses: Nothing, if the agent genuinely does not need the network. The tradeoff is that many real workloads need dependency resolution, so a full airgap requires pre-populated caches.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-5-infrastructure-isolation","level":3,"title":"Layer 5: Infrastructure Isolation","text":"

      The strongest boundary is a separate machine (or something that behaves like one).

      The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.

      Containers (Docker, Podman):

      docker run --rm \\\n  --network=none \\\n  --cap-drop=ALL \\\n  --memory=4g \\\n  --cpus=2 \\\n  -v /path/to/project:/workspace \\\n  -w /workspace \\\n  your-dev-image \\\n  ./loop.sh\n

      Docker Socket Is Sudo Access

      Critical: never mount the Docker socket (/var/run/docker.sock).

      An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox.

      Use rootless Docker or Podman to eliminate this escalation path.

      Virtual machines: The strongest isolation. The guest kernel has no visibility into the host OS. No shared folders, no filesystem passthrough, no SSH keys to other machines.

      Resource limits: CPU, memory, and disk quotas prevent a runaway agent from consuming all resources. Use ulimit, cgroup limits, or container resource constraints.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"

      A defense-in-depth setup for overnight autonomous runs:

      Layer Implementation Stops Soft instructions CONSTITUTION.md with \"never delete tests\", \"always run tests before committing\" Common mistakes (probabilistic) Application allowlist .claude/settings.local.json with explicit tool permissions Unauthorized commands (deterministic within runtime) Immutable config chattr +i on CLAUDE.md, .claude/, CONSTITUTION.md Self-modification between iterations Unprivileged user Dedicated user, no sudo, no docker group Privilege escalation Container --cap-drop=ALL --network=none, rootless, no socket mount Host escape, network exfiltration Resource limits --memory=4g --cpus=2, disk quotas Resource exhaustion

      Each layer is straightforward: The strength is in the combination.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#common-mistakes","level":2,"title":"Common Mistakes","text":"

      \"I'll just use --dangerously-skip-permissions\": This disables Layer 2 entirely. Without Layers 3-5, you have no protection at all. Only use this flag inside a properly isolated container or VM.

      \"The agent is sandboxed in Docker\": A Docker container with the Docker socket mounted, running as root, with --privileged, and full network access is not sandboxed. It is a root shell with extra steps.

      \"CONSTITUTION.md says not to do that\": Markdown is a suggestion. It works most of the time. It is not a security boundary. Do not use it as one.

      \"I reviewed the CLAUDE.md, it's fine\": The agent can modify CLAUDE.md during iteration N. Iteration N+1 loads the modified version. Unless the file is immutable, your review is stale.

      \"The agent only has access to this one project\": Does the project directory contain .env files, SSH keys, API tokens, or credentials? Does it have a .git/config with push access to a remote? Filesystem isolation means isolating what is in the directory too.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-security-considerations","level":2,"title":"Team Security Considerations","text":"

      When multiple developers share a .context/ directory, security considerations extend beyond single-agent hardening.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#code-review-for-context-files","level":3,"title":"Code Review for Context Files","text":"

      Treat .context/ changes like code changes. Context files influence agent behavior (a modified CONSTITUTION.md or CONVENTIONS.md changes what every agent on the team will do next session). Review them in PRs with the same scrutiny you apply to production code.

      Watch for:

      • Weakened constitutional rules (removed constraints, softened language)
      • New decisions that contradict existing ones without acknowledging it
      • Learnings that encode incorrect assumptions
      • Task additions that bypass the team's prioritization process
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#gitignore-patterns","level":3,"title":"Gitignore Patterns","text":"

      ctx init configures .gitignore automatically, but verify these patterns are in place:

      • Always gitignored: .ctx.key (encryption key), .context/logs/, .context/journal/
      • Team decision: scratchpad.enc (encrypted, safe to commit for shared scratchpad state); .gitignore if scratchpads are personal
      • Never committed: .env, credentials, API keys (enforced by drift secret detection)
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#multi-developer-context-sharing","level":3,"title":"Multi-Developer Context Sharing","text":"

      CONSTITUTION.md is the shared contract. All team members and their agents inherit it. Changes require team consensus, not unilateral edits.

      When multiple agents write to the same context files concurrently (e.g., two developers adding learnings simultaneously), git merge conflicts are expected. Resolution is typically additive: accept both additions. Destructive resolution (dropping one side) loses context.

      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-conventions-for-context-management","level":3,"title":"Team Conventions for Context Management","text":"

      Establish and document:

      • Who reviews context changes: Same reviewers as code, or a designated context owner?
      • How to resolve conflicting decisions: If two sessions record contradictory decisions, which wins? Default: the later one must explicitly supersede the earlier one with rationale.
      • Frequency of context maintenance: Weekly ctx drift checks, monthly consolidation passes, archival after each milestone.
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#checklist","level":2,"title":"Checklist","text":"

      Before running an unattended AI agent:

      • Agent runs as a dedicated unprivileged user (no sudo, no docker group)
      • Agent's config files are immutable or owned by a different user
      • Permission allowlist restricts tools to the project's toolchain
      • Container drops all capabilities (--cap-drop=ALL)
      • Docker socket is NOT mounted
      • Network is disabled or restricted to specific domains
      • Resource limits are set (memory, CPU, disk)
      • No SSH keys, API tokens, or credentials are accessible to the agent
      • Project directory does not contain .env or secrets files
      • Iteration cap is set (--max-iterations)
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#further-reading","level":2,"title":"Further Reading","text":"
      • Running an Unattended AI Agent: the ctx recipe for autonomous loops, including step-by-step permissions and isolation setup
      • Security: ctx's own trust model and vulnerability reporting
      • Autonomous Loops: full documentation of the loop pattern, prompt templates, and troubleshooting
      ","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/design/","level":1,"title":"Security Design","text":"

      How ctx thinks about security: trust boundaries, what the system does and does not do for you, the engineering principle behind the audit trail, and the permission hygiene workflow.

      For vulnerability disclosure, see Reporting Vulnerabilities.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#trust-model","level":2,"title":"Trust Model","text":"

      ctx operates within a single trust boundary: the local filesystem.

      The person who authors .context/ files is the same person who runs the agent that reads them. There is no remote input, no shared state, and no server component.

      This means:

      • ctx does not sanitize context files for prompt injection. This is a deliberate design choice, not an oversight. The files are authored by the developer who owns the machine: sanitizing their own instructions back to them would be counterproductive.
      • If you place adversarial instructions in your own .context/ files, your agent will follow them. This is expected behavior. You control the context; the agent trusts it.

      Shared Repositories

      In shared repositories, .context/ files should be reviewed in code review (the same way you would review CI/CD config or Makefiles). A malicious contributor could add harmful instructions to CONSTITUTION.md or TASKS.md.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#what-ctx-does-for-security","level":2,"title":"What ctx Does for Security","text":"

      ctx is designed with security in mind:

      • No secrets in context: The constitution explicitly forbids storing secrets, tokens, API keys, or credentials in .context/ files.
      • Local only: ctx runs entirely locally with no external network calls.
      • No code execution: ctx reads and writes Markdown files only; it does not execute arbitrary code.
      • Git-tracked: Core context files are meant to be committed, so they should never contain sensitive data. Exception: sessions/ and journal/ contain raw conversation data and should be gitignored.
      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#permission-hygiene","level":2,"title":"Permission Hygiene","text":"

      Claude Code evaluates permissions in deny → ask → allow order. ctx init automatically populates permissions.deny with rules that block dangerous operations before the allow list is ever consulted.

      Default deny rules block:

      • sudo, git push, rm -rf /, rm -rf ~, curl, wget, chmod 777
      • Read / Edit of .env, credentials, secrets, .pem, .key files

      Even with deny rules in place, the allow list accumulates one-off permissions over time. Periodically review for:

      • Destructive commands: git reset --hard, git clean -f, etc.
      • Config injection vectors: permissions that allow modifying files controlling agent behavior (CLAUDE.md, settings.local.json).
      • Broad wildcards: overly permissive patterns that pre-approve more than intended.

      For the full hygiene workflow, see the Claude Code Permission Hygiene recipe.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#state-file-management","level":2,"title":"State File Management","text":"

      Hook state files (throttle markers, prompt counters, pause markers) are stored in .context/state/, which is project-scoped and gitignored. State files are automatically managed by the hooks that create them; no manual cleanup is needed.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#log-first-audit-trail","level":2,"title":"Log-First Audit Trail","text":"

      The event log (.context/state/events.jsonl) is the authoritative record of what ctx hooks did during a session. Several audit-adjacent features depend on that log being trustworthy, not merely best-effort:

      • ctx event / ctx system view-events replays session history from the log.
      • Webhook notifications give operators a real-time signal that assumes every notification corresponds to a logged event.
      • Drift, freshness, and map-staleness checks count events over time and surface regressions.

      A log that silently drops entries while the rest of the system claims success is worse than no log at all: operators see a green TUI and a webhook notification and conclude \"it happened,\" even when the audit trail never landed. The codebase treats this as a correctness problem, not a UX polish problem.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#the-rule","level":3,"title":"The Rule","text":"

      Any code path that emits an observable side effect (webhook, stdout marker, throttle-file touch, state mutation) must append the corresponding event-log entry first and gate the side effect on the append succeeding. If the log write fails, the side effect must not fire.

      In code, this shape:

      if appendErr := event.Append(channel, msg, sessionID, ref); appendErr != nil {\n    return appendErr // do NOT send the webhook or touch the marker\n}\nif sendErr := notify.Send(channel, msg, sessionID, ref); sendErr != nil {\n    return sendErr\n}\n// downstream side effects (marker touch, stdout, etc.)\n

      The nudge.Relay helper in internal/cli/system/core/nudge enforces this for the common \"log + webhook\" pair. Hook Run functions that compose their own sequence (session_event, heartbeat, several check_* hooks) follow the same ordering explicitly.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#known-gaps","level":3,"title":"Known Gaps","text":"
      • Nudge webhooks have no log channel. nudge.EmitAndRelay sends a \"nudge\" notification before the \"relay\" event is logged. The nudge leg is fire-and-forget because no event-log channel records nudges today. A future refactor may add one; until then this is the one documented exception.
      • ctx agent --cooldown and ctx doctor propagate rather than gate. They surface real errors to the caller (usually Cobra) rather than deciding what to do with them locally. Editors that invoke these commands may display errors in an ugly way; the ugliness is the correct signal (something persisted is broken), not a defect to smooth over.
      • Verbose hook logs in core/log.Message stay best-effort. That logger captures per-hook activity (how many prompts, which percent, etc.) for debugging; it is NOT the event audit trail. Its failures go to stderr via log/warn.Warn rather than propagating, because losing an operational log line is not a correctness problem.
      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#background","level":3,"title":"Background","text":"

      The error returns on event.Append, io.AppendBytes, nudge.Relay, and cooldown.Active / cooldown.TouchTombstone were introduced as part of the resolver-tightening refactor. Before that change, most hook paths called these helpers and silently discarded their errors. The principle above was extracted from the observation that every user-visible correctness problem hit during the refactor traced back to some function saying \"this succeeded\" when the underlying write never landed.

      ","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#best-practices","level":2,"title":"Best Practices","text":"
      1. Review before committing: Always review .context/ files before committing.
      2. Use .gitignore: If you must store sensitive notes locally, add them to .gitignore.
      3. Drift detection: Run ctx drift to check for potential issues.
      4. Permission audit: Review .claude/settings.local.json after busy sessions.
      ","path":["Security","Security Design"],"tags":[]},{"location":"security/hub/","level":1,"title":"Hub Security Model","text":"","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#ctx-hub-security-model","level":1,"title":"ctx Hub: Security Model","text":"

      What the hub defends against, what it does not defend against, and the concrete mechanisms in play.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#threat-model","level":2,"title":"Threat Model","text":"

      The hub is designed for trusted cross-project knowledge sharing within a team or homelab. It assumes:

      • The hub host is trusted. Anyone with root on that box can read every entry ever published.
      • Network is semi-trusted. Hub traffic is gRPC over TCP; TLS is strongly recommended but not mandatory.
      • Client machines are trusted enough to hold a per-project client token. Losing a client token is roughly equivalent to losing an API key: scoped damage, not total compromise.
      • Entry content is not secret. Decisions, learnings, and conventions may be indexed by AI agents, rendered in docs, shared across projects. Do not push credentials or PII into the hub.

      The hub is not a secure messaging system, a secrets store, or a compliance-grade audit log. If your threat model needs those, use a dedicated tool and keep the hub for knowledge sharing.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#mechanisms","level":2,"title":"Mechanisms","text":"","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#bearer-tokens","level":3,"title":"Bearer Tokens","text":"

      All RPCs except Register require a bearer token in gRPC metadata. Two kinds of tokens exist:

      Kind Format Scope Lifetime Admin token ctx_adm_... Register new projects Manual rotate Client token ctx_cli_... Publish, Sync, Listen, Status Project lifetime

      Tokens are compared in constant time (crypto/subtle) to prevent timing oracles, and looked up via an O(1) hash map so the comparison cost does not depend on the total number of registered clients.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#client-side-encryption-at-rest","level":3,"title":"Client-Side Encryption at Rest","text":"

      .context/.connect.enc stores the client token and hub address, encrypted with AES-256-GCM using the same scheme the notification subsystem uses. The key is derived from ctx's local keyring (see internal/crypto).

      An attacker with read access to the project directory cannot learn the client token without also breaking ctx's local keyring.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#hub-side-token-storage","level":3,"title":"Hub-Side Token Storage","text":"

      Tokens Are Stored in Plaintext on the Hub Host

      <data-dir>/clients.json currently stores client tokens verbatim, not hashed. Anyone with read access to the hub's data directory sees every registered client's token and can impersonate any project that has ever registered.

      Mitigations today:

      • Run the hub as an unprivileged user and lock the data directory with chmod 700 <data-dir>.
      • Use the systemd unit in Operations, which enables ProtectSystem=strict, NoNewPrivileges=true, and a dedicated user.
      • Never expose <data-dir> over NFS, SMB, or shared filesystems.
      • Treat <data-dir> the same way you'd treat /etc/shadow: back it up encrypted, never check it into version control.

      Hashing clients.json and moving to keyring-backed storage is tracked as a follow-up in the PR #60 task group. Until that lands, assume a hub host compromise equals total hub compromise.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#input-validation","level":3,"title":"Input Validation","text":"

      Every published entry is validated before it touches the log:

      • Type must be one of: decision, learning, convention, task. Unknown types are rejected.
      • ID and Origin are required and non-empty.
      • Content size is capped at 1 MB. Reasonable for text, hostile for attempts to fill the disk.
      • Duplicate project registration is rejected; a client that replays an old Register call gets an error, not a second token.
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#no-script-execution","level":3,"title":"No Script Execution","text":"

      The hub never interprets entry content. There is no expression language, no template evaluation, no markdown rendering at ingest. Content is stored as bytes and fanned out to clients verbatim.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#audit-trail","level":3,"title":"Audit Trail","text":"

      entries.jsonl is append-only. Every accepted publish is recorded with the publishing project's origin tag and sequence number. Nothing is ever deleted by the hub; retention is managed manually by the operator (see log rotation).

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#what-the-hub-does-not-defend-against","level":2,"title":"What the Hub Does Not Defend Against","text":"
      • Untrusted entry senders. A client with a valid token can publish anything (within the 1 MB cap). There is no content validation beyond shape.
      • Denial of service from a registered client. A misbehaving client can publish until disk is full. Monitor entries.jsonl growth.
      • Network eavesdropping without TLS. Plain gRPC leaks entry content and tokens. Use a TLS-terminating reverse proxy (see Multi-machine recipe).
      • Host compromise. Root on the hub host = access to every entry and every token. Harden the host.
      • Accidental secret upload. The hub will happily fan out a decision containing an API key. Sanitize content before publishing.
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#operational-hardening-checklist","level":2,"title":"Operational Hardening Checklist","text":"
      • Run the hub as an unprivileged user with NoNewPrivileges=true and ProtectSystem=strict (see the systemd unit in Operations).
      • Terminate TLS in front of the hub for anything beyond a trusted LAN.
      • Restrict the listen port with firewall rules to the client subnet only.
      • Back up <data-dir>/admin.token to a secrets manager; do not leave it in shell history.
      • Rotate the admin token when a team member with access leaves. Client tokens keep working across rotations.
      • Monitor entries.jsonl growth; alert on sudden spikes.
      • Run NTP on all clients to prevent entry-timestamp skew.
      • Do not publish from machines you do not trust.
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#responsible-disclosure","level":2,"title":"Responsible Disclosure","text":"

      Security issues in the hub follow the same process as the rest of ctx; see Reporting.

      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#see-also","level":2,"title":"See Also","text":"
      • ctx Hub Operations
      • ctx Hub failure modes
      • HA cluster recipe
      ","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/reporting/","level":1,"title":"Reporting Vulnerabilities","text":"

      Disclosure process for security issues in ctx. For the broader security model (trust boundaries, audit trail, permission hygiene), see Security Design.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#reporting-vulnerabilities","level":2,"title":"Reporting Vulnerabilities","text":"

      At ctx we take security very seriously.

      If you discover a security vulnerability in ctx, please report it responsibly.

      Do NOT open a public issue for security vulnerabilities.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#email","level":3,"title":"Email","text":"

      Send details to security@ctx.ist.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#github-private-reporting","level":3,"title":"GitHub Private Reporting","text":"
      1. Go to the Security tab;
      2. Click \"Report a Vulnerability\";
      3. Provide a detailed description.
      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#encrypted-reports-optional","level":3,"title":"Encrypted Reports (Optional)","text":"

      If your report contains sensitive details (proof-of-concept exploits, credentials, or internal system information), you can encrypt your message with our PGP key:

      • In-repo: SECURITY_KEY.asc
      • Keybase: keybase.io/alekhinejose
      # Import the key\ngpg --import SECURITY_KEY.asc\n\n# Encrypt your report\ngpg --armor --encrypt --recipient security@ctx.ist report.txt\n

      Encryption is optional. Unencrypted reports to security@ctx.ist or via GitHub Private Reporting are perfectly fine.

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#what-to-include","level":3,"title":"What to Include","text":"
      • Description of the vulnerability,
      • Steps to reproduce,
      • Potential impact,
      • Suggested fix (if any).
      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#attribution","level":2,"title":"Attribution","text":"

      We appreciate responsible disclosure and will acknowledge security researchers who report valid vulnerabilities (unless they prefer to remain anonymous).

      ","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#response-timeline","level":2,"title":"Response Timeline","text":"

      Open Source, Best-Effort Timelines

      ctx is a volunteer-maintained open source project.

      The timelines below are guidelines, not guarantees, and depend on contributor availability.

      We will address security reports on a best-effort basis and prioritize them by severity.

      Stage Timeframe Acknowledgment Within 48 hours Initial assessment Within 7 days Resolution target Within 30 days (depending on severity)","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"thesis/","level":1,"title":"Context as State","text":"","path":["The Thesis"],"tags":[]},{"location":"thesis/#a-persistence-layer-for-human-ai-cognition","level":2,"title":"A Persistence Layer for Human-AI Cognition","text":"

      Volkan Özçelik - me@volkan.io

      February 2026

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#abstract","level":3,"title":"Abstract","text":"

      As AI tools evolve from code-completion utilities into reasoning collaborators, the knowledge that governs their behavior becomes as important as the code they produce; yet, that knowledge is routinely discarded at the end of every session.

      AI-assisted development systems assemble context at prompt time using heuristic retrieval from mutable sources: recent files, semantic search results, session history. These approaches optimize relevance at the moment of generation but do not persist the cognitive state that produced decisions. Reasoning is not reproducible, intent is lost across sessions, and teams cannot audit the knowledge that constrains automated behavior.

      This paper argues that context should be treated as deterministic, version-controlled state rather than as a transient query result. We ground this argument in three sources of evidence: a landscape analysis of 17 systems spanning AI coding assistants, agent frameworks, and knowledge stores; a taxonomy of five primitive categories that reveals irrecoverable architectural trade-offs; and an experience report from ctx, a persistence layer for AI-assisted development, which developed itself using its own persistence model across 389 sessions over 33 days. We define a three-tier model for cognitive state: authoritative knowledge, delivery views, and ephemeral state. Then we present six design invariants empirically validated by 56 independent rejection decisions observed across the analyzed landscape. We show that context determinism applies to assembly, not to model output, and that the curation cost this model requires is offset by compounding returns in reproducibility, auditability, and team cognition.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#1-introduction","level":2,"title":"1. Introduction","text":"

      The introduction of large language models into software development has shifted the primary interface from code execution to interactive reasoning. In this environment, the correctness of an output depends not only on source code but on the context supplied to the model: the conventions, decisions, architectural constraints, and domain knowledge that bound the space of acceptable responses.

      Current systems treat context as a query result assembled at the moment of interaction. A developer begins a session; the tool retrieves what it estimates to be relevant from chat history, recent files, and vector stores; the model generates output conditioned on this transient assembly; the session ends, and the context evaporates. The next session begins the cycle again.

      This model has improved substantially over the past year. CLAUDE.md files, Cursor rules, Copilot's memory system, and tools such as Mem0, Letta, and Kindex each address aspects of the persistence problem. Yet across 17 systems we analyzed spanning AI coding assistants, agent frameworks, autonomous coding agents, and purpose-built knowledge stores, no system provides all five of the following properties simultaneously: deterministic context assembly, human-readable file-based persistence, token-budgeted delivery, a single-binary core with zero required runtime dependencies for the persistence path, and local-first operation.

      This paper does not propose a universal replacement for retrieval-centric workflows. It defines a persistence layer (embodied in ctx (https://ctx.ist)) whose advantages emerge under specific operational conditions: when reproducibility is a requirement, when knowledge must outlive sessions and individuals, when teams require shared cognitive authority, or when offline operation is necessary.

      The trade-offs (manual curation cost, reduced automatic recall, coarser granularity) are intentional and mirror the trade-offs accepted by systems that favor reproducibility over convenience, such as reproducible builds and immutable infrastructure 1 6.

      The contribution is threefold: a three-tier model for cognitive state that resolves the ambiguity between authoritative knowledge and ephemeral session artifacts; six design invariants empirically grounded in a cross-system landscape analysis; and an experience report demonstrating that the model produces compounding returns when applied to its own development.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#2-the-limits-of-prompt-time-context","level":2,"title":"2. The Limits of Prompt-Time Context","text":"

      Prompt-time assembly pipelines typically consist of corpus selection, retrieval, ranking, and truncation. These pipelines are probabilistic and time-dependent, producing three failure modes that compound over the lifetime of a project.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#21-non-reproducibility","level":3,"title":"2.1 Non-Reproducibility","text":"

      If context is derived from mutable sources using heuristic ranking, identical requests at different times receive different inputs. A developer who asks \"What is our authentication strategy?\" on Tuesday may receive a different context window than the same question on Thursday: Not because the strategy changed, but because the retrieval heuristic surfaced different fragments.

      Reproducibility (the ability to reconstruct the exact inputs that produced a given output) is a foundational property of reliable systems. Its loss in AI-assisted development mirrors the historical evolution from ad-hoc builds to deterministic build systems 1 2. The build community learned that when outputs depend on implicit state (environment variables, system clocks, network-fetched dependencies), debugging becomes archaeology. The same principle applies when AI outputs depend on non-deterministic context retrieval.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#22-opaque-knowledge","level":3,"title":"2.2 Opaque Knowledge","text":"

      Embedding-based memory increases recall but reduces inspectability. When a vector store determines that a code snippet is \"similar\" to the current query, the ranking function is opaque: the developer cannot inspect why that snippet was chosen, whether a more relevant artifact was excluded, or whether the ranking will remain stable. This prevents deterministic debugging, policy auditing, and causal attribution (properties that information retrieval theory identifies as fundamental trade-offs of probabilistic ranking) 3.

      In practice, this opacity manifests as a compliance ceiling. In our experience developing a context management system (detailed in Section 7), soft instructions (directives that ask an AI agent to read specific files or follow specific procedures) achieve approximately 75-85% compliance. The remaining 15-25% represents cases where the agent exercises judgment about whether the instruction applies, effectively applying a second ranking function on top of the explicit directive. When 100% compliance is required, instruction is insufficient; the content must be injected directly, removing the agent's option to skip it.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#23-loss-of-intent","level":3,"title":"2.3 Loss of Intent","text":"

      Session transcripts record interaction but not cognition. A transcript captures what was said but not which assumptions were accepted, which alternatives were rejected, or which constraints governed the decision. The distinction matters: a decision to use PostgreSQL recorded as a one-line note (\"Use PostgreSQL\") teaches a model what was decided; a structured record with context, rationale, and consequences teaches it why (and why is what prevents the model from unknowingly reversing the decision in a future session) 4.

      Session transcripts provide history. Cognitive state requires something more: the persistent, structured representation of the knowledge required for correct decision-making.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#3-cognitive-state-a-three-tier-model","level":2,"title":"3. Cognitive State: A Three-Tier Model","text":"","path":["The Thesis"],"tags":[]},{"location":"thesis/#31-definitions","level":3,"title":"3.1 Definitions","text":"

      We define cognitive state as the authoritative, persistent representation of the knowledge required for correct decision-making within a project. It is human-authored or human-ratified, versioned, inspectable, and reproducible. It is distinct from logs, transcripts, retrieval results, and model-generated summaries.

      Previous formulations of this idea have treated cognitive state as a monolithic concept. In practice, a three-tier model better captures the operational reality:

      Tier 1: Authoritative State: The canonical knowledge that the system treats as ground truth. In a concrete implementation, this corresponds to a set of human-curated files with defined schemas: a constitution (inviolable rules), conventions (code patterns), an architecture document (system structure), decision records (choices with rationale), learnings (captured experience), a task list (current work), a glossary (domain terminology), and an agent playbook (operating instructions). Each file has a single purpose, a defined lifecycle, and a distinct update frequency. Authoritative state is version-controlled alongside code and reviewed through the same mechanisms (diffs, pull requests, blame annotations).

      Tier 2: Delivery Views: Derived representations of authoritative state, assembled for consumption by a model. A delivery view is produced by a deterministic assembly function that takes the authoritative state, a token budget, and an inclusion policy as inputs and produces a context window as output. The same authoritative state, budget, and policy must always produce the same delivery view. Delivery views are ephemeral (they exist only for the duration of a session), but their construction is reproducible.

      Tier 3: Ephemeral State: Session transcripts, scratchpad notes, draft journal entries, and other artifacts that exist during or immediately after a session but are not authoritative. Ephemeral state is the raw material from which authoritative state may be extracted through human review, but it is never consumed directly by the assembly function.

      This three-tier model resolves confusion present in earlier formulations: the claim that AI output is a deterministic function of the repository state. The corrected claim is that context selection is deterministic (the delivery view is a function of authoritative state), but model output remains stochastic, conditioned on the deterministic context. Formally:

      delivery_view = assemble(authoritative_state, budget, policy)\noutput = model(delivery_view)   # stochastic\n

      The persistence layer's contribution is making assemble reproducible, not making model deterministic.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#32-separation-of-concerns","level":3,"title":"3.2 Separation of Concerns","text":"

      The decision to separate authoritative state into distinct files with distinct purposes is not cosmetic. Different types of knowledge have different lifecycles:

      Knowledge Type Update Frequency Read Frequency Load Priority Example Constitution Rarely Every session Always \"Never commit secrets to git\" Tasks Every session Session start Always \"Implement token budget CLI flag\" Conventions Weekly Before coding High \"All errors use structured logging with severity levels\" Decisions When decided When questioning Medium \"Use PostgreSQL over MySQL (see ADR-003)\" Learnings When learned When stuck Medium \"Hook scripts >50ms degrade interactive UX\" Architecture When changed When designing On demand \"Three-layer pipeline: ingest → enrich → assemble\" Journal Every session Rarely Never auto \"Session 247: Removed dead-end session copy layer\"

      A monolithic context file would force the assembly function to load everything or nothing. Separation enables progressive disclosure: the minimum context that matters for the current moment, with the option to load more when needed. A normal session loads the constitution, tasks, and conventions; a deep investigation loads decision history and journal entries from specific dates.

      The budget mechanism is the constraint that makes separation valuable. Without a budget, the default behavior is to load everything, which destroys the attention density that makes loaded context useful. With a budget, the assembly function must prioritize ruthlessly: constitution first (always full), then tasks and conventions (budget-capped), then decisions and learnings (scored by recency). Entries that do not fit receive title-only summaries rather than being silently dropped (an application of the \"tell me what you don't know\" pattern identified independently by four systems in our landscape analysis).

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#4-design-invariants","level":2,"title":"4. Design Invariants","text":"

      The following six invariants define the constraints that a cognitive state persistence layer must satisfy. They are not axioms chosen a priori; they are empirically grounded properties whose violation was independently identified as producing complexity costs across the 17 systems we analyzed.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-1-markdown-on-filesystem-persistence","level":3,"title":"Invariant 1: Markdown-on-Filesystem Persistence","text":"

      Context files must be human-readable, git-diffable, and editable with any text editor. No database. No binary storage.

      Validation: 11 independent rejection decisions across the analyzed landscape protected this property. Systems that adopted embedded records, binary serialization, or knowledge graphs as their core primitive consistently traded away the ability for a developer to run cat DECISIONS.md and understand the system's knowledge. The inspection cost of opaque storage compounds over the lifetime of a project: every debugging session, every audit, every onboarding conversation requires specialized tooling to access knowledge that could have been a text file.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-2-zero-runtime-dependencies","level":3,"title":"Invariant 2: Zero Runtime Dependencies","text":"

      The tool must work with no installed runtimes, no running services, and no API keys for core functionality.

      Validation: 13 independent rejection decisions protected this property (the most frequently defended invariant). Systems that required databases (PostgreSQL, SQLite, Redis), embedding models, server daemons, container runtimes, or cloud APIs for core operation introduced failure modes proportional to their dependency count. A persistence layer that depends on infrastructure is not a persistence layer; it is a service. Services have uptime requirements, version compatibility matrices, and operational costs that simple file operations do not.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-3-deterministic-context-assembly","level":3,"title":"Invariant 3: Deterministic Context Assembly","text":"

      The same files plus the same budget must produce the same output. No embedding-based retrieval, no LLM-driven selection, no wall-clock-dependent scoring in the assembly path.

      Validation: 6 independent rejection decisions protected this property. Non-deterministic assembly (whether from embedding variance, LLM-based selection, or time-dependent scoring) destroys the ability to reproduce a context window and therefore to diagnose why a model produced a given output. Determinism in the assembly path is what makes the persistence layer auditable.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-4-human-authority-over-persistent-state","level":3,"title":"Invariant 4: Human Authority over Persistent State","text":"

      The agent may propose changes to context files but must not unilaterally modify them. All persistent changes go through human-reviewable git commits.

      Validation: 6 independent rejection decisions protected this property. Systems that allowed agents to self-modify their memory (writing freeform notes, auto-pruning old entries, generating summaries as ground truth) consistently produced lower-quality persistent context than systems that enforced human review. Structure is a feature, not a limitation: across the landscape, the pattern \"structured beats freeform\" was independently discovered by four systems that evolved from freeform LLM summaries to typed schemas with required fields.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-5-local-first-air-gap-capable","level":3,"title":"Invariant 5: Local-First, Air-Gap Capable","text":"

      Core functionality must work offline with no network access. Cloud services may be used for optional features but never for core context management.

      Validation: 7 independent rejection decisions protected this property. Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or disaster-recovery scenarios. A filesystem-native model continues to function under all conditions where the repository is accessible.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-6-no-default-telemetry","level":3,"title":"Invariant 6: No Default Telemetry","text":"

      Any analytics, if ever added, must be strictly opt-in.

      Validation: 4 independent rejection decisions protected this property. Default telemetry erodes the trust model that a persistence layer depends on. If developers must trust the system with their architectural decisions, operational learnings, and project constraints, the system cannot simultaneously be reporting usage data to external services.

      These six invariants collectively define a design space. Each feature proposal can be evaluated against them: a feature that violates any invariant is rejected regardless of how many other systems implement it. The discipline of constraint (refusing to add capabilities that compromise foundational properties) is itself an architectural contribution. Across the 17 analyzed systems, 56 patterns were explicitly rejected for violating these invariants. The rejection count per invariant (11, 13, 6, 6, 7, 4) provides a rough measure of each property's vulnerability to architectural erosion. A representative sample of these rejections is provided in Appendix A.1

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#5-landscape-analysis","level":2,"title":"5. Landscape Analysis","text":"

      The 17 systems were selected to cover the architectural design space rather than to achieve completeness. Each included system satisfies three criteria: it represents a distinct architectural primitive for AI-assisted development, it is actively maintained or widely referenced, and it provides sufficient public documentation or source code for architectural inspection. The goal was to ensure that every major category of primitive (document, embedded record, state snapshot, event/message, construction/derivation) was represented by multiple systems, enabling cross-system pattern detection.

      The resulting set spans six categories: AI coding assistants (Continue, Sourcegraph/Cody, Aider, Claude Code), AI agent frameworks (CrewAI, AutoGen, LangGraph, LlamaIndex, Letta/MemGPT), autonomous coding agents (OpenHands, Sweep), session provenance tools (Entire), data versioning systems (Dolt, Pachyderm), pipeline/build systems (Dagger), and purpose-built knowledge stores (QubicDB, Kindex). Each system was analyzed from its source code and documentation, producing 34 individual analysis artifacts (an architectural profile and a set of insights per system) that yielded 87 adopt/adapt recommendations, 56 explicit rejection decisions, and 52 watch items.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#51-primitive-taxonomy","level":3,"title":"5.1 Primitive Taxonomy","text":"

      Every system in the AI-assisted development landscape operates on a core primitive: an atomic unit around which the entire architecture revolves. Our analysis of 17 systems reveals five categories of primitives, each making irrecoverable trade-offs:

      Group A: Document/File Primitives: Human-readable documents as the primary unit. Documents are authored by humans, version-controlled in git, and consumed by AI tools. The invariant of this group is that the primitive is always human-readable and version-controllable with standard tools. Three systems participate in this pattern: the system described in this paper as a pure expression, and Continue (via its rules directory) and Claude Code (via CLAUDE.md files) as partial participants: both use document-based context as an input but organize around different core primitives.

      Group B: Embedded Record Primitives: Vector-embedded records stored with numerical embeddings for similarity search, metadata for filtering, and scoring mechanisms for ranking. Five systems use this approach (LlamaIndex, CrewAI, Letta/MemGPT, QubicDB, Kindex). The invariant is that the primitive requires an embedding model or vector database for core operations: a dependency that precludes offline and air-gapped use.

      Group C: State Snapshot Primitives: Point-in-time captures of the complete system state. The invariant is that any past state can be reconstructed at any historical point. Three systems use this approach (LangGraph, Entire, Dolt).

      Group D: Event/Message Primitives: Sequential events or messages forming an append-only log with causal relationships. Four systems use this approach (OpenHands, AutoGen, Claude Code, Sweep). The invariant is temporal ordering and append-only semantics.

      Group E: Construction/Derivation Primitives: Derived or constructed values that encode how they were produced. The invariant is that the primitive is a function of its inputs; re-executing the same inputs produces the same primitive. Three systems use this approach (Dagger, Pachyderm, Aider).

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#52-comparison-matrix","level":3,"title":"5.2 Comparison Matrix","text":"

      The five primitive categories differ along seven dimensions:

      Property Document Embedded Record State Snapshot Event/Message Construction Human-readable Yes No Varies Partially No Version-controllable Yes No Varies Yes Yes Queryable by meaning No Yes No No No Rewindable Via git No Yes Yes (replay) Yes Deterministic Yes No Yes Yes Yes Zero-dependency Yes No Varies Varies Varies Offline-capable Yes No Varies Varies Yes

      The document primitive is the only one that simultaneously satisfies human-readability, version-controllability, determinism, zero dependencies, and offline capability. This is not because documents are superior in general (embedded records provide semantic queryability that documents lack) but because the combination of all five properties is what the persistence layer requires. The choice between primitive categories is not a matter of capability but of which properties are considered invariant.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#53-convergent-patterns","level":3,"title":"5.3 Convergent Patterns","text":"

      Across the 17 analyzed systems, six design patterns were independently discovered. These convergent patterns carry extra validation weight because they emerged from different problem spaces:

      Pattern 1: \"Tell me what you don't know\": When context is incomplete, explicitly communicate to the model what information is missing and what confidence level the provided context represents. Four systems independently converged on this pattern: inserting skip markers, tracking evidence gaps, annotating provenance, or naming output quality tiers.

      Pattern 2: \"Freshness matters\": Information relevance decreases over time. Three systems independently chose exponential decay with different half-lives (30 days, 90 days, and LRU ordering). Static priority ordering with no time dimension leaves relevant recent knowledge at the same priority as stale entries. This pattern is in productive tension with the persistence model's emphasis on determinism: the claim is not that time-dependence is irrelevant, but that it belongs in the curation step (a human deciding to consolidate or archive stale entries) rather than in the assembly function (an algorithm silently down-ranking entries based on age).

      Pattern 3: \"Content-address everything\": Compute a hash of content at creation time for deduplication, cache invalidation, integrity verification, and change detection. Five systems independently implement content hashing, each discovering it solves different problems 5.

      Pattern 4: \"Structured beats freeform\": When capturing knowledge or session state, a structured schema with required fields produces more useful data than freeform text. Four systems evolved from freeform summaries to typed schemas: one moving from LLM-generated prose to a structured condenser with explicit fields for completed tasks, pending tasks, and files modified.

      Pattern 5: \"Protocol convergence\": The Model Context Protocol (MCP) is emerging as a standard tool integration layer. Nine of 17 systems support it, spanning every category in the analysis. MCP's significance for the persistence model is that it provides a transport mechanism for context delivery without dictating how context is stored or assembled. This makes the approach compatible with both retrieval-centric and persistence-centric architectures.

      Pattern 6: \"Human-in-the-loop for memory\": Critical memory decisions should involve human judgment. Fully automated memory management produces lower-quality persistent context than human-reviewed systems. Four systems independently converged on variants of this pattern: ceremony-based consolidation, interrupt/resume for human input, confirmation mode for high-risk actions, and separated \"think fast\" vs. \"think slow\" processing paths.

      Pattern 6 directly validates the ceremony model described in this paper. The persistence layer requires human curation not because automation is impossible, but because the quality of persistent knowledge degrades when the curation step is removed. The improvement opportunity is to make curation easier, not to automate it away.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#6-worked-example-architectural-decision-under-two-models","level":2,"title":"6. Worked Example: Architectural Decision under Two Models","text":"

      We now instantiate the three-tier model in a concrete system (ctx) and illustrate the difference between prompt-time retrieval and cognitive state persistence using a real scenario from its development.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#61-the-problem","level":3,"title":"6.1 The Problem","text":"

      During development, the system accumulated three overlapping storage layers for session data: raw transcripts (owned by the AI tool), session copies (JSONL copies plus context snapshots), and enriched journal entries (Markdown summaries). The middle layer (session copies) was a dead-end write sink. An auto-save hook copied transcripts to a directory that nothing read from, because the journal pipeline already read directly from the raw transcripts. Approximately 15 source files, a shell hook, 20 configuration constants, and 30 documentation references supported infrastructure with no consumers.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#62-prompt-time-retrieval-model","level":3,"title":"6.2 Prompt-Time Retrieval Model","text":"

      In a retrieval-based system, the decision to remove the middle layer depends on whether the retrieval function surfaces the relevant context:

      The developer asks: \"Should we simplify the session storage?\" The retrieval system must find and rank the original discussion thread where the three layers were designed, the usage statistics showing zero reads from the middle layer, the journal pipeline documentation showing it reads from raw transcripts directly, and the dependency analysis showing 15 files, a hook, and 30 doc references. If any of these fragments are not retrieved (because they are in old chat history, because the embedding similarity score is low, or because the token budget was consumed by more recent but less relevant context), the model may recommend preserving the middle layer, or may not realize it exists.

      Six months later, a new team member asks the same question. The retrieval results will differ: the original discussion has aged out of recency scoring, the usage statistics are no longer in recent history, and the model may re-derive the answer or arrive at a different conclusion.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#63-cognitive-state-model","level":3,"title":"6.3 Cognitive State Model","text":"

      In the persistence model, the decision is recorded as a structured artifact at write time:

      ## [2026-02-11] Remove .context/sessions/ storage layer\n\n**Status**: Accepted\n\n**Context**: The session/recall/journal system had three overlapping\nstorage layers. The recall pipeline reads directly from raw transcripts,\nmaking .context/sessions/ a dead-end write sink that nothing reads from.\n\n**Decision**: Remove .context/sessions/ entirely. Two stores remain:\nraw transcripts (global, tool-owned) and enriched journal\n(project-local).\n\n**Rationale**: Dead-end write sinks waste code surface, maintenance\neffort, and user attention. The recall pipeline already proved that\nreading directly from raw transcripts is sufficient. Context snapshots\nare redundant with git history.\n\n**Consequence**: Deleted internal/cli/session/ (15 files), removed\nauto-save hook, removed --auto-save from watch, removed pre-compact\nauto-save, removed /ctx-save skill, updated ~45 documentation files.\nFour earlier decisions superseded.\n

      This artifact is:

      • Deterministically included in every subsequent session's delivery view (budget permitting, with title-only fallback if budget is exceeded)
      • Human-readable and reviewable as a diff in the commit that introduced it
      • Permanent: it persists in version control regardless of retrieval heuristics
      • Causally linked: it explicitly supersedes four earlier decisions, creating an auditable chain

      When the new team member asks \"Why don't we store session copies?\" six months later, the answer is the same artifact, at the same revision, with the same rationale. The reasoning is reconstructible because it was persisted at write time, not discovered at query time.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#64-the-diff-when-policy-changes","level":3,"title":"6.4 The Diff When Policy Changes","text":"

      If a future requirement re-introduces session storage (for example, to support multi-agent session correlation), the change appears as a diff to the decision record:

      - **Status**: Accepted\n+ **Status**: Superseded by [2026-08-15] Reintroduce session storage\n+ for multi-agent correlation\n

      The new decision record references the old one, creating a chain of reasoning visible in git log. In the retrieval model, the old decision would simply be ranked lower over time and eventually forgotten.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#7-experience-report-a-system-that-designed-itself","level":2,"title":"7. Experience Report: A System That Designed Itself","text":"

      The persistence model described in this paper was developed and tested by using it on its own development. Over 33 days and 389 sessions, the system's context files accumulated a detailed record of decisions made, reversed, and consolidated: providing quantitative and qualitative evidence for the model's properties.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#71-scale-and-structure","level":3,"title":"7.1 Scale and Structure","text":"

      The development produced the following authoritative state artifacts:

      • 8 consolidated decision records covering 24 original decisions spanning context injection architecture, hook design, task management, security, agent autonomy, and webhook systems
      • 18 consolidated learning records covering 75 original observations spanning agent compliance, hook behavior, testing patterns, documentation drift, and tool integration
      • A constitution with 13 inviolable rules across 4 categories (security, quality, process, context preservation)
      • 389 enriched journal entries providing a complete session-level audit trail

      The consolidation ratio (24 decisions compressed to 8 records, 75 learnings compressed to 18) illustrates the curation cost and its return: authoritative state becomes denser and more useful over time as related entries are merged, contradictions are resolved, and superseded decisions are marked.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#72-architectural-reversals","level":3,"title":"7.2 Architectural Reversals","text":"

      Three architectural reversals during development provide evidence that the persistence model captures and communicates reasoning effectively:

      Reversal 1: The two-tier persistence model: The original design included a middle storage tier for session copies. After 21 days of development, the middle tier was identified as a dead-end write sink (described in Section 6). The decision record captured the full context, and the removal was executed cleanly: 15 source files, a shell hook, and 45 documentation references. The pattern of a \"dead-end write sink\" was subsequently observed in 7 of 17 systems in our landscape analysis that store raw transcripts alongside structured context.

      Reversal 2: The prompt-coach hook: An early design included a hook that analyzed user prompts and offered improvement suggestions. After deployment, the hook produced zero useful tips, its output channel was invisible to users, and it accumulated orphan temporary files. The hook was removed, and the decision record captured the failure mode for future reference.

      Reversal 3: The soft-instruction compliance model: The original context injection strategy relied on soft instructions: directives asking the AI agent to read specific files. After measuring compliance across multiple sessions, we found a consistent 75-85% compliance ceiling. The revised strategy injects content directly, bypassing the agent's judgment about whether to comply. The learning record captures the ceiling measurement and the rationale for the architectural change.

      Each reversal was captured as a structured decision record with context, rationale, and consequences. In a retrieval-based system, these reversals would exist only in chat history, discoverable only if the retrieval function happens to surface them. In the persistence model, they are permanent, indexable artifacts that inform future decisions.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#73-compliance-ceiling","level":3,"title":"7.3 Compliance Ceiling","text":"

      The 75-85% compliance ceiling for soft instructions is the most operationally significant finding from the experience report. It means that any context management strategy relying on agent compliance with instructions (\"read this file,\" \"follow this convention,\" \"check this list\") has a hard ceiling on reliability.

      The root cause is structural: the instruction \"don't apply judgment\" is itself evaluated by judgment. When an agent receives a directive to read a file, it first assesses whether the directive is relevant to the current task (and that assessment is the judgment the directive was trying to prevent).

      The architectural response maps directly to the formal model defined in Section 3.1. Content requiring 100% compliance is included in authoritative_state and injected by the deterministic assemble function, bypassing the agent entirely. Content where 80% compliance is acceptable is delivered as instructions within the delivery view. The three-tier architecture makes this distinction explicit: authoritative state is injected; delivery views are assembled deterministically; ephemeral state is available but not pushed.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#74-compounding-returns","level":3,"title":"7.4 Compounding Returns","text":"

      Over 33 days, we observed a qualitative shift in the development experience. Early sessions (days 1-7) spent significant time re-establishing context: explaining conventions, re-stating constraints, re-deriving past decisions. Later sessions (days 25-33) began with the agent loading curated context and immediately operating within established constraints, because the constraints were in files rather than in chat history.

      This compounding effect (where each session's context curation improves all subsequent sessions) is the primary return on the curation investment. The cost is borne once (writing a decision record, capturing a learning, updating the task list); the benefit is collected on every subsequent session load.

      The effect is analogous to compound interest in financial systems: the knowledge base grows not linearly with effort but with increasing marginal returns as new knowledge interacts with existing context. A learning captured on day 5 prevents a mistake on day 12, which avoids a debugging session that would have consumed a day 12 session, freeing that session for productive work that generates new learnings. The growth is not literally exponential (it is bounded by project scope and subject to diminishing returns as the knowledge base matures), but within the observed 33-day window, the returns were consistently accelerating.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#75-scope-and-generalizability","level":3,"title":"7.5 Scope and Generalizability","text":"

      This experience report is self-referential by design: the system was developed using its own persistence model. This circularity strengthens the internal validity of the findings (the model was stress-tested under authentic conditions) but limits external generalizability. The two-week crossover point was observed on a single project of moderate complexity with a small team already familiar with the model's assumptions. Whether the same crossover holds for larger teams, for codebases with different characteristics, or for teams adopting the model without having designed it remains an open empirical question. The quantitative claims in this section should be read as existence proofs (demonstrating that the model can produce compounding returns) rather than as predictions about specific adoption scenarios.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#8-situating-the-persistence-layer","level":2,"title":"8. Situating the Persistence Layer","text":"

      The persistence layer occupies a specific position in the stack of AI-assisted development:

      Application Logic\nAI Interaction / Agents\nContext Retrieval Systems\nCognitive State Persistence Layer\nVersion Control / Storage\n

      Current systems innovate primarily in the retrieval layer (improving how context is discovered, ranked, and delivered at query time). The persistence layer sits beneath retrieval and above version control. Its role is to maintain the authoritative state that retrieval systems may query but do not own. The relationship is complementary: retrieval answers \"What in the corpus might be relevant?\"; cognitive state answers \"What must be true for this system to operate correctly?\" A mature system uses both: retrieval for discovery, persistence for authority.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#9-applicability-and-trade-offs","level":2,"title":"9. Applicability and Trade-Offs","text":"","path":["The Thesis"],"tags":[]},{"location":"thesis/#91-when-to-use-this-model","level":3,"title":"9.1 When to Use This Model","text":"

      A cognitive state persistence layer is most appropriate when:

      Reproducibility is a requirement: If a system must be able to answer \"Why did this output occur, and can it be produced again?\" then deterministic, version-controlled context becomes necessary. This is relevant in regulated environments, safety-critical systems, long-lived infrastructure, and security-sensitive deployments.

      Knowledge must outlive sessions and individuals: Projects with multi-year lifetimes accumulate architectural decisions, domain interpretations, and operational policy. If this knowledge is stored only in chat history, issue trackers, and institutional memory, it decays. The persistence model converts implicit knowledge into branchable, reviewable artifacts.

      Teams require shared cognitive authority: In collaborative environments, correctness depends on a stable answer to \"What does the system believe to be true?\" When this answer is derived from retrieval heuristics, authority shifts to ranking algorithms. When it is versioned and human-readable, authority remains with the team.

      Offline or air-gapped operation is required: Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or disaster-recovery scenarios.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#92-when-not-to-use-this-model","level":3,"title":"9.2 When Not to Use This Model","text":"

      Zero-configuration personal workflows: For short-lived or exploratory tasks, the cost of explicit knowledge curation outweighs its benefits. Heuristic retrieval is sufficient when correctness is non-critical, outputs are disposable, and historical reconstruction is unnecessary.

      Maximum automatic recall from large corpora: Vector retrieval systems provide superior performance when the primary task is searching vast, weakly structured information spaces. The persistence model assumes that what matters can be decided and that this decision is valuable to record.

      Fully autonomous agent architectures: Agent runtimes that generate and discard state continuously, optimizing for local goal completion, do not benefit from a model that centers human ratification of knowledge.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#93-incremental-adoption","level":3,"title":"9.3 Incremental Adoption","text":"

      The transition does not require full system replacement. An incremental path:

      Step 1: Record decisions as versioned artifacts: Instead of allowing conclusions to remain in discussion threads, persist them in reviewable form with context, rationale, and consequences 4. This alone converts ephemeral reasoning into the cognitive state.

      Step 2: Make inclusion deterministic: Define explicit assembly rules. Retrieval may still exist, but it is no longer authoritative.

      Step 3: Move policy into cognitive state: When system behavior depends on stable constraints, encode those constraints as versioned knowledge. Behavior becomes reproducible.

      Step 4: Optimize assembly, not retrieval: Once the authoritative layer exists, performance improvements come from budgeting, caching, and structural refinement rather than from improving ranking heuristics.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#94-the-curation-cost","level":3,"title":"9.4 The Curation Cost","text":"

      The primary objection to this model is the cost of explicit knowledge curation. This cost is real. Writing a structured decision record takes longer than letting a chatbot auto-summarize a conversation. Maintaining a glossary requires discipline. Consolidating 75 learnings into 18 records requires judgment.

      The response is not that the cost is negligible but that it is amortized. A decision record written once is loaded hundreds of times. A learning captured today prevents repeated mistakes across all future sessions. The curation cost is paid once; the benefit compounds.

      The experience report provides rough order-of-magnitude numbers. Across 389 sessions over 33 days, curation activities (writing decision records, capturing learnings, updating the task list, consolidating entries) averaged approximately 3-5 minutes per session. In early sessions (days 1-7), before curated context existed, re-establishing context consumed approximately 10-15 minutes per session: re-explaining conventions, re-stating architectural constraints, re-deriving decisions that had been made but not persisted. By the final week (days 25-33), the re-explanation overhead had dropped to near zero: the agent loaded curated context and began productive work immediately.

      At ~12 sessions per day, the curation cost was roughly 35-60 minutes daily. The re-explanation cost in the first week was roughly 120-180 minutes daily. By the third week, that cost had fallen to under 15 minutes daily while the curation cost remained stable. The crossover (where cumulative curation cost was exceeded by cumulative time saved) occurred around day 10. These figures are approximate and derived from a single project with a small team already familiar with the model; the crossover point will vary with project complexity, team size, and curation discipline.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#10-future-work","level":2,"title":"10. Future Work","text":"

      Several directions are compatible with the model described here:

      Section-level deterministic budgeting: Current assembly operates at file granularity. Section-level budgeting would allow finer-grained control (including specific decision records while excluding others within the same file) without sacrificing determinism.

      Causal links between decisions: The experience report shows that decisions frequently reference earlier decisions (superseding, extending, or qualifying them). Formal causal links would enable traversal of the decision graph and automatic detection of orphaned or contradictory constraints.

      Content-addressed context caches: Five systems in our landscape analysis independently discovered that content hashing provides cache invalidation, integrity verification, and change detection. Applying content addressing to the assembly output would enable efficient cache reuse when the authoritative state has not changed.

      Conditional context inclusion: Five systems independently suggest that context entries could carry activation conditions (file patterns, task keywords, or explicit triggers) that control whether they are included in a given assembly. This would reduce the per-session budget cost of large knowledge bases without sacrificing determinism.

      Provenance metadata: Linking context entries to the sessions, decisions, or learnings that motivated them would strengthen the audit trail. Optional provenance fields on Markdown entries (session identifier, cause reference, motivation) would be lightweight and compatible with the existing file-based model.

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#11-conclusion","level":2,"title":"11. Conclusion","text":"

      AI-assisted development has treated context as a \"query result\" assembled at the moment of interaction, discarded at the session end. This paper identifies a complementary layer: the persistence of authoritative cognitive state as deterministic, version-controlled artifacts.

      The contribution is grounded in three sources of evidence. A landscape analysis of 17 systems reveals five categories of primitives and shows that no existing system provides the combination of human-readability, determinism, zero dependencies, and offline capability that the persistence layer requires. Six design invariants, validated by 56 independent rejection decisions, define the constraints of the design space. An experience report over 389 sessions and 33 days demonstrates compounding returns: later sessions start faster, decisions are not re-derived, and architectural reversals are captured with full context.

      The core claim is this: persistent cognitive state enables causal reasoning across time. A system built on this model can explain not only what is true, but why it became true and when it changed.

      When context is the state:

      • Reasoning is reproducible: the same authoritative state, budget, and policy produce the same delivery view.
      • Knowledge is auditable: decisions are traceable to explicit artifacts with context, rationale, and consequences.
      • Understanding compounds: each session's curation improves all subsequent sessions.

      The choice between retrieval-centric workflows and a persistence layer is not a matter of capability but of time horizon. Retrieval optimizes for relevance at the moment of interaction. Persistence optimizes for the durability of understanding across the lifetime of a project.

      🐸🖤 \"Gooood... let the deterministic context flow through the repository...\" - Kermit the Sidious, probably

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#appendix-a-representative-rejection-decisions","level":2,"title":"Appendix A: Representative Rejection Decisions","text":"

      The 56 rejection decisions referenced in Section 4 were cataloged across all 17 system analyses, grouped by the invariant they would violate. This appendix provides a representative sample (two per invariant) to illustrate the methodology.

      Invariant 1: Markdown-on-Filesystem (11 rejections): CrewAI's vector embedding storage was rejected because embeddings are not human-readable, not git-diff-friendly, and require external services. Kindex's knowledge graph as core primitive was rejected because it requires specialized commands to inspect content that could be a text file (kin show <id> vs. cat DECISIONS.md).

      Invariant 2: Zero Runtime Dependencies (13 rejections): Letta/MemGPT's PostgreSQL-backed architecture was rejected because it conflicts with local-first, no-database, single-binary operation. Pachyderm's Kubernetes-based distributed architecture was rejected as the antithesis of a single-binary design for a tool that manages text files.

      Invariant 3: Deterministic Assembly (6 rejections): LlamaIndex's embedding-based retrieval as the primary selection mechanism was rejected because it destroys determinism, requires an embedding model, and removes human judgment from the selection process. QubicDB's wall-clock-dependent scoring was rejected because it directly conflicts with the \"same inputs produce same output\" property.

      Invariant 4: Human Authority (6 rejections): Letta/MemGPT's agent self-modification of memory was rejected as fundamentally opposed to human-curated persistence. Claude Code's unstructured auto-memory (where the agent writes freeform notes) was rejected because structured files with defined schemas produce higher-quality persistent context than unconstrained agent output.

      Invariant 5: Local-First / Air-Gap Capable (7 rejections): Sweep's cloud-dependent architecture was rejected as fundamentally incompatible with the local-first, offline-capable model. LangGraph's managed cloud deployment was rejected because cloud dependencies for core functionality violate air-gap capability.

      Invariant 6: No Default Telemetry (4 rejections): Continue's telemetry-by-default (PostHog) was rejected because it contradicts the local-first, privacy-respecting trust model. CrewAI's global telemetry on import (Scarf tracking pixel) was rejected because it violates user trust and breaks air-gap capability.

      The remaining 9 rejections did not map to a specific invariant but were rejected on other architectural grounds: for example, Aider's full-file-content-in-context approach (which defeats token budgeting), AutoGen's multi-agent orchestration as core primitive (scope creep), and Claude Code's 30-day transcript retention limit (institutional knowledge should have no automatic expiration).

      ","path":["The Thesis"],"tags":[]},{"location":"thesis/#references","level":2,"title":"References","text":"
      1. Reproducible Builds Project, \"Reproducible Builds: Increasing the Integrity of Software Supply Chains\", 2017. https://reproducible-builds.org/docs/definition/ ↩↩↩

      2. S. McIntosh et al., \"The Impact of Build System Evolution on Software Quality\", ICSE, 2015. https://doi.org/10.1109/ICSE.2015.70 ↩

      3. C. Manning, P. Raghavan, H. Schütze, Introduction to Information Retrieval, Cambridge University Press, 2008. https://nlp.stanford.edu/IR-book/ ↩

      4. M. Nygard, \"Documenting Architecture Decisions\", Cognitect Blog, 2011. https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions ↩↩

      5. L. Torvalds et al., Git Internals - Git Objects (content-addressed storage concepts). https://git-scm.com/book/en/v2/Git-Internals-Git-Objects ↩

      6. Kief Morris, Infrastructure as Code, O'Reilly, 2016. ↩

      7. J. Kreps, \"The Log: What every software engineer should know about real-time data's unifying abstraction\", 2013. https://engineering.linkedin.com/distributed-systems/log ↩

      8. P. Hunt et al., \"ZooKeeper: Wait-free coordination for Internet-scale systems\", USENIX ATC, 2010. https://www.usenix.org/legacy/event/atc10/tech/full_papers/Hunt.pdf ↩

      ","path":["The Thesis"],"tags":[]}]} \ No newline at end of file diff --git a/specs/cli-add-symmetry.md b/specs/cli-add-symmetry.md new file mode 100644 index 000000000..e3286741e --- /dev/null +++ b/specs/cli-add-symmetry.md @@ -0,0 +1,354 @@ +--- +title: CLI add Symmetry — Noun-First Canonical Form +status: proposed +date: 2026-05-03 +owner: jose +scope: behavioral — CLI surface, slash-skill alignment, docs sweep +related: + - specs/cli-namespace-cleanup.md + - specs/ctx-init-overwrite-safety.md +--- + +# Spec: CLI add Symmetry + +## Problem + +The CLI today mixes two organizing principles: + +| Operation | Form | Lives under | +|-------------------------|--------------|--------------| +| `ctx task complete` | noun-first | `ctx task` | +| `ctx task archive` | noun-first | `ctx task` | +| `ctx task snapshot` | noun-first | `ctx task` | +| `ctx decision reindex` | noun-first | `ctx decision` | +| `ctx learning reindex` | noun-first | `ctx learning` | +| `ctx task add` | **missing** | (must use `ctx add task`) | +| `ctx decision add` | **missing** | (must use `ctx add decision`) | +| `ctx learning add` | **missing** | (must use `ctx add learning`) | +| `ctx convention add` | **missing** | (`ctx convention` doesn't exist at all — must use `ctx add convention`) | + +Every other verb in the artifact namespace is noun-first. Only +`add` lives under a verb-first parent. A user who learns `ctx +task complete` reasonably expects `ctx task add` to exist. It +doesn't, and the asymmetry is invisible until they hit +"unknown command". + +The asymmetry is also self-inflicted from the slash-skill side: +the user-facing skills are already noun-first +(`ctx-task-add`, `ctx-decision-add`, `ctx-learning-add`, +`ctx-convention-add`). The CLI is the odd one out. + +The 2026-05-03 incident that surfaced this: assistant referenced +`/ctx-decision-add` and `/ctx-learning-add` (the skill names); +user reasonably checked `ctx decision add` / `ctx task add` on +the CLI; user found nothing and concluded the schema-enforcing +commands had been deleted. They hadn't — they live at `ctx add +` — but the dissonance between CLI naming and +skill/docstring naming is real and recurring. + +Stale documentation in three places already implies the noun-first +form is canonical: + +- `internal/write/add/doc.go:8-9` — "entry addition commands + (ctx task add, ctx decision add, ctx learning add, ctx + convention add)" +- `specs/explicit-context-dir.md:267` — `ctx task add "foo"` +- 2026-04-19 journal entry — `ctx task add` + +Three sources of drift in the same direction is not a typo +pattern; it's an organizing intuition that the CLI never matched. + +## Goals + +1. Single, consistent organizing principle: **noun-first** for + every operation on a context artifact. +2. Make CLI naming match slash-skill naming + (`ctx--add` ↔ `ctx add`). +3. Remove the verb-first `ctx add` parent (or reduce it to a + thin deprecation alias — see Open Questions). +4. Ensure `ctx --help` lists *every* operation on that + noun, including `add`. No "must use a different parent" + surprises. + +## Non-goals + +- Changing the schema (`--context`, `--rationale`, + `--consequence`, `--lesson`, `--application`, etc. unchanged). +- Changing the underlying file formats. +- Renaming slash skills (already in the target form). +- Touching unrelated noun-first asymmetries elsewhere in the CLI + (separate audit, separate spec). + +## Design + +### A. New canonical commands + +Create the four noun-first add subcommands, each backed by the +existing `internal/cli/add/core/` machinery (which becomes +shared library, not a CLI parent's private core): + +``` +ctx task add → internal/cli/task/cmd/add/ +ctx decision add → internal/cli/decision/cmd/add/ +ctx learning add → internal/cli/learning/cmd/add/ +ctx convention add → internal/cli/convention/cmd/add/ (new parent) +``` + +Flag set, validation, error messages, and exit codes match the +current `ctx add ` exactly. Each new subcommand is a thin +adapter that calls the shared core. + +### B. Create `ctx convention` parent + +`ctx convention` is currently not a registered command (`ctx +convention` returns "unknown command, did you mean +'connection'?"). The flip requires a `ctx convention` parent +that hosts `add`. + +**Decided: ship `add` only.** CONVENTIONS.md doesn't have an +INDEX block today, so `reindex` would mean designing one — out +of scope for this spec. Initial subcommand set: + +``` +ctx convention add (port from `ctx add convention`) +``` + +If CONVENTIONS.md ever grows an index, add `ctx convention +reindex` as a follow-up. The `ctx convention` parent stands on +its own with one subcommand for now. + +### C. Refactor shared core + +`internal/cli/add/` is currently both: +- A CLI parent package (registers `ctx add`, owns + `cmd/root/cmd.go`). +- A shared library (`core/append.go`, `core/insert.go`, + `core/index.go`, etc., consumed by the parent's run.go). + +After the flip, the CLI-parent role goes away (or shrinks to a +deprecation alias). The shared library should keep working from +the same import path so the new noun-first commands import it +cleanly. + +Two options: + +1. **In place**: keep `internal/cli/add/core/` as the shared + library; new noun commands import it directly. The + `internal/cli/add/cmd/root/` shrinks to either nothing + (option D1) or a thin deprecation shim (option D2). +2. **Relocate**: move `internal/cli/add/core/` to + `internal/add/` (no `cli/` prefix, signaling it's + non-CLI shared logic). New noun commands import the new + path. `internal/cli/add/` package goes away entirely (option + D1) or becomes the deprecation shim (option D2). + +Recommendation: **option 1** for the migration commit (low +churn, no import-path-rewrite blast); follow up with option 2 +in a separate commit if `internal/cli/add/` ends up genuinely +empty after deprecation. + +### D. Deprecation strategy: hard cut + +**Decided: hard cut.** Remove `ctx add ` in the same +commit that adds `ctx add`. Matches the project's prior +namespace-cleanup pattern (`78fbdf7d` and `f4117b87` were both +hard renames). Release-notes call-out plus a one-line migration +sed in the breaking-change section is the only mitigation +needed. + +After the flip, `ctx add` either disappears entirely or returns +"unknown command" with a Cobra `did you mean` suggestion +pointing at the new noun-first form. + +### E. Slash-skill alignment + +The four `ctx--add` skills under +`internal/assets/claude/skills/` already use noun-first naming +externally, but they likely invoke `ctx add ` internally. +After the flip: + +- Audit each skill's SKILL.md / scripts for the verb-first + invocation; replace with noun-first. +- If D2 is chosen, the skills can be updated immediately (the + new form is preferred); if D1, they MUST be updated in the + same commit. + +### F. Documentation sweep + +20+ files reference the verb-first form (from grep across +`docs/`, `internal/assets/`): + +- `docs/home/{common-workflows,repeated-mistakes,first-session,context-files,is-ctx-right,joining-a-project}.md` +- `docs/cli/{connection,context,connect}.md` +- `docs/operations/{autonomous-loop,runbooks/sanitize-permissions,runbooks/hub-deployment}.md` +- `docs/blog/{2026-02-17-context-as-infrastructure,2026-02-03-the-attention-budget,2026-02-01-ctx-v0.2.0-the-archaeology-release,2026-02-07-the-anatomy-of-a-skill-that-works}.md` +- `docs/recipes/{task-management,hub-team,external-context,hub-personal}.md` +- `internal/write/add/doc.go` (the godoc that already implied + noun-first — becomes correct after the flip) +- `specs/explicit-context-dir.md` (line 267) +- AGENT_PLAYBOOK.md and CLAUDE.md template snippets (audit) + +**Blog posts**: do not rewrite history. Add an editor's note +("CLI surface changed in v0.X — see [link]") rather than +silently rewriting published commands. + +### G. Tests + +- Cobra-tree test: assert each of the four nouns has an `add` + subcommand; assert flag set matches the old `ctx add ` + flag set exactly (catch flag drift during the migration). +- If D2: alias test — `ctx add ...` still produces the + same output as `ctx add ...` and prints the deprecation + notice on stderr. +- If D1: removed-command test — `ctx add ` returns + "unknown command" with a helpful "did you mean `ctx + add`?" suggestion (Cobra's built-in fuzzy match should handle + this; verify it does). +- Drift test: lint-drift or doc-drift check for the + `internal/write/add/doc.go` claim, so it stays accurate after + the flip. + +## Open questions + +1. **Shared-core relocation (option 1 vs option 2 in section + C)**: in-place for the migration commit, follow-up move + later? Default proposal: in-place now, separate refactor + commit later if warranted. +2. **"Did you mean" text**: Cobra's default is acceptable but + a custom one-liner explaining the principle is friendlier: + "operations on a noun live under that noun: `ctx + `". Resolve at implementation time; minor. + +## Decisions baked in + +- **Deprecation horizon**: hard cut (D1). `ctx add ` + removed in the same commit that adds `ctx add`. +- **`ctx convention reindex`**: deferred. Ship `ctx convention + add` only. + +## Risks + +- **Breaking change without deprecation period (D1)**: any + external user/CI calling `ctx add ` breaks. Mitigation: + release notes call this out explicitly; provide a one-line + migration sed. +- **Forgotten doc reference**: 20+ docs is a lot. Mitigation: + the drift test in section G; also a final `rg "ctx add " + --type md` sweep gated in CI for the release commit. +- **Slash-skill regression**: skills currently work; the audit + in section E catches the invocation drift, but a missed skill + silently breaks for users invoking it. Mitigation: explicit + test that each `ctx--add` skill resolves to a working + CLI invocation post-flip. +- **`ctx convention` parent name collision**: low risk; + `convention` is unused as a top-level today. + +## Tasks + +Implementation order: shared core stays put → noun commands +land → deprecation choice executed → docs swept → +release notes. + +### Phase A: New noun commands (CLI surface) + +- [ ] Add `ctx task add` subcommand under + `internal/cli/task/cmd/add/`; thin adapter calling + `internal/cli/add/core/` +- [ ] Add `ctx decision add` subcommand under + `internal/cli/decision/cmd/add/` +- [ ] Add `ctx learning add` subcommand under + `internal/cli/learning/cmd/add/` +- [ ] Create `ctx convention` parent command in + `internal/cli/convention/cmd/root/`; add `ctx convention + add` subcommand under `internal/cli/convention/cmd/add/` +- [ ] Verify each new subcommand's flag set matches the old + `ctx add ` exactly (Cobra-tree test) + +### Phase B: Hard-cut removal of `ctx add ` + +- [ ] Remove `ctx add` parent registration from the root + command tree +- [ ] Remove `internal/cli/add/cmd/root/` (CLI-parent role + gone); keep `internal/cli/add/core/` as shared library +- [ ] Verify Cobra returns a useful "unknown command" with a + "did you mean `ctx add`?" suggestion; if Cobra's + default is unhelpful, add a custom suggestion +- [ ] Removed-command test: `ctx add task` returns non-zero + with the suggestion in stderr + +### Phase C: Slash-skill alignment + +- [ ] Audit `internal/assets/claude/skills/ctx-task-add/` + contents (SKILL.md, any helper scripts); replace any + `ctx add task` invocation with `ctx task add` +- [ ] Same for `ctx-decision-add`, `ctx-learning-add`, + `ctx-convention-add` +- [ ] Add a test that each skill's invocation resolves on the + post-flip CLI + +### Phase D: Documentation, docstrings, comments sweep (full surface) + +This is the "as usual" sweep. Source-tree comments and godocs +matter as much as user-facing docs — the +`internal/write/add/doc.go` drift is exactly what fooled both +user and assistant in the incident that prompted this spec. + +- [ ] **Source-tree godocs and comments** — `rg "ctx add + (decision|task|learning|convention)\b" --type go`; + every hit needs review. Notably: + - `internal/write/add/doc.go:8-9` (already noun-first; + confirm it's still accurate post-flip) + - Any `// Example: ctx add ...` comments + - Any cobra `Example:` field strings in + `internal/cli/**/cmd/root/cmd.go` + - Embed-level help text in + `internal/config/embed/text/**` if any references exist +- [ ] **Spec files** — `specs/explicit-context-dir.md:267` + and any other spec hits from `rg "ctx add " specs/` +- [ ] **User-facing docs** — files identified in section F: + `docs/home/{common-workflows,repeated-mistakes,first-session,context-files,is-ctx-right,joining-a-project}.md`, + `docs/cli/{connection,context,connect}.md`, + `docs/operations/{autonomous-loop,runbooks/sanitize-permissions,runbooks/hub-deployment}.md`, + `docs/recipes/{task-management,hub-team,external-context,hub-personal}.md` +- [ ] **Generated CLI reference** — if `docs/cli/index.md` or + similar is generated from Cobra metadata, regenerate. + Otherwise update by hand. +- [ ] **Blog posts** — `docs/blog/{2026-02-17-context-as-infrastructure,2026-02-03-the-attention-budget,2026-02-01-ctx-v0.2.0-the-archaeology-release,2026-02-07-the-anatomy-of-a-skill-that-works}.md` + — do NOT rewrite the body; add an editor's note at the + top: "*Editor's note (YYYY-MM-DD): the CLI surface + changed in v0.X. `ctx add ` is now `ctx + add`; see [link to release notes].*" Published commands + stay as published. +- [ ] **CLAUDE.md and AGENT_PLAYBOOK templates** — audit + `internal/assets/claude/CLAUDE*.md`, + `AGENT_PLAYBOOK*.md`, the project root CLAUDE.md, and + any embedded snippets. Replace verb-first invocations + with noun-first. +- [ ] **README and top-level docs** — `README.md`, any + `CHEAT-SHEETS.md`, `GLOSSARY.md` in `.context/` if + they reference the verb-first form. +- [ ] **CI drift gate** — add a check: + `rg "ctx add (decision|task|learning|convention)\b" + --type md --type go` returns zero hits *excluding* + `docs/blog/` (where the editor's notes are intentional + and the body is preserved). If there's an existing + drift-test infrastructure (`internal/audit/`, + `lint-drift`), wire this into it; otherwise add a + standalone test. +- [ ] **Release notes** — breaking-change section with the + one-line migration sed: + `find . -type f \( -name '*.md' -o -name '*.go' \) -exec sed -i.bak -E 's/ctx add (decision|task|learning|convention)/ctx \1 add/g' {} \;` + +### Phase E: Verification + +- [ ] `make lint && make test` clean +- [ ] Manual smoke: `ctx task add "foo" --session-id ... + --branch ... --commit ...` succeeds +- [ ] Manual smoke: same for decision, learning, convention +- [ ] Manual smoke: `ctx --help` lists `add` for every + noun +- [ ] If D1: manual smoke that `ctx add task` returns "unknown + command" with the "did you mean `ctx task add`?" + suggestion +- [ ] If D2: manual smoke that `ctx add task` still works and + prints the deprecation notice on stderr diff --git a/specs/ctx-init-overwrite-safety.md b/specs/ctx-init-overwrite-safety.md new file mode 100644 index 000000000..0435f4307 --- /dev/null +++ b/specs/ctx-init-overwrite-safety.md @@ -0,0 +1,268 @@ +--- +title: ctx init Overwrite Safety +status: proposed +date: 2026-05-03 +owner: jose +scope: behavioral — `ctx init` UX, hook scaffolding side effects, docs +related: + - specs/single-source-context-anchor.md +--- + +# Spec: ctx init Overwrite Safety + +## Problem + +On 2026-04-25 01:44 PDT, commit `423016c3` ("feat: enforce explicit +CTX_DIR with single-source anchor resolution") replaced the live +contents of four `.context/` files with the embedded scaffolding +templates from `internal/assets/context/`: + +| File | Before | After (template) | +|----------------|-------:|-----------------:| +| TASKS.md | 2138 | 36 | +| DECISIONS.md | 1801 | 49 | +| LEARNINGS.md | 1667 | 20 | +| CONVENTIONS.md | 272 | 62 | + +Total: 5878 lines of curated context destroyed in a single commit +with no warning and no backup. Recovery was possible only because +the prior versions were preserved in git — had this happened to a +user without git (or had it happened between commits), the loss +would have been irreversible. + +## Root cause + +Two compounding defects in `ctx init`: + +### Defect 1 — silent overwrite on "y" + +`internal/cli/initialize/cmd/root/run.go` (lines 117-136) prompts +`"Overwrite existing context?" [y/N]` when essential files exist. +The prompt: + +- Does not enumerate the files that will be overwritten. +- Does not show their current line counts or sizes. +- Does not warn that templates will replace curated content. +- Does not create a backup before overwriting. +- With `--force`, skips the prompt entirely. + +The word "overwrite" is doing all the rhetorical work. A user +treating `init` as idempotent (a reasonable mental model — most +`init` commands are no-ops on initialized state) sees a binary +prompt and answers `y` without realizing they are about to delete +thousands of lines of decisions, learnings, and tasks. + +### Defect 2 — phantom `.context/` from misbehaving hooks + +User-reported, hypothesis to be verified during implementation: +some hook in an empty project fires before context exists, fails +to see `.context/`, and instead of bailing **creates** one and +writes a session-anchor JSONL there (the `jsonl-path-` +file already noted in LEARNINGS as the +`filepath.Join('', rel)` trap). + +Symptom: a fresh project with no real context shows up with a +`.context/` containing only a `jsonl-path-*` file. If the +overwrite-safety fix from Defect 1 ships as "refuse +unconditionally when `.context/` is populated," then `ctx init` +on a fresh project will fail because a phantom `.context/` +already exists. + +The two defects are coupled: Defect 2 must be fixed first or the +Defect 1 fix backfires. + +## Goals (in order) + +1. Make it impossible for `ctx init` to silently destroy curated + context. Refusing-then-erroring is preferable to + prompting-then-overwriting. +2. Eliminate the phantom-`.context/` hook bug so the refuse + policy doesn't punish first-time users. +3. Preserve a recovery escape hatch for the rare case where a + user genuinely wants to nuke their context (`--reset` or + similar, with on-disk backup). + +## Non-goals + +- Restoring already-lost context (handled out-of-band via git + recovery for this incident; users without git are outside this + spec). +- Reworking the templates themselves. +- Changing the structure of `.context/` files. + +## Design + +### A. Make overwrite the impossible default + +Change `ctx init` to follow this decision tree: + +``` +.context/ does not exist → create + scaffold (current behavior) +.context/ exists, no populated → scaffold missing files only +files (only state/ or empty) +.context/ exists, files populated → REFUSE with explanatory error + pointing at `ctx init --reset` +``` + +"Populated" = any of TASKS.md / DECISIONS.md / LEARNINGS.md / +CONVENTIONS.md / CONSTITUTION.md exceeds the embedded template's +line count by more than a small tolerance, OR contains content +not present in the template (cheaper check: SHA mismatch with the +embedded asset). + +Remove `--force` as an overwrite mechanism. Replace with +`--reset`, which: + +- Requires interactive confirmation that names every populated + file by basename and shows its line count. +- Writes a timestamped backup to `.context/.backup-init-/` + containing every file it is about to replace, and prints the + backup path before proceeding. +- In non-interactive mode (`--caller`, no TTY, CI), refuses + unconditionally — there is no scripted use case for "reset my + context". + +The `--reset` name is intentionally not `--force`: `force` reads +as "ignore my safety rails," `reset` reads as "I want a clean +slate." The semantic difference matters at the call site. + +### B. Stop hooks from materializing `.context/` + +Audit every hook in `internal/assets/hooks/` and every code path +that writes to `state.Dir()` / `rc.ContextDir()`. Any path that +creates a directory or writes a file under `.context/` must: + +1. First call `state.Initialized()` (or equivalent) and bail + silently if false. +2. Never call `os.MkdirAll(stateDir, ...)` as a side effect of + reading. Read paths use `os.Stat` and return cleanly when the + directory does not exist. + +Specifically: trace the `jsonl-path-` writer (likely +in the session-anchor relay or journal-import hook) and confirm +it gates on `state.Initialized()`. The April LEARNINGS entry on +`filepath.Join('', rel)` closed the CWD-relative trap but did +not prove the writer is gated against bootstrapping a +`.context/` from scratch. + +### C. Update user-facing surface + +Every place that documents or invokes `ctx init` needs the new +contract: + +- `ctx init --help` text and the embedded usage example. +- `docs/cli/init.md` (or wherever the canonical init docs live). +- `docs/recipes/activating-context.md` and any recipe that walks + a user through first-run setup. +- `https://ctx.ist/recipes/activating-context/` (mirror in the + docs site). +- `CLAUDE.md` template snippets that mention `ctx init`. +- AGENT_PLAYBOOK.md if it references `--force` anywhere. +- Any `_ctx-release` / release-notes scaffolding that lists + flags. +- The error message in `rc.ErrDirNotDeclared` and the + "Overwrite existing context?" prompt removal. + +### D. Tests + +- Unit: `init` against a populated `.context/` returns + `ErrContextPopulated` (new sentinel), exit code != 0, no + files modified. +- Unit: `init --reset` in non-interactive mode returns + `ErrResetRequiresTTY`, exit code != 0, no files modified. +- Unit: `init --reset` in interactive mode with `n` answer: + no files modified, no backup directory created. +- Unit: `init --reset` with `y` answer: backup directory + exists with originals, target files match templates. +- Integration: hook-fired `ctx ...` invocation in a + non-initialized project does not create `.context/`. (Add a + test that runs every relay hook against an empty CWD and + asserts no `.context/` materializes.) + +## Risks + +- **Refuse-too-aggressive**: edge case where `.context/` exists + with one populated file (e.g., user manually created + CONSTITUTION.md before running init). Mitigation: scaffold + *missing* files in this case rather than refusing wholesale. +- **`--reset` rediscovers the original footgun**: if the + confirmation prompt is too quiet, we recreate Defect 1 under a + new flag name. Mitigation: file-by-file enumeration with line + counts in the prompt, plus mandatory backup. +- **Hook audit misses a writer**: a future hook adds a + `MkdirAll(stateDir)` and reintroduces phantom `.context/`. + Mitigation: the integration test in section D catches this on + CI; consider an AST audit (`internal/audit/`) that flags + `MkdirAll` calls outside of `init`/`activate`. + +## Tasks + +Implementation order matters: B before A so the refuse policy +doesn't strand fresh-project users. + +### Phase B: Stop phantom .context/ creation + +- [ ] Audit `internal/assets/hooks/` — list every hook that + reads or writes under `.context/` and its current + `state.Initialized()` gate status +- [ ] Locate the writer that produces `jsonl-path-` + files; confirm it bails when `.context/` does not exist + (not just when `CTX_DIR` is unset) +- [ ] Add an integration test: run each relay hook in a temp + CWD with no `.context/`; assert no directory or file is + created +- [ ] If the AST audit route is taken: add + `internal/audit/no_mkdir_in_hooks_test.go` that flags + `os.MkdirAll` / `os.Mkdir` calls in + `internal/assets/hooks/` and `internal/cli/*/hook/` + +### Phase A: Refuse-by-default in ctx init + +- [ ] Add `ErrContextPopulated` sentinel in + `internal/cli/initialize/...` (or `internal/err/`) +- [ ] Replace the `[y/N]` overwrite prompt in + `internal/cli/initialize/cmd/root/run.go` (lines 117-136) + with the populated-check + refuse-with-error path +- [ ] Implement "scaffold missing files only" branch for the + partial-init case +- [ ] Remove `--force` flag (lines 40, 63-71 in + `internal/cli/initialize/cmd/root/cmd.go`); add + `--reset` flag with the contract from section A +- [ ] `--reset` writes timestamped backup to + `.context/.backup-init-/` before any destructive op; + print the backup path to stderr +- [ ] `--reset` refuses in non-interactive mode + (`!isatty(stdin)` or `--caller` set) with + `ErrResetRequiresTTY` +- [ ] All unit tests from section D pass + +### Phase C: Docs and recipes + +- [ ] Update `ctx init --help` text and embedded examples +- [ ] Update `docs/cli/init.md` +- [ ] Update `docs/recipes/activating-context.md` and any other + recipe under `docs/recipes/` that mentions `ctx init` +- [ ] Cross-check the docs-site source (zensical.toml entries, + mkdocs nav) — same change must reach + https://ctx.ist/recipes/activating-context/ +- [ ] Audit `internal/assets/claude/CLAUDE*.md` and + `AGENT_PLAYBOOK*.md` for mentions of `ctx init --force`; + replace with `ctx init --reset` (and update the mental + model accordingly: this is now a destructive op, not a + shortcut) +- [ ] Release-notes entry: breaking change, `--force` removed, + replaced by `--reset` with stricter semantics +- [ ] Add a LEARNINGS.md entry post-implementation describing + the incident, the fix, and the AST-audit guard if added + +### Phase D: Verification + +- [ ] `make lint && make test` clean +- [ ] Manual smoke: fresh empty project → `ctx init` succeeds +- [ ] Manual smoke: populated project → `ctx init` refuses with + a useful error and exit code != 0 +- [ ] Manual smoke: populated project → `ctx init --reset`, + decline → no changes; accept → backup exists, files + reset +- [ ] Manual smoke: `ctx init --reset < /dev/null` → refused, + exit code != 0

      ctx add task "Write tests for X" --session-id ID --branch BR --commit HASHctx task add "Write tests for X" --session-id ID --branch BR --commit HASH "We should add tests for this: track that?"
      "TASKS.md is getting long, can you clean it up?"
      ctx add task ... --session-id ID --branch BR --commit HASH && ctx add task ...ctx task add ... --session-id ID --branch BR --commit HASH && ctx task add ... "Add follow-ups for what we just built."