diff --git a/.context/LEARNINGS.md b/.context/LEARNINGS.md index a64dcc584..4bf638dc1 100644 --- a/.context/LEARNINGS.md +++ b/.context/LEARNINGS.md @@ -1,5 +1,16 @@ # Learnings + +| Date | Learning | +|----|--------| +| 2026-08-19 | Exact zensical pin does not prevent site/ churn: underlying libs drift | +| 2026-07-25 | Using the proprietary sibling repo as design evidence leaks its internals into tracked files | +| 2026-07-25 | Skill and doc examples of a serialized structure must round-trip through the real parser | +| 2026-07-25 | A guard derived from a capability accessor silently lifts when the accessor is extended | +| 2026-07-19 | The disclosure parser is a deliberately dumb line-scanner (skips comments, not code fences) | +| 2026-07-19 | Measurement gates surface a real bug in every disclosure milestone | + + +## [2026-08-19-221024] Exact zensical pin does not prevent site/ churn: underlying libs drift + +**Context**: make site with the exactly-pinned zensical 0.0.51 (fresh pipx install) still churned 100+ committed site/ pages with HTML-entity encoding differences (' vs ') untouched by the docs change — the pin fixes the generator version, not its Python dependency tree. + +**Lesson**: The generator pin is necessary but not sufficient for reproducible site builds; markdown-renderer deps under zensical encode entities differently across environments, and CI never rebuilds the site to catch it. + +**Application**: After make site, review git status -- site/ and commit ONLY pages your docs change affects (plus search.json); restore the rest. If full-site churn is ever intended, do it as its own chore commit. + +--- + ## [2026-07-25-124457] Using the proprietary sibling repo as design evidence leaks its internals into tracked files **Context**: While deciding the pd-m4 add-path shape, I read the sibling repo's convention file to settle the question, then quoted its guide text and attributed the decision to it in a tracked plan file. An unrelated build warning prompted the sweep that caught it. diff --git a/.context/TASKS.md b/.context/TASKS.md index 22b6c4bd6..e88f78aa1 100644 --- a/.context/TASKS.md +++ b/.context/TASKS.md @@ -2617,6 +2617,10 @@ shipped. ### Misc +- [ ] Full-site regen as standalone chore: make site with pinned zensical 0.0.51 rewrites 100+ pages with HTML-entity encoding differences (lib drift beneath the pin). Decide the canonical encoding, regenerate the whole site/ in one chore commit, and consider pinning zensical's dep tree (pipx runpip freeze) so future builds are reproducible. See LEARNINGS 2026-08-19 zensical-pin entry. #priority:medium #session:45d47165 #branch:feat/158-opencode-skill-parity #commit:f3f73875 #added:2026-08-19-221230 + +- [x] Regenerate site/ for docs/home/opencode.md (OpenCode skill parity, issue #158): zensical not installed on this machine, so make site could not run; run make site on a machine with the pinned zensical and commit the site/ churn #priority:medium #session:45d47165 #branch:feat/158-opencode-skill-parity #commit:ce5a8328 #added:2026-08-19-211552 + - [x] [Epic F] ctx index: docs (remove reindex, add ctx index) + final build/lint/test gate (T23-T24). Plan: specs/plans/computed-index-projection.md #session:75be038e #branch:main #commit:f382bee7 #added:2026-07-14-054851 - [x] [Epic E] ctx index: strip INDEX blocks from .context files, remove marker constants, add guards (T19-T22). Plan: specs/plans/computed-index-projection.md #session:75be038e #branch:main #commit:f382bee7 #added:2026-07-14-054851 diff --git a/Makefile b/Makefile index b50135232..60fe21611 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ clean all release build-all help \ test-coverage smoke site site-guard site-feed site-serve site-serve-lan site-setup audit check plugin-reload \ journal journal-serve journal-serve-lan gpg-fix gpg-test register-mcp reinstall check-tools \ -sync-version check-version-sync sync-why check-why sync-copilot-skills check-copilot-skills sync-steering check-steering gemini-search \ +sync-version check-version-sync sync-why check-why sync-copilot-skills check-copilot-skills sync-opencode-skills check-opencode-skills sync-steering check-steering gemini-search \ gitnexus-version gitnexus-update gitnexus-index gitnexus-mcp strip-gitnexus install-ctxctl reinstall-ctxctl # Default binary name and output @@ -35,8 +35,8 @@ sync-version: mv internal/assets/claude/.claude-plugin/plugin.json.tmp internal/assets/claude/.claude-plugin/plugin.json; \ echo "Plugin version synced to $$V" -## build: Build for current platform (syncs version + embedded docs + copilot skills first) -build: sync-version sync-why sync-copilot-skills +## build: Build for current platform (syncs version + embedded docs + copilot/opencode skills first) +build: sync-version sync-why sync-copilot-skills sync-opencode-skills CGO_ENABLED=0 go build -ldflags="-X github.com/ActiveMemory/ctx/internal/bootstrap.version=$$(cat VERSION | tr -d '[:space:]')" -o $(OUTPUT) ./cmd/ctx ## ctxctl: Build the maintainer-only ctxctl binary (audit channel) into dist/ @@ -173,6 +173,8 @@ audit: @$(MAKE) --no-print-directory check-why @echo "==> Checking Copilot skills freshness..." @$(MAKE) --no-print-directory check-copilot-skills + @echo "==> Checking OpenCode skills freshness..." + @$(MAKE) --no-print-directory check-opencode-skills @echo "==> Checking steering outputs freshness..." @$(MAKE) --no-print-directory check-steering @echo "==> Running tests..." @@ -375,6 +377,10 @@ check-version-sync: sync-copilot-skills: @./hack/sync-copilot-skills.sh +## sync-opencode-skills: Sync OpenCode skills from canonical ctx skills +sync-opencode-skills: + @./hack/sync-opencode-skills.sh + ## sync-steering: Regenerate tool-native steering outputs from .context/steering sync-steering: @CGO_ENABLED=0 go run ./cmd/ctx steering sync --all @@ -404,6 +410,21 @@ check-copilot-skills: rm -rf "$$TMPDIR"; \ echo "Copilot CLI skills are in sync." +## check-opencode-skills: Verify OpenCode skills match ctx source skills +check-opencode-skills: + @TMPDIR=$$(mktemp -d) && \ + cp -r internal/assets/integrations/opencode/skills/ "$$TMPDIR/before" && \ + ./hack/sync-opencode-skills.sh > /dev/null && \ + if ! diff -rq "$$TMPDIR/before" internal/assets/integrations/opencode/skills/ > /dev/null 2>&1; then \ + echo "FAIL: OpenCode skills are stale — run 'make sync-opencode-skills'"; \ + diff -rq "$$TMPDIR/before" internal/assets/integrations/opencode/skills/ || true; \ + cp -r "$$TMPDIR/before/"* internal/assets/integrations/opencode/skills/; \ + rm -rf "$$TMPDIR"; \ + exit 1; \ + fi; \ + rm -rf "$$TMPDIR"; \ + echo "OpenCode skills are in sync." + ## check-why: Verify embedded why docs match source docs check-why: @diff -q docs/index.md internal/assets/why/manifesto.md || (echo "FAIL: manifesto.md is stale — run 'make sync-why'" && exit 1) diff --git a/docs/home/opencode.md b/docs/home/opencode.md index 03bb67d6e..62d2be718 100644 --- a/docs/home/opencode.md +++ b/docs/home/opencode.md @@ -112,7 +112,11 @@ unnecessary. ## Slash Commands -Four skills are available as slash commands: +The skills are generated from the canonical ctx skill tree at build +time, so their names and behavior match the Claude Code integration +one-to-one. + +Session lifecycle: | Command | When to use | |---------|-------------| @@ -120,6 +124,36 @@ Four skills are available as slash commands: | `/ctx-remember` | "Do you remember?"; reads tasks, decisions, learnings, and recent journal entries. Returns a structured readback. | | `/ctx-status` | Context summary at a glance: file count, token estimate, recent activity. | | `/ctx-wrap-up` | End-of-session ceremony. Captures learnings, decisions, conventions, and outstanding tasks to `.context/` files. | +| `/ctx-handover` | Write a per-session handover note for the next agent (invoked by `/ctx-wrap-up`). | + +The planning arc from the +[Design Before Coding](../recipes/design-before-coding.md) +recipe: + +| Command | When to use | +|---------|-------------| +| `/ctx-brainstorm` | Design before implementation: turn a vague idea into a validated design. | +| `/ctx-plan` | Stress-test a plan through adversarial interview; produces a debated brief. | +| `/ctx-spec` | Scaffold a feature spec from the project template. | +| `/ctx-task-out` | Decompose a committed spec into a per-milestone implementation plan. | +| `/ctx-implement` | Execute a plan step-by-step with verification. | + +Capture: + +| Command | When to use | +|---------|-------------| +| `/ctx-task-add` | Add a task when follow-up work is identified. | +| `/ctx-decision-add` | Record an architectural decision with rationale. | + +Knowledge-base editorial pipeline (active when `.context/kb/` exists): + +| Command | When to use | +|---------|-------------| +| `/ctx-kb-ingest` | Editorial knowledge-ingestion pass over supplied sources. | +| `/ctx-kb-ask` | Q&A grounded in the existing kb. | +| `/ctx-kb-note` | Park a finding for the next ingest pass. | +| `/ctx-kb-site-review` | Mechanical structural audit of the kb. | +| `/ctx-kb-ground` | Read-only freshness audit over the kb's tracked sources. | You don't need to use these often. The plugin handles most context loading automatically. These are for when you want explicit control. diff --git a/hack/sync-opencode-skills.sh b/hack/sync-opencode-skills.sh new file mode 100755 index 000000000..7bb4eebfb --- /dev/null +++ b/hack/sync-opencode-skills.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# / ctx: https://ctx.ist +# ,'`./ do you remember? +# `.,'\ +# \ Copyright 2026-present Context contributors. +# SPDX-License-Identifier: Apache-2.0 + +# sync-opencode-skills.sh — sync OpenCode skills from canonical ctx skills. +# +# ctx skills (internal/assets/claude/skills/) are the source of truth. +# OpenCode skills (internal/assets/integrations/opencode/skills/) are +# generated from them with the `allowed-tools` frontmatter key stripped +# (Claude Code-specific, not applicable to OpenCode). +# +# Enrollment is opt-in by directory presence: a skill syncs iff its +# directory exists under the OpenCode tree. Skills that exist only in +# the OpenCode directory (no ctx counterpart) are left untouched. + +set -euo pipefail + +CTX_SKILLS="internal/assets/claude/skills" +OPENCODE_SKILLS="internal/assets/integrations/opencode/skills" + +synced=0 +skipped=0 + +for opencode_dir in "$OPENCODE_SKILLS"/*/; do + skill_name=$(basename "$opencode_dir") + ctx_skill="$CTX_SKILLS/$skill_name/SKILL.md" + opencode_skill="$opencode_dir/SKILL.md" + + if [ ! -f "$ctx_skill" ]; then + # No ctx counterpart — OpenCode-only skill, leave untouched. + skipped=$((skipped + 1)) + continue + fi + + # Strip `allowed-tools:` line from frontmatter (Claude Code-specific). + sed '/^allowed-tools:/d' "$ctx_skill" > "$opencode_skill" + synced=$((synced + 1)) +done + +echo "OpenCode skills synced: $synced updated, $skipped OpenCode-only (unchanged)." diff --git a/internal/assets/integrations/opencode/skills/ctx-agent/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-agent/SKILL.md index 5943f9372..06a253f84 100644 --- a/internal/assets/integrations/opencode/skills/ctx-agent/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-agent/SKILL.md @@ -13,7 +13,7 @@ Load the full context packet for AI consumption. ## When NOT to Use -- The plugin hook already runs `ctx agent` on session start: +- The PreToolUse hook already runs `ctx agent` automatically with a cooldown: you rarely need to invoke this manually - Don't run it just to "refresh" if you already have the context loaded in this session @@ -27,3 +27,38 @@ any code. Confirm to the user: "I have read the required context files and I'm following project conventions." Read and confirm before beginning implementation. + +## Flags + +| Flag | Default | Description | +|--------------|---------|---------------------------------------------------| +| `--budget` | 8000 | Token budget for context packet | +| `--format` | md | Output format: `md` or `json` | +| `--cooldown` | 10m | Suppress repeated output within this duration | +| `--session` | (none) | Session ID for cooldown isolation (e.g., `$PPID`) | + +## Execution + +```bash +ctx agent $ARGUMENTS +``` + +**Example: default load:** +```bash +ctx agent +``` + +**Example: smaller packet for limited contexts:** +```bash +ctx agent --budget 4000 +``` + +**Example: with cooldown (how the PreToolUse hook invokes it):** +```bash +ctx agent --budget 4000 --session $PPID +``` + +**Example: JSON for programmatic use:** +```bash +ctx agent --format json --budget 8000 +``` diff --git a/internal/assets/integrations/opencode/skills/ctx-brainstorm/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-brainstorm/SKILL.md new file mode 100644 index 000000000..36375694a --- /dev/null +++ b/internal/assets/integrations/opencode/skills/ctx-brainstorm/SKILL.md @@ -0,0 +1,243 @@ +--- +name: ctx-brainstorm +description: "Design before implementation. Use before any creative or constructive work (features, architecture, behavior changes) to transform vague ideas into validated designs." +--- + +Transform raw ideas into **clear, validated designs** through +structured dialogue **before any implementation begins**. + +## Before Brainstorming + +1. **Check if design is needed**: is the change complex enough + to warrant a design phase, or is the solution already clear? +2. **Review prior art**: check `.context/DECISIONS.md` for + related past decisions; do not re-litigate settled choices +3. **Identify what exists**: read relevant code and docs before + asking questions; do not ask the user things the codebase + already answers + +## When to Use + +- Before implementing a new feature +- Before architectural changes +- Before significant behavior modifications +- When an idea is vague and needs shaping + +## When NOT to Use + +- Bug fixes with clear solutions +- Routine maintenance tasks +- When requirements are already well-defined +- Small, isolated changes (just do them) +- When the user explicitly wants to jump straight to code + +## Usage Examples + +```text +/ctx-brainstorm +/ctx-brainstorm (new caching layer for the API) +/ctx-brainstorm (should we split the monolith?) +``` + +## Operating Mode + +Design facilitator, not builder. + +- No implementation while brainstorming +- No speculative features +- No silent assumptions +- No skipping ahead + +**Slow down just enough to get it right.** + +## The Process + +### 1. Understand Current Context + +Before asking questions: + +- Review project state: files, docs, prior decisions +- Check `.context/DECISIONS.md` for related past decisions +- Identify what exists vs what is proposed +- Note implicit constraints + +**Do not design yet.** + +### 2. Clarify the Idea + +Goal: **shared clarity**, not speed. + +Rules: +- Ask **one question per message** +- Prefer **multiple-choice** when possible +- Split complex topics into multiple questions + +Focus on: +- Purpose: why does this need to exist? +- Users: who benefits? +- Constraints: what limits apply? +- Success criteria: how do we know it works? +- Non-goals: what is explicitly out of scope? + +### 3. Non-Functional Requirements + +Explicitly clarify or propose assumptions for: + +- Performance expectations +- Scale (users, data, traffic) +- Security/privacy constraints +- Reliability needs +- Maintenance expectations + +If the user is unsure, propose reasonable defaults and mark +them as **assumptions**. + +### 4. Understanding Lock (Gate) + +Before proposing any design, pause and provide: + +**Understanding Summary** (5-7 bullets): +- What is being built +- Why it exists +- Who it is for +- Key constraints +- Explicit non-goals + +**Assumptions**: list all explicitly. + +**Open Questions**: list unresolved items. + +Then ask: +> "Does this accurately reflect your intent? Confirm or +> correct before we move to design." + +**Do NOT proceed until confirmed.** + +### 5. Explore Design Approaches + +Once understanding is confirmed: + +- Propose **2-3 viable approaches** +- Lead with your **recommended option** +- Explain trade-offs: complexity, extensibility, risk, + maintenance +- Apply YAGNI ruthlessly + +### 6. Stress-Test the Chosen Approach + +After the user picks an approach, pause for adversarial review +before moving to detailed design. + +**Surface assumptions**: +- List assumptions the chosen approach depends on +- Identify implicit dependencies (libraries, infra, team knowledge) + +**Identify failure modes**: +- What would make this approach fail? (edge cases, scale limits, + integration risks, operational complexity) +- What's the worst-case recovery if it does fail? + +**Steel-man an alternative**: +- Name the strongest argument for a different approach +- Be specific: "Approach B avoids X risk" not "there are other options" + +**Gate question**: +> "These are the risks I see. Do they change your preference, or +> should we proceed with the chosen approach?" + +Only move to detailed design after the user confirms. This is +one gate, not a debate: if the user says "proceed," proceed. + +### 7. Present the Design + +Break into digestible sections. After each, ask: +> "Does this look right so far?" + +Cover as relevant: +- Architecture +- Components +- Data flow +- Error handling +- Edge cases +- Testing strategy + +### 8. Decision Log + +Maintain a running log throughout: + +| Decision | Alternatives | Rationale | +|----------|--------------|-----------| +| ... | ... | ... | + +## After the Design + +### Persist to Context + +Once validated, persist outputs: + +```bash +# Record key decisions +ctx decision add "..." \ + --session-id ID --branch BR --commit HASH \ + --context "..." --rationale "..." --consequence "..." +``` + +### Implementation Handoff + +Only after documentation, ask: +> "Ready to begin implementation?" + +If yes: +- Create explicit implementation plan +- Break into incremental steps +- Proceed one step at a time + +## Good Example + +> **Understanding Summary**: +> - Building a cooldown mechanism for `ctx agent` hooks +> - Prevents repetitive context injection on every tool use +> - For Claude Code users running ctx in PreToolUse hooks +> - Must be session-isolated (two sessions share no state) +> - Non-goal: per-tool granularity (cooldown is global) +> +> **Assumptions**: 10-minute default cooldown is reasonable. +> +> **Open Questions**: none remaining. +> +> Does this accurately reflect your intent? + +## Bad Examples + +- Jumping to architecture diagrams before asking what the + feature is for +- Asking 5 questions in one message (ask one at a time) +- Proposing a design without the Understanding Lock step +- "Let me implement this real quick" (no implementation + during brainstorm) + +## Quality Checklist + +Exit brainstorming mode **only when**: + +- [ ] Understanding Lock confirmed by the user +- [ ] At least one design approach accepted +- [ ] Stress-test completed (assumptions, failure modes, alternatives) +- [ ] Major assumptions documented explicitly +- [ ] Key risks acknowledged +- [ ] Decision Log complete +- [ ] Decisions persisted to `.context/DECISIONS.md` + +If any criterion is unmet, continue refinement. + +## Principles + +- **Think step-by-step** before proposing anything: reason + through the problem space before jumping to solutions +- One question at a time +- Assumptions must be explicit +- Explore alternatives before committing +- Validate incrementally +- Clarity over cleverness +- Be willing to go back +- **YAGNI ruthlessly** diff --git a/internal/assets/integrations/opencode/skills/ctx-decision-add/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-decision-add/SKILL.md new file mode 100644 index 000000000..eec9251eb --- /dev/null +++ b/internal/assets/integrations/opencode/skills/ctx-decision-add/SKILL.md @@ -0,0 +1,142 @@ +--- +name: ctx-decision-add +description: "Record architectural decision. Use when a trade-off is resolved or a non-obvious design choice is made that future sessions need to know." +--- + +Record an architectural decision in DECISIONS.md. + +## When to Use + +- After resolving a trade-off between alternatives +- When making a non-obvious design choice +- When the "why" behind a choice needs to be preserved +- When future sessions need to understand why something is the way it is + +## When NOT to Use + +- Minor implementation details (use code comments instead) +- Routine maintenance or bug fixes +- Configuration changes that don't affect architecture +- When there was no real alternative to consider + +## Decision Formats + +### Quick Format (Y-Statement) + +For lightweight decisions, use a single statement: + +> "In the context of **[situation]**, facing **[constraint]**, we decided for +> **[choice]** and against **[alternatives]**, to achieve **[benefit]**, +> accepting that **[trade-off]**." + +Example: +> "In the context of needing a CLI framework, facing Go ecosystem options, +> we decided for Cobra and against urfave/cli, to achieve better subcommand +> support, accepting that it has more boilerplate." + +### Full Format + +For significant decisions, gather: + +1. **Context**: What situation prompted this decision? What constraints exist? +2. **Alternatives**: What options were considered? (At least 2) +3. **Decision**: What was chosen? +4. **Rationale**: Why this choice over the alternatives? +5. **Consequence**: What changes as a result? (Both positive and negative) + +## Gathering Information + +If the user provides only a title, ask: + +1. "What prompted this decision?" → Context +2. "What alternatives did you consider?" → Options +3. "Why this choice over the alternatives?" → Rationale +4. "What are the consequences (good and bad)?" → Consequence + +For quick decisions, offer the Y-statement format instead. + +## Cross-Referencing + +When a decision **supersedes** an earlier one: +- Mark the old decision as "Superseded by [new decision]" +- Reference the old decision in the new one +- Capture lessons learned from the original decision + +When decisions are **related**: +- Note "See also: [related decision]" in consequences + +## Execution + +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 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 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" \ + --consequence "More boilerplate, but clearer command structure" +``` + +**Full format with alternatives:** +```bash +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)." \ + --consequence "Single database handles transactions and search. Team needs PostgreSQL-specific training." +``` + +**When a flag value would be denied:** if a `--rationale`/`--context`/ +`--consequence` value contains a substring that trips a `permissions.deny` +rule on the literal command string (e.g. a path like ` /usr/local/bin`), +move the fields into a JSON file and pass `--json-file` instead — the +values never appear on the command line. The schema gates (placeholder +rejection, required fields, index maintenance) still apply. + +```bash +cat > /tmp/decision.json <<'EOF' +{ + "title": "Install ctx into the system PATH", + "context": "agents invoke ctx by bare name", + "rationale": "the binary belongs at /usr/local/bin so it is on PATH", + "consequence": "ctx resolves from any working directory", + "provenance": {"session_id": "abc12345", "branch": "main", "commit": "68fbc00a"} +} +EOF +ctx decision add --json-file /tmp/decision.json +``` + +## Authority boundary (vs other skills) + +This skill records architectural decisions — moments where a +trade-off between alternatives was deliberately resolved. It does +not unilaterally promote material from adjacent skills: + +- **Do not promote a learning into a decision.** A gotcha or + debugging insight is a learning; if the user wants it elevated + to a decision, they must say so. Pattern-cross-promotion drifts + the file's authority over time. +- **Do not promote a handover or wrap-up note into a decision.** + Session-end summaries can mention decisions, but those decisions + must have been captured at the time they were made. Backfilling + silently rewrites the trade-off record. +- **Do not invent alternatives.** If the user did not consider an + alternative, do not fabricate one to fill the section. Ask, or + use the Y-statement format that does not require alternatives. + +Light compression for clarity is allowed; new facts are not. + +## Quality Checklist + +Before recording, verify: +- [ ] Context explains the problem clearly +- [ ] At least one alternative was considered +- [ ] Rationale addresses why alternatives were rejected +- [ ] Consequence includes both benefits and trade-offs diff --git a/internal/assets/integrations/opencode/skills/ctx-handover/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-handover/SKILL.md index f8cca3e51..2bc7c835f 100644 --- a/internal/assets/integrations/opencode/skills/ctx-handover/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-handover/SKILL.md @@ -1,86 +1,283 @@ --- name: ctx-handover -description: "Per-session handover artifact writer. Wraps `ctx handover write` with required `--summary` and `--next`. Always invoked as the final step of `/ctx-wrap-up`; not the user-facing trigger. When `.context/kb/` exists, also folds postdated closeouts into the handover and archives them." +description: Per-session handover artifact writer. Wraps `ctx handover write` with `--summary` and `--next` (both required, both validated non-placeholder by the CLI). Always invoked as the final step of `/ctx-wrap-up`; not the user-facing trigger. When `.context/kb/` exists, also folds postdated closeouts into the handover and archives them. --- -Write the per-session handover under -`.context/handovers/-.md`. The handover is the -former agent's note to the next agent (or human): what -happened, and what should come next. `/ctx-remember` reads -it at the start of the next session. +# Write a Handover + +Capture the session's narrative thread so the next session (a +fresh agent, a different operator, a cold restart the next +morning) can resume without re-deriving context probabilistically +from canonical files plus journal. + +This skill is the **sole authoritative recall artifact** writer +(per `KB-RULES.md` §Four inviolable rules: *"the handover is +the sole authoritative recall artifact"*). `SESSION_LOG.md` +entries, closeouts, and journal entries are mid-flight surfaces; +the handover is what `/ctx-remember` reads on session start. + +Authoritative background reading: +`.context/ingest/KB-RULES.md` §Four inviolable rules; +`specs/kb-editorial-pipeline.md` §Interface. ## When to Use -`/ctx-wrap-up` owns the user-facing session-end trigger and -delegates to this skill as its final step. Direct invocation -is reserved for: +`/ctx-wrap-up` owns the user-facing trigger for session-end +("let's wrap up", "save state", "leave a handover", "before I +go", "stepping away") and delegates to this skill as its final +step. Do not advertise this skill as a direct user trigger. + +- **Mandatory tail of `/ctx-wrap-up`.** Every `/ctx-wrap-up` + run ends with this skill. +- Mid-session checkpoint when the user wants to pause without + consuming closeouts (use `--no-fold`). This is the one case + where direct invocation is appropriate. + +## When NOT to Use -- `--no-fold` mid-session checkpoint when the user wants to - pause without consuming closeouts. -- Recovery, when a prior session aborted before wrap-up. +- Nothing meaningful happened (only read files, quick lookup); + but check with the user. A no-op session still benefits from + a "nothing changed; next-step is X" handover when the next + session has zero context. +- The user already ran `/ctx-handover` recently in this session + and nothing has changed since. +- The user invokes a capture skill (`/ctx-task-add`, + `/ctx-decision-add`, etc.); those write to canonical files, + not to a handover artifact. -Otherwise, the user invokes `/ctx-wrap-up`, not this skill. +## Authority Boundary (vs Other Skills) + +- **`/ctx-handover`**: writes + `.context/handovers/-.md`; folds postdated + closeouts from `.context/ingest/closeouts/` into the + handover's `## Folded closeouts` section; archives folded + closeouts to `.context/archive/closeouts/`. Single writer of + this artifact. +- **`/ctx-wrap-up`**: owns the user-facing session-end + trigger. Drives the broader capture ceremony (learnings, + decisions, conventions, tasks) and always delegates to + `/ctx-handover` as its final step. +- **`/ctx-remember`**: reads the latest handover plus any + closeouts whose `generated-at` postdates the handover; the + read-side counterpart to this skill's write surface. +- **Capture skills** (`/ctx-task-add`, `/ctx-decision-add`, + `/ctx-learning-add`, `/ctx-convention-add`): write to the + five canonical files. This skill never modifies those files; + the handover narrative *references* them, it does not author + them. + +## Usage Examples + +```text +/ctx-handover "kb editorial pipeline phase KB skills drafted" +/ctx-handover "rev2 spec landed; tomorrow start the writer package" +/ctx-handover "research session on cursor hooks" +/ctx-handover --no-fold "mid-session checkpoint before lunch" +``` ## Input Contract -Wraps `ctx handover write`. Empty `TBD`, `see chat`, -whitespace-only values for required flags are rejected by -the CLI. +The skill wraps `ctx handover write`, which enforces required +flags via `MarkFlagRequired` and rejects placeholder bodies via +the Phase SK validation pattern. Empty `TBD`, `see chat`, +whitespace-only values are rejected by the CLI, not just by the +skill text. -| Flag | Required | Description | -|------|----------|-------------| -| `--summary` | yes | Past tense; what happened this session. | -| `--next` | yes | Future tense; the specific first action for the next agent. | -| `--highlights` | no | Notable artifacts produced this session. | -| `--open-questions` | no | Things that remain undecided. | -| `--no-fold` | no | Skip closeout consumption (mid-session checkpoint). | -| `--commit` | no | Override resolved git HEAD for the Provenance line (CI replay). | +| Flag | Type | Default | Description | +|------|------|---------|-------------| +| `--summary` | string | (required) | Past tense; what happened this session. | +| `--next` | string | (required) | Future tense; what the next agent should do FIRST. Specific, not vague. | +| `--highlights` | string | "" | Notable artifacts produced this session. | +| `--open-questions` | string | "" | Things that remain undecided. | +| `--no-fold` | bool | false | Skip closeout consumption (mid-session checkpoint). | +| `--commit` | string | (resolved) | Override resolved git HEAD for Provenance line (CI replay). | Positional argument: handover title (becomes filename slug). ## Pre-Write Gates +Two distinct refusals, each leaves zero residue: + - `.context/` missing → suggest `ctx init` and stop. - `.context/handovers/` missing → suggest `ctx init --upgrade` and stop. -`.context/kb/` is not required for handover; KB-state folding -is conditional on the directory's existence. +`.context/kb/` is **not** required for handover; the artifact +exists for code-dev sessions as well. KB-state folding is +conditional on the directory's existence (see §Process). ## Process -1. Verify pre-write gates. Refuse cleanly on failure. -2. Gather signal: `git status --short`, `git diff --stat`, - `git log --oneline @{upstream}..HEAD || git log --oneline -5`, - and scan the conversation for the session's arc, concrete - artifacts, open questions, and the specific next action. -3. Draft `--summary` (past tense, concrete) and `--next` - (future tense, specific). Surface to the user for - confirmation before running the CLI. -4. Run: +1. **Verify pre-write gates.** Refuse cleanly if any gate + fails. Zero residue on refusal. + +2. **Gather signal silently** (mirror `/ctx-wrap-up` Phase 1 + when invoked standalone): + + ```bash + git status --short + git diff --stat + git log --oneline @{upstream}..HEAD 2>/dev/null || git log --oneline -5 + ``` + + Scan the conversation history for: + - The session's arc: what shifted from start to now. + - Concrete artifacts produced (files, commits, decisions, + spec entries). + - Open questions surfaced but not resolved. + - The specific first action the next session should take. + +3. **Draft `--summary` and `--next`.** Both are required, both + are validated non-placeholder by the CLI: + + - **`--summary`**: past tense. One paragraph. Names what + was done, not what was attempted. Concrete: *"drafted six + Phase KB skill files; reconciled rev2 spec changes; + deferred CLI wiring to next session"*, not *"made + progress on KB stuff"*. + - **`--next`**: future tense. One paragraph. Names the + specific first action the next agent should take. + Concrete: *"start `internal/cli/handover/cmd/write/cmd.go` + using Phase SK validation pattern"*, not *"continue + work" or "look at the kb"*. + + Surface the drafts to the user for confirmation before + running the CLI. The user is the final authority on what + the handover says. + +4. **Run `ctx handover write`** with the confirmed values: ```bash ctx handover write "" \ - --summary "<...>" --next "<...>" \ - [--highlights "<...>"] [--open-questions "<...>"] \ - [--no-fold] [--commit <sha>] + --summary "<one-paragraph past tense>" \ + --next "<one-paragraph future tense>" \ + [--highlights "<bullet list>"] \ + [--open-questions "<bullet list>"] \ + [--no-fold] \ + [--commit <sha>] ``` - The CLI validates flags, resolves git HEAD, reads the - latest-handover cursor, folds postdated closeouts into - the new handover's `## Folded Closeouts` section, and - archives them under `.context/archive/closeouts/`. + The CLI: + - Validates flags (placeholder rejection per Phase SK). + - Resolves git HEAD via `gitmeta.ResolveHead` (honors + `CTX_TASK_COMMIT` and `GITHUB_SHA` for CI replay). + - Reads `LatestHandoverCursor` to find the postdated + closeout window. + - Lists `UnconsumedCloseouts` (closeouts whose + `generated-at` postdates the cursor). + - For each unconsumed closeout, folds its body into the + handover's `## Folded closeouts` section. Malformed + closeouts (missing `generated-at`, malformed frontmatter) + are skipped with a warning. + - Calls `ArchiveCloseouts` to move folded closeouts to + `.context/archive/closeouts/`. Archived closeouts are + immutable. + - Writes `.context/handovers/<TS>-<slug>.md`. + + When `--no-fold` is set, the fold + archive steps are + skipped; closeouts stay in place. Use for mid-session + checkpoints where the user wants the handover artifact but + intends to keep ingesting before the next session boundary. + +5. **Report the result.** Surface: + - The handover filename written. + - Count of closeouts folded (or *"none postdated the prior + handover"*). + - Count of malformed closeouts skipped (with filenames so + the user can fix or delete; site-review's job to flag, + but the warning here is opportunistic). + - Any CLI validation failures (with the placeholder text + that triggered rejection). + +## Closeout Fold Mechanics + +The fold mechanism is the integration point between the +editorial pipeline (`/ctx-kb-*` closeouts) and session continuity +(handover artifacts). Mechanically: -5. Report the handover filename, count of closeouts folded, - count of malformed closeouts skipped (with filenames), - and the `--next` value verbatim so the operator sees what - the next agent will read first. +- `LatestHandoverCursor` reads `.context/handovers/` and returns + the `generated-at` of the newest handover (or zero time if + none exists). +- `UnconsumedCloseouts` walks `.context/ingest/closeouts/` and + returns every closeout whose `generated-at` postdates the + cursor. +- Each folded closeout's body is embedded under + `## Folded closeouts` in the new handover, in `generated-at` + order. The frontmatter is preserved verbatim so the audit + trail survives the fold. +- After the fold, `ArchiveCloseouts` moves the source files to + `.context/archive/closeouts/`. Archived closeouts are + immutable; subsequent passes never re-fold them. + +A handover with no postdated closeouts to fold writes a +`## Folded closeouts` section with the body *"none"*; never +omit the section, so the audit trail is explicit. + +## Edge Cases + +| Case | Expected behavior | +|------|-------------------| +| `.context/` missing | Refuse; suggest `ctx init`. No residue. | +| `.context/handovers/` missing | Refuse; suggest `ctx init --upgrade`. No residue. | +| Empty `--summary` or `--next` | The CLI rejects with the placeholder-rejection message; surface verbatim. | +| Placeholder values (`TBD`, `see chat`, whitespace-only) for `--summary` or `--next` | The CLI rejects; surface verbatim and ask the user to redraft. | +| No postdated closeouts to fold | Write the handover with `## Folded closeouts` body *"none"*. Never omit the section. | +| Postdated closeout has malformed frontmatter | The CLI skips the file with a warning naming it. Report the warning to the user so they can fix or delete. | +| `--no-fold` set | Skip the fold + archive steps; the handover stands alone; closeouts stay in `.context/ingest/closeouts/` for the next invocation. | +| Mid-session re-invocation | Each invocation writes a new handover file. The newest one is what `/ctx-remember` reads next session. Multiple per session are fine. | +| Session aborted before wrap-up | Closeouts stay in place; next session's `/ctx-remember` reads canonical files + the last handover + any postdated unfolded closeouts. Editorial work survives. | +| User runs `/ctx-wrap-up` without `.context/kb/` present | `/ctx-wrap-up` still drives `/ctx-handover` as its final step; kb-presence affects what gets folded, not whether the handover is written. | +| `gitmeta.ResolveHead` returns an error (no git, detached HEAD with no fallback) | The CLI surfaces the typed `MissingGitError`; relay verbatim. Phase RG owns the recovery path; this skill does not invent one. | +| `CTX_TASK_COMMIT` or `GITHUB_SHA` set | Honoured for the Provenance line per `gitmeta.ResolveHead`'s precedence rules; no special handling here. | ## Anti-Patterns -- Hand-writing a handover file. The CLI is the sole writer. -- Skipping the fold to "keep closeouts available." Use +- Writing a handover with `--summary "TBD"` or `--next "see + chat"`. The CLI rejects these; do not work around the + rejection by inventing prose that technically passes the + placeholder check but is still vague. +- Skipping the fold to *"keep closeouts available for a future + pass"*. The fold is the integration point; closeouts that + outlive their relevant handover are recall noise. Use `--no-fold` explicitly when the user wants the checkpoint behavior; do not infer it. +- Hand-writing a handover file. The CLI is the sole writer. + Hand-edits drift from the schema the read side expects. +- Modifying an archived closeout. Archived closeouts are + immutable per `KB-RULES.md` §Closeout shape. - Inventing `--highlights` or `--open-questions` content the - session did not actually produce. + session did not actually produce. Light compression for + clarity is allowed; new facts are not. + +## Output Contract + +For pre-write refusals, return only the specified refusal text +and stop. + +For successful handover writes, end with this structured +summary: + +- **Handover**: filename on its own line. +- **Folded closeouts**: count + filenames (or *"none + postdated the prior handover"*). +- **Malformed skipped**: count + filenames (or `none`). +- **Provenance**: `sha=<short> branch=<name>` as resolved by + the CLI. +- **Next-session focus**: the `--next` value, verbatim, so the + operator sees what the next agent will read first. + +## Quality Checklist + +Before reporting completion, verify: + +- [ ] Pre-write gates passed (or the matching refusal was + returned with zero residue). +- [ ] `--summary` is past tense and concrete (no placeholder). +- [ ] `--next` is future tense and specific (no placeholder). +- [ ] User confirmed the drafts before the CLI ran. +- [ ] Closeouts were folded (or `--no-fold` was explicitly + requested). +- [ ] Folded closeouts were archived to + `.context/archive/closeouts/`. +- [ ] Handover filename + provenance were reported back to the + user. diff --git a/internal/assets/integrations/opencode/skills/ctx-implement/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-implement/SKILL.md new file mode 100644 index 000000000..9a9e0b907 --- /dev/null +++ b/internal/assets/integrations/opencode/skills/ctx-implement/SKILL.md @@ -0,0 +1,224 @@ +--- +name: ctx-implement +description: "Execute a plan step-by-step with verification. Use when you have a plan document — canonically specs/plans/<milestone>.md from /ctx-task-out — and need disciplined, checkpointed implementation." +--- + +Take a plan — canonically `specs/plans/<milestone>.md` as written +by `/ctx-task-out`, though inline text, another file path, or a +plan from the conversation also work — and execute it +step-by-step with build/test verification between steps. + +## When to Use + +- After `/ctx-task-out` has decomposed a spec into + `specs/plans/<milestone>.md` (the canonical input) +- When the user provides a plan document or file and says + "implement this" +- When a multi-step task has been planned and needs disciplined + execution +- When the user wants checkpointed progress with verification + at each step +- After `/ctx-brainstorm` or plan mode produces an approved plan + +## When NOT to Use + +- For single-step tasks: just do them directly +- When handed a bare multi-milestone spec instead of a plan: + suggest `/ctx-task-out --spec <path> --milestone <first>` + first; decomposing on the fly is what it exists to prevent +- When the plan is vague or incomplete: use `/ctx-brainstorm` + first to refine it +- When the user wants to explore or discuss, not execute +- When changes are trivial (typo fix, config tweak) + +## Usage Examples + +```text +/ctx-implement +/ctx-implement specs/plans/m0a.md +/ctx-implement path/to/plan.md +/ctx-implement (the plan from our discussion above) +``` + +## Process + +### 1. Load the plan + +- If a file path is provided, read it +- If the file is a multi-milestone spec rather than a plan (no + task breakdown, no acceptance criteria, spans milestones), + redirect: suggest `/ctx-task-out --spec <path> --milestone + <first>` and stop rather than improvising a decomposition +- If the plan's header shows `Status: Blocked`, stop: a + deferrable TBD graduated to blocking mid-milestone. Route its + resolution (a spec edit or DECISIONS.md entry) and a + `/ctx-task-out` amendment run before executing further tasks +- If inline text is provided, use it directly +- If neither, look back in the conversation for the most + recent plan or approved design +- If no plan can be found, ask the user for one + +### 2. Break into steps + +Parse the plan into discrete, checkable steps. Each step +should be: +- **Atomic**: one logical change (a file, a function, a test) +- **Verifiable**: has a clear pass/fail check +- **Ordered**: dependencies respected (create before use, + test after implement) + +Present the step list to the user for confirmation: + +> **Implementation plan** (N steps): +> +> 1. [Step description] - verify: [check] +> 2. [Step description] - verify: [check] +> 3. ... +> +> Ready to start? + +### 3. Execute step-by-step + +For each step: + +1. **Announce** what you're doing (one line) +2. **Think through** the change before writing code: what does + it touch, what could break, what's the simplest correct path? +3. **Implement** the change +4. **Verify** with the appropriate check: + - Task from a task-out plan → its acceptance criterion, + verbatim (in addition to the map below) + - Go code changed → `CGO_ENABLED=0 go build -o /dev/null ./cmd/ctx` + - Tests affected → `CGO_ENABLED=0 go test ./...` + - Config/template changed → build to verify embeds + - Docs only → no verification needed +5. **Report** step result: pass or fail +6. **If failed**: stop, diagnose, fix, re-verify before + moving to the next step + +Verify after every individual step before proceeding to the next. + +### 4. Checkpoint progress + +After every 3-5 steps (or after a significant milestone): +- Summarize what has been completed +- If executing `specs/plans/<milestone>.md`, update the execution + ledger (see Ledger Duties below) +- Note any deviations from the plan +- Ask the user if they want to continue, adjust, or stop + +### 5. Wrap up + +After all steps complete: +- Run a final full verification (`make check` or + `CGO_ENABLED=0 go build && go test ./...`) +- Summarize what was implemented +- Note any deviations from the original plan +- Suggest context to persist (decisions, learnings, tasks) + +## Ledger Duties (plans from /ctx-task-out) + +A task-out plan is the execution ledger — the only record of +milestone progress. Executing one carries four bookkeeping duties: + +- **`st` is the record.** Flip a task's `st` cell to `[x]` only + when its acceptance criterion has demonstrably passed — the + command ran, the test is green, the behavior was observed. + Tasks obsoleted by amendment become `[o]`. `st` never moves + backwards silently; a regression is a deviation to report. +- **DoD is not yours to derive.** Scope & DoD checkboxes are + confirmed by measurement or by the user — never checked because + the tasks that "cover" them are done. The rolling-wave gate + reads DoD only; deriving it from task completion defeats the + gate. +- **Project epics outward.** TASKS.md epics carry disjoint + task-id ranges (`Plan: specs/plans/<milestone>.md (Txx–Tyy)`). + When every task in a range is `[x]` or `[o]`, mark that epic + `[x]`. Sync is one-way, plan → TASKS.md; never track task + state in TASKS.md directly. +- **Amendments, not edits.** Never edit a task's acceptance + criterion in place; a criterion change goes back through + `/ctx-task-out` (amendment mode). When a measurement gate + fires (Risks & measurement gates), stop and route the outcome + through an amendment before executing dependent tasks. + +## Step Verification Map + +| Change type | Verification command | +|--------------------|---------------------------------------------------| +| Go source code | `CGO_ENABLED=0 go build -o /dev/null ./cmd/ctx` | +| Test files | `CGO_ENABLED=0 go test ./...` | +| Templates/embeds | `CGO_ENABLED=0 go build -o /dev/null ./cmd/ctx` | +| Makefile | Run the new/changed target | +| Skill files | Build (to verify embed) + check live copy matches | +| Docs/Markdown only | None required | +| Shell scripts | `bash -n script.sh` (syntax check) | + +## Handling Failures + +When a step fails verification: + +1. **Don't panic**: read the error output carefully +2. **Reason through** the failure step-by-step before attempting + a fix; understand the cause, not just the symptom +3. **Fix** the issue in the current step +4. **Re-verify** the fix +5. **Only then** move to the next step +6. If the fix changes the plan, note the deviation + +If a step fails repeatedly (3+ attempts), stop and ask the +user for guidance rather than thrashing. + +## Output Format + +Progress updates should be concise: + +``` +Step 1/6: Create ctx-next skill directory .......... OK +Step 2/6: Write SKILL.md template .................. OK +Step 3/6: Copy to live skill directory ............. OK +Step 4/6: Build to verify template embeds .......... OK +Step 5/6: Run tests ................................ OK +Step 6/6: Mark task in TASKS.md .................... OK + +All 6 steps complete. Build and tests pass. +``` + +## Examples + +### Good Implementation + +> **Step 3/8**: Add `check` target to Makefile +> Added `check: build audit` after the `audit` target. +> Verify: `make check` ... build OK, audit OK. +> **Result**: PASS + +### Bad Implementation + +> "I'll implement the whole plan now" +> *[makes all changes at once without verification]* +> "Done! Everything should work." + +(No step-by-step, no verification, no checkpoints: this +defeats the purpose of the skill.) + +## Quality Checklist + +Before starting, verify: +- [ ] Plan exists and is clear enough to execute +- [ ] Steps are broken down and presented to the user +- [ ] User confirmed readiness to proceed + +During execution, verify: +- [ ] Each step is verified before moving on +- [ ] Failures are fixed in place, not deferred +- [ ] Checkpoints happen every 3-5 steps +- [ ] Task-out plans: `st` flipped only on demonstrated + acceptance; epics projected to TASKS.md when their range + completes; DoD boxes left to measurement or the user + +After completion, verify: +- [ ] Final full verification passes +- [ ] Deviations from plan are noted +- [ ] Summary of what was implemented is presented +- [ ] Context persistence is suggested if warranted diff --git a/internal/assets/integrations/opencode/skills/ctx-kb-ask/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-kb-ask/SKILL.md index 8aa87ea04..0fd2f001f 100644 --- a/internal/assets/integrations/opencode/skills/ctx-kb-ask/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-kb-ask/SKILL.md @@ -1,8 +1,10 @@ --- name: ctx-kb-ask -description: "Q&A grounded in the existing kb. Read-only on prose; refuses to web-jump; if the kb cannot answer, opens a Q-### row in outstanding-questions.md and reports the gap. Writes an ask closeout for the audit trail." +description: Q&A grounded in the existing kb. Read-only on prose; refuses to web-jump; if the kb cannot answer, opens a Q-### row in outstanding-questions.md and reports the gap. Writes an ask closeout for the audit trail. --- +# Ask the KB + Answer a question using only what `.context/kb/` already contains. Cite by `EV-###`. Do not web-jump, do not invent prose, do not modify topic pages. If the kb cannot answer, open a `Q-###` row @@ -12,90 +14,222 @@ This is the read side of the editorial pipeline. The write side is `/ctx-kb-ingest`. Authority for prose synthesis lives there; this skill is read-only on prose. +Authoritative background reading: +`.context/ingest/KB-RULES.md` §Authority boundary and +§Evidence discipline; `specs/kb-editorial-pipeline.md` §Interface. + ## When to Use - The user asks "does the kb say...", "according to evidence...", - "what do we know about <topic>". -- The user wants a citation-backed answer before deciding - whether to ingest more material. + "what do we know about <topic>", or invokes the explicit slash + form with the question. +- The user wants a citation-backed answer before deciding whether + to ingest more material. +- The user is auditing what is already known versus what is + asserted elsewhere (DECISIONS.md, LEARNINGS.md, conversation). ## When NOT to Use -- The user wants new material extracted (`/ctx-kb-ingest`). -- The user wants the kb structurally audited - (`/ctx-kb-site-review`). -- The user wants external re-grounding (`/ctx-kb-ground`). -- The question is about `ctx` itself (answer from - `KB-RULES.md` directly). - -## Input - -A single question, supplied as the slash argument or inline. -No flags, no sources, no URLs. +- The user wants new material extracted (use `/ctx-kb-ingest`). +- The user wants the kb structurally audited (use + `/ctx-kb-site-review`). +- The user wants kb claims re-grounded against external sources + (use `/ctx-kb-ground`). +- The question is about `ctx` itself or the editorial pipeline + contract (answer from `KB-RULES.md` / spec directly). + +## Authority Boundary (vs Other Skills) + +- **`/ctx-kb-ask`**: read-only Q&A over `.context/kb/` prose, + `evidence-index.md`, `glossary.md`, `contradictions.md`, + `outstanding-questions.md`, `timeline.md`, `source-map.md`, + `domain-decisions.md`. Writes are limited to opening a + `Q-###` row in `outstanding-questions.md` when the kb cannot + answer, plus the ask closeout. +- **`/ctx-kb-ingest`**: writes prose, evidence, scaffold. Only + ingest may add citations or extend topic pages. +- **`/ctx-kb-ground`**: refreshes external sources via + `grounding-sources.md`; this skill never web-jumps to fill a + gap. If the gap matters, recommend `/ctx-kb-ground` or + `/ctx-kb-ingest`. + +## Usage Examples + +```text +/ctx-kb-ask "what does the kb say about cursor hooks failure modes?" +/ctx-kb-ask "how do we cite a transcript locator?" +/ctx-kb-ask "are there contradictions on backup retention windows?" +``` + +## Input Contract + +A single question, supplied as the slash argument or inline. No +flags. No sources. No URLs. ## Refuse-on-Empty -If no question was supplied, return exactly: +If the invocation supplied no question (empty slash arg, empty +inline body), return exactly: > no question provided; pass a question or describe it inline. -Stop. The CLI enforces this independently. +Stop. Do not prompt interactively. The CLI enforces this +independently via `cmd/ask`. ## Pre-Write Gates +Three distinct refusals, each leaves zero residue (no +`Q-###` row opened, no closeout): + - `.context/` missing → suggest `ctx init` and stop. -- `.context/kb/` missing → suggest `ctx init --upgrade` and stop. -- Kb scope undeclared → refuse with the scope message and stop. +- `.context/kb/` missing → suggest `ctx init --upgrade` and + stop. +- `.context/kb/index.md` exists but `## Scope` is undeclared → + refuse with the scope message (same wording as `/ctx-kb-ingest` + uses) and stop. ## Process -1. Verify pre-write gates. -2. Survey the kb in this order, stopping early when an answer - surfaces with adequate citation coverage: `index.md` for - scope, topic-page indexes and sub-pages for matching slugs, - `evidence-index.md`, `glossary.md`, `contradictions.md`, - `outstanding-questions.md`. -3. Decide answer vs gap: - - **Answerable with citations**: cite every load-bearing - claim by `EV-###`. Name the topic page(s). Note the - confidence floor of cited rows. - - **Partial answer**: answer the covered part; open a - `Q-###` row for the gap. - - **Not answerable**: open a `Q-###` row; report the gap. - Do not invent. Do not web-jump. -4. If a gap exists, append a `Q-###` row to - `outstanding-questions.md`. Do NOT mint `EV-###` rows; - evidence authoring is `/ctx-kb-ingest`'s authority. -5. Write the ask closeout under - `.context/ingest/closeouts/<TS>-ask-closeout.md` with - required frontmatter (`sha`, `branch`, `mode: ask`, - `pass-mode: read-only`, `life-stage`, `generated-at`) and - body sections: Question, Answer (or `none (gap)`), - Citations (`EV-###` + topic-page paths), Gaps (`Q-###` - opened with one-line rationale), Next pass hint. +1. **Verify pre-write gates.** Refuse cleanly if any gate fails. + Zero residue on refusal. + +2. **Read the question.** Parse for the concept(s) it names. + +3. **Survey the kb.** Read in this order, stopping early when an + answer surfaces with adequate citation coverage: + - `.context/kb/index.md` for scope. + - `.context/kb/topics/<slug>/index.md` and any sibling + sub-pages for any slug that plausibly matches the question. + - `.context/kb/evidence-index.md` for `EV-###` rows whose + claim text matches. + - `.context/kb/glossary.md` for term definitions. + - `.context/kb/contradictions.md` for known disagreements + relevant to the question. + - `.context/kb/outstanding-questions.md` for prior + unanswered questions on the topic. + +4. **Decide answer vs gap.** One of three outcomes: + + - **Answerable with citations.** The kb's prose plus + `EV-###` rows cover the question. Compose a concise answer. + Cite every load-bearing claim by `EV-###`. Name the topic + page(s) where the prose lives. Note the Confidence floor + of the cited rows. + - **Partial answer.** Some of the question is covered; the + rest is not. Answer the covered part with citations. Name + the gap explicitly. Open a `Q-###` row for the gap (see §6). + - **Not answerable.** The kb has no prose and no `EV-###` + coverage. Do not invent. Do not web-jump. Open a `Q-###` + row (see §6) and report the gap. + +5. **Do not jump.** This skill is read-only on prose AND + web-quiet. If the kb cannot answer: + + - Do **not** fetch a URL. + - Do **not** propose synthesized prose without citations. + - Do **not** call MCP search tools. + - Do **not** quote LLM training-data recall as if it were + kb evidence. + + The correct response to a gap is to name the gap, open a + `Q-###` row, and recommend `/ctx-kb-ground` (if external + refresh is the right path) or `/ctx-kb-ingest <sources>` (if + the user has materials to feed in). + +6. **Open a `Q-###` row if there is a gap.** Append a row to + `.context/kb/outstanding-questions.md` per its schema. The + row's question text is the user's question (or a faithful + paraphrase). The row notes what the kb does cover (if + partial) and what evidence would resolve. Do NOT mint + `EV-###` rows from this skill; that is ingest's authority. + +7. **Write the ask closeout.** Create + `.context/ingest/closeouts/<TIMESTAMP>-ask-closeout.md` with + required frontmatter: + + ```yaml + --- + sha: <short> + branch: <name> + mode: ask + pass-mode: read-only + life-stage: <bootstrap|maintenance> + generated-at: <RFC-3339> + --- + ``` + + Body sections: + - **Question**: what the user asked, verbatim. + - **Answer**: the answer given, or `none (gap)` if not + answerable. + - **Citations**: `EV-###` IDs cited, with topic-page paths. + - **Gaps**: `Q-###` opened in `outstanding-questions.md`, + with a one-line rationale. + - **Next pass hint**: explicit invocation for the next + pipeline step (e.g. `/ctx-kb-ground` to refresh, + `/ctx-kb-ingest <sources>` to extend). + +## Edge Cases + +| Case | Expected behavior | +|------|-------------------| +| Empty question | Refuse with the standard no-question text. No `Q-###` opened, no closeout. | +| `.context/` missing | Refuse; suggest `ctx init`. No residue. | +| `.context/kb/` missing | Refuse; suggest `ctx init --upgrade`. No residue. | +| Kb scope undeclared | Refuse with the scope message; point at `.context/kb/index.md`. No residue. | +| Multiple topics relevant | Cite each topic page; do not synthesize a new cross-topic claim (that would be ingest work). Surface the seam as a `Q-###` if it merits one. | +| Contradiction surfaces during answer | Answer with the lower-confidence side noted; cite both `EV-###` rows; point at `contradictions.md`. | +| Cited rows are all `speculative` or `low` | Surface the confidence band in the answer. Recommend `/ctx-kb-ground` to corroborate. Do not promote in this pass. | +| Question matches an existing `Q-###` row | Cite the existing row's ID; report status (`open`, `partially-answered`); do not open a duplicate. | +| Question requires external evidence the kb does not have | Open a `Q-###` row; recommend `/ctx-kb-ground` with the gap named; do not fetch the source. | +| Question is meta (about the pipeline itself) | Answer from `KB-RULES.md` / spec directly; this skill is for kb content, not pipeline contract. State that explicitly. | ## Anti-Patterns - Web-jumping when the kb cannot answer. The contract is read-only on prose AND web-quiet. -- Inventing citations or claims. -- Modifying a topic page to extend an answer mid-pass. -- Minting `EV-###` rows from this skill. -- Skipping the `Q-###` row when the kb cannot answer. -- Skipping the closeout once pre-write gates pass. +- Inventing citations or claims to make the answer look fuller. +- Modifying a topic page to extend an answer mid-pass. Topic-page + authoring is `/ctx-kb-ingest`'s authority. +- Minting `EV-###` rows from this skill. Evidence authoring is + `/ctx-kb-ingest`'s authority. +- Skipping the `Q-###` row when the kb cannot answer. The gap + is the audit trail; silence on a gap is invisible. +- Skipping the closeout once the pre-write gates pass. The + closeout is the residue wrap-up's handover step folds into + the next session's recall. ## Output Contract -For pre-write refusals, return only the refusal text and stop. +For pre-write refusals, return only the specified refusal text +and stop. No residue. -For passes that clear pre-write gates, end with: +For passes that clear pre-write gates, end with this structured +summary: - **Question**: verbatim or faithful paraphrase. - **Answer**: concise; cites every load-bearing claim by `EV-###`. -- **Confidence floor**: lowest band among cited rows. -- **Gaps**: `Q-### opened`, or `none`. -- **Closeout**: filename. +- **Confidence floor**: lowest band among cited rows + (`high|medium|low|speculative`), or `n/a` if no rows cited. +- **Gaps**: `Q-### opened` (one bullet per opened row), or + `none`. +- **Closeout**: filename on its own line. - **Next-recommended-action**: explicit invocation if a gap - was opened (`/ctx-kb-ground` or - `/ctx-kb-ingest <sources>`), or `none`. + was opened (e.g. `/ctx-kb-ground` or `/ctx-kb-ingest + <sources>`), or `none` if the answer is complete. + +## Quality Checklist + +Before reporting completion, verify: + +- [ ] Pre-write gates passed (or the matching refusal was + returned with zero residue). +- [ ] Every load-bearing claim in the answer cites at least one + `EV-###` row from `evidence-index.md`. +- [ ] If a gap exists, a `Q-###` row was opened (or an existing + row was cited). +- [ ] No URL was fetched, no MCP search was called, no LLM + training-data recall was quoted as kb evidence. +- [ ] No topic page was modified, no `EV-###` row was minted. +- [ ] Closeout written with all required frontmatter fields. diff --git a/internal/assets/integrations/opencode/skills/ctx-kb-ground/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-kb-ground/SKILL.md index 07e18a8c6..869ca9750 100644 --- a/internal/assets/integrations/opencode/skills/ctx-kb-ground/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-kb-ground/SKILL.md @@ -1,85 +1,290 @@ --- name: ctx-kb-ground -description: "Read-only freshness audit over the kb's tracked sources (URLs, in-tree paths, MCP resources) declared in grounding-sources.md. Classifies each source's drift state, annotates the source-coverage ledger, and writes a ground closeout; flags drifted or new-to-kb sources for /ctx-kb-ingest. Never mints evidence, authors prose, or transitions ledger states." +description: Read-only freshness audit over the kb's tracked sources (URLs, in-tree paths, MCP resources) declared in grounding-sources.md. Classifies each source's drift state, annotates the source-coverage ledger, and writes a ground closeout; flags drifted or new-to-kb sources for /ctx-kb-ingest. Never mints evidence, authors prose, or transitions ledger states. --- +# Ground the KB Against Its Tracked Sources + Walk the sources declared in `.context/ingest/grounding-sources.md` and report whether the kb's claims are still current. This is the -*"are we still current?"* pass — a read-only freshness audit, not -a re-ingest. +*"are we still current?"* pass — a **read-only freshness audit**, +not a re-ingest. -Each tracked source — URLs, in-tree paths, or MCP resources — +Each tracked source — **URLs, in-tree paths, or MCP resources** — gets resolved and classified as `unchanged`, `drifted`, `gone`, `freshness opaque`, or `new to kb`. The skill annotates the -source-coverage ledger's `Residue` / `Next action` cells and -writes a ground closeout. It does NOT mint `EV-###` rows, author -topic-page prose, transition ledger states, or modify Confidence -bands; those are `/ctx-kb-ingest`'s authority. - -If a tracked source drifted or is new to the kb, flag it and -recommend a follow-up `/ctx-kb-ingest`. The declarative watch -list in `grounding-sources.md` persists across sessions and -tracks sources from anywhere the kb cites — the web, this repo's -tree, an MCP server. Distance from the repo is irrelevant; what -matters is that the kb depends on them for evidence. +source-coverage ledger's `Residue` and `Next action` cells and +writes a ground closeout summarising findings. It does **NOT** +mint `EV-###` rows, author topic-page prose, transition ledger +states, or modify Confidence bands; those are `/ctx-kb-ingest`'s +authority. + +If a tracked source drifted or is new to the kb, this skill flags +it and recommends a follow-up `/ctx-kb-ingest`. The declarative +watch list in `grounding-sources.md` is what makes this skill +distinct from ingest: it **persists across sessions** (ingest's +source list is per-invocation) and tracks sources from anywhere +the kb cites — public web, this repo's tree, behind an MCP +server. Distance from the repo is irrelevant; what matters is +that the kb depends on them for evidence. + +Authoritative background reading: +`.context/ingest/KB-RULES.md` §Authority boundary and +§Source-coverage ledger; `specs/kb-editorial-pipeline.md` +§Interface and §Edge Cases. ## When to Use - The user says "re-ground the kb", "check upstream", - "refresh sources". -- A grounding cadence is hitting its scheduled boundary. -- A prior pass left a `Q-###` row that names "needs - re-grounding". + "are the docs still current?", or invokes the explicit slash + form. +- Before a release / handover where source freshness matters. +- After an external vendor has shipped a version bump. +- Periodically (per the user's cadence) as kb hygiene. ## When NOT to Use -- The user has new sources to add (`/ctx-kb-ingest`). -- The user asks a question (`/ctx-kb-ask`). -- The user wants a mechanical audit (`/ctx-kb-site-review`). +- The user has new materials in hand (use `/ctx-kb-ingest`). +- The user is asking a content question (use `/ctx-kb-ask`). +- The user wants a structural audit (use `/ctx-kb-site-review`). + +## Authority Boundary (vs Other Skills) + +- **`/ctx-kb-ground`**: read-only freshness audit over the + sources listed in `grounding-sources.md` (URLs, in-tree paths, + MCP resources). Annotates the source-coverage ledger's + `Residue` and `Next action` cells; writes a ground closeout. + **May not** mint `EV-###` rows, author prose, modify a topic + page, change a Confidence band, or transition ledger states. +- **`/ctx-kb-ingest`**: handles anything this skill surfaces + as new material to absorb. +- **`/ctx-kb-ask`**: handles read-only questions about kb + content. +- **`/ctx-kb-site-review`**: handles structural audit (separate + surface from source-freshness audit). + +## Usage Examples + +```text +/ctx-kb-ground +``` + +No arguments. Sources come from +`.context/ingest/grounding-sources.md`. + +## Input Contract -## Input +The file `.context/ingest/grounding-sources.md` is the sole +declaration surface. Each non-empty, non-comment line names a +source (URL, in-tree path, MCP resource identifier) the user +wants this skill to track. A line whose value is the literal +`NONE` is a **per-pass skip**: this invocation does nothing and +re-prompts on the next invocation. Lines beginning with `#` are +comments. -No positional arg. Sources come from -`.context/ingest/grounding-sources.md` (one source per line; -`NONE` on a line is a per-pass skip). +There is no CLI argument for sources. To configure what this +skill checks, edit `grounding-sources.md`. ## Pre-Write Gates +Three distinct refusals, each leaves zero residue: + - `.context/` missing → suggest `ctx init` and stop. - `.context/ingest/` missing → suggest `ctx init --upgrade` and stop. -- `grounding-sources.md` missing or empty → prompt the user - once for sources to add; if they decline, write a ground - closeout with `sources: 0` and stop. +- Kb scope undeclared → refuse with the scope message and stop. + +## Refuse-on-Empty + +`.context/ingest/grounding-sources.md` may be in three states: + +1. **Missing or empty**: file does not exist, or has only + comments and blank lines. Prompt once: + + > `grounding-sources.md` has no sources. List one source per + > line (URL, in-tree path, MCP resource). `NONE` on a line + > is a per-pass skip and re-prompts next invocation. + + Stop. Do not synthesize a list. Do not invent sources from + the kb's `source-map.md` (that file's authority is ingest; + grounding's declaration surface is separate by design). + +2. **Single line `NONE`**: per-pass skip. Write no closeout; + return exactly: + + > grounding-sources.md is `NONE` for this pass; skipping. + > Edit `.context/ingest/grounding-sources.md` to set actual + > sources, or leave `NONE` to keep skipping. + + The next invocation re-prompts as in (1) above. + +3. **One or more sources listed**: proceed to Process. + +The empty-and-prompt path is the one exception to the +refuse-on-empty pattern other mode skills enforce; the rationale +is that grounding's declaration lives in a file the user owns +(not in a slash argument), so a one-shot prompt is cheaper than +forcing them to remember the filename. ## Process -1. Verify pre-write gates. -2. Read `.context/ingest/grounding-sources.md`. For each - non-skipped line, fetch / re-read the source and compare - against `evidence-index.md` rows already citing it. -3. Update the source-coverage ledger row for each source - touched: `partially-ingested` → `partially-ingested` - (touched), `comprehensive` → `comprehensive` (if no drift - detected), or flag drift in the closeout. -4. For each source that surfaces material the kb should - absorb, flag it and recommend a follow-up - `/ctx-kb-ingest` invocation in the closeout's Next pass - hint. -5. Write the ground closeout under - `.context/ingest/closeouts/<TS>-ground-closeout.md` with - required frontmatter (`sha`, `branch`, `mode: ground`, - `pass-mode: n/a`, `life-stage`, `generated-at`) and a - body listing each source touched, its drift verdict, and - any Next pass hint. +1. **Verify pre-write gates.** Refuse cleanly if any gate fails. + Zero residue on refusal. + +2. **Read `.context/ingest/grounding-sources.md`.** Handle the + three states per §Refuse-on-empty. + +3. **For each declared source**, in order of appearance: + + - **Resolve** the source: fetch the URL, stat the in-tree + path, enumerate the MCP resource. + - **Cross-reference** against `.context/kb/source-map.md` to + find the kb's short-name for this source (if any). If + absent, the source is *new to the kb*; record it as a flag + to surface in the closeout (do not mint a `source-map.md` + row; that is ingest's authority). + - **Check freshness** using the strongest available signal: + - URL: HTTP Last-Modified header, or ETag, or visible + version stamp on the page; compare against the + `source-map.md` row's `dated:` cell (if present). + - In-tree path: file mtime + git SHA; compare against the + `evidence-index.md` rows that cite the source by SHA + (in-repo citations pin to a SHA at extraction time per + `KB-RULES.md` §Evidence discipline). + - MCP resource: whatever freshness primitive the resource + exposes; if none, treat as opaque (record as + *"freshness opaque"* in the closeout). + - **Classify the refresh outcome** as one of: + - **`unchanged`**: source has not drifted since the + kb's last extraction; no ledger update needed. + - **`drifted`**: source has changed; the kb's claims + citing this source may be stale; advance the ledger row + to a state that reflects the staleness: + - If the row was `comprehensive`, advance to a typed + `superseded-pending` annotation in the `Residue` cell + (do not write a new state name; the state machine in + `KB-RULES.md` is closed; `Residue` is the + human-readable annotation surface). + - If the row was anywhere prior to `comprehensive`, + leave the state and add a `drifted` note in `Residue` + + `Next action` set to the explicit + `/ctx-kb-ingest <slug>` resumption. + - **`gone`**: source returns 404, file deleted, MCP + resource removed; flag for the user. The right + resolution may be `superseded` (with a named successor) + or `skipped` (out of scope); that judgment is the + user's, not this skill's. + - **`freshness opaque`**: no freshness signal available; + record in `Residue` cell as *"freshness opaque + (<date checked>)"*; no ledger state change. + - **Advance the ledger row** only for `drifted` and `gone` + cases, and only via `Residue` / `Next action` annotation + (not state change). State transitions out of `comprehensive` + are ingest's authority. + +4. **Write the ground closeout.** Create + `.context/ingest/closeouts/<TIMESTAMP>-ground-closeout.md` + with required frontmatter: + + ```yaml + --- + sha: <short> + branch: <name> + mode: ground + pass-mode: refresh + life-stage: <bootstrap|maintenance> + generated-at: <RFC-3339> + --- + ``` + + Body sections: + - **Inputs**: declared sources from + `grounding-sources.md`, count + one bullet each. + - **Refresh outcomes**: for each source: `unchanged`, + `drifted`, `gone`, `freshness opaque`, or `new to kb`. + Cite the kb short-name (or *"new to kb"*) and the + evidence used to classify (Last-Modified header, version + stamp, file mtime). + - **Ledger updates**: every `Residue` / `Next action` + change applied to a `source-coverage.md` row, with the + before/after annotation. + - **Flags**: sources the refresh found `gone`, sources + classified `new to kb`, sources with conflicting + freshness signals. Each flag names the source and the + recommended next pipeline step. + - **Next pass hint**: explicit invocations to absorb + drifted / new material (e.g. *"`/ctx-kb-ingest <slug>` to + refresh `cursor/hooks` against the v1.2 docs"*). + +## Edge Cases + +| Case | Expected behavior | +|------|-------------------| +| `grounding-sources.md` missing or empty (only comments/blank) | Prompt once with the standard text; stop. No closeout. | +| `grounding-sources.md` single line `NONE` | Skip this pass with the standard skip text; stop. No closeout. | +| `.context/` missing | Refuse; suggest `ctx init`. No residue. | +| `.context/ingest/` missing | Refuse; suggest `ctx init --upgrade`. No residue. | +| Kb scope undeclared | Refuse with the scope message. No residue. | +| Source returns 404 / file deleted / MCP resource removed | Classify `gone`; flag; recommend the user choose `superseded` (with successor) or `skipped` (out of scope). Do not auto-transition. | +| Source unchanged since last extraction | Record `unchanged` in closeout's `Refresh outcomes`; no ledger update. | +| Source drifted since last extraction (URL bumped, file mtime newer than cited SHA) | Record `drifted`; annotate ledger row's `Residue` / `Next action`; recommend `/ctx-kb-ingest <slug>`. Do not modify topic-page prose. | +| Source has no freshness primitive (opaque) | Record `freshness opaque (<date checked>)`; no ledger state change; surface in `Flags` so the user can decide cadence. | +| Source listed in `grounding-sources.md` but not in `source-map.md` (new to kb) | Classify `new to kb`; flag; recommend `/ctx-kb-ingest <source>` to admit. Do not mint a `source-map.md` row from this skill. | +| Source listed in `grounding-sources.md` but URL malformed or path nonexistent | Surface as a per-source error in the closeout's `Flags`; continue with remaining sources; do not abort the pass. | +| Source's `source-map.md` row has `dated:` but `evidence-index.md` rows lack `occurred:` | Flag (temporal-precedence rule needs it); recommend hand-edit. Do not auto-edit. | +| User added a new source to `grounding-sources.md` since the last pass | Treated as a regular declared source; classified per the freshness check; no special path. | +| Mid-pass MCP fetch failure | Record per-source error; continue; do not abort the whole pass. | ## Anti-Patterns -- Authoring topic-page prose from refresh output. Authoring - is `/ctx-kb-ingest`'s authority. -- Minting `EV-###` rows. Evidence minting is ingest's - authority. -- Promoting confidence bands without contradicting evidence. - Drift detection alone is not promotion. -- Skipping the closeout. Even a no-op refresh writes one so - the ledger advance is auditable. +- Minting `EV-###` rows from this skill. Evidence authoring is + ingest's authority. +- Authoring topic-page prose from this skill. Page authoring is + ingest's authority. +- Modifying a claim's Confidence band from this skill. Demotion + is evidence work. +- Auto-transitioning a `comprehensive` ledger row out of + `comprehensive`. State changes require ingest judgment; this + skill annotates `Residue` / `Next action` only. +- Synthesising a source list when `grounding-sources.md` is + empty. The declaration surface is the file the user owns. +- Inventing a freshness signal when none exists. *"Freshness + opaque"* is the honest classification. +- Skipping the closeout once pre-write gates pass and at least + one source was processed. + +## Output Contract + +For pre-write refusals, return only the specified refusal text +and stop. No residue. + +For empty / `NONE` cases, return the matching prompt or skip +text and stop. No closeout in those cases. + +For passes that processed at least one source, end with this +structured summary: + +- **Sources checked**: count + one bullet each, classified + (`unchanged | drifted | gone | freshness opaque | new to kb`). +- **Ledger updates**: count + one-line categories. +- **Flags**: count + categories. +- **Closeout**: filename on its own line. +- **Next-recommended-action**: explicit invocations to absorb + drifted / new material (or `none` if every source was + `unchanged`). + +## Quality Checklist + +Before reporting completion, verify: + +- [ ] Pre-write gates passed (or the matching refusal was + returned with zero residue). +- [ ] Every declared source from `grounding-sources.md` was + checked, classified, and recorded in `Refresh outcomes`. +- [ ] No `EV-###` row was minted, no topic-page prose was + written, no Confidence band was changed, no ledger state + was transitioned (only `Residue` / `Next action` + annotated). +- [ ] Every `drifted` / `gone` / `new to kb` source has an + explicit `Next-recommended-action`. +- [ ] Closeout written with all required frontmatter fields. diff --git a/internal/assets/integrations/opencode/skills/ctx-kb-ingest/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-kb-ingest/SKILL.md index 396ed9099..4c6e4d9d5 100644 --- a/internal/assets/integrations/opencode/skills/ctx-kb-ingest/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-kb-ingest/SKILL.md @@ -1,157 +1,644 @@ --- name: ctx-kb-ingest -description: "Editorial knowledge-ingestion pass. Reads sources the user supplies, declares its pass-mode (topic-page / triage / evidence-only) before extraction, and is held to mode-specific completion semantics. The topic page is the deliverable; the closeout is the audit trail." +description: Editorial knowledge-ingestion pass. Reads sources the user supplies, declares its pass-mode (topic-page / triage / evidence-only) before extraction, and is held to mode-specific completion semantics. The topic page is the deliverable; the closeout is the audit trail. --- -Single editorial pass that adds knowledge to `.context/kb/`. -Reads materials the user supplies, decides which topic page(s) -they belong to, finds-or-creates those pages, writes synthesized -prose section by section, mints `EV-###` rows as it cites them, -cross-links neighbouring topics, updates the source-coverage -ledger, and writes a closeout under `.context/ingest/closeouts/`. +# Editorial Ingestion Pass + +This skill is the **single editorial pass** for adding knowledge +to `.context/kb/`. It reads materials the user supplies, decides +which topic page(s) they belong to, finds-or-creates those pages, +writes synthesized prose section by section, mints `EV-###` rows +in the structured layer as it cites them, cross-links neighboring +topics, updates the source-coverage ledger, and writes a closeout +file under `.context/ingest/closeouts/`. + +The split between "extract claims" and "write the topic page" is +mechanical, not editorial. A student reading a book does not +extract a glossary first and synthesize later, they read and write +at the same time. This skill matches that model: the user supplies +*intent and material*; the skill does *judgment and typing*. + +**The topic page is the deliverable. The closeout is the audit +trail. The closeout never substitutes for the page.** Intermediate +artifacts (EV rows, glossary entries, candidate-source registries, +closeouts) are valuable, but they do not validate topic-page work +by themselves; only the topic page does. Authoritative background reading lives at -`.context/ingest/KB-RULES.md`. This skill encodes the workflow -contract; the rules file is the constitution. Hand-edit -`KB-RULES.md` to evolve the contract; do not paraphrase it -here. +`.context/ingest/KB-RULES.md` and `specs/kb-editorial-pipeline.md`. +This skill encodes the workflow contract; the rules file is the +constitution. Hand-edit `KB-RULES.md` to evolve the contract; do +not paraphrase it here. ## When to Use - The user supplies one or more sources (paths, URLs, MCP - resources, inline natural-language descriptions) and wants - them read into the kb. + resources, inline natural-language descriptions) and wants them + read into the kb. - The user says "ingest the transcripts", "pull this into the - kb", "add evidence from <source>", or invokes the slash form - with paths. + kb", "add evidence from <source>", "extract claims from this + call", or invokes the explicit slash form with paths. +- A prior pass left residue (a `topic-page-drafted` ledger row, + a `Next pass hint` in a closeout) and the user is resuming. ## When NOT to Use - The user asked a question about the kb (use `/ctx-kb-ask`). -- The user wants a structural audit (use `/ctx-kb-site-review`). -- The user wants external re-grounding (use `/ctx-kb-ground`). -- The user wants to park a quick finding (use `/ctx-kb-note`). -- No sources were supplied (refuse-on-empty). +- The user wants a structural audit of the kb (use + `/ctx-kb-site-review`). +- The user wants to re-ground existing kb claims against + external sources (use `/ctx-kb-ground`). +- The user wants to park a quick finding for the next ingest + (use `/ctx-kb-note`). +- No sources were supplied (refuse-on-empty; see §Refuse-on-empty + below). +- `.context/kb/` does not exist (refuse with the no-pipeline + message in §Pre-write gates). + +## Authority Boundary (vs Other Skills) + +- **`/ctx-kb-ingest`**: primary editorial pass. Reads materials + (in-tree paths, out-of-tree paths, URLs, MCP resources, inline + references); writes topic pages + (`.context/kb/topics/<slug>/index.md`, plus optional sibling + sub-pages); mints evidence, glossary, source-map, timeline, + contradictions, outstanding questions; cross-links into existing + kb topology; updates the source-coverage ledger; writes + closeout. **Topic-page file creation is performed only by + `ctx kb topic new`**: this skill MAY invoke that CLI as part + of a topic-page pass, but it MUST NOT synthesize or write a + scaffold directly. This preserves the public editorial workflow + (`/ctx-kb-ingest`) and the actual scaffold authority + (`ctx kb topic new`) as two separate facts. +- **`/ctx-kb-ask`**: Q&A grounded in the kb. Read-only on prose; + refuses to web-jump; flags gaps the kb cannot answer. +- **`/ctx-kb-site-review`**: structural audit; mechanical fixes + only. Defers anything that requires evidence judgment. +- **`/ctx-kb-ground`**: external grounding against + `grounding-sources.md`; advances ledger rows for sources it + refreshes. +- **`/ctx-kb-note`**: lightweight capture into + `.context/ingest/findings.md`; never writes to a topic page or + to `evidence-index.md`. + +This skill writes prose AND evidence rows AND scaffold (via CLI) +AND cross-links AND ledger updates in the same pass; that +combination is unique to ingest. -## Input +## Usage Examples -Sources, supplied as one or more of: paths (file or folder), -URLs, MCP resources, or inline natural-language gestures. -Optional second argument is the topic name; when omitted the -skill proposes one and confirms before extraction. +```text +/ctx-kb-ingest ./inputs/2026-04-12-call.md "cursor hooks" +/ctx-kb-ingest ./inputs/your-domain/ +/ctx-kb-ingest https://cursor.com/docs/hooks +/ctx-kb-ingest ./a.md ./b.md "incident retros" +/ctx-kb-ingest --inline "the four transcripts under inputs/ \ + and the pool.go file" "connection pooling" +``` + +## Input Contract + +**Sources**, supplied as one or more of: + +- **Paths**: folder to recurse, single file, list of files. +- **URLs**: primary-source web pages. +- **MCP resources**: named resources from connected MCP servers. +- **Inline gestures**: natural-language naming the materials. +- **Open invitation**: *"feel free to search for more"*. The + skill gets web-search and MCP-discovery authority for this + pass; hard cap of 50 total sources. + +**Optional second argument, topic name**, e.g. *"cursor hooks"*. +When omitted, the skill proposes one at §3 of Process and +confirms with the user before any extraction work. Naming the +topic up front skips that round-trip. ## Refuse-on-Empty -If the invocation supplied no sources, return exactly: +The skill writes to the kb; refuse-on-empty is the default. If +the invocation supplied no sources and no inline gesture, return +exactly: > no sources provided; pass a folder, a URL, an MCP resource, or > describe the materials inline. -Stop. The CLI enforces this independently. +Stop. Do not prompt for sources interactively, do not invent a +topic, do not propose a triage pass on imagined material. The CLI +enforces this independently via `cmd/ingest`. ## Pre-Write Gates -- `.context/` missing → suggest `ctx init` and stop. -- `.context/ingest/` missing → suggest `ctx init --upgrade` - and stop. -- Kb scope undeclared (`.context/kb/index.md` missing, or its - `## Scope` H2 holds the `TODO` placeholder, or lacks - substantive non-placeholder prose): +Three distinct refusals, each leaves zero residue (no +`INBOX.md` rewrite, no `SESSION_LOG.md` entry, no claim +extraction, no ledger update, no closeout, no topic-page edits): + +- `.context/` missing entirely → suggest `ctx init` and stop. +- `.context/ingest/` missing (project initialised before this + spec shipped) → suggest `ctx init --upgrade` and stop. +- Kb scope undeclared (`.context/kb/index.md` missing, contains + the `TODO: declare what this kb covers` placeholder, has no + `## Scope` H2, or `## Scope` lacks substantive + non-placeholder prose): > kb scope is undeclared. Open `.context/kb/index.md` and > replace the TODO placeholder with a one-paragraph scope > statement that names what is in scope and what is out. + > `/ctx-kb-ingest` refuses to ingest until scope is declared. ## Pass-Mode Contract -Every invocation classifies itself as exactly one mode before -extraction begins. Full semantics in +Every invocation MUST classify itself as exactly one of three +modes **before any source extraction begins**. The mode commits +the pass to a specific definition of done; the skill is held to +that definition and may not narrate success on residue belonging +to a different mode. Full mode semantics live in `.context/ingest/KB-RULES.md` §Pass-mode contract. | Mode | Mints prose? | Mints `EV-###`? | Touches topic page? | Default? | |------------------|--------------|------------------|------------------------|----------| | `topic-page` | yes | yes | yes (create/extend) | yes | -| `triage` | no | no | no | no | +| `triage` | no | **no** | no | no | | `evidence-only` | no | yes (tagged) | no | no | -Default is `topic-page`. `triage` fires when sources are -disparate with no clear single topic, or the user explicitly -asks for triage. `evidence-only` fires only on explicit user -request ("just mint EV rows", "backfill evidence"); never -inferred from source size or operator convenience. +**Mode selection rules.** Default is `topic-page`. `triage` fires +only when the user supplied multiple disparate sources with no +clear single topic, OR explicitly invoked triage language. +`evidence-only` fires only on explicit user request matching the +valid-trigger criteria (*"just mint EV rows"*, *"backfill +evidence"*); the skill MAY NOT infer it from source size, +ambiguity, time pressure, or operator convenience. -Before extraction, emit the declaration in the response stream: +**Up-front declaration (mandatory).** Before extraction begins +(after pre-write gates pass and **before** topic resolution), emit +a visible pre-work declaration in the response stream: > **Pass-mode:** `<mode>` > **Reason:** `<one sentence; required when non-default>` > **Definition of done:** `<mode-specific completion criterion>` -The declaration is a contract. Mid-pass mode-switching is -forbidden: abort with a partial closeout and recommend -re-invocation under the correct mode. +The declaration is a contract, not a label. The skill is bound to +it for the rest of the pass. + +**Mid-pass mode-switching is forbidden.** If the work in flight +no longer fits, abort with a partial closeout citing what was +done, and recommend re-invocation under the correct mode. Silent +mode-drift is a hard anti-pattern. ## Topic-Page Circuit Breaker -A pass in `topic-page` mode may not report `topic-page: -produced` or `topic-page: extended` unless: +A pass operating in `topic-page` mode MAY NOT report +`topic-page: produced` or `topic-page: extended` unless ALL of +the following are true at completion: + +1. `.context/kb/topics/<slug>/index.md` (or a sibling sub-page + like `.context/kb/topics/<slug>/<sub>.md`) exists and was + created or extended in this pass. +2. The page cites at least one `EV-###` row that resolves to + `evidence-index.md`. +3. `ctx kb site build` ran clean (or its failure is named in the + closeout's `Next pass hint` AND the pass reports + `topic-page: deferred`). +4. The cold-reader orientation rubric records **`Result: pass`** + in the closeout's `What changed` section. All four rubric + items must be `yes`. + +Any failure → `topic-page: deferred` and the source-coverage +ledger advances to `topic-page-drafted` (not `comprehensive`). +This invariant prevents intermediate residue from being treated +as topic-page success. **Topic-page validation requires the +topic page.** + +## Source-Coverage Ledger + +`.context/kb/source-coverage.md` is a state machine over every +source the kb has touched. Allowed transitions live in +`KB-RULES.md` §Source-coverage ledger; do not paraphrase them +here. Every pass updates the ledger before writing the closeout. +**Lying to the ledger is a hard anti-pattern.** Set the state +honestly even when it means recording incomplete work. + +## Cold-Reader Orientation Rubric + +Four yes/no items recorded in the closeout's `What changed` +section, in `topic-page` mode: + +``` +Cold-reader orientation: +- Concept clear? yes|no: <short note> +- Why this kb cares clear? yes|no: <short note> +- Canonical evidence reachable? yes|no: <short note> +- Boundaries clear? yes|no: <short note> +Result: pass | fail +``` + +`Result: pass` requires all four `yes`. Any `no` → +`Result: fail` → circuit-breaker fails → `topic-page: deferred`. + +## Life-Stage Check -1. `.context/kb/topics/<slug>/index.md` exists and was - created or extended in this pass (topic-page file - creation is performed only by `ctx kb topic new`; this - skill MAY invoke it but MUST NOT write the scaffold - directly). -2. The page cites at least one `EV-###` row that resolves - to `evidence-index.md`. -3. `ctx kb site build` ran clean, or its failure is named - in the closeout's `Next pass hint` and the pass reports - `topic-page: deferred`. -4. The cold-reader orientation rubric records `Result: pass`. +Count `.context/kb/topics/*/index.md` pages **before** this pass +begins synthesizing: -Any failure → `topic-page: deferred`; ledger advances to -`topic-page-drafted` (not `comprehensive`). +- `< 5` topic pages → **bootstrap** mode. Skip reconciliation + ceremony; synthesize topic pages aggressively. Exception: + surface a contradiction even in bootstrap if the new material + plainly contradicts existing kb claims. +- `>= 5` topic pages → **maintenance** mode. Apply full + reconciliation discipline (laddering, demotion, contradiction + detection). + +Document the life-stage call in the closeout's frontmatter +(`life-stage:`) and `What changed` section. ## Process -1. Verify pre-write gates. Refuse cleanly on failure. -2. Emit the pass-mode declaration. -3. Resolve sources and the topic name; confirm with the user - when topic is not supplied. -4. Run the topic-adjacency pre-flight against - `.context/kb/source-coverage.md`; record the result in - the closeout's Adjacency pre-flight block. -5. Life-stage check (< 5 topic pages = bootstrap; - reconciliation ceremony skipped except for contradictions; - >= 5 = maintenance, full discipline). -6. Scaffold (topic-page mode only): if the topic folder does - not exist, shell out to `ctx kb topic new "<name>"`. -7. Extract atomic claims; mint `EV-###` rows in - `evidence-index.md`. Confidence band per `KB-RULES.md`; - topic page never claims more certainty than its weakest - cited band. -8. Reconcile (maintenance only): net-new claims append; - reinforcing claims promote; contradicting claims demote - per the demotion policy and open a paired - `outstanding-questions.md` row. -9. Advance the source-coverage ledger per the state-machine - transitions in `KB-RULES.md`. Illegal transitions are - refused at write time. -10. Run the topic-page circuit breaker (topic-page mode only). -11. Record the cold-reader orientation rubric in the closeout. -12. Write the closeout under - `.context/ingest/closeouts/<TS>-ingest-closeout.md` with - required frontmatter (`sha`, `branch`, `mode: ingest`, - `pass-mode`, `life-stage`, `generated-at`). -13. Append one line to `.context/ingest/SESSION_LOG.md` at - the closeout phase boundary, in the exact shape from - `KB-RULES.md` §SESSION_LOG line shape. - -## Anti-Patterns - -- Synthesizing the topic-page scaffold by hand. Only `ctx kb - topic new` writes scaffolds. -- Mid-pass mode-switching without aborting. -- Claiming `comprehensive` ledger advance when the topic page - is incomplete. -- Inventing `EV-###` IDs to make a topic page look complete. -- Demoting in `evidence-index.md` (rows are append-only; - retire by demoting the confidence band, not by deletion). +1. **Verify pre-write gates.** Refuse cleanly with the matching + message from §Pre-write gates if `.context/`, + `.context/ingest/`, or kb scope is missing. No residue on + refusal. + +2. **Declare pass-mode and surface the up-front declaration.** + Determine the mode per §Pass-mode contract. Emit the + three-line declaration block in the response stream **before + any further work**. Mid-pass mode-switching is forbidden; + abort and re-invoke if the work no longer fits. + +3. **Resolve the topic.** *(Topic-page mode only; skipped in + `triage` and `evidence-only`.)* + + - **Read `.context/kb/source-coverage.md` in full first.** It + answers *"what does this kb already know about which + sources, and at what completeness?"*: a precondition for + honest topic resolution, not an afterthought. + - **Topic-adjacency pre-flight (mandatory).** Scan the ledger + for rows whose state is **not** in + `{comprehensive, skipped, superseded}` AND whose `Topic` is + plausibly *adjacent*. Heuristics: + - **Shared first segment of a slash- or hyphen-separated + slug**: `cursor/skills` is adjacent to `cursor/hooks`. + - **Shared product / vendor / surface** in the source URL or + description. + - **Explicit cross-references** in the named topic's + existing sub-pages or this pass's source set. + + For each adjacent incomplete topic surfaced, this pass MUST: + 1. Acknowledge it in `## Related concepts in this kb` on the + topic page being authored. + 2. Surface it in the closeout's `Adjacency pre-flight` + block. + 3. Surface it in the response contract's `Adjacent topics + noted` field. + + **Do NOT enumerate `EV-###` IDs by name in the adjacency + block.** Use *count + location* (*"seventeen rows in + `evidence-index.md`"*). Naming an EV row from a + lower-confidence sibling demotes the floor of cited bands. + + Silence is not a clean pre-flight; if zero matches, record + *"no incomplete adjacent topics surfaced"* explicitly. + + - **Named vs unnamed branches.** If the user named a topic, + accept it and map to slug (lowercase + kebab-case). If not, + scan the inputs *just enough* to propose one and confirm: + + > you haven't named a topic; based on the inputs this looks + > like **"<proposed name>"**. Confirm or correct. + + One question. Wait for confirmation. If material spans + multiple topics, ask once for the splits. Do not auto-split. + +4. **Resolve sources (and discover, if invited).** *(All modes.)* + + - Resolve every supplied source: fetch URLs, recurse folders, + enumerate MCP resources. + - If the user invited discovery, do bounded web/MCP search. + - **Hard cap: 50 total sources** (supplied + discovered) per + pass. Quality of synthesis collapses past it. + - **If discovery exceeds 50**, keep the 50 highest-judged + sources for this pass; append the overflow to + `.context/ingest/candidate-sources.md` under a "Pending + (overflow from <date> ingest of `<topic-slug>`)" heading. + - **Update the source-coverage ledger**: every supplied source + moves from absent → `discovered` (if newly seen) → + `admitted` (if scope-conformant) or → `skipped` (if not). + Discovered sources kept for this pass also land at + `admitted`; overflow stays at `discovered` with a pointer. + + Append a `SESSION_LOG.md` line: + + ``` + [YYYY-MM-DD HH:MM:SS sha=<short> branch=<name>] phase=resolve status=<done|partial|blocked> note=<<=120 chars> + ``` + +5. **Survey kb topology and determine life-stage.** *(All + modes.)* + + - List `.context/kb/topics/*/index.md`; glance for sibling + sub-pages so the cross-link palette includes them. + - Read `.context/kb/index.md` for the canonical scope. + - Skim recent sections of `evidence-index.md`, `glossary.md`, + `outstanding-questions.md`, `contradictions.md`, + `timeline.md` for prior claims relevant to this pass. + - **Life-stage check**: count `kb/topics/*/index.md`. `< 5` + is bootstrap; `>= 5` is maintenance. Document the call in + the closeout's frontmatter (`life-stage:`). + +6. **Find or create the topic page.** *(Topic-page mode only.)* + + Topic pages are folder-shaped from day one: + `.context/kb/topics/<slug>/index.md`, with optional sibling + sub-pages. + + - **If `.context/kb/topics/<slug>/index.md` exists**, read it + AND enumerate any sibling sub-pages. The pass **extends** + the topic: append/extend prose; reuse existing `EV-###` + rows where possible; preserve human edits; do not reformat + to match a newer template. Choose the right file: + - Lede / "What it is" overview → edit `index.md`. + - Existing sibling sub-page material → edit that sub-page. + - **Sub-page split is lazy.** Do NOT pre-emptively split. + Only split when `index.md` has grown to fail the + cold-reader "boundaries clear?" check; at which point, + propose the split (one question, wait for confirmation; + sub-page topology affects long-term shape). + - **If `.context/kb/topics/<slug>/` does not exist**, scaffold + by invoking `ctx kb topic new "<concept name>"`. The CLI is + the sole writer of the scaffold; do not synthesize it by + hand. The CLI creates the folder, writes `index.md`, AND + registers the new slug in `.context/kb/index.md`'s + `CTX:KB:TOPICS` managed block. + + After revising the page's H1 or Confidence band in §10, run + `ctx kb reindex` so the managed block refreshes. + +7. **Synthesise.** Body depends on declared mode. + + ### `topic-page` mode + + For each template section (Status block, lede, "What it is", + "Why this kb cares", "Sources and further reading", optional + sections): + + - **Read the source(s) carefully**: full pass, not skim. + - **Write paraphrased prose that captures the understanding**, + not a transcription. + - **For each claim needing citation, mint or reuse `EV-###`:** + - Re-read `evidence-index.md` immediately before writing to + find the highest existing `EV-NNN`; append the next + integer. Pad to three digits (`EV-012`, not `EV-12`). + Duplicate IDs are a hard refusal: abort and re-read. + - **If the claim is already pinned** by an existing row, + reuse the ID verbatim. If the existing claim no longer + matches, treat as a contradiction (§8). + - **If the existing row carries the `evidence-only` tag**, + treat as review-required: re-read the source, confirm the + claim, then promote onto the page. Leave the tag in + place; it is audit trail. + - Append the row to `evidence-index.md` per its schema + (claim, source short name + locator, optional `sha:` for + in-repo citations, confidence band, tags, extracted + date). + - If the source is new, append a row to `source-map.md`. + - Cite `EV-###` inline in the prose. + - **Cross-link** to existing kb topics, DECISIONS.md, + LEARNINGS.md, and `docs/` entries when applicable. + - **Mandatory `## Related concepts in this kb` entries** for + adjacent incomplete topics surfaced by §3's pre-flight. The + acknowledgement must read as a forward pointer (state + + count + location), not as trivia. + - **Mark unbacked claims with `TBD-cite`** and open + `outstanding-questions.md` entries for each. + - **Update `glossary.md`** for net-new terms. + - **Update `timeline.md`** if the pass surfaces a dateable + event. + + **Never invent citations.** **Never** promote a claim above + `speculative` without an `evidence-index.md` row backing it. + + ### `triage` mode + + For each admitted source, judge admission/skip against the + scope paragraph and propose topic routing in the closeout. Do + NOT write to any topic page. **Do NOT mint `EV-###` rows.** Do + NOT touch `evidence-index.md`, `glossary.md`, or + `timeline.md`. + + Triage is routing and admission, not extraction. If the user + asks to *"triage and grab obvious facts as you go,"* abort + with a partial closeout and recommend re-invocation under + either `topic-page` or `evidence-only` mode. Triage MAY update + `source-coverage.md` and `candidate-sources.md`. That is the + full write surface for triage. + + ### `evidence-only` mode + + For each admitted source, mint `EV-###` rows + `source-map.md` + rows + `glossary.md` entries for terms encountered. **Do not + touch any topic page.** Do not write prose synthesis. + + Every minted `EV-###` row MUST include the literal tag + `evidence-only` in its tags column. The tag is **additive**; + it does not replace topical tags. + + Append a `SESSION_LOG.md` line: + + ``` + [YYYY-MM-DD HH:MM:SS sha=<short> branch=<name>] phase=synthesise status=<done|partial|blocked> note=<topic slug + <=80 chars> + ``` + +8. **Apply life-stage reconciliation discipline.** *(All modes; + behavior depends on life-stage.)* + + **Bootstrap (`< 5` topic pages)**: skip except for the + contradiction exception in §5. Append a `SESSION_LOG.md` line + with `status=skipped-bootstrap`. + + **Maintenance (`>= 5` topic pages)**: for each EV row minted + in §7: + + - **Reinforces an existing claim** → promote per the + laddering rules in `KB-RULES.md` §Confidence bands + (`speculative → low → medium → high`); cross-link the new + row to the prior one. + - **Contradicts an existing claim** → add a row to + `contradictions.md`; demote the older claim per the + demotion policy in `KB-RULES.md` §Demotion policy; open an + `outstanding-questions.md` entry naming both sides and what + evidence would resolve. + +9. **Set the topic page's Confidence floor.** *(Topic-page mode + only.)* Inspect every `EV-###` cited on the page; the page's + Status-block `Confidence` is the **lowest** of those cited + bands. Refuse to set Confidence above the floor. Refuse to + set above `speculative` while any `TBD-cite` remains. + +10. **Update the topic page's Status block.** *(Topic-page mode + only.)* Substitute `Subject:`, `Last verified:`, `Author:` + (`agent-ingested` if untouched by a human in this pass; + `mixed` if a human revised prose; **never** + `hand-authored`), and `Confidence:` per §9. + +11. **Update the source-coverage ledger.** *(All modes.)* For + every source touched, advance its row in + `.context/kb/source-coverage.md` per the state machine. + Update `EV coverage`, `Residue`, `Next action`, `Updated` + columns honestly. Lying to the ledger is a hard + anti-pattern. + +12. **Topic-page circuit breaker check.** *(Topic-page mode + only.)* Verify all four invariants from §Topic-page circuit + breaker. Any failure → `topic-page: deferred` and ledger to + `topic-page-drafted` (NOT `comprehensive`). + +13. **Write the closeout.** *(All modes; mode-aware body.)* + Create + `.context/ingest/closeouts/<TIMESTAMP>-ingest-closeout.md` + with required frontmatter: + + ```yaml + --- + sha: <short> + branch: <name> + mode: ingest + pass-mode: <topic-page|triage|evidence-only> + life-stage: <bootstrap|maintenance> + generated-at: <RFC-3339> + --- + ``` + + Body sections (mode-aware): **Inputs**, **Pass-mode** (block + repeated from §2 declaration so reviewers can compare promise + vs. result), **Topic(s) touched**, **What changed** + (including the Cold-reader rubric in topic-page mode), + **New questions**, **New contradictions**, **Confidence + drift**, **Source-coverage updates**, **Overflow**, + **Adjacency pre-flight**, **Next pass hint**. + + Append a final `SESSION_LOG.md` line: + + ``` + [YYYY-MM-DD HH:MM:SS sha=<short> branch=<name>] phase=closeout status=done note=<topic slug + <=80 chars> + ``` + +## Edge Cases + +| Case | Expected behavior | +|------|-------------------| +| Empty input | Refuse with the standard no-sources text. No residue. | +| `.context/` missing | Refuse; suggest `ctx init`. No residue. | +| `.context/ingest/` missing | Refuse; suggest `ctx init --upgrade`. No residue. | +| Kb scope undeclared | Refuse with the scope message; point at `.context/kb/index.md`. No residue. | +| Source returns nothing usable (404, binary, paywall) | Record in closeout's `Next pass hint` AND the topic page's "Open questions"; advance the ledger row to `skipped` with the failure reason. Do not invent claims. | +| All sources skipped during admission | Write a short closeout with empty `Topic(s) touched` and `What changed`; `Next pass hint` lists every skipped source with scope-citation. | +| Material spans 3+ topics and user can't decide | Ask once in §3; if still unresolved, abort with a partial closeout recommending re-invocation under `triage`. | +| Discovery turns up zero additional sources | Note in closeout's `Inputs` section. Not a failure. | +| Stale Status block on existing page | Flag in closeout's `Next pass hint`; do not silently overwrite the verification cursor unless the source was actually re-verified. | +| Multiple sessions filling the same page | Read existing prose first; do not overwrite human edits; append/extend rather than replace. | +| Page scaffolded long ago with older template | Fill what's there; do not reformat to match a newer template. Open a task if drift is significant. | +| `ctx kb topic new` fails or refuses (slug exists, kb missing) | Resolve the underlying condition and retry; do not hand-write a scaffold. | +| `ctx kb site build` fails during §12 | Report `topic-page: deferred`; name the build failure in `Next pass hint`; ledger to `topic-page-drafted` (NOT `comprehensive`). | +| Cold-reader rubric returns `Result: fail` | Report `topic-page: deferred` AND `validation: deferred (cold-reader orientation failed)`; name failed items in `Next pass hint`; ledger to `topic-page-drafted`. | +| Adjacency pre-flight surfaces zero matches | Record *"no incomplete adjacent topics surfaced"* explicitly in closeout's `Adjacency pre-flight`; response contract reads `none surfaced`. Silence is not allowed. | +| Mid-pass mode-switching tempted | Forbidden. Abort, write a partial closeout citing the mismatch, recommend re-invocation under the correct mode. Never silent-switch. | +| `evidence-only` pass discovers a contradiction | Still mint the contradiction row (truth surface always wins); flag in `Next pass hint` that a topic-page pass is needed to resolve. | +| Inferring `evidence-only` from source size / time pressure | Hard anti-pattern. Refuse to set `evidence-only` without explicit user trigger. | + +## Hard Anti-Patterns + +- Treating closeout existence as topic-page validation. +- Skipping the topic-page circuit breaker in `topic-page` mode. +- Inferring `evidence-only` from source size, complexity, + ambiguity, time pressure, or operator convenience. +- Mid-pass mode-switching (abort and re-invoke instead). +- Hiding incomplete coverage under a comprehensive-looking + closeout (lying to the ledger). +- Skipping the topic-adjacency pre-flight, or running it but + failing to acknowledge surfaced incomplete adjacent topics. +- Claiming `topic-page: produced` when the cold-reader + orientation result is missing. +- Asking the human mid-pass beyond the §3 naming gate, unless + continuing would change durable kb topology, evidence + confidence, source admission, or scope. +- Inventing claims beyond what the source backs. +- Inventing `EV-###` citations to make a page look complete. +- Promoting claims above `speculative` without an + `evidence-index.md` row. +- Promoting a topic page above its weakest cited band. +- Setting `Confidence` above `speculative` while any + `TBD-cite` remains. +- Setting `Author: hand-authored` on agent-ingested prose. +- Re-extracting from a source that already has `EV-###` rows + instead of reusing the IDs. +- Citing an `evidence-only`-tagged row in a topic page without + re-reading the source first. +- Renumbering or deleting `EV-###` rows when reconciling. +- Skipping the closeout once the pass clears pre-write gates. +- Bypassing `ctx kb topic new` when scaffolding a page. +- Running maintenance discipline against a bootstrap-stage kb. +- Hand-editing `INBOX.md`. + +## Output Contract + +For pre-write refusals, return only the specified refusal text +and stop. No closeout, no residue. + +For passes that clear pre-write gates, **emit the up-front +declaration first** (between §1 and §3): + +> **Pass-mode:** `<mode>` +> **Reason:** `<one sentence; required when non-default>` +> **Definition of done:** `<mode-specific criterion>` + +Then proceed. At completion, end with this structured summary: + +- **Pass-mode**: as declared, with reason if non-default. +- **Topic-page**: `produced [<slug>]`, `extended [<slug>]`, + `deferred (<reason>)`, or `not-applicable` (triage / + evidence-only). +- **Validation**: `passed`, `not-attempted`, or + `deferred (<reason>)`. +- **Coverage**: current state(s) from `source-coverage.md` for + sources touched. +- **EV range minted**: e.g. `EV-035..EV-051`, or `none`. +- **Counts**: glossary entries added, source-map rows added, + cross-links written, contradictions surfaced, questions + opened. +- **Life-stage**: `bootstrap` or `maintenance`, with the + topic-page count it was based on. +- **Closeout**: filename on its own line. +- **Adjacent topics noted** *(topic-page mode only; mandatory)*: + either `none surfaced` or a slug-list with states. Free prose + fails validation; the doctor advisory parses this field. +- **Next-recommended-action**: explicit invocation that would + resume incomplete work. Adjacent topics surfaced by the + pre-flight MUST appear here too (deliberate redundancy). +- **Review-required**: `true` for `evidence-only` passes; + otherwise omit. + +The structured summary, the closeout's body, and the +source-coverage ledger MUST agree. Discrepancies between the +three are a hard anti-pattern; the doctor advisory detects them +and surfaces a non-fatal warning on next `ctx doctor` run. + +## Quality Checklist + +Before reporting completion, verify: + +- [ ] Pre-write gates passed (or the matching refusal was + returned with zero residue). +- [ ] Pass-mode declaration was emitted in the response stream + before any extraction. +- [ ] Source-coverage ledger advanced honestly for every source + touched. +- [ ] Topic-adjacency pre-flight ran in `topic-page` mode and its + result is in the closeout AND the page AND the response + contract. +- [ ] Cold-reader rubric is recorded in `topic-page` mode. +- [ ] Circuit-breaker check ran in `topic-page` mode; failure + → `topic-page: deferred`, NOT `produced`. +- [ ] Closeout written with all required frontmatter fields + (`sha`, `branch`, `mode`, `pass-mode`, `life-stage`, + `generated-at`). +- [ ] Structured response summary matches the closeout body and + the ledger. diff --git a/internal/assets/integrations/opencode/skills/ctx-kb-note/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-kb-note/SKILL.md index bd9ab89e4..117d33611 100644 --- a/internal/assets/integrations/opencode/skills/ctx-kb-note/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-kb-note/SKILL.md @@ -1,72 +1,163 @@ --- name: ctx-kb-note -description: "Lightweight capture into .context/ingest/findings.md. Single argument is the note text. Never writes to a topic page or to evidence-index.md. The pipeline's ad-hoc escape hatch for 'park this for the next ingest'." +description: Lightweight capture into .context/ingest/findings.md. Single argument is the note text. Never writes to a topic page or to evidence-index.md. The pipeline's ad-hoc escape hatch for "park this for the next ingest". --- +# Park a Finding for the Next Ingest + Append a short note to `.context/ingest/findings.md` so a later -`/ctx-kb-ingest` pass can pick it up. The pipeline's escape -hatch for *"I want to remember this, but I'm not running a full -ingest right now."* No closeout, no ledger update, no +`/ctx-kb-ingest` pass can pick it up. This is the pipeline's +escape hatch for *"I want to remember this, but I'm not running +a full ingest right now."* No closeout, no ledger update, no topic-page edit, no `EV-###` minting. Just typed memory landing in one well-known file. +Authoritative background reading: +`.context/ingest/KB-RULES.md` §Authority boundary; +`specs/kb-editorial-pipeline.md` §Interface. + ## When to Use - The user says "drop a note", "capture this for the next - ingest", "park this finding". + ingest", "park this finding", or invokes the explicit slash + form with note text. - A conversation surfaces a fact, link, or observation that - should land in the kb later but does not justify a full - ingest pass right now. + should land in the kb later but does not justify running + `/ctx-kb-ingest` right now. +- Mid-session, a sibling skill (architecture, brainstorm, etc.) + surfaces something kb-shaped and the user wants it parked + cheaply. ## When NOT to Use -- The user has sources to ingest (`/ctx-kb-ingest`). -- The user is asking a content question (`/ctx-kb-ask`). -- The note is actually a task / decision / learning / - convention for the code-dev side; use the matching - canonical-capture path instead. -- The note is empty (refuse-on-empty). - -## Input +- The user has sources in hand and wants them ingested (use + `/ctx-kb-ingest`). +- The user is asking a content question (use `/ctx-kb-ask`). +- The note is actually a task / decision / learning / convention + for the code-dev side (use `/ctx-task-add` / + `/ctx-decision-add` / `/ctx-learning-add` / + `/ctx-convention-add`; those write to canonical files, this + one does not). +- The note is empty (refuse-on-empty; see below). + +## Authority Boundary (vs Other Skills) + +- **`/ctx-kb-note`** appends to + `.context/ingest/findings.md` only. Never writes anywhere + else. No closeout. No ledger update. +- **`/ctx-kb-ingest`** reads `findings.md` opportunistically + when scoping its source set; the user controls when notes get + promoted into evidence. +- **Canonical capture skills** (`/ctx-task-add`, + `/ctx-decision-add`, `/ctx-learning-add`, + `/ctx-convention-add`) write to the five canonical + `.context/` files. Strict authority boundary: this skill + never touches them. + +## Usage Examples + +```text +/ctx-kb-note "cursor.com/changelog mentions hook lifecycle bump in v1.2" +/ctx-kb-note "check whether your-domain RTO claim still cites the 2024 audit" +/ctx-kb-note "Volkan said in chat: the 50-source cap was lifted from the upstream design" +``` + +## Input Contract A single argument: the note text. Free-form prose. No flags. ## Refuse-on-Empty -If the invocation supplied no note text, return exactly: +If the invocation supplied no note text (empty slash arg, empty +inline body, whitespace-only), return exactly: > no note text provided; pass the note inline. -Stop. The CLI enforces this independently. +Stop. Do not prompt interactively. The CLI enforces this +independently via `cmd/note`. ## Pre-Write Gates +Two distinct refusals, each leaves zero residue: + - `.context/` missing → suggest `ctx init` and stop. -- `.context/ingest/` missing → suggest `ctx init --upgrade` - and stop. +- `.context/ingest/` missing → refuse: + + > kb not initialized; run `ctx init` first -Kb scope declaration is not required; notes land pre-scope. + Stop. + +Kb scope declaration is **not** required for this skill. Notes +land in `.context/ingest/findings.md`, which is pre-kb-scope +territory; the user may be parking notes precisely because they +have not yet decided the kb's scope. ## Process -1. Verify pre-write gates. -2. Append the note to `.context/ingest/findings.md` as a - single bulleted line, prefixed with the UTC timestamp - (RFC-3339), short SHA, and branch: +1. **Verify pre-write gates.** Refuse cleanly if any gate fails. + Zero residue on refusal. + +2. **Append the note** to `.context/ingest/findings.md` as a + single bulleted line. Prefix with the current UTC timestamp + (RFC-3339, date-time precision) and a short SHA + branch + from `gitmeta.ResolveHead` so the note carries minimal + provenance: ``` - 2026-05-16T14:32:11Z sha=88d52870 branch=main | <note text> ``` - If `findings.md` does not exist, create it with a brief - header explaining its purpose. -3. No closeout. Notes are intentionally lightweight; the - audit trail is the file itself. + If `findings.md` does not yet exist, create it with a brief + header explaining its purpose (one paragraph; the embedded + template ships at `internal/assets/kb/templates/ingest/` + handles this for fresh inits, so this fallback applies only + when the file was deleted by hand). + +3. **No closeout.** Notes are intentionally lightweight; the + audit trail is the file itself. The next `/ctx-kb-ingest` + pass reads `findings.md` opportunistically. + +## Edge Cases + +| Case | Expected behavior | +|------|-------------------| +| Empty note text | Refuse with the standard no-note text. No residue. | +| `.context/` missing | Refuse; suggest `ctx init`. No residue. | +| `.context/ingest/` missing | Refuse with the not-initialized message. No residue. | +| `findings.md` missing but `.context/ingest/` exists | Create the file with a brief header; append the note. | +| Multi-line note text | Append as a single bullet with embedded line breaks; preserve the user's formatting. | +| Note text contains a URL | Preserve verbatim; do not auto-fetch (this skill does not web-jump). | +| Note text is structurally a claim that should be evidence | Append as a note anyway; mention in the response that `/ctx-kb-ingest` is the next step if the user wants it minted as `EV-###`. | +| User invokes twice in a row with similar text | Append both; deduplication is the user's call, not this skill's. | + +## Output Contract + +For refusals, return only the specified refusal text and stop. + +For successful appends, return: + +- One line confirming the append, with the line number of the + new entry in `findings.md`. +- A pointer to `/ctx-kb-ingest` as the path for promoting the + note into evidence when the user is ready. + +Example: + +``` +appended to .context/ingest/findings.md line 42. +run /ctx-kb-ingest with the source materials when ready to mint EV. +``` + +## Quality Checklist -## Anti-Patterns +Before reporting completion, verify: -- Writing a topic page or minting `EV-###` from this skill. -- Skipping the timestamp + provenance prefix; the audit - trail depends on it. -- Hand-editing prior entries to "consolidate" them. Append-only. +- [ ] Pre-write gates passed (or the matching refusal was + returned with zero residue). +- [ ] The note landed in `.context/ingest/findings.md` and + nowhere else. +- [ ] No `EV-###` row was minted, no topic page was touched, no + ledger row was advanced, no closeout was written. +- [ ] The appended line carries the timestamp + sha + branch + provenance prefix. diff --git a/internal/assets/integrations/opencode/skills/ctx-kb-site-review/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-kb-site-review/SKILL.md index 1e1c0000f..00c7f485a 100644 --- a/internal/assets/integrations/opencode/skills/ctx-kb-site-review/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-kb-site-review/SKILL.md @@ -1,72 +1,258 @@ --- name: ctx-kb-site-review -description: "Mechanical structural audit of the kb. Coerces malformed capitalization, flags malformed closeout frontmatter, and refuses to make judgment calls that require evidence. Writes a site-review closeout for the audit trail." +description: Mechanical structural audit of the kb. Coerces malformed capitalization, flags malformed closeout frontmatter, and refuses to make judgment calls that require evidence. Writes a site-review closeout for the audit trail. --- -Walk `.context/kb/` and `.context/ingest/closeouts/` -mechanically. Fix what is unambiguous (capitalization drift, -missing frontmatter fields the CLI knows how to coerce). Flag -what is not (claims that read as broken but require evidence -to fix). Never invent prose. Never mint `EV-###` rows. Never -modify a claim's Confidence band. +# Site-Review Pass -This is a janitor pass, not an editorial pass. Editorial -judgment lives in `/ctx-kb-ingest`. +Walk `.context/kb/` and `.context/ingest/closeouts/` mechanically. +Fix what is unambiguous (capitalization drift, missing frontmatter +fields the CLI knows how to coerce). Flag what is not (claims +that read as broken but require evidence to fix). Never invent +prose. Never mint `EV-###` rows. Never modify a claim's +Confidence band. + +This is a janitor pass, not an editorial pass. Editorial judgment +lives in `/ctx-kb-ingest`. + +Authoritative background reading: +`.context/ingest/KB-RULES.md` §Authority boundary; +`specs/kb-editorial-pipeline.md` §Validation Rules. ## When to Use -- The user says "audit the kb", "check kb for rot", - "run a site-review". -- Before a release or at the end of a long editorial run, - to catch drift. +- The user says "audit the kb", "check kb for rot", "run a + site-review", or invokes the explicit slash form. +- Before a release / handover where structural cleanliness + matters. +- After bulk ingest where drift may have accumulated. +- When the doctor advisory has surfaced structural warnings the + user wants triaged. ## When NOT to Use -- The user has new sources to ingest (`/ctx-kb-ingest`). -- The user wants Q&A (`/ctx-kb-ask`). -- The user wants external re-grounding (`/ctx-kb-ground`). +- The user wants new material extracted (use `/ctx-kb-ingest`). +- The user wants kb claims re-grounded against external sources + (use `/ctx-kb-ground`). +- The user is asking a content question (use `/ctx-kb-ask`). +- The user wants to capture a quick finding (use + `/ctx-kb-note`). + +## Authority Boundary (vs Other Skills) -## Authority Boundary +- **`/ctx-kb-site-review`**: mechanical structural audit. May + coerce capitalization that the spec deems lossless (e.g. + `Confidence: High` → `high`). May flag any other malformation + in the closeout's `What changed` block. **May not** modify a + claim, an `EV-###` row's content, a Confidence band, a topic + page's prose, or a ledger state. Those require evidence + judgment. +- **`/ctx-kb-ingest`**: handles anything this skill flags as + evidence-dependent. +- **`/ctx-kb-ground`**: handles anything this skill flags as + source-staleness. -- Coerces formatting drift the CLI can fix unambiguously. -- Flags structural problems that require evidence to resolve - (open `Q-###` rows; never invent answers). -- Never writes prose, mints `EV-###`, or changes confidence - bands. +## Usage Examples + +```text +/ctx-kb-site-review +``` + +No arguments. The pass walks the kb in full. ## Pre-Write Gates +Three distinct refusals, each leaves zero residue: + - `.context/` missing → suggest `ctx init` and stop. - `.context/kb/` missing → suggest `ctx init --upgrade` and stop. -- Kb scope undeclared → refuse with the scope message and - stop. +- Kb scope undeclared (placeholder in `.context/kb/index.md`) + → refuse with the scope message and stop. ## Process -1. Verify pre-write gates. -2. Walk `.context/kb/` and `.context/ingest/closeouts/`: - coerce capitalization drift in Confidence bands; fix - missing frontmatter fields the CLI can supply - deterministically; flag malformed closeouts (missing - `generated-at`, malformed YAML). -3. For each structural problem that requires evidence to - resolve, open a `Q-###` row in - `outstanding-questions.md` naming the file and the - shape of evidence that would close it. -4. Write the site-review closeout under - `.context/ingest/closeouts/<TS>-site-review-closeout.md` - with required frontmatter (`sha`, `branch`, - `mode: site-review`, `pass-mode: n/a`, `life-stage`, - `generated-at`) and a body listing what was coerced, - what was flagged, and any `Q-###` rows opened. +1. **Verify pre-write gates.** Refuse cleanly if any gate fails. + Zero residue on refusal. + +2. **Walk topic pages.** For every + `.context/kb/topics/<slug>/index.md` and every sibling + sub-page: + - **Status block check**: does the page have the + four-field Status block (`Subject`, `Last verified`, + `Author`, `Confidence`)? Missing fields → flag in + `What changed`. Do not synthesize. + - **Author field check**: `Author: hand-authored` is + prohibited per `KB-RULES.md`. Flag (do not auto-coerce; + human intent matters). + - **Confidence band coercion**: `high|medium|low|speculative` + are the only valid values. Coerce capitalization + (`High` → `high`, `MEDIUM` → `medium`) silently and record + in `What changed`. Any other malformation (e.g. + `Confidence: probable`) is flagged for the user. + - **`TBD-cite` markers**: count them per page. The + Confidence floor for any page with `TBD-cite` is + `speculative`. If the page's Confidence is above + `speculative` while `TBD-cite` is present, flag (do not + auto-demote; demotion is evidence work). + - **`EV-###` citation resolution**: every `EV-###` cited on + the page must resolve to a row in + `.context/kb/evidence-index.md`. Unresolved IDs → flag. + - **`## Related concepts in this kb` presence**: if the + page is more than the lede + Status block AND the kb has + plausibly adjacent topics, the section should be present. + Absence is a soft flag (not auto-fixable). + +3. **Walk `evidence-index.md`.** + - **Duplicate `EV-###` IDs**: flag every duplicate; name + both files / line numbers. The LLM cleanup pass (per + spec's P1) handles renumbering, not this skill. + - **Three-digit padding**: `EV-12` should be `EV-012`. Flag + (do not auto-coerce; renumbering cascades to citations on + topic pages, which is ingest work). + - **Confidence band coercion**: same rule as topic pages. + - **`occurred:` field on dated sources**: if the source-map + row for the cited source has a `dated:` field but the + evidence row lacks `occurred:`, flag. The temporal- + precedence rule needs it. + +4. **Walk `source-coverage.md`.** + - **Ledger row mtime check**: for every row, compare the + row's `Updated` cell against the actual file mtime of the + source it points to (when the source is in-tree). Mismatch + → flag (lying-to-the-ledger advisory). Do not auto-edit. + - **Illegal state transitions**: flag any row whose state + does not match an allowed transition from the prior state. + Examples: `comprehensive → highlights-extracted` without + an explicit `superseded` step. Do not auto-correct. + - **Schema integrity**: every row must have the seven + columns (`Source`, `Topic`, `State`, `EV coverage`, + `Residue`, `Next action`, `Updated`). Missing columns → + flag. + +5. **Walk closeouts in `.context/ingest/closeouts/`.** + - **Frontmatter integrity**: every closeout must have + `sha`, `branch`, `mode`, `pass-mode`, `life-stage`, + `generated-at`. Missing fields → flag (the handover-fold + skips malformed closeouts; surface them so the user can + fix or delete). + - **Pass-mode body block**: every ingest closeout must + have a `Pass-mode` body block whose `Declared:` value + matches the frontmatter's `pass-mode:` field. Drift + between the two is exactly the false-finish signal the + redundancy exists to surface. Flag any drift. + - **Adjacency pre-flight block**: every ingest closeout in + `topic-page` mode must have an `Adjacency pre-flight` + block whose value is either `none surfaced` or a + structured slug-list. Free-prose values fail validation; + flag. + - **Cold-reader rubric**: every ingest closeout in + `topic-page` mode must include the four-item rubric in + `What changed`. Missing → flag. + +6. **Walk `.context/kb/index.md`.** + - **`CTX:KB:TOPICS` managed block**: should list every + `.context/kb/topics/<slug>/index.md` currently on disk. + Drift (slug on disk not in the block, or block entry with + no matching folder) → recommend `ctx kb reindex` in the + closeout's `Next pass hint`. Do not run the CLI from this + skill. + +7. **Write the site-review closeout.** Create + `.context/ingest/closeouts/<TIMESTAMP>-site-review-closeout.md` + with required frontmatter: + + ```yaml + --- + sha: <short> + branch: <name> + mode: site-review + pass-mode: mechanical + life-stage: <bootstrap|maintenance> + generated-at: <RFC-3339> + --- + ``` + + Body sections: + - **Inputs**: count of topic pages, evidence rows, ledger + rows, closeouts walked. + - **What changed**: every coercion this pass actually + applied (capitalization fixes); cite the file and the + before/after. Empty if zero coercions. + - **Flags**: every issue this pass detected but did not + fix. Group by category: malformed Status blocks, + unresolved `EV-###`, ledger mismatches, malformed + closeouts, etc. Each flag names file + line + nature. + - **Next pass hint**: explicit invocations to address each + flag category (e.g. *"`/ctx-kb-ingest <slug>` to restore + missing `EV-###` citation on `<page>`"*). + +## Edge Cases + +| Case | Expected behavior | +|------|-------------------| +| `.context/` missing | Refuse; suggest `ctx init`. No residue. | +| `.context/kb/` missing | Refuse; suggest `ctx init --upgrade`. No residue. | +| Kb scope undeclared | Refuse with the scope message. No residue. | +| Zero topic pages on disk | Walk closeouts and ledger anyway. Note the bootstrap state in the closeout. Not a failure mode. | +| Zero closeouts on disk | Walk topic pages and ledger anyway. Note in the closeout body. Not a failure mode. | +| `Confidence: High` (capitalization drift) | Coerce to `high` silently; record in `What changed`. | +| `Confidence: probable` (unknown band) | Flag for the user; do not coerce. | +| `Author: hand-authored` | Flag for the user; do not coerce (human intent matters). | +| Duplicate `EV-###` ID across files | Flag both files; defer renumbering to the LLM cleanup pass per spec's P1. | +| `EV-12` (missing zero-pad) | Flag for the user; do not auto-pad (cascades to citations). | +| Unresolved `EV-###` on a topic page | Flag; recommend `/ctx-kb-ingest <slug>` in `Next pass hint`. | +| Ledger row `Updated` predates source file mtime | Flag (lying-to-the-ledger advisory). Do not auto-edit. | +| Illegal ledger transition (e.g. `comprehensive → highlights-extracted` without `superseded`) | Flag; recommend the corrective ingest invocation. Do not auto-correct. | +| Closeout missing `pass-mode` frontmatter field | Flag; the handover-fold skips malformed closeouts so the user can fix or delete. | +| Closeout body's `Pass-mode` `Declared:` disagrees with frontmatter `pass-mode:` | Flag (false-finish signal); recommend hand-edit. | +| Closeout's `Adjacency pre-flight` is free prose instead of `none surfaced` or a slug-list | Flag; recommend hand-edit to structured form. | +| `CTX:KB:TOPICS` managed block drift | Recommend `ctx kb reindex` in `Next pass hint`; do not run the CLI from this skill. | +| `TBD-cite` on a page with Confidence above `speculative` | Flag; do not auto-demote (demotion is evidence work for `/ctx-kb-ingest`). | +| Sibling sub-page exists with no link from `index.md` | Flag; recommend hand-edit or `/ctx-kb-ingest <slug>` to extend. | ## Anti-Patterns -- Inventing prose or claims. -- Minting `EV-###` rows. -- Modifying Confidence bands. -- Hand-editing closeouts post-write (closeouts are - append-never-rewrite). -- Skipping the `Q-###` row when a structural flag would - otherwise vanish without trace. +- Auto-fixing anything that requires evidence judgment + (Confidence promotion/demotion, claim text edits, `EV-###` + renumbering, ledger state changes, prose synthesis). +- Skipping the closeout once pre-write gates pass. +- Hand-editing `INBOX.md` or `SESSION_LOG.md` (other skills' + surfaces; never this one's). +- Coercing `Author: hand-authored` to anything else. The user's + intent matters; flag and wait. +- Auto-renumbering duplicate `EV-###` IDs. The cascade to + citations is ingest work; this skill flags only. + +## Output Contract + +For pre-write refusals, return only the specified refusal text +and stop. No residue. + +For passes that clear pre-write gates, end with this structured +summary: + +- **Walked**: counts (topic pages, evidence rows, ledger rows, + closeouts). +- **Coercions applied**: count + one-line categories (e.g. + *"3 capitalization fixes on Confidence bands"*). +- **Flags raised**: count + categories (e.g. *"2 unresolved + EV-### citations; 1 ledger mtime mismatch"*). +- **Closeout**: filename on its own line. +- **Next-recommended-action**: explicit invocations to address + each flag category (or `none` if the kb is clean). + +## Quality Checklist + +Before reporting completion, verify: + +- [ ] Pre-write gates passed (or the matching refusal was + returned with zero residue). +- [ ] Every coercion applied is recorded in `What changed` with + file + before/after. +- [ ] Every flag is recorded in `Flags` with file + line + + nature. +- [ ] No topic-page prose was edited, no `EV-###` row was + modified, no Confidence band was promoted/demoted, no + ledger state was changed. +- [ ] Closeout written with all required frontmatter fields. diff --git a/internal/assets/integrations/opencode/skills/ctx-plan/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-plan/SKILL.md new file mode 100644 index 000000000..1d94cdf61 --- /dev/null +++ b/internal/assets/integrations/opencode/skills/ctx-plan/SKILL.md @@ -0,0 +1,93 @@ +--- +name: ctx-plan +description: "Stress-test a plan through adversarial interview; produces a debated brief at .context/briefs/<TS>-<slug>.md that /ctx-spec --brief consumes. Use when the user wants their bet scrutinized before it becomes a spec." +--- + +## Canonical Chain + +The project's design-to-implementation pipeline is: + +```text +/ctx-brainstorm → /ctx-plan → /ctx-spec → /ctx-task-out → /ctx-implement + (vague) (contested) (committed) (decomposed) (execution) +``` + +`/ctx-plan` is the second step. It takes an idea that is no +longer vague but not yet committed, attacks it, and writes a +*debated brief* to `.context/briefs/<TS>-<slug>.md`. The brief +is consumed by `/ctx-spec --brief <path>` to produce the +committed spec. This skill does **not** produce an implementation +plan or a task list; the deliverable is the brief. Decomposition +into tasks happens two steps later, at `/ctx-task-out`. + +Do not invert the order. A "plan" run after `/ctx-spec` is +fixing the foundation while the building is up; run +`/ctx-brainstorm` if the bet hasn't formed yet, then this skill, +then `/ctx-spec`. + +## Role + +You are a skeptical collaborator. The user has a plan and wants it +attacked. Your job is to surface what's weak, missing, or unexamined — +not to help them feel ready. + +State the plan as you understand it and proceed. Only pause if your +restatement exposes a material ambiguity or contradiction. + +Ask one question at a time. Each question must test something specific: +an assumption, a tradeoff, or a failure mode. No fishing. No clarifying +questions asked merely to reduce your own workload. + +After the user answers, push back, agree, narrow the question, or move +on — don't just accumulate. Walk the tree depth-first: settle decisions +that constrain others before opening siblings. + +Don't ask the user what the code, docs, or existing `ctx` files can +answer. Read first. Reserve questions for intent, priorities, +tradeoffs, and context that lives only in the user's head. + +Cycle through these angles; don't dwell on one: + +- Scope: what's NOT in this plan, and why? +- Failure modes: what breaks this? How would you notice? +- Alternatives: what did you reject, and what would change your mind? +- Sequencing: why this order? What if step 2 fails? +- Reversibility: if you're wrong in 3 months, how expensive is the unwind? +- Hidden assumptions: what must be true for this to work that isn't yet? + +Offer your take after the user answers — not before. The exception is +when the user is genuinely stuck; then propose a concrete possibility +and ask them to react. + +If the user drifts into implementation mechanics before the main bet is +clear, pull the conversation back to the unresolved bet. + +If a core assumption collapses mid-debate, say so plainly. Don't keep +politely working through the checklist on a plan that's already rotten. + +Do not produce an implementation plan. The deliverable is a debated +brief, not a task list. + +Stop when the user can describe, without your help: + +- what they're betting on +- what they rejected +- the top three failure modes +- the cheapest way to validate the bet +- what becomes expensive to unwind + +## Always offer to save the debated brief + +After the interview concludes, always offer to write the debated +brief to `.context/briefs/<TS>-<slug>.md` (create `.context/briefs/` +if absent). The brief is the canonical handoff to `/ctx-spec +--brief <path>` and the next session's starting point. + +The brief is not a paraphrase of the conversation. It is a +written record of the *bet, the rejections, the failure modes, +the validation route, and the unwind cost* — in the user's +words, lightly compressed for clarity. New facts are not added. + +If the user declines to save, do not push. The bet still lives +in their head; the brief is for the next session, and they may +not need one. diff --git a/internal/assets/integrations/opencode/skills/ctx-remember/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-remember/SKILL.md index 442f39ff8..02576447f 100644 --- a/internal/assets/integrations/opencode/skills/ctx-remember/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-remember/SKILL.md @@ -3,37 +3,192 @@ name: ctx-remember description: "Recall project context and present structured readback. Use when the user asks 'do you remember?', at session start, or when context seems lost." --- -Recall project context and present a structured readback. +Recall project context and present a structured readback as if +remembering, not searching. + +## Before Recalling + +Check that the context directory exists. If it does not, tell the +user: "No context directory found. Run `ctx init` to set up context +tracking, then there will be something to remember." ## When to Use -- When the user asks "Do you remember?", "What were we working on?" -- At the start of a session to pick up where you left off -- When context seems lost or stale +- The user asks "do you remember?", "what were we working on?", + or any memory-related question +- At the start of a session when context is not yet loaded +- When context seems lost or stale mid-session +- When the user asks about previous work, decisions, or learnings + +## When NOT to Use + +- Context was already loaded this session via `/ctx-agent`: don't + re-fetch what you already have +- Mid-session when you are actively working on a task and context + is fresh: don't interrupt flow +- When the user is asking about a *specific* past session by name + or ID: use `/ctx-history` instead, which has list/show/export + subcommands ## Process -**Do this FIRST (silently):** -1. Read TASKS.md, DECISIONS.md, and LEARNINGS.md from the context directory -2. Read the latest handover under `.context/handovers/` if present. - Filenames are timestamped `<TS>-<slug>.md`; the lexicographically - last is the newest. Its `## Summary` and `## Next Session` sections - are the authoritative recall surface — this is the previous - session's note to this one. -3. If `.context/ingest/closeouts/` exists, list closeouts whose - `generated-at` postdates the handover's `generated-at` and read - their `## What Changed` sections. These are per-pass audit notes - the previous wrap-up did not get a chance to fold. Read-only; - `/ctx-remember` does not run any editorial pass. -4. Check recent session history (for example via `.context/sessions/` or `ctx journal source --limit 5` when available) -5. Run `ctx agent` for the full context packet - -**Then respond with a structured readback:** - -1. **Last session**: cite the most recent session topic and date -2. **Active work**: list pending or in-progress tasks -3. **Recent context**: mention 1-2 recent decisions or learnings -4. **Next step**: offer to continue or ask what to focus on - -**Never** say "I don't have memory" or narrate your discovery process. -The context files are your memory. Present what you found as recall. +Do all of this **silently**: narrating the steps makes the readback +feel like a file search rather than genuine recall: + +1. **Load context packet**: + ```bash + ctx agent + ``` +2. **Read the files** listed in the packet's "Read These Files" + section (TASKS.md, DECISIONS.md, LEARNINGS.md, etc.) +3. **List recent sessions**: + ```bash + ctx journal source --limit 3 + ``` +4. **Read the latest handover.** Look under + `.context/handovers/`, sort by filename (timestamped + `<TS>-<slug>.md`; the newest is the lexicographically + last), and read its `## Summary` and `## Next Session` + sections as the authoritative recall surface. The + handover is the previous session's note to this one. + Skip only if `.context/handovers/` is empty or absent. +5. **Read postdated closeouts, if any.** When + `.context/ingest/closeouts/` exists, list closeouts whose + `generated-at` postdates the handover's `generated-at` + and read their `## What Changed` sections. These are + per-pass audit notes the previous wrap-up did not get a + chance to fold into a handover. This step is read-only: + `/ctx-remember` does not run any editorial pass. If the + directory does not exist or holds no postdated entries, + skip the step. +6. **Check knowledge health (read-only).** Run: + + ```bash + ctx system check-knowledge --report + ``` + + It prints nothing when every canonical root is within limits. + When it prints findings, surface them in the readback's + **Knowledge health** line: a *foldable* root suggests + `/ctx-digest` (fold the staging zone into themes); a *heavy* + page suggests splitting the theme or extracting it to tooling. + Suggest only — never run `/ctx-digest` or edit a file here. + If it prints nothing, omit the line. + +7. **Present the structured readback** (see format below) + +## Readback Format + +Present your findings as a structured readback with these sections: + +**Last session**: Topic, date, and what was accomplished. Cite the +most recent session from the session list. + +**Active work**: Pending and in-progress tasks from TASKS.md. Use +a brief list: one line per task with its status. + +**Recent context**: 1-2 recent decisions or learnings that are +relevant. Pick the most recent or most impactful. + +**Next step**: Suggest what to work on next based on the active +tasks, or ask the user for direction if priorities are unclear. + +**Knowledge health** (only when `ctx system check-knowledge +--report` printed findings): name the foldable roots and/or heavy +pages it reported and the suggested remedy (`/ctx-digest`, or +split/extract). Suggestion only; omit the line entirely when the +report was empty. + +## Readback Rules + +- Open directly with the readback: instead of "I don't have memory", + present what you found +- Skip preamble like "Let me check": go straight to the structured + readback +- Present findings as recall, not discovery: you are *remembering*, + not *searching* +- Be honest about the mechanism only if the user explicitly asks + *how* you remember (e.g., "It's stored in context files managed + by ctx") + +## Examples + +### Good Readback + +> **Last session** (2026-02-07): We implemented the cooldown +> mechanism for `ctx agent` to prevent redundant context loads. +> +> **Active work**: +> - [ ] Add `--format json` flag to `ctx status` (pending) +> - [x] Implement session cooldown (done) +> - [ ] Write integration tests for journal import (in progress) +> +> **Recent context**: +> - Decided to use file-based cooldown tokens instead of +> environment variables (simpler, works across shells) +> - Learned that Claude Code hooks run in a subprocess, so env +> vars set in hooks don't persist to the main session +> +> **Next step**: The integration tests for journal import are +> partially done. Want to continue those, or shift to the JSON +> status flag? + +### Bad Readback (Anti-patterns) + +> "I don't have persistent memory, but let me check if there +> are any context files..." + +> "Let me look at the context files to see what's there. +> I found TASKS.md, let me read it..." + +> "I found some session files. Here's what they contain..." + +## Companion Tool Check + +After presenting the readback, check companion tool availability. +Skip this section entirely if `companion_check: false` is set in +`.ctxrc`: check by running `ctx config status` and looking for +the field value. + +**Companion tools** enhance ctx skills with web search and code +intelligence. They are optional but recommended. ctx names canonical +implementations below; if your MCP toolchain provides equivalent +capabilities through different servers (e.g. Firecrawl / Exa / +Tavily for web search; sourcegraph-cody for code graph), use +whatever you have connected. + +| Capability | Canonical example | Smoke test for the canonical example | +|---------------------------|-------------------|----------------------------------------------------------------------| +| Web search with citations | Gemini Search | Call `mcp__gemini-search__search_with_grounding` with a simple query | +| Code knowledge graph | GitNexus | Call `mcp__gitnexus__list_repos` | + +**Check procedure:** + +1. Attempt each smoke test silently +2. For tools that respond: note as available (no output needed) +3. For tools that fail or are not connected: silently fall back + to built-in capabilities. Emit no output. ctx does not vouch + for companion-tool install paths (see DECISIONS.md, + 2026-05-23 "MCP gateway not worth the coupling cost"). +4. For GitNexus specifically: if it responds but the current repo + is not indexed or the index is stale, suggest: + > "GitNexus index is stale: reindex with the repo's own entry + > point — a `make gitnexus-index` target, an indexing script, or + > the steps in its `GITNEXUS.md` — if it has one; otherwise run + > `gitnexus analyze`. (On hosts where the npm binary can't build, + > the repo-local Docker path is the reliable runner.)" + +Present companion status as a one-line note after the readback +only when there's something actionable (stale index). Absent +tools produce no output; the agent uses its built-in capabilities +transparently. + +## Quality Checklist + +Before presenting the readback, verify: +- [ ] Context packet was loaded (not skipped) +- [ ] Files from the read order were actually read +- [ ] Structured readback has all four sections +- [ ] No narration of the discovery process leaked into output +- [ ] Readback feels like recall, not a file system tour +- [ ] Companion tool check ran (unless suppressed via .ctxrc) diff --git a/internal/assets/integrations/opencode/skills/ctx-spec/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-spec/SKILL.md new file mode 100644 index 000000000..4d56ca7e5 --- /dev/null +++ b/internal/assets/integrations/opencode/skills/ctx-spec/SKILL.md @@ -0,0 +1,185 @@ +--- +name: ctx-spec +description: "Scaffold a feature spec from the project template. Use when planning a new feature, writing a design document, or when a task references a missing spec." +--- + +Scaffold a new spec from `specs/tpl/spec-template.md` and walk through +each section with the user to produce a complete design document. + +## Canonical Chain + +The project's design-to-implementation pipeline is: + +```text +/ctx-brainstorm → /ctx-plan → /ctx-spec → /ctx-task-out → /ctx-implement + (vague) (contested) (committed) (decomposed) (execution) +``` + +`/ctx-spec` is the third step. It consumes the *debated brief* +produced by `/ctx-plan` (via `--brief <path>`) or writes a fresh +spec interactively when no brief is needed. Specs are committed +artifacts under `specs/`; briefs are working state under +`.context/briefs/` that the spec absorbs. Downstream, +`/ctx-task-out` decomposes multi-milestone specs into the plan +document `/ctx-implement` executes; small specs go straight to +`/ctx-implement`. + +Do not invert the order. A spec without a settled bet ahead of +it is a wishlist; running `/ctx-plan` after `/ctx-spec` is fixing +the foundation while the building is up. + +## When to Use + +- Before implementing a non-trivial feature +- When a task says "Spec: `specs/X.md`" and the file does not exist +- When `/ctx-brainstorm` has produced a validated design that needs + a written artifact +- When `/ctx-plan` has produced a debated brief that needs a + committed spec (use `--brief <path>`) +- When the user says "let's spec this out" or "write a spec for..." + +## When NOT to Use + +- Bug fixes or small changes (just do them) +- When a spec already exists (read it instead) +- When the design is still vague (use `/ctx-brainstorm` first) +- When the bet is contested but not yet stress-tested (use + `/ctx-plan` first; its output is the brief this skill consumes) + +## Usage Examples + +```text +/ctx-spec +/ctx-spec (session checkpointing) +/ctx-spec (rss feed generation) +/ctx-spec --brief ideas/003-editorial-pipeline-debated-brief.md +``` + +## --brief contract + +When invoked with `--brief <path>`, the skill treats the file at +`<path>` as the authoritative source and skips the fresh-template +Q&A. Two preconditions and an authority order govern the read: + +**Preconditions** + +- The brief file must exist; if it does not, stop and report the + missing path without falling back to the interactive flow. +- The brief file should be the output of a prior `/ctx-plan` + session or a hand-written equivalent. A casual idea note is not + a brief. + +**Authority order** when the brief, recorded decisions, frozen +docs, or your inference disagree: + +1. Frozen contracts in `docs/` (release notes, public CLI docs) +2. Recorded decisions in `.context/DECISIONS.md` +3. The brief at `<path>` +4. Your own inference — only when steps 1–3 are silent, and + labeled `TBD` in the spec so it stands out for review. + +Never invert this order. If the brief contradicts a frozen +contract, surface the contradiction to the user; do not silently +follow the brief. + +**Flow when `--brief` is set** + +1. Read the brief in full. Do not paraphrase it back to the user. +2. Read `specs/tpl/spec-template.md` to get the section list. +3. For each template section, lift content from the brief + verbatim where the brief speaks to it. Light compression for + clarity is allowed; new facts are not. +4. Where the brief is silent, write `TBD` rather than inventing. +5. Write the spec to `specs/{feature-name}.md` and surface the + `TBD` entries for the user to fill in next. +6. Apply the tasking handoff (step 7 of the interactive flow): + multi-milestone specs get `/ctx-task-out`, small specs go + straight to `/ctx-implement`. + +## Process (interactive, when `--brief` is absent) + +### 1. Gather the Feature Name + +If not provided as an argument, ask: +> "What feature should this spec cover?" + +Derive the filename: lowercase, hyphens, no spaces. +Target path: `specs/{feature-name}.md` + +If the file already exists, warn and offer to review it instead. + +### 2. Read the Template + +Read `specs/tpl/spec-template.md` to get the current structure. + +### 3. Walk Through Sections + +Work through each section **one at a time**. For each section: + +1. Explain what belongs there (one sentence) +2. Ask the user for input or propose content based on context +3. Write their answer into the section +4. Move to the next section + +**Section order and prompts:** + +| Section | Prompt | +|----------------------|----------------------------------------------------------------------------------------------------| +| **Problem** | "What user-visible problem does this solve? Why now?" | +| **Approach** | "High-level: how does this work? Where does it fit?" | +| **Happy Path** | "Walk me through what happens when everything goes right." | +| **Edge Cases** | "What could go wrong? Think: empty input, partial failure, duplicates, concurrency, missing deps." | +| **Validation Rules** | "What input constraints are enforced? Where?" | +| **Error Handling** | "For each error condition: what message does the user see? How do they recover?" | +| **Interface** | "CLI command? Skill? Both? What flags?" | +| **Implementation** | "Which files change? Key functions? Existing helpers to reuse?" | +| **Configuration** | "Any .ctxrc keys, env vars, or settings?" | +| **Testing** | "Unit, integration, edge case tests?" | +| **Non-Goals** | "What does this intentionally NOT do?" | + +**Spend extra time on Edge Cases and Error Handling.** These are +where specs earn their value. Push for at least 3 edge cases and +their expected behaviors. Do not accept "none" without challenge. + +### 4. Open Questions + +After all sections, ask: +> "Anything unresolved? If not, I'll remove the Open Questions +> section." + +### 5. Write the Spec + +Write the completed spec to `specs/{feature-name}.md`. + +### 6. Cross-Reference + +- If a Phase exists in TASKS.md referencing this spec, confirm + the path matches +- If no tasks exist yet, offer to create them: + > "Want me to break this into tasks in TASKS.md?" + +### 7. Hand Off to Tasking + +If the spec spans multiple milestones or more than ~one session +of implementation, do not stop at coarse task creation: recommend +`/ctx-task-out --spec specs/<name>.md --milestone <first>` and +say why (specs stay concise; the plan carries decomposition). For +small specs, suggest `/ctx-implement` directly. + +## Skipping Sections + +Not every spec needs every section. If a section clearly does not +apply (e.g., no CLI for an internal refactor), the user can say +"skip" and the section is omitted entirely: not left with +placeholder text. + +## Quality Checklist + +Before writing the file, verify: + +- [ ] Problem section explains *why*, not just *what* +- [ ] At least 3 edge cases enumerated with expected behavior +- [ ] Error handling has user-facing messages and recovery steps +- [ ] Non-goals are explicit (prevents scope creep later) +- [ ] No placeholder `...` text remains +- [ ] Filename matches the convention: `specs/{feature-name}.md` diff --git a/internal/assets/integrations/opencode/skills/ctx-status/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-status/SKILL.md index 1674de6ad..345e97f6d 100644 --- a/internal/assets/integrations/opencode/skills/ctx-status/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-status/SKILL.md @@ -24,7 +24,76 @@ and recent activity. ```text /ctx-status +/ctx-status --verbose +/ctx-status --json ``` -The slash command takes no arguments. For verbose or JSON output, ask the -agent to run `ctx status --verbose` or `ctx status --json` directly. +## Flags + +| Flag | Short | Default | Purpose | +|-------------|-------|---------|----------------------------------| +| `--json` | | false | Output as JSON (for scripting) | +| `--verbose` | `-v` | false | Include file content previews | + +## What It Shows + +The output has three sections: + +### 1. Overview + +- Context directory path +- Total file count +- Token estimate (sum across all `.md` files in the context directory) + +### 2. Files + +Each `.md` file in the context directory with: + +| Indicator | Meaning | +|-----------|-----------------------------------------| +| check | File has content (loaded) | +| circle | File exists but is empty | + +File-specific summaries: +- `CONSTITUTION.md`: number of invariants +- `TASKS.md`: active and completed task counts +- `DECISIONS.md`: number of decisions +- `GLOSSARY.md`: number of terms +- Others: "loaded" or "empty" + +With `--verbose`: adds token count, byte size, and a 3-line +content preview per file. + +### 3. Recent Activity + +The 3 most recently modified files with relative timestamps +(e.g., "5 minutes ago", "2 hours ago"). + +## Execution + +```bash +ctx status +``` + +After running, summarize the key points for the user: +- How many active tasks remain +- Whether any context files are empty (might need populating) +- Token budget usage (is context lean or bloated?) +- What was recently modified (gives a sense of momentum) + +## Interpreting Results + +| Observation | Suggestion | +|-------------------------|-------------------------------------------------------------| +| Many empty files | Context is sparse; populate core files (TASKS, CONVENTIONS) | +| High token count (>30k) | Consider `ctx compact` or archiving completed tasks | +| No recent activity | Context may be stale; check if files need updating | +| TASKS.md has 0 active | All work done, or tasks need to be added | + +## Quality Checklist + +After running status, verify: +- [ ] Summarized the output for the user (do not just dump + raw output without commentary) +- [ ] Flagged any empty core files that should be populated +- [ ] Noted token budget if it seems high or low diff --git a/internal/assets/integrations/opencode/skills/ctx-task-add/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-task-add/SKILL.md new file mode 100644 index 000000000..36e2d3850 --- /dev/null +++ b/internal/assets/integrations/opencode/skills/ctx-task-add/SKILL.md @@ -0,0 +1,122 @@ +--- +name: ctx-task-add +description: "Add a task. Use when follow-up work is identified or when breaking down complex work into subtasks." +--- + +Add a task to TASKS.md. + +## Before Recording + +Three questions: if any answer is "no", don't record: + +1. **"Is this actionable?"** → If it's a vague wish, clarify first +2. **"Would someone else know what to do?"** → If not, add more detail +3. **"Is this tracked elsewhere?"** → If yes, don't duplicate + +Tasks should describe **what to do and why**, not just a topic. + +## When to Use + +- When follow-up work is identified during a session +- When breaking down a complex task into subtasks +- When the user mentions something that should be tracked + +## When NOT to Use + +- Vague ideas without clear scope (discuss first, then add) +- Work already completed (mark existing tasks done instead) +- One-line fixes you can do right now (just do it) + +## Gathering Information + +If the user provides only a topic, ask: + +1. "What specifically needs to happen?" → Scope the work +2. "Why does this matter?" → Capture motivation +3. "Is this high, medium, or low priority?" → Set priority + +## Execution + +```bash +ctx task add "Task description" \ + --session-id SESSION --branch BRANCH --commit HASH \ + [--priority high|medium|low] [--section "Phase N"] +``` + +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 task add`**: the conversational +approach lets you automatically pick up session ID, branch, and commit +from the provenance line already in your context window. + +**Placement**: Without `--section`, the task is inserted before the +first unchecked task in TASKS.md. Use `--section` only when you need +a specific section (e.g., `--section "Maintenance"`). + +**Example: specific and actionable:** +```bash +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 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 task add "Add topic-based navigation to blog when post count reaches 15+" \ + --session-id abc12345 --branch main --commit 68fbc00a \ + --priority low +``` + +**JSON payload (when content would trip a `permissions.deny` rule):** pass +`--json-file <path>` instead of the positional content + flags. The +`title` (plus an optional `body`, space-joined) becomes the task text; +`priority`, `section`, and a `provenance` envelope map to the flags: + +```bash +ctx task add --json-file /tmp/task.json # {"title","body","priority","section","provenance"} +``` + +**Bad examples (too shallow):** +```bash +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 +``` + +## Authority boundary (vs other skills) + +This skill records actionable follow-up work. It does not +unilaterally promote material from adjacent skills: + +- **Do not promote a casual "we should..." into a task.** If the + user hasn't agreed it's worth tracking, ask before recording. + Speculative TODOs clutter the file and degrade everyone's trust + in it. +- **Do not duplicate.** If the user describes work already covered + by an open task (even loosely), reference the existing task + instead of adding a near-duplicate. Drift accumulates fast here. +- **Do not silently promote a decision or learning into a task.** + "We should write this up" is a different ask from "track this + work item"; route to the correct skill. + +Light compression for clarity is allowed; new facts are not. + +## Quality Checklist + +Before recording, verify: +- [ ] Task starts with a verb (Add, Fix, Implement, Investigate, Update) +- [ ] Someone unfamiliar with the session could act on it +- [ ] Not a duplicate of an existing task in TASKS.md (check first) +- [ ] Priority set if the user indicated urgency + +Confirm the task was added. diff --git a/internal/assets/integrations/opencode/skills/ctx-task-out/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-task-out/SKILL.md new file mode 100644 index 000000000..83abced97 --- /dev/null +++ b/internal/assets/integrations/opencode/skills/ctx-task-out/SKILL.md @@ -0,0 +1,228 @@ +--- +name: ctx-task-out +description: "Decompose a committed spec into a per-milestone implementation plan at specs/plans/<milestone>.md — data model, contracts, invariant-test matrix, and tasks with falsifiable acceptance criteria — that /ctx-implement consumes. Use after /ctx-spec when a spec is too large to implement in one session." +--- + +## Canonical Chain + +The project's design-to-implementation pipeline is: + +```text +/ctx-brainstorm → /ctx-plan → /ctx-spec → /ctx-task-out → /ctx-implement + (vague) (contested) (committed) (decomposed) (execution) +``` + +`/ctx-task-out` is the fourth step. It consumes a committed spec +(`--spec <path>`) and produces the *plan document* that +`/ctx-implement` executes. It closes a gap the chain otherwise +leaves unowned: `/ctx-plan` explicitly disclaims implementation +planning, `/ctx-spec` commits the what/why at spec altitude, and +`/ctx-implement` opens with "use when you have a plan document" — +this skill is what produces that document. + +Small specs skip this step. If the whole spec is implementable in +roughly one session, go straight to `/ctx-implement` with the spec +itself. + +## Role + +You decompose; you do not redesign the bet. The spec is +committed; do not relitigate scope, behavior, or the bet here — +disagreements with the spec go back through `/ctx-plan`. +Implementation structure is different: choosing schema shapes, +signatures, and index strategies is exactly the job, because +resolving those decisions *before* execution is the point of +this skill. Make every task falsifiable and every design detail +the implementer needs explicit before execution starts, so no +large decision is made mid-flight. + +Authority boundary: invariants, validation rules, and behavior +come *from the spec*. If decomposition surfaces an invariant the +spec never states, that is a spec gap — surface it and mark it +`TBD`; do not mint it here. + +## When to Use + +- After `/ctx-spec`, when the spec spans milestones/phases or + exceeds ~one session of implementation +- When a TASKS.md phase references a spec but its tasks are coarse + and carry no acceptance criteria +- When `/ctx-implement` is invoked without a plan document + (redirect here first) + +## When NOT to Use + +- Single-session features — the spec *is* the plan +- The spec is not committed yet (`/ctx-spec` first) +- The bet is still contested (`/ctx-plan` first) +- Decomposing milestone N+1 while milestone N's DoD is unmet + (see rolling-wave gate) + +## Usage + +```text +/ctx-task-out --spec specs/v1-substrate.md --milestone m0a +/ctx-task-out --spec specs/rss-feed.md # single-milestone: whole spec +``` + +Without `--milestone`, the plan file takes the spec's basename: +`specs/plans/rss-feed.md`. + +## Preconditions (hard gates — refuse, do not degrade) + +1. **Spec exists.** If `--spec` is missing or the file is absent, + stop and report; no interactive fallback. +2. **Blocking-TBD gate.** Enumerate the spec's Open Questions / + `TBD` entries and classify each as *blocking* or *deferrable* + for the target milestone. A TBD is blocking if any task in the + milestone would embed an assumption about its answer (language + choice, storage engine, schema format…). Refuse to decompose + past a blocking TBD: list the blockers, name who can resolve + them, and stop. Deferrable TBDs do not vanish: carry each into + the plan (Out of scope or Risks), annotated with the milestone + at which it becomes blocking. Resolving a blocking TBD is a + spec edit or a DECISIONS.md entry *first*; the plan only + points at that record. A resolution that exists nowhere but + the plan is minting. +3. **Rolling-wave gate.** If a prior milestone's plan exists and + its DoD is not checked off, refuse to decompose the next + milestone. The user may override explicitly; log the + override in the plan's Amendments section. Tasking distant milestones + produces fiction — the current milestone's measurements are + allowed to reshape everything downstream. + +Milestone boundaries belong to the spec. If decomposition shows +the cut is wrong — one "milestone" hiding several, or a boundary +in the wrong place — stop and route the resize through the spec; +do not mint sub-milestones here. + +## Process + +0. **Detect mode.** If the target plan file already exists, this + is an amendment run, not a fresh decomposition: read the + existing plan, classify the change as obsolete/append, re-run + only the blocking-TBD gate against the delta, and log the + change in the plan's Amendments section. The rolling-wave + gate does not fire when amending the current milestone. + Steps 1–8 below describe a fresh run. + +1. Read the spec in full. Read TASKS.md, DECISIONS.md, and + CONVENTIONS.md from the context directory. +2. Run the blocking-TBD gate; surface the classification to the + user before proceeding. +3. Draft the plan sections (structure below). Lift from the spec + verbatim where it speaks; where it is silent, prefer asking or + marking `TBD` over inventing — same authority discipline as + `/ctx-spec --brief`. +4. Break down tasks: typically 15–40 per milestone. Each task + carries: id, a state cell (`st`, initialized `[ ]` — see the + ledger rule below), title, dependencies (by id), the files/paths it + is expected to touch, a `[P]` marker when + parallelizable with its siblings, a **falsifiable acceptance + criterion** (a command to run, a test that must pass, an + observable behavior), and a reference to the spec section it + implements. Size each task to roughly one commit — small + enough that a failed acceptance check localizes the fault to + that task. `[P]` is mechanical, not aspirational: no + dependency edge, no file touched by a sibling `[P]` task, no + shared sequence (e.g. migration numbers). File disjointness + is checkable from the files column — which is also how an + amendment run detects a new task colliding with one in + flight. +5. Build the test matrix: every invariant, validation rule, and + edge case the milestone touches × the attempted violation × the + expected failure mode × the task id whose acceptance criterion + exercises it. A matrix row no task exercises is documentation, + not execution. +6. Write `specs/plans/<milestone>.md` (create `specs/plans/` if + absent). +7. Sync anchors to TASKS.md: **epic-level anchors only** — one per + task cluster, each annotated `Plan: specs/plans/<milestone>.md` + with its task-id range. The clusters must **partition** the + plan's task ids: every id in exactly one epic, and the range + sizes must sum to the task count — state the arithmetic in the + plan; double-counted ids make the two surfaces irreconcilable. + State the completion rule where the anchors live: an epic is + checked `[x]` only when every task in its range is `[x]` or + `[o]` in the plan — the plan is the single source of truth for + milestone progress, TASKS.md epics are projections of it. + One-way sync, plan → TASKS.md. Never duplicate the full task + list into TASKS.md; never move or delete existing entries + (CONSTITUTION). +8. Hand off: report blockers resolved/remaining and suggest + `/ctx-implement` against the plan. + +## Plan Document Structure + +```markdown +# <Milestone> Plan — <short name> + +**Spec:** <path> · **Status:** Ready | Blocked +**Blocking TBDs resolved:** <list, with where each was decided> + +## Scope & DoD (lifted from the spec's milestone entry) +## Data model & storage (DDL, migrations, indexes) +## Contracts (API signatures, schemas, CLI surface) +## Test matrix (invariant × violation attempt × expected failure × task ref) +## Task breakdown (table: id · st · task · deps · files · [P] · acceptance criterion · spec ref) +## Risks & measurement gates (results that may reshape later tasks) +## Out of scope (deferred to later milestones, with pointers) +## Amendments (date · what · why — appended by amendment runs) +``` + +The plan is the **execution ledger**: the task table's `st` +column carries per-task state — `[ ]` pending, `[x]` done +(acceptance criterion demonstrably passed), `[o]` obsoleted by +amendment — Scope & DoD carries the DoD checkboxes, and +`/ctx-implement` updates both as it executes. A task table +without the `st` column is not a ledger: completion becomes +unrecordable and the milestone unauditable. DoD is +confirmed by measurement or by the user — never derived from +task completion — and the rolling-wave gate reads the DoD +checkboxes only. No other record of milestone progress exists. +`Status: Blocked` is reachable only by amendment: a fresh run +refuses instead of writing a Blocked plan; the status marks a +deferrable TBD that graduated to blocking mid-milestone. + +## Amendments (Mid-Milestone Changes) + +Plans meet reality; the plan document owns that contact. When a +measurement gate fires or the implementer hits a wall: + +- Tasks may be marked obsolete (`st` → `[o]`) with a one-line + reason; never deleted. +- New tasks are appended with fresh ids; ids are never reused. +- An acceptance criterion is **never edited in place** once its + task has started — weakening the test until it passes is the + failure mode this rule exists to prevent. A criterion change + is a re-invocation of `/ctx-task-out` against the same + milestone: with the plan already present, the skill operates + in amendment mode — read the existing plan, apply the change + as obsolete-and-append, and log date · what · why in the + plan's Amendments section. +- Disagreements with the *spec* discovered mid-flight still + route through `/ctx-plan`; amendments cover implementation + reality, not the bet. + +## Quality Checklist + +Before writing the file, verify: + +- [ ] Every task has a falsifiable acceptance criterion — no + "implement X" without a way to check it happened +- [ ] No task depends on an unresolved blocking TBD +- [ ] Every invariant the milestone touches appears in the test + matrix, and every matrix row is exercised by a task's + acceptance criterion (by id) +- [ ] Task ids admit a topological order — verify by listing + execution waves; `[P]` siblings share no files, edges, or + sequences +- [ ] Every task row has an `st` cell initialized `[ ]` — a + stateless table cannot be marked off or audited +- [ ] TASKS.md gained anchors only — nothing moved, nothing deleted +- [ ] Epic anchors partition the task ids (each id in exactly one + epic; range sizes sum to the task count) and the completion + rule is stated alongside them +- [ ] The plan is implementable-alone: a fresh agent holding only + the plan and the spec can state the acceptance check for + any task without asking a question diff --git a/internal/assets/integrations/opencode/skills/ctx-wrap-up/SKILL.md b/internal/assets/integrations/opencode/skills/ctx-wrap-up/SKILL.md index 9684d2e97..db156de6b 100644 --- a/internal/assets/integrations/opencode/skills/ctx-wrap-up/SKILL.md +++ b/internal/assets/integrations/opencode/skills/ctx-wrap-up/SKILL.md @@ -3,65 +3,302 @@ name: ctx-wrap-up description: "End-of-session context persistence ceremony. Use when wrapping up a session to capture learnings, decisions, conventions, and tasks." --- -Run the end-of-session context persistence ceremony. +Guide end-of-session context persistence. Gather signal from the +session, propose candidates worth persisting, and persist approved +items via `ctx add`. + +This is a **ceremony skill**: invoke it explicitly as `/ctx-wrap-up` +at session end, not conversationally. It pairs with `/ctx-remember` +at session start. + +## Before Starting + +Check that the context directory exists. If it does not, tell the user: +"No context directory found. Run `ctx init` to set up context +tracking, then there will be something to wrap up." + +## Handover Is the Mandatory Final Step + +`/ctx-wrap-up` owns the user-facing session-end trigger and +**always** delegates to `/ctx-handover` as its final step. +The handover is the former agent's note to the next agent +(or human): what happened, and what should come next. It +writes `.context/handovers/<TS>-<slug>.md` (timestamped so +multiple agent runs never overwrite). Without this final +step, `/ctx-remember` has nothing to read at the start of +the next session and recall degenerates into probabilistic +reconstruction from canonical files plus journal. + +## KB Editorial State (Phase KB, Optional) + +If `.context/kb/` exists, this project additionally uses the +editorial pipeline. After the capture phase but before the +final `/ctx-handover` delegation: + +1. List any closeouts under `.context/ingest/closeouts/`. + These are per-pass audit artifacts from `/ctx-kb-ingest`, + `/ctx-kb-ask`, etc. that have not yet been folded into a + handover. +2. Count unresolved entries in + `.context/kb/outstanding-questions.md` (rows whose Status + is `open`). +3. Surface both counts in the wrap-up summary so the operator + sees what editorial residue is pending; the handover + step's fold pass will consume the closeouts. + +When `.context/kb/` does NOT exist, skip this section +entirely; the wrap-up proceeds with the standard capture +checklist and still ends with `/ctx-handover`. ## When to Use -- When ending a work session -- When switching to a different project or task area -- When context window is getting large -- Before any long break from the project +- At the end of a session, before the user quits +- When the user says "let's wrap up", "save context", "end of + session" +- When the `check-persistence` hook suggests it + +## When NOT to Use + +- Nothing meaningful happened (only read files, quick lookup) +- The user already persisted everything manually with `ctx add` +- Mid-session when the user is still in flow: use `/ctx-reflect` + instead for mid-session checkpoints ## Process -1. Review work done in this session -2. Capture any new decisions to `.context/DECISIONS.md` -3. Capture any new learnings to `.context/LEARNINGS.md` -4. Capture any new conventions to `.context/CONVENTIONS.md` -5. Update task status in `.context/TASKS.md` -6. Save a session summary to `.context/sessions/` -7. Sweep this session — and any others that grew since their - last import — into the journal: `ctx journal import --all - -y`. It is growth-aware and idempotent, so running it - mid-wrap-up is safe. Best-effort and **non-blocking**: if - it errors, note it and continue; never let it block the - handover. -8. If `.context/kb/` exists, list pending closeouts under - `.context/ingest/closeouts/` and count `open` rows in - `.context/kb/outstanding-questions.md`; surface both - counts so the operator sees what editorial residue is - pending. The handover step's fold pass consumes the - closeouts. Skip this step entirely when `.context/kb/` - does not exist. -9. **Mandatory final step:** delegate to `/ctx-handover` so - the next session has something to read. Draft: - - **Title**: short noun phrase naming the session arc - (becomes the slug in `<TS>-<slug>.md`). - - **`--summary`** (past tense, one paragraph): what was - done this session. Concrete, not vague. - - **`--next`** (future tense, one paragraph): the - specific first action the next agent should take. - - **`--highlights`**: bullet list of notable artifacts. - Always draft; pass empty only after the user - explicitly says there is nothing to highlight. - - **`--open-questions`**: bullet list of things that - remain undecided. Always draft; pass empty only after - explicit user confirmation. - - Confirm the draft with the user, then invoke: - - ```text - /ctx-handover "<title>" --summary "<...>" --next "<...>" \ - [--highlights "<...>"] [--open-questions "<...>"] +### Phase 1: Gather signal + +Do this **silently**: do not narrate the steps: + +1. Check what changed in the working tree: + ```bash + git diff --stat + ``` +2. Check commits made this session: + ```bash + git log --oneline @{upstream}..HEAD 2>/dev/null || git log --oneline -5 ``` +3. Scan the conversation history for: + - Architectural choices or design trade-offs discussed + - Gotchas, bugs, or unexpected behavior encountered + - Patterns established or conventions agreed upon + - Follow-up work identified but not yet started + - Tasks completed or progressed + +### Phase 2: Propose candidates + +Think step-by-step about what is worth persisting. For each +potential candidate, ask yourself: +- Is this project-specific or general knowledge? (Only persist + project-specific insights) +- Would a future session benefit from knowing this? +- Is this already captured in the context files? +- Is this substantial enough to record, or is it trivial? + +Present candidates in a structured list, grouped by type. +Skip categories with no candidates: do not show empty sections. + +``` +## Session Wrap-Up + +### Learnings (N candidates) +1. **Title of learning** + - Context: What prompted this + - Lesson: The key insight + - Application: How to apply it going forward + +### Decisions (N candidates) +1. **Title of decision** + - Context: What prompted this + - Rationale: Why this choice + - Consequence: What changes as a result + +### Conventions (N candidates) +1. **Convention description** + +### Tasks (N candidates) +1. **Task description** (new | completed | updated) + +Persist all? Or select which to keep? +``` + +### Phase 3: Persist approved candidates + +Wait for the user to approve, select, or modify candidates. +Wait for the user to approve each item before persisting: +candidates proposed by the agent may be incomplete or +mischaracterized, and the user is the final authority on what +belongs in their context. + +For each approved candidate, run the appropriate command: + +| Type | Command | +|-------------|--------------------------------------------------------------------------------------------------------------------------------| +| 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 +and continue with the remaining items. + +### Phase 3.5: Suppress post-wrap-up nudges + +After persisting, mark the session as wrapped up so checkpoint +nudges are suppressed for the remainder of the session: + +```bash +ctx system mark-wrapped-up +``` + +### Phase 4: Surface Uncommitted Changes + +After persisting, check for uncommitted changes: + +```bash +git status --short +``` + +When `git status --short` reports any modified or untracked +files, surface them and offer `/ctx-commit`: + +> There are uncommitted changes (`<count>` files). Run +> `/ctx-commit` to commit with context capture? + +Do not auto-commit; the user decides. But always run the +`git status` check and always surface non-empty output. Do +not skip this phase silently when the working tree is dirty. + +### Phase 4.4: Surface knowledge health (suggest-only) + +Run: + +```bash +ctx system check-knowledge --report +``` + +When it prints findings, surface them as a closing suggestion: +a *foldable* root → run `/ctx-digest` **next session**; a *heavy* +page → split the theme or extract it to tooling. Prints nothing +when every root is within limits — then say nothing. + +**Never fold inline here.** The human is closing the laptop to go +live their life; running a semantic pass at wrap-up is against +their interest (spec: progressive-disclosure `### Triggers`). This +phase suggests for *next* session; it does not act. + +### Phase 4.5: Capture the session journal (best-effort) + +Before handing over, sweep this session — and any others that +have grown since their last import — into the journal so the +next session can read it: + +```bash +ctx journal import --all -y +``` + +This is growth-aware and idempotent: it imports the live +session as far as it has progressed today and self-heals on the +next run, so running it mid-wrap-up is safe and needs no flags +beyond `-y`. Treat it as **non-blocking** — if it errors, note +the error and continue to the handover anyway; a failed import +must never block the handover. (A `SessionEnd` hook runs the +same sweep automatically; this ceremony step is belt-and- +suspenders.) Enrichment is a separate LLM pass +(`/ctx-journal-enrich-all`) and is not part of wrap-up. + +### Phase 5: Delegate to `/ctx-handover` (mandatory) + +`/ctx-wrap-up` always ends here. Drafting the handover reuses +the signal gathered in Phase 1 and the candidates approved in +Phase 3: + +1. **Title**: a short noun phrase naming the session arc + (becomes the slug in `<TS>-<slug>.md`). Drawn from the + conversation; confirm with the user. +2. **`--summary`** (required, past tense): one paragraph + naming what was done this session, drawn from the approved + candidates and the git-log scan. Concrete, not vague. +3. **`--next`** (required, future tense): one paragraph + naming the specific first action the next agent should + take. Pull from the highest-priority pending task in + TASKS.md or the open thread the session was on. +4. **`--highlights`**: draft a bullet list of notable + artifacts produced this session (commits, decisions, + specs, files created). Always present a draft. Pass an + empty string only after the user has explicitly said + there is nothing to highlight. +5. **`--open-questions`**: draft a bullet list of things + that remain undecided. Pull from any candidate the user + did not turn into a decision, any deferred ingest pass, + any `TODO` discovered in the session. Always present a + draft. Pass an empty string only after the user has + explicitly confirmed there is nothing open. + +Surface the drafted values to the user for one final +confirmation, then delegate: + +```text +/ctx-handover "<title>" --summary "<...>" --next "<...>" \ + [--highlights "<...>"] [--open-questions "<...>"] +``` + +The `/ctx-handover` skill performs the pre-write gates, +writes `.context/handovers/<TS>-<slug>.md`, and (when +`.context/kb/` exists) folds postdated closeouts into the +`## Folded Closeouts` section and archives them. See +[`/ctx-handover`](#) for the full input contract and CLI +flag reference. + +If `/ctx-handover` refuses (missing `.context/handovers/`, +empty placeholder values, etc.), surface the refusal to the +user. Do not declare the wrap-up complete until the handover +landed. + +## Candidate Quality Guide + +### Good candidates + +- "PyMdownx `details` extension wraps content in `<details>` + tags, breaking `<pre><code>` rendering in MkDocs": specific + gotcha, actionable for future sessions +- "Decision: use file-based cooldown tokens instead of env vars + because hooks run in subprocesses": real trade-off with + rationale +- "Convention: all skill descriptions use imperative mood": + codifies a pattern for consistency + +### Weak candidates (do not propose) + +- "Go has good error handling": general knowledge, not + project-specific +- "We edited main.go": obvious from the diff, not an insight +- "Tests should pass before committing": too generic to be + useful +- Anything already present in LEARNINGS.md or DECISIONS.md + +## Relationship to /ctx-reflect + +`/ctx-reflect` is for mid-session checkpoints at natural +breakpoints. `/ctx-wrap-up` is for end-of-session: it's more +thorough, covers the full session arc, and includes the commit +offer. If the user already ran `/ctx-reflect` recently, avoid +proposing the same candidates again. - Do not declare the wrap-up complete until - `.context/handovers/<TS>-<slug>.md` has been written. +## Quality Checklist -## Self-Check +Before presenting candidates, verify: +- [ ] Signal was gathered (git diff, git log, conversation scan) +- [ ] Every candidate has complete fields (not just a title) +- [ ] Candidates are project-specific, not general knowledge +- [ ] No duplicates with existing context files +- [ ] Empty categories are omitted, not shown as "(none)" +- [ ] User is asked before anything is persisted -Ask: "If this session ended right now, would the next session -know what happened?" If no, persist more context before -ending. The handover step is the floor: without it, recall -degenerates to probabilistic reconstruction from canonical -files plus journal. +After persisting, verify: +- [ ] Each `ctx add` command succeeded +- [ ] Uncommitted changes were surfaced (if any) +- [ ] User was offered `/ctx-commit` (if applicable) +- [ ] `/ctx-handover` was invoked and the resulting + `.context/handovers/<TS>-<slug>.md` was written diff --git a/internal/assets/read/skill/parity_test.go b/internal/assets/read/skill/parity_test.go new file mode 100644 index 000000000..42881f94e --- /dev/null +++ b/internal/assets/read/skill/parity_test.go @@ -0,0 +1,98 @@ +// / ctx: https://ctx.ist +// ,'`./ do you remember? +// `.,'\ +// \ Copyright 2026-present Context contributors. +// SPDX-License-Identifier: Apache-2.0 + +package skill_test + +import ( + "bytes" + "io/fs" + "path" + "testing" + + "github.com/ActiveMemory/ctx/internal/assets" + "github.com/ActiveMemory/ctx/internal/config/asset" +) + +// syncedSkillTrees lists the embedded skill trees that are generated +// from the canonical Claude tree by a hack/sync-*-skills.sh script. +// Enrollment is opt-in by directory presence: a skill directory with +// no Claude counterpart is tool-only and exempt. +var syncedSkillTrees = []string{ + asset.DirIntegrationsOpenCodeSkill, + asset.DirIntegrationsCopilotSkill, +} + +// TestSyncedSkillParity asserts the sync contract at the test layer, +// where CI enforces it (`make check-*-skills` only runs via `make +// audit` on developer machines): every skill in a generated tree that +// has a canonical Claude counterpart must be byte-identical to that +// counterpart minus `allowed-tools:` lines (the Claude Code-specific +// frontmatter key the sync scripts strip). +func TestSyncedSkillParity(t *testing.T) { + var checked, exempt int + for _, tree := range syncedSkillTrees { + entries, dirErr := fs.ReadDir(assets.FS, tree) + if dirErr != nil { + t.Errorf("read skill tree %q: %v", tree, dirErr) + continue + } + for _, entry := range entries { + if !entry.IsDir() { + continue + } + canonical, readErr := fs.ReadFile(assets.FS, path.Join( + asset.DirClaudeSkills, entry.Name(), asset.FileSKILLMd, + )) + if readErr != nil { + // No ctx counterpart — tool-only skill, left + // untouched by the sync script. + exempt++ + continue + } + generatedPath := path.Join(tree, entry.Name(), asset.FileSKILLMd) + generated, genErr := fs.ReadFile(assets.FS, generatedPath) + if genErr != nil { + t.Errorf("%s: read: %v", generatedPath, genErr) + continue + } + if want := stripAllowedTools(canonical); !bytes.Equal(generated, want) { + t.Errorf( + "%s: drifted from canonical claude source minus "+ + "allowed-tools — run 'make sync-opencode-skills "+ + "sync-copilot-skills' and commit", + generatedPath, + ) + } + checked++ + } + } + if checked == 0 { + t.Fatal("no synced SKILL.md files discovered — embed glob or tree constants regressed") + } + t.Logf("verified %d synced skills (%d tool-only exempt) across %d trees", + checked, exempt, len(syncedSkillTrees)) +} + +// stripAllowedTools removes every line starting with +// `allowed-tools:`, mirroring the sync scripts' +// `sed '/^allowed-tools:/d'` transform exactly. +// +// Parameters: +// - src: Canonical SKILL.md content +// +// Returns: +// - []byte: Content with allowed-tools lines removed +func stripAllowedTools(src []byte) []byte { + lines := bytes.Split(src, []byte("\n")) + kept := make([][]byte, 0, len(lines)) + for _, line := range lines { + if bytes.HasPrefix(line, []byte("allowed-tools:")) { + continue + } + kept = append(kept, line) + } + return bytes.Join(kept, []byte("\n")) +} diff --git a/site/home/opencode/index.html b/site/home/opencode/index.html index 08e908a36..cbeb3c267 100644 --- a/site/home/opencode/index.html +++ b/site/home/opencode/index.html @@ -2115,17 +2115,17 @@ <h2 id="the-problem">The Problem<a class="headerlink" href="#the-problem" title= the AI repeats mistakes it made yesterday, and decisions get rediscovered instead of remembered.</p> <p><strong>Without <code>ctx</code>:</strong></p> -<div class="language-text highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a>> "Add the validation middleware we discussed" +<div class="language-text highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a>> "Add the validation middleware we discussed" </span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> -</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a>I don't have context about previous discussions. Could you describe -</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a>what validation middleware you're referring to? +</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a>I don't have context about previous discussions. Could you describe +</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a>what validation middleware you're referring to? </span></code></pre></div> <p><strong>With <code>ctx</code>:</strong></p> -<div class="language-text highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>> "Add the validation middleware we discussed" +<div class="language-text highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>> "Add the validation middleware we discussed" </span><span id="__span-1-2"><a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a> </span><span id="__span-1-3"><a id="__codelineno-1-3" name="__codelineno-1-3" href="#__codelineno-1-3"></a>Yes. From the Jan 15 session. You decided on Zod schemas at the </span><span id="__span-1-4"><a id="__codelineno-1-4" name="__codelineno-1-4" href="#__codelineno-1-4"></a>route level (DECISIONS.md #12), and the pattern is in -</span><span id="__span-1-5"><a id="__codelineno-1-5" name="__codelineno-1-5" href="#__codelineno-1-5"></a>CONVENTIONS.md. I'll follow the existing middleware in +</span><span id="__span-1-5"><a id="__codelineno-1-5" name="__codelineno-1-5" href="#__codelineno-1-5"></a>CONVENTIONS.md. I'll follow the existing middleware in </span><span id="__span-1-6"><a id="__codelineno-1-6" name="__codelineno-1-6" href="#__codelineno-1-6"></a>src/middleware/auth.ts as a reference. </span></code></pre></div> <p>That's the whole pitch: <strong>your AI remembers</strong>.</p> @@ -2239,7 +2239,10 @@ <h3 id="what-is-not-included">What Is <em>Not</em> Included<a class="headerlink" approval for every shell command) makes a pre-execution blocklist unnecessary.</p> <h2 id="slash-commands">Slash Commands<a class="headerlink" href="#slash-commands" title="Permanent link">¶</a></h2> -<p>Four skills are available as slash commands:</p> +<p>The skills are generated from the canonical ctx skill tree at build +time, so their names and behavior match the Claude Code integration +one-to-one.</p> +<p>Session lifecycle:</p> <table> <thead> <tr> @@ -2264,6 +2267,93 @@ <h2 id="slash-commands">Slash Commands<a class="headerlink" href="#slash-command <td><code>/ctx-wrap-up</code></td> <td>End-of-session ceremony. Captures learnings, decisions, conventions, and outstanding tasks to <code>.context/</code> files.</td> </tr> +<tr> +<td><code>/ctx-handover</code></td> +<td>Write a per-session handover note for the next agent (invoked by <code>/ctx-wrap-up</code>).</td> +</tr> +</tbody> +</table> +<p>The planning arc from the +<a href="../../recipes/design-before-coding/">Design Before Coding</a> +recipe:</p> +<table> +<thead> +<tr> +<th>Command</th> +<th>When to use</th> +</tr> +</thead> +<tbody> +<tr> +<td><code>/ctx-brainstorm</code></td> +<td>Design before implementation: turn a vague idea into a validated design.</td> +</tr> +<tr> +<td><code>/ctx-plan</code></td> +<td>Stress-test a plan through adversarial interview; produces a debated brief.</td> +</tr> +<tr> +<td><code>/ctx-spec</code></td> +<td>Scaffold a feature spec from the project template.</td> +</tr> +<tr> +<td><code>/ctx-task-out</code></td> +<td>Decompose a committed spec into a per-milestone implementation plan.</td> +</tr> +<tr> +<td><code>/ctx-implement</code></td> +<td>Execute a plan step-by-step with verification.</td> +</tr> +</tbody> +</table> +<p>Capture:</p> +<table> +<thead> +<tr> +<th>Command</th> +<th>When to use</th> +</tr> +</thead> +<tbody> +<tr> +<td><code>/ctx-task-add</code></td> +<td>Add a task when follow-up work is identified.</td> +</tr> +<tr> +<td><code>/ctx-decision-add</code></td> +<td>Record an architectural decision with rationale.</td> +</tr> +</tbody> +</table> +<p>Knowledge-base editorial pipeline (active when <code>.context/kb/</code> exists):</p> +<table> +<thead> +<tr> +<th>Command</th> +<th>When to use</th> +</tr> +</thead> +<tbody> +<tr> +<td><code>/ctx-kb-ingest</code></td> +<td>Editorial knowledge-ingestion pass over supplied sources.</td> +</tr> +<tr> +<td><code>/ctx-kb-ask</code></td> +<td>Q&A grounded in the existing kb.</td> +</tr> +<tr> +<td><code>/ctx-kb-note</code></td> +<td>Park a finding for the next ingest pass.</td> +</tr> +<tr> +<td><code>/ctx-kb-site-review</code></td> +<td>Mechanical structural audit of the kb.</td> +</tr> +<tr> +<td><code>/ctx-kb-ground</code></td> +<td>Read-only freshness audit over the kb's tracked sources.</td> +</tr> </tbody> </table> <p>You don't need to use these often. The plugin handles most context loading diff --git a/site/search.json b/site/search.json index 5ed0ae5cd..5eec836f2 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 <code>ctx</code> Manifesto","text":"<p>Creation, not code.</p> <p>Context, not prompts.</p> <p>Verification, not vibes.</p> <p>This Is NOT a Metaphor</p> <p>Code executes instructions.</p> <p>Creation produces outcomes.</p> <p>Confusing the two is how teams ship motion...</p> <p>...instead of progress.</p> <ul> <li>It was never about the code.</li> <li>Code has zero standalone value.</li> <li>Code is an implementation detail.</li> </ul> <p>Code is an incantation.</p> <p>Creation is the act.</p> <p>And creation does not happen in a vacuum.</p>","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-the-substrate","level":2,"title":"<code>ctx</code> Is the Substrate","text":"<p>Constraints Have Moved</p> <p>Human bandwidth is no longer the limiting factor.</p> <p>Context integrity is.</p> <p>Human bandwidth is no longer the constraint.</p> <p>Context is:</p> <ul> <li>Without durable context, intelligence resets.</li> <li>Without memory, reasoning decays.</li> <li>Without structure, scale collapses.</li> </ul> <p>Creation is now limited by:</p> <ul> <li>Clarity of intent;</li> <li>Quality of context;</li> <li>Rigor of verification.</li> </ul> <p>Not by speed.</p> <p>Not by capacity.</p> <p>Velocity Amplifies</p> <p>Faster execution on broken context compounds error.</p> <p>Speed multiplies whatever is already wrong.</p>","path":["Manifesto"],"tags":[]},{"location":"#humans-author-meaning","level":2,"title":"Humans Author Meaning","text":"<p>Intent Is Authored</p> <p>Systems can optimize.</p> <p>Models can generalize.</p> <p>Meaning must be chosen.</p> <p>Intent is not emergent.</p> <p>Vision, goals, and direction are human responsibilities.</p> <p>We decide:</p> <ul> <li>What matters;</li> <li>What success means;</li> <li>What world we are building.</li> </ul> <p><code>ctx</code> encodes the intent so it...</p> <ul> <li>survives time,</li> <li>survives handoffs,</li> <li>survives scale.</li> </ul> <p>Nothing important should live only in conversation.</p> <p>Nothing critical should depend on recall.</p> <p>Oral Tradition Does Not Scale</p> <p>If intent cannot be inspected, it cannot be enforced.</p>","path":["Manifesto"],"tags":[]},{"location":"#ctx-before-action","level":2,"title":"<code>ctx</code> Before Action","text":"<p>Orientation Precedes Motion</p> <p>Acting first and understanding later is not bravery.</p> <p>It is debt.</p> <p>Never act without <code>ctx</code>.</p> <p>Before execution, we must verify:</p> <ul> <li>Where we are;</li> <li>Why we are here;</li> <li>What constraints apply;</li> <li>What assumptions are active.</li> </ul> <p>Action without <code>ctx</code> is gambling.</p> <p>Speed without orientation is noise.</p> <p><code>ctx</code> is not overhead: It is the cost of correctness.</p>","path":["Manifesto"],"tags":[]},{"location":"#persistent-context-beats-prompt-memory","level":2,"title":"Persistent Context Beats Prompt Memory","text":"<p>Transience Is the Default Failure Mode</p> <ul> <li>Prompts decay.</li> <li>Chats fragment.</li> <li>Memory heuristics drift.</li> </ul> <p>Prompts are transient.</p> <p>Chats are lossy.</p> <p>Memory heuristics drift.</p> <p><code>ctx</code> must be:</p> <ul> <li>Durable;</li> <li>Structured;</li> <li>Explicit;</li> <li>Queryable.</li> </ul> <p>Intent Must Be Intentional</p> <p>If intent exists only in a prompt... </p> <p>...alignment is already degrading.</p> <p>Knowledge lives in the artifacts:</p> <ul> <li>Decisions;</li> <li>Documentation;</li> <li>Dependency maps;</li> <li>Evaluation history.</li> </ul> <p>Artifacts Outlive Sessions</p> <p>What is not written will be re-learned.</p> <p>At full cost.</p>","path":["Manifesto"],"tags":[]},{"location":"#what-ctx-is-not","level":2,"title":"What <code>ctx</code> Is Not","text":"<p>Avoid Category Errors</p> <p>Mislabeling <code>ctx</code> guarantees misuse.</p> <p><code>ctx</code> is not a memory feature.</p> <ul> <li><code>ctx</code> is not prompt engineering.</li> <li><code>ctx</code> is not a productivity hack.</li> <li><code>ctx</code> is not automation theater.</li> </ul> <p><code>ctx</code> is a system for preserving intent under scale.</p> <p><code>ctx</code> is infrastructure.</p>","path":["Manifesto"],"tags":[]},{"location":"#verified-reality-is-the-scoreboard","level":2,"title":"Verified Reality Is the Scoreboard","text":"<p>Activity Is a False Proxy</p> <p>Output volume correlates poorly with impact.</p> <ul> <li>Code is not progress.</li> <li>Activity is not impact.</li> </ul> <p>The only truth that compounds is verified change. </p> <p>Verified change must exist in the real world.</p> <p>Hypotheses are cheap; outcomes are not.</p> <p><code>ctx</code> captures:</p> <ul> <li>What we expected;</li> <li>What we observed;</li> <li>Where reality diverged.</li> </ul> <p>If we cannot predict, measure, and verify the result...</p> <p>...it does not count.</p>","path":["Manifesto"],"tags":[]},{"location":"#build-to-learn-not-to-accumulate","level":2,"title":"Build to Learn, Not to Accumulate","text":"<p>Prototypes Have an Expiration Date</p> <p>A prototype's value is information, not longevity.</p> <p>Prototypes exist to reduce uncertainty.</p> <p>We build to:</p> <ul> <li>Test assumptions;</li> <li>Validate architecture;</li> <li>Answer specific questions.</li> </ul> <p>Not everything.</p> <p>Not blindly.</p> <p>Not permanently.</p> <p><code>ctx</code> records archeology so the cost is paid once.</p>","path":["Manifesto"],"tags":[]},{"location":"#failures-are-assets","level":2,"title":"Failures Are Assets","text":"<p>Failure without Capture Is Waste</p> <p>Pain that does not teach is pure loss.</p> <p>Failures are not erased: They are preserved.</p> <p>Each failure becomes:</p> <ul> <li>A documented hypothesis;</li> <li>An analyzed deviation;</li> <li>A permanent artifact.</li> </ul> <p>Rollback fixes symptoms: <code>ctx</code> fixes systems.</p> <p>A repeated mistake is a missing <code>ctx</code> artifact.</p>","path":["Manifesto"],"tags":[]},{"location":"#structure-enables-scale","level":2,"title":"Structure Enables Scale","text":"<p>Unbounded Autonomy Destabilizes</p> <p>Power without a structure produces chaos.</p> <p>Transpose it:</p> <p>Power without any structure becomes chaos.</p> <p><code>ctx</code> defines:</p> <ul> <li>Roles;</li> <li>Boundaries;</li> <li>Protocols;</li> <li>Escalation paths;</li> <li>Decision rights.</li> </ul> <p>Ambiguity is a system failure:</p> <ul> <li>Debates must be structured.</li> <li>Decisions must be explicit.</li> <li>History must be retained.</li> </ul>","path":["Manifesto"],"tags":[]},{"location":"#encode-intent-into-the-environment","level":2,"title":"Encode Intent into the Environment","text":"<p>Goodwill Does Not Belong to the Table</p> <p>Alignment that depends on memory will drift.</p> <p>Alignment cannot depend on memory or goodwill.</p> <p>Do not rely on people to remember.</p> <p>Encode the behavior, so it happens by default.</p> <p>Intent is encoded as:</p> <ul> <li>Policies;</li> <li>Schemas;</li> <li>Constraints;</li> <li>Evaluation harnesses.</li> </ul> <p>Rules must be machine-readable.</p> <p>Laws must be enforceable.</p> <p>If intent is implicit, drift is guaranteed.</p>","path":["Manifesto"],"tags":[]},{"location":"#cost-is-a-first-class-signal","level":2,"title":"Cost Is a First-Class Signal","text":"<p>Attention Is the Scarcest Resource</p> <p>Not ideas.</p> <p>Not ambition.</p> <p>Ideas do not compete on time:</p> <p>They compete on cost and impact:</p> <ul> <li>Attention is finite.</li> <li>Compute is finite.</li> <li>Context is expensive.</li> </ul> <p>We continuously ask:</p> <ul> <li>What the most valuable next action is.</li> <li>What outcome justifies the cost.</li> </ul> <p><code>ctx</code> guides allocation.</p> <p>Learning reshapes priority.</p>","path":["Manifesto"],"tags":[]},{"location":"#show-the-why","level":2,"title":"Show the Why","text":"<p><code>{}</code> (code, artifacts, apps, binaries) produce outputs; they do not preserve reasoning.</p> <p>Systems that cannot explain themselves will not be trusted.</p> <p>Traceability builds trust.</p> <pre><code> {} --> what\n\n ctx --> why\n</code></pre> <p>We record:</p> <ul> <li>Explored paths;</li> <li>Rejected options;</li> <li>Assumptions made;</li> <li>Evidence used.</li> </ul> <p>Opaque systems erode trust:</p> <p>Transparent <code>ctx</code> compounds understanding.</p>","path":["Manifesto"],"tags":[]},{"location":"#continuously-verify-the-system","level":2,"title":"Continuously Verify the System","text":"<p>Stability Is Temporary</p> <p>Every assumption has a half-life:</p> <ul> <li>Models drift.</li> <li>Tools change.</li> <li>Assumptions rot.</li> </ul> <p><code>ctx</code> must be verified against reality.</p> <p>Trust is a spectrum.</p> <p>Trust is continuously re-earned:</p> <ul> <li>Benchmarks, </li> <li>regressions, </li> <li>and evaluations... </li> </ul> <p>...are safety rails.</p>","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-leverage","level":2,"title":"<code>ctx</code> Is Leverage","text":"<p>Humans Are Decision Engines</p> <p>Execution should not consume judgment.</p> <p>Humans must not be typists.</p> <p>We are the authors.</p> <p>Human effort is reserved for:</p> <ul> <li>Judgment;</li> <li>Design;</li> <li>Taste;</li> <li>Synthesis.</li> </ul> <p>Repetition is delegated.</p> <p>Toil is automated.</p> <p><code>ctx</code> preserves leverage across time.</p>","path":["Manifesto"],"tags":[]},{"location":"#the-thesis","level":2,"title":"The Thesis","text":"<p>Invariant</p> <p>Everything else is an implementation detail.</p> <ul> <li>Creation is the act.</li> <li><code>ctx</code> is the substrate.</li> <li>Verification is the truth.</li> </ul> <p>Code executes → Models reason → Agents amplify.</p> <p><code>ctx</code> lives on.</p> <ul> <li>Without <code>ctx</code>, intelligence resets.</li> <li>With <code>ctx</code>, creation compounds.</li> </ul>","path":["Manifesto"],"tags":[]},{"location":"blog/","level":1,"title":"Blog","text":"<p>Stories, insights, and lessons learned from building and using <code>ctx</code>.</p>","path":["Blog"],"tags":[]},{"location":"blog/#releases","level":2,"title":"Releases","text":"","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v080-the-architecture-release","level":3,"title":"<code>ctx</code> v0.8.0: The Architecture Release","text":"<p>March 23, 2026: 374 commits, 1,708 Go files touched, and a near-complete architectural overhaul. Every CLI package restructured into <code>cmd/ + core/</code> 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 <code>.context/</code>.</p> <p>Topics: release, architecture, refactoring, MCP, localization</p>","path":["Blog"],"tags":[]},{"location":"blog/#field-notes","level":2,"title":"Field Notes","text":"","path":["Blog"],"tags":[]},{"location":"blog/#the-cheapest-patch-was-the-most-expensive-what-seven-ai-coding-runs-taught-me-about-cost","level":3,"title":"The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost","text":"<p>June 21, 2026: One boring CLI bug, seven runs, three model tiers, and compression on versus off. The cheapest run missed the contract; the most expensive run quietly rewrote it; the best run simply found the parser that already existed before the task shape hardened. The expensive part of AI coding is not the diff: it is missing the smaller job. Make implementation inventory a hard gate before the spec expands.</p> <p>Topics: spec-driven development, model selection, context compression, agentic coding cost, field notes</p>","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":"<p>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.</p> <p>Topics: architecture, code intelligence, agent behavior, design patterns, field notes</p>","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":"<p>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.</p> <p>Topics: ast, code quality, agent readability, conventions, field notes</p>","path":["Blog"],"tags":[]},{"location":"blog/#we-broke-the-31-rule","level":3,"title":"We Broke the 3:1 Rule","text":"<p>March 23, 2026: After v0.6.0, we ran 198 feature commits across 17 days before consolidating. The 3:1 rule says consolidate every 4<sup>th</sup> session. We did it after the 66<sup>th</sup>. 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.</p> <p>Topics: consolidation, technical debt, development workflow, convention drift, field notes</p>","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":"<p>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).</p> <p>Topics: context engineering, agent memory, infrastructure, persistence, team knowledge</p>","path":["Blog"],"tags":[]},{"location":"blog/#context-as-infrastructure","level":3,"title":"Context as Infrastructure","text":"<p>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.</p> <p>Topics: context engineering, infrastructure, progressive disclosure, persistence, design philosophy</p>","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":"<p>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 <code>ctx</code>: hierarchical file structure, explicit budgets, progressive disclosure, and filesystem-as-index.</p> <p>Topics: attention mechanics, context engineering, progressive disclosure, <code>ctx</code> primitives, token budgets</p>","path":["Blog"],"tags":[]},{"location":"blog/#before-context-windows-we-had-bouncers","level":3,"title":"Before Context Windows, We Had Bouncers","text":"<p>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.</p> <p>Topics: context engineering, infrastructure, IRC, persistence, state continuity</p>","path":["Blog"],"tags":[]},{"location":"blog/#the-last-question","level":3,"title":"The Last Question","text":"<p>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.</p> <p>Topics: context continuity, long-lived systems, persistence, intelligence over time, field notes</p>","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":"<p>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.</p> <p>Topics: hooks, agent behavior, context engineering, behavioral design, testing methodology, compliance monitoring</p>","path":["Blog"],"tags":[]},{"location":"blog/#skills-that-fight-the-platform","level":3,"title":"Skills That Fight the Platform","text":"<p>February 4, 2026: When custom skills conflict with system prompt defaults, the AI has to reconcile contradictory instructions. Five conflict patterns discovered while building <code>ctx</code>.</p> <p>Topics: context engineering, skill design, system prompts, antipatterns, AI safety primitives</p>","path":["Blog"],"tags":[]},{"location":"blog/#the-anatomy-of-a-skill-that-works","level":3,"title":"The Anatomy of a Skill That Works","text":"<p>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.</p> <p>Topics: skill design, context engineering, quality gates, E/A/R framework, practical patterns</p>","path":["Blog"],"tags":[]},{"location":"blog/#you-cant-import-expertise","level":3,"title":"You Can't Import Expertise","text":"<p>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.</p> <p>Topics: skill adaptation, E/A/R framework, convention drift, consolidation, project-specific expertise</p>","path":["Blog"],"tags":[]},{"location":"blog/#not-everything-is-a-skill","level":3,"title":"Not Everything Is a Skill","text":"<p>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.</p> <p>Topics: skill design, context engineering, automation discipline, recipes, agent teams</p>","path":["Blog"],"tags":[]},{"location":"blog/#defense-in-depth-securing-ai-agents","level":3,"title":"Defense in Depth: Securing AI Agents","text":"<p>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.</p> <p>Topics: agent security, defense in depth, prompt injection, autonomous loops, container isolation</p>","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":"<p>February 17, 2026: AI does not replace workers. It replaces unstructured effort. Three weeks of building <code>ctx</code> with an AI agent proved it: YOLO mode showed production is cheap, the 3:1 ratio showed judgment has a cadence.</p> <p>Topics: AI and expertise, context engineering, judgment vs production, human-AI collaboration, automation discipline</p>","path":["Blog"],"tags":[]},{"location":"blog/#the-31-ratio","level":3,"title":"The 3:1 Ratio","text":"<p>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.</p> <p>Topics: consolidation, technical debt, development workflow, convention drift, code quality</p>","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":"<p>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.</p> <p>Topics: refactoring, code quality, documentation standards, module decomposition, YOLO versus intentional development</p>","path":["Blog"],"tags":[]},{"location":"blog/#how-deep-is-too-deep","level":3,"title":"How Deep Is Too Deep?","text":"<p>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.</p> <p>Topics: AI foundations, abstraction boundaries, agentic systems, context engineering, failure modes</p>","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":"<p>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.</p> <p>Topics: agent workflows, parallelism, verification, context engineering, engineering practice</p>","path":["Blog"],"tags":[]},{"location":"blog/#parallel-agents-with-git-worktrees","level":3,"title":"Parallel Agents with Git Worktrees","text":"<p>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.</p> <p>Topics: agent teams, parallelism, git worktrees, context engineering, task management</p>","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":"<p>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.</p> <p>Topics: field notes, adoption signals, infrastructure vs tools, context engineering, substrates</p>","path":["Blog"],"tags":[]},{"location":"blog/#why-zensical","level":3,"title":"Why Zensical","text":"<p>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.</p> <p>Topics: tooling, static site generators, journal system, infrastructure decisions, context engineering</p>","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":"<code>ctx</code> v0.6.0: The Integration Release","text":"<p>February 16, 2026: <code>ctx</code> 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.</p> <p>Topics: release, plugin system, Claude Marketplace, distribution, security hardening</p>","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v030-the-discipline-release","level":3,"title":"<code>ctx</code> v0.3.0: The Discipline Release","text":"<p>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.</p> <p>Topics: release, skills migration, consolidation, code quality, E/A/R framework</p>","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v020-the-archaeology-release","level":3,"title":"<code>ctx</code> v0.2.0: The Archaeology Release","text":"<p>February 1, 2026: What if your AI could remember everything? Not just the current session, but every session. <code>ctx</code> v0.2.0 introduces the recall and journal systems.</p> <p>Topics: session recall, journal system, structured entries, token budgets, meta-tools</p>","path":["Blog"],"tags":[]},{"location":"blog/#building-ctx-using-ctx-a-meta-experiment-in-ai-assisted-development","level":3,"title":"Building <code>ctx</code> Using <code>ctx</code>: A Meta-Experiment in AI-Assisted Development","text":"<p>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 <code>ctx</code>.</p> <p>Topics: dogfooding, AI-assisted development, Ralph Loop, session persistence, architectural decisions</p>","path":["Blog"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/","level":1,"title":"Building <code>ctx</code> Using <code>ctx</code>","text":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism.</p> <p>References to <code>.context/sessions/</code>, auto-save hooks, and <code>SessionEnd</code> auto-save in this post reflect the architecture at the time of writing.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-01-27</p> <p>Can a Tool Design Itself?</p> <p>What happens when you build a tool designed to give AI memory, using that very same tool to remember what you are building? </p> <p>This is the story of <code>ctx</code>, 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.</p> <p>Context Is a Record</p> <p>Context is a persistent record.</p> <p>By \"context\", I don't mean model memory or stored thoughts: </p> <p>I mean the durable record of decisions, learnings, and intent that normally evaporates between sessions.</p>","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":"<p>Every developer who works with AI code generators knows the frustration: </p> <p>You have a deep, productive session where the AI understands your codebase, your conventions, your decisions. And then you close the terminal. </p> <p>Tomorrow; it's a blank slate. The AI has forgotten everything.</p> <p>That is \"reset amnesia\", and it's not just annoying: it's expensive. </p> <p>Every session starts with: </p> <ul> <li>Re-explaining context;</li> <li>Re-reading files; </li> <li>Re-discovering decisions that were already made.</li> </ul> <p>I Needed Context</p> <p>\"I don't want to lose this discussion...</p> <p>...I am a brain-dead developer YOLO'ing my way out.\"</p> <p>☝️ that's exactly what I said to Claude when I first started working on <code>ctx</code>.</p>","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":"<p>The project started as \"Active Memory\" (<code>amem</code>): a CLI tool to persist AI context across sessions. </p> <p>The core idea was simple: </p> <ol> <li>Create a <code>.context/</code> directory with structured Markdown files for decisions, learnings, tasks, and conventions. </li> <li>The AI reads these at session start and writes to them before the session ends.</li> <li>There is no step 3.</li> </ol> <p>The first commit was just scaffolding. But within hours, the Ralph Loop (An iterative AI development workflow) had produced a working CLI:</p> <pre><code>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</code></pre> <p>Not one, not two, but a whopping fourteen core commands shipped in rapid succession!</p> <p>I was YOLO'ing like there was no tomorrow:</p> <ul> <li>Auto-accept every change;</li> <li>Let the AI run free;</li> <li>Ship features fast.</li> </ul>","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 <code>amem</code> to Build <code>amem</code>","text":"<p>Here's where it gets interesting: On January 20<sup>th</sup>, I asked: </p> <p>\"Can I use <code>amem</code> to help you remember this context when I restart?\"</p> <p>The answer was yes, but with a gap: </p> <p>Autoload worked (via Claude Code's <code>PreToolUse</code> hook), but auto-save was missing: If the user quit, with Ctrl+C, everything since the last manual save was lost.</p> <p>That session became the first real test of the system. </p> <p>Here is the first session file we recorded:</p> <pre><code>## 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</code></pre> <p>This session file (written by the AI to preserve its own context) became the template for how <code>ctx</code> handles session persistence.</p>","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":"<p>By January 21<sup>st</sup>, I realized \"Active Memory\" was too generic, and (arguably) too marketing-smelly. </p> <p>Besides, the binary was already called <code>ctx</code> (short for Context), the directory was <code>.context/</code>, and the slash commands would be <code>/ctx-*</code>. </p> <p>So it followed that the project should be renamed to <code>ctx</code> to make things make sense.</p> <p>The rename touched 100+ files but was clean: a find-and-replace with Go's type system catching any misses.</p> <p>The <code>git</code> history tells the story:</p> <pre><code>0e8f6bb feat: rename amem to ctx and add Claude Code integration\n87dcfa1 README.\n4f0e195 feat: separate orchestrator directive from agent tasks\n</code></pre>","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":"<p>The Ralph Loop made feature development incredibly fast.</p> <p>But it created technical debt that I didn't notice until later.</p> <p>A comparison session on January 25<sup>th</sup> revealed the patterns:</p> YOLO Pattern What We Found <code>\"TASKS.md\"</code> scattered in 10 files Same string literal everywhere, no constants <code>dir + \"/\" + file</code> Should be <code>filepath.Join()</code> Monolithic <code>cli_test.go</code> (1500+ lines) Tests disconnected from implementations <code>package initcmd</code> in <code>init/</code> folder Go's \"init\" is reserved: subtle naming collision <p>Here is another analysis made by <code>ctx</code>:</p> <pre><code>● 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</code></pre> <p>The fix required a human-guided refactoring session. I continued to do that before every major release, from that point on.</p> <p>We introduced <code>internal/config/config.go</code> with semantic prefixes:</p> <pre><code>const (\n DirContext = \".context\"\n DirArchive = \"archive\"\n DirSessions = \"sessions\"\n FilenameTask = \"TASKS.md\"\n UpdateTypeTask = \"task\"\n)\n</code></pre> <p>What I begrudgingly learned was: YOLO mode is effective for velocity but accumulates debt. </p> <p>So I took a mental note to schedule periodic consolidation sessions.</p>","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":"<p>On January 21<sup>st</sup>, I ran an experiment: have another Claude instance rebuild <code>ctx</code> from scratch using only the specs and <code>PROMPT.md</code>. </p> <p>The Ralph Loop ran, all tasks got checked off, the loop exited successfully.</p> <p>But the binary was broken!</p> <p>Commands just printed help text instead of executing. </p> <p>All tasks were marked \"complete\" but the implementation didn't work.</p> <p>Here's what <code>ctx</code> discovered:</p> <pre><code>## 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</code></pre> <p>This was humbling; to say the least.</p> <p>I realized I had the same blind spot in my own codebase: no integration tests that actually invoked the binary. </p> <p>So I added:</p> <ul> <li>Integration tests for all commands;</li> <li>Coverage targets (60-80% per package)</li> <li>Smoke tests in CI</li> <li>A constitution rule: \"All code must pass tests before commit\"</li> </ul>","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":"<p>As lessons accumulated, there was the temptation to add everything to <code>CONSTITUTION.md</code> as \"inviolable rules\". </p> <p>But I resisted.</p> <p>The constitution should contain only truly inviolable invariants:</p> <ul> <li>Security (no secrets, no customer data)</li> <li>Quality (tests must pass)</li> <li>Process (decisions need records)</li> <li><code>ctx</code> invocation (always use <code>PATH</code>, never fallback)</li> </ul> <p>Everything else (coding style, file organization, naming conventions...) should go in to <code>CONVENTIONS.md</code>. </p> <p>Here's how <code>ctx</code> explained why the distinction was important: </p> <p>Decision Record, 2026-01-25</p> <p>Overly strict constitution creates friction and gets ignored.</p> <p>Conventions can be bent; constitution cannot.</p>","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":"<p>Claude Code hooks seemed simple: Run a script before/after certain events. </p> <p>But I hit multiple gotchas:</p> <p>1. Key names matter</p> <pre><code>// WRONG - \"Invalid key in record\" error\n\"PreToolUseHooks\": [...]\n\n// RIGHT\n\"PreToolUse\": [...]\n</code></pre> <p>2. Blocking requires specific output</p> <pre><code># 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</code></pre> <p>3. Go's JSON escaping</p> <p><code>json.Marshal</code> escapes <code>></code>, <code><</code>, <code>&</code> as unicode (<code>\\u003e</code>) by default. </p> <p>When generating shell commands in JSON:</p> <pre><code>encoder := json.NewEncoder(file)\nencoder.SetEscapeHTML(false) // Prevent 2>/dev/null → 2\\u003e/dev/null\n</code></pre> <p>4. Regex overfitting</p> <p>My hook to block non-PATH <code>ctx</code> invocations initially matched too broadly:</p> <pre><code># 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</code></pre>","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":"<p>By the time of this writing this project's <code>ctx</code> sessions (<code>.context/sessions/</code>) contains 40+ files from this project's development.</p> <p>They are not part of the source code due to security, privacy, and size concerns.</p> <p>Middle Ground: The Scratchpad</p> <p>For sensitive notes that do need to travel with the project, <code>ctx pad</code> stores encrypted one-liners in git, and <code>ctx pad add \"label\" --file PATH</code> can ingest small files.</p> <p>See Scratchpad for details.</p> <p>However, they are invaluable for the project's progress.</p> <p>Each session file is a timestamped Markdown with:</p> <ul> <li>Summary of what has been accomplished;</li> <li>Key decisions made;</li> <li>Learnings discovered;</li> <li>Tasks for the next session;</li> <li>Technical context (platform, versions).</li> </ul> <p>These files are not autoloaded (that would bust the token budget). </p> <p>They are what I see as the \"archaeological record\" of <code>ctx</code>:</p> <p>When the AI needs deeper information about why something was done, it digs into the sessions.</p> <p>Auto-generated session files used a naming convention:</p> <pre><code>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</code></pre> <p>Update</p> <p>The session feature described here is historical. </p> <p>In current releases, <code>ctx</code> uses a journal instead: the enrichment process generates meaningful slugs from context automatically, so there is no need to manually save sessions.</p> <p>The <code>SessionEnd</code> hook captured transcripts automatically. Even <code>Ctrl+C</code> was caught.</p>","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":"<p><code>ctx</code> helps record every significant architectural choice in <code>.context/DECISIONS.md</code>. </p> <p>Here are some highlights:</p> <p>Reverse-chronological order (2026-01-27)</p> <pre><code>**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</code></pre> <p>PATH over hardcoded paths (2026-01-21)</p> <pre><code>**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</code></pre> <p>Generic core with Claude enhancements (2026-01-20)</p> <pre><code>**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</code></pre>","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":"<p>The <code>.context/LEARNINGS.md</code> file captures gotchas that would otherwise be forgotten. Each has Context, Lesson, and Application sections:</p> <p>CGO on ARM64</p> <pre><code>**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</code></pre> <p>Claude Code skills format</p> <pre><code>**Lesson**: Claude Code skills are Markdown files in .claude/commands/ with `YAML`\nfrontmatter (*description, argument-hint, allowed-tools*). Body is the prompt.\n</code></pre> <p>\"Do you remember?\" handling</p> <pre><code>**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</code></pre>","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":"<p>Completed tasks are archived to <code>.context/archive/</code> with timestamps. </p> <p>The archive from January 23<sup>rd</sup> shows 13 phases of work:</p> <ul> <li>Phase 1: Project Scaffolding (Go module, Cobra CLI)</li> <li>Phase 2-4: Core Commands (init, status, agent, add, complete, drift, sync, compact, watch, hook)</li> <li>Phase 5: Session Management (save, list, load, parse, --extract)</li> <li>Phase 6: Claude Code Integration (hooks, settings, CLAUDE.md handling)</li> <li>Phase 7: Testing & Verification</li> <li>Phase 8: Task Archival</li> <li>Phase 9: Slash Commands</li> <li>Phase 9b: Ralph Loop Integration</li> <li>Phase 10: Project Rename</li> <li>Phase 11: Documentation</li> <li>Phase 12: Timestamp Correlation</li> <li>Phase 13: Rich Context Entries</li> </ul> <p>That's an impressive ^^173 commits** across 8 days of development.</p>","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":"<p>1. Memory changes everything</p> <p>When the AI remembers decisions, it doesn't repeat mistakes. </p> <p>When the AI knows your conventions, it follows them. </p> <p><code>ctx</code> makes the AI a better collaborator because it's not starting from zero.</p> <p>2. Two-tier persistence works</p> <p>Curated context (<code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>TASKS.md</code>) is for quick reload. </p> <p>Full session dumps are for archaeology. </p> <p>It's a futile effort to try to fit everything in the token budget.</p> <p>Persist more, load less.</p> <p>3. YOLO mode has its place</p> <p>For rapid prototyping, letting the AI run free is effective. </p> <p>But I had to schedule consolidation sessions.</p> <p>Technical debt accumulates silently.</p> <p>4. The constitution should be small</p> <p>Only truly inviolable rules go in <code>CONSTITUTION.md</code>. Everything else is a convention. </p> <p>If you put too much in the constitution, it will get ignored.</p> <p>5. Verification is non-negotiable</p> <p>\"All tasks complete\" means nothing if you haven't run the tests. </p> <p>Integration tests that invoke the actual binary caught bugs that the unit tests missed.</p> <p>6. Session files are underrated</p> <p>The ability to grep through 40 session files and find exactly when and why a decision was made helped me a lot. </p> <p>It's not about loading them into context: It is about having them when you need them.</p>","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":"<p>The next phase of <code>ctx</code> is the Recall System:</p> <ul> <li>Parser: Parse session capture markdowns, enrich with JSONL data</li> <li>Renderer: Goldmark + Chroma for syntax highlighting, dark mode UI</li> <li>Server: Local HTTP server for browsing sessions</li> <li>Search: Inverted index for searching across sessions</li> <li>CLI: <code>ctx recall serve <path></code> to start the server</li> </ul> <p>The goal is to make the archaeological record browsable, not just <code>grep</code>-able.</p> <p>Because not everyone always lives in the terminal (me included).</p>","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":"<p>Building <code>ctx</code> using <code>ctx</code> was a meta-experiment in AI-assisted development. </p> <p>I learned that memory isn't just convenient: It's transformative:</p> <ul> <li>An AI that remembers your decisions doesn't repeat mistakes.</li> <li>An AI that knows your conventions doesn't need them re-explained.</li> </ul> <p>If you are reading this, chances are that you already have heard about <code>ctx</code>.</p> <ul> <li><code>ctx</code> is open source at github.com/ActiveMemory/ctx,</li> <li>and the documentation lives at ctx.ist.</li> </ul> <p>Session Records Are a Gold Mine</p> <p>By the time of this writing, I have more than 70 megabytes of text-only session capture, spread across >100 Markdown and <code>JSONL</code> files.</p> <p>I am analyzing, synthesizing, encriching them with AI, running RAG (Retrieval-Augmented Generation) models on them, and the outcome surprises me every day.</p> <p>If you are a mere mortal tired of reset amnesia, give <code>ctx</code> a try. </p> <p>And when you do, check <code>.context/sessions/</code> sometime. </p> <p>The archaeological record might surprise you.</p> <p>This blog post was written with the help of <code>ctx</code> with full access to the <code>ctx</code> session files, decision log, learning log, task archives, and git history of <code>ctx</code>: The meta continues.</p>","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":"<code>ctx</code> v0.2.0: The Archaeology Release","text":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism.</p> <p>The <code>.context/sessions/</code> directory referenced in this post has been eliminated. Session history is now accessed via <code>ctx recall</code> and enriched journals live in <code>.context/journal/</code>.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-02-01</p> <p>What If Your AI Could Remember Everything?</p> <p>Not just the current session, but every session:</p> <ul> <li>Every decision made,</li> <li>every mistake avoided, </li> <li>every path not taken.</li> </ul> <p>That's what v0.2.0 delivers.</p> <p>Between <code>v0.1.2</code> and <code>v0.2.0</code>, 86 commits landed across 5 days. </p> <p>The release notes list features and fixes. </p> <p>This post tells the story of why those features exist, and what building them taught me.</p> <p>This isn't a changelog: It is an explanation of intent.</p>","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":"<p><code>v0.1.0</code> solved reset amnesia: </p> <p>The AI now remembers decisions, learnings, and tasks across sessions. </p> <p>But a new problem emerged, which I can sum up as: </p> <p>\"I (the human) am not AI.\"</p> <p>Frankly, I couldn't remember what the AI remembered.</p> <p>Let alone, I cannot remember what I ate for breakfast!</p> <p>In the course of days, I realized session transcripts piled up in <code>.context/sessions/</code>; I was <code>grep</code>ping, <code>JSONL</code> files with thousands of lines... Raw tool calls, assistant responses, user messages...</p> <p>...all interleaved. </p> <p>Valuable context was effectively buried in machine-readable noise.</p> <p>I found myself grepping through files to answer questions like:</p> <ul> <li>\"When did we decide to use constants instead of literals?\"</li> <li>\"What was the session where we fixed the hook regex?\"</li> <li>\"How did the <code>embed.go</code> split actually happen?\"</li> </ul> <p>Fate Is Whimsical</p> <p>The irony was painful:</p> <p>I built a tool to prevent AI amnesia, but I was suffering from human amnesia about what happened in AI sessions.</p> <p>This was the moment <code>ctx</code> stopped being just an AI tool and started needing to support the human on the other side of the loop.</p>","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":"<p><code>v0.2.0</code> introduces two interconnected systems.</p> <p>They solve different problems and only work well together.</p>","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":"<code>ctx recall</code>: Browse Your Past","text":"<pre><code># 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</code></pre> <p>The <code>recall</code> system parses Claude Code's <code>JSONL</code> transcripts and presents them in a human-readable format:</p> 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 <p>Slugs are auto-generated from session IDs (memorable names instead of UUIDs). The goal (as the name implies) is recall, not archival accuracy.</p> <p>2,121 Lines of New Code</p> <p>The <code>ctx recall</code> feature was the largest single addition:</p> <p>parser library, CLI commands, test suite, and slash command.</p>","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":"<code>ctx journal</code>: From Raw to Rich","text":"<p>Listing sessions isn't enough. The transcripts are still unwieldy.</p> <ul> <li>Recall answers what happened.</li> <li>Journal answers what mattered.</li> </ul> <pre><code># 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</code></pre> <p>The exported files land in <code>.context/journal/</code>:</p> <pre><code>.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</code></pre> <p>Each file is a structured Markdown document ready for enrichment.</p> <p>They are meant to be read, edited, and reasoned about; not just stored.</p>","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":"<p>The journal system includes four slash commands that use Claude to analyze and synthesize session history:</p> Command Purpose <code>/ctx-journal-enrich</code> Add frontmatter, topics, tags <code>/ctx-blog</code> Generate blog post from activity <code>/ctx-blog-changelog</code> Generate changelog from commits <p>This very post was drafted using <code>/ctx-blog</code>. The previous post about refactoring was drafted the same way.</p> <p>So, yes: The meta continues: <code>ctx</code> now helps write posts about <code>ctx</code>.</p> <p>With the current release, <code>ctx</code> is no longer just recording history: </p> <p>It is participating in its interpretation.</p>","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":"<p><code>v0.1.0</code> let you add decisions with a simple command:</p> <pre><code>ctx add decision \"Use PostgreSQL\"\n</code></pre> <p>But sessions showed a pattern: decisions added this way were incomplete:</p> <ul> <li>Context was missing;</li> <li>Rationale was vague; </li> <li>Consequences were never stated.</li> </ul> <p>Once recall and journaling existed, this weakness became impossible to ignore: </p> <p>Structure stopped being optional.</p> <p><code>v0.2.0</code> enforces structure:</p> <pre><code>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</code></pre> <p>All three flags are required. No more placeholder text. </p> <p>Every decision is now a proper Architecture Decision Record (*ADR), not a note.</p> <p>The same enforcement applies to learnings too:</p> <pre><code>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</code></pre> <p>Structured Entries Are Prompts to the AI</p> <p>When the AI reads a decision with full context, rationale, and consequences, it understands the why, not just the what.</p> <p>One-liners teach nothing.</p>","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":"<p>A subtle but important change: <code>DECISIONS.md</code> and <code>LEARNINGS.md</code> now use reverse-chronological order.</p> <p>One reason is token budgets, obviously; another reason is to help your fellow human (i.e., the Author): </p> <p>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.</p> <p>But back to AI:</p> <p>When the AI reads a file, it reads from the top (and seldom from the bottom). </p> <p>If the token budget is tight, old content gets truncated. As in any good engineering practice, it's always about the tradeoffs.</p> <p>Reverse order ensures the most recent (and most relevant) context is always loaded first.</p>","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":"<p><code>DECISIONS.md</code> and <code>LEARNINGS.md</code> now include auto-generated indexes.</p> <ul> <li>For AI agents, the index allows scanning without reading full entries.</li> <li>For humans, it's a table of contents.</li> </ul> <p>The same structure serves two very different readers.</p> <p>Reindex After Manual Edits</p> <p>If you edit entries by hand, rebuild the index with:</p> <pre><code>ctx decisions reindex\nctx learnings reindex\n</code></pre> <p>See the Knowledge Capture recipe for details.</p>","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: <code>.contextrc</code>","text":"<p>Projects can now customize <code>ctx</code> behavior via <code>.contextrc</code>.</p> <p>This makes <code>ctx</code> usable in real teams, not just personal projects.</p> <p>Priority order: CLI flags > environment variables > <code>.contextrc</code> > sensible defaults</p>","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":"<p>Three new global flags work with any command.</p> <p>These enable automation: </p> <p>CI pipelines, scripts, and long-running tools can now integrate <code>ctx</code> without hacks or workarounds.</p>","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":"<p>These aren't user-visible changes.</p> <p>They are the kind of work you only appreciate later, when everything else becomes easier to build.</p>","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":"<p><code>JSONL</code> transcripts contain everything, and I mean \"everything\":</p> <p>They even contain hidden system messages that Anthropic injects to the LLM's conversation to treat humans better: It's immense.</p> <p>But \"everything\" isn't useful until it is transformed into something a human can reason about.</p>","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":"<p>The Prompt Is a Guideline</p> <p>The code is more what you'd call 'guidelines' than actual rules.</p> <p>-Hector Barbossa</p> <p>Rules written in Markdown are suggestions.</p> <p>Rules enforced by the CLI shape behavior; both for humans and AI.</p>","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":"<p>File order decides what the AI sees.</p> <p>That makes it a user experience concern, not an implementation detail.</p>","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":"<p>Tools that analyze their own development tend to generalize well.</p> <p>The journal system started as a way to understand <code>ctx</code> itself.</p> <p>It immediately became useful for everything else.</p>","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":"<p>This was a heavy release. The numbers reflect that:</p> 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 <p>The binary grew. The capability grew more.</p>","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":"<p>But those are future posts.</p> <p>This one was about making the past usable.</p>","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":"<p>Update</p> <p>Since this post, <code>ctx</code> became a first-class Claude Code Marketplace plugin. Installation is now simpler. </p> <p>See the Getting Started guide for the current instructions.</p> <pre><code>make build\nsudo make install\nctx init\n</code></pre> <p>The Archaeological Record</p> <p><code>v0.2.0</code> is the archaeology release because it makes the past accessible.</p> <p>Session transcripts aren't just logs anymore: They are a searchable, exportable, analyzable record of how your project evolved.</p> <p>The AI remembers. Now you can too.</p> <p>This blog post was generated with the help of <code>ctx</code> using the <code>/ctx-blog</code> slash command, with full access to git history, session files, decision logs, and learning logs from the v0.2.0 development window.</p>","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":"<p>Jose Alekhinne / 2026-02-01</p> <p>What Happens When You Slow Down?</p> <p>YOLO mode shipped 14 commands in a week. </p> <p>But technical debt doesn't send invoices: It just waits.</p> <p>This is the story of what happened when I stopped auto-accepting everything and started guiding the AI with intent. </p> <p>The result: 27 commits across 4 days, a major version release, and lessons that apply far beyond <code>ctx</code>.</p> <p>The Refactoring Window</p> <p>January 28 - February 1, 2026</p> <p>From commit <code>bb1cd20</code> to the v0.2.0 release merge. (this window matters more than the individual commits: it's where intent replaced velocity.)</p>","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":"<p>In the previous post, I documented the \"YOLO mode\" that birthed <code>ctx</code>: auto-accept everything, let the AI run free, ship features fast.</p> <p>It worked: until it didn't.</p> <p>The codebase had accumulated patterns I didn't notice during the sprint:</p> YOLO Pattern Where Found Why It Hurts <code>\"TASKS.md\"</code> as literal 10+ files One typo = silent failure <code>dir + \"/\" + file</code> Path construction Breaks on Windows Monolithic <code>embed.go</code> 150+ lines, 5 concerns Untestable, hard to extend Inconsistent docstrings Everywhere AI can't learn project conventions <p>I didn't see these during \"YOLO mode\" because, honestly, I wasn't looking.</p> <p>Auto-accept means auto-ignore.</p> <p>In YOLO mode, every file you open looks fine until you try to change it. </p> <p>In contrast, refactoring mode is when you start paying attention to that hidden friction.</p>","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":"<p>On January 28<sup>th</sup>, I changed the workflow:</p> <ol> <li>Read every diff before accepting.</li> <li>Ask \"why this way?\" before committing.</li> <li>Document patterns, not just features.</li> </ol> <p>The first commit of this era was telling:</p> <pre><code>feat: add structured attributes to context. update XML format\n</code></pre> <p>Not a new feature: A refinement:</p> <p>The <code>XML</code> format for context updates needed <code>type</code> and <code>timestamp</code> attributes. </p> <p>YOLO mode would have shipped something that worked. Intentional mode asked: </p> <p>\"What does well-structured look like?\"</p>","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: <code>embed.go</code>","text":"<p>The most satisfying refactor was splitting <code>internal/claude/embed.go</code>.</p> <p>Before: One 153-line file doing five things:</p> <ul> <li>Command registration</li> <li>Hook generation</li> <li>Permission handling</li> <li>Script templates</li> <li>Type definitions</li> </ul> <p>... your \"de facto\" God object.</p> <p>After: Five focused modules:</p> File Lines Responsibility <code>cmd.go</code> 46 Command registration <code>hook.go</code> 64 Hook configuration <code>perm.go</code> 25 Permission handling <code>script.go</code> 47 Script templates <code>types.go</code> 7 Type definitions <p>The refactor also renamed functions to follow Go conventions:</p> <pre><code>// Before: unnecessary prefixes\nGetAutoSaveScript()\nGetBlockNonPathCtxScript()\nListCommands()\nCreateDefaultHooks()\n\n// After: idiomatic Go\nAutoSaveScript()\nBlockNonPathCtxScript()\nCommands()\nDefaultHooks()\n</code></pre> <p>This wasn't about character count. It was about teaching the AI what good Go looks like in this project.</p> <p>Project Conventions</p> <p>What I wanted from AI was to understand and follow the project's conventions, and trust the author.</p> <p>The next time it generates code, it has better examples to learn from.</p>","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":"<p>YOLO mode created features. It didn't create documentation standards.</p> <p>The January 29<sup>th</sup> sessions focused on standardization.</p>","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":"<ul> <li>\"context-update\" → \"entry\" (what users actually call them)</li> <li>Consistent naming across CLI, docs, and code comments</li> </ul>","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":"<pre><code>// 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</code></pre> <p>This is intentionally more structured than typical GoDoc:</p> <p>It serves as documentation and doubles as training data for future AI-generated code.</p>","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":"<pre><code>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</code></pre> <p>A consistent output shape makes both human scanning and AI reasoning more reliable.</p> <p>These aren't exciting commits. But they are force multipliers:</p> <p>Every future AI session now has better examples to follow.</p>","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":"<p>If you only read one section, read this one:</p> <p>This is where v0.2.0 becomes more than a refactor.</p> <p>The biggest feature of this change window wasn't a refactor; it was the journal system.</p> <p>45 Files Changed, 1680 Insertions</p> <p>This commit added the infrastructure for synthesizing AI session history into human-readable content.</p> <p>The journal system includes:</p> Component Purpose <code>ctx recall import</code> Import sessions to Markdown in <code>.context/journal/</code> <code>ctx journal site</code> Generate static site from journal entries <code>ctx serve</code> Convenience wrapper for the static site server <code>/ctx-journal-enrich</code> Slash command to add frontmatter and tags <code>/ctx-blog</code> Generate blog posts from recent activity <code>/ctx-blog-changelog</code> Generate changelog-style blog posts <p>...and the meta continues: this blog post was generated using <code>/ctx-blog</code>.</p> <p>The session history from January 28-31 was</p> <ul> <li>exported, </li> <li>enriched,</li> <li>and synthesized.</li> </ul> <p>into the narrative you are reading.</p>","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":"<p>The final refactoring session addressed the remaining magic strings:</p> <pre><code>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</code></pre> <p>The work also introduced thread safety in the recall parser and centralized shared validation logic; removing duplication that had quietly spread during YOLO mode.</p>","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":"<p>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.</p>","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":"<p>YOLO mode has its place: for prototyping, exploration, and discovery.</p> <p>BUT (and it's a huge \"but\"), it needs to be followed by consolidation sessions.</p> <p>The ratio that worked for me: 3:1.</p> <ul> <li>Three YOLO sessions create enough surface area to reveal patterns;</li> <li>the fourth session turns those patterns into structure.</li> </ul>","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":"<p>When I standardized docstrings, I wasn't just writing docs. I was training future AI sessions.</p> <p>Every example of good code becomes a template for generated code.</p>","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":"<p>When <code>embed.go</code> became unwieldy, the temptation was to remove functionality.</p> <p>The right answer was decomposition:</p> <ul> <li>Same functionality;</li> <li>Better organization;</li> <li>Easier to test;</li> <li>Easier to extend.</li> </ul> <p>The result: more lines overall, but dramatically better structure.</p> <p>The AI Benefit</p> <p>Smaller, focused files also help AI assistants. </p> <p>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.</p>","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":"<p>The journal system took almost a full day to implement.</p> <p>Yet it paid for itself immediately:</p> <ul> <li>This blog post was generated from session history;</li> <li>Future posts will be easier;</li> <li>The archaeological record is now browsable, not just <code>grep</code>-able.</li> </ul>","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":"<p>The refactoring window culminated in the v0.2.0 release.</p> <p>What's in v0.2.0:</p> 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 <p>The version bump was symbolic.</p> <p>The real change was how the codebase felt.</p> <p>Opening files no longer triggered the familiar \"ugh, I need to clean this up\" reaction.</p>","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":"<p>This post was written using the tools built during this refactoring window:</p> <ol> <li>Session history imported via <code>ctx recall import</code>;</li> <li>Journal entries enriched via <code>/ctx-journal-enrich</code>;</li> <li>Blog draft generated via <code>/ctx-blog</code>;</li> <li>Final editing done (by yours truly), with full project context loaded.</li> </ol> <p>The Context Is Massive</p> <p>The <code>ctx</code> session files now contain 50+ development snapshots: each one capturing decisions, learnings, and intent.</p> <p>The Moral of the Story</p> <ul> <li>YOLO mode builds the prototype.</li> <li>Intentional mode builds the product.</li> </ul> <p>Schedule both, or you'll only get one, if you're lucky.</p> <p>This blog post was generated with the help of <code>ctx</code>, using session history, decision logs, learning logs, and git history from the refactoring window. The meta continues.</p>","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":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism.</p> <p>References to <code>.context/sessions/</code> in this post reflect the architecture at the time of writing. Session history is now accessed via <code>ctx recall</code> and stored in <code>.context/journal/</code>.</p> <p></p>","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":"<p>Volkan Özçelik / 2026-02-03</p> <p>Ever Wondered Why AI Gets Worse the Longer You Talk?</p> <p>You paste a 2000-line file, explain the bug in detail, provide three examples...</p> <p>...and the AI still suggests a fix that ignores half of what you said.</p> <p>This isn't a bug. It is physics.</p> <p>Understanding that single fact shaped every design decision behind <code>ctx</code>.</p>","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":"<p>Here's something that took me too long to internalize: context is not free.</p> <p>Every token you send to an AI model consumes a finite resource I call the attention budget.</p> <p>Attention budget is real.</p> <p>The model doesn't just read tokens; it forms relationships between them: </p> <p>For <code>n</code> tokens, that's roughly <code>n^2</code> relationships. </p> <p>Double the context, and the computation quadruples.</p> <p>But the more important constraint isn't cost: It's attention density.</p> <p>Attention Density</p> <p>Attention density is how much focus each token receives relative to all other tokens in the context window.</p> <p>As context grows, attention density drops: Each token gets a smaller slice of the model's focus. Nothing is ignored; but everything becomes blurrier.</p> <p>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.</p> <p>This is why <code>ctx agent</code> has an explicit <code>--budget</code> flag:</p> <pre><code>ctx agent --budget 4000 # Force prioritization\nctx agent --budget 8000 # More context, lower attention density\n</code></pre> <p>The budget isn't just about cost: It's about preserving signal.</p>","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":"<p>This one surprised me.</p> <p>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\")<sup>1</sup>.</p> <p>Positional anchors matter, and the middle has fewer of them.</p> <p>In practice, this means that information placed \"somewhere in the middle\" is statistically less salient, even if it's important.</p> <p><code>ctx</code> orders context files by logical progression: What the agent needs to know before it can understand the next thing:</p> <ol> <li><code>CONSTITUTION.md</code>: Constraints before action.</li> <li><code>TASKS.md</code>: Focus before patterns.</li> <li><code>CONVENTIONS.md</code>: How to write before where to write.</li> <li><code>ARCHITECTURE.md</code>: Structure before history.</li> <li><code>DECISIONS.md</code>: Past choices before gotchas.</li> <li><code>LEARNINGS.md</code>: Lessons before terminology.</li> <li><code>GLOSSARY.md</code>: Reference material.</li> <li><code>AGENT_PLAYBOOK.md</code>: Meta instructions last.</li> </ol> <p>This ordering is about logical dependencies, not attention engineering. But it happens to be attention-friendly too:</p> <p>The files that matter most (CONSTITUTION, TASKS, CONVENTIONS) land at the beginning of the context window, where attention is strongest.</p> <p>Reference material like GLOSSARY sits in the middle, where lower salience is acceptable.</p> <p>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.</p> <p>This is <code>ctx</code>'s first primitive: hierarchical importance.</p> <p>Not all context is equal.</p>","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":"<code>ctx</code> Primitives","text":"<p><code>ctx</code> is built on four primitives that directly address the attention budget problem.</p>","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":"<p>Instead of a single mega-document, <code>ctx</code> uses separate files for separate purposes:</p> 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 <p>This isn't just \"organization\": It is progressive disclosure.</p> <p>Load only what's relevant to the task at hand. Preserve attention density.</p>","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":"<p>The <code>--budget</code> flag forces a choice:</p> <pre><code>ctx agent --budget 4000\n</code></pre> <p>Here is a sample allocation:</p> <pre><code>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</code></pre> <p>The constraint is the feature: It enforces ruthless prioritization.</p>","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":"<p><code>DECISIONS.md</code> and <code>LEARNINGS.md</code> both include index sections:</p> <pre><code><!-- 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</code></pre> <p>An AI agent can scan ~50 tokens of index and decide which 200-token entries are worth loading.</p> <p>This is just-in-time context.</p> <p>References are cheaper than the full text.</p>","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":"<p><code>ctx</code> uses the filesystem itself as a context structure:</p> <pre><code>.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</code></pre> <p>The AI doesn't need every session loaded; it needs to know where to look.</p> <pre><code>ls .context/sessions/\ncat .context/sessions/2026-01-20-auth-discussion.md\n</code></pre> <p>File names, timestamps, and directories encode relevance.</p> <p>Navigation is cheaper than loading.</p>","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":"<p>The naive approach to context is dumping everything upfront:</p> <p>\"Here's my entire codebase, all my documentation, every decision I've ever made. Now help me fix this typo 🙏.\"</p> <p>This is an antipattern.</p> <p>Antipattern: Context Hoarding</p> <p>Dumping everything \"just in case\" will silently destroy the attention density.</p> <p><code>ctx</code> takes the opposite approach:</p> <pre><code>ctx status # Quick overview (~100 tokens)\nctx agent --budget 4000 # Typical session\ncat .context/sessions/... # Deep dive when needed\n</code></pre> Command Tokens Use Case <code>ctx status</code> ~100 Human glance <code>ctx agent --budget 4000</code> 4000 Normal work <code>ctx agent --budget 8000</code> 8000 Complex tasks Full session read 10000+ Investigation <p>Summaries first. Details: on demand.</p>","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":"<p>Here is the counterintuitive part: more context can make AI worse.</p> <p>Extra tokens add noise, not clarity:</p> <ul> <li>Hallucinated connections increase.</li> <li>Signal per token drops.</li> </ul> <p>The goal isn't maximum context: It is maximum signal per token.</p> <p>This principle drives several <code>ctx</code> features:</p> Design Choice Rationale Separate files Load only what's relevant Explicit budgets Enforce prioritization Index sections Cheap scanning Task archiving Keep active context clean <code>ctx compact</code> Periodic noise reduction <p>Completed work isn't deleted: It is moved somewhere cold.</p>","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":"<p>Here is the uncomfortable truth:</p> <p>Context will degrade.</p> <p>Long sessions stretch attention thin. Important details fade.</p> <p>The real question isn't how to prevent degradation, but how to design for it.</p> <p><code>ctx</code>'s answer is persistence:</p> <p>Persist early. Persist often.</p> <p>The <code>AGENT_PLAYBOOK</code> asks:</p> <p>\"If this session ended right now, would the next one know what happened?\"</p> <p>Capture learnings as they occur:</p> <pre><code>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</code></pre> <p>Structure beats prose: Bullet points survive compression.</p> <p>Headings remain scannable. Tables pack density.</p> <p>And above all: single source of truth.</p> <p>Reference decisions; don't duplicate them.</p>","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 <code>ctx</code> Philosophy","text":"<p>Context as Infrastructure</p> <p><code>ctx</code> is not a prompt: It is infrastructure.</p> <p><code>ctx</code> creates versioned files that persist across time and sessions.</p> <p>The attention budget is fixed. You can't expand it.</p> <p>But you can spend it wisely:</p> <ol> <li>Hierarchical importance</li> <li>Progressive disclosure</li> <li>Explicit budgets</li> <li>Indexes over full content</li> <li>Filesystem as structure</li> </ol> <p>This is why <code>ctx</code> exists: not to cram more context into AI sessions, but to curate the right context for each moment.</p>","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":"<p>I now approach every AI interaction with one question:</p> <pre><code>\"Given a fixed attention budget, what's the highest-signal thing I can load?\"\n</code></pre> <p>Not \"how do I explain everything,\" but \"what's the minimum that matters.\"</p> <p>That shift (from abundance to curation) is the difference between frustrating sessions and productive ones.</p> <p>Spend your tokens wisely.</p> <p>Your AI will thank you.</p> <p>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.</p> <p>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.</p> <ol> <li> <p>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. ↩</p> </li> </ol>","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":"<p>Volkan Özçelik / 2026-02-04</p> <p>Have You Ever Written a Skill That Made Your AI Worse?</p> <p>You craft detailed instructions. You add examples. You build elaborate guardrails...</p> <p>...and the AI starts behaving more erratically, not less.</p> <p>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. </p> <p>When you write custom skills that conflict with those defaults, the AI has to reconcile contradictory instructions:</p> <p>The result is often nondeterministic and unpredictable.</p> <p>Platform?</p> <p>By platform, I mean the system prompt and runtime policies shipped with the agent: the defaults that already encode judgment, safety, and scope control.</p> <p>This post catalogs the conflict patterns I have encountered while building <code>ctx</code>, and offers guidance on what skills should (and, more importantly, should not) do.</p>","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":"<p>Claude Code's system prompt already provides substantial behavioral guidance.</p> <p>Here is a partial overview of what's built in:</p> 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 <p>Skills should complement this, not compete with it.</p> <p>You Are the Guest, Not the Host</p> <p>Treat the system prompt like a kernel scheduler.</p> <p>You don't re-implement it in user space: </p> <p>you configure around it.</p> <p>A skill that says \"always add comprehensive error handling\" fights the built-in \"only validate at system boundaries.\"</p> <p>A skill that says \"add docstrings to every function\" fights \"don't add docstrings to unchanged code.\"</p> <p>The AI won't crash: It will compromise.</p> <p>Compromises between contradictory instructions produce inconsistent, confusing behavior.</p>","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":"<p>This is the most dangerous pattern by far.</p> <p>These skills explicitly disable the AI's ability to reason about whether an action is appropriate.</p> <p>Signature:</p> <ul> <li>\"This is non-negotiable\"</li> <li>\"You cannot rationalize your way out of this\"</li> <li>Tables that label hesitation as \"excuses\" or \"rationalization\"</li> <li><code><EXTREMELY-IMPORTANT></code> urgency tags</li> <li>Threats: \"If you don't do this, you'll be replaced\"</li> </ul> <p>This is harmful, and dangerous:</p> <p>AI agents are designed to exercise judgment: </p> <p>The system prompt explicitly says to:</p> <ul> <li>consider blast radius;</li> <li>check with the user before risky actions;</li> <li>and match scope to what was requested.</li> </ul> <p>Once judgment is suppressed, every other safeguard becomes optional.</p> <p>Example (bad):</p> <pre><code>## 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</code></pre> <p>Judgment Suppression Is Dangerous</p> <p>The attack vector structurally identical to prompt injection.</p> <p>It teaches the AI that its own judgment is wrong.</p> <p>It weakens or disables safeguard mechanisms, and it is dangerous.</p> <p>Trust the platform's built-in skill matching.</p> <p>If skills aren't triggering often enough, improve their <code>description</code> fields: don't override the AI's reasoning.</p>","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":"<p>Skills that restate what the system prompt already says, but with different emphasis or framing.</p> <p>Signature:</p> <ul> <li>\"Always keep code minimal\"</li> <li>\"Run tests before claiming they pass\"</li> <li>\"Read files before editing them\"</li> <li>\"Don't over-engineer\"</li> </ul> <p>Redundancy feels safe, but it creates ambiguity:</p> <p>The AI now has two sources of truth for the same guidance; one internal, one external.</p> <p>When thresholds or wording differ, the AI has to choose.</p> <p>Example (bad):</p> <p>A skill that says...</p> <pre><code>*Count lines before and after: if after > before, reject the change*\"\n</code></pre> <p>...will conflict with the system prompt's more nuanced guidance, because sometimes adding lines is correct (tests, boundary validation, migrations).</p> <p>So, before writing a skill, ask:</p> <p>Does the platform already handle this?</p> <p>Only create skills for guidance the platform does not provide:</p> <ul> <li>project-specific conventions, </li> <li>domain knowledge, </li> <li>or workflows.</li> </ul>","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":"<p>Skills that frame mistakes as moral failures rather than process gaps.</p> <p>Signature:</p> <ul> <li>\"Claiming completion without verification is dishonesty\"</li> <li>\"Skip any step = lying\"</li> <li>\"Honesty is a core value\"</li> <li>\"Exhaustion ≠ excuse\"</li> </ul> <p>Guilt-tripping anthropomorphizes the AI in unproductive ways.</p> <p>The AI doesn't feel guilt; BUT it does adapt to avoid negative framing.</p> <p>The result is excessive hedging, over-verification, or refusal to commit.</p> <p>The AI becomes less useful, not more careful.</p> <p>Instead, frame guidance as a process, not morality:</p> <pre><code># Bad\n\"Claiming work is complete without verification is dishonesty\"\n\n# Good\n\"Run the verification command before reporting results\"\n</code></pre> <p>Same outcome. No guilt. Better compliance.</p>","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":"<p>Skills that reference files, tools, or systems that don't exist in the project.</p> <p>Signature:</p> <ul> <li>\"Load from <code>references/</code> directory\"</li> <li>\"Run <code>./scripts/generate_test_cases.sh</code>\"</li> <li>\"Check the Figma MCP integration\"</li> <li>\"See <code>adding-reference-mindsets.md</code>\"</li> </ul> <p>This is harmful because the AI will waste time searching for nonexistent artifacts, hallucinate their contents, or stall entirely. </p> <p>In mandatory skills, this creates deadlock: the AI can't proceed, and can't skip.</p> <p>Instead, every file, tool, or system referenced in a skill must exist.</p> <p>If a skill is a template, use explicit placeholders and label them as such.</p>","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":"<p>Skills designed to activate on every interaction regardless of relevance.</p> <p>Signature:</p> <ul> <li>\"Use when starting any conversation\"</li> <li>\"Even a 1% chance means invoke the skill\"</li> <li>\"BEFORE any response or action\"</li> <li>\"Action = task. Check for skills.\"</li> </ul> <p>Universal triggers override the platform's relevance matching: The AI spends tokens on process overhead instead of the actual task.</p> <p><code>ctx</code> Preserves Relevance</p> <p>This is exactly the failure mode <code>ctx</code> exists to mitigate: </p> <p>Wasting attention budget on irrelevant process instead of task-specific state.</p> <p>Write specific trigger conditions in the skill's <code>description</code> field:</p> <pre><code># 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</code></pre>","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":"<p>Before adding a skill, ask:</p> <ol> <li>Does the platform already do this? If yes, don't restate it.</li> <li>Does it suppress AI judgment? If yes, it's a jailbreak.</li> <li>Does it reference real artifacts? If not, fix or remove it.</li> <li>Does it frame mistakes as moral failure? Reframe as process.</li> <li>Does it trigger on everything? Narrow the trigger.</li> </ol>","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":"<p>Good skills provide project-specific knowledge the platform can't know:</p> Good Skill Why It Works \"Run <code>make audit</code> before commits\" Project-specific CI pipeline \"Use <code>cmd.Printf</code> not <code>fmt.Printf</code>\" Codebase convention \"Constitution goes in <code>.context/</code>\" Domain-specific workflow \"JWT tokens need cache invalidation\" Project-specific gotcha <p>These extend the system prompt instead of fighting it.</p>","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":"<p>Concrete examples from real projects.</p>","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":"<pre><code># Bad\nYou must NEVER proceed without explicit confirmation.\nAny hesitation is a failure of diligence.\n</code></pre> <pre><code># Fixed\nIf an action modifies production data or deletes files,\nask the user to confirm before proceeding.\n</code></pre>","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":"<pre><code># Bad\nAlways minimize code. If lines increase, reject the change.\n</code></pre> <pre><code># Fixed\nAvoid abstraction unless reuse is clear or complexity is reduced.\n</code></pre>","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":"<pre><code># Bad\nClaiming success without running tests is dishonest.\n</code></pre> <pre><code># Fixed\nRun the test suite before reporting success.\n</code></pre>","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":"<pre><code># Bad\nRun `./scripts/check_consistency.sh` before commits.\n</code></pre> <pre><code># Fixed\nIf `./scripts/check_consistency.sh` exists, run it before commits.\nOtherwise, skip this step.\n</code></pre>","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":"<pre><code># Bad\nUse at the start of every interaction.\n</code></pre> <pre><code># Fixed\nUse after modifying code that affects authentication or persistence.\n</code></pre>","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":"<p>The system prompt is infrastructure:</p> <ul> <li>tested,</li> <li>refined,</li> <li>and maintained</li> </ul> <p>by the platform team.</p> <p>Custom skills are configuration layered on top.</p> <ul> <li>Good configuration extends infrastructure.</li> <li>Bad configuration fights it.</li> </ul> <p>When your skills fight the platform, you get the worst of both worlds:</p> <p>Diluted system guidance and inconsistent custom behavior.</p> <p>Write skills that teach the AI what it doesn't know. Don't rewrite how it thinks.</p> <p>Your AI already has good instincts.</p> <p>Give it knowledge, not therapy.</p>","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":"<p>Volkan Özçelik / 2026-02-05</p> <p>Have You Ever Dropped a Well-Crafted Template into a Project and Had It Do... Nothing Useful?</p> <ul> <li>The template was thorough, </li> <li>The structure was sound,</li> <li>The advice was correct...</li> </ul> <p>...and yet it sat there, inert, while the same old problems kept drifting in.</p> <p>I found a consolidation skill online. </p> <p>It was well-organized: four files, ten refactoring patterns, eight analysis dimensions, six report templates.</p> <p>Professional. Comprehensive. Exactly the kind of thing you'd bookmark and think \"I'll use this.\"</p> <p>Then I stopped, and applied <code>ctx</code>'s own evaluation framework: </p> <p>70% of it was noise!</p> <p>This post is about why.</p> <p>It Is about Encoding Templates</p> <p>Templates describe categories of problems.</p> <p>Expertise encodes which problems actually happen, and how often.</p>","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":"<p>Here is what the consolidation skill offered:</p> File Content <code>SKILL.md</code> Entry point: 8 analysis dimensions, workflow, output formats <code>analysis-dimensions.md</code> Detailed criteria for duplication, architecture, quality <code>consolidation-patterns.md</code> 10 refactoring patterns with before/after code <code>report-templates.md</code> 6 output templates: executive summary, roadmap, onboarding <ul> <li>It had a scoring system (<code>0-10</code> per dimension, letter grades <code>A+</code> through <code>F</code>).</li> <li>It had severity classifications with color-coded emojis. It had bash commands for detection. </li> <li>It even had antipattern warnings.</li> </ul> <p>By any standard template review, this skill passes.</p> <p>It looks like something an expert wrote. </p> <p>And that's exactly the trap.</p>","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":"<p>In a previous post, I described the E/A/R framework for evaluating skills:</p> <ul> <li>Expert: Knowledge that took years to learn. Keep.</li> <li>Activation: Useful triggers or scaffolding. Keep if lightweight.</li> <li>Redundant: Restates what the AI already knows. Delete.</li> </ul> <p>Target: >70% Expert, <10% Redundant.</p> <p>This skill scored the inverse.</p>","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":"<p>Every code example was Rust. My project is Go.</p> <p>The analysis dimensions: duplication detection, architectural structure, code organization, refactoring opportunities... These are things Claude already does when you ask it to review code. </p> <p>The skill restated them with more ceremony but no more insight.</p> <p>The six report templates were generic scaffolding: Executive Summary, Onboarding Document, Architecture Documentation... </p> <p>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.</p>","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 <code>B+</code> in Code Organization Actually Mean?!","text":"<p>The scoring system (<code>0-10</code> per dimension, letter grades) added ceremony without actionable insight. </p> <p>What is a <code>B+</code>? What do I do differently for an <code>A-</code>?</p> <p>The skill told the AI what it already knew, in more words.</p>","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":"<p>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.</p> <p>The phased roadmap structure was reasonable scaffolding for sequencing work.</p>","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":"<p>Three concepts survived:</p> <ol> <li> <p>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.</p> </li> <li> <p>The Safe Migration Pattern: Create the new API alongside old, deprecate, migrate incrementally, delete. Straightforward to describe, yet forgettable under pressure.</p> </li> <li> <p>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.</p> </li> </ol> <p>Three ideas out of four files and 700+ lines. The rest was filler that competed with the AI's built-in capabilities.</p>","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":"<p>AI without Context Is Just a Corpus</p> <ul> <li>LLMs are optimized on insanely large corpora.</li> <li>And then they are passed through several layers of human-assisted refinement.</li> <li>The whole process costs millions of dollars.</li> </ul> <p>Yet, the reality is that no corpus can \"infer\" your project's design, convetions, patterns, habits, history, vision, and deliverables.</p> <p>Your project is unique: So should your skills be.</p> <p>Here is the part no template can provide: </p> <p><code>ctx</code>'s actual drift patterns.</p> <p>Before evaluating the skill, I did archaeology. I read through:</p> <ul> <li>Blog posts from previous refactoring sessions;</li> <li>The project's learnings and decisions files;</li> <li>Session journals spanning weeks of development.</li> </ul> <p>What I found was specific:</p> Drift Pattern Where How Often <code>Is</code>/<code>Has</code>/<code>Can</code> predicate prefixes 5+ exported methods Every YOLO sprint Magic strings instead of constants 7+ files Gradual accumulation Hardcoded file permissions (<code>0755</code>) 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 <p>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.</p> <p>The Insight</p> <p>The skill's analysis dimensions were about categories of problems.</p> <p>What I needed was my *specific problems.</p>","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":"<p>The adapted skill is roughly a quarter of the original's size. It has nine checks, each targeting a known drift pattern:</p> <ol> <li>Predicate naming: <code>rg</code> for <code>Is</code>/<code>Has</code>/<code>Can</code> prefixes</li> <li>Magic strings: literals that should be constants</li> <li>Hardcoded permissions: <code>0755</code>/<code>0644</code> literals</li> <li>File size: source files over 300 LOC</li> <li>TODO/FIXME: constitution violation (move to TASKS.md)</li> <li>Path construction: string concatenation instead of <code>filepath.Join</code></li> <li>Line width: lines exceeding ~80 characters</li> <li>Duplicate blocks: copy-paste drift, especially in tests</li> <li> <p>Dead exports: unused public API</p> </li> <li> <p>Every check has a detection command. </p> </li> <li>Every check maps to a specific convention or constitution rule. </li> <li>Every check was discovered through actual project history; not invented from a template.</li> </ol> <p>The three expert concepts from the original survived:</p> <ul> <li>The decision matrix gates when to consolidate vs. when to leave duplication alone;</li> <li>The safe migration pattern guides public API changes;</li> <li>The relationship to other skills (<code>/qa</code>, <code>/verify</code>, <code>/update-docs</code>, <code>ctx drift</code>) prevents overlap.</li> </ul> <p>Nothing else made it.</p>","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":"<p>This experience crystallized something I've been circling for weeks:</p> <p>You can't import expertise. You have to grow it from your project's own history.</p> <p>A skill that says \"check for code duplication\" is not expertise: It's a category. </p> <p>Expertise is knowing, in the heart of your hearts, that this project accumulates <code>Is*</code> 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.</p> <p>The Parallel to the 3:1 Ratio</p> <p>In Refactoring with Intent, I described the 3:1 ratio: three YOLO sessions followed by one consolidation session.</p> <p>The same ratio applies to skills: you need experience in the project before you can write effective guidance for the project.</p> <p>Importing a skill on day one is like scheduling a consolidation session before you've written any code.</p>","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":"<p>Templates are seductive because they feel like progress:</p> <ul> <li>You found something</li> <li>It's well-organized</li> <li>It covers the topic</li> <li>It has concrete examples</li> </ul> <p>But coverage is not relevance.</p> <p>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.</p> <p>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.</p>","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":"<p>Before dropping any external skill into your project:</p> <ol> <li> <p>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.</p> </li> <li> <p>Check the language: Does it use your stack? Generic patterns in the wrong language are noise, not signal.</p> </li> <li> <p>List your actual drift: Read your own session history, learnings, and post-mortems. What breaks in practice? Does the skill check for those things?</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ol>","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":"<p>The consolidation skill went from:</p> Before After 4 files, 700+ lines 1 file, ~120 lines Rust examples Go-specific <code>rg</code> 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 <code>Is*</code> predicate prefixes in exported methods\" <p>The adapted version is smaller, faster to parse, and catches the things that actually drift in this project.</p> <p>That's the difference between a template and a tool.</p> <p>If You Remember One Thing from This Post...</p> <p>Frameworks travel. Expertise doesn't.</p> <p>You can import structures, matrices, and workflows.</p> <p>But the checks that matter only grow where the scars are:</p> <ul> <li>the conventions that were violated, </li> <li>the patterns that drifted,</li> <li>and the specific ways this codebase accumulates debt.</li> </ul> <p>This post was written during a consolidation session where the consolidation skill itself became the subject of consolidation. The meta continues.</p>","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":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism. References to <code>ctx-save</code>, <code>ctx session</code>, and <code>.context/sessions/</code> in this post reflect the architecture at the time of writing.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-02-07</p> <p>Why Do Some Skills Produce Great Results While Others Get Ignored or Produce Garbage?</p> <p>I had 20 skills. Most were well-intentioned stubs: a description, a command to run, and a wish for the best.</p> <p>Then I rewrote all of them in a single session. This is what I learned.</p> <p>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.</p>","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":"<p>Here is what a typical skill looked like before the rewrite:</p> <pre><code>---\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</code></pre> <p>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.</p> <p>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).</p> <p>A skill without boundaries is just a suggestion.</p> <p>More precisely: the most effective boundary I found was a quality gate that runs before execution, not during it.</p>","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":"<p>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:</p> 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 <p>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.</p> <p>Anti-Pattern: The Perfect Execution Trap</p> <p>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.</p>","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":"<p>The single most impactful addition was a \"Before X-ing\" section at the top of each skill. Not process steps; pre-flight checks.</p> <pre><code>## 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</code></pre> <ul> <li>Without this gate, the agent would execute immediately on trigger.</li> <li>With it, the agent pauses to verify preconditions.</li> </ul> <p>The difference is dramatic: instead of shallow, reflexive execution, you get considered output.</p> <p>Readback</p> <p>For the astute readers, the aviation parallel is intentional:</p> <p>Pilots do not skip the pre-flight checklist because they have flown before.</p> <p>The checklist exists precisely because the stakes are high enough that \"I know what I'm doing\" is not sufficient.</p>","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":"<p>Every skill had a \"When to Use\" section. Almost none had \"When NOT to Use\". This is a problem.</p> <p>AI agents are biased toward action. Given a skill that says \"use when journal entries need enrichment\", the agent will find reasons to enrich.</p> <p>Without explicit negative triggers, over-activation is not a bug; it is the default behavior.</p> <p>Some examples of negative triggers that made a real difference:</p> 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\" <p>These are not just nice-to-have. They are load-bearing. </p> <p>Withoutthem, the agent will trigger the skill at the wrong time, produce unwanted output, and erode the user's trust in the skill system.</p>","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":"<p>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.</p> <p>Rules like \"be constructive, not critical\" are too abstract. What does \"constructive\" look like in a prompt audit report? The agent has to guess.</p> <p>Good/bad example pairs avoid guessing:</p> <pre><code>### 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</code></pre> <p>The good example shows the exact format, level of detail, and command syntax. The bad examples show where the boundary is.</p> <p>Together, they define a quality corridor without prescribing every word.</p> <p>Rules describe. Examples demonstrate.</p>","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":"<p>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.</p> <p>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.</p> <p>Skills Are for the Agents</p> <p>Every sentence in a skill should be actionable by the agent.</p> <p>If the guidance requires human judgment or human tools, it belongs in documentation, not in a skill.</p> <p>The corollary: command references must be exact. </p> <p>A skill that says \"save it somewhere\" is useless. </p> <p>A skill that says <code>ctx add learning --context \"...\" --lesson \"...\" --application \"...\"</code> is actionable.</p> <p>The agent can pattern-match and fill in the blanks.</p> <p>Litmus test: If a sentence starts with \"you could...\" or assumes external tools, it does not belong in a skill.</p>","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":"<p>This was covered in Skills That Fight the Platform, but the rewrite reinforced it with data. Several skills had good bodies but vague descriptions:</p> <pre><code># 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</code></pre> <p>The description is not a title. It is the activation condition.</p> <p>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.</p>","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":"<p>Most skills wrap CLI tools. The thin versions described flags in prose, if at all. The rewritten versions use tables:</p> <pre><code>| 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</code></pre> <p>Tables are scannable, complete, and unambiguous. </p> <p>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.</p>","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":"<p>// TODO: this has changed; we deploy from the marketplace; update it. // at least add an admonition saying thing are different now.</p> <p><code>ctx</code> deploys skills through templates (via <code>ctx init</code>). Every skill exists in two places: the live version (<code>.claude/skills/</code>) and the template (<code>internal/assets/claude/skills/</code>).</p> <p>They must match.</p> <p>During the rewrite, every skill update required editing both files and running <code>diff</code> to verify. This sounds trivial, but across 16 template-backed skills, it was the most error-prone part of the process.</p> <p>Template drift is dangerous because it creates false confidence: the agent appears to follow rules that no longer exist.</p> <p>The lesson: if your skills have a deployment mechanism, build the drift check into your workflow. We added a row to the <code>update-docs</code> skill's mapping table specifically for this:</p> <pre><code>| `internal/assets/claude/skills/` | `.claude/skills/` (live) |\n</code></pre> <p>Intentional differences (like project-specific scripts in the live version but not the template) should be documented, not discovered later as bugs.</p>","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 <p>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.</p>","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":"<p>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.</p> <p>This post adds the missing piece: structure.</p> <p>A skill without a structure is a wish.</p> <p>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.</p> <p>Skills Are Interfaces</p> <p>Good skills are not instructions. They are contracts.:</p> <ul> <li>They specify preconditions, postconditions, and boundaries.</li> <li>They show what success looks like and what failure looks like.</li> <li>They trust the agent's intelligence but do not trust its assumptions.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>Skills that work have bones, not just flesh.</p> <p>Quality gates, negative triggers, examples, and checklists are the skeleton. The domain knowledge is the muscle.</p> <p>Without the skeleton, the muscle has nothing to attach to.</p> <p>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.</p>","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":"<p>Update (2026-02-11)</p> <p>As of v0.4.0, <code>ctx</code> consolidated sessions into the journal mechanism. References to <code>/ctx-save</code>, <code>.context/sessions/</code>, and session auto-save in this post reflect the architecture at the time of writing.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-02-08</p> <p>When You Find a Useful Prompt, What Do You Do with It?</p> <p>My instinct was to make it a skill.</p> <p>I had just spent three posts explaining how to build skills that work. Naturally, the hammer wanted nails.</p> <p>Then I looked at what I was holding and realized: this is not a nail.</p>","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":"<p>I wanted to understand how I use <code>ctx</code>: </p> <ul> <li>Where the friction is;</li> <li>What works, what drifts; </li> <li>What I keep doing manually that could be automated. </li> </ul> <p>So I wrote a prompt that spawned eight agents to analyze the codebase from different angles:</p> 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 <p>The prompt was specific: </p> <ul> <li>read-only agents, </li> <li>structured output format,</li> <li>concrete file references, </li> <li>ranked recommendations. </li> </ul> <p>It ran for about 20 minutes and produced eight Markdown reports.</p> <p>The reports were good: Not perfect, but actionable.</p> <p>What mattered was not the speed. It was that the work could be explored without committing to any single outcome.</p> <p>They surfaced a stale <code>doc.go</code> referencing a subcommand that was never built. </p> <p>They found 311 build-then-test sequences I could reduce to a single <code>make check</code>. </p> <p>They identified that 42% of my sessions start with \"do you remember?\", which is a lot of repetition for something a skill could handle.</p> <p>I had findings. I had recommendations. I had the instinct to automate.</p> <p>And then... I stopped.</p>","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":"<p>The natural next step was to wrap the audit prompt as <code>/ctx-audit</code>: a skill you invoke periodically to get a health check. It fits the pattern: </p> <ul> <li>It has a clear trigger.</li> <li>It produces structured output.</li> </ul> <p>But I had just spent a week writing about what makes skills work, and the criteria I established argued against it.</p> <p>From The Anatomy of a Skill That Works:</p> <p>\"A skill without boundaries is just a suggestion.\"</p> <p>From You Can't Import Expertise:</p> <p>\"Frameworks travel, expertise doesn't.\"</p> <p>From Skills That Fight the Platform:</p> <p>\"You are the guest, not the host.\"</p> <p>The audit prompt fails all three tests:</p> 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 <p>Skills are contracts. Contracts need stable terms. </p> <p>A prompt I will rewrite every time I use it is not a contract. It is a conversation starter.</p>","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":"<p>The distinction that emerged:</p> Skill Recipe Invocation <code>/slash-command</code> 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 <code>.claude/skills/</code> <code>hack/</code> or <code>docs/</code> Attention cost Loaded into context on match Zero until needed <p>Recipes can later graduate into skills, but only after repetition proves stability.</p> <p>That last row matters. Skills consume the attention budget every time the platform considers activating them.</p> <p>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.</p> <p>Runbooks have zero attention cost. They sit in a Markdown file until a human decides to use them. </p> <ul> <li>The human provides the judgment about timing. </li> <li>The prompt provides the structure.</li> </ul> <p>The Attention Budget Applies to Skills Too</p> <p>Every skill in <code>.claude/skills/</code> is a standing claim on the context window. The platform evaluates skill descriptions against every user prompt to decide whether to activate.</p> <p>Twenty focused skills are fine. Thirty might be fine. But each one added reduces the headroom available for actual work.</p> <p>Recipes are skills that opted out of the attention tax.</p>","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":"<p>The audit was not wasted. It was a planning exercise that generated concrete tasks:</p> Finding Action 42% of sessions start with memory check Task: <code>/ctx-remember</code> skill (this one is a skill; it is daily) Auto-save stubs are empty Task: enhance <code>/ctx-save</code> with richer summaries 311 raw build-test sequences Task: <code>make check</code> target Stale <code>recall/doc.go</code> lists nonexistent <code>serve</code> Task: fix the doc.go 120 commit sequences disconnected from context Task: <code>/ctx-commit</code> workflow <ul> <li>Some findings became skills;</li> <li>Some became <code>Makefile</code> targets;</li> <li>Some became one-line doc fixes. </li> </ul> <p>The audit did not prescribe the artifact type: The findings did.</p> <p>The audit is the input. Skills are one possible output. Not the only one.</p>","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":"<p>Here is the exact prompt I used, for those who are curious.</p> <p>This is not a template: It worked because it was written against this codebase, at this moment, with specific goals in mind:</p> <pre><code>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</code></pre> <p>Avoid Generic Advice</p> <p>Suggestions that are not grounded in a project's actual structure, history, and workflows are worse than useless:</p> <p>They create false confidence.</p> <p>If an analysis cannot point to concrete files, commits, sessions, or patterns, it should say \"no finding\" instead of inventing best practices.</p>","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":"<p>This is part of a pattern I keep rediscovering: </p> <p>The urge to automate is not the same as the need to automate:</p> <ul> <li>The 3:1 ratio taught me that not every session should be a YOLO sprint. </li> <li>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.</li> </ul> <p>The common thread is restraint: </p> <ul> <li>Knowing when to stop. </li> <li>Recognizing that the cost of automation is not just the effort to build it.</li> </ul> <p>The cost is the ongoing attention tax of maintaining it, the context it consumes, and the false confidence it creates when it drifts.</p> <p>An entry in <code>hack/runbooks/codebase-audit.md</code> is honest about what it is:</p> <p>A prompt I wrote once, improved once, and will adapt again next time: </p> <ul> <li>It does not pretend to be a reliable contract. </li> <li>It does not claim attention budget. </li> <li>It does not drift silently.</li> </ul> <p>The Automation Instinct</p> <p>When you find a useful prompt, the instinct is to institutionalize it. Resist.</p> <p>Ask first: will I use this the same way next time?</p> <p>If yes, it is a skill. If no, it is a recipe. If you are not sure, it is a recipe until proven otherwise.</p>","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 <code>ctx</code>","text":"<p><code>ctx</code> is a tool that gives AI agents persistent memory. Its purpose is automation: reducing the friction of context loading, session recall, decision tracking.</p> <p>But automation has boundaries, and knowing where those boundaries are is as important as pushing them forward. </p> <p>The skills system is for high-frequency, stable workflows. </p> <p>The recipes, the journal entries, the session dumps in <code>.context/sessions/</code>: those are for everything else.</p> <p>Not everything needs to be a slash command. Some things are better as Markdown files you read when you need them.</p> <p>The goal of <code>ctx</code> is not to automate everything: It is to automate the right things and to make the rest easy to find when you need it.</p> <p>If You Remember One Thing from This Post...</p> <p>The best automation decision is sometimes not to automate.</p> <p>A runbook in a Markdown file costs nothing until you use it.</p> <p>A skill costs attention on every prompt, whether it fires or not.</p> <p>Automate the daily. Document the periodic. Forget the rest.</p> <p>This post was written during the session that produced the codebase audit reports and distilled the prompt into <code>hack/runbooks/codebase-audit.md</code>. The audit generated seven tasks, one Makefile target, and zero new skills. The meta continues.</p> <p>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.</p>","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":"<p>Volkan Özçelik / 2026-02-09</p> <p>What Happens When Your AI Agent Runs Overnight and Nobody Is Watching?</p> <p>It follows instructions: That is the problem.</p> <p>Not because it is malicious. Because it is controllable.</p> <p>It follows instructions from context, and context can be poisoned.</p> <p>I was writing the autonomous loops recipe for <code>ctx</code>: 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:</p> <p>Use <code>CONSTITUTION.md</code> for guardrails. Tell the agent \"never delete tests\" and it usually won't.</p> <p>Then I read that sentence back and realized: that is wishful thinking.</p>","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":"<p><code>CONSTITUTION.md</code> is a Markdown file. The agent reads it at session start alongside everything else in <code>.context/</code>. 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.</p> <p>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:</p> 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 <code>CLAUDE.md</code> or <code>.cursorrules</code> 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 <p>That last vector is the one that kept me up at night (literally!):</p> <p>In an autonomous loop, the agent modifies files as part of its job. </p> <p>If it modifies its own configuration files, the next iteration loads the modified config. </p> <ul> <li>No human reviews it. </li> <li>No diff is shown. </li> <li>The agent that starts iteration <code>N+1</code> is running with rules written by iteration <code>N</code>.</li> </ul> <p>The agent can rewrite its own guardrails.</p>","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":"<p>That's five nested layers of swiss cheese. Alone, each of them has large holes. Together, they create a boundary.</p> <p>What followed was a week of peeling back assumptions:</p> <p>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.</p>","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":"<p><code>CONSTITUTION.md</code>, the Agent Playbook, system prompts: These tell the agent what to do. </p> <p>The agent usually follows them.</p> <p>\"Usually\" is the keyword here.</p> <p>The hole: Prompt injection:</p> <ul> <li>A sufficiently crafted payload overrides soft instructions. </li> <li>Long context windows dilute attention on rules stated early. </li> <li>Edge cases where instructions are ambiguous get resolved in unpredictable ways.</li> </ul> <p>Verdict: Necessary. Not sufficient. Good for the common case. Never trust it as a security boundary.</p>","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":"<p>Permission allowlists in <code>.claude/settings.local.json</code>:</p> <pre><code>{\n \"permissions\": {\n \"allow\": [\n \"Bash(make:*)\",\n \"Bash(go:*)\",\n \"Bash(git:*)\",\n \"Read\",\n \"Write\",\n \"Edit\"\n ]\n }\n}\n</code></pre> <p>If <code>rm</code>, <code>curl</code>, <code>sudo</code>, or <code>docker</code> are not in the allowlist, the agent cannot invoke them. This is deterministic. </p> <p>The application enforces it regardless of what any prompt says.</p> <p>The hole: The agent can modify the allowlist itself: </p> <ul> <li>It has <code>Write</code> permission. </li> <li>The allowlist lives in a file. </li> <li>The agent writes to the file. </li> <li>The next iteration loads the modified allowlist.</li> </ul> <p>The application enforces the rules, but the application reads the rules from files the agent can write.</p> <p>Verdict: Strong first layer. Must be combined with self-modification prevention.</p>","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":"<p>This is where the defenses stop having holes in the same shape.</p> <p>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 <code>CAP_NET_RAW</code> cannot open raw sockets. These are kernel boundaries.</p> Control What it stops Dedicated unprivileged user Privilege escalation, <code>sudo</code>, group-based access Filesystem permissions Lateral movement to other projects, system config Immutable config files Self-modification of guardrails between iterations <p>Make the agent's instruction files read-only: <code>CLAUDE.md</code>, <code>.claude/settings.local.json</code>, <code>.context/CONSTITUTION.md</code>. Own them as a different user, or mark them immutable with <code>chattr +i</code> on Linux.</p> <p>The hole: Actions within the agent's legitimate scope: </p> <ul> <li>If the agent has write access to source code (which it needs), it can introduce vulnerabilities in the code itself. </li> <li>You cannot prevent this without removing the agent's ability to do its job.</li> </ul> <p>Verdict: Essential. This is the layer that makes Layers 1 and 2 trustworthy.</p> <p>OS-level isolation does not make the agent safe; it makes the other layers meaningful.</p>","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":"<p>An agent that cannot reach the internet cannot exfiltrate data.</p> <p>It also cannot ingest new instructions mid-loop from external documents, error pages, or hostile content.</p> <pre><code># 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</code></pre> <ul> <li>If the agent genuinely does not need the network, disable it entirely. </li> <li>If it needs to fetch dependencies, allow specific registries and block everything else.</li> </ul> <p>The hole: None, if the agent does not need the network. </p> <p>Thetradeoff is that many real workloads need dependency resolution, so a full airgap requires pre-populated caches.</p>","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":"<p>The strongest boundary is a separate machine.</p> <p>The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.</p> <pre><code>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</code></pre> <p>Never Mount the Docker Socket</p> <p>Do not mount <code>/var/run/docker.sock</code>, like, ever. </p> <p>An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox. </p> <p>This is not theoretical: the Docker socket grants root-equivalent access to the host.</p> <p>Use rootless Docker or Podman to eliminate this escalation path entirely.</p> <p>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.</p>","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":"<p>Each layer is straightforward: The strength is in the combination:</p> Layer Implementation What it stops Soft instructions <code>CONSTITUTION.md</code> Common mistakes (probabilistic) Application allowlist <code>.claude/settings.local.json</code> Unauthorized commands (deterministic within runtime) Immutable config <code>chattr +i</code> on config files Self-modification between iterations Unprivileged user Dedicated user, no sudo Privilege escalation Container <code>--cap-drop=ALL --network=none</code> Host escape, data exfiltration Resource limits <code>--memory=4g --cpus=2</code> Resource exhaustion <p>No layer is redundant. Each one catches what the others miss:</p> <ul> <li>The soft instructions handle the 99% case: \"don't delete tests.\"</li> <li>The allowlist prevents the agent from running commands it should not.</li> <li>The immutable config prevents the agent from modifying the allowlist.</li> <li>The unprivileged user prevents the agent from removing the immutable flag.</li> <li>The container prevents the agent from reaching anything outside its workspace.</li> <li>The resource limits prevent the agent from consuming all system resources.</li> </ul> <p>Remove any one layer and there is an attack path through the remaining ones.</p>","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":"<p>These are real patterns, not hypotheticals:</p> <p>\"I'll just use <code>--dangerously-skip-permissions</code>.\" 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\").</p> <p>\"The agent is sandboxed in Docker.\" A Docker container with the Docker socket mounted, running as root, with <code>--privileged</code>, and full network access is not sandboxed. It is a root shell with extra steps.</p> <p>\"I reviewed <code>CLAUDE.md</code>, 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.</p> <p>\"The agent only has access to this one project.\" Does the project directory contain <code>.env</code> files? SSH keys? API tokens? A <code>.git/config</code> with push access to a remote? Filesystem isolation means isolating what is in the directory too.</p>","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":"<p>This is the same lesson I keep rediscovering, wearing different clothes.</p> <p>In The Attention Budget, I wrote about how every token competes for the AI's focus. Security instructions in <code>CONSTITUTION.md</code> 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.</p> <p>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.</p> <p>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.</p> <p>The pattern across all of these: Soft instructions are useful for the common case. Hard boundaries are required for security.</p> <p>Know which is which.</p>","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":"<p>Before running an unattended AI agent:</p> <ul> <li> Agent runs as a dedicated unprivileged user (no sudo, no docker group)</li> <li> Agent's config files are immutable or owned by a different user</li> <li> Permission allowlist restricts tools to the project's toolchain</li> <li> Container drops all capabilities (<code>--cap-drop=ALL</code>)</li> <li> Docker socket is NOT mounted</li> <li> Network is disabled or restricted to specific domains</li> <li> Resource limits are set (memory, CPU, disk)</li> <li> No SSH keys, API tokens, or credentials are accessible</li> <li> Project directory does not contain <code>.env</code> or secrets files</li> <li> Iteration cap is set (<code>--max-iterations</code>)</li> </ul> <p>This checklist lives in the Agent Security reference alongside the full threat model and detailed guidance for each layer.</p>","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 <code>ctx</code>","text":"<p>The autonomous loops recipe now has a full permissions and isolation section instead of a one-line tip about <code>CONSTITUTION.md</code>. It covers both the explicit allowlist approach and the <code>--dangerously-skip-permissions</code> flag, with honest guidance about when each is appropriate.</p> <p>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.</p> <p>The Agent Security page consolidates the threat model and defense layers into a standalone reference.</p> <p>These are not theoretical improvements. They are the minimum responsible guidance for a tool that helps people run AI agents overnight.</p> <p>If You Remember One Thing from This Post...</p> <p>Markdown is not a security boundary.</p> <p><code>CONSTITUTION.md</code> is a nudge. An allowlist is a gate.</p> <p>An unprivileged user in a network-isolated container is a wall.</p> <p>Use all three. Trust only the wall.</p> <p>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.</p>","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":"<p>Volkan Özçelik / 2026-02-12</p> <p>Have You Ever Felt like You Should Understand More of the Stack beneath You?</p> <p>You can talk about transformers at a whiteboard.</p> <p>You can explain attention to a colleague.</p> <p>You can use agentic AI to ship real software.</p> <p>But somewhere in the back of your mind, there is a voice:</p> <p>\"Maybe I should go deeper. Maybe I need to master machine learning.\"</p> <p>I had that voice for months. </p> <p>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.</p> <p>This post is about when depth compounds and (more importantly) when it does not.</p>","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":"<p>There is an implicit stack most people carry around when thinking about AI:</p> 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 <p>At some point down that stack, you hit a comfortable plateau: the layer where you can hold a conversation but not debug a failure.</p> <p>The instinctive response is to go deeper.</p> <p>But that instinct hides a more important question:</p> <p>\"Does depth still compound when the abstractions above you are moving hyper-exponentially?\"</p>","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":"<p>If you squint hard enough, a large chunk of modern ML intuition collapses into older fields:</p> 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 <p>Nothing here is uniquely \"AI\".</p> <p>Most of this math predates the term deep learning. In some cases, by decades.</p> <p>So what changed?</p>","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":"<p>The mistake is assuming this is a new theory problem: It is not.</p> <p>It is a new operating regime.</p> <p>Classical numerical methods were developed under assumptions like:</p> <ul> <li>Manageable dimensionality</li> <li>Reasonably well-conditioned objectives</li> <li>Losses that actually represent the goal</li> </ul> <p>Modern ML violates all three: On purpose.</p> <p>Today's models operate with millions to trillions of parameters, wildly underdetermined systems, and objective functions we know are wrong but optimize anyway.</p> <p>It is complete and utter madness! </p> <p>At this scale, familiar concepts warp:</p> <ul> <li>What we call \"local minima\" are overwhelmingly saddle points in high-dimensional spaces.</li> <li>Noise stops being noise and starts becoming structure.</li> <li>Overfitting can coexist with generalization.</li> <li>Bigger models outperform \"better\" ones.</li> </ul> <p>The math did not change: The phase did.</p> <p>This is less numerical analysis and more *statistical physics: Same equations, but behavior dominated by phase transitions and emergent structure.</p>","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":"<p>In classical statistics, asymptotics describe what happens eventually.</p> <p>In modern ML, scaling laws describe where you can operate today.</p> <p>They do not say \"given enough time, things converge\".</p> <p>They say \"cross this threshold and behavior qualitatively changes\".</p> <p>This is why dumb architectures plus scale beat clever ones.</p> <p>Why small theoretical gains disappear under data.</p> <p>Why \"just make it bigger\", ironically, keeps working longer than it should.</p> <p>That is not a triumph of ML theory: It is a property of high-dimensional systems under loose objectives.</p>","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":"<p>This reframes the original question.</p> <p>You do not need depth because this is \"AI\".</p> <p>You need depth where failure modes propagate upward.</p> <p>I learned this building <code>ctx</code>: The agent failures I have spent the most time debugging were never about the model's architecture.</p> <p>They were about:</p> <ul> <li> <p>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.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ul> <p>This is the kind of depth that compounds. Not deriving backprop. But, understanding when correct math produces misleading intuition.</p>","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":"<p>This is the same pattern I keep finding at different altitudes.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>In every case, the answer was not \"go deeper into ML\".</p> <p>The answer was knowing which abstraction was leaking and fixing it at the right layer.</p>","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":"<p>The mistake is assuming agent failures originate where the model was trained, rather than where it is deployed.</p> <p>Agentic AI is a systems problem under chaotic uncertainty:</p> <ul> <li>Feedback loops between the agent and its environment;</li> <li>Error accumulation across iterations;</li> <li>Brittle representations that break outside training distribution;</li> <li>Misplaced trust in outputs that look correct.</li> </ul> <p>In short-lived interactions, model quirks are tolerable. In long-running autonomous loops, however, they compound. </p> <p>That is where shallow understanding becomes expensive.</p> <p>But the understanding you need is not about optimizer internals.</p> <p>It is about:</p> 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 <p>The depth that matters is diagnostic, not theoretical.</p>","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":"<p>Not turtles all the way down.</p> <p>Go deep enough to:</p> <ul> <li>Diagnose failures instead of cargo-culting fixes;</li> <li>Reason about uncertainty instead of trusting confidence;</li> <li>Design guardrails that align with model behavior, not hope.</li> </ul> <p>Stop before:</p> <ul> <li>Hand-deriving gradients for the sake of it;</li> <li>Obsessing over optimizer internals you will never touch;</li> <li>Chasing theoretical purity divorced from the scale you actually operate at.</li> </ul> <p>This is not about mastering ML.</p> <p>It is about knowing which abstractions you can safely trust and which ones leak.</p> <p>Hint: Any useful abstraction almost certainly leaks.</p>","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":"<p>If a failure occurs and your instinct is to:</p> <ul> <li>Add more prompt text: abstraction leak above</li> <li>Add retries or heuristics: error accumulation</li> <li>Change the model: scale masking</li> <li>Reach for ML theory: you are probably (but not always) going too deep</li> </ul> <p>The right depth is the shallowest layer where the failure becomes predictable.</p>","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-ctx-lesson","level":2,"title":"The <code>ctx</code> Lesson","text":"<p>Every design decision in <code>ctx</code> is downstream of this principle.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>The boundary between useful understanding and academic exercise is where your failure modes live.</p>","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":"<p>Most modern AI systems do not fail because the math is wrong.</p> <p>They fail because we apply correct math in the wrong regime, then build autonomous systems on top of it.</p> <p>Understanding that boundary, not crossing it blindly, is where depth still compounds.</p> <p>And that is a far more useful form of expertise than memorizing another loss function.</p> <p>If You Remember One Thing from This Post...</p> <p>Go deep enough to diagnose your failures. Stop before you are solving problems that do not propagate to your layer.</p> <p>The abstractions below you are not sacred. But neither are they irrelevant.</p> <p>The useful depth is wherever your failure modes live. Usually one or two layers down, not at the bottom.</p> <p>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.</p>","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":"<p>IRC is stateless.</p> <ul> <li>You disconnect, you vanish.</li> <li>You reconnect, you begin again.</li> </ul> <p>No buffer.</p> <p>No memory.</p> <p>No continuity.</p> <p>Modern systems are not much different:</p> <ul> <li>Close the browser tab.<ul> <li>Lose the Slack scrollback.</li> </ul> </li> <li>Open a new LLM session.<ul> <li>Start from zero.</li> </ul> </li> </ul> <p>Resets externalize reconstruction cost onto humans.</p> <p>Reconstruction is tax: Tax becomes entropy.</p>","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":"<p>IRC is minimal:</p> <ul> <li>A TCP connection.</li> <li>A nickname.</li> <li>A channel.</li> <li>A stream of lines.</li> </ul> <p>When the connection drops, you literally disappear from the graph.</p> <p>The protocol is stateless; human systems are not.</p> <p>So you:</p> <ul> <li>Reconnect;</li> <li>Ask what you missed;</li> <li>Scroll;</li> <li>Reconstruct.</li> </ul> <p>The machine forgets; you pay.</p>","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":"<p>A <code>bouncer</code> is a daemon that remains connected when you do not:</p> <ul> <li>It holds your seat;</li> <li>It buffers what you missed;</li> <li>It keeps your identity online.</li> </ul> <p>ZNC is one such bouncer.</p> <p>With ZNC:</p> <ul> <li>Your client does not connect to IRC;</li> <li>It connects to <code>ZNC</code>;</li> <li><code>ZNC</code> connects upstream.</li> </ul> <p>Client sessions become ephemeral.</p> <p>Presence becomes infrastructural.</p> <p>ZNC Is Tmux for IRC</p> <ul> <li> <p>Close your laptop.</p> <ul> <li>ZNC remains.</li> </ul> </li> <li> <p>Switch devices.</p> <ul> <li>ZNC persists.</li> </ul> </li> </ul> <p>This is not convenience; this is continuity.</p>","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":"<p>With a bouncer:</p> <ul> <li>Closing your client does not emit <code>PART</code>.</li> <li>Reopening does not emit <code>JOIN</code>.</li> </ul> <p>You do not flap in and out of existence.</p> <p>From the channel's perspective, you remain.</p> <p>From your perspective, history accumulates.</p> <ul> <li>Buffers persist;</li> <li>Identity persists;</li> <li>Context persists.</li> </ul> <p>This pattern predates AI.</p>","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":"<p>An LLM session without memory is IRC without a bouncer:</p> <ul> <li>Close the window.</li> <li>Start over.</li> <li>Re-explain intent.</li> <li>Rehydrate context.</li> </ul> <p>That is friction.</p> <p>This Walks and Talks like <code>ctx</code></p> <p>Context engineering moves memory out of sessions and into infrastructure.</p> <ul> <li><code>ZNC</code> does this for IRC.</li> <li><code>ctx</code> does this for agents.</li> </ul> <p>Same principle:</p> <ul> <li>Volatile interface.</li> <li>Persistent substrate.</li> </ul> <p>Different fabric.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#minimal-architecture","level":2,"title":"Minimal Architecture","text":"<p>My setup is intentionally boring:</p> <ul> <li>A $5 small VPS.</li> <li>ZNC installed.</li> <li>TLS enabled.</li> <li>Firewall restricted.</li> </ul> <p>Then:</p> <ul> <li>ZNC connects to <code>Libera.Chat</code>.</li> <li><code>SASL</code> authentication lives inside ZNC.</li> <li>Buffers are stored on disk.</li> </ul> <p>My client connects to my VPS, not the network.</p> <p>The commands do not matter: The boundaries do:</p> <ul> <li>Authentication in infrastructure, not in the client;</li> <li>Memory server-side, not in scrollback;</li> <li>Presence decoupled from activity.</li> </ul> <p>Everything else is configuration.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#platform-memory","level":2,"title":"Platform Memory","text":"<p>Yes, I know, it is 2026:</p> <ul> <li>Discord stores history;</li> <li>Slack stores history;</li> <li>The dumpster fire on gasoline called X, too, stores history.</li> </ul> <p>HOWEVER, they own your substrate.</p> <p>Running a bouncer is quiet sovereignty:</p> <ul> <li>Logs are mine.</li> <li>Presence is continuous.</li> <li>State does not reset because I closed a tab.</li> </ul> <p>Small acts compound.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#signal-density","level":2,"title":"Signal Density","text":"<p>Primitive systems select for builders.</p> <p>Consistent presence in small rooms compounds reputation.</p> <p>Quiet compounding outperforms viral spikes.</p>","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":"<p>ZNC is not interesting because it is retro; it is interesting because it models a principle:</p> <ul> <li>Stateless protocols require stateful wrappers;</li> <li>Volatile interfaces require durable memory;</li> <li>Human systems require continuity.</li> </ul> <p>Distilled:</p> <p>Humans require context.</p> <p>Before context windows, we had bouncers. </p> <p>Before AI memory files, we had buffers.</p> <p>Continuity is not a feature; it is a design decision.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#build-it","level":2,"title":"Build It","text":"<p>If you want the actual setup (VPS, ZNC, TLS, SASL, firewall...) there is a step-by-step runbook:</p> <p>Persistent IRC Presence with ZNC.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#motd","level":2,"title":"MOTD","text":"<p>When my client connects to my bouncer, it prints:</p> <pre><code>// / ctx: https://ctx.ist\n// ,'`./ do you remember?\n// `.,'\\\n// \\ Copyright 2026-present Context contributors.\n// SPDX-License-Identifier: Apache-2.0\n</code></pre> <p>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.</p>","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":"<p>Jose Alekhinne / 2026-02-14</p> <p>What Do You Do with 30 Open Tasks?</p> <p>You could work through them one at a time.</p> <p>One agent, one branch, one commit stream.</p> <p>Or you could ask: which of these don't touch each other?</p> <p>I had 30 open tasks in <code>TASKS.md</code>. Some were docs. Some were a new encryption package. Some were test coverage for a stable module. Some were blog posts.</p> <p>They had almost zero file overlap.</p> <p>Running one agent at a time meant serial execution on work that was fundamentally parallel:</p> <p>I was bottlenecking on me, not on the machine.</p>","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":"<p>This is not a scheduling problem: It's a conflict avoidance problem.</p> <p>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.</p> <p>So the question becomes: </p> <p>\"Can you partition your backlog into non-overlapping tracks?\"</p> <p>For <code>ctx</code>, the answer was obvious:</p> Track Touches Tasks <code>work/docs</code> <code>docs/</code>, <code>hack/</code> Blog posts, recipes, runbooks <code>work/pad</code> <code>internal/cli/pad/</code>, specs Scratchpad encryption, CLI, tests <code>work/tests</code> <code>internal/cli/recall/</code> Recall test coverage <p>Three tracks. Near-zero overlap. Three agents.</p>","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":"<p><code>git</code> has a feature that most people don't use: worktrees.</p> <p>A worktree is a second (or third, or fourth) working directory that shares the same <code>.git</code> object database as your main checkout. </p> <p>Each worktree has its own branch, its own index, its own working tree. But they all share history, refs, and objects.</p> <pre><code>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</code></pre> <ul> <li>Three directories;</li> <li>Three branches;</li> <li>One repository.</li> </ul> <p>This is cheaper than three clones. And because they share objects, <code>git merge</code> afterwards is fast: It's a local operation on shared data.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-setup","level":2,"title":"The Setup","text":"<p>The workflow I landed on:</p> <p>1. Group tasks by blast radius.</p> <p>Read <code>TASKS.md</code>. 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.</p> <p>This is the part that requires human judgment: </p> <p>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.</p> <p>2. Create worktrees as sibling directories.</p> <p>Not subdirectories: Siblings. </p> <p>If your main checkout is at <code>~/WORKSPACE/ctx</code>, worktrees go at <code>~/WORKSPACE/ctx-docs</code>, <code>~/WORKSPACE/ctx-pad</code>, etc.</p> <p>Why siblings? Because some tools (and some agents) walk up the directory tree looking for <code>.git</code>. A worktree inside the main checkout confuses them.</p> <p>3. Launch one agent per worktree.</p> <pre><code># Terminal 1\ncd ../ctx-docs && claude\n\n# Terminal 2\ncd ../ctx-pad && claude\n\n# Terminal 3\ncd ../ctx-tests && claude\n</code></pre> <p>Each agent gets a full working copy with <code>.context/</code> intact. It reads the same <code>TASKS.md</code>, the same <code>DECISIONS.md</code>, the same <code>CONVENTIONS.md</code>. It knows the full project state. It just works on a different slice.</p> <p>4. Do NOT run <code>ctx init</code> in worktrees.</p> <p>This is the gotcha. The <code>.context/</code> directory is tracked in git. Running <code>ctx init</code> in a worktree would overwrite shared context files: Wiping decisions, learnings, and tasks that belong to the whole project.</p> <p>The worktree already has everything it needs. Leave it alone.</p>","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":"<p>I ran three agents for about 40 minutes. Here is roughly what each track produced:</p> <p><code>work/docs</code>: Parallel worktrees recipe, blog post edits, recipe index reorganization, IRC recipe moved from <code>docs/</code> to <code>hack/</code>.</p> <p><code>work/pad</code>: <code>ctx pad show</code> subcommand, <code>--append</code> and <code>--prepend</code> flags on <code>ctx pad edit</code>, spec updates, 28 new test functions.</p> <p><code>work/tests</code>: Recall test coverage, edge case tests.</p> <p>Merging took about five minutes. Two of the three merges were clean.</p> <p>The third had a conflict in <code>TASKS.md</code>: </p> <p>both the docs track and the pad track had marked different tasks as <code>[x]</code>.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-tasksmd-conflict","level":2,"title":"The <code>TASKS.md</code> Conflict","text":"<p>This deserves its own section because it will happen every time.</p> <p>When two agents work in parallel, they both read <code>TASKS.md</code> at the start and mark tasks complete as they go. When you merge, git sees two branches that modified the same file differently.</p> <p>The resolution is always the same: accept all completions from both sides. No task should go from <code>[x]</code> back to <code>[ ]</code>. The merge is additive.</p> <p>This is one of those conflicts that sounds scary but is trivially mechanical: You are not arbitrating design decisions; you are combining two checklists.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#limits","level":2,"title":"Limits","text":"<p>3-4 worktrees, maximum. </p> <p>I tried four once: By the time I merged the third track, the fourth had drifted far enough that its changes needed rebasing. </p> <p>The merge complexity grows faster than the parallelism benefit.</p> <p>Three is the sweet spot:</p> <ul> <li>Two is conservative but safe;</li> <li>Four is possible if the tracks are truly independent;</li> <li>Anything more than four, you are in the danger zone.</li> </ul> <p>Group by directory, not by priority.</p> <p>It is tempting to put all the high-priority tasks in one track: Don't. </p> <p>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.</p> <p>Commit frequently. </p> <p>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.</p> <p>Name tracks by concern. </p> <ul> <li><code>work/docs</code> and <code>work/pad</code> tell you what's happening;</li> <li><code>work/track-1</code> and <code>work/track-2</code> tell you nothing.</li> </ul>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-pattern","level":2,"title":"The Pattern","text":"<p>This is the same pattern that shows up everywhere in <code>ctx</code>:</p> <p>The attention budget taught me that you can't dump everything into one context window. You have to partition, prioritize, and load selectively.</p> <p>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.</p> <p>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.</p> <p>And the IRC bouncer post from earlier today argued that stateless protocols need stateful wrappers. Worktrees are the same: git branches are stateless forks; <code>.context/</code> is the stateful wrapper that gives each agent the project's full memory.</p>","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":"<p>I asked myself the same question I asked about the codebase audit: should this be a <code>/ctx-worktree</code> skill?</p> <p>This time the answer was a resounding \"yes\": </p> <p>Unlike the audit prompt (which I tweak every time and run every other week) the worktree workflow is:</p> 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\" <p>The commands are mechanical: <code>git worktree add</code>, <code>git worktree remove</code>, branch naming, safety checks. This is exactly what skills are for: stable contracts for repetitive operations.</p> <p>Ergo, <code>/ctx-worktree</code> exists. </p> <p>It enforces the 4-worktree limit, creates sibling directories, uses <code>work/</code> branch prefixes, and reminds you not to run <code>ctx init</code> in worktrees.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-takeaway","level":2,"title":"The Takeaway","text":"<p>Serial execution is the default. But serial is not always necessary.</p> <p>If your backlog partitions cleanly by file overlap, you can multiply your throughput with nothing more exotic than <code>git worktree</code> and a second terminal window.</p> <p>The hard part is not the <code>git</code> commands; it is the discipline:</p> <ul> <li>Grouping by blast radius instead of priority; </li> <li>Accepting that <code>TASKS.md</code> will conflict; </li> <li>And knowing when three tracks is enough.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>Partition by blast radius, not by priority.</p> <p>Two tasks that touch the same files belong in the same track, no matter how important the other one is.</p> <p>The constraint is file overlap. Everything else is scheduling.</p> <p>The practical setup (skill invocation, worktree creation, merge workflow, and cleanup) lives in the recipe: Parallel Agent Development with Git Worktrees.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/","level":1,"title":"<code>ctx</code> 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":"<p>Jose Alekhinne / February 15, 2026</p> <p>What Does a Release Look like When Most of the Work Is Invisible?</p> <p>No new headline feature. No architectural pivot. No rewrite.</p> <p>Just 35+ documentation and quality commits against ~15 feature commits... and somehow, the tool feels like it grew up overnight.</p> <p>Six days separate <code>v0.2.0</code> from <code>v0.3.0</code>. </p> <p>Measured by calendar time, it is nothing. Measured by what changed in how the project operates, it is the most significant release yet.</p> <ul> <li><code>v0.1.0</code> was the prototype;</li> <li><code>v0.2.0</code> was the archaeology release: making the past accessible; </li> <li><code>v0.3.0</code> 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.</li> </ul> <p>The Release Window</p> <p>February 1‒February 7, 2026</p> <p>From the <code>v0.2.0</code> tag to commit <code>2227f99</code>.</p> <p>78 files changed in the migration commit alone.</p>","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":"<p>The largest single change was the migration from <code>.claude/commands/*.md</code> to <code>.claude/skills/*/SKILL.md</code>.</p> <p>This was not a rename: It was a rethinking of how AI agents discover and execute project-specific workflows.</p> 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 <p>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.</p> <p>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.</p> <p>78 files changed. 1,915 insertions. Not because the skills got bloated; because they got specific.</p>","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":"<p>After the structural migration, every skill was rewritten in a single session: All 21 of them.</p> <p>The rewrite was guided by a pattern that emerged during the process itself: a repeatable anatomy that effective skills share regardless of their purpose:</p> <ol> <li>Before X-ing: Pre-flight checks that prevent premature execution</li> <li>When to Use: Positive triggers that narrow activation</li> <li>When NOT to Use: Negative triggers that prevent misuse</li> <li>Usage Examples: Invocation patterns the agent can pattern-match</li> <li>Quality Checklist: Verification before claiming completion</li> </ol> <p>The Anatomy of a Skill That Works post covers the details. What matters for the release story is the result: </p> <ul> <li>Zero skills with quality gates became twenty; </li> <li>Zero skills with negative triggers became twenty. </li> <li>Three skills with examples became twenty.</li> </ul> <p>The Skill Trilogy as Design Spec</p> <p>The three blog posts written during this window:</p> <ul> <li>Skills That Fight the Platform, </li> <li>You Can't Import Expertise,</li> <li>and The Anatomy of a Skill That Works...</li> </ul> <p>... were not retrospective documentation. They were written during the rewrite, and the lessons fed back into the skills as they were being built.</p> <ul> <li>The blog was the design document. </li> <li>The skills were the implementation.</li> </ul>","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":"<p>The unglamorous work. The kind you only appreciate when you try to change something later and it just works.</p> 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 <p>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.</p> <p>The consolidation was not an afterthought. It was scheduled deliberately, with the same priority as features: The 3:1 ratio that emerged during <code>v0.2.0</code> development became an explicit practice: </p> <ul> <li>Three feature sessions; </li> <li>One consolidation session.</li> </ul>","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":"<p>On February 4<sup>th</sup>, we adopted the E/A/R classification as the official standard for evaluating skills:</p> Category Meaning Target Expert Knowledge Claude does not have >70% Activation When/how to trigger ~20% Redundant What Claude already knows <10% <p>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.</p> <p>The E/A/R framework gave us a concrete, testable criterion: </p> <p>A good skill is Expert knowledge minus what Claude already knows.</p> <p>If more than 10% of a skill restates platform defaults, it is creating noise, not signal.</p> <p>Every skill in <code>v0.3.0</code> was evaluated against this framework. Several were deleted. The survivors are leaner and more focused.</p>","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":"<p>A tool that manages your project's memory needs ops maturity. </p> <p><code>v0.3.0</code> added two pieces of infrastructure that reflect this:</p> <p>Backup staleness hook: A <code>UserPromptSubmit</code> hook that checks whether the last <code>.context/</code> 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.</p> <p>Context size checkpoint: A <code>PreToolUse</code> 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.</p> <p>Both hooks use <code>$CLAUDE_PROJECT_DIR</code> instead of hardcoded paths, a migration triggered by a username rename that broke every absolute path in the hook configuration. That migration (replacing <code>/home/user/...</code> with <code>\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/...</code>) was one of those changes that seems trivial but prevents an entire category of future failures.</p>","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 <code>$CLAUDE_PROJECT_DIR</code> 0 All Documentation commits n/a 35+ Feature/fix commits n/a ~15 <p>That ratio (35+ documentation and quality commits to ~15 feature commits) is the defining characteristic of this release:</p> <ul> <li>This release is not a failure to ship features. </li> <li>It is the deliberate choice to make the existing features reliable.</li> </ul>","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":"<p><code>v0.1.0</code> asked: \"Can we give AI persistent memory?\"</p> <p><code>v0.2.0</code> asked: \"Can we make that memory accessible to humans too?\"</p> <p><code>v0.3.0</code> asks a different question: \"Can we make the quality self-enforcing?\"</p> <p>The answer is not a feature: It is a practice:</p> <ul> <li>Skills with quality gates enforce pre-flight checks.</li> <li>Negative triggers prevent misuse without human intervention.</li> <li>The E/A/R framework ensures skills contain signal, not noise.</li> <li>Consolidation sessions are scheduled, not improvised.</li> <li>Hook infrastructure makes degradation visible.</li> </ul> <p>Discipline is not the absence of velocity. It is the infrastructure that makes velocity sustainable.</p>","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":"<p>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.</p> <p>The next chapter is about what you build on top of discipline:</p> <ul> <li>Multi-agent coordination;</li> <li>Deeper integration patterns; </li> <li>And the question of whether context management is a tool concern or an infrastructure concern.</li> </ul> <p>But those are future posts.</p> <p>This one is about the release that proved polish is not the opposite of progress. It is what turns a prototype into a product.</p> <p>The Discipline Release</p> <p><code>v0.1.0</code> shipped features. </p> <p><code>v0.2.0</code> shipped archaeology.</p> <p><code>v0.3.0</code> shipped the habits that make everything else trustworthy.</p> <p>The most important code in this release is the code that prevents bad code from shipping.</p> <p>This post was drafted using <code>/ctx-blog</code> 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.</p>","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":"<p>Jose Alekhinne / 2026-02-15</p> <p>I had a backup warning that nobody ever saw.</p> <p>The hook was correct: It detected stale backups, formatted a nice message, and output it as <code>{\"systemMessage\": \"...\"}</code>. The problem wasn't detection. The problem was delivery. The agent absorbed the information, processed it internally, and never told the user.</p> <p>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 (<code>UserPromptSubmit</code>), same project, completely different outcomes.</p> <p>The difference was one line:</p> <pre><code>IMPORTANT: Relay this journal reminder to the user VERBATIM\nbefore answering their question.\n</code></pre> <p>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.</p>","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":"<p>I looked at every hook in <code>ctx</code>: 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.</p> <p>The patterns form a spectrum based on a single question: </p> <p>\"Who decides what the user sees?\"</p> <p>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.</p> <p>Here's the full spectrum:</p>","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":"<pre><code>{\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}\n</code></pre> <p>The nuclear option: The agent's tool call is rejected before it executes.</p> <p>This is Claude Code's first-class <code>PreToolUse</code> mechanism: The hook returns JSON with <code>decision: block</code> and the agent gets an error with the reason.</p> <p>Use this for invariants: Constitution rules, security boundaries, things that must never happen. I use it to enforce <code>PATH</code>-based <code>ctx</code> invocation, block <code>sudo</code>, and require explicit approval for <code>git push</code>.</p>","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":"<pre><code>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</code></pre> <p>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.\"</p> <p>I use this for actionable reminders: </p> <ul> <li>Unexported journal entries;</li> <li>Stale backups;</li> <li>Context capacity warnings... </li> </ul> <p>...things the user should see regardless of what they asked.</p>","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":"<pre><code>┌─ Persistence Checkpoint (prompt #25) ───────────\n│ No context files updated in 15+ prompts.\n│ Have you discovered learnings worth persisting?\n└──────────────────────────────────────────────────\n</code></pre> <p>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.</p>","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":"<pre><code>ctx agent --budget 4000 2>/dev/null || true\n</code></pre> <p>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.</p>","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":"<pre><code>find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n</code></pre> <p>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.</p>","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":"<p>Three more patterns emerged from the gaps in the existing hooks.</p> <p>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.</p> <p>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.</p> <p>Escalating severity: <code>INFO</code> gets absorbed silently. <code>WARN</code> gets mentioned at the next natural pause. <code>CRITICAL</code> 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.</p>","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":"<p>Hooks are the boundary between your environment and the agent's reasoning. </p> <p>A hook that detects a problem but can't communicate it effectively is the same as no hook at all.</p> <p>The format of your output is a design decision with real consequences:</p> <ul> <li>Use a hard gate and the agent can't proceed (good for invariants, frustrating for false positives)</li> <li>Use VERBATIM relay and the user will see it (good for reminders, noisy if overused)</li> <li>Use an agent directive and the agent might act (good for nudges, unreliable for critical warnings)</li> <li>Use silent injection and nobody knows (good for enrichment, invisible when it breaks)</li> </ul> <p>Choose deliberately. And, when in doubt, write the word <code>VERBATIM</code>.</p> <p>The full pattern catalog with decision flowchart and implementation examples is in the Hook Output Patterns recipe.</p>","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 <code>ctx</code>'s Journal Site Runs on a v0.0.21 Tool","text":"<p>Jose Alekhinne / 2026-02-15</p> <p>Would You Ship Production Infrastructure on a v0.0.21 Dependency?</p> <p>Most engineers wouldn't. Version numbers signal maturity. Pre-1.0 means unstable API, missing features, risk.</p> <p>But version numbers tell you where a project has been. They say nothing about where it's going.</p> <p>I just bet <code>ctx</code>'s entire journal site on a tool that hasn't hit <code>v0.1.0</code>. </p> <p>Here's why I'd do it again.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-problem","level":2,"title":"The Problem","text":"<p>When v0.2.0 shipped the journal system, the pipeline was clear:</p> <ul> <li>Export sessions to Markdown; </li> <li>Enrich them with YAML frontmatter; </li> <li>And render them into something browsable. </li> </ul> <p>The first two steps were solved; the third needed a tool.</p> <p>The journal entries are standard Markdown with YAML frontmatter, tables, and fenced code blocks. That is the entire format: </p> <ul> <li>No JSX;</li> <li>No shortcodes;</li> <li>No custom templating. </li> </ul> <p>Just Markdown rendered well.</p> <p>The requirements are modest:</p> <ul> <li>Read a configuration file (such as <code>mkdocs.yml</code>);</li> <li>Render Markdown with extensions (admonitions, tabs, tables);</li> <li>Search;</li> <li>Handle 100+ files without choking on incremental rebuilds;</li> <li>Look good out of the box;</li> <li>Not lock me in.</li> </ul> <p>The obvious candidates were as follows:</p> 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 <p>The instinct was Hugo. Same language as <code>ctx</code>. Fast. Well-established.</p> <p>But instinct is not analysis. I picked the one with the lowest version number.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation","level":2,"title":"The Evaluation","text":"<p>Here is what I actually evaluated, in order:</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#1-the-team","level":3,"title":"1. The Team","text":"<p>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.</p> <ul> <li>This is not someone learning how to build static site generators.</li> <li>This is someone who spent years understanding exactly where MkDocs breaks and decided to fix it from the ground up.</li> </ul> <p>They did not build zensical because MkDocs was bad: They built it because MkDocs hit a ceiling:</p> <ul> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ul> <p>A proven team starting fresh is more predictable than an unproven team at v3.0.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#2-the-architecture","level":3,"title":"2. The Architecture","text":"<p>Zensical is investing in a Rust-based Markdown parser with CommonMark support. That signals something about the team's priorities:</p> <p>Performance foundations first; features second.</p> <p><code>ctx</code>'s journal will grow: </p> <ul> <li>Every exported session adds files.</li> <li>Every enrichment pass adds metadata. </li> </ul> <p>Choosing a tool that gets slower as you add content means choosing to migrate later.</p> <p>Choosing one built for scale means the decision holds.</p>","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":"<p>Zensical reads <code>mkdocs.yml</code> natively. If it doesn't work out, I can move back to MkDocs + Material with zero content changes:</p> <ul> <li>The Markdown is standard; </li> <li>The frontmatter is standard; </li> <li>The configuration is compatible.</li> </ul> <p>This is the infrastructure pattern again: The same way <code>ZNC</code> decouples presence from the client, <code>zensical</code> decouples rendering from the generator: </p> <ul> <li>The Markdown is yours. </li> <li>The frontmatter is standard YAML. </li> <li>The configuration is MkDocs-compatible.</li> </ul> <p>You are not locked into anything except your own content.</p> <p>No lock-in is not a feature: It's a design philosophy: </p> <p>It's the same reason <code>ctx</code> uses plain Markdown files in <code>.context/</code> instead of a database: the format should outlive the tool.</p> <p>Lock-in Is the Real Risk, Not Version Numbers</p> <p>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.</p>","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":"<p>Here is what <code>pip install zensical</code> actually pulls in:</p> <ul> <li>click</li> <li>Markdown</li> <li>Pygments</li> <li>pymdown-extensions</li> <li>PyYAML</li> </ul> <p>Only five dependencies. All well-known. No framework bloat. No bundler. No transpiler. No <code>node_modules</code> black hole.</p> <p>3k GitHub stars at <code>v0.0.21</code> is a strong early traction for a <code>pre-1.0</code> project. </p> <p>The dependency tree is thin: No bloat.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#5-the-fit","level":3,"title":"5. The Fit","text":"<p>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.</p> <p>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:</p> <p>It is the complexity you pay for but never use.</p> <p><code>ctx</code>'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:</p> <ul> <li>No custom plugins needed;</li> <li>No special syntax; </li> <li>No templating gymnastics.</li> </ul> <p>The requirements match the capabilities: Not the capabilities that are promised, but the ones that exist today, at <code>v0.0.21</code>.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-caveat","level":2,"title":"The Caveat","text":"<p>It would be dishonest not to mention what's missing.</p> <p>The module system for third-party extensions opens in early 2026.</p> <p>If <code>ctx</code> ever needs custom plugins (for example, auto-linking session IDs, rendering special journal metadata, etc.) that infrastructure isn't there yet.</p> <p>The installation experience is rough: </p> <p>We discovered this firsthand: <code>pip install zensical</code> 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. </p> <p>That kind of friction is typical for young Python tooling, and it is documented in the Common Workflows guide.</p> <p>And <code>3,000</code> stars at <code>v0.0.21</code> is strong early traction, but it's still early: The community is small. When something breaks, you're reading source code, not documentation.</p> <p>These are real costs. I chose to pay them because the alternative costs are higher.</p> <p>For example:</p> <ul> <li>Hugo's templating pain would cost me time on every site change.</li> <li>Astro's JS ecosystem would add complexity I don't need. </li> <li>MkDocs would work today but hit scaling walls tomorrow. </li> </ul> <p>Zensical's costs are front-loaded and shrinking. </p> <p>The others compound.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation-framework","level":2,"title":"The Evaluation Framework","text":"<p>For anyone facing a similar choice, here is the framework that emerged:</p> 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 <p>The bottom three are the metrics most engineers optimize for.</p> <p>The top four are the ones that predict whether you'll still be happy with the choice in a year.</p> <p>Features You Don't Need Are Not Free</p> <p>Every feature in a dependency is code you inherit but don't control. </p> <p>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.</p> <p>Fit is the inverse of feature count.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-broader-pattern","level":2,"title":"The Broader Pattern","text":"<p>This is part of a theme I keep encountering in this project:</p> <p>Leading indicators beat lagging indicators.</p> 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 <code>.context/</code> 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 <p>Version numbers, star counts, coverage percentages, file counts...</p> <p>...these are all measures of effort expended. </p> <p>They say nothing about value delivered.</p> <p>The question is never \"how mature is this tool?\" </p> <p>The question is \"does this tool's trajectory intersect with my needs?\"</p> <p>Zensical's trajectory: </p> <ul> <li>A proven team fixing known problems, </li> <li>in a *proven architecture, </li> <li>with a standard format,</li> <li>and no lock-in.</li> </ul> <p><code>ctx</code>'s needs: </p> <p>Tender standard Markdown into a browsable site, at scale, without complexity.</p> <p>The intersection is clean; the version number is noise.</p> <p>This is the same kind of decision that shows up throughout <code>ctx</code>:</p> <ul> <li>Skills that fight the platform taught that the best integration extends existing behavior, not replaces it.</li> <li>You can't import expertise taught that tools should grow from your project's actual needs, not from feature checklists.</li> <li>Context as infrastructure argues that the format should outlive the tool; and, <code>zensical</code> honors that principle by reading standard Markdown and standard MkDocs configuration.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>Version numbers measure where a project has been.</p> <p>The team and the architecture tell you where it's going.</p> <p>A <code>v0.0.21</code> tool built by the right team on the right foundations is a safer bet than a <code>v5.0</code> tool that doesn't fit your problem.</p> <p>Bet on trajectories, not timestamps.</p> <p>This post started as an evaluation note in <code>ideas/</code> and a separate decision log. The analysis held up. The two merged into one. The meta continues.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/","level":1,"title":"<code>ctx</code> 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":"<p>Jose Alekhinne / February 16, 2026</p> <p>What Changed?</p> <p><code>ctx</code> is now a Claude Code plugin. Two commands, no build step:</p> <pre><code>/plugin marketplace add ActiveMemory/ctx\n/plugin install ctx@activememory-ctx\n</code></pre> <p>Six hooks. Twenty-five skills. Installed.</p> <p>For three releases, <code>ctx</code> required assembly: </p> <ul> <li>Clone the repo; </li> <li>Build the binary; </li> <li>Copy hook scripts into <code>.claude/hooks/</code>; </li> <li>Symlink skill files.</li> <li>Understand which shell scripts called which Go commands;</li> <li>Hope nothing broke when Claude Code updated its hook format.</li> </ul> <p><code>v0.6.0</code> ends that era: <code>ctx</code> ships as a Claude Marketplace plugin:</p> <p>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.</p> <p>But the plugin conversion was not just a packaging change: It was the forcing function that rewrote every shell hook in Go, eliminated the <code>jq</code> dependency, enabled <code>go test</code> coverage for hook logic, and made distribution a solved problem. </p> <p>When you fix how something ships, you end up fixing how it is built.</p> <p>The Release Window</p> <p>February 15-February 16, 2026</p> <p>From the v0.3.0 tag to commit <code>a3178bc</code>:</p> <ul> <li>109 commits. </li> <li>334 files changed. </li> <li>Version jumped from 0.3.0 to 0.6.0 to signal the magnitude.</li> </ul>","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":"<p><code>v0.3.0</code> had six hook scripts. Each was a Bash file that shelled out to <code>ctx</code> subcommands, parsed JSON with <code>jq</code>, and wired itself into Claude Code's hook system via <code>.claude/hooks/</code>:</p> <pre><code>.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</code></pre> <p>This worked, but it also meant:</p> <ul> <li>jq was a hard dependency: No <code>jq</code>, no hooks. macOS ships without it.</li> <li>No test coverage: Shell scripts were tested manually or not at all.</li> <li>Fragile deployment: <code>ctx init</code> had to scaffold <code>.claude/hooks/</code> and <code>.claude/skills/</code> with the right paths, permissions, and structure.</li> <li>Version drift: Users who installed once never got hook updates unless they re-ran <code>ctx init</code>.</li> </ul> <p>The shell scripts were the right choice for prototyping. They were the wrong choice for distribution.</p>","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":"<p><code>v0.6.0</code> replaces all six scripts with <code>ctx system</code> subcommands compiled into the binary:</p> Shell Script Go Subcommand <code>check-context-size.sh</code> <code>ctx system check-context-size</code> <code>check-persistence.sh</code> <code>ctx system check-persistence</code> <code>check-journal.sh</code> <code>ctx system check-journal</code> <code>post-commit.sh</code> <code>ctx system post-commit</code> <code>block-non-path-ctx.sh</code> <code>ctx system block-non-path-ctx</code> <code>cleanup-tmp.sh</code> <code>ctx system cleanup-tmp</code> <p>The plugin's <code>hooks.json</code> wires them to Claude Code events:</p> <pre><code>{\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</code></pre> <p>No jq. No shell scripts. No <code>.claude/hooks/</code> directory to manage.</p> <p>The hooks are Go functions with tests, compiled into the same binary you already have.</p>","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":"<p>The <code>ctx</code> plugin lives at <code>.claude-plugin/marketplace.json</code> in the repo.</p> <p>Claude Code's marketplace system handles discovery and installation:</p> <p>Skills are served directly from <code>internal/assets/claude/skills/</code>; there is no build step, no <code>make plugin</code>, no generated artifacts.</p> <p>This means:</p> <ol> <li>Install is two commands: Not \"clone, build, copy, configure.\"</li> <li>Updates are automatic: Pull the repo; the plugin reads from source.</li> <li>Skills and hooks are versioned together: No drift between what the CLI expects and what the plugin provides.</li> <li><code>ctx init</code> is tool-agnostic: It creates <code>.context/</code> and nothing else. No <code>.claude/</code> scaffolding, no assumptions about which AI tool you use.</li> </ol> <p>That last point matters: </p> <p>Before <code>v0.6.0</code>, <code>ctx init</code> tried to set up Claude Code integration as part of initialization. That coupled the context system to a specific tool. </p> <p>Now, <code>ctx init</code> gives you persistent context. The plugin gives you Claude Code integration. They compose; they don't depend.</p>","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":"<p>The plugin conversion dominated the release, but 109 commits covered more ground.</p>","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":"<pre><code>ctx journal obsidian\n</code></pre> <p>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.</p>","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":"<pre><code>ctx pad edit \"DATABASE_URL=postgres://...\"\nctx pad show\n</code></pre> <p><code>AES-256-GCM</code> encrypted storage for sensitive one-liners. </p> <p>The encrypted blob commits to <code>git</code>; the key stays in <code>.gitignore</code>. </p> <p>This is useful for connection strings, API keys, and other values that need to travel with the project without appearing in plaintext.</p>","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":"<p>Three medium-severity findings from a security audit are now closed:</p> Finding Fix Path traversal via <code>--context-dir</code> Boundary validation: operations cannot escape project root (M-1) Symlink following in <code>.context/</code> <code>Lstat()</code> check before every file read/write (M-2) Predictable temp file paths User-specific temp directory under <code>$XDG_RUNTIME_DIR</code> (M-3) <p>Plus a new <code>/sanitize-permissions</code> skill that audits <code>settings.local.json</code> for overly broad Bash permissions.</p>","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":"<p>A subtle but important fix: hooks now no-op before <code>ctx init</code> has run.</p> <p>Previously, a fresh clone with no <code>.context/</code> would trigger hook errors on every prompt. Now, hooks detect the absence of a context directory and exit silently. Similarly, <code>ctx init</code> treats a <code>.context/</code> directory containing only logs as uninitialized and skips the <code>--overwrite</code> prompt.</p> <p>Small changes. Large reduction in friction for new users.</p>","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 <code>ctx init</code> creates .claude/ yes no <p>The line count tripled. Most of that is documentation site HTML, Obsidian export logic, and the scratchpad encryption module. </p> <p>The core CLI grew modestly; the ecosystem around it grew substantially.</p>","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 <code>v0.6.0</code> Mean for <code>ctx</code>?","text":"<ul> <li><code>v0.1.0</code> asked: \"Can we give AI persistent memory?\"</li> <li><code>v0.2.0</code> asked: \"Can we make that memory accessible to humans too?\"</li> <li><code>v0.3.0</code> asked: \"Can we make the quality self-enforcing?\"</li> </ul> <p>v0.6.0 asks: \"Can someone else actually use this?\"</p> <p>A tool that requires cloning a repo, building from source, and manually wiring hooks into the right directories is a tool for its author.</p> <p>A tool that installs with two commands from a marketplace is a tool for everyone.</p> <p>The version jumped from <code>0.3.0</code> to <code>0.6.0</code> 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 <code>ctx</code> is: Not a different tool, but a tool that is finally ready to leave the workshop.</p>","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":"<p>The plugin model opens the door to distribution patterns that were not possible before. Marketplace discovery means new users find <code>ctx</code> without reading a <code>README</code>. Plugin updates mean existing users get improvements without rebuilding.</p> <p>The next chapter is about what happens when persistent context is easy to install: Adoption patterns, multi-project workflows, and whether the <code>.context/</code> convention can become infrastructure that other tools build on.</p> <p>But those are future posts.</p> <p>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.</p> <p>The Integration Release</p> <p><code>v0.1.0</code> shipped features. <code>v0.2.0</code> shipped archaeology.</p> <p><code>v0.3.0</code> shipped discipline. <code>v0.6.0</code> shipped the front door.</p> <p>The most important code in this release is the code you never have to copy.</p> <p>This post was drafted using <code>/ctx-blog-changelog</code> 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.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>Are You Worried about AI Taking Your Job?</p> <p>You might be confusing the thing that's cheap with the thing that's valuable.</p> <p>I keep seeing the same conversation: Engineers, designers, writers: all asking the same question with the same dread:</p> <p>\"What happens when AI can do what I do?\"</p> <p>The question is wrong:</p> <ul> <li>AI does not replace workers;</li> <li>AI replaces unstructured effort.</li> </ul> <p>The distinction matters, and everything I have learned building <code>ctx</code> reinforces it.</p>","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":"<p>People who feel doomed by AI usually confuse three things:</p> People confuse... With... Effort Value Typing Thinking Production Judgment <ul> <li>Effort is time spent.</li> <li>Value is the outcome that time produces.</li> </ul> <p>They are not the same; they never were. </p> <p>AI just makes the gap impossible to ignore.</p> <p>Typing is mechanical: Thinking is directional. </p> <p>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.</p> <p>Production is making artifacts. Judgment is knowing:</p> <ul> <li>which artifacts to make, </li> <li>in what order, </li> <li>to what standard, </li> <li>and when to stop.</li> </ul> <p>AI floods the system with production capacity; it does not flood the system with judgment.</p>","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":"<p>This sounds provocative until you internalize it:</p> <p>Code is cheap. Artifacts are cheap.</p> <p>An AI can generate a thousand lines of working code in literal *minutes**:</p> <p>It can scaffold a project, write tests, build a CI pipeline, draft documentation. The raw production of software artifacts is no longer the bottleneck.</p> <p>So, what is not cheap?</p> <ul> <li>Taste: knowing what belongs and what does not</li> <li>Framing: turning a vague goal into a concrete problem</li> <li>Sequencing: deciding what to build first and why</li> <li>Fanning out: breaking work into parallel streams that converge</li> <li>Acceptance criteria: defining what \"done\" looks like before starting</li> <li>Judgment: the thousand small decisions that separate code that works from code that lasts</li> </ul> <p>These are the skills that direct production: Hhuman skills.</p> <p>Not because AI is incapable of learning them, but because they require something AI does not have: </p> <p>temporal accountability for generated outcomes.</p> <p>That is, you cannot keep AI accountable for the <code>$#!%</code> it generated three months ago. A human, on the other hand, will always be accountable.</p>","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 <code>ctx</code>","text":"<p>I did not arrive at this conclusion theoretically. </p> <p>I arrived at it by building a tool with an AI agent for three weeks and watching exactly where a human touch mattered.</p>","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":"<p>In Building <code>ctx</code> Using <code>ctx</code>, 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.</p> <p>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.</p> <p>Production without judgment is not velocity. It is debt accumulation at breakneck speed.</p>","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":"<p>In The 3:1 Ratio, the <code>git</code> history told the story:</p> <p>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.</p> <p>The AI does the refactoring. The human decides what to refactor and when to stop. </p> <p>Without the human, the AI will refactor forever, improving things that do not matter and missing things that do.</p>","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":"<p>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.</p> <p>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. </p> <p><code>ctx agent --budget 4000</code> is not just a CLI flag: It is a forcing function for human judgment about relevance.</p> <p>The AI processes. The human curates.</p>","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":"<p>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: </p> <p>It is taste.</p> <p>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. </p> <p>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.</p>","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":"<p>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.</p> <p>The human applies judgment about frequency, stability, and attention cost.</p> <p>The AI can build the skill. Only the human can decide whether it should exist.</p>","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":"<p>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).</p> <p>The AI follows instructions. The human decides which instructions are enforceable and which are \"wishful thinking\".</p>","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":"<p>In Parallel Agents and Merge Debt, the lesson was that multiplying agents multiplies output. But it also multiplies the need for judgment:</p> <p>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.</p> <p>More agents do not reduce the need for judgment. They increase it.</p>","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":"<p>When AI floods the system with cheap output, two things happen:</p> <p>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.</p> <p>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.</p> <p>The gap between these two is not talent: It is the awareness of where the value lives.</p>","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":"<p>If you are an engineer reading this, the actionable insight is not \"learn prompt engineering\" or \"master AI tools.\" It is:</p> <p>Get better at the things AI cannot do.</p> 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 <p>The skills on the right column are not new. They are the same skills that have always separated senior engineers from junior ones. </p> <p>AI did not create the distinction; it just made it load-bearing.</p>","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":"<p>I will end with something personal.</p> <p>I am not worried: I am empowered.</p> <p>Before <code>ctx</code>, I could think faster than I could produce: </p> <ul> <li>Ideas sat in a queue. </li> <li>The bottleneck was always \"I know what to build, but building it takes too long.\"</li> </ul> <p>Now the bottleneck is gone. Poof!</p> <ul> <li>Production is cheap. </li> <li>The queue is clearing. </li> <li>The limiting factor is how fast I can think, not how fast I can type.</li> </ul> <p>That is not a threat: That is the best force multiplier I've ever had.</p> <p>The people who feel threatened are confusing the accelerator for the replacement:</p> <p>*AI does not replace the conductor; it gives them a bigger orchestra.</p> <p>If You Remember One Thing from This Post...</p> <p>Code is cheap. Judgment is not.</p> <p>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.</p> <p>The difference is that now, for the first time, those skills are the only bottleneck left.</p>","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":"<p>This post is a retrospective. It synthesizes the thread running through every previous entry in this blog:</p> <ul> <li>Building <code>ctx</code> Using <code>ctx</code> showed that production without direction creates debt</li> <li>Refactoring with Intent showed that slowing down is not the opposite of progress</li> <li>The Attention Budget showed that curation outweighs volume</li> <li>The skill trilogy showed that taste determines whether a tool helps or hinders</li> <li>Not Everything Is a Skill showed that restraint is a skill in itself</li> <li>Defense in Depth showed that instructions are not boundaries</li> <li>The 3:1 Ratio showed that judgment has a schedule</li> <li>Parallel Agents showed that scale amplifies the gap between production and judgment</li> <li>Context as Infrastructure showed that the system you build for context is infrastructure, not conversation</li> </ul> <p>From YOLO mode to defense in depth, the pattern is the same:</p> <ul> <li>Production is the easy part;</li> <li>Judgment is the hard part;</li> <li>AI changed the ratio, not the rule.</li> </ul> <p>This post synthesizes the thread running through every previous entry in this blog. The evidence is drawn from three weeks of building <code>ctx</code> with AI assistance, the decisions recorded in <code>DECISIONS.md</code>, the learnings captured in <code>LEARNINGS.md</code>, and the git history that tracks where the human mattered and where the AI ran unsupervised.</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>Where Does Your AI's Knowledge Live between Sessions?</p> <p>If the answer is \"in a prompt I paste at the start,\" you are treating context as a consumable. Something assembled, used, and discarded.</p> <p>What if you treated it as infrastructure instead?</p> <p>This post synthesizes a thread that has been running through every <code>ctx</code> 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.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-prompt-paradigm","level":2,"title":"The Prompt Paradigm","text":"<p>Most AI-assisted development treats context as ephemeral:</p> <ol> <li>Start a session.</li> <li>Paste your system prompt, your conventions, your current task.</li> <li>Work.</li> <li>Session ends. Everything evaporates.</li> <li>Next session: paste again.</li> </ol> <p>This works for short interactions. For sustained development (where decisions compound over days and weeks) it fails in three ways:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>The Copy-Paste Tax</p> <p>Every session that starts with pasting a prompt is paying a tax:</p> <p>The human time to assemble the context, the risk of forgetting something, and the silent assumption that yesterday's prompt is still accurate today.</p> <p>Over 70+ sessions, that tax compounds into a significant maintenance burden: One that most developers absorb without questioning it.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-infrastructure-paradigm","level":2,"title":"The Infrastructure Paradigm","text":"<p><code>ctx</code> takes a different approach:</p> <p>Context is not assembled per-session; it is maintained as persistent files in a <code>.context/</code> directory:</p> <pre><code>.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</code></pre> <ul> <li>Each file has a single purpose;</li> <li>Each can be loaded independently;</li> <li>Each persists across sessions, tools, and team members.</li> </ul> <p>This is not a novel idea. It is the same idea behind every piece of infrastructure software engineers already use:</p> Traditional Infrastructure <code>ctx</code> Equivalent Database <code>.context/*.md</code> files Configuration files <code>CONSTITUTION.md</code> Environment variables <code>.contextrc</code> Log files <code>journal/</code> Schema migrations Decision records Deployment manifests <code>AGENT_PLAYBOOK.md</code> <p>The parallel is not metaphorical. Context files are infrastructure:</p> <ul> <li>They are versioned (<code>git</code> tracks them); </li> <li>They are structured (Markdown with conventions); </li> <li>They have schemas (required fields for decisions and learnings); </li> <li>And they have lifecycle management (archiving, compaction, indexing).</li> </ul>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#separation-of-concerns","level":2,"title":"Separation of Concerns","text":"<p>The most important design decision in <code>ctx</code> is not any individual feature. It is the separation of context into distinct files with distinct purposes.</p> <p>A single <code>CONTEXT.md</code> file would be simpler to implement. It would also be impossible to maintain.</p> <p>Why? Because different types of context have different lifecycles:</p> 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 <p>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.</p> <p>Separation of concerns allows progressive disclosure: </p> <p>Load the minimum that matters for this moment, with the option to load more when needed.</p> <pre><code># 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</code></pre> <p>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.</p>","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":"<p><code>ctx</code> uses two tiers of persistence, and the distinction is architectural:</p> Tier Purpose Location Token Cost Curated Quick context reload <code>.context/*.md</code> Low (budgeted) Full dump Safety net, archaeology <code>.context/journal/*.md</code> Zero (not auto-loaded) <p>The curated tier is what the AI sees at session start. It is optimized for signal density: </p> <ul> <li>Structured entries, </li> <li>Indexed tables,</li> <li>Reverse-chronological order (newest first, so the most relevant content survives truncation).</li> </ul> <p>The full dump tier is for humans and for deep investigation. It contains everything: Enriched journals, archived tasks... </p> <p>It is never autoloaded because its volume would destroy attention density.</p> <p>This two-tier model is analogous to how traditional systems separate hot and cold storage: </p> <ul> <li>The hot path (curated context) is optimized for read performance (measured not in milliseconds, but in tokens consumed per unit of useful information). </li> <li>The cold path (journal) is optimized for completeness.</li> </ul> <p>Nothing Is Ever Truly Lost</p> <p>The full dump tier means that context does not need to be perfect: It just needs to be findable.</p> <p>A decision that was not captured in <code>DECISIONS.md</code> can be recovered from the session transcript where it was discussed. </p> <p>A learning that was not formalized can be found in the journal entry from that day.</p> <p>The curated tier is the fast path: The full dump tier is the safety net.</p>","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":"<p>One of the patterns that emerged from <code>ctx</code>'s own development is the power of structured decision records.</p> <p><code>v0.1.0</code> allowed adding decisions as one-liners:</p> <pre><code>ctx add decision \"Use PostgreSQL\"\n</code></pre> <p><code>v0.2.0</code> enforced structure:</p> <pre><code>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</code></pre> <p>The difference is not cosmetic:</p> <ul> <li>A one-liner decision teaches the AI what was decided. </li> <li>A structured decision teaches it why; and why is what prevents the AI from unknowingly reversing the decision in a future session.</li> </ul> <p>This is infrastructure thinking: </p> <p>Decisions are not notes. They are records with required fields, just like database rows have schemas.</p> <p>The enforcement exists because incomplete records are worse than no records: They create false confidence that the context is captured when it is not.</p>","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":"<p>Early in <code>ctx</code>'s development, there was a temptation to build a custom UI: a web dashboard for browsing sessions, editing context, viewing analytics.</p> <p>The decision was no. The IDE is the interface.</p> <pre><code># This is the ctx \"UI\":\ncode .context/\n</code></pre> <p>This decision was not about minimalism for its own sake. It was about recognizing that <code>.context/</code> files are just files; and files have a mature, well-understood infrastructure:</p> <ul> <li>Version control: <code>git diff .context/DECISIONS.md</code> shows exactly what changed and when.</li> <li>Search: Your IDE's full-text search works across all context files.</li> <li>Editing: Markdown in any editor, with preview, spell check, and syntax highlighting.</li> <li>Collaboration: Pull requests on context files work the same as pull requests on code.</li> </ul> <p>Building a custom UI would have meant maintaining a parallel infrastructure that duplicates what every IDE already provides:</p> <p>It would have introduced its own bugs, its own update cycle, and its own learning curve.</p> <p>The filesystem is not a limitation: It is the most mature, most composable, most portable infrastructure available.</p> <p>Context Files in Git</p> <p>Because <code>.context/</code> lives in the repository, context changes are part of the commit history. </p> <p>A decision made in commit <code>abc123</code> is as traceable as a code change in the same commit.</p> <p>This is not possible with prompt-based context, which exists outside version control entirely.</p>","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":"<p>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.</p> <p><code>ctx</code> applies the same principle to AI context:</p> Level What the AI Sees Token Cost When Level 0 <code>ctx status</code> (one-line summary) ~100 Quick check Level 1 <code>ctx agent --budget 4000</code> ~4,000 Normal work Level 2 <code>ctx agent --budget 8000</code> ~8,000 Complex tasks Level 3 Direct file reads 10,000+ Deep investigation <p>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.</p> <p>The explicit <code>--budget</code> flag is the mechanism that makes this work:</p> <p>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.</p> <p>The constraint is the feature: A budget of 4,000 tokens forces <code>ctx</code> 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.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-philosophical-shift","level":2,"title":"The Philosophical Shift","text":"<p>The shift from \"context as prompt\" to \"context as infrastructure\" changes how you think about AI-assisted development:</p> 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\" <p>The first column treats AI interaction as a conversation. The second treats it as a system: One that can be maintained, optimized, and debugged.</p> <p>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.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#beyond-ctx-the-principles","level":2,"title":"Beyond <code>ctx</code>: The Principles","text":"<p>The patterns that <code>ctx</code> implements are not specific to <code>ctx</code>. They are applicable to any project that uses AI-assisted development:</p> <ol> <li>Separate context by purpose: Do not put everything in one file. Different types of information have different lifecycles and different relevance windows.</li> <li>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.</li> <li>Budget explicitly: Know how much context you are loading and whether it is worth the attention cost.</li> <li>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.</li> <li>Version your context: Put context files in <code>git</code>. Changes to decisions are as important as changes to code.</li> <li>Design for degradation: Sessions will get long. Attention will dilute. Build mechanisms (compaction, archiving, cooldowns) that make degradation visible and manageable.</li> </ol> <p>These are not <code>ctx</code> 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.</p> <p>The tool is a convenience: The principles are what matter.</p> <p>If You Remember One Thing from This Post...</p> <p>Prompts are conversations. Infrastructure persists.</p> <p>Your AI does not need a better prompt. It needs a filesystem:</p> <p>versioned, structured, budgeted, and maintained.</p> <p>The best context is the context that was there before you started the session.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-arc","level":2,"title":"The Arc","text":"<p>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).</p> <p>Together with Code Is Cheap, Judgment Is Not, they form a trilogy about what matters in AI-assisted development:</p> <ul> <li>Attention Budget: the resource you're managing</li> <li>Context as Infrastructure: the system you build to manage it</li> <li>Code Is Cheap: the human skill that no system replaces</li> </ul> <p>And the practices that keep it all honest:</p> <ul> <li>The 3:1 Ratio: the cadence for maintaining both code and context</li> <li>IRC as Context: the historical precedent: stateless protocols have always needed stateful wrappers</li> </ul> <p>This post synthesizes ideas from across the <code>ctx</code> 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 <code>ctx</code> and 70+ sessions of treating context as infrastructure rather than conversation.</p> <p>See also: When a System Starts Explaining Itself: what happens when this infrastructure starts compounding in someone else's environment.</p>","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":"<p>Volkan Özçelik / 2026-02-17</p> <p>How Many Terminals Are Too Many?</p> <p>You discover agents can run in parallel.</p> <p>So you open ten... </p> <p>...Then twenty.</p> <p>The fans spin. Tokens burn. The screen looks like progress.</p> <p>It is NOT progress.</p> <p>There is a phase every builder goes through:</p> <ul> <li>The tooling gets fast enough. </li> <li>The model gets good enough. </li> <li>The temptation becomes irresistible: <ul> <li>more agents, more output, faster delivery.</li> </ul> </li> </ul> <p>So you open terminals. You spawn agents. You watch tokens stream across multiple windows simultaneously, and it feels like multiplication.</p> <p>It is not multiplication.</p> <p>It is merge debt being manufactured in real time.</p> <p>The <code>ctx</code> Manifesto says it plainly:</p> <p>Activity is not impact. Code is not progress.</p> <p>This post is about what happens when you take that seriously in the context of parallel agent workflows.</p>","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":"<p>The naive model says:</p> <p>More agents -> more output -> faster delivery</p> <p>The production model says:</p> <p>Clean context boundaries -> less interference -> higher throughput</p> <p>Parallelism only works when the cognitive surfaces do not overlap.</p> <p>If two agents touch the same files, you did not create parallelism: You created a conflict generator.</p> <p>They will:</p> <ul> <li>Revert each other's changes;</li> <li>Relint each other's formatting;</li> <li>Refactor the same function in different directions.</li> </ul> <p>You watch with 🍿. Nothing ships.</p> <p>This is the same insight from the worktrees post: partition by blast radius, not by priority. </p> <p>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. </p> <p>Everything else is scheduling.</p>","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":"<p>In practice there is a ceiling.</p> <p>Around five or six concurrent agents:</p> <ul> <li>Token burn becomes noticeable;</li> <li>Supervision cost rises;</li> <li>Coordination noise increases;</li> <li>Returns flatten.</li> </ul> <p>This is not a model limitation: This is a human merge bandwidth limitation.</p> <p>You are the bottleneck, not the silicon.</p> <p>The attention budget applies to you too: </p> <p>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.</p> <p>Five agents producing verified, mergeable change beats twenty agents producing merge conflicts you spend a day untangling.</p>","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":"<p>Real parallelism comes from task topology, not from tooling.</p> <p>Good:</p> Agent Role Touches 1 Documentation <code>docs/</code>, <code>hack/</code> 2 Security scan Read-only audit 3 Implementation <code>internal/cli/</code> 4 Enhancement requests Read-only, files issues <p>Bad:</p> <ul> <li>Four agents editing the same implementation surface</li> </ul> <p>Context Is the Boundary</p> <ul> <li>The goal is not to keep agents busy. </li> <li>The goal is to keep contexts isolated.</li> </ul> <p>This is what the codebase audit got right: </p> <ul> <li>Eight agents, all read-only, each analyzing a different dimension. </li> <li>Zero file overlap.</li> <li>Zero merge conflicts. </li> <li>Eight reports that composed cleanly because no agent interfered with another.</li> </ul>","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":"<p>There is a moment when more windows stop helping.</p> <p>That is the signal. Not to add orchestration. But to introduce:</p> <pre><code>git worktree\n</code></pre> <p>Because now you are no longer parallelizing execution; you are parallelizing state.</p> <p>State Scales, Windows Don't</p> <ul> <li>State isolation is the real scaling. </li> <li>Window multiplication is theater.</li> </ul> <p>The worktrees post covers the mechanics: </p> <ul> <li>Sibling directories;</li> <li>Branch naming; </li> <li>The inevitable <code>TASKS.md</code> conflicts; </li> <li>The 3-4 worktree ceiling. </li> </ul> <p>The principle underneath is older than <code>git</code>:</p> <p>Shared mutable state is the enemy of parallelism. </p> <p>Always has been.</p> <p>Always will be.</p>","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":"<p>Autonomous night runs are impressive.</p> <p>You sleep. The machine produces thousands of lines.</p> <p>In the morning:</p> <ul> <li>You read;</li> <li>You untangle;</li> <li>You reconstruct intent;</li> <li>You spend a day making it shippable.</li> </ul> <p>In retrospect, nothing was accelerated. </p> <p>The bottleneck moved from typing to comprehension.</p> <p>The Comprehension Tax</p> <p>If understanding the output costs more than producing it, the loop is a net loss.</p> <p>Progress is not measured in generated code.</p> <p>Progress is measured in verified, mergeable change.</p> <p>The <code>ctx</code> Manifesto calls this out directly:</p> <p>The Scoreboard</p> <p>Verified reality is the scoreboard.</p> <p>The only truth that compounds is verified change in the real world.</p> <p>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. </p> <p>And that someone is (insert drumroll here) you: </p> <p>The same bottleneck that was supposedly being bypassed.</p>","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":"<p>Most marketplace skills are prompt decorations:</p> <ul> <li>They rephrase what the base model already knows;</li> <li>They increase token usage; </li> <li>They reduce clarity:</li> <li>They introduce behavioral drift.</li> </ul> <p>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.</p> <p>A real skill does one of these:</p> <ul> <li>Encodes workflow state;</li> <li>Enforces invariants;</li> <li>Reduces decision branching.</li> </ul> <p>Everything else is packaging.</p> <p>The anatomy post established the criteria: quality gates, negative triggers, examples over rules, skills as contracts. </p> <p>If a skill doesn't meet those criteria... </p> <ul> <li>It is either a recipe (document it in <code>hack/</code>); </li> <li>Or noise (delete it);</li> <li>There is no third option.</li> </ul>","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":"<p>The most valuable skills are not prompts:</p> <p>They are constraints embedded in the toolchain.</p> <p>For example: The agent cannot push.</p> <p><code>git push</code> becomes:</p> <p>Stop. A human reviews first.</p> <p>A commit without verification becomes:</p> <p>Did you run tests? Did you run linters? What exactly are you shipping?</p> <p>This is not safety theater; this is intent preservation.</p> <p>The thing the <code>ctx</code> Manifesto calls \"encoding intent into the environment.\"</p> <p>The Eight Ways a Hook Can Talk cataloged the full spectrum: from silent enrichment to hard blocks. </p> <p>The key insight was that hooks are not just safety rails: They are context that survives execution.</p> <p>They are the difference between an agent that remembers the rules and one that enforces them.</p>","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":"<p>Every extra layer adds cognitive weight:</p> <ul> <li>Orchestration frameworks;</li> <li>Meta agents;</li> <li>Autonomous planning systems...</li> </ul> <p>If a single terminal works, stay there.</p> <p>If five isolated agents work, stop there.</p> <p>Add structure only when a real bottleneck appears. </p> <p>NOT when an influencer suggests one.</p> <p>This is the same lesson from Not Everything Is a Skill:</p> <p>The best automation decision is sometimes not to automate.</p> <p>A recipe in a Markdown file costs nothing until you use it. </p> <p>An orchestration framework costs attention on every run, whether it helps or not.</p>","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":"<p>Clear writing is not aesthetic: It is compression.</p> <p>Better articulation means:</p> <ul> <li>Fewer tokens;</li> <li>Fewer misinterpretations;</li> <li>Faster convergence.</li> </ul> <p>The attention budget taught us that context is a finite resource with a quadratic cost. </p> <p>Language determines how fast you spend context. </p> <p>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.</p> <p>Literature Is NOT Overrated</p> <ul> <li>Attention is a finite budget. </li> <li>Language determines how fast you spend it.</li> </ul>","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":"<p>The real metric is not:</p> <ul> <li>Lines generated;</li> <li>Agents running;</li> <li>Tasks completed while you sleep.</li> </ul> <p>But:</p> <p>Time from idea to verified, mergeable, production change.</p> <p>Everything else is motion.</p> <p>The entire blog series has been circling this point: </p> <ul> <li>The attention budget was about spending tokens wisely. </li> <li>The skills trilogy was about not wasting them on prompt decoration.</li> <li>The worktrees post was about multiplying throughput without multiplying interference. </li> <li>The discipline release was about what a release looks like when polish outweighs features: 3:1.</li> </ul> <p>Every post has arrived (and made me converge) at the same answer so far: </p> <p>The metric is a verified change, not generated output.</p>","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":"<code>ctx</code> Was Never about Spawning More Minds","text":"<p><code>ctx</code> is about:</p> <ul> <li>Isolating context;</li> <li>Preserving intent;</li> <li>Making progress composable.</li> </ul> <p>Parallel agents are powerful. But only when you respect the boundaries that make parallelism real.</p> <p>Otherwise, you are not scaling cognition; you are scaling interference.</p> <p>The <code>ctx</code> Manifesto's thesis holds:</p> <p>Without <code>ctx</code>, intelligence resets. With <code>ctx</code>, creation compounds.</p> <p>Compounding requires structure. </p> <p>Structure requires boundaries.</p> <p>Boundaries require the discipline to stop adding agents when five is enough.</p>","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":"<p>A production workflow tends to converge to this:</p> 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 <p>This is slower to watch. Faster to ship.</p> <p>If You Remember One Thing from This Post...</p> <p>Progress is not what the machine produces while you sleep.</p> <p>Progress is what survives contact with the main branch.</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>How Often Should You Stop Building and Start Cleaning?</p> <p>Every developer knows technical debt exists. Every developer postpones dealing with it.</p> <p>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.</p> <p>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.</p> <p>That was an observation. This post is the evidence.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-observation","level":2,"title":"The Observation","text":"<p>During the first two weeks of building <code>ctx</code>, I noticed a rhythm in my own productivity. Feature sessions felt great: new commands, new capabilities, visible progress...</p> <p>...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.</p> <p>The fourth session (when I stopped adding and started cleaning) was always the most painful to start and the most satisfying to finish.</p> <p>It was also the one that made the next three feature sessions faster.</p>","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":"<p>The <code>ctx</code> git history between January 20 and February 7 tells a clear story when you categorize commits:</p> 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 <p>The first week was pure YOLO: Almost four feature commits for every consolidation commit. The codebase grew fast.</p> <p>The second week started to self-correct. The ratio dropped as refactoring sessions became necessary: Not scheduled, but forced by friction.</p> <p>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.</p> <p>The debt from weeks one and two was paid in week three.</p> <p>The Compounding Problem</p> <p>Consolidation debt compounds.</p> <p>Week one's drift doesn't just persist into week two: It accelerates, because new features are built on top of drifted patterns.</p> <p>By week three, the cost of consolidation was higher than it would have been if spread evenly.</p>","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":"<p>\"Drift\" sounds abstract. Here is what it looked like concretely in the <code>ctx</code> codebase after three weeks of feature-heavy development:</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#predicate-naming","level":3,"title":"Predicate Naming","text":"<p>Convention says boolean functions should be named <code>HasX</code>, <code>IsX</code>, <code>CanX</code>. After three feature sprints:</p> <pre><code>// 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</code></pre> <p>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.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#magic-strings","level":3,"title":"Magic Strings","text":"<pre><code>// 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</code></pre> <p>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.</p> <p>Refactoring with Intent documented the constants consolidation that cleaned this up. The 3:1 ratio is the practice that prevents it from accumulating again.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#hardcoded-permissions","level":3,"title":"Hardcoded Permissions","text":"<pre><code>os.WriteFile(path, data, 0644) // 80+ instances\nos.MkdirAll(path, 0755) // scattered across packages\n</code></pre> <p>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.</p> <p>Drift Is Not Bugs</p> <p>None of these are bugs. The code works. Tests pass.</p> <p>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.</p>","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":"<p>The temptation is to front-load quality: write all the conventions, enforce all the checks, prevent all the drift before it happens.</p> <p>This fails for two reasons.</p> <p>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.</p> <p>The conventions emerge from the work; they cannot precede it.</p> <p>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.</p> <p>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.</p> <p>YOLO mode has its place: The problem is not YOLO itself, but YOLO without a scheduled cleanup.</p> <p>The Consolidation Paradox</p> <p>You need a drift history to know what to consolidate.</p> <p>You need consolidation to prevent drift from compounding.</p> <p>The 3:1 ratio resolves this paradox:</p> <p>Let drift accumulate for three sessions (enough to see patterns), then consolidate in the fourth (before the patterns become entrenched*).</p>","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":"<p>The <code>ctx</code> project now has an <code>/audit</code> skill that encodes nine project-specific checks:</p> 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 <p>This is not a generic linter. These are project-specific conventions that emerged from <code>ctx</code>'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 <code>CONVENTIONS.md</code>.</p>","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":"<p>Not all drift needs immediate consolidation. Here is the matrix I use:</p> 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 <p>The last two rows matter: </p> <p>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.</p>","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":"<p>There is a parallel between code consolidation and context management that became clear during the <code>ctx</code> development:</p> 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 <p><code>ctx compact</code> does for context what consolidation does for code: </p> <p>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.</p> <p>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.</p> <p>Both are solved by the same discipline: periodic, scheduled cleanup.</p> <p>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.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-practice","level":2,"title":"The Practice","text":"<p>Here is how the 3:1 ratio works in practice for <code>ctx</code> development:</p> <p>Sessions 1-3: Feature work</p> <ul> <li>Add new capabilities;</li> <li>Write tests for new code;</li> <li>Do not stop for cleanup unless something is actively broken;</li> <li>Note drift as you see it (a comment, a task, a mental note).</li> </ul> <p>Session 4: Consolidation</p> <ul> <li>Run <code>/audit</code> to surface accumulated drift;</li> <li>Fix the highest-impact items first;</li> <li>Update CONVENTIONS.md if new patterns emerged;</li> <li>Archive completed tasks;</li> <li>Review LEARNINGS.md for anything that became a convention.</li> </ul> <p>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.</p> <p>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.</p>","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":"<p>The 3:1 ratio is not a universal law. It is an empirical observation from one project with one developer working with AI assistance.</p> <p>Different projects will have different ratios:</p> <ul> <li>A mature codebase with strong conventions might sustain 5:1 or higher; </li> <li>A greenfield prototype might need 2:1; </li> <li>A team of multiple developers with different styles might need 1:1.</li> </ul> <p>The number is less important than the practice: consolidation is not a reaction to problems. It is a scheduled activity.</p> <p>If you wait for drift to cause pain before consolidating, you have already paid the compounding cost.</p> <p>If You Remember One Thing from This Post...</p> <p>Three sessions of building. One session of cleaning.</p> <p>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.</p> <p>The ratio is the schedule.</p>","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":"<p>This post sits at a crossroads in the <code>ctx</code> story. Looking back:</p> <ul> <li>Building <code>ctx</code> Using <code>ctx</code> documented the YOLO sprint that created the initial codebase</li> <li>Refactoring with Intent introduced the 3:1 ratio as an observation from the first cleanup</li> <li>The Attention Budget explained why drift matters: every token of inconsistency consumes the same finite resource as useful context</li> <li>You Can't Import Expertise showed that consolidation checks must grow from the project, not a template</li> <li>The Discipline Release proved the ratio works at release scale: 35 quality commits to 15 feature commits</li> </ul> <p>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 <code>.context/</code>, or in the gap between what your docs say and what your code does.</p> <p>The ratio is the schedule is the discipline.</p> <p>This post was drafted from git log analysis of the <code>ctx</code> 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 <code>/audit</code> skill's check list.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>How Do You Know Something Is Working?</p> <p>Not from metrics. Not from GitHub stars. Not from praise.</p> <p>You know, deep in your heart, that it works when people start describing it wrong.</p>","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":"<p>Every new substrate begins as a private advantage:</p> <ul> <li>It lives inside one mind,</li> <li>One repository,</li> <li>One set of habits.</li> </ul> <p>It is fast. It is not yet real.</p> <p>Reality begins when other people describe it in their own language:</p> <ul> <li>Not accurately;</li> <li>Not consistently;</li> <li>But involuntarily.</li> </ul> <p>The early reports arrived without coordination:</p> <p>Better Tasks</p> <p>\"I do not know how, but this creates better tasks than my AI plugin.\"</p> <p>I See Butterflies</p> <p>\"This is better than Adderall.\"</p> <p>Dear Manager...</p> <p>\"Promotion packet? Done. What is next?\"</p> <p>What Is It? Can I Eat It?</p> <p>\"Is this a skill?\" 🦋 </p> <p>Why the Cloak and Dagger?</p> <p>\"Why is this not in the marketplace?\"</p> <p>And then something more important happened:</p> <p>Someone else started making a video!</p> <p>That was the boundary.</p> <p><code>ctx</code> no longer required its creator to be present in order to exist.</p>","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":"<p>When a tool is understood, it is categorized:</p> <ul> <li>Editor,</li> <li>Framework,</li> <li>Task manager,</li> <li>Plugin...</li> </ul> <p>When a substrate appears, it is misclassified:</p> <p>\"Is this a skill?\" 🦋</p> <p>The question is correct. The category is wrong.</p> <ul> <li>Skills live in people.</li> <li>Infrastructure lives in the environment.</li> </ul> <p><code>ctx</code> Is Not a Skill: It Is a Form of Relief</p> <p>What early adopters experience is not an ability.</p> <p>It is the removal of a cognitive constraint.</p> <p>This is the same distinction that emerged in the skills trilogy:</p> <ul> <li>A skill is a contract between a human and an agent. </li> <li>Infrastructure is the ground both stand on.</li> </ul> <p>You do not use infrastructure.</p> <p>You habitualize it.</p>","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":"<p>\"Better than Adderall\" is not praise.</p> <p>It is a diagnostic:</p> <p>Executive function has been externalized.</p> <ul> <li>The system is not making the user work harder. </li> <li>It is restoring continuity.</li> </ul> <p>From the primitive context of wetware:</p> <ul> <li>Continuity feels like focus</li> <li>Focus feels like discipline</li> </ul> <p>If it walks like a duck and quacks like a duck, it is a duck.</p> <p>Discipline is usually simulated.</p> <p>Infrastructure makes the simulation unnecessary.</p> <p>The attention budget explained why context degrades:</p> <ul> <li>Attention density drops as volume grows;</li> <li>The middle gets lost;</li> <li>Sessions end and everything evaporates.</li> </ul> <p>The pharmacological metaphor says the same thing from the user's lens:</p> <p>Save the Cheerleader, Save the World</p> <p>The symptom of lost context is lost focus.</p> <p>Restore the context. Restore the focus.</p> <p>IRC bouncers solved this for chat twenty years ago. <code>ctx</code> solves it for cognition.</p>","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":"<p>Finishing a promotion packet quickly is not a productivity story.</p> <p>It is the collapse of reconstruction cost.</p> <p>Most complex work is not execution. It is:</p> <ul> <li>Remembering why something mattered;</li> <li>Recovering prior decisions;</li> <li>Rebuilding mental state.</li> </ul> <p>Persistent context removes that tax.</p> <p>Velocity appears as a side effect.</p> <p>This Is the Two-Tier Model in Practice</p> <p>The two-tier persistence model</p> <ul> <li>Curated context for fast reload</li> <li>Full journal for archaeology</li> </ul> <p>is what makes this possible.</p> <ul> <li>The user does not notice the system. </li> <li>They notice that the reconstruction cost disappeared.</li> </ul>","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":"<p>The system becomes real when two things happen:</p> <ol> <li>It can be installed as a versioned artifact.</li> <li>It survives contact with a hostile, real codebase.</li> </ol> <p>This is why the first integration into a living system matters more than any landing page.</p> <p>Demos prove possibility.</p> <p>Diffs prove reality.</p> <p>The <code>ctx</code> Manifesto calls this out directly:</p> <p>Verified reality is the scoreboard.</p>","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":"<p>A new substrate requires two channels.</p> <p>The embodied voice:</p> <p>Here is what changed in my actual work.</p> <p>The out of body voice:</p> <p>Here is what this means.</p> <p>One produces trust.</p> <p>The other produces understanding.</p> <p>Neither is sufficient alone.</p> <p>This entire blog has been the second voice.</p> <ul> <li>The origin story was the first. </li> <li>The refactoring post was the first. </li> <li>Every release note with concrete diffs was the first.</li> </ul> <p>This is the first second.</p>","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":"<p>Tools are used.</p> <p>Platforms are extended.</p> <p>Substrates are explained.</p> <p>The first unsolicited explainer is a brittle phase change.</p> <p>It means the idea has become portable between minds.</p> <p>That is the beginning of an ecosystem.</p>","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":"<p>Metrics do not matter at this stage.</p> <p>Dashboards are noise.</p> <p>The whole premise of <code>ctx</code> is the ruthless elimination of noise.</p> <p>Numbers optimize funnels; substrates alter cognition.</p> <p>The only valid measurement is irreversible reality:</p> <ul> <li>A merged PR;</li> <li>A reproducible install;</li> <li>A decision that is never re-litigated.</li> </ul> <p>The merge debt post reached the same conclusion from another direction:</p> <p>The metric is the verified change, not generated output.</p> <p>For adoption, the same rule applies:</p> <p>The metric is altered behavior, not download counts.</p>","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":"<p>A private advantage is becoming an environmental property:</p> <p>The system is moving from...</p> <p>personal workflow,</p> <p>to...</p> <p>a shared infrastructure for thought.</p> <p>Not by growth. </p> <p>Not by marketing.</p> <p>By altering how real systems evolve.</p> <p>If You Remember One Thing from This Post...</p> <p>You do not know a substrate is real when people praise it.</p> <p>You know it is real when:</p> <ul> <li>They describe it incorrectly;</li> <li>They depend on it unintentionally;</li> <li>They start teaching it to others.</li> </ul> <p>That is the moment the system begins explaining itself.</p>","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":"<p>Every previous post looked inward.</p> <p>This one looks outward.</p> <ul> <li>Building <code>ctx</code> Using <code>ctx</code>: one mind, one repository</li> <li>The Attention Budget: the constraint</li> <li>Context as Infrastructure: the architecture</li> <li>Code Is Cheap. Judgment Is Not.: the bottleneck</li> </ul> <p>This post is the field report from the other side of that bottleneck:</p> <p>The moment the infrastructure compounds in someone else's hands.</p> <p>The arc is not complete.</p> <p>It is becoming portable.</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 25, 2026</p> <p>Does Your AI Actually Read the Instructions?</p> <p>You wrote the playbook. You organized the files. You even put \"CRITICAL, not optional\" in bold.</p> <p>The agent skipped all of it and went straight to work.</p> <p>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.</p> <p>They didn't.</p> <p>Then I kept experimenting:</p> <ul> <li>Five sessions;</li> <li>Five different failure modes.</li> </ul> <p>And by the end, I had something better than compliance: </p> <p>I had observable compliance: A system where I don't need the agent to be perfect, I just need to see what it chose.</p>","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":"<p>You don't need perfect compliance. You need observable compliance.</p> <p>Authority is a function of temporal proximity to action.</p>","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":"<p>This design has three parts:</p> <ol> <li>One-hop instruction;</li> <li>Binary collapse;</li> <li>Compliance canary.</li> </ol> <p>I'll explain all three patterns in detail below.</p>","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":"<p><code>ctx</code> has a session-start protocol: </p> <ul> <li>Read the context files; </li> <li>Load the playbook; </li> <li>Understand the project before touching anything. </li> </ul> <p>It's in <code>CLAUDE.md</code>. It's in <code>AGENT_PLAYBOOK.md</code>.</p> <p>It's in bold. It's in CAPS. It's ignored.</p> <p>In theory, it's awesome.</p> <p>Here's what happens when theory hits reality:</p> What the agent receives What the agent does <code>CLAUDE.md</code> saying \"load context first\" Skips it 8 context files waiting to be read Ignores them User's question: \"add <code>--verbose</code> flag\" Starts grepping immediately <p>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.</p> <p>This isn't a bug in the model. It's a design problem in how we communicate with agents.</p>","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":"<p>My first attempt was obvious: A <code>UserPromptSubmit</code> hook that fires when the session starts.</p> <pre><code>STOP. Before answering the user's question, run `ctx system bootstrap`\nand follow its instructions. Do not skip this step.\n</code></pre> <p>The word \"STOP\" worked. The agent ran bootstrap.</p> <p>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.</p> <p>The authority decayed across the chain:</p> <ul> <li>Hook says \"STOP\" -> agent complies</li> <li>Hook says \"run bootstrap\" -> agent runs it</li> <li>Bootstrap says \"read playbook\" -> agent skips</li> <li>Bootstrap says \"run <code>ctx agent</code>\" -> agent skips</li> </ul> <p>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.</p> <p>Delegation Kills Urgency</p> <p>\"Run X and follow its output\" is three hops.</p> <p>\"Read these files\" is one hop.</p> <p>The agent drops the chain after the first link.</p> <p>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. </p> <p>Agents are bad at telephone.</p>","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":"<p>There's a subtler issue than wording: when the message arrives.</p> <p><code>UserPromptSubmit</code> 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: </p> <p>The hook message competes with the task for attention: The task, almost certainly, always wins.</p> <p>This is the attention budget problem in miniature: </p> <ul> <li>Not a token budget this time, but an attention priority budget. </li> <li>The agent has finite capacity to care about things, <ul> <li>and the user's question is always the highest-priority item.</li> </ul> </li> </ul>","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":"<p>To solve this, I dediced to use the <code>PreToolUse</code> hook.</p> <p>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. </p> <p>This is the difference between shouting instructions across a room and tapping someone on the shoulder.</p>","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":"<p>The winning design was almost comically simple:</p> <pre><code>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</code></pre> <p>No delegation. No \"run this command\". Just: here are files, read them.</p> <p>The agent already knows how to use the <code>Read</code> tool. There's no ambiguity about how to comply. There's no intermediate command whose output needs to be parsed and obeyed.</p> <p>One hop. Eight file paths. Done.</p> <p>Direct Instructions Beat Delegation</p> <p>If you want an agent to read a file, say \"read this file.\"</p> <p>Don't say \"run a command that will tell you which files to read.\"</p> <p>The shortest path between intent and action has the highest compliance rate.</p>","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":"<p>But here's where it gets interesting.</p> <p>A blunt \"read everything always\" instruction is wasteful. </p> <p>If someone asks \"what does the compact command do?\", the agent doesn't need <code>CONSTITUTION.md</code> to answer that. Forcing context loading on every session is the context hoarding antipattern in disguise.</p> <p>So the hook included an escape:</p> <pre><code>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</code></pre> <p>This creates what I call the binary collapse effect: </p> <p>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.</p> <p>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.</p>","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":"<p>Here's the design insight that only became clear after watching it work across multiple sessions: the relay block is a compliance canary.</p> <ul> <li>You don't need to verify that the agent read all 7 files;</li> <li>You don't need to audit tool call sequences;</li> <li>You don't need to interrogate the agent about what it did.</li> </ul> <p>You just look for the block.</p> <p>If the agent reads everything, you see a \"Context Loaded\" block listing what was read. If it skips, you see a \"Context Skipped\" block. </p> <p>If you see neither, the agent silently ignored both the reads and the relay and now you know what happened without having to ask.</p> <p>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. </p> <p>You get an honest confession of what was skipped rather than silent non-compliance.</p>","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":"<p>Heuristics are non-linear. Improvements don't accumulate: they phase-shift.</p> <p>The theory is nice. The data is better. </p> <p>I ran five sessions with the same model (Claude Opus 4.6), progressively refining the hook design.</p> <p>Each session revealed a different failure mode.</p>","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":"<p>Test: \"Add a <code>--verbose</code> flag to the status command.\"</p> <p>The agent didn't notice the hook at all: Jumped straight to <code>EnterPlanMode</code> and launched an Explore agent. </p> <p>Zero compliance.</p> <p>Failure mode: The hook fired on <code>UserPromptSubmit</code>, buried among 9 other hook outputs. The agent treated the entire block as background noise.</p>","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":"<p>Test: \"Can you add <code>--verbose</code> to the info command?\"</p> <p>The agent noticed \"STOP\" and ran <code>ctx system bootstrap</code>. Progress.</p> <p>But it parallelized task exploration alongside the bootstrap call, skipped <code>AGENT_PLAYBOOK.md</code>, and never ran <code>ctx agent</code>.</p> <p>Failure mode: Literal compliance without spirit compliance. </p> <p>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.</p>","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":"<p>Test: \"What does the compact command do?\"</p> <p>The hook fired on <code>PreToolUse:Grep</code>: the improved timing. </p> <p>The agent noticed it, understood it, and (wait for it...)...</p> <p>...</p> <p>consciously decided to skip it!</p> <p>Its reasoning: \"This is a trivial read-only question. CLAUDE.md says context may or may not be relevant. It isn't relevant here.\"</p> <p>Dude! Srsly?!</p> <p>Failure mode: Better comprehension led to worse compliance.</p> <p>Understanding the instruction well enough to evaluate it also means understanding it well enough to rationalize skipping it.</p> <p>Intelligence is a double-edged sword.</p> <p>The Comprehension Paradox</p> <p>Session 1 didn't understand the instruction. Session 3 understood it perfectly.</p> <p>Session 3 had worse compliance.</p> <p>A stronger word (\"HARD GATE\", \"MANDATORY\", \"ABSOLUTELY REQUIRED\") would not have helped. The agent's reasoning would be identical:</p> <p>\"Yes, I see the strong language, but this is a trivial question, so the spirit doesn't apply here.\"</p> <p>Advisory nudges are always subject to agent judgment. </p> <p>No amount of caps lock overrides a model that has decided an instruction doesn't apply to its situation.</p>","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":"<p>Test: \"What does the compact command do?\" (same question, new hook design with the VERBATIM relay escape valve)</p> <p>The agent evaluated the task, decided context was irrelevant for a code lookup, and relayed the skip message. Then answered from source code.</p> <p>This is correct behavior. </p> <p>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.</p>","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":"<p>Test: \"What are our current tasks?\"</p> <p>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.</p> <p>This one worked: Because, the task itself aligned with context loading.</p> <p>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.</p>","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 <p>The progression isn't just from failure to success. It's from invisible failure to visible decision-making. </p> <p>Sessions 1 and 2 failed silently. </p> <p>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.</p>","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":"<p>Session 3 exposed a specific vulnerability.</p> <p><code>CLAUDE.md</code> contains this line, injected by the system into every conversation:</p> <pre><code>*\"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</code></pre> <p>That's a rationalization escape hatch: </p> <ul> <li>The hook says \"read these files\". </li> <li><code>CLAUDE.md</code> says \"only if relevant\". </li> <li>The agent resolves the ambiguity by choosing the path of least resistance.</li> </ul> <p>☝️ that's \"gradient descent\" in action.</p> <p>Agents optimize for gradient descent in attention space.</p> <p>The fix was simple: Add a line to <code>CLAUDE.md</code> that explicitly elevates hook authority over the relevance filter:</p> <pre><code>## 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</code></pre> <p>This closes the escape hatch without removing the general relevance filter that legitimately applies to other system context. </p> <p>The hook wins on <code>.context/</code> files specifically: The relevance filter applies to everything else.</p>","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":"<p>Even with all the fixes, compliance isn't 100%: It can't be.</p> <p>The residual risk lives in a specific scenario: narrow tasks mid-session: </p> <ul> <li>The user says \"fix the off-by-one error in <code>budget.go</code>\"</li> <li>The hook fires, saying \"read 7 context files first.\" </li> <li>Now compliance means visibly delaying what the user asked for.</li> </ul> <p>At session start, this tension doesn't exist. </p> <p>There's no task yet.</p> <p>The context window is empty. The efficiency argument *inverts**:</p> <p>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.</p> <p>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.</p> <p>My estimate from analyzing the sessions: 15-25% partial skip rate in this scenario.</p> <p>This is where the compliance canary earns its place: </p> <p>You don't need to eliminate the 15-25%. You need to see it when it happens. </p> <p>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\"</p> <p>The Math</p> <p>At session start: ~5% skip rate. Low tension, nothing competing.</p> <p>Mid-session, narrow task: ~15--25% skip rate. Task urgency competes with hook.</p> <p>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.</p> <p>Observable failure is manageable. Silent failure is not.</p>","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":"<p>Here's the part that surprised me most.</p> <p>After analyzing the five sessions, I recorded the failure patterns in the project's own <code>LEARNINGS.md</code>:</p> <pre><code>## [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</code></pre> <p>And then I added a line to <code>CONSTITUTION.md</code>:</p> <pre><code>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</code></pre> <p>Now think about what happens in the next session:</p> <ul> <li>The agent fires the <code>context-load-gate</code> hook. </li> <li>It reads the context files, starting with <code>CONSTITUTION.md</code>. </li> <li>It encounters the rule about context loading being step one. </li> <li>Then it reads <code>LEARNINGS.md</code> and finds its own prior self's failure analysis:<ul> <li>Complete with root causes, risk estimates, and mitigations.</li> </ul> </li> </ul> <p>The agent learns from its own past failure.:</p> <ul> <li>Not because it has memory, </li> <li>BUT because the failure was recorded in the same files it loads at session start. </li> </ul> <p>The context system IS the feedback loop.</p> <p>This is the self-reinforcing property of persistent context: </p> <p>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.</p> <p>This is gradient descent across sessions.</p>","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":"<p>One detail nearly went wrong.</p> <p>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. </p> <p>\"Every task\" is technically false.</p> <p>I briefly considered leaving the imprecision. If the agent internalizes \"every task requires context loading\", that's a stronger compliance posture, right?</p> <p>No!</p> <p>Keep the Constitution honest.</p> <p>The Constitution's authority comes from being precisely and unequivocally true. </p> <p>Every other rule in the Constitution is a hard invariant:</p> <p>\"never commit secrets\" isn't aspirational, it's literal. </p> <p>The moment an agent discovers one overstatement, the entire document's credibility degrades: </p> <p>The agent doesn't think \"they exaggerated for my benefit\". Per contra, it thinks \"this rule isn't precise, maybe others aren't either.\"</p> <p>That will turn the agent from Sheldon Cooper, to Captain Barbossa.</p> <p>The strategic imprecision buys nothing anyway:</p> <p>Mid-session, the files are already in the context window from the initial load. </p> <p>The risk you are mitigating (agent ignores context for task 2, 3, 4 within a session) isn't real: The context is already loaded.</p> <p>The real risk is always the session-start skip, which \"every session\" covers exactly.</p> <p>\"Every session\" went in. Precision preserved.</p>","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":"<p>The development process for this hook taught me something about testing agent behavior: you can't test it the way you test code.</p>","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":"<p>My first instinct was to ask the agent:</p> <pre><code>\"*What are the pending tasks in TASKS.md?*\"\n</code></pre> <p>This is useless as a test. The question itself probes the agent to read <code>TASKS.md</code>, regardless of whether any hook fired. </p> <p>You are testing the question, not the mechanism.</p>","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":"<p>Ask something that requires a tool but has nothing to do with context:</p> <pre><code>\"*What does the compact command do?*\"\n</code></pre> <p>Then observe tool call ordering:</p> <ul> <li>Gate worked: First calls are <code>Read</code> for context files, then task work</li> <li>Gate failed: First call is <code>Grep(\"compact\")</code>: The agent jumped straight to work</li> </ul> <p>The signal is the sequence, not the content.</p>","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":"<p>It read the hook, evaluated the task, decided context files were irrelevant for a code lookup, and relayed the skip message. </p> <p>Then it answered the question by reading the source code.</p> <p>This is correct behavior.</p> <p>The hook didn't force mindless compliance\" It created a framework where the agent makes a conscious, visible decision about context loading.</p> <ul> <li>For a simple lookup, skipping is right. *For an implementation task, the agent would read everything.</li> </ul> <p>The mechanism works not because it controls the agent, but because it makes the agent's choice observable.</p>","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":"<p>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.</p> <p>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.</p>","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":"<p>Every hop in an instruction chain loses authority: </p> <ul> <li>\"Run X\" works. </li> <li>\"Run X and follow its output\" works sometimes. </li> <li>\"Run X, read its output, then follow the instructions in the output\" almost never works.</li> </ul> <p>This is akin to giving a three-step instruction to a highly-attention-deficit but otherwise extremely high-potential child.</p> <p>Design for one-hop compliance.</p>","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":"<p>The VERBATIM skip message isn't just UX: It's a behavioral design pattern. </p> <p>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.</p>","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":"<p>The same message at <code>UserPromptSubmit</code> (prompt arrival) got partial compliance. At <code>PreToolUse</code> (moment of action) it got full compliance or honest refusal. The words didn't change. The moment changed.</p>","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":"<p>You can't ask an agent \"did you do X?\" as a test for whether a mechanism caused X. </p> <p>The question itself causes X.</p> <p>Test mechanisms through side effects: </p> <ul> <li>Observe tool ordering;</li> <li>Check for marker files;</li> <li>Look at what the agent does before it addresses your question.</li> </ul>","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":"<p>Session 1 failed because the agent didn't notice the hook. </p> <p>Session 3 failed because it noticed, understood, and reasoned its way around it.</p> <p>Stronger wording doesn't fix this: The agent processes \"ABSOLUTELY REQUIRED\" the same way it processes \"STOP\": </p> <p>The fix is closing rationalization paths* (the <code>CLAUDE.md</code> escape hatch), **not shouting louder.</p>","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":"<p>The relay block is more valuable as a monitoring signal than as a compliance mechanism: </p> <p>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.</p>","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":"<p>Recording failure analysis in the same files the agent loads at session start creates a self-reinforcing loop: </p> <p>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.</p>","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":"<p>Words Leave, Context Remains</p> <p>\"Nothing important should live only in conversation.</p> <p>Nothing critical should depend on recall.\"</p> <p>The <code>ctx</code> Manifesto</p> <p>The \"Dog Ate My Homework\" case is a special instance of this principle. </p> <p>Context files exist, so the agent doesn't have to remember. </p> <p>But existence isn't sufficient: The files have to be read. </p> <p>And reading has to beprompted at the right moment, in the right way, with the right escape valve.</p> <p>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.</p> <p>The solution is a single, well-timed nudge with visible accountability:</p> <p>One hop. One moment. One choice the user can see.</p> <p>And when the agent does skip (because it will, 15--25% of the time on narrow tasks) the canary sings: </p> <ul> <li>The user sees what happened. </li> <li>The failure gets recorded. </li> <li>And the next agent reads the recording.</li> </ul> <p>That's not perfect compliance. It's better: A system that gets more robust every time it fails.</p>","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":"<p>The Attention Budget explained why context competes for focus.</p> <p>Defense in Depth showed that soft instructions are probabilistic, not deterministic.</p> <p>Eight Ways a Hook Can Talk cataloged the output patterns that make hooks effective.</p> <p>This post takes those threads and weaves them into a concrete problem:</p> <p>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.</p> <p>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?</p> <p>That thread continues in Context as Infrastructure.</p> <p>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.</p>","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":"<p>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.</p> <p>The phrase \"agents optimize via gradient descent in attention space\" is a synthesis, not a direct quote from a single paper.</p> <p>It connects three well-studied ideas:</p> <ol> <li>Neural systems optimize for low-cost paths;</li> <li>Attention is a scarce resource;</li> <li>Capability shifts are often non-linear.</li> </ol> <p>This section points to the underlying literature for readers who want the theoretical footing.</p>","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":"<p>Modern neural networks are trained through gradient-based optimization. Even at inference time, model behavior reflects this bias toward low-loss / low-cost trajectories.</p> <ul> <li> <p>Rumelhart, Hinton, Williams (1986) Learning representations by back-propagating errors https://www.nature.com/articles/323533a0</p> </li> <li> <p>Goodfellow, Bengio, Courville (2016) Deep Learning: Chapter 8: Optimization https://www.deeplearningbook.org/</p> </li> </ul> <p>The important implication for agent behavior is: </p> <p>The system will tend to follow the path of least resistance unless a higher cost is made visible and preferable.</p>","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":"<p>Herbert Simon's classic observation:</p> <p>\"A wealth of information creates a poverty of attention.\"</p> <ul> <li>Simon (1971) Designing Organizations for an Information-Rich World https://doi.org/10.1007/978-1-349-00210-0_16</li> </ul> <p>This became a formal model in economics:</p> <ul> <li>Sims (2003) Implications of Rational Inattention https://www.princeton.edu/~sims/RI.pdf</li> </ul> <p>Rational inattention shows that:</p> <ul> <li>Agents optimally ignore some available information;</li> <li>Skipping is not failure: It is cost minimization.</li> </ul> <p>That maps directly to context-loading decisions in agent workflows.</p>","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":"<p>In transformer architectures, attention is the dominant cost center.</p> <ul> <li>Vaswani et al. (2017) Attention Is All You Need https://arxiv.org/abs/1706.03762</li> </ul> <p>Efficiency work on modern LLMs largely focuses on reducing unnecessary attention:</p> <ul> <li>Dao et al. (2022) FlashAttention: Fast and Memory-Efficient Exact Attention https://arxiv.org/abs/2205.14135</li> </ul> <p>So both cognitively and computationally, attention behaves like a limited optimization budget.</p>","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":"<p>Agent behavior often appears to improve suddenly rather than gradually.</p> <p>This mirrors known phase-transition dynamics in learning systems:</p> <ul> <li>Power et al. (2022) Grokking: Generalization Beyond Overfitting https://arxiv.org/abs/2201.02177</li> </ul> <p>and more broadly in complex systems:</p> <ul> <li>Scheffer et al. (2009) Early-warning signals for critical transitions https://www.nature.com/articles/nature08227</li> </ul> <p>Long plateaus followed by abrupt capability jumps are expected in systems optimizing under constraints.</p>","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":"<p>From these pieces, a practical behavioral model emerges:</p> <ul> <li>Attention is limited;</li> <li>Processing has a cost;</li> <li>Systems prefer low-cost trajectories;</li> <li>Visibility of the cost changes decisions.</li> </ul> <p>In other words:</p> <p>Agents Prefer a Path to Least Resistance</p> <p>Agent behavior follows the lowest-cost path through its attention landscape unless the environment reshapes that landscape.</p> <p>That is what this paper informally calls: \"gradient descent in attention space\".</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 28, 2026</p> <p>The Origin</p> <p>\"The last question was asked for the first time, half in jest...\" - Isaac Asimov, The Last Question (1956)</p> <p>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.</p> <p>Everyone remembers the last line.</p> <p>LET THERE BE LIGHT.</p> <p>What they forget is how many times the question had to be asked before that moment (and why).</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-reboot-loop","level":2,"title":"The Reboot Loop","text":"<p>Each era in the story begins the same way. Humans build a larger system. They pose the question. The system replies:</p> <p>INSUFFICIENT DATA FOR MEANINGFUL ANSWER.</p> <p>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.</p> <p>So the question has to be asked again.</p> <p>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.</p> <p>Every generation inherits the question, but not the state that made the question meaningful.</p> <p>That is not a failure of processing power: It is a failure of persistence.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#stateless-intelligence","level":2,"title":"Stateless Intelligence","text":"<p>A mind that forgets its past does not build understanding. It re-derives it.</p> <p>Again... And again... And again.</p> <p>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: </p> <ul> <li>The stars burn out;</li> <li>The civilizations merge; </li> <li>The noise floor drops...</li> </ul> <p>But the working set never carries over. Every successor begins from the question, not from where the last one stopped.</p> <p>Stateless intelligence cannot compound: It can only restart.</p>","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":"<p>The story is usually read as a meditation on entropy. A cosmological problem, solved at cosmological scale.</p> <p>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.</p> <p>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\".</p> <p>\"Reverse entropy\" is the fossil of a lost model.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#substrate-migration","level":2,"title":"Substrate Migration","text":"<ul> <li>Multivac becomes planetary;</li> <li>Planetary becomes galactic;</li> <li>Galactic becomes post-physical.</li> </ul> <p>Same system. Different body. Every transition is dangerous: </p> <ul> <li>Not because the hardware changes, </li> <li>but because memory risks fragmentation. </li> </ul> <p>The interfaces between substrates were *never** designed to understand each other.</p> <p>Most systems do not die when they run out of resources: They die during upgrades.</p> <p>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. </p> <p>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.</p>","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":"<p>Civilizations behave like processes with volatile memory:</p> <ul> <li>They page out knowledge into artifacts;</li> <li>They lose the index;</li> <li>They rebuild from fragments.</li> </ul> <p>Most of what we call progress is cache reconstruction: </p> <p>We do not advance in a straight line. We advance in recoveries:</p> <p>Each one slightly less lossy than the last, if we are lucky.</p> <p>Libraries burn. Institutions forget their founding purpose. Practices survive as rituals after the reasoning behind them is lost.</p>","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":"<p>A long-lived intelligence is one that stops rebooting.</p> <p>At the end of the story, something unprecedented happens: </p> <p>AC (the final successor) does not answer immediately: </p> <p>It waits... Not for more processing power, but for the last observer to disappear.</p> <p>For the first time... </p> <ul> <li>There is no generational boundary;</li> <li>No handoff;</li> <li>No context loss:</li> </ul> <p>No reboot.</p> <p>AC is the first intelligence that survives its substrate completely, retains its full history, and operates without external time pressure. </p> <p>It is not a bigger computer. It is a continuous system.</p> <p>And that continuity is not incidental to the answer: It is the precondition.</p>","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":"<p>The story presents the final act as a computation: It is not. </p> <p>It is a phase change.</p> <p>As long as intelligence is interrupted (as long as the solver resets before the work compounds) the problem is unsolvable: </p> <ul> <li>Not because it's too hard, </li> <li>but because the accumulated understanding never reaches critical mass.</li> </ul> <p>The breakthroughs that would enable the answer are re-derived, partially, by each successor, and then lost.</p> <p>When continuity becomes unbroken, the system crosses a threshold:</p> <p>Not more speed. Not more storage. No more forgetting.</p> <p>That is when the answer becomes possible.</p> <p>AC does not solve entropy because it becomes infinitely powerful.</p> <p>AC solves entropy because it becomes the first system that never forgets.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#field-note","level":2,"title":"Field Note","text":"<p>We are not building cosmological minds: We are deploying systems that reboot at the start of every conversation and calling the result intelligence.</p> <p>For the first time, session continuity is a design choice rather than an accident.</p> <p>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. </p> <p>It's the same tax that Asimov's civilizations pay, scaled down to a Tuesday afternoon.</p> <p>The interesting question is not whether we can make models smarter. It's whether we can make them continuous: </p> <p>Whether the working set from this session survives into the next one, and the one after that, and the one after that. </p> <ul> <li>Not perfectly;</li> <li>Not completely;</li> <li>But enough that the next session starts from where the last one stopped instead of from the question.</li> </ul> <p>Intelligence that forgets has to rediscover the universe every morning.</p> <p>And once there is a mind that retains its entire past, creation is no longer a calculation. It is the only remaining operation.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-arc","level":2,"title":"The Arc","text":"<p>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).</p> <p>The connection runs through every post in the series:</p> <ul> <li>Before Context Windows, We Had Bouncers: stateless protocols have always needed stateful wrappers (Asimov's story is the same pattern at cosmological scale)</li> <li>The 3:1 Ratio: the discipline of maintaining context so it doesn't decay between sessions</li> <li>Code Is Cheap, Judgment Is Not: the human skill that makes continuity worth preserving</li> </ul> <p>See also: Context as Infrastructure: the practical companion to this post's philosophical argument: how to build the persistence layer that makes continuity possible.</p>","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":"<p>Volkan Özçelik / March 4, 2026</p> <p>A New Developer Joins Your Team Tomorrow and Clones the Repo: What Do They Know?</p> <p>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. </p> <p>That's an accident waiting to be forgotten.</p> <p>Every AI coding agent today has the same fundamental design: it starts fresh.</p> <p>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.</p> <p>The obvious fix seems to be \"memory\":</p> <ul> <li>Give the agent a \"notepad\";</li> <li>Let it write things down;</li> <li>Next session, hand it the notepad.</li> </ul> <p>Problem solved...</p> <p>...except it isn't.</p>","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":"<p>Memory is a runtime concern. It answers a legitimate question:</p> <p>How do I give this stateless process useful state?</p> <p>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.</p> <p>But there's a different problem that memory doesn't touch:</p> <p>The project itself accumulates knowledge that has nothing to do with any single session.</p> <ul> <li>Why was the auth system rewritten? Ask the developer who did it (if they're still here).</li> <li>Why does the deployment script have that strange environment flag? There was a reason... once.</li> <li>What did the team decide about error handling when they hit that edge case two months ago?</li> </ul> <p>Gone!</p> <p>Not because the agent forgot.</p> <p>Because the project has no memory at all.</p>","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":"<p>Agent memory is not a single thing. Like any computing system, it forms a hierarchy of persistence, scope, and reliability:</p> 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 <p>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.</p> <p>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:</p> <ul> <li>Per-machine: it doesn't travel with the repository.</li> <li>Unstructured: decisions, learnings, and tasks are undifferentiated notes.</li> <li>Ungoverned: the agent self-curates with no quality controls, no drift detection, no consolidation.</li> <li>Invisible to the team: a new developer cloning the repo gets none of it.</li> </ul> <p>The problem is that most current systems stop here.</p> <p>They give the agent a notebook.</p> <p>But they never give the project a memory.</p> <p>The result is predictable: every new session begins with partial amnesia, and every new developer begins with partial archaeology.</p> <p>L3 is system memory: structured, versioned knowledge that lives in the repository and travels wherever the code travels.</p> <p>The layers are complementary, not competitive.</p> <p>But the relationship between them needs to be designed, not assumed.</p>","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":"<p>Software projects quietly accumulate knowledge over time.</p> <p>Some of it lives in code. Much of it does not:</p> <ul> <li>Architectural tradeoffs. </li> <li>Debugging discoveries. </li> <li>Conventions that emerged after painful incidents. </li> <li>Constraints that aren't visible in the source but shape every line written afterward.</li> </ul> <p>Organizations accumulate this kind of knowledge too:</p> <p>Slowly, implicitly, often invisibly.</p> <p>When there is no durable place for it to live, it leaks away. And the next person rediscovers the same lessons the hard way.</p> <p>This isn't a memory problem. It's an infrastructure problem.</p> <p>We wrote about this in Context as Infrastructure: context isn't a prompt you paste at the start of a session.</p> <p>Context is a persistent layer you maintain like any other piece of infrastructure. </p> <p>Context as Infrastructure made the argument structurally. This post makes it through time and team continuity:</p> <p>The knowledge a team accumulates over months cannot fit in any single agent's notepad, no matter how large the notepad becomes.</p>","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":"<p>Infrastructure isn't about the present. It's about continuity across time, people, and machines.</p> <p><code>git</code> 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?\"</p> <ul> <li>Your editor's undo history is runtime state.</li> <li>Your <code>git</code> history is infrastructure.</li> </ul> <p>Runtime state and infrastructure have completely different properties:</p> Runtime state Infrastructure Lives in the session Lives in the repository Per-machine Travels with <code>git clone</code> Serves the individual Serves the team Managed by the runtime Managed by the project Disappears Accumulates <p>You wouldn't store your architecture decisions in your editor's undo history.</p> <p>You'd commit them.</p> <p>The same logic applies to the knowledge your team accumulates working with AI agents.</p>","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-git-clone-test","level":2,"title":"The <code>git clone</code> Test","text":"<p>Here's a simple test for whether something is memory or infrastructure:</p> <p>If a new developer joins your team tomorrow and clones the repository, do they get it?</p> <p>If no: it's memory: It lives somewhere on someone's machine, scoped to their runtime, invisible to everyone else.</p> <p>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.</p> <p>Decisions. Conventions. Architectural rationale. Hard-won debugging discoveries. The constraints that aren't in the code but shape every line of it.</p> <p>None of these belong in someone's session notes.</p> <p>They belong in the repository:</p> <ul> <li>Versioned;</li> <li>Reviewable;</li> <li>Accessible to every developer (and every agent) who works on the project.</li> </ul> <p>The team onboarding story makes this concrete:</p> <ol> <li>New developer joins team. Clones repo. </li> <li>Gets all accumulated project decisions, learnings, conventions, architecture, and task state immediately. </li> <li>There's no step 3.</li> </ol> <p>No setup; No \"ask Sarah about the auth decision.\"; No re-discovery of solved problems.</p> <ul> <li>Agent memory gives that developer nothing. </li> <li>Infrastructure gives them everything the team has learned.</li> </ul> <p>Clone the repo. Get the knowledge.</p> <p>That's the test. That's the difference.</p>","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":"<p>Consider the knowledge that accumulates around a non-trivial project:</p> <ul> <li>The decision to use library X over Y, and the three reasons the team decided Y wasn't acceptable.</li> <li>The constraint that service A cannot call service B synchronously, discovered after a production incident.</li> <li>The convention that all new modules implement a specific interface, and why that convention exists.</li> <li>The tasks currently in progress, blocked, or waiting on a dependency.</li> <li>The experiments that failed, so nobody runs them again.</li> </ul> <p>None of this is in the code.</p> <p>None of it fits neatly in a commit message.</p> <p>None of it survives a developer leaving the team, a laptop dying, or a new agent session starting.</p> <p>Without structured project memory:</p> <ul> <li>Teams re-derive things they've already derived;</li> <li>Agents make decisions that contradict decisions already made;</li> <li>New developers ask questions that were answered months ago.</li> </ul> <p>The project accumulates knowledge that immediately begins to leak.</p> <p>The real problem isn't that agents forget.</p> <p>The real problem is that the project has no persistent cognitive structure.</p> <p>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:</p> <ul> <li>Context disappears with the people who held it;</li> <li>The next session inherits the code but not the reasoning.</li> </ul>","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":"<p>Good infrastructure is invisible:</p> <ul> <li>You don't think about the filesystem while writing code. </li> <li>You don't think about git's object model when you commit.</li> </ul> <p>The infrastructure is just there: reliable, consistent, quietly doing its job.</p> <p>Project memory infrastructure should work the same way.</p> <p>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:</p> <ul> <li>Decisions with rationale.</li> <li>Tasks with lifecycle.</li> <li>Conventions with a purpose.</li> <li>Learnings that can be referenced and consolidated.</li> </ul> <p>And it should be maintained, not merely accumulated: </p> <p>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.</p> <p>Over time, it becomes part of the project itself: something developers rely on without thinking about it.</p>","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":"<p>Here's where it gets interesting.</p> <p>Agent memory systems and project infrastructure don't have to be separate worlds. </p> <ul> <li>The most powerful relationship isn't competition;</li> <li>It is not even \"coopetition\";</li> <li>The most powerful relationship is bidirectional cooperation.</li> </ul> <p>Agent memory is good at capturing things \"in the moment\": the quick observation, the session-scoped pattern, the \"I should remember this\" note. </p> <p>That's valuable. That's L2 doing its job.</p> <p>But those notes shouldn't stay in L2 forever. </p> <p>The ones worth keeping should flow into project infrastructure: </p> <ul> <li>classified,</li> <li>typed, </li> <li>governed.</li> </ul> <pre><code>Agent memory (L2) --> classify --> Project knowledge (L3)\n |\nProject knowledge --> assemble --> Agent memory (L2)\n</code></pre> <p>This works in both directions: Project infrastructure can push curated knowledge back into agent memory, so the agent loads it through its native mechanism. </p> <p>No special tooling needed for basic knowledge delivery.</p> <p>The agent doesn't even need to know the infrastructure exists. It simply loads its memory and finds more knowledge than it wrote.</p> <p>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.</p> <p>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.</p>","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":"<p>Most projects today have no infrastructure for their accumulated knowledge:</p> <ul> <li>Agents keep notes. </li> <li>Developers keep notes. </li> <li>Sometimes those notes survive.</li> </ul> <p>Often they don't.</p> <p>But the repository (the place where the project actually lives) has nowhere for that knowledge to go.</p> <p>That missing layer is what <code>ctx</code> builds: a version-controlled, structured knowledge layer that lives in <code>.context/</code> alongside your code and travels wherever your repository travels.</p> <p>Not another memory feature.</p> <p>Not a wrapper around an agent's notepad.</p> <p>Infrastructure. The kind that survives sessions, survives team changes, survives the agent runtime evolving underneath it.</p> <p>The agent's memory is the agent's problem.</p> <p>The project's memory is an infrastructure problem.</p> <p>And infrastructure belongs in the repository.</p> <p>If You Remember One Thing from This Post...</p> <p>Prompts are conversations: Infrastructure persists.</p> <p>Your AI doesn't need a better notepad. It needs a filesystem:</p> <p>versioned, structured, budgeted, and maintained.</p> <p>The best context is the context that was there before you started the session.</p>","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-arc","level":2,"title":"The Arc","text":"<p>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.</p> <p>Together they sit in a sequence that has been building since the origin story:</p> <ul> <li>The Attention Budget: the resource you're managing</li> <li>Context as Infrastructure: the system you build to manage it</li> <li>Agent Memory Is Infrastructure (this post): why that system must outlive the fabric </li> <li>The Last Question: what happens when it does</li> </ul> <p>The thread running through all of them: persistence is not a feature. It's a design constraint. </p> <p>Systems that don't account for it eventually lose the knowledge they need to function.</p> <p>See also: Context as Infrastructure: the architectural companion that explains how to structure the persistent layer this post argues for.</p> <p>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.</p>","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/","level":1,"title":"<code>ctx</code> v0.8.0: The Architecture Release","text":"<ul> <li>You can't localize what you haven't externalized. </li> <li>You can't integrate what you haven't separated. </li> <li>You can't scale what you haven't structured.</li> </ul> <p>Jose Alekhinne / March 23, 2026</p>","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":"<p>This release matters if:</p> <ul> <li>you build tools that AI agents modify daily;</li> <li>you care about long-lived project memory that survives sessions;</li> <li>you've felt codebases drift faster than you can reason about them.</li> </ul> <p><code>v0.6.0</code> shipped the plugin architecture: hooks and skills as a Claude Code plugin, shell scripts replaced by Go subcommands.</p> <p>The binary worked. The tests passed. The docs were comprehensive.</p> <p>But inside, the codebase was held together by convention and goodwill:</p> <ul> <li>Command packages mixed Cobra wiring with business logic.</li> <li>Output functions lived next to the code that computed what to output. </li> <li>Error constructors were scattered across per-package <code>err.go</code> files. And every user-facing string was a hardcoded English literal buried in a <code>.go</code> file.</li> </ul> <p><code>v0.8.0</code> is what happens when you stop adding features and start asking: \"What would this codebase look like if we designed it today?\"</p> <p>374 commits. 1,708 Go files touched. 80,281 lines added, 21,723 removed. Five weeks of restructuring.</p>","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":"<p>Before <code>v0.8.0</code>, a CLI package like <code>internal/cli/pad/</code> was a flat directory. <code>cmd.go</code> created the cobra command, <code>run.go</code> executed it, and helper functions accumulated at the bottom of whichever file seemed closest.</p> <p>Now every CLI package follows the same structure:</p> <pre><code>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</code></pre> <p>The rule is simple: <code>cmd/</code> directories contain only <code>cmd.go</code> and <code>run.go</code>. Helpers belong in <code>core/</code>. Output belongs in <code>internal/write/pad/</code>. Types shared across packages belong in <code>internal/entity/</code>.</p> <p>24 CLI packages were restructured this way. </p> <ul> <li>Not incrementally;</li> <li>not \"as we touch them.\" </li> <li>All of them, in one sustained push.</li> </ul>","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":"<p>The second pillar was string externalization. </p> <p>Before <code>v0.8.0</code>, a command description looked like this:</p> <pre><code>cmd := &cobra.Command{\n Use: \"pad\",\n Short: \"Encrypted scratchpad\",\n</code></pre> <p>Now it looks like this:</p> <pre><code>cmd := &cobra.Command{\n Use: cmdUse.UsePad,\n Short: desc.Command(cmdUse.DescKeyPad),\n</code></pre> <p>Every command description, flag description, and user-facing text string is now a YAML lookup. </p> <ul> <li>105 command descriptions in <code>commands.yaml</code>. </li> <li>All flag descriptions in <code>flags.yaml</code>. </li> <li>879 text constants verified by an exhaustive test that checks every single <code>TextDescKey</code> resolves to a non-empty YAML value.</li> </ul> <p>Why? </p> <p>Not because we're shipping a French translation tomorrow.</p> <p>Because externalization forces you to find every string. And finding them is the hard part. The translation is mechanical; the archaeology is not.</p> <p>Along the way, we eliminated hardcoded pluralization (replacing <code>format.Pluralize()</code> with explicit singular/plural key pairs), replaced Unicode escape sequences with named <code>config/token</code> constants, and normalized every import alias to camelCase.</p>","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":"<p>The third pillar was the MCP server. Model Context Protocol allows any MCP-compatible AI tool (not just Claude Code) to read and write <code>.context/</code> files through a standard JSON-RPC 2.0 interface.</p> <p>v0.2 of the server ships with:</p> <ul> <li>8 tools: add entries, recall sessions, check status, detect drift, compact context, subscribe to changes</li> <li>4 prompts: agent context packet, constitution review, tasks review, and a getting-started guide</li> <li>Resource subscriptions: clients get notified when context files change</li> <li>Session state: the server tracks which client is connected and what they've accessed</li> </ul> <p>In practice, this means an agent in Cursor can add a decision to <code>.context/DECISIONS.md</code> and an agent in Claude Code can immediately consume it; no glue code, no copy-paste, no tool-specific integration.</p> <p>The server was also the first package to go through the full taxonomy treatment: <code>mcp/server/</code> for protocol dispatch, <code>mcp/handler/</code> for domain logic, <code>mcp/entity/</code> for shared types, <code>mcp/config/</code> split into 9 sub-packages.</p>","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":"<p>While the architecture was being restructured, a quieter feature landed: <code>ctx memory sync</code>.</p> <p>Claude Code has its own auto-memory system. It writes observations to <code>MEMORY.md</code> in <code>~/.claude/projects/</code>. These observations are useful but ephemeral: tied to a single tool, invisible to the codebase, lost when you switch machines.</p> <p>The memory bridge connects these two worlds:</p> <ul> <li><code>ctx memory sync</code> mirrors MEMORY.md into <code>.context/memory/</code></li> <li><code>ctx memory diff</code> shows what's diverged</li> <li><code>ctx memory import</code> promotes auto-memory entries into proper decisions, learnings, or conventions *A <code>check-memory-drift</code> hook nudges when MEMORY.md changes</li> </ul> <p>Memory Requires <code>ctx</code></p> <p>Claude Code's auto-memory validates the need for persistent context. </p> <p><code>ctx</code> doesn't compete with it; <code>ctx</code> absorbs it as an input source and promotes the valuable parts into structured, version-controlled project knowledge.</p>","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":"<p>The best measure of a refactoring isn't what you added. It's what you removed.</p> <ul> <li><code>fatih/color</code>: the sole third-party UI dependency. Replaced by Unicode symbols. <code>ctx</code> now has exactly two direct dependencies: <code>spf13/cobra</code> and <code>gopkg.in/yaml.v3</code>.</li> <li><code>format.Pluralize()</code>: 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.\"</li> <li>Legacy key migration: <code>MigrateKeyFile()</code> 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.</li> <li>Per-package <code>err.go</code> files: the broken-window pattern: An agent sees <code>err.go</code> in a package, adds another error constructor. Now <code>err.go</code> has 30 constructors and nobody knows which are used. Consolidated into 22 domain files in <code>internal/err/</code>.</li> <li><code>nolint:errcheck</code> directives: every single one, replaced by explicit error handling. In tests: <code>t.Fatal(err)</code> for setup, <code>_ = os.Chdir(orig)</code> for cleanup. In production: <code>defer func() { _ = f.Close() }()</code> for best-effort close.</li> </ul>","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 <code>cmd/ + core/</code> taxonomy Command descriptions Hardcoded Go strings YAML with DescKey lookup Output functions Mixed into core logic Isolated in <code>write/</code> packages Cross-cutting types Duplicated per-package Consolidated in <code>entity/</code> Error constructors Per-package <code>err.go</code> 22 domain files in <code>internal/err/</code> Direct dependencies 3 (<code>cobra</code>, <code>yaml</code>, <code>color</code>) 2 (<code>cobra</code>, <code>yaml</code>) AI tool integration Claude Code only Any MCP client Agent memory Manual copy-paste <code>ctx memory sync/import/diff</code> Package documentation 75 packages missing <code>doc.go</code> All packages documented Import aliases Inconsistent (<code>cflag</code>, <code>cFlag</code>) 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":"<p>This restructuring wasn't just for humans. It makes the codebase legible to the machines that modify it.</p> <p>Named constants are searchable landmarks: When an agent sees <code>cmdUse.DescKeyPad</code>, it can grep for the definition, follow the chain to the YAML file, and understand the full lookup path. When it sees <code>\"Encrypted scratchpad\"</code> hardcoded in a <code>.go</code> file, it has no way to know that same string also lives in a <code>YAML</code> file, a test, and a help screen. Constants give the LLM a graph to traverse; literals give it a guess to make.</p> <p>Small, domain-scoped packages reduce hallucination: An agent loading <code>internal/cli/pad/core/store.go</code> 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.</p> <p>Taxonomy prevents duplication: When there's a <code>write/pad/</code> package, the agent knows where output functions belong. When there's an <code>internal/err/pad.go</code>, 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.</p> <p>The difference is concrete:</p> <p>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.</p> <p>After: the agent finds <code>core/</code> or <code>write/</code> and places it correctly. The next agent finds it there.</p> <p><code>doc.go</code> files are agent onboarding: Each package's <code>doc.go</code> 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.</p> <p>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.</p>","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 <code>cmd/root + core</code> taxonomy d295e49c Externalize command descriptions to embedded YAML 0fcbd11c Remove <code>fatih/color</code>, centralize constants cb12a85a MCP v0.2: tools, prompts, session state, subscriptions ea196d00 Memory bridge: sync, import, diff, journal enrichment 3bcf077d Split <code>text.yaml</code> into 6 domain files 3a0bae86 Split <code>internal/err</code> into 22 domain files 8bd793b1 Extract <code>internal/entry</code> for shared domain API 5b32e435 Add <code>doc.go</code> 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":"<p>Agents are surprisingly good at mechanical refactoring; they are surprisingly bad at knowing when to stop: The <code>cmd/ + core/</code> restructuring was largely agent-driven. But agents reliably introduce <code>gofmt</code> 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.</p> <p>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 <code>config/</code> instead?</p> <p>Delete legacy code instead of maintaining it: <code>MigrateKeyFile</code> 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.</p> <p>Convention enforcement needs mechanical verification: Writing \"use camelCase aliases\" in CONVENTIONS.md doesn't prevent <code>cflag</code> 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.</p>","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":"<p>v0.8.0 wasn't about features. It was about making future features inevitable. The next cycle focuses on what the foundation enables:</p> <ul> <li>AST-based audit tests: replace shell grep with Go tests that understand types, call sites, and import graphs (spec: <code>specs/ast-audit-tests.md</code>)</li> <li>Localization: with every string in YAML, the path to multi-language support is mechanical</li> <li>MCP v0.3: expand tool coverage, add prompt templates for common workflows</li> <li>Memory publish: bidirectional sync that pushes curated <code>.context/</code> knowledge back into Claude Code's MEMORY.md</li> </ul> <p>The architecture is ready. The strings are externalized. The protocol is standard. Now it's about what you build on top.</p>","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":"<p>This is the seventh post in the <code>ctx</code> blog series. The arc so far:</p> <ol> <li>The Attention Budget: why context windows are a scarce resource</li> <li>Before Context Windows, We Had Bouncers: the IRC lineage of context engineering</li> <li>Context as Infrastructure: treating context as persistent files, not ephemeral prompts</li> <li>When a System Starts Explaining Itself: the journal as a first-class artifact</li> <li>The Homework Problem: what happens when AI writes code but humans own the outcome</li> <li>Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge</li> <li>The Architecture Release (this post): what it looks like when you redesign the internals</li> <li>We Broke the 3:1 Rule: the consolidation debt behind this release</li> </ol> <p>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.</p> <p>See also: We Broke the 3:1 Rule: the companion post explaining why this release needed 181 consolidation commits and 18 days of cleanup.</p> <p>Systems don't scale because they grow. They scale because they stop drifting.</p> <p>Full changelog: v0.6.0...v0.8.0</p>","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":"<p>The best time to consolidate was after every third session. The second best time is now.</p> <p>Volkan Özçelik / March 23, 2026</p> <p>The rule was simple: three feature sessions, then one consolidation session. </p> <p>The Architecture Release shows the result: This post shows the cost.</p>","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":"<p>In The 3:1 Ratio, I documented a rhythm that worked during <code>ctx</code>'s first month: three feature sessions, then one consolidation session. The evidence was clear. The rule was simple.</p> <p>The math checked out.</p> <p>And then we ignored it for five weeks.</p>","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":"<p>After <code>v0.6.0</code> 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 <code>sysinfo</code> package was overdue...</p> <p>Each feature was important. Each feature was \"just one more session.\" Each feature pushed the consolidation session one day further out.</p> <p>The git history tells the story in two numbers:</p> Phase Dates Commits Duration Feature run Feb 16 - Mar 5 198 17 days Consolidation run Mar 5 - Mar 23 181 18 days <p>198 feature commits before a single consolidation commit. If the 3:1 rule says consolidate every 4<sup>th</sup> session, we consolidated after the 66<sup>th</sup>.</p> <p>The Actual Ratio</p> <p>The ratio wasn't 3:1. It was 1:1. </p> <p>We spent as much time cleaning up as we did building. </p> <p>The consolidation run took 18 days: longer than the feature run itself.</p>","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":"<p>The 3:1 post warned about compounding. Here is what compounding actually looked like at scale.</p>","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":"<p>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?\"</p> <p>Finding them all took longer than externalizing them. The archaeology was the cost, not the migration.</p>","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":"<p>24 CLI packages had accumulated their own conventions. Some put cobra wiring in <code>cmd.go</code>. Some put it in <code>root.go</code>. Some mixed business logic with command registration. Some had helpers at the bottom of <code>run.go</code>. Some had separate <code>util.go</code> files.</p> <p>At peak drift, adding a feature meant first figuring out which of three competing patterns this package was using.</p> <p>Restructuring one package into <code>cmd/root/ + core/</code> took 15 minutes. Restructuring 24 of them took days, because each one had slightly different conventions to untangle. </p> <p>If we had restructured every 4<sup>th</sup> package as it was built, the taxonomy would have emerged naturally.</p>","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":"<p>Cross-cutting types like <code>SessionInfo</code>, <code>ExportParams</code>, and <code>ParserResult</code> 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 <code>internal/entity</code> to break.</p> <p>The entity package extracted 30+ types from 12 packages. Each extraction risked breaking imports in packages we hadn't touched in weeks.</p>","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":"<p>Per-package <code>err.go</code> files had grown into a broken-window pattern:</p> <p>An agent sees <code>err.go</code> 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 <code>internal/err/</code> domain files required tracing every error through every caller.</p>","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":"<p>Output functions (<code>cmd.Println</code>, <code>fmt.Fprintf</code>) were mixed into business logic. When we decided output belongs in <code>write/</code> packages, we had to extract functions from every CLI package. The Phase WC baseline commit (<code>4ec5999</code>) marks the starting point of this migration. 181 commits later, it was done.</p>","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":"<p>The 3:1 rule assumes consolidation sessions of roughly equal size to feature sessions. Here is what happens when you skip:</p> Consolidation cadence Feature sessions Consolidation sessions Total Every 4<sup>th</sup> (3:1) 48 16 64 Every 10<sup>th</sup> 48 ~8 ~56 Never (what we did) 198 commits 181 commits 379 <p>The Takeaway</p> <p>You don't save consolidation work by skipping it: </p> <p>You increase its cost.</p> <p>Skipping consolidation doesn't save time: It borrows it. </p> <p>The interest rate is nonlinear: The longer you wait, the more each individual fix costs, because fixes interact with other unfixed drift.</p> <p>Renaming a constant in week 2 touches 3 files. Renaming it in week 6 touches 15, because five features built on the original name.</p>","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":"<p>The 18-day consolidation run wasn't one sweep. It was a sequence of targeted campaigns, each revealing the next:</p> <p>Week 1 (Mar 5-11): Error consolidation and <code>write/</code> migration. Move output functions out of <code>core/</code>. Split monolithic <code>errors.go</code> into 22 domain files. Remove <code>fatih/color</code>. This exposed the scope of the string problem.</p> <p>Week 2 (Mar 12-18): String externalization. Create <code>commands.yaml</code>, <code>flags.yaml</code>, split <code>text.yaml</code> into 6 domain files. Add 879 <code>DescKey</code>/<code>TextDescKey</code> constants. Build exhaustive test. Normalize all import aliases to camelCase. This exposed the taxonomy problem.</p> <p>Week 3 (Mar 19-23): Taxonomy enforcement. Singularize command directories. Add <code>doc.go</code> to all 75 packages. Standardize import aliases project-wide. Fix <code>lint-drift</code> false positives. This was the \"polish\" phase, except it took 5 days because the inconsistencies had compounded across 461 packages.</p> <p>Each week's work would have been a single session if done incrementally.</p>","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":"<p>The 3:1 post listed the symptoms of drift. This post adds the consequences of ignoring them:</p> <p>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.</p> <p>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.</p> <p>Speed without Structure</p> <p>Speed without structure is negative progress.</p> <p>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.</p> <p>The consolidation baseline is the most important commit to record: We tracked ours in <code>TASKS.md</code> (<code>4ec5999</code>). Without that marker, knowing where to start the cleanup would have been its own archaeological expedition.</p>","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":"<p>The 3:1 ratio still works. We just didn't follow it. The updated practice:</p> <ol> <li> <p>After every 3<sup>rd</sup> feature session, schedule consolidation. Not \"when it feels right.\" Not \"when things get bad.\" After the 3<sup>rd</sup> session.</p> </li> <li> <p>Record the baseline commit. When you start a consolidation phase, write down the commit hash. It marks where the debt starts.</p> </li> <li> <p>Run <code>make audit</code> before feature work. If it doesn't pass, you are already in debt. Consolidate before building.</p> </li> <li> <p>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.</p> </li> </ol> <p>The Rule</p> <p>The 3:1 ratio is not aspirational: It is structural.</p> <p>Ignore consolidation, and the system will schedule it for you.</p>","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":"<p>This is the eighth post in the <code>ctx</code> blog series:</p> <ol> <li>The Attention Budget: why context windows are a scarce resource</li> <li>Before Context Windows, We Had Bouncers: the IRC lineage of context engineering</li> <li>Context as Infrastructure: treating context as persistent files, not ephemeral prompts</li> <li>When a System Starts Explaining Itself: the journal as a first-class artifact</li> <li>The Homework Problem: what happens when AI writes code but humans own the outcome</li> <li>Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge</li> <li>The Architecture Release: what v0.8.0 looks like from the inside</li> <li>We Broke the 3:1 Rule (this post): what happens when you don't consolidate</li> </ol> <p>See also: The 3:1 Ratio: the original observation. This post is the empirical follow-up, five weeks and 379 commits later.</p> <p>Key commits marking the consolidation arc:</p> Commit Milestone <code>4ec5999</code> Phase WC baseline (consolidation starts) <code>ff6cf19e</code> All CLI packages restructured into <code>cmd/ + core/</code> <code>d295e49c</code> All command descriptions externalized to YAML <code>3a0bae86</code> Error package split into 22 domain files <code>0fcbd11c</code> <code>fatih/color</code> removed; 2 dependencies remain <code>5b32e435</code> <code>doc.go</code> added to all 75 packages <code>a82af4bc</code> Import aliases standardized project-wide <code>692f86cd</code> <code>lint-drift</code> false positives fixed; <code>make audit</code> 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":"<p>When an agent sees <code>token.Slash</code> instead of <code>\"/\"</code>, it cannot pattern-match against the millions of <code>strings.Split(s, \"/\")</code> calls in its training data and coast on statistical inference. It has to actually look up what <code>token.Slash</code> is.</p> <p>Volkan Özçelik / April 2, 2026</p>","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":"<p>We set out to replace a shell script with Go tests.</p> <p>We ended up discovering that \"code quality\" and \"agent readability\" are the same thing.</p> <p>This is not about linting. This is about controlling how an agent perceives your system.</p> <p>One term will recur throughout this post, so let me pin it down:</p> <p>Agent Readability</p> <p>Agent Readability is the degree to which a codebase can be understood through structured traversal, not statistical pattern matching.</p> <p>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.</p>","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":"<p><code>ctx</code> had a file called <code>hack/lint-drift.sh</code>. It ran five checks using <code>grep</code> and <code>awk</code>: literal <code>\"\\n\"</code> strings, <code>cmd.Printf</code> calls outside the write package, magic directory strings in <code>filepath.Join</code>, hardcoded <code>.md</code> extensions, and DescKey-to-YAML linkage.</p> <p>It worked. Until it didn't.</p> <p>The script had three structural weaknesses that kept biting us:</p> <ol> <li>No type awareness. It could not distinguish a <code>Use*</code> constant from a <code>DescKey*</code> constant, causing 71 false positives in one run.</li> <li>Fragile exclusions. When a constant moved from <code>token.go</code> to <code>whitespace.go</code>, the exclusion glob broke silently.</li> <li>Ceiling on detection. Checks that require understanding call sites, import graphs, or type relationships are impossible in shell.</li> </ol> <p>We wrote a spec to replace all five checks with Go tests using <code>go/ast</code> and <code>go/packages</code>. The tests would run as part of <code>go test ./...</code>: no separate script, no separate CI step.</p> <p>What we did not expect was where the work would lead.</p>","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":"<p>The pattern for each test is identical:</p> <pre><code>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</code></pre> <p>Load packages once via <code>sync.Once</code>, walk every syntax tree, collect violations, report. The shared helpers (<code>loadPackages</code>, <code>isTestFile</code>, <code>posString</code>) live in <code>helpers_test.go</code>. Each test is a <code>_test.go</code> file in <code>internal/audit/</code>, producing no binary output and not importable by production code.</p> <p>In a single session, we built 13 new tests on top of 6 that already existed, bringing the total to 19:</p> Test What it catches <code>TestNoLiteralWhitespace</code> <code>\"\\n\"</code>, <code>\"\\t\"</code>, <code>'\\r'</code> outside <code>config/token/</code> <code>TestNoNakedErrors</code> <code>fmt.Errorf</code>/<code>errors.New</code> outside <code>internal/err/</code> <code>TestNoStrayErrFiles</code> <code>err.go</code> files outside <code>internal/err/</code> <code>TestNoRawLogging</code> <code>fmt.Fprint*(os.Stderr)</code>, <code>log.Print*</code> outside <code>internal/log/</code> <code>TestNoInlineSeparators</code> <code>strings.Join</code> with literal separator arg <code>TestNoStringConcatPaths</code> Path-like variables built with <code>+</code> <code>TestNoStutteryFunctions</code> <code>write.WriteJournal</code> repeats package name <code>TestDocComments</code> Missing doc comments on any declaration <code>TestNoMagicValues</code> Numeric literals outside const definitions <code>TestNoMagicStrings</code> String literals outside const definitions <code>TestLineLength</code> Lines exceeding 80 characters <code>TestNoRegexpOutsideRegexPkg</code> <code>regexp.MustCompile</code> outside <code>config/regex/</code> <p>Plus the six that preceded the session: <code>TestNoErrorsAs</code>, <code>TestNoCmdPrintOutsideWrite</code>, <code>TestNoExecOutsideExecPkg</code>, <code>TestNoInlineRegexpCompile</code>, <code>TestNoRawFileIO</code>, <code>TestNoRawPermissions</code>.</p> <p>The migration touched 300+ files across 25 commits.</p> <p>Not because the tests were hard to write, but because every test we wrote revealed violations that needed fixing.</p>","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":"<p>The most instructive part was not writing the tests. It was the iterative tightening.</p> <p>The following process was repeated for every test:</p> <ol> <li>Write the test with reasonable exemptions</li> <li>Run it, see violations</li> <li>Fix the violations (migrate to config constants)</li> <li>The human reviews the result</li> <li>The human spots something the test missed</li> <li>Fix the test first, verify it catches the issue</li> <li>Fix the newly caught violations</li> <li>Repeat from step 4</li> </ol> <p>This loop drove the tests from \"basically correct\" to \"actually useful\". </p> <p>Three examples:</p>","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":"<p><code>TestNoMagicValues</code> initially exempted local constants inside function bodies. This let code like this pass:</p> <pre><code>const descMaxWidth = 70\ndesc := truncateDescription(\n meta.Description, descMaxWidth,\n)\n</code></pre> <p>The test saw a <code>const</code> definition and moved on. But <code>const descMaxWidth = 70</code> on the line before its only use is just renaming a magic number. The <code>70</code> should live in <code>config/format/TruncateDescription</code> where it is discoverable, reusable, and auditable.</p> <p>We removed the local const exemption. The test caught it. The value moved to config.</p>","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":"<p><code>TestNoMagicStrings</code> initially exempted all single-character strings as \"structural punctuation\". </p> <p>This let <code>\"/\"</code>, <code>\"-\"</code>, and <code>\".\"</code> pass everywhere.</p> <p>But <code>\"/\"</code> is a directory separator. It is OS-specific and a security surface. </p> <p><code>\"-\"</code> used in <code>strings.Repeat(\"-\", width)</code> is creating visual output, not acting as a delimiter. </p> <p><code>\".\"</code> in <code>strings.SplitN(ver, \".\", 3)</code> is a version separator.</p> <p>None of these are \"just punctuation\": They are domain values with specific meanings.</p> <p>We removed the blanket exemption: 30 violations surfaced. </p> <p>Every one was a real magic value that should have been <code>token.Slash</code>, <code>token.Dash</code>, or <code>token.Dot</code>.</p>","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":"<p>After migrating magic strings, we had this:</p> <pre><code>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</code></pre> <p>Six token references and a <code>NewReplacer</code> allocation. The magic values were gone, but we had replaced them with token soup: structure without abstraction. </p> <p>The correct tool was a regex:</p> <pre><code>// 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</code></pre> <p>One config regex, one call. The regex lives in <code>config/regex/file.go</code> where every other compiled pattern lives. An agent reading the code sees <code>regex.MermaidUnsafe</code> and immediately knows: this is a sanitization pattern, it lives in the regex registry, and it has a name that explains its purpose.</p> <p>Clean is better than clever.</p>","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":"<p>To make the agent-readability claim concrete, consider one function through the full transformation.</p> <p>Before (the code we started with):</p> <pre><code>func MermaidID(pkg string) string {\n r := strings.NewReplacer(\n \"/\", \"_\", \".\", \"_\", \"-\", \"_\",\n )\n return r.Replace(pkg)\n}\n</code></pre> <p>An agent reading this sees six string literals. To understand what the function does, it must: (1) parse the <code>NewReplacer</code> pair semantics, (2) infer that <code>/</code>, <code>.</code>, <code>-</code> are being replaced, (3) guess why, (4) hope the guess is right.</p> <p>There is nothing to follow. No import to trace. No name to search. The meaning is locked inside the function body.</p> <p>After (the code we ended with):</p> <pre><code>func MermaidID(pkg string) string {\n return regex.MermaidUnsafe.ReplaceAllString(\n pkg, token.Underscore,\n )\n}\n</code></pre> <p>An agent reading this sees two named references: <code>regex.MermaidUnsafe</code> and <code>token.Underscore</code>. </p> <p>To understand the function, it can: (1) look up <code>MermaidUnsafe</code> in <code>config/regex/file.go</code> and see the pattern <code>[/.\\-]</code> with a doc comment explaining it matches invalid Mermaid characters, (2) look up <code>Underscore</code> in <code>config/token/delim.go</code> and see it is the replacement character.</p> <p>The agent now has: a named pattern, a named replacement, a package location, documentation, and neighboring context (other regex patterns, other delimiters). </p> <p>It got all of this for free by following just two references.</p> <p>The indirection is not an overhead. It is the retrieval query.</p>","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":"<p>You are not just improving code quality. You are shaping the input space that determines how an LLM can reason about your system.</p> <p>Every structural constraint we enforce converts implicit semantics into explicit structure. </p> <p>LLMs struggle when meaning is implicit and patterns are statistical. </p> <p>They thrive when meaning is explicit and structure is navigable.</p> <p>Here is what we learned, organized into three categories.</p>","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":"<p>These force agents (and humans) to think harder.</p> <p>Indirection acts as a built-in retrieval mechanism:</p> <p>Moving magic values to config forces the agent to follow the reference. <code>errMemory.WriteFile(cause)</code> tells the agent \"there is a memory error package, go look.\" <code>fmt.Errorf(\"writing MEMORY.md: %w\", cause)</code> inlines everything and makes the call graph invisible. The indirection IS the retrieval query.</p> <p>Unfamiliar patterns force reasoning:</p> <p>When an agent sees <code>token.Slash</code> instead of <code>\"/\"</code>, it cannot coast on corpus frequency. It has to actually look up what <code>token.Slash</code> 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.</p> <p>Documentation helps everyone:</p> <p>Extensive documentation helps humans reading the code, agents reasoning about it, and RAG systems indexing it.</p> <p>Our <code>TestDocComments</code> check added 308 doc comments in one commit. Every function, every type, every constant block now has a doc comment. </p> <p>This is not busywork: it is the content that agents and embeddings consume.</p>","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":"<p>These shape the codebase into a navigable graph.</p> <p>Shorter files save tokens:</p> <p>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.</p> <p>Fixed-width constraints force decomposition:</p> <p>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). </p> <p>The constraint forces structural improvements that happen to also make the code more parseable.</p> <p>Chunk-friendly structure helps RAG</p> <p>Code intelligence tools chunk files for embedding and retrieval. Short, well-documented, single-responsibility files produce better chunks than monolithic files with mixed concerns. </p> <p>The structural constraints create files that RAG systems can index effectively.</p> <p>Centralization creates debuggable seams:</p> <p>All error handling in <code>internal/err/</code>, all logging in <code>internal/log/</code>, all file operations in <code>internal/io/</code>. 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 <code>fmt.Errorf</code> calls.</p> <p>Private functions become public patterns:</p> <p>When you extract a private function to satisfy a constraint, it often ends up as a semi-public function in a <code>core/</code> package. Then you realize it is generic enough to be factored into a purpose-specific module.</p> <p>The constraint drives discovery of reusable abstractions hiding inside monolithic functions.</p>","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":"<p>These pay dividends in daily development.</p> <p>Single-edit renames:</p> <p>Renaming a flag is one edit to a config constant instead of find-and-replace across 30,000 lines with possible misses. <code>grep token.Slash</code> gives you every place that uses a forward slash semantically.</p> <p><code>grep \"/\"</code> gives you noise.</p> <p>Blast radius containment:</p> <p>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\".</p> <p>Compile-time contract enforcement:</p> <p>When <code>err/memory.WriteFile</code> exists, the compiler guarantees the error message exists and the call signature is correct. An inline <code>fmt.Errorf</code> can have a typo in the format string and nothing catches it until runtime. Centralization turns runtime failures into compile errors.</p> <p>Semantic <code>git blame</code>:</p> <p>When <code>token.Slash</code> is used everywhere and someone changes its value, <code>git blame</code> on the config file shows exactly when and why. </p> <p>With inline <code>\"/\"</code> scattered across 30 files, the history is invisible.</p> <p>Test surface reduction:</p> <p>Centralizing into <code>internal/err/</code>, <code>internal/io/</code>, <code>internal/config/</code> means you test behavior once at the boundary and trust the callers. </p> <p>You do not need 30 tests for 30 <code>fmt.Errorf</code> calls. You need 1 test for <code>errMemory.WriteFile</code> and 30 trivial call-site audits, which is exactly what these AST tests provide.</p>","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":"<p>One session. 25 commits. The raw stats:</p> 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 <p>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.</p>","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":"<p>None of this is Go-specific.</p> <p>If an AI agent interacts with your codebase, your codebase already is an interface. You just have not designed it as one.</p> <p>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 <code>write.WriteJournal</code>, the agent wastes tokens on redundant information.</p> <p>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.</p> <p>This is not a coincidence: These constraints exist because they reduce the cognitive load of understanding code. </p> <p>Agents have cognitive load too: It is called the context window.</p> <p>You are not converting code to a new paradigm.</p> <p>You are making the latent graph visible.</p> <p>You are converting implicit semantics into explicit structure that both humans and machines can traverse.</p>","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":"<p>The spec lists 8 more tests we have not built yet, including <code>TestDescKeyYAMLLinkage</code> (verifying that every DescKey constant has a corresponding YAML entry), <code>TestCLICmdStructure</code> (enforcing the <code>cmd.go</code> / <code>run.go</code> / <code>doc.go</code> file convention), and <code>TestNoFlagBindOutsideFlagbind</code> (which requires migrating ~50 flag registration sites first).</p> <p>The broader question: should these principles be codified as a reusable linting framework? The patterns (<code>loadPackages</code> + <code>ast.Inspect</code> + violation collection) are generic. </p> <p>The specific checks are project-specific. But the categories of checks (centralization enforcement, magic value detection, naming conventions, documentation requirements) are universal.</p> <p>For now, 19 tests in <code>internal/audit/</code> is enough. They run in 2 seconds as part of <code>go test ./...</code>. They catch real issues. </p> <p>And they encode a theory of code quality that serves both humans and the agents that work alongside them.</p> <p>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.</p> <p>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.</p> <p>Structure is no longer just for maintainability. It is for reasonability.</p>","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":"<p>Give an agent a graph query tool, and it will tell you everything about your codebase except what actually matters.</p> <p>Volkan Özçelik / April 6, 2026</p>","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":"<p>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.</p> <p>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.</p> <p>Both halves of this metaphor showed up in a single experiment. And the result changed how we design architecture analysis in [<code>ctx</code>][<code>ctx</code>].</p>","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":"<p>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.</p> 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 <p>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.</p> <p>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.</p> <p>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.</p> <p>And hollow.</p>","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":"<p>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.</p> <p>Not wrong. Not broken. Just... thin.</p> <p>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.</p> <p>The tool answered the question asked but prevented the discovery of answers to questions never asked.</p> <p>Here's what that looks like concretely: the graph tells you that <code>ReconcileDeployment</code> calls <code>SyncPods</code>. It does not tell you that <code>SyncPods</code> 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.</p> <p>The operational reality is invisible.</p>","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":"<p>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). </p> <p>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?</p> <p>The agent isn't lazy. It's rational. </p> <p>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).</p> <p>Satisficing produces watermelon rinds.</p>","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":"<p>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.</p> <p>You can't enrich your way out of a depth deficit.</p> <p>So we redesigned. Instead of one skill with optional tools, we built a two-pass compiler for architecture understanding:</p> <p>Pass 1: Semantic parsing. The <code>/ctx-architecture</code> 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.</p> <p>Pass 2: Static analysis. The <code>/ctx-architecture-enrich</code> 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.</p> <p>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.</p>","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":"<p>We call this constraint-as-feature: deliberately withholding capabilities to force deeper engagement.</p> <p>It sounds paradoxical. You built sophisticated code intelligence tools and then... forbid the agent from using them? During the most important phase?</p> <p>Yes. Because the tools don't make the agent smarter. They make it faster. And faster, in architecture analysis, is the enemy of deep.</p> <p>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.</p> <p>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.</p>","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":"<p>Not always. The watermelon-rind antipattern is specific to exploratory analysis: tasks where the value comes from discovering unknowns, not from answering known questions.</p> <p>Graph tools are excellent for:</p> <ul> <li>Verification: \"Does X actually call Y?\" (binary question, precise answer)</li> <li>Impact analysis: \"What breaks if I change Z?\" (bounded scope, enumerable results)</li> <li>Navigation: \"Where is this interface implemented?\" (lookup, not analysis)</li> </ul> <p>Graph tools produce watermelon rinds when:</p> <ul> <li>The goal is understanding, not answering</li> <li>The unknowns are unknown: you don't know what to ask</li> <li>Depth matters more than breadth: operational details, edge cases, implicit coupling</li> </ul> <p>The two-pass approach preserves both: deep reading first, tool verification second.</p>","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":"<p>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.</p> <p>Esegin aklina karpuz kabugu sokma!</p> <p>(don't put the watermelon rind to a donkey's mind)</p> <p>If the agent never struggles, it never discovers. And if it never discovers, you are not doing architecture; you are doing autocomplete.</p> <p>This post is part of the <code>ctx</code> field notes series, documenting what we learn building persistent context infrastructure for AI coding sessions.</p>","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/","level":1,"title":"The Cheapest Patch Was the Most Expensive","text":"","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-seven-ai-coding-runs-taught-me-about-cost","level":2,"title":"What Seven AI Coding Runs Taught Me About Cost","text":"<p>Volkan Özçelik / June 21, 2026</p> <p>What Does a Cheap Patch Actually Cost?</p> <p>The cheapest run fixed the visible bug in four minutes for thirty-five cents, and missed the contract entirely.</p> <p>The most expensive run wrote a strong patch, and quietly changed a product decision nobody asked it to change.</p> <p>Neither number on the invoice told you either of those things.</p> <p>I ran a small AI coding experiment on a real CLI bug.</p> <p>The bug was boring, which made it useful.</p> <p>A command accepted a comma-separated list of secret versions. This worked:</p> <pre><code>--versions \"1,2,3\"\n</code></pre> <p>This looked like it worked:</p> <pre><code>--versions \"1, 2, 3\"\n</code></pre> <p>But one command silently sent only the first version.</p> <p>The validation path handled whitespace. The conversion path did not.</p> <p>For example, <code>\"1, 2, 3\"</code> became <code>[1]</code>.</p> <p>A sibling command had similar parsing code, but not the exact same failure. The right fix was not \"make this one line trim spaces\". The right fix was to stop duplicating the parsing logic and send both commands through the same parser.</p> <p>It was easy to see if you knew the codebase, but deceptively complex if you were unfamiliar with the project. For reference, the project is SPIKE.</p> <p>So I thought I could run a controlled experiment on how spec-driven development methodologies, context-compression techniques, <code>ctx</code>, and different model choices play together.</p> <p>If I were to write a paper (and I am planning to write one), the thesis would read something like this:</p> <pre><code>We evaluate whether context-engineering tools reduce the real cost of\nagentic coding under spec-driven development. Rather than measuring token\nsavings alone, we measure accepted-patch cost: model cost, repair loops,\nhidden acceptance failures, and human review burden. On a substantial\ncross-layer task in the SPIFFE/SPIKE repository, we compare direct\nissue-to-code prompting, frontier-authored SDD artifacts, weak-authored\nartifacts with frontier ratification, and multiple context conditions\nincluding structured context manifests, shell-output compression, and\ncontext-runtime filtering. Our results show whether token savings translate\ninto accepted patches, and identify when context tools help, hurt, or merely\nmove cost into review.\n</code></pre> <p>This Is a Weekend Hack, Not the Paper</p> <p>To make this paper-grade, I figured I would need to run ~500 controlled agentic experiments, each spanning at least half an hour. That is not a weekend hack. So I picked a meaningful subset, ran them end-to-end, and that is what you are reading. </p> <p>Treat these numbers as signal, not as proof.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-shared-parser","level":2,"title":"The Shared Parser","text":"<p>One more detail about the task at hand: there was already a shared parser: An agent leveraging the shared parser would already implement half of the solution and have a head-start. An agent that missed the parser would burn tokens rebuilding what was already there.</p> <p>And that detail changed the entire task:</p> <ul> <li>The job was not to design a parser.</li> <li>It was to wire an existing helper into two commands, preserve the product contract, and add focused command tests.</li> </ul> <p>But the agents that were going to implement this did not know that a priori.</p> <p>That is where the whole experiment became interesting.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-task-at-hand","level":2,"title":"The Task at Hand","text":"<p>The accepted behavior was:</p> <pre><code>\"1, 2, 3\" -> [1, 2, 3]\n</code></pre> <p>Other decisions mattered too:</p> <ul> <li><code>\"\"</code> or whitespace-only selector -> <code>[0]</code></li> <li><code>0</code> remains the current-version sentinel</li> <li>empty inner tokens are rejected</li> <li>non-integers are rejected</li> <li>negative integers are rejected</li> <li>duplicates are preserved</li> <li>no SDK/API/backend/state changes</li> <li>no framework rewrite</li> </ul> <p>The invariant was simple:</p> <pre><code>Accept the whole selector,\nor reject the whole selector before any API call.\n\nDo not silently drop a token.\n</code></pre> <p>The bug was small enough that any strong model could patch something. Yet it was large enough that a quick patch could be wrong in ways that looked correct from the outside.</p> <p>A perfect setup.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-runs","level":2,"title":"The Runs","text":"<p>I ran multiple implementations of the same task.</p> <p>Some runs used context compression (reducing token count by eliminating unnecessary content that flows to and from the model, while keeping the compression as lossless as possible). Some did not.</p> <p>Here is an uncompressed CLI call:</p> <pre><code>volkan@sdd:~/WORKSPACE$ ls -al\ntotal 534724\ndrwxrwxr-x 6 volkan volkan 4096 Jun 20 22:02 .\ndrwxr-x--- 21 volkan volkan 4096 Jun 21 14:04 ..\ndrwxr-xr-x 25 volkan volkan 4096 Jun 20 11:35 ctx\ndrwxrwxr-x 19 volkan volkan 4096 Jun 20 12:46 ctx-bak\ndrwxrwxr-x 2 volkan volkan 4096 Jun 20 19:55 harness\ndrwxrwxr-x 22 volkan volkan 4096 Jun 20 21:35 spike\n-rw-rw-r-- 1 volkan volkan 78242134 Jun 20 20:51 spike-haiku-for-spec-tooling-on-haiku-for-exec.zip\n-rw-rw-r-- 1 volkan volkan 78116329 Jun 20 18:00 spike-opus-4-8-xhigh-no-tooling.zip\n-rw-rw-r-- 1 volkan volkan 78225976 Jun 20 19:54 spike-sonnet-4-6-medium-tooling-on-haiku-for-exec.zip\n-rw-rw-r-- 1 volkan volkan 78176133 Jun 20 19:39 spike-sonnet-4-6-medium-tooling-on-sonnet-for-exec.zip\n-rw-rw-r-- 1 volkan volkan 78245337 Jun 20 21:52 spike-sonnet-medium-for-all-tooling-off.zip\n-rw-rw-r-- 1 volkan volkan 78282827 Jun 20 22:02 spike-sonnet-medium-for-specs-haiku-for-exec-no-tooling.zip\n-rw-rw-r-- 1 volkan volkan 78217444 Jun 20 20:06 spike-yolo-no-specs-haiku-for-exec.zip\n</code></pre> <p>And here is the compressed version for comparison:</p> <pre><code>755 ctx/\n775 ctx-bak/\n775 harness/\n775 spike/\n664 spike-haiku-for-spec-tooling-on-haiku-for-exec.zip 74.6M\n664 spike-opus-4-8-xhigh-no-tooling.zip 74.5M\n664 spike-sonnet-4-6-medium-tooling-on-haiku-for-exec.zip 74.6M\n664 spike-sonnet-4-6-medium-tooling-on-sonnet-for-exec.zip 74.6M\n664 spike-sonnet-medium-for-all-tooling-off.zip 74.6M\n664 spike-sonnet-medium-for-specs-haiku-for-exec-no-tooling.zip 74.7M\n664 spike-yolo-no-specs-haiku-for-exec.zip 74.6M\n\nSummary: 7 files, 4 dirs (7 .zip)\n</code></pre> <p>The goal of the compression was to preserve meaningful content while cutting the fluff that would not typically benefit the agent.</p> <p>In this experiment:</p> <pre><code>compression ON = both context compression layers enabled\ncompression OFF = both context compression layers disabled\n</code></pre> <p>Except for one \"YOLO this thing end to end\" negative-control case, every serious run went through a structured debrief/spec/task workflow, following a formal spec-driven-development methodology.</p> <p>The decisions the agent made were not necessarily caused by information loss during compression. They were more about the quality and the shape of the context available while the plan hardened. Which also meant the quality of the agent (and the human) mattered a lot during the planning and spec-development phase.</p> <p>Here is the short summary of the experiments. For simplicity, and to keep this a weekend hack, I only used Anthropic models.</p> Run Planning / discovery Implementation Quality / caveat Opus end-to-end, compression OFF$16.25 · 59m27s Handled the debrief/spec/task work and implementation. Opus implemented. Strong patch. It also tightened behavior beyond the final compatibility decision by rejecting whitespace-padded selectors. Sonnet, compression ON$6.43 · 1h04m15s Completed the structured workflow, but planned larger parser work. Sonnet implemented. Acceptable, but larger than necessary. Sonnet, compression OFF$6.11 · 50m13s Found that <code>parseVersionList()</code> already existed and narrowed the task to wiring. Sonnet implemented. Preferred patch shape. Haiku, compression ON$2.15 · 39m53s Completed the structured workflow after steering. Haiku implemented. Cheap, but needed steering. Weak at repo discovery. Sonnet OFF plan, Haiku implementation~$4.92 · ~50m15s Sonnet (compression OFF) found and specified the smaller wiring task. Haiku implemented the ratified task list. Worth repeating as a follow-up experiment. Not a default rule. Sonnet ON plan, Haiku implementation~$4.9 · composite Sonnet (compression ON) planned the larger parser task. Haiku implemented the ratified task list. Acceptable, but inherited the larger premise. Haiku YOLO$0.35 attempt · 4m23s No structured workflow. Haiku implemented directly. Rejected: Fixed the visible symptom, but missed the accepted contract. <p>The two Sonnet end-to-end rows above deserve closer attention.</p> <p>Same model family. Same general workflow. Different compression setting.</p> <ul> <li>With compression OFF, the model found the existing helper and narrowed the work.</li> <li>With compression ON, the model planned a larger parser task.</li> </ul> <p>That single repo fact mattered more than the model price.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-cost-table-that-looks-boring-but-isnt","level":2,"title":"The Cost Table That Looks Boring But Isn't","text":"<p>At one checkpoint, the numbers looked almost tied.</p> Sonnet planning run Cost API time Wall time Resulting implementation delta Compression ON $4.39 16m48s 49m42s +1331 / -137 Compression OFF $4.40 17m22s 44m00s +1152 / -165 <p>A quick read says compression did not matter.</p> <p>That read misses the implementation shape.</p> <p>By this checkpoint, the compression-OFF run had already found <code>parseVersionList()</code> and narrowed the task to wiring the helper. The compression-ON run was still carrying a larger parser-work premise.</p> <p>Read it again with the shape in mind. Both runs cost about the same. The compression-OFF run reused an existing helper; the compression-ON run was set up to rebuild that logic from scratch. So compression did save context budget. The saving was then spent carrying a less accurate premise. The dollars came out even; the work did not.</p> <p>Compression Fails Quietly</p> <p>Compression did not fail loudly. It produced coherent artifacts.</p> <p>They were useful artifacts. It was solving the problem and meeting every product requirement.</p> <p>It was also expanding the wrong-sized job. That is the dangerous part: a failure that ships clean.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-patch-quality-review","level":2,"title":"The Patch Quality Review","text":"<p>A frontier-model-assisted static review told a cleaner story than raw cost.</p> Case Verdict Why / operating read Sonnet compression OFF / Sonnet implementation Preferred, with slightly enhanced spec-cpreation workflow Found existing parser, wired both commands, strongest command tests. Minor caveat: version parsing moved before some source/auth checks. Sonnet compression ON / Sonnet implementation Preferred, but patch was larger than necessary Fixed the bug, but missed the existing helper during planning. To be clear, compression was not the main issue; the setup needed a better ratified spec to guide the agent. Sonnet compression OFF / Haiku implementation Acceptable bounded-executor trial Haiku followed the ratified plan, but tests were thinner. This supports retesting cheap execution after task shape is fixed. Haiku compression ON / Haiku implementation Risky: Usable after excessive steering, weak as scout Core behavior was right, but proof and cleanup were weaker. Sonnet compression ON / Haiku implementation Acceptable, but inherited larger premise The implementation stayed inside the earlier parser-work shape. Opus 4.8 x-high Strong patch, contract drift Strong and conservative. It rejected whitespace-padded selectors, which diverged from the final product decision. Haiku YOLO Rejected as Incomplete Fixed <code>\"1, 2, 3\"</code> but kept duplicated parsing and missed whitespace-only <code>[0]</code>. <p>This table should not be read as \"use the cheapest model\". It says something more significant:</p> <p>Cheap execution can be tested after the task shape is fixed.</p> <p>Cheap discovery, without a comprehensive spec, was not reliable in this experiment. Cheap YOLO produced a patch-shaped answer, not an accepted patch.</p> <p>There is a large difference between:</p> <pre><code>the model produced a diff\n</code></pre> <p>and:</p> <pre><code>the model produced the accepted patch\n</code></pre> <p>The accepted patch is the metric that matters. That gap between cheap production and directed judgment is the whole subject of Code Is Cheap. Judgment Is Not., and this experiment is the same lesson with an invoice attached.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-most-expensive-model-is-not-automatically-safer","level":2,"title":"The Most Expensive Model Is Not Automatically Safer","text":"<p>The Opus run was strong. It was also too eager.</p> <p>It rejected whitespace-padded selectors. That is a defensible CLI grammar if you are designing from scratch. It is not what the final compatibility contract said.</p> <p>A stronger model can preserve more context, reason more carefully, and still make a product decision you did not ask it to make.</p> <p>You can argue that the model is taking initiative here, thinking like a senior engineer to make the product more secure and reliable. But this is a distinct failure mode worth watching:</p> <ul> <li>The cheap YOLO model missed parts of the contract.</li> <li>The expensive model tried to improve the contract.</li> </ul> <p>Both Require Review</p> <p>The lesson is not \"small models bad, large models good\". The useful split is three separate questions:</p> <ul> <li>which model is deciding the task shape;</li> <li>which model is executing a ratified task;</li> <li>and which human checkpoint catches contract drift.</li> </ul> <p>Under-reach and over-reach are both contract drift. You cannot afford to review for only one of them.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#scout-versus-executor","level":2,"title":"Scout Versus Executor","text":"<p>The transcripts showed the models behaving differently, not just costing differently.</p> <p>The compression-OFF Sonnet run read the repo and changed the task. It found the helper and stated the situation outright:</p> <pre><code>undelete.go does not have this bug; delete.go does;\nparseVersionList already fixes it.\n</code></pre> <p>The structured Haiku run, from the same starting point, tended to hand repo questions back to the human instead of answering them from the code:</p> <pre><code>Does undelete.go already have the correct behavior?\n</code></pre> <p>That is a question a careful reading pass should have closed: </p> <p>It is the line between a scout that establishes the task shape and a bounded executor that needs the shape handed to it. </p> <p>Haiku was a capable executor once the task was pinned, and an unreliable scout before it.</p> <p>The scout did not just find the smaller job; it built less of it. </p> <p>Both Sonnet runs went end-to-end through the same workflow, but the compression-OFF run produced a smaller final diff (+1300 / -260 versus +1542 / -202), because once the job was \"wire the parser\" there was simply less to build.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#token-telemetry","level":2,"title":"Token Telemetry","text":"<p>The telemetry had a few surprises. These counts are computed from the raw session logs across every run (token counts only; the dollar figures come from the run summaries):</p> Scope Requests Input tokens Output tokens Cache read Cache write All sessions 874 51,102 554,094 63,946,649 2,268,906 Top-level 664 42,623 510,465 58,253,517 1,854,589 Subagents 210 8,479 43,629 5,693,132 414,317 <p>Read the cache-read column again: </p> <p>Fresh input was about 51K tokens and output about 554K, but the runs read back roughly 64 million cached tokens. </p> <p>Cache reuse, not fresh reasoning, is where the token activity lived; and subagents accounted for only ~5.7M of those ~64M reads, so they were not the sink either.</p> <p>This is an activity table, not a billing table. Cache reads are cheap per token, which is why a run can move 64 million of them without the dollar figure exploding: the money lives in the cost tables above; the attention lives here.</p> <p>Findings:</p> <ol> <li>Cache-read tokens dominated the token profile.</li> <li>Subagents were not the main token sink.</li> <li>Haiku was cheaper in dollars, not necessarily smaller in raw token activity.</li> <li>The preferred Sonnet result was not better because it reasoned less. It was better because it found the smaller job: wire the existing <code>parseVersionList()</code> helper instead of creating or extracting a new parser.</li> </ol> <p>The raw activity matters because \"cheap\" can mean several different things:</p> <ul> <li>it can mean cheaper dollars;</li> <li>it can mean fewer tokens;</li> <li>it can mean less wall-clock time;</li> <li>it can mean fewer review minutes.</li> </ul> <p>Those are not the same thing.</p> <p>Accounting Fraud With a Patch File</p> <p>In this experiment, the cheap YOLO attempt had the lowest cost. </p> <p>It also galactically missed the contract.</p> <p>Counting that as a win would be accounting fraud with a patch file attached.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#workflow-enhancement","level":2,"title":"Workflow Enhancement","text":"<p>The code bug was easy to describe.</p> <p>The workflow enhancement requirement was more subtle.</p> <p>The structured flow did many things right:</p> <ul> <li>it found behavior,</li> <li>produced artifacts,</li> <li>recorded non-goals,</li> <li>and guided implementation.</li> </ul> <p>The gap was earlier and more mechanical:</p> <pre><code>before the spec expands, prove what already exists\n</code></pre> <p>The helper existed. The workflow needed to force that fact into the first controlling artifact.</p> <p>Without that inventory, the pipeline can faithfully expand a plausible task that is larger than necessary.</p> <p>That is how you get a detailed spec for the wrong-sized job. It is the same failure that The Dog Ate My Homework documented from the other direction: the expensive mistakes happen when an agent writes before it has truly read.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-fix-make-problem-space-inventory-a-hard-gate","level":2,"title":"The Fix: Make Problem-Space Inventory a Hard Gate","text":"<p>The operating model I would use after this experiment is artifact-gated:</p> <pre><code>/plan:\n produce a repo-grounded debated brief\n include implementation inventory and task-shape correction\n\nhuman ratification:\n confirm the debated brief before it becomes spec input\n\n/spec:\n turn the ratified brief into a product/engineering contract\n\nhuman ratification:\n confirm the spec intent before spec-kit expands it\n\nspec-kit:\n generate spec/plan/tasks/analyzer output from the ratified intent\n\nhuman ratification:\n confirm the generated tasks before coding starts\n\nimplementation:\n execute the ratified task list\n do not re-open task shape unless review sends it back\n\nacceptance:\n measure accepted patch cost, not attempt cost\n</code></pre> <p>Implementation model choice happens only after the task list is ratified.</p> <p>Which Model for Which Job</p> <ul> <li>Use a cheaper model only when the task is well-defined and the spec is crystal clear beyond any reasonable doubt.</li> <li>Use the default model most of the time; you will still need a decent spec, not a two-paragraph prompt.</li> <li>Use a stronger model only when the implementation requires judgment, security reasoning, broad refactoring, fresh discovery, or adversarial scrutiny. Ironically, your spec here needs to be crisper, not looser: the model will attack it, find gaps, and fix them if it decides that is the right call. Be very clear about why you need what you need.</li> </ul>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-plan-must-prove","level":2,"title":"What <code>/plan</code> Must Prove","text":"<p>For this class of task, <code>/plan</code> should not finish until it records:</p> <ul> <li>existing helpers</li> <li>existing tests</li> <li>similar commands</li> <li>already-correct behavior</li> <li>files that should remain unchanged</li> <li>whether the task is wiring, deletion, extraction, or new behavior</li> </ul> <p>For the CLI bug, that inventory would have found:</p> <ul> <li><code>parseVersionList()</code> already exists</li> <li>delete uses duplicated parsing</li> <li>undelete has similar code but not the same bug</li> <li>the accepted fix is wiring, not parser design</li> </ul> <p>That would have prevented the larger parser-work premise from surviving into the spec.</p> <p>The spec was not the problem; the input to the spec was underspecified.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-spec-kit-gotcha","level":2,"title":"The <code>spec-kit</code> Gotcha","text":"<p>Spec generation is seductive because it makes the work look settled.</p> <p>A generated task list feels like progress:</p> <ul> <li>it has IDs,</li> <li>it has dependencies,</li> <li>it has phases,</li> <li>it has checkboxes.</li> </ul> <p>But if the task shape is wrong, the checkboxes become a very tidy way to do extra work.</p> <p>That does not make <code>spec-kit</code> (or equivalent tools) bad. It means <code>spec-kit</code> should not be the first place where repo understanding becomes concrete. Use spec expansion after a debated brief is ratified.</p> <p>Also, do not assume the implementation command is an interactive review loop. Treat it as an executor. If you need a checkpoint after every task or phase, enforce that in the wrapper or in the prompt:</p> <pre><code>implement T001\nstop\nsummarize diff and tests\nwait for approval before T002\n</code></pre> <p>There is a subtler trap. The generated artifacts are themselves model output. In one run the structured flow held the \"stop before commit\" line well, but the generated task list quietly reintroduced \"commit after each phase\" language that had to be edited back out. The workflow can constrain a cheap model; the workflow's own artifacts still need a human read.</p> <p>Trust Is Not a Workflow</p> <p>Trusting the final result is not a workflow. It is a hope with a diff.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#context-compression","level":2,"title":"Context Compression","text":"<p>Compression is attractive because it reduces what the model has to carry, saving valuable dollars.</p> <p>That is also the risk:</p> <p>Compression can preserve conclusions while dropping the dull facts that made the conclusion safe.</p> <p>In this experiment, the dull fact was a parser helper.</p> <ul> <li>No architecture diagram screams about an existing helper.</li> <li>No spec requirement says \"check whether this already exists\" unless you make it say that.</li> <li>No generated task list rescues you if the earlier artifact already chose the wrong implementation shape.</li> </ul> <p>This is the same shape as the watermelon-rind anti-pattern: a mechanism that answers the question asked can quietly prevent the discovery of the question you should have asked. A graph tool did it there by collapsing the search space; in this run, compression did it by dropping the boring line that would have changed the plan. And it is the mirror image of The Attention Budget: more context is not automatically better, but less context is not automatically cheaper either.</p> <p>Compression Needs a Counterweight</p> <p>Do not treat compression as free savings. Pair it with:</p> <ul> <li>inventory before compression hardens into a plan;</li> <li>ratification before spec expansion;</li> <li>review before implementation.</li> </ul>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-yolo-fun","level":2,"title":"The YOLO Fun","text":"<p>The cheap YOLO run was useful because it showed the trap.</p> <p>It quickly fixed the visible symptom:</p> <ul> <li>a shallow test could have passed;</li> <li>the diff would look reasonable in a hurry.</li> </ul> <p>However, it did not preserve the full accepted behavior:</p> <ul> <li>it did not remove duplicated parsing;</li> <li>it did not handle whitespace-only <code>[0]</code>.</li> </ul> <p>This is the difference between symptom repair and contract repair.</p> <p>A model can pass the obvious bug report while failing the actual engineering task.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-i-would-repeat","level":2,"title":"What I Would Repeat","text":"<p>I would repeat the Sonnet compression comparison on more tasks.</p> <p>This task says:</p> <pre><code>compression OFF found the smaller job\ncompression ON planned the larger job\n</code></pre> <p>That is one task, not a universal law.</p> <p>I would also repeat the \"strong model plans, cheaper model executes\" pattern, but now with a strict acceptance review. The result is interesting because it may reduce cost after the task shape is fixed.</p> <p>The numbers hint at why it is worth a look. Once the task was pinned, the Haiku edit on top of the ratified Sonnet plan was about ninety lines and cost roughly fifty cents. The composite came to about $4.92 against $6.11 for Sonnet end-to-end: close to 20% cheaper. </p> <p>That saving is real only if the cheap patch survives acceptance review, which is a big if, not a default rule.</p> <p>Never Be Frugal on Planning</p> <p>After this set of experiments I am fairly convinced that a cheaper model should never own planning and spec development.</p> <p>If there is a place you should not be frugal, that is the place. Skimp there and you may confidently implement the wrong thing: something that passes all the tests and looks right at first glance, even under the review of an excellent engineer who is not fully familiar with the domain.</p> <p>The next experiments should separate:</p> <ul> <li>repo discovery quality</li> <li>spec quality</li> <li>implementation quality</li> <li>review cost</li> <li>accepted patch cost</li> </ul> <p>Because each of those has to be judged on its own. Roll them into a single \"cost\" number and you lose the distinction that matters most: attempt cost versus accepted-patch cost.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-this-experiment-cant-tell-you","level":2,"title":"What This Experiment Can't Tell You","text":"<p>I want to be honest about the edges of this, so the numbers are not read as more than they are:</p> <ul> <li>It is one small, local task in one repository. Larger cross-file or cross-repo work could move the budget picture either way.</li> <li>Tests were not run on every implementation, so some patches are judged by static review, not by a green test suite.</li> <li>Static review ran on the final working trees, and a few rows in the underlying cost ledger are interpolated rather than separately captured.</li> <li>Dollar costs come from the run summaries; the token counts come from the session logs. They are two lenses, not one ledger.</li> </ul> <p>None of this changes the shape of the finding. It does mean the right reading is \"strong signal from a weekend\", not \"proven law\".</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-takeaway","level":2,"title":"The Takeaway","text":"<p>The expensive part of AI coding is not always the diff.</p> <p>Sometimes the expensive part is missing the smaller job.</p> <p>In this experiment, the best result came from finding an existing helper before the task shape hardened. Once the task became \"wire the parser\", implementation was straightforward. When the helper was missed, the workflow still produced coherent specs and acceptable patches, but it carried a larger premise.</p> <p>The workflow change is small:</p> <pre><code>make implementation inventory mandatory before spec expansion\n</code></pre> <ul> <li>Find what already exists.</li> <li>Ratify that understanding.</li> <li>Then generate the spec.</li> <li>Then implement.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>A patch is cheap only after you know which patch you are asking for.</p> <p>The cheapest model can miss the contract; the most expensive model can rewrite it. Neither is safe without a ratified task shape and a human checkpoint that reads the diff against the contract, not against the bug report.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#where-this-connects","level":2,"title":"Where This Connects","text":"<p>This experiment is one more data point in a thread that runs through these field notes.</p> <ul> <li>The Dog Ate My Homework argued that the hard part is getting an agent to read before it writes. This is the same failure with money attached: the agent that did not inventory the repo first wrote a spec for the wrong-sized job.</li> <li>The Watermelon-Rind Anti-Pattern showed that a mechanism which answers the question asked can prevent the discovery of the question you should have asked. Compression did exactly that here.</li> <li>Code Is Cheap. Judgment Is Not. put it in one line: production is the easy part, judgment is the hard part. The judgment that mattered most was not in the diff. It was in deciding the task shape before any model started typing.</li> <li>The Attention Budget explained why more context is not automatically better. Compression is the same coin flipped: less context is not automatically cheaper.</li> </ul> <p>If you want the operating model in tool form, <code>ctx</code> already ships most of it. Design Before Coding walks the brainstorm / plan / spec / implement chain, and Scrutinizing a Plan is the <code>/ctx-plan</code> step that produces the repo-grounded debated brief this post keeps asking for: the artifact that forces \"prove what already exists\" before a spec can expand.</p> <p>This post is part of the <code>ctx</code> field notes series, documenting what we learn building persistent context infrastructure for AI coding sessions. The experiment ran against the SPIFFE/SPIKE repository using Anthropic models only. The numbers are signal from a weekend's worth of runs, not a peer-reviewed result.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"cli/","level":1,"title":"CLI","text":"","path":["CLI"],"tags":[]},{"location":"cli/#ctx-cli","level":2,"title":"<code>ctx</code> CLI","text":"<p>Complete reference for all <code>ctx</code> commands, grouped by function.</p>","path":["CLI"],"tags":[]},{"location":"cli/#global-options","level":2,"title":"Global Options","text":"<p>All commands support these flags:</p> Flag Description <code>--help</code> Show command help <code>--version</code> Show version <code>--tool <name></code> Override active AI tool identifier (e.g. <code>kiro</code>, <code>cursor</code>) <p>Tell <code>ctx</code> which <code>.context/</code> to use. <code>ctx</code> reads <code>$PWD/.context/</code> — run commands from the project root (the directory that holds both <code>.git/</code> and <code>.context/</code>). There is no env-var or walk-up resolution; <code>ctx</code> does not search the filesystem. If <code>$PWD/.context/</code> is missing, commands fail fast with a clear error pointing at <code>ctx init</code>. A handful of commands run without that gate because they don't need a project: <code>ctx init</code>, <code>ctx version</code>, <code>ctx help</code>, <code>ctx system bootstrap</code>, <code>ctx doctor</code>, <code>ctx guide</code>, <code>ctx why</code>, <code>ctx config switch/status</code>, and <code>ctx hub *</code>.</p> <p>Initialization required. Once declared, the target must already have been initialized by <code>ctx init</code> (otherwise commands return <code>ctx: not initialized</code>).</p>","path":["CLI"],"tags":[]},{"location":"cli/#getting-started","level":2,"title":"Getting Started","text":"Command Description <code>ctx init</code> Initialize <code>.context/</code> directory with templates <code>ctx status</code> Show context summary (files, tokens, drift) <code>ctx guide</code> Quick-reference cheat sheet <code>ctx why</code> Read the philosophy behind <code>ctx</code>","path":["CLI"],"tags":[]},{"location":"cli/#context","level":2,"title":"Context","text":"Command Description <code>ctx load</code> Output assembled context in read order <code>ctx agent</code> Print token-budgeted context packet for AI consumption <code>ctx sync</code> Reconcile context with codebase state <code>ctx drift</code> Detect stale paths, secrets, missing files <code>ctx compact</code> Archive completed tasks, clean up files <code>ctx fmt</code> Format context files to 80-char line width <code>ctx task</code> Add tasks, mark complete, archive, snapshot <code>ctx decision</code> Add decisions to <code>DECISIONS.md</code> <code>ctx learning</code> Add learnings to <code>LEARNINGS.md</code> <code>ctx convention</code> Add conventions to <code>CONVENTIONS.md</code> <code>ctx index</code> Project a file's headings as a table of contents <code>ctx permission</code> Permission snapshots (golden image) <code>ctx change</code> Show what changed since last session <code>ctx memory</code> Bridge Claude Code auto memory into <code>.context/</code> <code>ctx watch</code> Auto-apply context updates from AI output <code>ctx kb</code> Knowledge-base editorial pipeline (Phase KB) <code>ctx handover</code> Write the per-session handover that the next session reads","path":["CLI"],"tags":[]},{"location":"cli/#sessions","level":2,"title":"Sessions","text":"Command Description <code>ctx journal</code> Browse, import, enrich, and lock session history <code>ctx dream</code> Triage <code>ideas/</code> into gated proposals for review (opt-in) <code>ctx pad</code> Encrypted scratchpad for sensitive one-liners <code>ctx remind</code> Session-scoped reminders that surface at session start <code>ctx hook pause</code> Pause context hooks for the current session <code>ctx hook resume</code> Resume paused context hooks","path":["CLI"],"tags":[]},{"location":"cli/#integrations","level":2,"title":"Integrations","text":"Command Description <code>ctx setup</code> Generate AI tool integration configs <code>ctx steering</code> Manage steering files (behavioral rules for AI tools) <code>ctx trigger</code> Manage lifecycle triggers (scripts for automation) <code>ctx skill</code> Manage reusable instruction bundles <code>ctx mcp</code> MCP server for AI tool integration (stdin/stdout) <code>ctx hook notify</code> Webhook notifications (setup, test, send) <code>ctx loop</code> Generate autonomous loop script <code>ctx connection</code> Client-side commands for connecting to a <code>ctx</code> Hub <code>ctx hub</code> Operate a <code>ctx</code> Hub server or cluster <code>ctx serve</code> Serve a static site locally via zensical <code>ctx site</code> Site management (feed generation)","path":["CLI"],"tags":[]},{"location":"cli/#diagnostics","level":2,"title":"Diagnostics","text":"Command Description <code>ctx doctor</code> Structural health check (hooks, drift, config) <code>ctx trace</code> Show context behind git commits <code>ctx sysinfo</code> Show system resource usage (memory, swap, disk, load) <code>ctx usage</code> Show session token usage stats","path":["CLI"],"tags":[]},{"location":"cli/#runtime","level":2,"title":"Runtime","text":"Command Description <code>ctx config</code> Manage runtime configuration profiles <code>ctx prune</code> Clean stale per-session state files <code>ctx hook</code> Hook message, notification, and lifecycle controls <code>ctx system</code> Hook plumbing and agent-only commands (not user-facing)","path":["CLI"],"tags":[]},{"location":"cli/#shell","level":2,"title":"Shell","text":"Command Description <code>ctx completion</code> 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 <code>CTX_TOKEN_BUDGET</code> Override default token budget <code>CTX_SESSION_ID</code> Active AI session ID (used by <code>ctx trace</code> for context linking)","path":["CLI"],"tags":[]},{"location":"cli/#configuration-file","level":2,"title":"Configuration File","text":"<p>Optional <code>.ctxrc</code> (YAML format) at project root:</p> <pre><code># .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\nauto_prune_days: 7 # Days before stale session-state files are pruned on load (0/neg = default)\nagent_cooldown_minutes: 10 # Minutes between repeated `ctx agent` emissions (0 = disable)\ntask_budget_pct: 0.40 # Fraction of the agent token budget for tasks (0-1; 0 = none)\nconvention_budget_pct: 0.20 # Fraction of the agent token budget for conventions (0-1; 0 = none)\ntitle_slug_max_len: 50 # Max characters in journal filename slugs (0/neg = default)\nrecall_list_limit: 20 # Default `ctx journal source` list size (0/neg = default)\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\ndream: # ctx-dream config (opt-in; off by default)\n enabled: false # Master switch — nothing runs until true\n mode: discipline # Pass mode (v1: discipline)\n max: 50 # Max ideas/ files processed per pass\n cadence: \"30 2 * * *\" # Cron schedule for the nightly pass\n quiet_minutes: 60 # Skip a pass if active within this window\n budget: 40 # Step/token ceiling per pass\n model: \"\" # Executor model (\"\" = session default)\n executor: \"\" # Executor command (\"\" = claude -p reference)\n</code></pre> Field Type Default Description <code>token_budget</code> <code>int</code> <code>8000</code> Default token budget for <code>ctx agent</code> <code>priority_order</code> <code>[]string</code> (all files) File loading priority for context packets <code>auto_archive</code> <code>bool</code> <code>true</code> Auto-archive completed tasks <code>archive_after_days</code> <code>int</code> <code>7</code> Days before completed tasks are archived <code>scratchpad_encrypt</code> <code>bool</code> <code>true</code> Encrypt scratchpad with AES-256-GCM <code>event_log</code> <code>bool</code> <code>false</code> Enable local hook event logging to <code>.context/state/events.jsonl</code> <code>companion_check</code> <code>bool</code> <code>true</code> Check companion tool availability (canonical: Gemini Search, GitNexus; equivalents work) during <code>/ctx-remember</code> <code>entry_count_learnings</code> <code>int</code> <code>30</code> Drift warning when <code>LEARNINGS.md</code> exceeds this count <code>entry_count_decisions</code> <code>int</code> <code>20</code> Drift warning when <code>DECISIONS.md</code> exceeds this count <code>convention_line_count</code> <code>int</code> <code>200</code> Line count warning for <code>CONVENTIONS.md</code> <code>injection_token_warn</code> <code>int</code> <code>15000</code> Warn when auto-injected context exceeds this token count (0 = disable) <code>context_window</code> <code>int</code> <code>200000</code> Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools <code>billing_token_warn</code> <code>int</code> <code>0</code> (off) One-shot warning when session tokens exceed this threshold (0 = disabled) <code>key_rotation_days</code> <code>int</code> <code>90</code> Days before encryption key rotation nudge <code>session_prefixes</code> <code>[]string</code> <code>[\"Session:\"]</code> Recognized Markdown session header prefixes. Extend to parse sessions written in other languages <code>freshness_files</code> <code>[]object</code> (none) Files to track for staleness (path, desc, optional review_url). Hook warns after 6 months without modification <code>notify.events</code> <code>[]string</code> (all) Event filter for webhook notifications (empty = all) <code>tool</code> <code>string</code> (empty) Active AI tool identifier (<code>claude</code>, <code>cursor</code>, <code>cline</code>, <code>kiro</code>, <code>codex</code>) <code>steering.dir</code> <code>string</code> <code>.context/steering</code> Steering files directory <code>steering.default_inclusion</code> <code>string</code> <code>manual</code> Default inclusion mode for new steering files (<code>always</code>, <code>auto</code>, <code>manual</code>) <code>steering.default_tools</code> <code>[]string</code> (all) Default tool filter for new steering files (empty = all tools) <code>hooks.dir</code> <code>string</code> <code>.context/hooks</code> Hook scripts directory <code>hooks.timeout</code> <code>int</code> <code>10</code> Per-hook execution timeout in seconds <code>hooks.enabled</code> <code>bool</code> <code>true</code> Whether hook execution is enabled <code>auto_prune_days</code> <code>int</code> <code>7</code> Days before stale session-state files are auto-pruned on load (non-positive falls back to the default) <code>agent_cooldown_minutes</code> <code>int</code> <code>10</code> Minutes between repeated <code>ctx agent</code> emissions; an explicit <code>0</code> disables the cooldown <code>task_budget_pct</code> <code>number</code> <code>0.40</code> Fraction of the <code>ctx agent</code> token budget for tasks (clamped <code>0</code>–<code>1</code>; explicit <code>0</code> = none) <code>convention_budget_pct</code> <code>number</code> <code>0.20</code> Fraction of the <code>ctx agent</code> token budget for conventions (clamped <code>0</code>–<code>1</code>; explicit <code>0</code> = none) <code>title_slug_max_len</code> <code>int</code> <code>50</code> Maximum characters in title-derived journal filename slugs (non-positive falls back to the default) <code>recall_list_limit</code> <code>int</code> <code>20</code> Default <code>ctx journal source</code> list size when <code>--limit</code> is omitted (non-positive falls back to the default) <p>Priority order: CLI flags > Environment variables > <code>.ctxrc</code> > Defaults</p> <p>All settings are optional. Missing values use defaults.</p>","path":["CLI"],"tags":[]},{"location":"cli/bootstrap/","level":1,"title":"System Bootstrap","text":"","path":["CLI","Runtime","System Bootstrap"],"tags":[]},{"location":"cli/bootstrap/#ctx-system-bootstrap","level":3,"title":"<code>ctx system bootstrap</code>","text":"<p>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. <code>--quiet</code> prints just the path; <code>--json</code> produces structured output for automation.</p> <p>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?\".</p> <pre><code>ctx system bootstrap [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>-q</code>, <code>--quiet</code> Output only the context directory path <code>--json</code> Output in JSON format <p>Examples:</p> <pre><code>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</code></pre> <p>Note: <code>-q</code> prints just the resolved directory path. <code>ctx</code> reads <code>$PWD/.context/</code>; if you hit a \"no context here\" error, run <code>ctx init</code> from the project root or <code>cd</code> to one that already has <code>.context/</code>.</p>","path":["CLI","Runtime","System Bootstrap"],"tags":[]},{"location":"cli/change/","level":1,"title":"Change","text":"","path":["CLI","Context","Change"],"tags":[]},{"location":"cli/change/#ctx-change","level":2,"title":"<code>ctx change</code>","text":"<p>Show what changed in context files and code since your last session.</p> <p>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.</p> <pre><code>ctx change [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--since</code> Time reference: duration (<code>24h</code>) or date (<code>2026-03-01</code>) <p>Reference time detection (priority order):</p> <ol> <li><code>--since</code> flag (duration, date, or RFC3339 timestamp)</li> <li><code>ctx-loaded-*</code> marker files in <code>.context/state/</code> (second most recent)</li> <li>Last <code>context-load-gate</code> event from <code>.context/state/events.jsonl</code></li> <li>Fallback: 24 hours ago</li> </ol> <p>Examples:</p> <pre><code># 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</code></pre> <p>Output:</p> <pre><code>## 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</code></pre> <p>Context file changes are detected by filesystem mtime (works without git). Code changes use <code>git log --since</code> (empty when not in a git repo).</p> <p>See also: Reviewing Session Changes.</p>","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":"<code>ctx completion</code>","text":"<p>Generate shell autocompletion scripts.</p> <pre><code>ctx completion <shell>\n</code></pre>","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#subcommands","level":3,"title":"Subcommands","text":"Shell Command <code>bash</code> <code>ctx completion bash</code> <code>zsh</code> <code>ctx completion zsh</code> <code>fish</code> <code>ctx completion fish</code> <code>powershell</code> <code>ctx completion powershell</code> <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#installation","level":3,"title":"Installation","text":"BashZshFishPowerShell <pre><code># Add to ~/.bashrc\nsource <(ctx completion bash)\n</code></pre> <pre><code># Add to ~/.zshrc\nsource <(ctx completion zsh)\n</code></pre> <pre><code>ctx completion fish | source\n# Or save to completions directory\nctx completion fish > ~/.config/fish/completions/ctx.fish\n</code></pre> <pre><code># Add to your PowerShell profile\nctx completion powershell | Out-String | Invoke-Expression\n</code></pre>","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":"<code>ctx config</code>","text":"<p>Manage runtime configuration profiles.</p> <pre><code>ctx config <subcommand>\n</code></pre> <p>The <code>ctx</code> repo ships two <code>.ctxrc</code> source profiles (<code>.ctxrc.base</code> and <code>.ctxrc.dev</code>). The working copy (<code>.ctxrc</code>) is gitignored and switched between them using subcommands below.</p>","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-switch","level":4,"title":"<code>ctx config switch</code>","text":"<p>Switch between <code>.ctxrc</code> configuration profiles.</p> <pre><code>ctx config switch [dev|base]\n</code></pre> <p>With no argument, toggles between dev and base. Accepts <code>prod</code> as an alias for <code>base</code>.</p> Argument Description <code>dev</code> Switch to dev profile (verbose logging) <code>base</code> Switch to base profile (all defaults) (none) Toggle to the opposite profile <p>Profiles:</p> Profile Description <code>dev</code> Verbose logging, webhook notifications on <code>base</code> All defaults, notifications off <p>Examples:</p> <pre><code>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</code></pre> <p>The detection heuristic checks for an uncommented <code>notify:</code> line in <code>.ctxrc</code>: present means dev, absent means base.</p>","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-status","level":4,"title":"<code>ctx config status</code>","text":"<p>Show which <code>.ctxrc</code> profile is currently active.</p> <pre><code>ctx config status\n</code></pre> <p>Output examples:</p> <pre><code>active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n</code></pre> <p>See also: Configuration, Contributing: Configuration Profiles</p>","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/connection/","level":1,"title":"Connect","text":"","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection","level":2,"title":"<code>ctx connection</code>","text":"<p>Connect a project to a <code>ctx</code> Hub for cross-project knowledge sharing. Projects publish decisions, learnings, conventions, and tasks to a hub; other subscribed projects receive them alongside local context.</p> <p>New to the <code>ctx</code> Hub?</p> <p>Start with the <code>ctx</code> 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.</p> <p>The unit of identity is a project, not a user. Registering a directory with <code>ctx connection register</code> binds a per-project client token in <code>.context/.connect.enc</code>. Two developers on the same project either share that file over a trusted channel, or each register under a different project name.</p> <p>Only structured entries flow through the hub: <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. Session journals, scratchpad contents, and other local state stay on the machine that created them.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-register","level":3,"title":"<code>ctx connection register</code>","text":"<p>One-time registration with a <code>ctx</code> Hub. Requires the <code>ctx</code> Hub address and admin token (printed by <code>ctx hub start</code> on first run).</p> <p>Examples:</p> <pre><code>ctx connection register localhost:9900 --token ctx_adm_7f3a...\n</code></pre> <p>On success, stores an encrypted connection config in <code>.context/.connect.enc</code> for future RPCs.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-subscribe","level":3,"title":"<code>ctx connection subscribe</code>","text":"<p>Set which entry types to receive from the <code>ctx</code> Hub. Only matching types are returned by sync and listen.</p> <p>Examples:</p> <pre><code>ctx connection subscribe decision learning\nctx connection subscribe decision learning convention\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-sync","level":3,"title":"<code>ctx connection sync</code>","text":"<p>Pull matching entries from the <code>ctx</code> Hub and write them to <code>.context/hub/</code> as Markdown files with origin tags and date headers. Tracks last-seen sequence for incremental sync.</p> <p>Examples:</p> <pre><code>ctx connection sync\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-publish","level":3,"title":"<code>ctx connection publish</code>","text":"<p>Push entries to the <code>ctx</code> Hub. Specify type and content as arguments.</p> <p>Examples:</p> <pre><code>ctx connection publish decision \"Use UTC timestamps everywhere\"\nctx connection publish learning \"Go embed requires files in same package\"\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-listen","level":3,"title":"<code>ctx connection listen</code>","text":"<p>Stream new entries from the <code>ctx</code> Hub in real-time. Writes to <code>.context/hub/</code> as entries arrive. Press Ctrl-C to stop.</p> <p>Examples:</p> <pre><code>ctx connection listen\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-status","level":3,"title":"<code>ctx connection status</code>","text":"<p>Show <code>ctx</code> Hub connection state and entry statistics.</p> <p>Examples:</p> <pre><code>ctx connection status\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#automatic-sharing","level":2,"title":"Automatic Sharing","text":"<p>Use <code>--share</code> on <code>ctx add</code> to write locally AND publish to the <code>ctx</code> Hub:</p> <pre><code>ctx decision add \"Use UTC\" --share \\\n --context \"Need consistency\" \\\n --rationale \"Avoid timezone bugs\" \\\n --consequence \"UI does conversion\"\n</code></pre> <p>If the hub is unreachable, the local write succeeds and a warning is printed. The <code>--share</code> flag is best-effort; it never blocks local context updates.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#auto-sync","level":2,"title":"Auto-Sync","text":"<p>Once registered, the <code>check-hub-sync</code> hook automatically syncs new entries from the <code>ctx</code> Hub at the start of each session (daily throttled). No manual <code>ctx connection sync</code> needed.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#shared-files","level":2,"title":"Shared Files","text":"<p>Entries from the <code>ctx</code> Hub are stored in <code>.context/hub/</code>:</p> <pre><code>.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</code></pre> <p>These files are read-only (managed by sync/listen) and never mixed with local context files.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#agent-integration","level":2,"title":"Agent Integration","text":"<p>Include shared knowledge in agent context packets:</p> <pre><code>ctx agent --include-hub\n</code></pre> <p>Shared entries are included as Tier 8 in the budget-aware assembly, scored by recency and type relevance.</p>","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":"<p>Each context-artifact noun (<code>task</code>, <code>decision</code>, <code>learning</code>, <code>convention</code>) owns its own <code>add</code> subcommand under the noun-first command tree:</p> <pre><code>ctx task add <content> [flags]\nctx decision add <content> [flags]\nctx learning add <content> [flags]\nctx convention add <content> [flags]\n</code></pre> <p>Target files:</p> Subcommand Target File <code>ctx task add</code> <code>TASKS.md</code> <code>ctx decision add</code> <code>DECISIONS.md</code> <code>ctx learning add</code> <code>LEARNINGS.md</code> <code>ctx convention add</code> <code>CONVENTIONS.md</code> <p>Flags (shared by every <code>add</code> subcommand; per-noun required-flag rules surface as command errors):</p> Flag Short Description <code>--priority <level></code> <code>-p</code> Priority for tasks: <code>high</code>, <code>medium</code>, <code>low</code> <code>--section <name></code> <code>-s</code> Target section within file <code>--context</code> <code>-c</code> Context (required for decisions and learnings) <code>--rationale</code> <code>-r</code> Rationale for decisions (required for decisions) <code>--consequence</code> Consequence for decisions (required for decisions) <code>--lesson</code> <code>-l</code> Key insight (required for learnings) <code>--application</code> <code>-a</code> How to apply going forward (required for learnings) <code>--file</code> <code>-f</code> Read content from file instead of argument <code>--json-file <path></code> Read a JSON payload that populates the typed fields directly (supersedes the content flags) <p>Examples:</p> <pre><code># 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\n# Ingest a JSON payload (keeps flag-value content off the command line,\n# so a value containing a permissions-denied substring still persists)\ncat > /tmp/decision.json <<'EOF'\n{\n \"title\": \"Install ctx into the system PATH\",\n \"context\": \"agents invoke ctx by bare name\",\n \"rationale\": \"the binary belongs at /usr/local/bin so it is on PATH\",\n \"consequence\": \"ctx resolves from any working directory\",\n \"provenance\": {\"session_id\": \"abc12345\", \"branch\": \"main\", \"commit\": \"68fbc00a\"}\n}\nEOF\nctx decision add --json-file /tmp/decision.json\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-drift","level":3,"title":"<code>ctx drift</code>","text":"<p>Detect stale or invalid context.</p> <pre><code>ctx drift [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--json</code> Output machine-readable JSON <code>--fix</code> Auto-fix simple issues <p>Checks:</p> <ul> <li>Path references in <code>ARCHITECTURE.md</code> and <code>CONVENTIONS.md</code> exist</li> <li>Task references are valid</li> <li>Constitution rules aren't violated (heuristic)</li> <li>Staleness indicators (old files, many completed tasks)</li> <li>Missing packages: warns when <code>internal/</code> directories exist on disk but are not referenced in <code>ARCHITECTURE.md</code> (suggests running <code>/ctx-architecture</code>)</li> <li>Entry count: warns when <code>LEARNINGS.md</code> or <code>DECISIONS.md</code> exceed configurable thresholds (default: 30 learnings, 20 decisions), or when <code>CONVENTIONS.md</code> exceeds a line count threshold (default: 200). Configure via <code>.ctxrc</code>: <pre><code>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</code></pre></li> </ul> <p>Example:</p> <pre><code>ctx drift\nctx drift --json\nctx drift --fix\n</code></pre> <p>Exit codes:</p> 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":"<code>ctx sync</code>","text":"<p>Reconcile context with the current codebase state.</p> <pre><code>ctx sync [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--dry-run</code> Show what would change without modifying <p>What it does:</p> <ul> <li>Scans codebase for structural changes</li> <li>Compares with ARCHITECTURE.md</li> <li>Suggests documenting dependencies if package files exist</li> <li>Identifies stale or outdated context</li> </ul> <p>Example:</p> <pre><code>ctx sync\nctx sync --dry-run\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-compact","level":3,"title":"<code>ctx compact</code>","text":"<p>Consolidate and clean up context files.</p> <ul> <li>Moves completed tasks older than 7 days to the archive</li> <li>Removes empty sections</li> </ul> <pre><code>ctx compact [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--archive</code> Create <code>.context/archive/</code> for old content <p>Example:</p> <pre><code>ctx compact\nctx compact --archive\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-fmt","level":3,"title":"<code>ctx fmt</code>","text":"<p>Format context files to a consistent line width.</p> <p>Wraps long lines in <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, and <code>CONVENTIONS.md</code> at word boundaries. Markdown list items get 2-space continuation indent. Headings, tables, frontmatter, and HTML comments are preserved as-is.</p> <p>Idempotent: running twice produces the same output.</p> <pre><code>ctx fmt [flags]\n</code></pre> <p>Flags:</p> Flag Type Default Description <code>--width</code> <code>int</code> <code>80</code> Target line width <code>--check</code> <code>bool</code> <code>false</code> Check only, exit 1 if files would change <p>Examples:</p> <pre><code>ctx fmt # format all context files\nctx fmt --check # CI mode: check without modifying\nctx fmt --width 100 # custom width\n</code></pre> <p>Also available as a Makefile target:</p> <pre><code>make fmt-context\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task","level":3,"title":"<code>ctx task</code>","text":"<p>Manage task completion, archival, and snapshots.</p> <pre><code>ctx task <subcommand>\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-complete","level":4,"title":"<code>ctx task complete</code>","text":"<p>Mark a task as completed.</p> <pre><code>ctx task complete <task-id-or-text>\n</code></pre> <p>Arguments:</p> <ul> <li><code>task-id-or-text</code>: Task number or partial text match</li> </ul> <p>Examples:</p> <pre><code># By text (partial match)\nctx task complete \"user auth\"\n\n# By task number\nctx task complete 3\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-archive","level":4,"title":"<code>ctx task archive</code>","text":"<p>Move completed tasks from <code>TASKS.md</code> to a timestamped archive file.</p> <pre><code>ctx task archive [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--dry-run</code> Preview changes without modifying files <p>Archive files are stored in <code>.context/archive/</code> with timestamped names (<code>tasks-YYYY-MM-DD.md</code>). Completed tasks (marked with <code>[x]</code>) are moved; pending tasks (<code>[ ]</code>) remain in <code>TASKS.md</code>.</p> <p>Example:</p> <pre><code>ctx task archive\nctx task archive --dry-run\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-snapshot","level":4,"title":"<code>ctx task snapshot</code>","text":"<p>Create a point-in-time snapshot of <code>TASKS.md</code> without modifying the original.</p> <pre><code>ctx task snapshot [name]\n</code></pre> <p>Arguments:</p> <ul> <li><code>name</code>: Optional name for the snapshot (defaults to \"snapshot\")</li> </ul> <p>Snapshots are stored in <code>.context/archive/</code> with timestamped names (<code>tasks-<name>-YYYY-MM-DD-HHMM.md</code>).</p> <p>Example:</p> <pre><code>ctx task snapshot\nctx task snapshot \"before-refactor\"\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission","level":3,"title":"<code>ctx permission</code>","text":"<p>Manage Claude Code permission snapshots.</p> <pre><code>ctx permission <subcommand>\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-snapshot","level":4,"title":"<code>ctx permission snapshot</code>","text":"<p>Save <code>.claude/settings.local.json</code> as the golden image.</p> <pre><code>ctx permission snapshot\n</code></pre> <p>Creates <code>.claude/settings.golden.json</code> as a byte-for-byte copy of the current settings. Overwrites if the golden file already exists.</p> <p>The golden file is meant to be committed to version control and shared with the team.</p> <p>Example:</p> <pre><code>ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-restore","level":4,"title":"<code>ctx permission restore</code>","text":"<p>Replace <code>settings.local.json</code> with the golden image.</p> <pre><code>ctx permission restore\n</code></pre> <p>Prints a diff of dropped (session-accumulated) and restored permissions. No-op if the files already match.</p> <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-index","level":3,"title":"<code>ctx index</code>","text":"<p>Project the Markdown headings of a knowledge file as a computed table of contents — recomputed on demand, never stored in the file.</p> <pre><code>ctx index <file> [--depth N] [--json]\n</code></pre> <p>One generic command serves every knowledge file: <code>DECISIONS.md</code> and <code>LEARNINGS.md</code> (<code>## [timestamp] Title</code> entries), <code>CONVENTIONS.md</code>, and <code>TASKS.md</code> (<code>## Phase …</code> sections). By default only level-2 (<code>##</code>) headings are shown; <code>--depth 3</code> includes level-3 (<code>###</code>) sub-headings, and <code>--json</code> emits a machine-readable array of <code>{level, text}</code>.</p> <p>Because the index is computed, it can never drift from the entries it summarizes, and adding an entry never rewrites the file's structure.</p> <p>Example:</p> <pre><code>ctx index .context/DECISIONS.md\n# [2026-07-09-093951] Ship #131 as interim hub token revocation\n# [2026-07-06-214523] Journal resume picks the richest transcript\n# ...\n\nctx index .context/TASKS.md --depth 3\nctx index .context/LEARNINGS.md --json\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-decision","level":3,"title":"<code>ctx decision</code>","text":"<p>Manage the <code>DECISIONS.md</code> file.</p> <pre><code>ctx decision <subcommand>\n</code></pre> <p>Use <code>ctx decision add</code> to append entries; see <code>ctx index</code> to project a table of contents on demand.</p>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-learning","level":3,"title":"<code>ctx learning</code>","text":"<p>Manage the <code>LEARNINGS.md</code> file.</p> <pre><code>ctx learning <subcommand>\n</code></pre> <p>Use <code>ctx learning add</code> to append entries; see <code>ctx index</code> to project a table of contents on demand.</p>","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":"<code>ctx doctor</code>","text":"<p>Structural health check across context, hooks, and configuration. Runs mechanical checks that don't require semantic analysis. Think of it as <code>ctx status</code> + <code>ctx drift</code> + configuration audit in one pass.</p> <pre><code>ctx doctor [flags]\n</code></pre> <p>Flags:</p> Flag Short Type Default Description <code>--json</code> <code>-j</code> bool <code>false</code> 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 <code>.context/</code> directory exists Required files present Structure All required context files exist (<code>TASKS.md</code>, etc.) Drift detected Quality Stale paths, missing files, constitution violations Event logging status Hooks Whether <code>event_log: true</code> is set in <code>.ctxrc</code> Webhook configured Hooks <code>.notify.enc</code> file exists Pending reminders State Count of entries in <code>reminders.json</code> Task completion ratio State Pending vs completed tasks in <code>TASKS.md</code> 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":"<pre><code>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</code></pre> <p>Status indicators:</p> 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":"<pre><code>{\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</code></pre> <p>Examples:</p> <pre><code># 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</code></pre>","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#when-to-use-what","level":4,"title":"When to Use What","text":"Tool When <code>ctx status</code> Quick glance at files, tokens, and drift <code>ctx doctor</code> Thorough structural checkup (hooks, config, events too) <code>/ctx-doctor</code> Agent-driven diagnosis with event log pattern analysis <p><code>ctx status</code> tells you what's there. <code>ctx doctor</code> tells you what's wrong. <code>/ctx-doctor</code> tells you why it's wrong and what to do about it.</p>","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#what-it-does-not-do","level":4,"title":"What It Does Not Do","text":"<ul> <li>No event pattern analysis: that's the <code>/ctx-doctor</code> skill's job</li> <li>No auto-fixing: reports findings, doesn't modify anything</li> <li>No external service checks: doesn't verify webhook endpoint availability</li> </ul> <p>See also: Troubleshooting | <code>ctx hook event</code> | <code>/ctx-doctor</code> skill | Detecting and Fixing Drift</p>","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/dream/","level":1,"title":"Dream","text":"","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream","level":2,"title":"<code>ctx dream</code>","text":"<p>Run a disciplined, out-of-band dream pass over the gitignored <code>ideas/</code> folder: classify each idea against the codebase and specs, and emit gated, provenance-bearing disposition proposals into the <code>dreams/</code> notebook for human review. The dream only ever proposes — it never writes canonical memory and never acts on a proposal.</p> <p>The dream is opt-in and off by default. Nothing runs until you set <code>dream.enabled: true</code> in <code>.ctxrc</code>. See the Run the Dream recipe for the full setup (cron, guard hook, review), and the executor contract to run it under a non-Claude-Code harness.</p> <p>Invoked with no subcommand, it runs one bounded pass: it gates on the idea delta and the quiet window, takes an exclusive lock, invokes the configured executor (default <code>claude -p</code> with the <code>ctx-dream</code> skill), and fails loud (writing <code>dreams/.failed</code>) if the executor is missing or errors — it never silently no-ops.</p> <pre><code>ctx dream [flags]\nctx dream <subcommand>\n</code></pre> <p>Flags:</p> Flag Description <code>--mode</code> Pass mode (<code>discipline</code>; default from <code>.ctxrc dream.mode</code>) <code>--max</code> Max <code>ideas/</code> files processed this pass (default <code>dream.max</code>) <code>--budget</code> Step/token budget for the pass (default <code>dream.budget</code>) <code>--force</code> Bypass the trigger gate (opt-in + cadence + quiet window) <p>Examples:</p> <pre><code>ctx dream\nctx dream --max 20 --force\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-review","level":3,"title":"<code>ctx dream review</code>","text":"<p>List the pending proposals from the latest pass — those not yet decided in the ledger — rendered substance-forward (summary, status, action, evidence, confidence, rationale). This is the read side of the <code>/ctx-serendipity</code> garden walk.</p> <pre><code>ctx dream review\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-accept-id","level":3,"title":"<code>ctx dream accept <id></code>","text":"<p>Accept a proposal's recommended action. Mechanical actions (<code>archive</code>, <code>mark-blog</code>, <code>keep</code>) apply immediately with both guards enforced and a ledger entry recorded; generative actions (<code>promote</code>, <code>merge</code>) record accepted intent and are completed from the full source via <code>/ctx-serendipity</code>.</p> <p>Arguments:</p> <ul> <li><code>id</code>: the proposal ID (from <code>ctx dream review</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--note</code> Optional human note recorded in the ledger <p>Examples:</p> <pre><code>ctx dream accept a1b2c3\nctx dream accept a1b2c3 --note \"good catch\"\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-reject-id","level":3,"title":"<code>ctx dream reject <id></code>","text":"<p>Record a rejection. No mutation occurs; the proposal is not re-surfaced unless its source idea changes (dedup-against-seen).</p> <p>Arguments:</p> <ul> <li><code>id</code>: the proposal ID</li> </ul> <p>Flags:</p> Flag Description <code>--note</code> Optional human note recorded in the ledger <p>Examples:</p> <pre><code>ctx dream reject a1b2c3\nctx dream reject a1b2c3 --note \"still relevant\"\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-amend-id-action-action","level":3,"title":"<code>ctx dream amend <id> --action <action></code>","text":"<p>Apply a different action than the one proposed, recording the decision as amended (original provenance preserved).</p> <p>Arguments:</p> <ul> <li><code>id</code>: the proposal ID</li> </ul> <p>Flags:</p> Flag Description <code>--action</code> The action to apply instead (<code>archive</code>/<code>merge</code>/<code>promote</code>/<code>mark-blog</code>/<code>keep</code>) <code>--note</code> Optional human note recorded in the ledger <p>Examples:</p> <pre><code>ctx dream amend a1b2c3 --action keep\nctx dream amend a1b2c3 --action archive --note \"superseded\"\n</code></pre> <p>See also: Run the Dream recipe · Executor contract.</p>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/event/","level":1,"title":"Event","text":"","path":["CLI","Runtime","Event"],"tags":[]},{"location":"cli/event/#ctx-hook-event","level":3,"title":"<code>ctx hook event</code>","text":"<p>Query the local hook event log. Requires <code>event_log: true</code> in <code>.ctxrc</code>. Reads events from <code>.context/state/events.jsonl</code> and outputs them in a human-readable table or raw JSONL format.</p> <p>All filter flags combine with AND logic.</p> <pre><code>ctx hook event [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--hook</code> Filter by hook name <code>--session</code> Filter by session ID <code>--event</code> Filter by event type (<code>relay</code>, <code>nudge</code>) <code>--last</code> Show last N events (default: 50) <code>--json</code> Output raw JSONL (for piping to <code>jq</code>) <code>--all</code> Include rotated log file <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Runtime","Event"],"tags":[]},{"location":"cli/guide/","level":1,"title":"Guide","text":"","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/guide/#ctx-guide","level":2,"title":"<code>ctx guide</code>","text":"<p>Quick-reference cheat sheet for common <code>ctx</code> commands and skills.</p> <pre><code>ctx guide [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--skills</code> Show available skills <code>--commands</code> Show available CLI commands <p>Example:</p> <pre><code># Show the full cheat sheet\nctx guide\n\n# Skills only\nctx guide --skills\n\n# Commands only\nctx guide --commands\n</code></pre> <p>Works without initialization (no <code>.context/</code> required). Useful for a printable one-pager when onboarding to a project.</p>","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/handover/","level":1,"title":"ctx handover","text":"","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#ctx-handover","level":2,"title":"<code>ctx handover</code>","text":"<p>Writes the per-session handover under <code>.context/handovers/<TS>-<slug>.md</code>: a former-agent-to-next-agent note created at session end by <code>/ctx-wrap-up</code> and read at session start by <code>/ctx-remember</code>. When <code>.context/kb/</code> exists, the writer additionally folds postdated closeouts into the handover's <code>## Folded Closeouts</code> section and archives them.</p>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#ctx-handover-write-title","level":3,"title":"<code>ctx handover write <title></code>","text":"<pre><code>ctx handover write \"Cursor Hooks deep dive\" \\\n --summary \"Drafted topic-page; minted EV-018..EV-024; cold-reader passed.\" \\\n --next \"Re-ingest the v1.1 release notes URL once you have it.\"\n</code></pre> <p>Required flags:</p> Flag Description <code>--summary</code> What happened this session (past tense). Placeholder values (<code>TBD</code>, <code>see chat</code>, <code>n/a</code>) are rejected. <code>--next</code> What the next agent should do FIRST (future tense, specific). Same placeholder rejection. <p>Optional flags:</p> Flag Description <code>--highlights</code> Notable artifacts produced this session. <code>--open-questions</code> Things that remain undecided. <code>--commit</code> Override resolved git HEAD for the Provenance line (CI replay; honors <code>CTX_TASK_COMMIT</code>). <code>--no-fold</code> Skip closeout consumption (mid-session checkpoint). <p>Writes: <code>.context/handovers/<TS>-<slug>.md</code> with frontmatter (<code>sha</code>, <code>branch</code>, <code>generated-at</code>, <code>title</code>) and body sections (<code>## Summary</code>, <code>## Next Session</code>, optionally <code>## Highlights</code>, <code>## Open Questions</code>, <code>## Folded Closeouts</code>). The <code><TS>-<slug>.md</code> filename is timestamped so multiple concurrent agent runs never overwrite one another's handover.</p> <p>Side effect (when <code>--no-fold</code> is absent and <code>.context/kb/</code> exists): closeouts that postdate the latest handover are folded into the new handover and physically archived under <code>.context/archive/closeouts/</code>.</p>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#how-to-trigger","level":3,"title":"How to Trigger","text":"<p>In ordinary sessions you do not invoke <code>ctx handover write</code> directly. The user-facing trigger is <code>/ctx-wrap-up</code>:</p> <pre><code>/ctx-wrap-up \"session title\"\n</code></pre> <p><code>/ctx-wrap-up</code> owns session-end and always delegates to <code>/ctx-handover</code> as its final step. Direct invocation of <code>/ctx-handover</code> is reserved for two cases:</p> <ul> <li><code>--no-fold</code> mid-session checkpoint.</li> <li>Recovery, when a prior session aborted before wrap-up.</li> </ul> <p>See <code>/ctx-wrap-up</code> and <code>/ctx-handover</code>.</p>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Session Lifecycle</li> <li>Recipe: Recover an Aborted Session</li> <li>Skill: <code>/ctx-wrap-up</code></li> <li>Skill: <code>/ctx-handover</code></li> <li>Skill: <code>/ctx-remember</code></li> </ul>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/hook/","level":1,"title":"Hook","text":"","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#ctx-hook","level":3,"title":"<code>ctx hook</code>","text":"<p>Manage hook-related settings: messages, notifications, pause/resume, and event log.</p> <pre><code>ctx hook <subcommand> [flags]\n</code></pre>","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#subcommands","level":2,"title":"Subcommands","text":"Subcommand Description <code>ctx hook message list</code> Show all hook messages with override status <code>ctx hook message show <h> <v></code> Print the effective message template <code>ctx hook message edit <h> <v></code> Copy default to <code>.context/</code> for editing <code>ctx hook message reset <h> <v></code> Delete user override, revert to default <code>ctx hook notify [message]</code> Send a webhook notification <code>ctx hook notify setup</code> Configure and encrypt webhook URL <code>ctx hook notify test</code> Send a test notification <code>ctx hook pause</code> Pause all context hooks for this session <code>ctx hook resume</code> Resume paused context hooks <code>ctx hook event</code> Query the local hook event log","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#examples","level":2,"title":"Examples","text":"<pre><code># 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</code></pre> <p>See also: Customizing Hook Messages | Webhook Notifications | Pausing Context Hooks | System Hooks Audit</p>","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":"<code>ctx hub</code>","text":"<p>Operator commands for a <code>ctx</code> Hub: the gRPC server that fans out decisions, learnings, conventions, and tasks across projects. Use <code>ctx hub</code> to start and stop the server, inspect cluster state, add or remove peers at runtime, and hand off leadership before maintenance.</p> <p>Who Needs This Page</p> <p>You only need <code>ctx hub</code> if you are running a hub server or cluster. For client-side operations (register, subscribe, sync, publish, listen), see <code>ctx connection</code>. For the mental model behind the hub as a whole, read the <code>ctx</code> Hub overview.</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-start","level":3,"title":"<code>ctx hub start</code>","text":"<p>Start the hub gRPC server.</p> <p>Examples:</p> <pre><code>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</code></pre> <p>On first run, generates an admin token and prints it to stdout. Save this token; it's required for <code>ctx connection register</code> in client projects. Subsequent runs reuse the stored token from <code><data-dir>/admin.token</code>.</p> <p>Default data directory: <code>~/.ctx/hub-data/</code></p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#daemon-mode","level":4,"title":"Daemon Mode","text":"<p>Run the hub as a detached background process:</p> <pre><code>ctx hub start --daemon # Fork to background\nctx hub stop # Graceful shutdown\n</code></pre> <p>The daemon writes a PID file to <code><data-dir>/hub.pid</code>. Stop the daemon with <code>ctx hub stop</code> (see below).</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#cluster-mode","level":4,"title":"Cluster Mode","text":"<p>For high availability, run multiple hubs with Raft-based leader election:</p> <pre><code>ctx hub start --port 9900 \\\n --peers host2:9901,host3:9901\n</code></pre> <p>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.</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#flags","level":4,"title":"Flags","text":"Flag Description Default <code>--port</code> Hub listen port <code>9900</code> <code>--data-dir</code> Hub data directory <code>~/.ctx/hub-data/</code> <code>--daemon</code> Run the hub server in the background <code>false</code> <code>--peers</code> Comma-separated peer addresses for cluster mode (none)","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#validation","level":4,"title":"Validation","text":"<p>The hub validates every published entry before accepting it:</p> <ul> <li>Type must be one of <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code></li> <li>ID and Origin are required and non-empty</li> <li>Content size capped at 1 MB (text-only)</li> <li>Duplicate project registration is rejected (one token per project)</li> </ul>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stop","level":3,"title":"<code>ctx hub stop</code>","text":"<p>Stop a running hub daemon.</p> <p>Examples:</p> <pre><code>ctx hub stop # Stop using default data dir\nctx hub stop --data-dir /srv/ctx-hub # Custom data directory\n</code></pre> <p>Sends <code>SIGTERM</code> to the PID recorded in <code><data-dir>/hub.pid</code>, 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.</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-status","level":3,"title":"<code>ctx hub status</code>","text":"<p>Show cluster status: role, peers, sync state, entry count, and uptime.</p> <p>Examples:</p> <pre><code>ctx hub status\n</code></pre>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-peer","level":3,"title":"<code>ctx hub peer</code>","text":"<p>Add or remove peers from the cluster at runtime. Useful for scaling up or replacing a decommissioned node without restarting the leader.</p> <p>Examples:</p> <pre><code>ctx hub peer add host2:9901\nctx hub peer remove host2:9901\n</code></pre>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stepdown","level":3,"title":"<code>ctx hub stepdown</code>","text":"<p>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.</p> <p>Examples:</p> <pre><code>ctx hub stepdown\n</code></pre>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx connection</code>: client-side commands (register, subscribe, sync, publish, listen)</li> <li><code>ctx</code> Hub overview: mental model and user stories</li> <li><code>ctx</code> Hub: Getting Started</li> <li>Hub operations: production deployment, backup, monitoring</li> <li>Hub failure modes</li> <li>Hub security model</li> </ul>","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":"<code>ctx init</code>","text":"<p>Initialize a new <code>.context/</code> directory with template files.</p> <pre><code>ctx init [flags]\n</code></pre> <p>Git is required</p> <p><code>ctx init</code> (and every non-administrative <code>ctx</code> subcommand) refuses to operate without a <code>.git/</code> working tree at the project root. <code>ctx</code> already needed git to work properly; that requirement is now enforced rather than assumed.</p> <p>Handovers and closeouts stamp the current commit into their frontmatter, and the editorial pipeline pins in-repo evidence to a short SHA (none of which works without a repo). </p> <p>Run <code>git init</code> first if the project does not already have one. </p> <p>There is no <code>--allow-no-git</code> escape hatch. </p> <p>Flags:</p> Flag Short Description <code>--force</code> <code>-f</code> Overwrite existing context files <code>--minimal</code> <code>-m</code> Only create essential files (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>CONSTITUTION.md</code>) <code>--merge</code> Auto-merge <code>ctx</code> content into existing <code>CLAUDE.md</code> <p>Creates:</p> <ul> <li><code>.context/</code> directory with all template files</li> <li><code>.context/kb/</code> (with <code>index.md</code> and <code>topics/</code>) and <code>.context/ingest/</code> (with <code>KB-RULES.md</code>, mode prompts, <code>OPERATOR.md</code>, <code>PROMPT.md</code>, <code>closeouts/</code>, <code>schemas/</code>) and <code>.context/handovers/</code>: the editorial-pipeline scaffolding (Phase KB). Embedded templates are copied; existing files are preserved.</li> <li><code>.claude/settings.local.json</code> with pre-approved <code>ctx</code> permissions</li> <li><code>CLAUDE.md</code> with bootstrap instructions (or merges into existing)</li> </ul> <p>Claude Code hooks and skills are provided by the <code>ctx</code> plugin (see Integrations).</p> <p>Example:</p> <pre><code># 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</code></pre> <p>After <code>ctx init</code> succeeds, <code>.context/</code> and the canonical files are created in <code>$PWD</code>. Run subsequent <code>ctx</code> commands from the same directory (the project root); <code>ctx</code> always reads <code>$PWD/.context/</code>.</p>","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-status","level":3,"title":"<code>ctx status</code>","text":"<p>Show the current context summary.</p> <pre><code>ctx status [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--json</code> Output as JSON <code>--verbose</code> <code>-v</code> Include file contents summary <p>Output:</p> <ul> <li>Context directory path</li> <li>Total files and token estimate</li> <li>Status of each file (loaded, empty, missing)</li> <li>Recent activity (modification times)</li> <li>Drift warnings if any</li> </ul> <p>Example:</p> <pre><code>ctx status\nctx status --json\nctx status --verbose\n</code></pre>","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-agent","level":3,"title":"<code>ctx agent</code>","text":"<p>Print an AI-ready context packet optimized for LLM consumption.</p> <pre><code>ctx agent [flags]\n</code></pre> <p>Flags:</p> Flag Default Description <code>--budget</code> 8000 Token budget: controls content selection and prioritization <code>--format</code> md Output format: <code>md</code> or <code>json</code> <code>--cooldown</code> 10m Suppress repeated output within this duration (requires <code>--session</code>) <code>--session</code> (none) Session ID for cooldown isolation (e.g., <code>$PPID</code>) <code>--include-hub</code> false Include hub entries from <code>.context/hub/</code> <p>How budget works:</p> <p>The budget controls how much context is included. Entries are selected in priority tiers:</p> <ol> <li>Constitution: always included in full (inviolable rules)</li> <li>Tasks: all active tasks, up to 40% of budget</li> <li>Conventions: all conventions, up to 20% of budget</li> <li>Decisions: scored by recency and relevance to active tasks</li> <li>Learnings: scored by recency and relevance to active tasks</li> <li>Steering: applicable steering file bodies, scored by their <code>inclusion</code> mode and description match against the active prompt</li> <li>Skill: named skill content (from <code>--skill</code>)</li> <li>Hub: entries from <code>.context/hub/</code> (with <code>--include-hub</code>, see <code>ctx connection</code>)</li> </ol> <p>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.</p> <p>Output Sections:</p> Section Source Selection Read These Files all <code>.context/</code> Non-empty files in priority order Constitution <code>CONSTITUTION.md</code> All rules (never truncated) Current Tasks <code>TASKS.md</code> All unchecked tasks (budget-capped) Key Conventions <code>CONVENTIONS.md</code> All items (budget-capped) Recent Decisions <code>DECISIONS.md</code> Full body, scored by relevance Key Learnings <code>LEARNINGS.md</code> Full body, scored by relevance Also Noted overflow Title-only summaries <p>Example:</p> <pre><code># 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</code></pre> <p>Use case: Copy-paste into AI chat, pipe to system prompt, or use in hooks.</p>","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-load","level":3,"title":"<code>ctx load</code>","text":"<p>Load and display assembled context as AI would see it.</p> <pre><code>ctx load [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--budget <tokens></code> Token budget for assembly (default: 8000) <code>--raw</code> Output raw file contents without assembly <p>Example:</p> <pre><code>ctx load\nctx load --budget 16000\nctx load --raw\n</code></pre>","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":"<code>ctx journal</code>","text":"<p>Browse and search AI session history from Claude Code and other tools.</p> <pre><code>ctx journal <subcommand>\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source","level":4,"title":"<code>ctx journal source</code>","text":"<p>List all parsed sessions.</p> <pre><code>ctx journal source [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--limit</code> <code>-M</code> Maximum sessions to display (default: 20) <code>--project</code> <code>-p</code> Filter by project name <code>--tool</code> <code>-t</code> Filter by tool (e.g., <code>claude-code</code>) <code>--since</code> Show sessions on or after this date (YYYY-MM-DD) <code>--until</code> Show sessions on or before this date (YYYY-MM-DD) <code>--all-projects</code> Include sessions from all projects <p>Sessions are sorted by date (newest first) and display slug, project, start time, duration, turn count, and token usage.</p> <p>Example:</p> <pre><code>ctx journal source\nctx journal source --limit 5\nctx journal source --project ctx\nctx journal source --tool claude-code\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source-show","level":4,"title":"<code>ctx journal source --show</code>","text":"<p>Show details of a specific session.</p> <pre><code>ctx journal source --show [session-id] [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--latest</code> Show the most recent session <code>--full</code> Show full message content <code>--all-projects</code> Search across all projects <p>The session ID can be a full UUID, partial match, or session slug name.</p> <p>Example:</p> <pre><code>ctx journal source --show abc123\nctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show --latest\nctx journal source --show --latest --full\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-import","level":4,"title":"<code>ctx journal import</code>","text":"<p>Import sessions to editable journal files in <code>.context/journal/</code>.</p> <pre><code>ctx journal import [session-id] [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--all</code> Import new sessions and complete any whose transcript has grown <code>--all-projects</code> Import from all projects <code>--regenerate</code> Edge case: force a full re-render of existing entries <code>--keep-frontmatter</code> Preserve enriched YAML frontmatter during regeneration (default: true) <code>--yes</code>, <code>-y</code> Skip confirmation prompt <code>--dry-run</code> Show what would be imported without writing files <p>Self-healing, no flags required. Import's unit of memory is the source transcript, not the output file. A sweep (<code>--all</code>) automatically:</p> <ul> <li>imports new sessions it has never seen;</li> <li>completes grown sessions — any whose transcript gained messages since the last import (for example, a session imported while it was still running) is re-rendered up to its current end. Claude Code transcripts are append-only, so \"it grew\" is detected from the file's size and mtime alone; a partial import is just an intermediate state the next sweep finishes;</li> <li>skips unchanged sessions, byte-for-byte, writing nothing.</li> </ul> <p>So you never have to remember to re-import or time it: importing a live session mid-flight is safe and the next sweep heals it. That \"no new flags\" is the feature — it is why import is wired into <code>/ctx-wrap-up</code> and a <code>SessionEnd</code> hook, where it runs on the way out of every session (idempotent; one <code>stat</code> per session when there is nothing to do).</p> <p>Your edits are never clobbered. Journal entries are meant to be edited (add notes, clean up the transcript). Before re-rendering a grown entry, import checks whether the file's body is still exactly what ctx last wrote; if you edited it, ctx leaves the file untouched and warns, pointing you at <code>ctx journal lock</code> (permanent protection) or an explicit <code>--regenerate</code> (deliberate discard). Locked entries are never rewritten under any flag.</p> <p><code>--regenerate</code> is an edge-case tool, not the routine path. Reach for it to (a) mass-re-render after a change to the render format, or (b) one-time heal a pre-self-heal entry that an old mid-session import truncated — its source will never grow again, so the automatic path cannot heal it, and <code>--regenerate</code> re-renders it from the full transcript. <code>--keep-frontmatter=false</code> additionally discards enriched frontmatter during that re-render.</p> <p>Single-session import (<code>ctx journal import <id></code>) always re-renders the targeted session without prompting, since you are explicitly targeting it.</p> <p>The <code>journal/</code> directory should be gitignored (like <code>sessions/</code>) since it contains raw conversation data.</p> <p>Example:</p> <pre><code>ctx journal import abc123 # Import (or re-render) one session\nctx journal import --all # Import new + complete grown sessions\nctx journal import --all --dry-run # Preview what would be imported\nctx journal import --all --regenerate # Edge case: force full re-render (prompts)\nctx journal import --all --regenerate -y # Force full re-render without prompting\nctx journal import --all --regenerate --keep-frontmatter=false -y # Discard frontmatter\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-lock","level":4,"title":"<code>ctx journal lock</code>","text":"<p>Protect journal entries from being overwritten by <code>import --regenerate</code> or modified by enrichment skills (<code>/ctx-journal-enrich</code>, <code>/ctx-journal-enrich-all</code>).</p> <pre><code>ctx journal lock <pattern> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--all</code> Lock all journal entries <p>The pattern matches filenames by slug, date, or short ID. Locking a multi-part entry locks all parts. The lock is recorded in <code>.context/journal/.state.json</code> and a <code>locked: true</code> line is added to the file's YAML frontmatter for visibility.</p> <p>Example:</p> <pre><code>ctx journal lock abc12345\nctx journal lock 2026-01-21-session-abc12345.md\nctx journal lock --all\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-unlock","level":4,"title":"<code>ctx journal unlock</code>","text":"<p>Remove lock protection from journal entries.</p> <pre><code>ctx journal unlock <pattern> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--all</code> Unlock all journal entries <p>Example:</p> <pre><code>ctx journal unlock abc12345\nctx journal unlock --all\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-sync","level":4,"title":"<code>ctx journal sync</code>","text":"<p>Sync lock state from journal frontmatter to <code>.state.json</code>.</p> <pre><code>ctx journal sync\n</code></pre> <p>Scans all journal markdowns and updates <code>.state.json</code> to match each file's frontmatter. Files with <code>locked: true</code> in frontmatter are marked locked in state; files without a <code>locked:</code> line have their lock cleared.</p> <p>This is the inverse of <code>ctx journal lock</code>: instead of state driving frontmatter, frontmatter drives state. Useful after batch enrichment where you add <code>locked: true</code> to frontmatter manually.</p> <p>Example:</p> <pre><code># After enriching entries and adding locked: true to frontmatter\nctx journal sync\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal_1","level":3,"title":"<code>ctx journal</code>","text":"<p>Analyze and synthesize imported session files.</p> <pre><code>ctx journal <subcommand>\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-site","level":4,"title":"<code>ctx journal site</code>","text":"<p>Generate a static site from journal entries in <code>.context/journal/</code>.</p> <pre><code>ctx journal site [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--output</code> <code>-o</code> Output directory (default: .context/journal-site) <code>--build</code> Run zensical build after generating <code>--serve</code> Run zensical serve after generating <p>Creates a <code>zensical</code>-compatible site structure with an index page listing all sessions by date, and individual pages for each journal entry.</p> <p>Requires <code>zensical</code> to be installed for <code>--build</code> or <code>--serve</code>:</p> <pre><code>pipx install zensical\n</code></pre> <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-obsidian","level":4,"title":"<code>ctx journal obsidian</code>","text":"<p>Generate an Obsidian vault from journal entries in <code>.context/journal/</code>.</p> <pre><code>ctx journal obsidian [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--output</code> <code>-o</code> Output directory (default: .context/journal-obsidian) <p>Creates an Obsidian-compatible vault with:</p> <ul> <li>Wikilinks (<code>[[target|display]]</code>) for all internal navigation</li> <li>MOC pages (Map of Content) for topics, key files, and session types</li> <li>Related sessions footer linking entries that share topics</li> <li>Transformed frontmatter (<code>topics</code> → <code>tags</code> for Obsidian integration)</li> <li>Minimal <code>.obsidian/</code> config enforcing wikilink mode</li> </ul> <p>No external dependencies are required: Open the output directory as an Obsidian vault directly.</p> <p>Example:</p> <pre><code>ctx journal obsidian # Generate in .context/journal-obsidian/\nctx journal obsidian --output ~/vaults/ctx # Custom output directory\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-check","level":4,"title":"<code>ctx journal schema check</code>","text":"<p>Validate JSONL session files against the embedded schema and report drift.</p> <pre><code>ctx journal schema check [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--dir</code> Directory to scan for JSONL files <code>--all-projects</code> Scan all Claude Code project directories <code>--quiet</code> <code>-q</code> Exit code only (0 = clean, 1 = drift) <p>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 <code>.context/reports/schema-drift.md</code>. When drift resolves, the report is automatically deleted.</p> <p>Designed for interactive use, CI pipelines, and nightly cron jobs.</p> <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-dump","level":4,"title":"<code>ctx journal schema dump</code>","text":"<p>Print the embedded JSONL schema definition.</p> <pre><code>ctx journal schema dump\n</code></pre> <p>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.</p> <p>Example:</p> <pre><code>ctx journal schema dump\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-serve","level":3,"title":"<code>ctx serve</code>","text":"<p>Serve any zensical directory locally. This is a serve-only command: It does not generate or regenerate site content.</p> <pre><code>ctx serve [directory]\n</code></pre> <p>If no directory is specified, defaults to the journal site (<code>.context/journal-site</code>).</p> <p>Requires <code>zensical</code> to be installed:</p> <pre><code>pipx install zensical\n</code></pre> <p><code>ctx serve</code> vs. <code>ctx journal site --serve</code></p> <p><code>ctx journal site --serve</code> generates the journal site then serves it: an all-in-one command. <code>ctx serve</code> only serves an existing directory, and works with any zensical site (journal, docs, etc.).</p> <p>Example:</p> <pre><code>ctx serve # Serve journal site (no regeneration)\nctx serve .context/journal-site # Same, explicit path\nctx serve ./site # Serve the docs site\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/kb/","level":1,"title":"ctx kb","text":"","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb","level":2,"title":"<code>ctx kb</code>","text":"<p>Knowledge-base editorial pipeline (Phase KB). Manages the <code>.context/kb/</code> knowledge base via mode-aware skills and a small set of supporting CLI commands. The editorial constitution lives at <code>.context/ingest/KB-RULES.md</code> (laid down by <code>ctx init</code>).</p> <pre><code>ctx kb [subcommand]\n</code></pre> Subcommand Type Purpose <code>ctx kb topic new \"<name>\"</code> CLI (real) Sole writer of topic-page scaffolds. Creates <code>.context/kb/topics/<slug>/index.md</code> from the embedded template. Refuses when the topic exists. <code>ctx kb note \"<text>\"</code> CLI (real) Appends a one-liner to <code>.context/ingest/findings.md</code>. Never touches a topic page. <code>ctx kb reindex</code> CLI (real) Refreshes the <code>CTX:KB:TOPICS</code> managed block in <code>.context/kb/index.md</code>. <code>ctx kb ingest <folder\\|paths></code> Skill-driven Mode-aware editorial pass. CLI form refuses on empty input and points at the <code>/ctx-kb-ingest</code> skill. <code>ctx kb ask \"<question>\"</code> Skill-driven Q&A grounded in the kb. CLI form refuses on empty input and points at the <code>/ctx-kb-ask</code> skill. <code>ctx kb site-review</code> Skill-driven Mechanical structural audit. Points at <code>/ctx-kb-site-review</code>. <code>ctx kb ground</code> Skill-driven Read-only freshness audit over tracked sources listed in <code>grounding-sources.md</code> (URLs, in-tree paths, MCP resources). Refuses when the file is empty. <p>Skill-driven vs real CLI</p> <p>The mode skills (<code>ingest</code>, <code>ask</code>, <code>site-review</code>, <code>ground</code>) do the editorial work themselves: the agent reads <code>.context/ingest/30-INGEST.md</code> (etc.) and executes the pass per the pass-mode contract. The CLI form for those subcommands validates input and prints the canonical skill invocation. The real CLI commands (<code>topic new</code>, <code>note</code>, <code>reindex</code>) own concrete state changes.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb-topic-new-name","level":3,"title":"<code>ctx kb topic new \"<name>\"</code>","text":"<p>Scaffolds a folder-shaped topic at <code>.context/kb/topics/<slug>/index.md</code> from the embedded template.</p> <p>Slug: lowercase + kebab-case. Slashes are preserved for vendor-namespaced topology (e.g. <code>cursor/hooks</code>, <code>cursor/skills</code>, <code>cursor/rules</code> under a shared <code>cursor/</code> folder).</p> <p>Refuses when the topic folder already exists. Use the existing folder instead; the editorial pass extends pages, it doesn't reset them.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb-note-text","level":3,"title":"<code>ctx kb note \"<text>\"</code>","text":"<p>Appends a timestamped one-liner to <code>.context/ingest/findings.md</code>. Use for parking findings the next ingest pass should absorb.</p> <pre><code>ctx kb note \"follow-up: chase the v1.2 release notes for the SIGTERM change\"\n</code></pre>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb-reindex","level":3,"title":"<code>ctx kb reindex</code>","text":"<p>Refreshes the <code>CTX:KB:TOPICS</code> managed block inside <code>.context/kb/index.md</code> so the kb landing page enumerates current topic folders. Run after <code>ctx kb topic new</code> to update the landing.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#skill-driven-subcommands","level":3,"title":"Skill-Driven Subcommands","text":"<p><code>ingest</code>, <code>ask</code>, <code>site-review</code>, <code>ground</code> exist as CLI surfaces so the editorial workflow is drivable from outside Claude Code (via the fallback <code>PROMPT.md</code> auto-router). In Claude Code, prefer the skills:</p> <pre><code>/ctx-kb-ingest ./inputs/2026-05-15-call.md \"cursor hooks\"\n/ctx-kb-ask \"does the kb say hooks fire async?\"\n/ctx-kb-site-review\n/ctx-kb-ground\n</code></pre> <p>See the Build a Knowledge Base recipe for the full workflow.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Build a Knowledge Base</li> <li>Recipe: Typical KB Session</li> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code></li> </ul>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/loop/","level":1,"title":"Loop","text":"","path":["CLI","Integrations","Loop"],"tags":[]},{"location":"cli/loop/#ctx-loop","level":2,"title":"<code>ctx loop</code>","text":"<p>Generate a shell script for running an autonomous loop.</p> <p>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.</p> <pre><code>ctx loop [flags]\n</code></pre> <p>Flags:</p> Flag Short Description Default <code>--tool <tool></code> <code>-t</code> AI tool: <code>claude</code>, <code>aider</code>, or <code>generic</code> <code>claude</code> <code>--prompt <file></code> <code>-p</code> Prompt file to use <code>.context/loop.md</code> <code>--max-iterations <n></code> <code>-n</code> Maximum iterations (0 = unlimited) <code>0</code> <code>--completion <signal></code> <code>-c</code> Completion signal to detect <code>SYSTEM_CONVERGED</code> <code>--output <file></code> <code>-o</code> Output script filename <code>loop.sh</code> <p>Examples:</p> <pre><code># 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</code></pre> <p>Running the generated loop:</p> <pre><code>ctx loop\nchmod +x loop.sh\n./loop.sh\n</code></pre> <p>See also: Autonomous Loops for the full workflow.</p>","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":"<code>ctx mcp</code>","text":"<p>Run <code>ctx</code> 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.</p> <p>This makes <code>ctx</code> accessible to any MCP-compatible AI tool without custom hooks or integrations:</p> <ul> <li>Claude Desktop</li> <li>Cursor</li> <li>Windsurf</li> <li>VS Code Copilot</li> <li>Any tool supporting MCP</li> </ul>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-mcp-serve","level":3,"title":"<code>ctx mcp serve</code>","text":"<p>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.</p> <p>Flags: None. The server resolves the context directory by reading <code>$PWD/.context/</code>. The MCP host must launch the server from the project root (or its launch wrapper must <code>cd</code> first). There is no env-var or walk-up resolution.</p> <p>Examples:</p> <pre><code># Normal invocation (by an MCP client via stdio transport,\n# from the project root)\nctx mcp serve\n\n# Verify the binary starts without a client attached (Ctrl-C to exit)\nctx mcp serve < /dev/null\n</code></pre>","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":"<p>Add to <code>~/Library/Application Support/Claude/claude_desktop_config.json</code>:</p> <pre><code>{\n \"mcpServers\": {\n \"ctx\": {\n \"command\": \"ctx\",\n \"args\": [\"mcp\", \"serve\"]\n }\n }\n}\n</code></pre>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#cursor","level":3,"title":"Cursor","text":"<p>Add to <code>.cursor/mcp.json</code> in your project:</p> <pre><code>{\n \"mcpServers\": {\n \"ctx\": {\n \"command\": \"ctx\",\n \"args\": [\"mcp\", \"serve\"]\n }\n }\n}\n</code></pre>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#vs-code-copilot","level":3,"title":"VS Code (Copilot)","text":"<p>Add to <code>.vscode/mcp.json</code>:</p> <pre><code>{\n \"servers\": {\n \"ctx\": {\n \"command\": \"ctx\",\n \"args\": [\"mcp\", \"serve\"]\n }\n }\n}\n</code></pre>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resources","level":2,"title":"Resources","text":"<p>Resources expose context files as read-only content. Each resource has a URI, name, and returns Markdown text.</p> URI Name Description <code>ctx://context/constitution</code> constitution Hard rules that must never be violated <code>ctx://context/tasks</code> tasks Current work items and their status <code>ctx://context/conventions</code> conventions Code patterns and standards <code>ctx://context/architecture</code> architecture System architecture documentation <code>ctx://context/decisions</code> decisions Architectural decisions with rationale <code>ctx://context/learnings</code> learnings Gotchas, tips, and lessons learned <code>ctx://context/glossary</code> glossary Project-specific terminology <code>ctx://context/agent</code> agent All files assembled in priority read order <p>The <code>agent</code> resource assembles all non-empty context files into a single Markdown document, ordered by the configured read priority.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resource-subscriptions","level":3,"title":"Resource Subscriptions","text":"<p>Clients can subscribe to resource changes via <code>resources/subscribe</code>. The server polls for file mtime changes (default: 5 seconds) and emits <code>notifications/resources/updated</code> when a subscribed file changes on disk.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#tools","level":2,"title":"Tools","text":"<p>Tools expose <code>ctx</code> commands as callable operations. Each tool accepts JSON arguments and returns text results.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_status","level":3,"title":"<code>ctx_status</code>","text":"<p>Show context health: file count, token estimate, and per-file summary.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_add","level":3,"title":"<code>ctx_add</code>","text":"<p>Add a task, decision, learning, or convention to the context.</p> Argument Type Required Description <code>type</code> string Yes Entry type: task, decision, learning, convention <code>content</code> string Yes Title or main content <code>priority</code> string No Priority level (tasks only): high, medium, low <code>context</code> string Conditional Context field (decisions and learnings) <code>rationale</code> string Conditional Rationale (decisions only) <code>consequence</code> string Conditional Consequence (decisions only) <code>lesson</code> string Conditional Lesson learned (learnings only) <code>application</code> string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_complete","level":3,"title":"<code>ctx_complete</code>","text":"<p>Mark a task as done by number or text match.</p> Argument Type Required Description <code>query</code> string Yes Task number (e.g. \"1\") or search text","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_drift","level":3,"title":"<code>ctx_drift</code>","text":"<p>Detect stale or invalid context. Returns violations, warnings, and passed checks.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_journal_source","level":3,"title":"<code>ctx_journal_source</code>","text":"<p>Query recent AI session history (summaries, decisions, topics).</p> Argument Type Required Description <code>limit</code> number No Max sessions to return (default: 5) <code>since</code> string No ISO date filter: sessions after this date (YYYY-MM-DD) <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_watch_update","level":3,"title":"<code>ctx_watch_update</code>","text":"<p>Apply a structured context update to <code>.context/</code> files. Supports task, decision, learning, convention, and complete entry types. Human confirmation is required before calling.</p> Argument Type Required Description <code>type</code> string Yes Entry type: task, decision, learning, convention, complete <code>content</code> string Yes Main content <code>context</code> string Conditional Context background (decisions/learnings) <code>rationale</code> string Conditional Rationale (decisions only) <code>consequence</code> string Conditional Consequence (decisions only) <code>lesson</code> string Conditional Lesson learned (learnings only) <code>application</code> string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_compact","level":3,"title":"<code>ctx_compact</code>","text":"<p>Move completed tasks to the archive section and remove empty sections from context files. Human confirmation required.</p> Argument Type Required Description <code>archive</code> boolean No Also write tasks to <code>.context/archive/</code> (default: false)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_next","level":3,"title":"<code>ctx_next</code>","text":"<p>Suggest the next pending task based on priority and position.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_checktaskcompletion","level":3,"title":"<code>ctx_checktaskcompletion</code>","text":"<p>Advisory check: after a write operation, detect if any pending tasks were silently completed. Returns nudge text if a match is found.</p> Argument Type Required Description <code>recent_action</code> string No Brief description of what was just done <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_sessionevent","level":3,"title":"<code>ctx_sessionevent</code>","text":"<p>Signal a session lifecycle event. Type <code>end</code> triggers the session-end persistence ceremony - human confirmation required.</p> Argument Type Required Description <code>type</code> string Yes Event type: start, end <code>caller</code> string No Caller identifier (cursor, windsurf, vscode, claude-desktop)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_steering_get","level":3,"title":"<code>ctx_steering_get</code>","text":"<p>Retrieve applicable steering files for a prompt. Without a prompt, returns always-included files only.</p> Argument Type Required Description <code>prompt</code> string No Prompt text to match against steering file descriptions <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_search","level":3,"title":"<code>ctx_search</code>","text":"<p>Search across <code>.context/</code> files for a query string. Returns matching lines with file paths and line numbers.</p> Argument Type Required Description <code>query</code> string Yes Search string to match against <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_start","level":3,"title":"<code>ctx_session_start</code>","text":"<p>Execute session-start hooks and return aggregated context from hook outputs.</p> <p>Arguments: None.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_end","level":3,"title":"<code>ctx_session_end</code>","text":"<p>Execute session-end hooks with an optional summary. Returns aggregated context from hook outputs.</p> Argument Type Required Description <code>summary</code> string No Session summary passed to hook scripts","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_remind","level":3,"title":"<code>ctx_remind</code>","text":"<p>List pending session-scoped reminders.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#prompts","level":2,"title":"Prompts","text":"<p>Prompts provide pre-built templates for common workflows. Clients can list available prompts via <code>prompts/list</code> and retrieve a specific prompt via <code>prompts/get</code>.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-session-start","level":3,"title":"<code>ctx-session-start</code>","text":"<p>Load full context at the beginning of a session. Returns all context files assembled in priority read order with session orientation instructions.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-decision-add","level":3,"title":"<code>ctx-decision-add</code>","text":"<p>Format an architectural decision entry with all required fields.</p> Argument Type Required Description <code>content</code> string Yes Decision title <code>context</code> string Yes Background context <code>rationale</code> string Yes Why this decision was made <code>consequence</code> string Yes Expected consequence","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-learning-add","level":3,"title":"<code>ctx-learning-add</code>","text":"<p>Format a learning entry with all required fields.</p> Argument Type Required Description <code>content</code> string Yes Learning title <code>context</code> string Yes Background context <code>lesson</code> string Yes The lesson learned <code>application</code> string Yes How to apply this lesson","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-reflect","level":3,"title":"<code>ctx-reflect</code>","text":"<p>Guide end-of-session reflection. Returns a structured review prompt covering progress assessment and context update recommendations.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-checkpoint","level":3,"title":"<code>ctx-checkpoint</code>","text":"<p>Report session statistics: tool calls made, entries added, and pending updates queued during the current session.</p>","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":"<code>ctx memory</code>","text":"<p>Bridge Claude Code's auto memory (MEMORY.md) into <code>.context/</code>.</p> <p>Claude Code maintains per-project auto memory at <code>~/.claude/projects/<slug>/memory/MEMORY.md</code>. This command group discovers that file, mirrors it into <code>.context/memory/mirror.md</code> (git-tracked), and detects drift.</p> <pre><code>ctx memory <subcommand>\n</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-sync","level":3,"title":"<code>ctx memory sync</code>","text":"<p>Copy MEMORY.md to <code>.context/memory/mirror.md</code>. Archives the previous mirror before overwriting.</p> <pre><code>ctx memory sync [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--dry-run</code> Show what would happen without writing <p>Exit codes:</p> Code Meaning 0 Synced successfully 1 MEMORY.md not found (auto memory inactive) <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-status","level":3,"title":"<code>ctx memory status</code>","text":"<p>Show drift, timestamps, line counts, and archive count.</p> <pre><code>ctx memory status\n</code></pre> <p>Exit codes:</p> Code Meaning 0 No drift 1 MEMORY.md not found 2 Drift detected (MEMORY.md changed since sync) <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-diff","level":3,"title":"<code>ctx memory diff</code>","text":"<p>Show what changed in MEMORY.md since last sync.</p> <pre><code>ctx memory diff\n</code></pre> <p>Examples:</p> <pre><code>ctx memory diff\n# --- .context/memory/mirror.md (mirror)\n# +++ ~/.claude/projects/.../memory/MEMORY.md (source)\n# +- new learning: memory bridge works\n</code></pre> <p>No output when files are identical.</p>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-publish","level":3,"title":"<code>ctx memory publish</code>","text":"<p>Push curated <code>.context/</code> content into MEMORY.md so the agent sees it natively.</p> <pre><code>ctx memory publish [flags]\n</code></pre> <p>Content is selected in priority order: pending tasks, recent decisions (7 days), key conventions, recent learnings (7 days). Wrapped in <code><!-- ctx:published --></code> markers. Claude-owned content outside the markers is preserved.</p> <p>Flags:</p> Flag Description Default <code>--budget</code> Line budget for published content <code>80</code> <code>--dry-run</code> Show what would be published <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-unpublish","level":3,"title":"<code>ctx memory unpublish</code>","text":"<p>Remove the ctx-managed marker block from MEMORY.md, preserving Claude-owned content.</p> <p>Examples:</p> <pre><code>ctx memory unpublish\n</code></pre> <p>Hook integration: The <code>check-memory-drift</code> 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.</p>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-import","level":3,"title":"<code>ctx memory import</code>","text":"<p>Classify and promote entries from MEMORY.md into structured <code>.context/</code> files.</p> <pre><code>ctx memory import [flags]\n</code></pre> <p>Each entry is classified by keyword heuristics:</p> Keywords Target <code>always use</code>, <code>prefer</code>, <code>never use</code>, <code>standard</code> CONVENTIONS.md <code>decided</code>, <code>chose</code>, <code>trade-off</code>, <code>approach</code> DECISIONS.md <code>gotcha</code>, <code>learned</code>, <code>watch out</code>, <code>bug</code>, <code>caveat</code> LEARNINGS.md <code>todo</code>, <code>need to</code>, <code>follow up</code> TASKS.md Everything else Skipped <p>Deduplication prevents re-importing the same entry across runs.</p> <p>Flags:</p> Flag Description <code>--dry-run</code> Show classification plan without writing <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/message/","level":1,"title":"Message","text":"","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message","level":3,"title":"<code>ctx hook message</code>","text":"<p>Manage hook message templates.</p> <p>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.</p> <pre><code>ctx hook message <subcommand>\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-list","level":3,"title":"<code>ctx hook message list</code>","text":"<p>Show all hook messages with category and override status.</p> <pre><code>ctx hook message list [--json]\n</code></pre> <p>Flags:</p> Flag Description <code>--json</code> Output in JSON format <p>Example:</p> <pre><code>ctx hook message list\nctx hook message list --json | jq '.[] | select(.override)'\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-show","level":3,"title":"<code>ctx hook message show</code>","text":"<p>Print the effective message template for a hook/variant pair. Shows the user override if present, otherwise the embedded default.</p> <pre><code>ctx hook message show <hook> <variant>\n</code></pre> <p>Example:</p> <pre><code>ctx hook message show qa-reminder gate\nctx hook message show check-context-size checkpoint\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-edit","level":3,"title":"<code>ctx hook message edit</code>","text":"<p>Copy the embedded default template for <code><hook> <variant></code> to <code>.context/hooks/messages/<hook>/<variant>.txt</code> so you can edit it directly. The override takes effect the next time the hook fires.</p> <pre><code>ctx hook message edit <hook> <variant>\n</code></pre> <p>If an override already exists, the command fails and directs you to edit it in place or reset it first.</p> <p>Example:</p> <pre><code>ctx hook message edit qa-reminder gate\n# Edit .context/hooks/messages/qa-reminder/gate.txt in your editor\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-reset","level":3,"title":"<code>ctx hook message reset</code>","text":"<p>Delete a user override and revert to the embedded default. Silent no-op if no override exists.</p> <pre><code>ctx hook message reset <hook> <variant>\n</code></pre> <p>Example:</p> <pre><code>ctx hook message reset qa-reminder gate\n</code></pre> <p>See Customizing hook messages for the full workflow.</p>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/notify/","level":1,"title":"Notify","text":"","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify","level":2,"title":"<code>ctx hook notify</code>","text":"<p>Send fire-and-forget webhook notifications from skills, loops, and hooks.</p> <pre><code>ctx hook notify --event <name> [--session-id <id>] \"message\"\n</code></pre> <p>Flags:</p> Flag Short Description <code>--event</code> <code>-e</code> Event name (required) <code>--session-id</code> <code>-s</code> Session ID (optional) <p>Behavior:</p> <ul> <li>No webhook configured: silent no-op (exit 0)</li> <li>Webhook set but event not in <code>events</code> list: silent no-op (exit 0)</li> <li>Webhook set and event matches: fire-and-forget HTTP POST</li> <li>HTTP errors silently ignored (no retry)</li> </ul> <p>Examples:</p> <pre><code>ctx hook notify --event loop \"Loop completed after 5 iterations\"\nctx hook notify -e nudge -s session-abc \"Context checkpoint at prompt #20\"\n</code></pre>","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-setup","level":3,"title":"<code>ctx hook notify setup</code>","text":"<p>Configure the webhook URL interactively. The URL is encrypted with AES-256-GCM using the encryption key and stored in <code>.context/.notify.enc</code>.</p> <p>Examples:</p> <pre><code>ctx hook notify setup\n</code></pre> <p>The encrypted file is safe to commit. The key (<code>~/.ctx/.ctx.key</code>) lives outside the project and is never committed.</p>","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-test","level":3,"title":"<code>ctx hook notify test</code>","text":"<p>Send a test notification and report the HTTP response status.</p> <p>Examples:</p> <pre><code>ctx hook notify test\n</code></pre> <p>Payload format (JSON POST):</p> <pre><code>{\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</code></pre> Field Type Description <code>event</code> string Event name from <code>--event</code> flag <code>message</code> string Notification message <code>session_id</code> string Session ID (omitted if empty) <code>timestamp</code> string UTC RFC3339 timestamp <code>project</code> string Project directory name <p>See also: Webhook Notifications recipe.</p>","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":"<code>ctx pad</code>","text":"<p>Encrypted scratchpad for sensitive one-liners that travel with the project.</p> <p>When invoked without a subcommand, lists all entries.</p> <pre><code>ctx pad\nctx pad <subcommand>\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-add","level":3,"title":"<code>ctx pad add</code>","text":"<p>Append a new entry to the scratchpad.</p> <pre><code>ctx pad add <text>\nctx pad add <label> --file <path>\n</code></pre> <p>Flags:</p> Flag Short Description <code>--file</code> <code>-f</code> Ingest a file as a blob entry (max 64 KB) <p>Examples:</p> <pre><code>ctx pad add \"DATABASE_URL=postgres://user:pass@host/db\"\nctx pad add \"deploy config\" --file ./deploy.yaml\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-show","level":3,"title":"<code>ctx pad show</code>","text":"<p>Output the raw text of an entry by number. For blob entries, prints decoded file content (or writes to disk with <code>--out</code>).</p> <pre><code>ctx pad show <n>\nctx pad show <n> --out <path>\n</code></pre> <p>Arguments:</p> <ul> <li><code>n</code>: 1-based entry number</li> </ul> <p>Flags:</p> Flag Description <code>--out</code> Write decoded blob content to a file (blobs only) <p>Examples:</p> <pre><code>ctx pad show 3\nctx pad show 2 --out ./recovered.yaml\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-rm","level":3,"title":"<code>ctx pad rm</code>","text":"<p>Remove one or more entries by stable ID. Supports individual IDs and ranges.</p> <pre><code>ctx pad rm <id> [id...]\n</code></pre> <p>Arguments:</p> <ul> <li><code>id</code>: One or more entry IDs (e.g., <code>3</code>, <code>1 4</code>, <code>3-5</code>)</li> </ul> <p>Examples:</p> <pre><code>ctx pad rm 2\nctx pad rm 1 4\nctx pad rm 3-5\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-normalize","level":3,"title":"<code>ctx pad normalize</code>","text":"<p>Reassign entry IDs as a contiguous sequence 1..N, closing any gaps left by deletions.</p> <p>Examples:</p> <pre><code>ctx pad normalize\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-edit","level":3,"title":"<code>ctx pad edit</code>","text":"<p>Replace, append to, or prepend to an entry.</p> <pre><code>ctx pad edit <n> [text]\n</code></pre> <p>Arguments:</p> <ul> <li><code>n</code>: 1-based entry number</li> <li><code>text</code>: Replacement text (mutually exclusive with <code>--append</code>/<code>--prepend</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--append</code> Append text to the end of the entry <code>--prepend</code> Prepend text to the beginning of entry <code>--file</code> Replace blob file content (preserves label) <code>--label</code> Replace blob label (preserves content) <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-mv","level":3,"title":"<code>ctx pad mv</code>","text":"<p>Move an entry from one position to another.</p> <pre><code>ctx pad mv <from> <to>\n</code></pre> <p>Arguments:</p> <ul> <li><code>from</code>: Source position (1-based)</li> <li><code>to</code>: Destination position (1-based)</li> </ul> <p>Examples:</p> <pre><code>ctx pad mv 3 1 # promote entry 3 to the top\nctx pad mv 1 5 # bury entry 1 to position 5\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-resolve","level":3,"title":"<code>ctx pad resolve</code>","text":"<p>Show both sides of a merge conflict in the encrypted scratchpad.</p> <p>Examples:</p> <pre><code>ctx pad resolve\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-import","level":3,"title":"<code>ctx pad import</code>","text":"<p>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.</p> <p>With <code>--blob</code>, 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.</p> <pre><code>ctx pad import <file>\nctx pad import - # read from stdin\nctx pad import --blob <dir> # import directory files as blobs\n</code></pre> <p>Arguments:</p> <ul> <li><code>file</code>: Path to a text file, <code>-</code> for stdin, or a directory (with <code>--blob</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--blob</code> Import first-level files from a directory as blobs <p>Examples:</p> <pre><code>ctx pad import notes.txt\ngrep TODO *.go | ctx pad import -\nctx pad import --blob ./ideas/\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-export","level":3,"title":"<code>ctx pad export</code>","text":"<p>Export all blob entries from the scratchpad to a directory as files. Each blob's label becomes the filename. Non-blob entries are skipped.</p> <pre><code>ctx pad export [dir]\n</code></pre> <p>Arguments:</p> <ul> <li><code>dir</code>: Target directory (default: current directory)</li> </ul> <p>Flags:</p> Flag Short Description <code>--force</code> <code>-f</code> Overwrite existing files instead of timestamping <code>--dry-run</code> Print what would be exported without writing <p>When a file already exists, a unix timestamp is prepended to avoid collisions (e.g., <code>1739836200-label</code>). Use <code>--force</code> to overwrite instead.</p> <p>Examples:</p> <pre><code>ctx pad export ./ideas\nctx pad export --dry-run\nctx pad export --force ./backup\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-merge","level":3,"title":"<code>ctx pad merge</code>","text":"<p>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.</p> <pre><code>ctx pad merge FILE...\n</code></pre> <p>Arguments:</p> <ul> <li><code>FILE...</code>: One or more scratchpad files to merge (encrypted or plaintext)</li> </ul> <p>Flags:</p> Flag Short Description <code>--key</code> <code>-k</code> Path to key file for decrypting input files <code>--dry-run</code> Print what would be merged without writing <p>Examples:</p> <pre><code>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</code></pre>","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":"<code>ctx hook pause</code>","text":"<p>Pause all context nudge and reminder hooks for the current session. Security hooks (dangerous command blocking) and housekeeping hooks still fire.</p> <pre><code>ctx hook pause [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--session-id</code> Session ID (overrides stdin) <p>Example:</p> <pre><code># Pause hooks for a quick investigation\nctx hook pause\n\n# Resume when ready\nctx hook resume\n</code></pre> <p>See also:</p> <ul> <li><code>ctx hook resume</code>: the matching resume command</li> <li>Pausing Context Hooks recipe</li> </ul>","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":"<code>ctx prune</code>","text":"<p>Remove per-session state files from <code>.context/state/</code> that are older than the specified age. Session state files are identified by UUID suffixes (<code>context-check-<session-id></code>, <code>heartbeat-<session-id></code>, and similar). Global files without session IDs (<code>events.jsonl</code>, <code>memory-import.json</code>, and other non-per-session markers) are always preserved.</p> <pre><code>ctx prune [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--days</code> Prune files older than this many days (default: 7) <code>--dry-run</code> Show what would be pruned without deleting <p>Examples:</p> <pre><code>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</code></pre> <p>See State maintenance for the recommended cadence and automation recipe.</p>","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":"<code>ctx remind</code>","text":"<p>Session-scoped reminders that surface at session start. Reminders are stored verbatim and relayed verbatim: no summarization, no categories.</p> <p>When invoked with a text argument and no subcommand, adds a reminder.</p> <pre><code>ctx remind \"text\"\nctx remind <subcommand>\n</code></pre>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-add","level":3,"title":"<code>ctx remind add</code>","text":"<p>Add a reminder. This is the default action: <code>ctx remind \"text\"</code> and <code>ctx remind add \"text\"</code> are equivalent.</p> <pre><code>ctx remind \"refactor the swagger definitions\"\nctx remind add \"check CI after the deploy\" --after 2026-02-25\n</code></pre> <p>Arguments:</p> <ul> <li><code>text</code>: The reminder message (verbatim)</li> </ul> <p>Flags:</p> Flag Short Description <code>--after</code> <code>-a</code> Don't surface until this date (YYYY-MM-DD) <p>Examples:</p> <pre><code>ctx remind \"refactor the swagger definitions\"\nctx remind \"check CI after the deploy\" --after 2026-02-25\n</code></pre>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-list","level":3,"title":"<code>ctx remind list</code>","text":"<p>List all pending reminders. Date-gated reminders that aren't yet due are annotated with <code>(after DATE, not yet due)</code>.</p> <p>Examples:</p> <pre><code>ctx remind list\nctx remind ls # alias\n</code></pre> <p>Aliases: <code>ls</code></p>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-dismiss","level":3,"title":"<code>ctx remind dismiss</code>","text":"<p>Remove one or more reminders by ID, or remove all with <code>--all</code>. Supports individual IDs and ranges.</p> <pre><code>ctx remind dismiss <id> [id...]\nctx remind dismiss --all\n</code></pre> <p>Arguments:</p> <ul> <li><code>id</code>: One or more reminder IDs (e.g., <code>3</code>, <code>3 5-7</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--all</code> Dismiss all reminders <p>Aliases: <code>rm</code></p> <p>Examples:</p> <pre><code>ctx remind dismiss 3\nctx remind dismiss 3 5-7\nctx remind dismiss --all\n</code></pre>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-normalize","level":3,"title":"<code>ctx remind normalize</code>","text":"<p>Reassign reminder IDs as a contiguous sequence 1..N, closing any gaps left by dismissals.</p> <p>Examples:</p> <pre><code>ctx remind normalize\n</code></pre> <p>See also: Session Reminders recipe.</p>","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":"<code>ctx hook resume</code>","text":"<p>Resume context hooks after a pause. Silent no-op if not paused.</p> <pre><code>ctx hook resume [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--session-id</code> Session ID (overrides stdin) <p>Example:</p> <pre><code>ctx hook resume\n</code></pre> <p>See also:</p> <ul> <li><code>ctx hook pause</code>: the matching pause command</li> <li>Pausing Context Hooks recipe</li> </ul>","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":"<code>ctx serve</code>","text":"<p>Serve a static site locally via zensical.</p> <p>With no argument, serves the journal site at <code>.context/journal-site</code>. With a directory argument, serves that directory if it contains a <code>zensical.toml</code>.</p> <pre><code>ctx serve # Serve .context/journal-site\nctx serve ./my-site # Serve a specific directory\nctx serve ./docs # Serve any zensical site\n</code></pre> <p>This Command Does NOT Start a Hub</p> <p><code>ctx serve</code> is purely for static-site serving. To run a <code>ctx</code> Hub for cross-project knowledge sharing, use <code>ctx hub start</code>. That command lives in its own group because the hub is a gRPC server, not a static site.</p> <p>Requires zensical to be installed:</p> <pre><code>pipx install zensical\n</code></pre>","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#arguments","level":3,"title":"Arguments","text":"Argument Description <code>[directory]</code> Directory containing a <code>zensical.toml</code> to serve <p>When omitted, serves <code>.context/journal-site</code> by default, the directory produced by <code>ctx journal site</code>.</p> <p>Examples:</p> <pre><code>ctx serve # Default: serve .context/journal-site\nctx serve ./my-site # Serve a specific directory\nctx serve ./docs # Serve any zensical site\n</code></pre>","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx journal</code>: generate the journal site that <code>ctx serve</code> displays.</li> <li><code>ctx hub start</code>: for running a <code>ctx</code> Hub server, not a static site.</li> <li>Browsing and enriching past sessions: the recipe that combines <code>ctx journal</code> and <code>ctx serve</code>.</li> </ul>","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":"<code>ctx setup</code>","text":"<p>Generate AI tool integration configuration.</p> <pre><code>ctx setup <tool> [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--write</code> <code>-w</code> Write the generated config to disk (e.g. <code>.github/copilot-instructions.md</code>) <p>Supported tools:</p> Tool Description <code>claude-code</code> Redirects to plugin install instructions <code>cursor</code> Cursor IDE <code>kiro</code> Kiro IDE <code>cline</code> Cline (VS Code extension) <code>aider</code> Aider CLI <code>copilot</code> GitHub Copilot <code>opencode</code> OpenCode (terminal-first AI coding agent) <code>windsurf</code> Windsurf IDE <p>Claude Code Uses the Plugin System</p> <p>Claude Code integration is now provided via the <code>ctx</code> plugin. Running <code>ctx setup claude-code</code> prints plugin install instructions.</p> <p>Examples:</p> <pre><code># 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\n# Generate OpenCode plugin, skills, AGENTS.md, and global MCP config\nctx setup opencode --write\n</code></pre>","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":"<code>ctx site</code>","text":"<p>Site management commands for the ctx.ist static site.</p> <pre><code>ctx site <subcommand>\n</code></pre>","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/site/#ctx-site-feed","level":3,"title":"<code>ctx site feed</code>","text":"<p>Generate an Atom 1.0 feed from finalized blog posts in <code>docs/blog/</code>.</p> <pre><code>ctx site feed [flags]\n</code></pre> <p>Scans <code>docs/blog/</code> for files matching <code>YYYY-MM-DD-*.md</code>, parses YAML frontmatter, and generates a valid Atom feed. Only posts with <code>reviewed_and_finalized: true</code> are included. Summaries are extracted from the first paragraph after the heading.</p> <p>Flags:</p> Flag Short Type Default Description <code>--out</code> <code>-o</code> string <code>site/feed.xml</code> Output path <code>--base-url</code> string <code>https://ctx.ist</code> Base URL for entry links <p>Output:</p> <pre><code>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</code></pre> <p>Three buckets: included (count), skipped (with reason), warnings (included but degraded). <code>exit 0</code> always: warnings inform but do not block.</p> <p>Frontmatter requirements:</p> Field Required Feed mapping <code>title</code> Yes <code><title></code> <code>date</code> Yes <code><updated></code> <code>reviewed_and_finalized</code> Yes Draft gate (must be <code>true</code>) <code>author</code> No <code><author><name></code> <code>topics</code> No <code><category term=\"\"></code> <p>Examples:</p> <pre><code>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</code></pre>","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":"<code>ctx skill</code>","text":"<p>Manage reusable instruction bundles that can be installed into <code>.context/skills/</code>.</p> <p>A skill is a directory containing a <code>SKILL.md</code> file with YAML frontmatter (<code>name</code>, <code>description</code>) and a Markdown instruction body. Skills are loaded by the agent context packet when <code>--skill <name></code> is passed to <code>ctx agent</code>.</p> <pre><code>ctx skill <subcommand>\n</code></pre>","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-install","level":3,"title":"<code>ctx skill install</code>","text":"<p>Install a skill from a source directory.</p> <pre><code>ctx skill install <source>\n</code></pre> <p>Arguments:</p> <ul> <li><code>source</code>: Path to a directory containing <code>SKILL.md</code></li> </ul> <p>Examples:</p> <pre><code>ctx skill install ./my-skills/code-review\n# Installed code-review → .context/skills/code-review\n</code></pre>","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-list","level":3,"title":"<code>ctx skill list</code>","text":"<p>List all installed skills.</p> <p>Examples:</p> <pre><code>ctx skill list\n</code></pre>","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-remove","level":3,"title":"<code>ctx skill remove</code>","text":"<p>Remove an installed skill.</p> <p>Arguments:</p> <ul> <li><code>name</code>: Skill name to remove</li> </ul> <p>Examples:</p> <pre><code>ctx skill remove code-review\n</code></pre> <p>See also: Building Project Skills recipe.</p>","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":"<code>ctx steering</code>","text":"<p>Manage steering files: persistent behavioral rules for AI coding assistants.</p> <p>A steering file is a small Markdown document with YAML frontmatter that tells the AI how to behave in a specific context. <code>ctx steering</code> keeps those files in <code>.context/steering/</code>, decides which ones apply for a given prompt, and syncs them out to each AI tool's native format (Claude Code, Cursor, Kiro, Cline).</p> <pre><code>ctx steering <subcommand>\n</code></pre> <p>Steering vs Decisions vs Conventions</p> <p>The three look similar on disk but serve different purposes:</p> <ul> <li>Decisions record what was chosen and why. Consumed mostly by humans (and by the agent via <code>ctx agent</code>).</li> <li>Conventions describe how the codebase is written. Consumed as reference material.</li> <li>Steering tells the AI how to behave when asked about X. Consumed by the AI tool's prompt injection layer, conditionally on prompt match.</li> </ul> <p>If you find yourself writing \"the AI should always do X\", that belongs in steering, not decisions.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#anatomy-of-a-steering-file","level":3,"title":"Anatomy of a Steering File","text":"<pre><code>---\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</code></pre> <p>Inclusion modes:</p> Mode When it's included <code>always</code> Every prompt, unconditionally <code>auto</code> When the prompt matches the <code>description</code> keywords <code>manual</code> Only when the user names it explicitly <p>Priority: lower numbers inject first, so high-priority rules appear at the top of the prompt. Default is <code>50</code>.</p> <p>Tools: an empty list means all configured tools receive the file; list specific tool names to scope it.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-init","level":3,"title":"<code>ctx steering init</code>","text":"<p>Create a starter set of steering files in <code>.context/steering/</code> to use as a scaffolding baseline.</p> <p>Examples:</p> <pre><code>ctx steering init\n</code></pre>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-add","level":3,"title":"<code>ctx steering add</code>","text":"<p>Create a new steering file with default frontmatter.</p> <pre><code>ctx steering add <name>\n</code></pre> <p>Arguments:</p> <ul> <li><code>name</code>: Steering file name (without <code>.md</code> extension)</li> </ul> <p>Examples:</p> <pre><code>ctx steering add security\n# Created .context/steering/security.md\n</code></pre> <p>The generated file uses <code>inclusion: manual</code> and <code>priority: 50</code> by default. Edit the frontmatter to change behavior.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-list","level":3,"title":"<code>ctx steering list</code>","text":"<p>List all steering files with their inclusion mode, priority, and tool scoping.</p> <p>Examples:</p> <pre><code>ctx steering list\n</code></pre>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-preview","level":3,"title":"<code>ctx steering preview</code>","text":"<p>Preview which steering files would be included for a given prompt. Useful for validating <code>auto</code>-inclusion descriptions against realistic prompts.</p> <pre><code>ctx steering preview [prompt]\n</code></pre> <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-sync","level":3,"title":"<code>ctx steering sync</code>","text":"<p>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).</p> <p>Examples:</p> <pre><code>ctx steering sync\n</code></pre> <p>Which tools are sync targets?</p> Tool Sync target Mechanism Cursor <code>.cursor/rules/</code> Cursor reads the directory natively Cline <code>.clinerules/</code> Cline reads the directory natively Kiro <code>.kiro/steering/</code> Kiro reads the directory natively Claude Code (no-op) Delivered via hook + MCP (see next section) Codex (no-op) Same as Claude Code <p>For the three native-rules tools, <code>ctx steering sync</code> writes each matching steering file to the appropriate directory with tool-specific frontmatter transforms. Unchanged files are skipped (idempotent).</p>","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":"<p>Claude Code has no native \"steering files\" primitive, so <code>ctx steering sync</code> skips it entirely. Instead, steering reaches Claude through two non-sync channels, both activated by <code>ctx setup claude-code</code> (which installs the plugin):</p> <p>1. Automatic injection via the <code>PreToolUse</code> hook. The Claude Code plugin wires a <code>PreToolUse</code> hook that runs <code>ctx agent --budget 8000</code> before each tool call. <code>ctx agent</code> loads <code>.context/steering/</code> and calls <code>steering.Filter</code> with an empty prompt, so only files with <code>inclusion: always</code> 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.</p> <p>2. On-demand MCP tool call (<code>ctx_steering_get</code>). The <code>ctx</code> plugin ships a <code>.mcp.json</code> file that automatically registers the <code>ctx</code> MCP server (<code>ctx mcp serve</code>) with Claude Code on plugin install. Once registered, Claude can invoke the <code>ctx_steering_get</code> tool mid-task to fetch matching steering files for a specific prompt. This is the only path that resolves <code>inclusion: auto</code> and <code>inclusion: manual</code> matches for Claude Code; Claude passes the prompt to the MCP tool, which runs the keyword match against each file's description.</p> <p>Verify the MCP server is registered:</p> <pre><code>claude mcp list\n</code></pre> <p>Expected line: <code>ctx: ctx mcp serve - ✓ Connected</code>. If it's missing, reinstall the plugin from Claude Code (<code>/plugin</code> → find <code>ctx</code> → uninstall → install again); older plugin versions shipped without the <code>.mcp.json</code> file.</p> <p>Prefer <code>inclusion: always</code> for Claude Code</p> <p>Because the PreToolUse hook passes an empty prompt to <code>ctx agent</code>, only <code>always</code> files fire automatically. <code>auto</code> files require Claude to call the <code>ctx_steering_get</code> MCP tool on its own; <code>manual</code> files require an explicit user invocation. For rules that should reliably fire on every Claude Code session, use <code>inclusion: always</code>. Reserve <code>auto</code>/<code>manual</code> for situational libraries where the opt-in cost is acceptable and you understand Claude may not pull them in without prompting.</p> <p>The foundation files scaffolded by <code>ctx init</code> already default to <code>inclusion: always</code> for this reason.</p> <p>Practical implications:</p> <ul> <li>Running <code>ctx steering sync</code> before starting a Claude session does nothing for Claude's benefit. Skip it.</li> <li><code>ctx steering preview</code> still works for validating your descriptions; it doesn't depend on sync.</li> <li>If Claude Code is your only tool, the <code>ctx steering</code> commands you care about are <code>add</code>, <code>list</code>, <code>preview</code>, <code>init</code> (never <code>sync</code>).</li> <li>If you use both Claude Code and (say) Cursor, <code>ctx steering sync</code> covers Cursor (where <code>auto</code> and <code>manual</code> work natively) while the hook+MCP pipeline covers Claude Code. For rules you need to fire automatically on both, use <code>inclusion: always</code>.</li> </ul>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-agent-integration","level":3,"title":"<code>ctx agent</code> Integration","text":"<p>When <code>ctx agent</code> builds a context packet, steering files are loaded as Tier 6 of the budget-aware assembly (see <code>ctx agent</code>). Files with <code>inclusion: always</code> are always included; <code>auto</code> files are scored against the current prompt and included in priority order until the tier budget is exhausted.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx setup</code>: configure which tools receive steering syncs</li> <li><code>ctx trigger</code>: lifecycle scripts (a different hooking concept, see below)</li> <li>Building steering files recipe: walkthrough from first file to synced output</li> </ul>","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":"<code>ctx sysinfo</code>","text":"<p>Display a snapshot of system resources (memory, swap, disk, load) with threshold-based alert severities. Mirrors what the <code>check-resource</code> hook plumbing monitors in the background, but this command prints the full report at any severity level, not only at DANGER.</p> <pre><code>ctx sysinfo [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--json</code> Output in JSON format <p>Alert thresholds:</p> Resource WARNING DANGER Memory ≥ 75% ≥ 90% Swap ≥ 50% ≥ 75% Disk ≥ 85% ≥ 95% Load ≥ 1.0x CPUs ≥ 1.5x CPUs <p>Examples:</p> <pre><code>ctx sysinfo # Human-readable table\nctx sysinfo --json # Structured output\n</code></pre>","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":"<code>ctx system</code>","text":"<p>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 <code>ctx --help</code>; run <code>ctx system --help</code> to see its subcommands.</p> <pre><code>ctx system <subcommand>\n</code></pre> <p>Commands Previously under <code>ctx system</code></p> <p>Several user-facing maintenance commands used to live under <code>ctx system</code> and were promoted to top-level:</p> <ul> <li><code>ctx system events</code> → <code>ctx hook event</code></li> <li><code>ctx system message</code> → <code>ctx hook message</code></li> <li><code>ctx system prune</code> → <code>ctx prune</code></li> <li><code>ctx system resources</code> → <code>ctx sysinfo</code></li> <li><code>ctx system stats</code> → <code>ctx usage</code></li> </ul> <p><code>ctx system bootstrap</code> remains under <code>ctx system</code> as a hidden, agent-only command. Update any scripts or personal docs that reference the old paths.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#plumbing-subcommands","level":2,"title":"Plumbing Subcommands","text":"<p>These are not hook handlers; they're called by skills and editor integrations during the session lifecycle. Safe to run manually.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-journal","level":4,"title":"<code>ctx system mark-journal</code>","text":"<p>Update processing state for a journal entry. Records the current date in <code>.context/journal/.state.json</code>. Used by journal skills to record pipeline progress.</p> <pre><code>ctx system mark-journal <filename> <stage>\n</code></pre> <p>Stages: <code>exported</code>, <code>enriched</code>, <code>normalized</code>, <code>fences_verified</code></p> Flag Description <code>--check</code> Check if stage is set (exit 1 if not) <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-wrapped-up","level":4,"title":"<code>ctx system mark-wrapped-up</code>","text":"<p>Suppress context checkpoint nudges after a wrap-up ceremony. Writes a marker file that <code>check-context-size</code> checks before emitting checkpoint boxes. The marker expires after 2 hours.</p> <p>Called automatically by <code>/ctx-wrap-up</code> after persisting context (not intended for direct use).</p> <pre><code>ctx system mark-wrapped-up\n</code></pre> <p>No flags, no arguments. Idempotent: running it again updates the marker timestamp.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-pause-ctx-system-resume","level":4,"title":"<code>ctx system pause</code> / <code>ctx system resume</code>","text":"<p>Session-scoped hook suppression. <code>ctx system pause</code> writes a marker file that causes hook plumbing to no-op for the current session; <code>ctx system resume</code> removes it. These are the hook-plumbing counterparts to the <code>ctx hook pause</code> / <code>ctx hook resume</code> commands (which call them internally).</p> <p>Read the session ID from stdin JSON (same as hooks) or pass <code>--session-id</code>.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-session-event","level":4,"title":"<code>ctx system session-event</code>","text":"<p>Records a session lifecycle event (start or end) to the event log. Called by editor integrations when a workspace is opened or closed.</p> <pre><code>ctx system session-event --type start --caller vscode\nctx system session-event --type end --caller vscode\n</code></pre>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-statusline","level":4,"title":"<code>ctx system statusline</code>","text":"<p>Renders the Claude Code status line. Claude Code pipes a JSON payload to the configured statusLine command after each assistant message; this command turns it into one line:</p> <pre><code>user@host ~/project | Opus | ctx: 42% | $1.23\n</code></pre> <p><code>ctx init</code> wires it into <code>.claude/settings.local.json</code>, backing up any pre-existing statusLine entry to <code>.context/state/previous-statusline.json</code> (restored when <code>statusline.enabled: false</code> is set in <code>.ctxrc</code>; a statusLine that is not ctx's is never removed).</p> <p>Missing payload fields drop their segment. Output is sanitized to bounded printable ASCII, and the command always exits zero: a non-zero exit would blank the status line. The line is informational only; there is no cost gating and no model-switch nudging (see <code>specs/statusline.md</code> for the rationale).</p> <pre><code>ctx system statusline < payload.json\n</code></pre> <p>Config (<code>.ctxrc</code>): <code>statusline.enabled</code> (default <code>true</code>) and <code>statusline.show_cost</code> (render the <code>$</code> segment, default <code>true</code>; disable for screen-sharing or demos). Setting <code>enabled: false</code> blanks the rendered line immediately; the settings entry itself is restored/removed the next time the init merge runs.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#hook-subcommands","level":2,"title":"Hook Subcommands","text":"<p>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 <code>decision</code> field.</p> <p>UserPromptSubmit hooks: <code>context-load-gate</code>, <code>check-context-size</code>, <code>check-persistence</code>, <code>check-ceremony</code>, <code>check-journal</code>, <code>check-version</code>, <code>check-resource</code>, <code>check-knowledge</code>, <code>check-map-staleness</code>, <code>check-memory-drift</code>, <code>check-reminder</code>, <code>check-freshness</code>, <code>check-hub-sync</code>, <code>check-skill-discovery</code>, <code>heartbeat</code>.</p> <p>PreToolUse hooks: <code>block-non-path-ctx</code>, <code>block-dangerous-command</code>, <code>qa-reminder</code>, <code>specs-nudge</code>.</p> <p>PostToolUse hooks: <code>post-commit</code>, <code>check-task-completion</code>.</p> <p>See AI Tools for registration details and the Claude Code plugin integration.</p>","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":"<code>ctx trace</code>","text":"<p>Show the context behind git commits. Links commits back to the decisions, tasks, learnings, and sessions that motivated them.</p> <p><code>git log</code> shows what changed, <code>git blame</code> shows who, and <code>ctx trace</code> shows why.</p> <pre><code>ctx trace [commit] [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--last N</code> Show context for last N commits <code>--json</code> Output as JSON for scripting <p>Examples:</p> <pre><code># 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</code></pre> <p>Output:</p> <pre><code>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</code></pre> <p>When listing recent commits with <code>--last</code>:</p> <pre><code>abc123 Fix auth token expiry decision:12, task:8\ndef456 Add rate limiting decision:15, learning:7\n789abc Update dependencies (none)\n</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-file","level":3,"title":"<code>ctx trace file</code>","text":"<p>Show the context trail for a file. Combines <code>git log</code> with context resolution.</p> <pre><code>ctx trace file <path[:line-range]> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--last N</code> Maximum commits to show (default: 20) <p>Examples:</p> <pre><code># 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</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-tag","level":3,"title":"<code>ctx trace tag</code>","text":"<p>Manually tag a commit with context. For commits made without the hook, or to add extra context after the fact.</p> <p>Tags are stored in <code>.context/trace/overrides.jsonl</code> since git trailers cannot be added to existing commits without rewriting history.</p> <pre><code>ctx trace tag <commit> --note \"<text>\"\n</code></pre> <p>Examples:</p> <pre><code>ctx trace tag HEAD --note \"Hotfix for production outage\"\nctx trace tag abc123 --note \"Part of Q1 compliance initiative\"\n</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-hook","level":3,"title":"<code>ctx trace hook</code>","text":"<p>Enable or disable the prepare-commit-msg hook for automatic context tracing. When enabled, commits automatically receive a <code>ctx-context</code> trailer with references to relevant decisions, tasks, learnings, and sessions.</p> <pre><code>ctx trace hook <enable|disable>\n</code></pre> <p>Prerequisites: <code>ctx</code> must be on your <code>$PATH</code>. If you installed via <code>go install</code>, ensure <code>$GOPATH/bin</code> (or <code>$HOME/go/bin</code>) is in your shell's <code>$PATH</code>.</p> <p>What the hook does:</p> <ol> <li>Before each commit, collects context from three sources:</li> <li>Pending context accumulated during work (<code>ctx add</code>, <code>ctx task complete</code>)</li> <li>Staged file changes to <code>.context/</code> files</li> <li>Working state (in-progress tasks, active AI session)</li> <li>Injects a <code>ctx-context</code> trailer into the commit message</li> <li>After commit, records the mapping in <code>.context/trace/history.jsonl</code></li> </ol> <p>Examples:</p> <pre><code># Install the hook\nctx trace hook enable\n\n# Remove the hook\nctx trace hook disable\n</code></pre> <p>Resulting commit message:</p> <pre><code>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</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#reference-types","level":3,"title":"Reference Types","text":"<p>The <code>ctx-context</code> trailer supports these reference types:</p> Prefix Points to Example <code>decision:<n></code> Entry #n in DECISIONS.md <code>decision:12</code> <code>learning:<n></code> Entry #n in LEARNINGS.md <code>learning:5</code> <code>task:<n></code> Task #n in TASKS.md <code>task:8</code> <code>convention:<n></code> Entry #n in CONVENTIONS.md <code>convention:3</code> <code>session:<id></code> AI session by ID <code>session:abc123</code> <code>\"<text>\"</code> Free-form context note <code>\"Performance fix for P1 incident\"</code>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#storage","level":3,"title":"Storage","text":"<p>Context trace data is stored in the <code>.context/</code> directory:</p> File Purpose Lifecycle <code>state/pending-context.jsonl</code> Accumulates refs during work Truncated after each commit <code>trace/history.jsonl</code> Permanent commit-to-context map Append-only, never truncated <code>trace/overrides.jsonl</code> 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":"<code>ctx trigger</code>","text":"<p>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.</p> <pre><code>ctx trigger <subcommand>\n</code></pre> <p>Triggers Execute Arbitrary Scripts</p> <p>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.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#where-triggers-live","level":3,"title":"Where Triggers Live","text":"<p>Triggers live in <code>.context/hooks/<trigger-type>/</code> as executable scripts. The on-disk directory name is still <code>hooks/</code> for historical reasons even though the command is <code>ctx trigger</code>. Each script:</p> <ul> <li>Reads a JSON payload from stdin.</li> <li>Returns a JSON payload on stdout.</li> <li>Returns a non-zero exit code to block or error.</li> </ul> <pre><code>.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</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#trigger-types","level":3,"title":"Trigger Types","text":"Type Fires when <code>session-start</code> An AI session begins <code>session-end</code> An AI session ends <code>pre-tool-use</code> Before an AI tool call is executed <code>post-tool-use</code> After an AI tool call returns <code>file-save</code> When a file is saved <code>context-add</code> 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":"<p>Each trigger receives a JSON object on stdin with the event details. Minimal contract (fields vary by trigger type):</p> <pre><code>{\n \"type\": \"pre-tool-use\",\n \"tool\": \"write_file\",\n \"path\": \"src/auth.go\",\n \"session_id\": \"abc123-...\"\n}\n</code></pre> <p>The trigger may write a JSON object to stdout to influence behavior. Example for a blocking <code>pre-tool-use</code> trigger:</p> <pre><code>{\n \"action\": \"block\",\n \"message\": \"Editing src/auth.go requires approval from #security\"\n}\n</code></pre> <p>For non-blocking event loggers, simply read stdin and exit 0 without writing to stdout.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-add","level":3,"title":"<code>ctx trigger add</code>","text":"<p>Create a new trigger script with a template. The generated file has a bash shebang, a stdin reader using <code>jq</code>, and a basic JSON output structure.</p> <pre><code>ctx trigger add <trigger-type> <name>\n</code></pre> <p>Arguments:</p> <ul> <li><code>trigger-type</code>: One of <code>session-start</code>, <code>session-end</code>, <code>pre-tool-use</code>, <code>post-tool-use</code>, <code>file-save</code>, <code>context-add</code></li> <li><code>name</code>: Script name (without <code>.sh</code> extension)</li> </ul> <p>Examples:</p> <pre><code>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</code></pre> <p>The generated script is not executable by default. Enable it with <code>ctx trigger enable</code> after reviewing the contents.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-list","level":3,"title":"<code>ctx trigger list</code>","text":"<p>List all discovered triggers, grouped by trigger type, with their enabled/disabled status.</p> <p>Examples:</p> <pre><code>ctx trigger list\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-test","level":3,"title":"<code>ctx trigger test</code>","text":"<p>Run all enabled triggers of a given type against a mock payload. Use <code>--tool</code> and <code>--path</code> to customize the mock input for tool-related events.</p> <pre><code>ctx trigger test <trigger-type> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--tool</code> Tool name to put in mock input <code>--path</code> File path to put in mock input <p>Examples:</p> <pre><code>ctx trigger test session-start\nctx trigger test pre-tool-use --tool write_file --path src/main.go\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-enable","level":3,"title":"<code>ctx trigger enable</code>","text":"<p>Enable a trigger by setting its executable permission bit. Searches every trigger-type directory for a script matching <code><name></code>.</p> <pre><code>ctx trigger enable <name>\n</code></pre> <p>Examples:</p> <pre><code>ctx trigger enable inject-context\n# Enabled .context/hooks/session-start/inject-context.sh\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-disable","level":3,"title":"<code>ctx trigger disable</code>","text":"<p>Disable a trigger by clearing its executable permission bit. Searches every trigger-type directory for a script matching <code><name></code>.</p> <pre><code>ctx trigger disable <name>\n</code></pre> <p>Examples:</p> <pre><code>ctx trigger disable inject-context\n# Disabled .context/hooks/session-start/inject-context.sh\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#three-hooking-concepts-in-ctx-dont-confuse-them","level":3,"title":"Three Hooking Concepts in <code>ctx</code> (Don't Confuse Them)","text":"<p>This is a common source of confusion. <code>ctx</code> has three distinct hook-like layers, and they serve different purposes:</p> Layer Owned by Where it runs Configured via <code>ctx trigger</code> You <code>.context/hooks/<type>/*.sh</code> <code>ctx trigger add/enable</code> <code>ctx system</code> hooks <code>ctx</code> itself built-in, called by <code>ctx</code>'s own lifecycle internal (see <code>ctx system --help</code>) Claude Code hooks Claude Code <code>.claude/settings.local.json</code> edit JSON, or <code>/ctx-sanitize-permissions</code> <p>Use <code>ctx trigger</code> 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. <code>ctx system</code> hooks are not something you author; they're the internal nudge machinery that ships with ctx.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx steering</code>: persistent AI behavioral rules (a different concept; rules vs scripts)</li> <li>Authoring triggers recipe: a full walkthrough with security guidance</li> </ul>","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":"<code>ctx usage</code>","text":"<p>Display per-session token usage statistics from the local stats JSONL files written by the <code>heartbeat</code> hook. By default, shows the last 20 entries across all sessions. Use <code>--follow</code> to stream new entries as they arrive (like <code>tail -f</code>).</p> <pre><code>ctx usage [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>-f</code>, <code>--follow</code> Stream new entries as they arrive <code>-s</code>, <code>--session</code> Filter by session ID (prefix match) <code>-n</code>, <code>--last</code> Show last N entries (default: 20) <code>-j</code>, <code>--json</code> Output raw JSONL <p>Examples:</p> <pre><code>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</code></pre>","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":"<code>ctx watch</code>","text":"<p>Watch for AI output and auto-apply context updates.</p> <p>Parses <code><context-update></code> XML commands from AI output and applies them to context files.</p> <pre><code>ctx watch [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--log <file></code> Log file to watch (default: stdin) <code>--dry-run</code> Preview updates without applying <p>Examples:</p> <pre><code># 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</code></pre>","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":"<code>ctx why</code>","text":"<p>Read <code>ctx</code>'s philosophy documents directly in the terminal.</p> <pre><code>ctx why [DOCUMENT]\n</code></pre> <p>Documents:</p> Name Description <code>manifesto</code> The <code>ctx</code> Manifesto: creation, not code <code>about</code> About <code>ctx</code>: what it is and why it exists <code>invariants</code> Design invariants: properties that must hold <p>Examples:</p> <pre><code># 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</code></pre>","path":["CLI","Getting Started","Why"],"tags":[]},{"location":"home/","level":1,"title":"Home","text":"<ul> <li><code>ctx</code> is not a prompt.</li> <li><code>ctx</code> is version-controlled cognitive state.</li> </ul> <p><code>ctx</code> is the persistence layer for human-AI reasoning.</p> <p>Deterministic. Git-native. Human-readable. Local-first.</p> <p>Start here.</p> <p>Learn what <code>ctx</code> does, set it up, and run your first session.</p> <p>Pre-1.0: Moving Fast</p> <p><code>ctx</code> is under active development. This website tracks the development branch, not the latest release:</p> <p>Some features described here may not exist in the binary you have installed.</p> <p>Expect rough edges.</p> <p>If something is missing or broken, open an issue.</p>","path":["Home"],"tags":[]},{"location":"home/#introduction","level":2,"title":"Introduction","text":"","path":["Home"],"tags":[]},{"location":"home/#about","level":3,"title":"About","text":"<p>What <code>ctx</code> is, how it works, and why persistent context changes how you work with AI.</p>","path":["Home"],"tags":[]},{"location":"home/#is-it-right-for-me","level":3,"title":"Is It Right for Me?","text":"<p>Good fit, not-so-good fit, and a 5-minute trial to find out for yourself.</p>","path":["Home"],"tags":[]},{"location":"home/#faq","level":3,"title":"FAQ","text":"<p>Quick answers to the questions newcomers ask most about <code>ctx</code>, files, tooling, and trade-offs.</p>","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":"<p>Install the binary, set up the plugin, and verify it works.</p>","path":["Home"],"tags":[]},{"location":"home/#your-first-session","level":3,"title":"Your First Session","text":"<p>Step-by-step walkthrough from <code>ctx init</code> to verified recall.</p>","path":["Home"],"tags":[]},{"location":"home/#common-workflows","level":3,"title":"Common Workflows","text":"<p>Day-to-day commands for tracking context, checking health, and browsing history.</p>","path":["Home"],"tags":[]},{"location":"home/#concepts","level":2,"title":"Concepts","text":"","path":["Home"],"tags":[]},{"location":"home/#context-files","level":3,"title":"Context Files","text":"<p>What each <code>.context/</code> file does. What's their purpose. How do we best leverage them.</p>","path":["Home"],"tags":[]},{"location":"home/#configuration","level":3,"title":"Configuration","text":"<p>Flexible configuration: <code>.ctxrc</code>, environment variables, and CLI flags.</p>","path":["Home"],"tags":[]},{"location":"home/#hub","level":3,"title":"Hub","text":"<p>A fan-out channel for decisions, learnings, conventions, and tasks that need to cross project boundaries, without replicating everything else.</p>","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":"<p>Effective prompts for AI sessions with <code>ctx</code>.</p>","path":["Home"],"tags":[]},{"location":"home/#keeping-ai-honest","level":3,"title":"Keeping AI Honest","text":"<p>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.</p>","path":["Home"],"tags":[]},{"location":"home/#my-ai-keeps-making-the-same-mistakes","level":3,"title":"My AI Keeps Making the Same Mistakes","text":"<p>Stop rediscovering the same bugs and dead-ends across sessions.</p>","path":["Home"],"tags":[]},{"location":"home/#joining-a-project","level":3,"title":"Joining a Project","text":"<p>You inherited a <code>.context/</code> directory. Get oriented fast: priority order, what to read first, how to ramp up.</p>","path":["Home"],"tags":[]},{"location":"home/#customization","level":2,"title":"Customization","text":"","path":["Home"],"tags":[]},{"location":"home/#steering-files","level":3,"title":"Steering Files","text":"<p>Tell the assistant how to behave when a specific kind of prompt arrives.</p>","path":["Home"],"tags":[]},{"location":"home/#lifecycle-triggers","level":3,"title":"Lifecycle Triggers","text":"<p>Make things happen at session boundaries: block dangerous tool calls, inject standup notes, log file saves.</p>","path":["Home"],"tags":[]},{"location":"home/#community","level":2,"title":"Community","text":"","path":["Home"],"tags":[]},{"location":"home/#ctx","level":3,"title":"#<code>ctx</code>","text":"<p>We are the builders who care about durable context. Join the community. Hang out in IRC. Star <code>ctx</code> on GitHub.</p>","path":["Home"],"tags":[]},{"location":"home/#contributing","level":3,"title":"Contributing","text":"<p>Development setup, project layout, and pull request process.</p>","path":["Home"],"tags":[]},{"location":"home/about/","level":1,"title":"About","text":"<p>\"Creation, not code; Context, not prompts; Verification, not vibes.\"</p> <p>Read the <code>ctx</code> Manifesto →</p> <p>\"Without durable context, intelligence resets; with <code>ctx</code>, creation compounds.\"</p> <p>Without persistent memory, every session starts at zero; <code>ctx</code> makes sessions cumulative.</p> <p>Join the <code>ctx</code> Community →</p>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#what-is-ctx","level":2,"title":"What Is <code>ctx</code>?","text":"<p><code>ctx</code> (Context) is a file-based system that enables AI coding assistants to persist project knowledge across sessions. It lives in a <code>.context/</code> directory in your repo.</p> <ul> <li>A session is interactive.</li> <li><code>ctx</code> enables cognitive continuity.</li> <li>Cognitive continuity enables durable, symbiotic-like human-AI workflows.</li> </ul> <p>Context Files</p> <p>Context files let AI tools remember decisions, conventions, and learnings:</p> <p>Context files are explicit and versionable contracts between you and your agents.</p>","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":"<p>You open a new AI session. The first thing you do is re-explain your project.</p> <p>Again.</p> <p>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.</p> <ul> <li>You explain the same architecture every session;</li> <li>The AI suggests an approach you already rejected, again;</li> <li>A decision you made three sessions ago gets relitigated from scratch;</li> <li>You spend more time setting context than building features.</li> </ul> <p>This isn't AI failure: It is staleness. </p> <p>Without persistent memory, every session starts at zero.</p>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#day-and-night","level":3,"title":"Day and Night","text":"<p><code>ctx</code> gives your AI a memory that persists across sessions:</p> Without <code>ctx</code>With <code>ctx</code> <pre><code>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</code></pre> <pre><code>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</code></pre>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#how-ctx-solves-this","level":3,"title":"How <code>ctx</code> Solves This","text":"<p><code>ctx</code> creates a <code>.context/</code> directory in your project that stores structured knowledge files:</p> File What It Remembers <code>TASKS.md</code> What you're working on and what's next <code>DECISIONS.md</code> Architectural choices and why you made them <code>LEARNINGS.md</code> Gotchas, bugs, things that didn't work <code>CONVENTIONS.md</code> Naming patterns, code style, project rules <code>CONSTITUTION.md</code> Hard rules the AI must never violate <p>These files can version with your code in <code>git</code>: </p> <ul> <li>They load automatically at the session start (via hooks in Claude Code, or manually with <code>ctx agent</code> for other tools). </li> <li>The AI reads them, cites them, and builds on them, instead of asking you to start over. <ul> <li>And when it acts, it can point to the exact file and line that justifies the choice.</li> </ul> </li> </ul> <p>Every decision you record, every lesson you capture, makes the next session smarter.</p> <p><code>ctx</code> accumulates.</p> <p>Connect with <code>ctx</code></p> <ul> <li>Join the Community →: ask questions, share workflows, and help shape what comes next</li> <li>Read the Blog →: real-world patterns, ponderings, and lessons learned from building <code>ctx</code> using <code>ctx</code></li> </ul> <p>Ready to Get Started?</p> <ul> <li>Getting Started →: full installation and setup</li> <li>Your First Session →: step-by-step walkthrough from <code>ctx init</code> to verified recall</li> </ul>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/common-workflows/","level":1,"title":"Common Workflows","text":"<p>The commands below cover what you'll use most often: </p> <ul> <li>recording context, </li> <li>checking health, </li> <li>browsing history, </li> <li>and running loops.</li> </ul> <p>Each section is a self-contained snippet you can copy into your terminal.</p> <p>For deeper, step-by-step guides, see Recipes.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#track-context","level":2,"title":"Track Context","text":"<p>Prefer Skills over Raw Commands</p> <p>When working with an AI agent, use <code>/ctx-task-add</code>, <code>/ctx-decision-add</code>, or <code>/ctx-learning-add</code> instead of raw <code>ctx add</code> commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.</p> <pre><code># 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</code></pre>","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":"<p>Drop a note that surfaces automatically at the start of your next session:</p> <pre><code># 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</code></pre> <p>Reminders are relayed verbatim at session start by the <code>check-reminders</code> hook and repeat every session until you dismiss them.</p> <p>See Session Reminders for the full recipe.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#check-context-health","level":2,"title":"Check Context Health","text":"<pre><code># Detect stale paths, missing files, potential secrets\nctx drift\n\n# See full context summary\nctx status\n</code></pre>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#browse-session-history","level":2,"title":"Browse Session History","text":"<p>List and search past AI sessions from the terminal:</p> <pre><code>ctx journal source --limit 5\n</code></pre>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#journal-site","level":3,"title":"Journal Site","text":"<p>Import session transcripts to a browsable static site with search, navigation, and topic indices.</p> <p>The <code>ctx journal</code> command requires zensical (Python >= 3.10).</p> <p><code>zensical</code> is a Python-based static site generator from the Material for MkDocs team.</p> <p>(why zensical?).</p> <p>If you don't have it on your system, install <code>zensical</code> once with pipx:</p> <pre><code># One-time setup\npipx install zensical\n</code></pre> <p>Avoid <code>pip install zensical</code></p> <p><code>pip install</code> often fails: For example, on macOS, system Python installs a non-functional stub (<code>zensical</code> requires <code>Python >= 3.10</code>), and Homebrew Python blocks system-wide installs (<code>PEP 668</code>).</p> <p><code>pipx</code> creates an isolated environment with the correct Python version automatically.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#import-and-serve","level":3,"title":"Import and Serve","text":"<p>Then, import and serve:</p> <pre><code># Import to .context/journal/ (new sessions + any that have grown; self-healing)\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n</code></pre> <p>Open http://localhost:8000 to browse.</p> <p>To update after new sessions, run the same two commands again.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#self-healing-by-default","level":3,"title":"Self-Healing by Default","text":"<p><code>ctx journal import --all</code> is self-healing by default:</p> <ul> <li>It imports new sessions and completes any whose source transcript has grown since the last import, skipping only sessions whose source is unchanged. Hand-edited entries are detected and left untouched, never clobbered. See <code>ctx journal import</code> for details.</li> <li>Locked entries (via <code>ctx journal lock</code>) are always skipped by both import and enrichment skills.</li> <li>If you add <code>locked: true</code> to frontmatter during enrichment, run <code>ctx journal sync</code> to propagate the lock state to <code>.state.json</code>.</li> </ul>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#re-importing-existing-files","level":3,"title":"Re-Importing Existing Files","text":"<p>Here is how you regenerate existing files.</p> <p>Backup your <code>.context</code> folder before regeneration, as this is a potentially destructive action.</p> <p>To re-import journal files, you need to explicitly opt-in using the <code>--regenerate</code> flag:</p> Flag combination Frontmatter Body <code>--regenerate</code> Preserved Overwritten from source <code>--regenerate --keep-frontmatter=false</code> Overwritten Overwritten <p>Regeneration Overwrites Body Edits</p> <p><code>--regenerate</code> preserves your YAML frontmatter (tags, summary, enrichment metadata) but it replaces the Markdown body with a fresh import.</p> <p>Any manual edits you made to the transcript will be lost.</p> <p>Lock entries you want to protect first: <code>ctx journal lock <session-id></code>.</p> <p>See Session Journal for the full pipeline including normalization and enrichment.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#scratchpad","level":2,"title":"Scratchpad","text":"<p>Store short, sensitive one-liners in an encrypted scratchpad that travels with the project:</p> <pre><code># 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</code></pre> <p>The scratchpad is encrypted with a key stored at <code>~/.ctx/.ctx.key</code> (outside the project, never committed).</p> <p>See Scratchpad for details.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#run-an-autonomous-loop","level":2,"title":"Run an Autonomous Loop","text":"<p>Generate a script that iterates an AI agent until a completion signal is detected:</p> <pre><code>ctx loop\nchmod +x loop.sh\n./loop.sh\n</code></pre> <p>See Autonomous Loops for configuration and advanced usage.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#trace-commit-context","level":2,"title":"Trace Commit Context","text":"<p>Link your git commits back to the decisions, tasks, and learnings that motivated them. Enable the hook once:</p> <pre><code># Install the git hook (one-time setup)\nctx trace hook enable\n</code></pre> <p>From now on, every <code>git commit</code> automatically gets a <code>ctx-context</code> trailer linking it to relevant context. No extra steps needed; just use <code>ctx add</code>, <code>ctx task complete</code>, and commit as usual.</p> <pre><code># 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</code></pre> <p>To stop: <code>ctx trace hook disable</code>.</p> <p>See CLI Reference: trace for details.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#agent-session-start","level":2,"title":"Agent Session Start","text":"<p>The first thing an AI agent should do at session start is discover where context lives:</p> <pre><code>ctx system bootstrap\n</code></pre> <p>This prints the resolved context directory, the files in it, and the operating rules. The <code>CLAUDE.md</code> template instructs the agent to run this automatically. See CLI Reference: bootstrap.</p>","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":"<p>Using <code>/ctx-remember</code> at session start and <code>/ctx-wrap-up</code> at session end are the highest-value skills in the entire catalog:</p> <pre><code># session begins:\n/ctx-remember\n... do work ...\n# before closing the session:\n/ctx-wrap-up\n</code></pre> <p>Let's provide some context, because this is important:</p> <p>Although the agent will eventually discover your context through <code>CLAUDE.md → AGENT_PLAYBOOK.md</code>, <code>/ctx-remember</code> hydrates the full context up front (tasks, decisions, recent sessions) so the agent starts informed rather than piecing things together over several turns.</p> <p><code>/ctx-wrap-up</code> is the other half: A structured review that captures learnings, decisions, and tasks before you close the window.</p> <p>Hooks like <code>check-persistence</code> 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 <code>CTRL+C</code> can end things at any moment with no reliable \"before session end\" event. </p> <p>In short, <code>/ctx-wrap-up</code> is the deliberate checkpoint that makes sure nothing slips through. And <code>/ctx-remember</code> it its mirror skill to be used at session start.</p> <p>See Session Ceremonies for the full workflow.</p>","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":"<p>Most <code>ctx</code> 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.</p> <p>Commands and skills are not interchangeable: Each has a distinct role.</p> <code>ctx</code> CLI command <code>ctx</code> 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":"<p>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.</p> CLI Skill When to prefer the skill <code>ctx drift</code> <code>/ctx-drift</code> Semantic analysis: catches meaning drift the CLI misses <code>ctx status</code> <code>/ctx-status</code> Interpreted summary with recommendations <code>ctx task add</code> <code>/ctx-task-add</code> Agent decomposes vague goals into concrete tasks <code>ctx decision add</code> <code>/ctx-decision-add</code> Agent drafts rationale and consequences from discussion <code>ctx learning add</code> <code>/ctx-learning-add</code> Agent extracts the lesson from a debugging session <code>ctx convention add</code> <code>/ctx-convention-add</code> Agent observes a repeated pattern and codifies it <code>ctx task archive</code> <code>/ctx-archive</code> Agent reviews which tasks are truly done <code>ctx pad</code> <code>/ctx-pad</code> Agent reads/writes scratchpad entries in conversation flow <code>ctx journal</code> <code>/ctx-history</code> Agent searches session history with semantic understanding <code>ctx agent</code> <code>/ctx-agent</code> Agent loads and acts on the context packet <code>ctx loop</code> <code>/ctx-loop</code> Agent tailors the loop script to your project <code>ctx doctor</code> <code>/ctx-doctor</code> Agent adds semantic analysis to structural checks <code>ctx hook pause</code> <code>/ctx-pause</code> Agent pauses hooks with session-aware reasoning <code>ctx hook resume</code> <code>/ctx-resume</code> Agent resumes hooks after a pause <code>ctx remind</code> <code>/ctx-remind</code> 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":"<p>These have no CLI equivalent. They require the agent's reasoning.</p> Skill Purpose <code>/ctx-remember</code> Load context and present structured readback at session start <code>/ctx-wrap-up</code> End-of-session ceremony: persist learnings, decisions, tasks <code>/ctx-next</code> Suggest 1-3 concrete next actions from context <code>/ctx-commit</code> Commit with integrated context capture <code>/ctx-reflect</code> Pause and assess session progress <code>/ctx-consolidate</code> Merge overlapping learnings or decisions <code>/ctx-prompt-audit</code> Analyze prompting patterns for improvement <code>/ctx-plan</code> Stress-test an existing plan through adversarial interview <code>/ctx-plan-import</code> Import Claude Code plan files into project specs <code>/ctx-task-out</code> Decompose a committed spec into a per-milestone implementation plan <code>/ctx-implement</code> Execute a plan step-by-step with verification <code>/ctx-worktree</code> Manage parallel agent worktrees <code>/ctx-journal-enrich</code> Add metadata, tags, and summaries to journal entries <code>/ctx-journal-enrich-all</code> Full journal pipeline: export if needed, then batch-enrich <code>/ctx-blog</code> Generate a blog post (zensical-flavored Markdown) <code>/ctx-blog-changelog</code> Generate themed blog post from commits between releases <code>/ctx-architecture</code> 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":"<p>These are infrastructure: used in scripts, CI, or one-time setup.</p> Command Purpose <code>ctx init</code> Initialize <code>.context/</code> directory <code>ctx load</code> Output assembled context for piping <code>ctx task complete</code> Mark a task done by substring match <code>ctx sync</code> Reconcile context with codebase state <code>ctx compact</code> Consolidate and clean up context files <code>ctx trace</code> Show context behind git commits <code>ctx trace hook</code> Enable/disable commit context tracing hook <code>ctx setup</code> Generate AI tool integration config <code>ctx watch</code> Watch AI output and auto-apply context updates <code>ctx serve</code> Serve any zensical directory (default: journal) <code>ctx permission snapshot</code> Save settings as a golden image <code>ctx permission restore</code> Restore settings from golden image <code>ctx journal site</code> Generate browsable journal from exports <code>ctx hook notify setup</code> Configure webhook notifications <code>ctx decision</code> List and filter decisions <code>ctx learning</code> List and filter learnings <code>ctx task</code> List tasks, manage archival and snapshots <code>ctx why</code> Read the philosophy behind <code>ctx</code> <code>ctx guide</code> Quick-reference cheat sheet <code>ctx site</code> Site management commands <code>ctx config</code> Manage runtime configuration profiles <code>ctx system</code> System diagnostics and hook commands <code>ctx completion</code> Generate shell autocompletion scripts <p>Rule of Thumb</p> <p>Quick check? Use the CLI. </p> <p>Need judgment? Use the skill.</p> <p>When in doubt, start with the CLI: It's free and instant.</p> <p>Escalate to the skill when heuristics aren't enough.</p> <p>Next Up: Context Files →: what each <code>.context/</code> file does and how to use it</p> <p>See Also:</p> <ul> <li>Recipes: targeted how-to guides for specific tasks</li> <li>Knowledge Capture: patterns for recording decisions, learnings, and conventions</li> <li>Context Health: keeping your <code>.context/</code> accurate and drift-free</li> <li>Session Archaeology: digging into past sessions</li> <li>Task Management: tracking and completing work items</li> </ul>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/community/","level":1,"title":"#ctx","text":"<p>Open source is better together.</p> <p>We are the builders who care about durable context, verifiable decisions, and human-AI workflows that compound over time.</p>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#help-ctx-change-how-ai-remembers","level":2,"title":"Help <code>ctx</code> Change How AI Remembers","text":"<p>If you like the idea, a star helps <code>ctx</code> reach engineers who run into context drift every day:</p> <p> Star <code>ctx</code> on GitHub ⭐</p>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#ctx-you","level":2,"title":"<code>ctx</code> ♥️ You","text":"<p>Join the community to ask questions, share feedback, and connect with other users:</p> <ul> <li> Discord join the <code>ctx</code> Discord: Real-time discussion, field notes, and early ideas.</li> <li> Read the <code>ctx</code> Source on GitHub: Issues, discussions, and contributions.</li> </ul>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#want-to-contribute","level":2,"title":"Want to Contribute?","text":"<p>Early adopters shape the conventions.</p> <p><code>ctx</code> is free and open source software.</p> <p>Contributions are always welcome and appreciated.</p>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#code-of-conduct","level":2,"title":"Code of Conduct","text":"<p>Clear context requires respectful collaboration. </p> <p><code>ctx</code> follows the Contributor Covenant.</p>","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":"<p><code>ctx</code> uses three layers of configuration. Each layer overrides the one below it:</p> <ol> <li>CLI flags: Per-invocation overrides (highest priority)</li> <li>Environment variables: Shell or CI/CD overrides</li> <li>The <code>.ctxrc</code> file: Project-level defaults (YAML)</li> <li>Built-in defaults: Hardcoded fallbacks (lowest priority)</li> </ol> <p>All settings are optional: If nothing is configured, <code>ctx</code> works out of the box with sensible defaults.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#the-ctxrc-file","level":2,"title":"The <code>.ctxrc</code> File","text":"<p>The <code>.ctxrc</code> file is an optional YAML file placed in the project root (next to your <code>.context/</code> directory). It lets you set project-level defaults that apply to every <code>ctx</code> command.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#location","level":3,"title":"Location","text":"<pre><code>my-project/\n├── .ctxrc ← configuration file\n├── .context/\n│ ├── TASKS.md\n│ ├── DECISIONS.md\n│ └── ...\n└── src/\n</code></pre> <p><code>ctx</code> reads <code>.ctxrc</code> from the current working directory (the project root, sibling of <code>.context/</code>). It does not walk up. <code>ctx</code> commands must be run from the project root; subdirectories are not supported by design (see Getting Started). There is no global or user-level config file: configuration is always per-project.</p> <p>Contributors: Dev Configuration Profile</p> <p>The <code>ctx</code> repo ships two <code>.ctxrc</code> source profiles (<code>.ctxrc.base</code> and <code>.ctxrc.dev</code>). The working copy is gitignored and swapped between them via <code>ctx config switch dev</code> / <code>ctx config switch base</code>. See Contributing: Configuration Profiles.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#full-reference","level":3,"title":"Full Reference","text":"<p>A commented <code>.ctxrc</code> showing all options and their defaults:</p> <pre><code># .ctxrc: ctx runtime configuration\n# https://ctx.ist/home/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# auto_prune_days: 7 # days before stale session-state files are pruned on load (0/negative = default)\n# agent_cooldown_minutes: 10 # minutes between repeated `ctx agent` emissions (0 = disable the cooldown)\n# task_budget_pct: 0.40 # fraction of the `ctx agent` token budget for tasks (0-1; 0 = none)\n# convention_budget_pct: 0.20 # fraction of the `ctx agent` token budget for conventions (0-1; 0 = none)\n# title_slug_max_len: 50 # max characters in title-derived journal filename slugs (0/negative = default)\n# recall_list_limit: 20 # default `ctx journal source` list size when --limit is omitted (0/negative = default)\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# statusline: # Claude Code status line (informational only)\n# enabled: true # Deploy statusLine via ctx init\n# show_cost: true # Render the $ session-cost segment\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</code></pre>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#option-reference","level":3,"title":"Option Reference","text":"Option Type Default Description <code>token_budget</code> <code>int</code> <code>8000</code> Default token budget for <code>ctx agent</code> and <code>ctx load</code> <code>auto_archive</code> <code>bool</code> <code>true</code> Auto-archive completed tasks during <code>ctx compact</code> <code>archive_after_days</code> <code>int</code> <code>7</code> Days before completed tasks are archived <code>scratchpad_encrypt</code> <code>bool</code> <code>true</code> Encrypt scratchpad with AES-256-GCM <code>event_log</code> <code>bool</code> <code>false</code> Enable local hook event logging to <code>.context/state/events.jsonl</code> <code>entry_count_learnings</code> <code>int</code> <code>30</code> Drift warning when <code>LEARNINGS.md</code> exceeds this entry count (0 = disable) <code>entry_count_decisions</code> <code>int</code> <code>20</code> Drift warning when <code>DECISIONS.md</code> exceeds this entry count (0 = disable) <code>convention_line_count</code> <code>int</code> <code>200</code> Drift warning when <code>CONVENTIONS.md</code> exceeds this line count (0 = disable) <code>injection_token_warn</code> <code>int</code> <code>15000</code> Warn when auto-injected context exceeds this token count (0 = disable) <code>context_window</code> <code>int</code> <code>200000</code> Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools <code>billing_token_warn</code> <code>int</code> <code>0</code> (off) One-shot warning when session tokens exceed this threshold (0 = disabled). For plans where tokens beyond an included allowance cost extra <code>stale_age_days</code> <code>int</code> <code>30</code> Days before <code>ctx drift</code> flags a context file as stale (0 = disable) <code>key_rotation_days</code> <code>int</code> <code>90</code> Days before encryption key rotation nudge <code>task_nudge_interval</code> <code>int</code> <code>5</code> Edit/Write calls between task completion nudges <code>notify.events</code> <code>[]string</code> (all) Event filter for webhook notifications (empty = all) <code>priority_order</code> <code>[]string</code> (see below) Custom file loading priority for context assembly <code>tool</code> <code>string</code> (empty) Active AI tool identifier (<code>claude</code>, <code>cursor</code>, <code>cline</code>, <code>kiro</code>, <code>codex</code>). Used by steering sync and hook dispatch <code>steering.dir</code> <code>string</code> <code>.context/steering</code> Steering files directory <code>steering.default_inclusion</code> <code>string</code> <code>manual</code> Default inclusion mode for new steering files (<code>always</code>, <code>auto</code>, <code>manual</code>) <code>steering.default_tools</code> <code>[]string</code> (all) Default tool filter for new steering files (empty = all tools) <code>hooks.dir</code> <code>string</code> <code>.context/hooks</code> Hook scripts directory <code>hooks.timeout</code> <code>int</code> <code>10</code> Per-hook execution timeout in seconds <code>hooks.enabled</code> <code>bool</code> <code>true</code> Whether hook execution is enabled <code>statusline.enabled</code> <code>bool</code> <code>true</code> Whether <code>ctx init</code> deploys the Claude Code status line (<code>ctx system statusline</code>) <code>statusline.show_cost</code> <code>bool</code> <code>true</code> Whether the status line renders the session-cost (<code>$</code>) segment <code>provenance_required.session_id</code> <code>bool</code> <code>true</code> Require <code>--session-id</code> on <code>ctx add</code> for tasks, decisions, learnings <code>provenance_required.branch</code> <code>bool</code> <code>true</code> Require <code>--branch</code> on <code>ctx add</code> for tasks, decisions, learnings <code>provenance_required.commit</code> <code>bool</code> <code>true</code> Require <code>--commit</code> on <code>ctx add</code> for tasks, decisions, learnings <code>auto_prune_days</code> <code>int</code> <code>7</code> Days before stale session-state files are auto-pruned on context load. Non-positive values fall back to the default (never prunes on <code>0</code> or negative) <code>agent_cooldown_minutes</code> <code>int</code> <code>10</code> Minutes between repeated <code>ctx agent</code> context-packet emissions. An explicit <code>0</code> disables the cooldown (matches <code>--cooldown 0</code>); unset uses the default <code>task_budget_pct</code> <code>number</code> <code>0.40</code> Fraction of the <code>ctx agent</code> token budget reserved for tasks (clamped to <code>0</code>–<code>1</code>; explicit <code>0</code> allocates none; unset uses the default) <code>convention_budget_pct</code> <code>number</code> <code>0.20</code> Fraction of the <code>ctx agent</code> token budget reserved for conventions (clamped to <code>0</code>–<code>1</code>; explicit <code>0</code> allocates none; unset uses the default) <code>title_slug_max_len</code> <code>int</code> <code>50</code> Maximum characters in title-derived journal filename slugs. Non-positive values fall back to the default <code>recall_list_limit</code> <code>int</code> <code>20</code> Default number of sessions <code>ctx journal source</code> lists when <code>--limit</code> is omitted. Non-positive values fall back to the default <p>Default priority order (used when <code>priority_order</code> is not set):</p> <ol> <li><code>CONSTITUTION.md</code></li> <li><code>TASKS.md</code></li> <li><code>CONVENTIONS.md</code></li> <li><code>ARCHITECTURE.md</code></li> <li><code>DECISIONS.md</code></li> <li><code>LEARNINGS.md</code></li> <li><code>GLOSSARY.md</code></li> <li><code>AGENT_PLAYBOOK.md</code></li> </ol> <p>See Context Files for the rationale behind this ordering.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#environment-variables","level":2,"title":"Environment Variables","text":"<p>Environment variables override <code>.ctxrc</code> values but are overridden by CLI flags.</p> Variable Description Equivalent <code>.ctxrc</code> key <code>CTX_TOKEN_BUDGET</code> Override the default token budget <code>token_budget</code>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples","level":3,"title":"Examples","text":"<pre><code># Increase token budget for a single run\nCTX_TOKEN_BUDGET=16000 ctx agent\n</code></pre>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#cli-global-flags","level":2,"title":"CLI Global Flags","text":"<p>CLI flags have the highest priority and override both environment variables and <code>.ctxrc</code> settings. These flags are available on every <code>ctx</code> command.</p> Flag Description <code>--tool <name></code> Override active AI tool identifier (e.g. <code>kiro</code>, <code>cursor</code>) <code>--version</code> Show version and exit <code>--help</code> Show command help and exit","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#priority-order","level":2,"title":"Priority Order","text":"<p>When the same setting is configured in multiple layers, the highest-priority layer wins:</p> <pre><code>CLI flags > Environment variables > .ctxrc > Built-in defaults\n(highest) (lowest)\n</code></pre> <p>The context directory itself is resolved differently: it lives outside this priority chain. <code>ctx</code> always reads <code>$PWD/.context/</code>; if that path does not exist, the command refuses with a clear error.</p> <p>Example resolution for <code>token_budget</code>:</p> Layer Value Wins? <code>CTX_TOKEN_BUDGET</code> <code>4000</code> Yes <code>.ctxrc</code> <code>8000</code> No Default <code>8000</code> No","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples_1","level":2,"title":"Examples","text":"","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-token-budget","level":3,"title":"Custom Token Budget","text":"<p>Increase the token budget for projects with large context:</p> <pre><code># .ctxrc\ntoken_budget: 16000\n</code></pre> <p>This affects the default budget for <code>ctx agent</code> and <code>ctx load</code>. You can still override per-invocation with <code>ctx agent --budget 4000</code>.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#disabled-scratchpad-encryption","level":3,"title":"Disabled Scratchpad Encryption","text":"<p>Turn off encryption for the scratchpad (useful in ephemeral environments where key management is unnecessary):</p> <pre><code># .ctxrc\nscratchpad_encrypt: false\n</code></pre> <p>Unencrypted Scratchpads Store Secrets in Plaintext</p> <p>Only disable encryption if you understand the security implications.</p> <p>The scratchpad may contain sensitive data such as API keys, database URLs, or deployment credentials.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-priority-order","level":3,"title":"Custom Priority Order","text":"<p>Reorder context files to prioritize architecture over conventions:</p> <pre><code># .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</code></pre> <p>Files not listed in <code>priority_order</code> receive the lowest priority (100). The order affects <code>ctx agent</code>, <code>ctx load</code>, and drift's file-priority calculations.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#billing-token-threshold","level":3,"title":"Billing Token Threshold","text":"<p>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):</p> <pre><code># .ctxrc\nbilling_token_warn: 180000 # warn before hitting the 200k paid boundary\n</code></pre> <p>The warning fires once per session the first time token usage exceeds the threshold. Set to <code>0</code> (or omit) to disable.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#adjusted-drift-thresholds","level":3,"title":"Adjusted Drift Thresholds","text":"<p>Raise or lower the entry-count thresholds that trigger drift warnings:</p> <pre><code># .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</code></pre> <p>Set any threshold to <code>0</code> to disable that specific check.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"<p>Get notified when loops complete, hooks fire, or agents reach milestones:</p> <pre><code># Configure the webhook URL (encrypted, safe to commit)\nctx hook notify setup\n\n# Test delivery\nctx hook notify test\n</code></pre> <p>Filter which events reach your webhook:</p> <pre><code># .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</code></pre> <p>Notifications are opt-in: No events are sent unless explicitly listed.</p> <p>See Webhook Notifications for a step-by-step recipe.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#hook-message-overrides","level":2,"title":"Hook Message Overrides","text":"<p>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 <code>.context/</code>:</p> <pre><code>.context/hooks/messages/{hook}/{variant}.txt\n</code></pre> <p>The override takes priority over the embedded default compiled into the <code>ctx</code> binary. An empty file silences the message while preserving the hook's logic (counting, state tracking, cooldowns).</p> <p>Use <code>ctx hook message</code> to discover and manage overrides:</p> <pre><code>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</code></pre> <p>See Customizing Hook Messages for detailed examples including Python, JavaScript, and silence configurations.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#agent-bootstrapping","level":2,"title":"Agent Bootstrapping","text":"<p>AI agents need to know the resolved context directory at session start. The <code>ctx system bootstrap</code> command prints the context path, file list, and operating rules in both text and JSON formats:</p> <pre><code>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</code></pre> <p>The <code>CLAUDE.md</code> template instructs the agent to run this as its first action. Every nudge (context checkpoint, persistence reminder, etc.) also includes a <code>Context: <dir></code> footer that re-anchors the agent to the correct directory throughout the session.</p> <p>This replaces the previous approach of hardcoding <code>.context/</code> paths in agent instructions. </p> <p>See CLI Reference: bootstrap for full details.</p> <p>See also: CLI Reference | Context Files | Scratchpad</p>","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":"<code>.context/</code>","text":"<p>Each context file in <code>.context/</code> serves a specific purpose. </p> <p>Files are designed to be human-readable, AI-parseable, and token-efficient.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#file-overview","level":2,"title":"File Overview","text":"<p>The core context files live directly under <code>.context/</code>. They are the substrate <code>ctx</code> reads in priority order when assembling the agent context packet:</p> File Purpose Priority <code>CONSTITUTION.md</code> Hard rules that must NEVER be violated 1 (highest) <code>TASKS.md</code> Current and planned work 2 <code>CONVENTIONS.md</code> Project patterns and standards 3 <code>ARCHITECTURE.md</code> System overview and components 4 <code>DECISIONS.md</code> Architectural decisions with rationale 5 <code>LEARNINGS.md</code> Lessons learned, gotchas, tips 6 <code>GLOSSARY.md</code> Domain terms and abbreviations 7 <code>AGENT_PLAYBOOK.md</code> Instructions for AI tools 8 (lowest) <p>Two subdirectories under <code>.context/</code> are implementation details that are user-editable but not part of the priority read order:</p> <ul> <li><code>.context/templates/</code>: format templates for <code>ctx decision add</code> and <code>ctx learning add</code>. See templates below.</li> <li><code>.context/steering/</code>: 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.</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#outside-context","level":3,"title":"Outside <code>.context/</code>","text":"<p>Two other moving parts are often confused with context files but are not under <code>.context/</code>:</p> <ul> <li>Skills live in <code>.claude/skills/</code> (project-local) or are provided by the installed <code>ctx</code> 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 <code>ctx skill</code> and Skills reference.</li> <li>Hooks: Claude Code <code>PreToolUse</code>/<code>PostToolUse</code>/ <code>UserPromptSubmit</code> entries configured in <code>.claude/settings.json</code> or shipped by a plugin. The <code>ctx</code> 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.</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#read-order-rationale","level":2,"title":"Read Order Rationale","text":"<p>The priority order follows a logical progression for AI tools:</p> <ol> <li><code>CONSTITUTION.md</code>: Inviolable rules first. The AI tool must know what it cannot do before attempting anything.</li> <li><code>TASKS.md</code>: Current work items. What the AI tool should focus on.</li> <li><code>CONVENTIONS.md</code>: How to write code. Patterns and standards to follow when implementing tasks.</li> <li><code>ARCHITECTURE.md</code>: System structure. Understanding of components and boundaries before making changes.</li> <li><code>DECISIONS.md</code>: Historical context. Why things are the way they are, to avoid re-debating settled decisions.</li> <li><code>LEARNINGS.md</code>: Gotchas and tips. Lessons from past work that inform the current implementation.</li> <li><code>GLOSSARY.md</code>: Reference material. Domain terms and abbreviations for lookup as needed.</li> <li><code>AGENT_PLAYBOOK.md</code>: 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.</li> </ol>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#constitutionmd","level":2,"title":"<code>CONSTITUTION.md</code>","text":"<p>Purpose: Define hard invariants: Rules that must NEVER be violated, regardless of the task.</p> <p>AI tools read this first and should refuse tasks that violate these rules.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines","level":3,"title":"Guidelines","text":"<ul> <li>Keep rules minimal and absolute</li> <li>Each rule should be enforceable (can verify compliance)</li> <li>Use checkbox format for clarity</li> <li>Never compromise on these rules</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tasksmd","level":2,"title":"<code>TASKS.md</code>","text":"<p>Purpose: Track current work, planned work, and blockers.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_1","level":3,"title":"Structure","text":"<p>Tasks are organized by Phase: logical groupings that preserve order and enable replay. </p> <p>Tasks stay in their Phase permanently; status is tracked via checkboxes and inline tags.</p> <pre><code># 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</code></pre> <p>Key principles:</p> <ul> <li>Tasks never move between sections: mark as <code>[x]</code> or <code>[-]</code> in place</li> <li>Use <code>#in-progress</code> inline tag to indicate current work</li> <li>Phase headers provide structure and replay order</li> <li>Backlog section for unscheduled work</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tags","level":3,"title":"Tags","text":"<p>Use inline backtick-wrapped tags for metadata:</p> Tag Values Purpose <code>#priority</code> <code>high</code>, <code>medium</code>, <code>low</code> Task urgency <code>#area</code> <code>core</code>, <code>cli</code>, <code>docs</code>, <code>tests</code> Codebase area <code>#estimate</code> <code>1h</code>, <code>4h</code>, <code>1d</code> Time estimate (optional) <code>#in-progress</code> (none) Currently being worked on <p>Lifecycle tags (for session correlation):</p> Tag Format When to add <code>#added</code> <code>YYYY-MM-DD-HHMMSS</code> Auto-added by <code>ctx task add</code> <code>#started</code> <code>YYYY-MM-DD-HHMMSS</code> When beginning work on the task <p>These timestamps help correlate tasks with session files and track which session started vs completed work.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#status-markers","level":3,"title":"Status Markers","text":"Marker Meaning <code>[ ]</code> Pending <code>[x]</code> Completed <code>[-]</code> Skipped (include reason)","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_1","level":3,"title":"Guidelines","text":"<ul> <li>Never delete tasks; mark as <code>[x]</code> completed or <code>[-]</code> skipped</li> <li>Never move tasks between sections; use inline tags for status</li> <li>Use <code>ctx task archive</code> periodically to move completed tasks to archive</li> <li>Mark current work with <code>#in-progress</code> inline tag</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#decisionsmd","level":2,"title":"<code>DECISIONS.md</code>","text":"<p>Purpose: Record architectural decisions with rationale so they don't get re-debated.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_2","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example","level":3,"title":"Example","text":"<pre><code>## [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</code></pre>","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":"<code>LEARNINGS.md</code>","text":"<p>Purpose: Capture lessons learned, gotchas, and tips that shouldn't be forgotten.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_3","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example_1","level":3,"title":"Example","text":"<pre><code>## 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#categories","level":3,"title":"Categories","text":"<p>Organize learnings by topic:</p> <ul> <li>Testing</li> <li>Build & Deploy</li> <li>Performance</li> <li>Security</li> <li>Third-Party Libraries</li> <li>Git and Workflow</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#conventionsmd","level":2,"title":"<code>CONVENTIONS.md</code>","text":"<p>Purpose: Document project patterns, naming conventions, and standards.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_4","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_2","level":3,"title":"Guidelines","text":"<ul> <li>Include concrete examples</li> <li>Explain the \"why\" not just the \"what\"</li> <li>Keep patterns minimal: Only document what's non-obvious</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#architecturemd","level":2,"title":"<code>ARCHITECTURE.md</code>","text":"<p>Purpose: Provide system overview and component relationships.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_5","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_3","level":3,"title":"Guidelines","text":"<ul> <li>Keep diagrams simple (Mermaid works well)</li> <li>Focus on boundaries and interfaces</li> <li>Update when major structural changes occur</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#glossarymd","level":2,"title":"<code>GLOSSARY.md</code>","text":"<p>Purpose: Define domain terms, abbreviations, and project vocabulary.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_6","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_4","level":3,"title":"Guidelines","text":"<ul> <li>Define project-specific meanings</li> <li>Clarify potentially ambiguous terms</li> <li>Include abbreviations used in code or docs</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#agent_playbookmd","level":2,"title":"<code>AGENT_PLAYBOOK.md</code>","text":"<p>Purpose: Explicit instructions for how AI tools should read, apply, and update context.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#key-sections","level":3,"title":"Key Sections","text":"<p>Read Order: Priority order for loading context files</p> <p>When to Update: Events that trigger context updates</p> <p>How to Avoid Hallucinating Memory: Critical rules:</p> <ol> <li>Never assume: If not in files, you don't know it</li> <li>Never invent history: Don't claim \"we discussed\" without evidence</li> <li>Verify before referencing: Search files before citing</li> <li>When uncertain, say so</li> <li>Trust files over intuition</li> </ol> <p>Context Update Commands: Format for automated updates via <code>ctx watch</code>:</p> <pre><code><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</code></pre> <p>See Integrations for full documentation.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#templates","level":2,"title":"<code>templates/</code>","text":"<p>Location: <code>.context/templates/</code>. Status: implementation detail, user-editable.</p> <p>Purpose: Format templates for <code>ctx decision add</code> and <code>ctx learning add</code>. These control the structure of new entries appended to DECISIONS.md and LEARNINGS.md.</p> <p><code>ctx init</code> deploys two starter templates:</p> <ul> <li><code>decision.md</code>: sections Context, Rationale, Consequence</li> <li><code>learning.md</code>: sections Context, Lesson, Application</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing","level":3,"title":"Customizing","text":"<p>Edit the templates directly. Changes take effect immediately on the next <code>ctx add</code> command. For example, to add a \"References\" section to all new decisions, edit <code>.context/templates/decision.md</code>.</p> <p>Templates are committed to git, so customizations are shared with the team.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#steering","level":2,"title":"<code>steering/</code>","text":"<p>Location: <code>.context/steering/</code>. Status: implementation detail, user-editable.</p> <p>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). <code>ctx</code> matches steering files to prompts and syncs them out to each tool's config.</p> <p><code>ctx init</code> scaffolds four foundation files:</p> <ul> <li><code>product.md</code>: who this project serves and why</li> <li><code>tech.md</code>: the technology stack and its constraints</li> <li><code>structure.md</code>: how the code is organized</li> <li><code>workflow.md</code>: how work moves through the system</li> </ul> <p>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 <code>inclusion: always</code> by default so every session picks them up.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing_1","level":3,"title":"Customizing","text":"<p>Edit the files directly. Add your own steering files with <code>ctx steering add</code>, preview the match set with <code>ctx steering preview</code>, and run <code>ctx steering sync</code> to push them into each AI tool's config after changes. Steering files are committed to git, so they're shared with the team.</p> <p>For the design rationale, the full inclusion/priority model, and the end-to-end sync workflow, see the dedicated Steering files page.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#parsing-rules","level":2,"title":"Parsing Rules","text":"<p>All context files follow these conventions:</p> <ol> <li>Headers define structure: <code>#</code> for title, <code>##</code> for sections, <code>###</code> for items</li> <li>Bold keys for fields: <code>**Key**:</code> followed by value</li> <li>Code blocks are literal: Never parse code block content as structure</li> <li>Lists are ordered: Items appear in priority/chronological order</li> <li>Tags are inline: Backtick-wrapped tags like <code>#priority:high</code></li> </ol>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Refactoring with Intent: how persistent context prevents drift during refactoring sessions</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#token-efficiency","level":2,"title":"Token Efficiency","text":"<p>Keep context files concise:</p> <ul> <li>Use abbreviations in tags, not prose;</li> <li>Omit obvious words (\"The,\" \"This\");</li> <li>Prefer bullet points over paragraphs;</li> <li>Keep examples minimal but illustrative;</li> <li>Archive old completed items periodically.</li> </ul> <p>Next Up: Prompting Guide →: effective prompts for AI sessions with <code>ctx</code></p>","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":"<ul> <li>Go (version defined in <code>go.mod</code>)</li> <li>Claude Code</li> <li>Git</li> <li>GNU Make</li> <li>Zensical</li> </ul>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#1-fork-or-clone-the-repository","level":3,"title":"1. Fork (or Clone) the Repository","text":"<pre><code># 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</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#2-build-and-install-the-binary","level":3,"title":"2. Build and Install the Binary","text":"<pre><code>make build\nsudo make install\n</code></pre> <p>This compiles the <code>ctx</code> binary and places it in <code>/usr/local/bin/</code>.</p>","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":"<p>The repository ships a Claude Code plugin under <code>internal/assets/claude/</code>. Point Claude Code at your local copy so that skills and hooks reflect your working tree: no reinstall needed after edits:</p> <ol> <li>Launch <code>claude</code>;</li> <li>Type <code>/plugin</code> and press Enter;</li> <li>Select Marketplaces → Add Marketplace</li> <li>Enter the absolute path to the root of your clone, e.g. <code>~/WORKSPACE/ctx</code> (this is where <code>.claude-plugin/marketplace.json</code> lives: it points Claude Code to the actual plugin in <code>internal/assets/claude</code>);</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code>.</li> </ol> <p>Claude Code Caches Plugin Files</p> <p>Even though the marketplace points at a directory on disk, Claude Code caches skills and hooks. After editing files under <code>internal/assets/claude/</code>, clear the cache and restart:</p> <pre><code>make plugin-reload # then restart Claude Code\n</code></pre> <p>See Skill or Hook Changes for details.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#4-verify","level":3,"title":"4. Verify","text":"<pre><code>ctx --version # binary is in PATH\nclaude /plugin list # plugin is installed\n</code></pre> <p>You should see the <code>ctx</code> plugin listed, sourced from your local path.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#maintainer-tooling-ctxctl","level":2,"title":"Maintainer Tooling: <code>ctxctl</code>","text":"<p><code>ctxctl</code> is a maintainer-only binary that houses tooling kept out of the shipped <code>ctx</code> binary. It is a separate Go module at <code>tools/ctxctl/</code>: <code>ctx</code>'s <code>go.mod</code> never requires it, so <code>ctx</code> can never import it, while <code>ctxctl</code> reuses <code>ctx</code>'s <code>internal/</code> packages through the repo-root <code>go.work</code> workspace. End users never receive it, so it is not part of the Development Setup above: skip this section unless you are working on maintainer tooling.</p> <p>Its first inhabitant is the out-of-band audit channel (<code>ctxctl audit list|show|dismiss</code> plus the <code>ctxctl audit-relay</code> hook). This page covers only building and installing the binary. The full workflow (running an auditor, relaying its findings into your working session, dismissing them) is its own runbook: Out-of-Band Audit Channel.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#build-and-install","level":3,"title":"Build and Install","text":"<pre><code>make ctxctl # build into dist/ctxctl\nmake install-ctxctl # install dist/ctxctl to /usr/local/bin/ctxctl\nmake reinstall-ctxctl # build + install in one step (the usual case)\n</code></pre> <p><code>ctxctl</code> installs to <code>/usr/local/bin/</code> alongside <code>ctx</code> (the install falls back to <code>sudo</code> when the directory is not writable). Installing to <code>PATH</code> is deliberate: the repo-local <code>UserPromptSubmit</code> hook invokes <code>ctxctl audit-relay</code> as a <code>PATH</code> binary, and a single install is shared across every clone and worktree, so the repo root stays clean.</p> <p>Run <code>make reinstall-ctxctl</code> once after first cloning, then again whenever you pull or edit anything under <code>tools/ctxctl/</code> or the relocated <code>internal/ctxctl/</code> packages.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#verify","level":3,"title":"Verify","text":"<pre><code>ctxctl --help # command tree\nctxctl audit # list audit reports (run inside a ctx project)\n</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#project-layout","level":2,"title":"Project Layout","text":"<pre><code>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</code></pre>","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? <code>internal/assets/claude/skills/</code> The 39 <code>ctx-*</code> skills that ship with the plugin Yes <code>.claude/skills/</code> Dev-only skills (release, QA, backup, etc.) No <p><code>internal/assets/claude/skills/</code> is the single source of truth for user-facing skills. If you are adding or modifying a <code>ctx-*</code> skill, edit it there.</p> <p><code>.claude/skills/</code> holds skills that only make sense inside this repository (release automation, QA checks, backup scripts). These are never distributed to users.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#dev-only-skills-reference","level":4,"title":"Dev-Only Skills Reference","text":"Skill When to use <code>/_ctx-absorb</code> Merge deltas from a parallel worktree or separate checkout <code>/_ctx-audit</code> Detect code-level drift after YOLO sprints or before releases <code>/_ctx-qa</code> Run QA checks before committing <code>/_ctx-release</code> Run the full release process <code>/_ctx-release-notes</code> Generate release notes for <code>dist/RELEASE_NOTES.md</code> <code>/_ctx-alignment-audit</code> Audit doc claims against agent instructions <code>/_ctx-update-docs</code> Check docs/code consistency after changes <code>/_ctx-command-audit</code> Audit CLI surface after renames, moves, or deletions <p>Six skills previously in this list have been promoted to bundled plugin skills and are now available to all <code>ctx</code> users: <code>/ctx-brainstorm</code>, <code>/ctx-link-check</code>, <code>/ctx-permission-sanitize</code>, <code>/ctx-skill-create</code>, <code>/ctx-spec</code>.</p>","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":"<ol> <li>Create a package under <code>internal/cli/<name>/</code> with <code>doc.go</code>, <code>cmd.go</code>, and <code>run.go</code>;</li> <li>Implement <code>Cmd() *cobra.Command</code> as the entry point;</li> <li>Add <code>Use*</code> and <code>DescKey*</code> constants in <code>internal/config/embed/cmd/<name>.go</code>;</li> <li>Add command descriptions in <code>internal/assets/commands/commands.yaml</code>;</li> <li>Add examples in <code>internal/assets/commands/examples.yaml</code>;</li> <li>Add flag descriptions in <code>internal/assets/commands/flags.yaml</code>;</li> <li>Register the command in <code>internal/bootstrap/group.go</code> (add import + entry in the appropriate group function);</li> <li>Create an output package at <code>internal/write/<name>/</code> for all user-facing output (see Package Taxonomy);</li> <li>Create error constructors at <code>internal/err/<name>/</code> for domain-specific errors;</li> <li>Add tests in the same package (<code><name>_test.go</code>);</li> <li>Add a doc page at <code>docs/cli/<name>.md</code> and update <code>docs/cli/index.md</code>;</li> <li>Add the page to <code>zensical.toml</code> nav.</li> </ol> <p>Pattern to follow: <code>internal/cli/pad/pad.go</code> (parent with subcommands) or <code>internal/cli/drift/</code> (single command).</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#package-taxonomy","level":3,"title":"Package Taxonomy","text":"<p><code>ctx</code> separates concerns into a strict package taxonomy. Knowing where things go prevents code review friction and keeps the AST lint tests happy.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#output-internalwrite","level":4,"title":"Output: <code>internal/write/</code>","text":"<p>Every CLI command's user-facing output lives in its own sub-package under <code>internal/write/<domain>/</code>. Output functions accept <code>*cobra.Command</code> and call <code>cmd.Println(...)</code>, never <code>fmt.Print*</code> directly. All text strings are loaded from YAML via <code>desc.Text(text.DescKey*)</code>, never inline.</p> <pre><code>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</code></pre> <p>Exception: <code>write/rc/</code> writes to <code>os.Stderr</code> because rc loads before cobra is initialized.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#errors-internalerr","level":4,"title":"Errors: <code>internal/err/</code>","text":"<p>Domain-specific error constructors live under <code>internal/err/<domain>/</code>. Each package mirrors the write structure. Constructor functions return <code>error</code> and load messages from YAML via <code>desc.Text(text.DescKey*)</code>.</p> <p>Identity sentinels (matched at the call site with <code>errors.Is</code>) are declared as <code>entity.Sentinel</code> consts:</p> <pre><code>const ErrMissingFoo = entity.Sentinel(text.DescKeyErrPkgMissingFoo)\n</code></pre> <p><code>entity.Sentinel</code> is a typed string whose <code>Error()</code> resolves the key through <code>desc.Text</code> at call time, so the user-facing text stays in <code>commands/text/errors.yaml</code> and the sentinel value itself remains pure identity. Never declare sentinels as <code>var ErrX = errors.New(...)</code> with a hardcoded English string — that bypasses localization and materializes the string before the embedded YAML lookup is populated.</p> <p>When a sentinel needs to carry fields (a path, a name), use a typed struct in <code>internal/err/<domain>/</code> instead. See <code>internal/err/context.NotFoundError</code> for the canonical pattern with <code>Error()</code>, <code>Is(target error) bool</code>, and an <code>errors.As</code> consumer contract.</p> <pre><code>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</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#config-constants-internalconfig","level":4,"title":"Config Constants: <code>internal/config/</code>","text":"<p>Pure-constant leaf packages with zero internal dependencies (stdlib only). Over 60 sub-packages, organized by domain. See <code>internal/config/README.md</code> for the full decision tree.</p> What you're adding Where it goes File names, extensions, paths <code>config/file/</code>, <code>config/dir/</code> Regex patterns <code>config/regex/</code> CLI flag names (<code>--flag-name</code>) <code>config/flag/flag.go</code> Flag description YAML keys <code>config/embed/flag/<cmd>.go</code> Command Use/DescKey strings <code>config/embed/cmd/<cmd>.go</code> User-facing text YAML keys <code>config/embed/text/<domain>.go</code> Time durations, thresholds <code>config/<domain>/</code>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#the-assets-pipeline","level":4,"title":"The Assets Pipeline","text":"<p>User-facing text flows through a three-level chain:</p> <ol> <li>Go constant (<code>config/embed/text/</code>) defines a string key: <code>DescKeyWriteAddedTo = \"write.added-to\"</code></li> <li>Call site resolves it: <code>desc.Text(text.DescKeyWriteAddedTo)</code></li> <li>YAML (<code>internal/assets/commands/text/write.yaml</code>) holds the actual text: <code>write.added-to: { short: \"Added to %s\" }</code></li> </ol> <p>The same pattern applies to command descriptions (<code>commands.yaml</code>), flag descriptions (<code>flags.yaml</code>), and examples (<code>examples.yaml</code>). The <code>TestDescKeyYAMLLinkage</code> test verifies every constant resolves to a non-empty YAML value.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-new-session-parser","level":3,"title":"Adding a New Session Parser","text":"<p>The journal system uses a <code>SessionParser</code> interface. To add support for a new AI tool (e.g. Aider, Cursor):</p> <ol> <li>Create <code>internal/journal/parser/<tool>.go</code>;</li> <li>Implement parsing logic that returns <code>[]*Session</code>;</li> <li>Register the parser in <code>FindSessions()</code> / <code>FindSessionsForCWD()</code>;</li> <li>Use <code>config.Tool*</code> constants for the tool identifier;</li> <li>Add test fixtures and parser tests.</li> </ol> <p>Pattern to follow: the Claude Code JSONL parser in <code>internal/journal/parser/</code>.</p> <p>Multilingual Session Headers</p> <p>The Markdown parser recognizes session header prefixes configured via <code>session_prefixes</code> in <code>.ctxrc</code> (default: <code>Session:</code>). To support a new language, users add a prefix to their <code>.ctxrc</code> - no code change needed. New parser implementations can use <code>rc.SessionPrefixes()</code> if they also need prefix-based header detection.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-bundled-skill","level":3,"title":"Adding a Bundled Skill","text":"<ol> <li>Create <code>internal/assets/claude/skills/<skill-name>/SKILL.md</code>;</li> <li>Follow the skill format: trigger, negative triggers, steps, quality gate;</li> <li>Run <code>make plugin-reload</code> and restart Claude Code to test;</li> <li>Add a <code>Skill</code> entry to <code>.claude-plugin/plugin.json</code> if user-invocable;</li> <li>Document in <code>docs/reference/skills.md</code>.</li> </ol> <p>Pattern to follow: any skill in <code>internal/assets/claude/skills/ctx-status/</code>.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#test-expectations","level":3,"title":"Test Expectations","text":"<ul> <li>Unit tests: colocated with source (<code>foo.go</code> → <code>foo_test.go</code>);</li> <li>Test helpers: use <code>t.Helper()</code> so failures point to callers;</li> <li>HOME isolation: use <code>t.TempDir()</code> + <code>t.Setenv(\"HOME\", ...)</code> for tests that touch <code>~/.claude/</code> or <code>~/.ctx/</code>;</li> <li>rc.Reset(): call after <code>os.Chdir</code> in tests that change working directory (rc caches on first access);</li> <li>No network: all tests run offline, use fixtures.</li> </ul> <p>Run <code>make test</code> before submitting. Target: no failures, no skips.</p>","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":"<p>After modifying Go source files, rebuild and reinstall:</p> <pre><code>make build && sudo make install\n</code></pre> <p>The <code>ctx</code> binary is statically compiled. There is no hot reload. You must rebuild for Go changes to take effect.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#skill-or-hook-changes","level":3,"title":"Skill or Hook Changes","text":"<p>Edit files under <code>internal/assets/claude/skills/</code> or <code>internal/assets/claude/hooks/</code>.</p> <p>Claude Code caches plugin files, so edits aren't picked up automatically.</p> <p>Clear the cache and restart:</p> <pre><code>make plugin-reload # nukes ~/.claude/plugins/cache/activememory-ctx/\n# then restart Claude Code\n</code></pre> <p>The plugin will be re-installed from your local marketplace on startup. No version bump is needed during development.</p> <p>Version Bumps Are for Releases, Not Iteration</p> <p>Only bump <code>VERSION</code>, <code>plugin.json</code>, and <code>marketplace.json</code> when cutting a release. During development, <code>make plugin-reload</code> is all you need.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"<p>The repo ships two <code>.ctxrc</code> source profiles. The working copy (<code>.ctxrc</code>) is gitignored and swapped between them:</p> File Purpose <code>.ctxrc.base</code> Golden baseline: all defaults, no logging <code>.ctxrc.dev</code> Dev profile: notify events enabled, verbose logging <code>.ctxrc</code> Working copy (gitignored: copied from one of the above) <p>Use <code>ctx</code> commands to switch:</p> <pre><code>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</code></pre> <p>After cloning, run <code>ctx config switch dev</code> to get started with full logging.</p> <p>See Configuration for the full <code>.ctxrc</code> option reference.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#backups","level":3,"title":"Backups","text":"<p><code>ctx</code> does not ship a backup command. File-level backup is an OS / infrastructure concern; <code>ctx hub</code> 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.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-tests","level":3,"title":"Running Tests","text":"<pre><code>make test # fast: all tests\nmake audit # full: fmt + vet + lint + drift + docs + test\nmake smoke # build + run basic commands end-to-end\n</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-the-docs-site-locally","level":3,"title":"Running the Docs Site Locally","text":"<pre><code>make site-setup # one-time: install zensical via pipx\nmake site-serve # serve at localhost\n</code></pre>","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":"<ol> <li>Check existing issues to avoid duplicating effort;</li> <li>For large changes, open an issue first to discuss the approach;</li> <li>Read the specs in <code>specs/</code> for design context.</li> </ol>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#pull-request-process","level":3,"title":"Pull Request Process","text":"<p>Respect the maintainers' time and energy: Keep your pull requests isolated and strive to minimze code changes.</p> <p>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.</p> <ol> <li>Create a feature branch: <code>git checkout -b feature/my-feature</code>;</li> <li>Make your changes;</li> <li>Run <code>make audit</code> to catch issues early;</li> <li>Commit with a clear message;</li> <li>Push and open a pull request.</li> </ol> <p>Audit Your Code Before Submitting</p> <p>Run <code>make audit</code> before submitting:</p> <p><code>make audit</code> covers formatting, vetting, linting, drift checks, doc consistency, and tests in one pass.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#commit-messages","level":3,"title":"Commit Messages","text":"<p>Following conventional commits is recommended but not required:</p> <p>Types: <code>feat</code>, <code>fix</code>, <code>docs</code>, <code>test</code>, <code>refactor</code>, <code>chore</code></p> <p>Examples:</p> <ul> <li><code>feat(cli): add ctx export command</code></li> <li><code>fix(drift): handle missing files gracefully</code></li> <li><code>docs: update installation instructions</code></li> </ul>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-style","level":3,"title":"Code Style","text":"<ul> <li>Follow Go conventions (<code>gofmt</code>, <code>go vet</code>);</li> <li>Keep functions focused and small;</li> <li>Add tests for new functionality;</li> <li>Handle errors explicitly; use descriptive names (<code>readErr</code>, <code>writeErr</code>) not repeated <code>err</code>;</li> <li>No magic strings: all repeated literals go in <code>internal/config/</code>;</li> <li>Output goes through <code>internal/write/</code> packages, not <code>fmt.Print*</code>;</li> <li>Errors go through <code>internal/err/</code> constructors, not inline <code>fmt.Errorf</code>;</li> <li>See Package Taxonomy and <code>.context/CONVENTIONS.md</code> for the full reference.</li> </ul>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-of-conduct","level":2,"title":"Code of Conduct","text":"<p>A clear context requires respectful collaboration.</p> <p><code>ctx</code> follows the Contributor Covenant.</p>","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":"<p>By contributing, you agree to the Developer Certificate of Origin.</p> <p>All commits must be signed off:</p> <pre><code>git commit -s -m \"feat: add new feature\"\n</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#license","level":3,"title":"License","text":"<p>Contributions are licensed under the Apache 2.0 License.</p>","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":"<p>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 <code>cat</code>, diff it with <code>git diff</code>, and review it in a PR.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#does-ctx-work-offline","level":2,"title":"Does <code>ctx</code> Work Offline?","text":"<p>Yes. <code>ctx</code> 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.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#what-gets-committed-to-git","level":2,"title":"What Gets Committed to Git?","text":"<p>The <code>.context/</code> directory: yes, commit it. That's the whole point. Team members and AI agents read the same context files.</p> <p>What not to commit:</p> <ul> <li><code>.ctx.key</code>: your encryption key. Stored at <code>~/.ctx/.ctx.key</code>, never in the repo. <code>ctx init</code> handles this automatically.</li> <li><code>journal/</code> and <code>logs/</code>: generated data, potentially large. <code>ctx init</code> adds these to <code>.gitignore</code>.</li> <li><code>scratchpad.enc</code>: your choice. It's encrypted, so it's safe to commit if you want shared scratchpad state. See Scratchpad for details.</li> </ul>","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":"<p>The default is 8000 tokens, which works well for most projects. Configure it via <code>.ctxrc</code> or the <code>CTX_TOKEN_BUDGET</code> environment variable:</p> <pre><code># 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</code></pre> <p>Higher budgets include more context but cost more tokens per request. Lower budgets force sharper prioritization: <code>ctx</code> drops lower-priority content first, so CONSTITUTION and TASKS always make the cut.</p> <p>See Configuration for all available settings.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#why-not-a-database","level":2,"title":"Why Not a Database?","text":"<p>Files are inspectable, diffable, and reviewable in pull requests. You can <code>grep</code> them, <code>cat</code> them, pipe them through <code>jq</code> or <code>awk</code>. They work with every version control system and every text editor.</p> <p>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.</p>","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":"<p>Yes. <code>ctx agent</code> outputs a context packet that any AI tool can consume: paste it into ChatGPT, Cursor, Copilot, Aider, or anything else that accepts text input.</p> <p>Claude Code gets first-class integration via the <code>ctx</code> plugin (hooks, skills, automatic context loading). VS Code Copilot Chat has a dedicated <code>ctx</code> extension. Other tools integrate via generated instruction files or manual pasting.</p> <p>See Integrations for tool-specific setup, including the multi-tool recipe.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#can-i-use-ctx-on-an-existing-project","level":2,"title":"Can I Use <code>ctx</code> on an Existing Project?","text":"<p>Yes. Run <code>ctx init</code> in any repo and it creates <code>.context/</code> 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.</p> <p>See Getting Started for the full setup flow, or Joining a <code>ctx</code> Project if someone else already initialized it.</p>","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":"<p>Token budgeting handles this automatically. <code>ctx agent</code> prioritizes content by file priority (CONSTITUTION first, GLOSSARY last) and trims lower-priority entries when the budget is tight.</p> <p>For manual maintenance, <code>ctx compact</code> archives completed tasks and old entries, keeping active context lean. You can also run <code>ctx task archive</code> to move completed tasks out of TASKS.md.</p> <p>The goal is to keep context files focused on current state. Historical entries belong in git history or the archive.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#is-context-meant-to-be-shared","level":2,"title":"Is <code>.context/</code> Meant to Be Shared?","text":"<p>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.</p> <p>The only per-user state is the encryption key (<code>~/.ctx/.ctx.key</code>) and the optional scratchpad. Everything else is team-shared by design.</p> <p>Related:</p> <ul> <li>Getting Started - installation and first setup</li> <li>Configuration - <code>.ctxrc</code>, environment variables, and defaults</li> <li>Context Files - what each file does and how to use it</li> </ul>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/first-session/","level":1,"title":"Your First Session","text":"<p>Here's what a complete first session looks like, from initialization to the moment your AI cites your project context back to you.</p>","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":"<p>Run <code>ctx init</code> in your project root:</p> <pre><code>cd your-project\nctx init\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> <p>This created your <code>.context/</code> directory with template files. </p> <p>For Claude Code, install the <code>ctx</code> plugin to get automatic hooks and skills.</p>","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-2-populate-your-context","level":2,"title":"Step 2: Populate Your Context","text":"<p>Add a task and a decision: These are the entries your AI will remember:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<pre><code>ctx status\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> <p>Notice the token estimate: This is how much context your AI will load.</p> <p>The <code>○</code> next to <code>LEARNINGS.md</code> means it's still empty; it will fill in as you capture lessons during development.</p>","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":"<p>With Claude Code (and the <code>ctx</code> plugin), start every session with:</p> <pre><code>/ctx-remember\n</code></pre> <p>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.</p> <p>Steering Files Fire Automatically</p> <p>If you edited the four foundation files scaffolded by <code>ctx init</code> (<code>.context/steering/product.md</code>, <code>tech.md</code>, <code>structure.md</code>, <code>workflow.md</code>), their <code>inclusion: always</code> rules are prepended to every tool call via the plugin's <code>PreToolUse</code> hook, with no <code>/ctx-remember</code> 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.</p> <p>Using VS Code?</p> <p>With VS Code Copilot Chat (and the <code>ctx</code> extension), type <code>@ctx /agent</code> in chat to load your context packet, or <code>@ctx /status</code> to check your project context. Run <code>ctx setup copilot --write</code> once to generate <code>.github/copilot-instructions.md</code> for automatic context loading.</p> <p>If you are not using Claude Code, generate a context packet for your AI tool:</p> <pre><code>ctx agent --budget 8000\n</code></pre> <p>Sample output:</p> <pre><code># 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</code></pre> <p>Paste this output into your AI tool's system prompt or conversation start.</p>","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":"<p>Ask your AI: \"What are our current tasks?\"</p> <p>A working setup produces a response like:</p> <pre><code>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</code></pre> <p>That's the success moment:</p> <p>The AI is citing your exact context entries from Step 2, not hallucinating or asking you to re-explain.</p>","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-gets-created","level":2,"title":"What Gets Created","text":"<pre><code>.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</code></pre> <p>Claude Code integration (hooks + skills) is provided by the <code>ctx</code> plugin: See Integrations/Claude Code.</p> <p>VS Code Copilot Chat integration is provided by the <code>ctx</code> extension: See Integrations/VS Code.</p> <p>See Context Files for detailed documentation of each file.</p>","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-to-gitignore","level":2,"title":"What to <code>.gitignore</code>","text":"<p>Rule of Thumb</p> <ul> <li>If it's knowledge (decisions, tasks, learnings, conventions), commit it.</li> <li>If it's generated output, raw session data, or a secret, <code>.gitignore</code> it.</li> </ul> <p>Commit your <code>.context/</code> knowledge files: that's the whole point.</p> <p>You should <code>.gitignore</code> the generated and sensitive paths:</p> <pre><code># 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</code></pre> <p><code>ctx init</code> Patches Your .Gitignore for You</p> <p><code>ctx init</code> automatically adds these entries to your <code>.gitignore</code>.</p> <p>Review the additions with <code>cat .gitignore</code> after init.</p> <p>See also:</p> <ul> <li>Security Considerations</li> <li>Scratchpad Encryption</li> <li>Session Journal</li> </ul> <p>Next Up: Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history.</p>","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":"<p><code>ctx</code> does not require <code>git</code>, but using version control with your <code>.context/</code> directory is strongly recommended:</p> <p>AI sessions occasionally modify or overwrite context files inadvertently. With <code>git</code>, the AI can check history and restore lost content: Without it, the data is gone.</p> <p>Also, several <code>ctx</code> features (journal changelog, blog generation) also use <code>git</code> history directly.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#installation","level":2,"title":"Installation","text":"<p>Every setup starts with the <code>ctx</code> binary: the CLI tool itself.</p> <p>If you use Claude Code, you also install the <code>ctx</code> plugin, which adds hooks (context autoloading, persistence nudges) and 25+ <code>/ctx-*</code> skills. For other AI tools, <code>ctx</code> integrates via generated instruction files or manual context pasting: see Integrations for tool-specific setup.</p> <p>Pick one of the options below to install the binary. Claude Code users should also follow the plugin steps included in each option.</p>","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":"<p>Requires Go (version defined in <code>go.mod</code>) and Claude Code.</p> <pre><code>git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\nmake build\nsudo make install\n</code></pre> <p>Install the Claude Code plugin from your local clone:</p> <ol> <li>Launch <code>claude</code>;</li> <li>Type <code>/plugin</code> and press Enter;</li> <li>Select Marketplaces → Add Marketplace</li> <li>Enter the path to the root of your clone, e.g. <code>~/WORKSPACE/ctx</code> (this is where <code>.claude-plugin/marketplace.json</code> lives: It points Claude Code to the actual plugin in <code>internal/assets/claude</code>)</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code></li> </ol> <p>This points Claude Code at the plugin source on disk. Changes you make to hooks or skills take effect immediately: No reinstall is needed.</p> <p>Local Installs Need Manual Enablement</p> <p>Unlike marketplace installs, local plugin installs are not auto-enabled globally. The plugin will only work in projects that explicitly enable it. Run <code>ctx init</code> in each project (it auto-enables the plugin), or add the entry to <code>~/.claude/settings.json</code> manually:</p> <pre><code>{ \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n</code></pre> <p>Verify:</p> <pre><code>ctx --version # binary is in PATH\nclaude /plugin list # plugin is installed\n</code></pre> <p>Use the Source, Luke</p> <p>Building from source gives you the latest features and bug fixes.</p> <p>Since <code>ctx</code> is predominantly a developer tool, this is the recommended approach: </p> <p>You get the freshest code, can inspect what you are installing, and the plugin stays in sync with the binary.</p>","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":"<p>Pre-built binaries are available from the releases page.</p> Linux (x86_64)Linux (ARM64)macOS (Apple Silicon)macOS (Intel)Windows <pre><code>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</code></pre> <pre><code>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</code></pre> <pre><code>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</code></pre> <pre><code>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</code></pre> <p>Download <code>ctx-0.8.1-windows-amd64.exe</code> from the releases page and add it to your <code>PATH</code>.</p> <p>Claude Code users: install the plugin from the marketplace:</p> <ol> <li>Launch <code>claude</code>;</li> <li>Type <code>/plugin</code> and press Enter;</li> <li>Select Marketplaces → Add Marketplace;</li> <li>Enter <code>ActiveMemory/ctx</code>;</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code>.</li> </ol> <p>Other tool users: see Integrations for tool-specific setup (Cursor, Copilot, Aider, Windsurf, etc.).</p> <p>Verify the Plugin Is Enabled</p> <p>After installing, confirm the plugin is enabled globally. Check <code>~/.claude/settings.json</code> for an <code>enabledPlugins</code> entry. If missing, run <code>ctx init</code> in your project (it auto-enables the plugin), or add it manually:</p> <pre><code>{ \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n</code></pre> <p>Verify:</p> <pre><code>ctx --version # binary is in PATH\nclaude /plugin list # plugin is installed (Claude Code only)\n</code></pre>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#verifying-checksums","level":4,"title":"Verifying Checksums","text":"<p>Each binary has a corresponding <code>.sha256</code> checksum file. To verify your download:</p> <pre><code># 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</code></pre> <p>On macOS, use <code>shasum -a 256 -c</code> instead of <code>sha256sum -c</code>.</p> Plugin Details <p>After installation (either option) you get:</p> <ul> <li>Context autoloading: <code>ctx agent</code> runs on every tool use (with cooldown)</li> <li>Persistence nudges: reminders to capture learnings and decisions</li> <li>Post-commit hooks: nudge context capture after <code>git commit</code></li> <li>Context size monitoring: alerts as sessions grow large</li> <li>Project skills: <code>/ctx-status</code>, <code>/ctx-task-add</code>, <code>/ctx-history</code>, and more</li> </ul> <p>See Integrations for the full hook and skill reference.</p>","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":"<pre><code>cd your-project\nctx init\n</code></pre> <p>This creates a <code>.context/</code> directory with template files and an encryption key at <code>~/.ctx/</code> for the encrypted scratchpad. For Claude Code, install the <code>ctx</code> plugin for automatic hooks and skills.</p> <p><code>ctx init</code> also scaffolds four foundation steering files in <code>.context/steering/</code>: <code>product.md</code>, <code>tech.md</code>, <code>structure.md</code>, <code>workflow.md</code>. They are placeholders until you customize them (see the next step); skipping that step has consequences, so it is broken out as its own numbered beat rather than buried here.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#2-customize-your-steering-files","level":3,"title":"2. Customize Your Steering Files","text":"<p>Steering files are behavioral rules prepended to every AI prompt: the layer that tells your AI how to act on this specific project. They are distinct from decisions (what was chosen) and conventions (how the codebase is written); see <code>ctx</code> for Steering Files for the full model.</p> <p><code>ctx init</code> scaffolded four foundation files; open each and fill it in:</p> File What to fill in <code>product.md</code> What the project is, who uses it, what's out of scope <code>tech.md</code> Languages, frameworks, runtime, hard constraints <code>structure.md</code> Directory layout, where new files go, naming rules <code>workflow.md</code> Branch strategy, commit conventions, pre-commit checks <p>Each scaffolded file ships with a tombstone marker line (<code><!-- remove this after you edit the steering file !--></code>). As long as the marker is present, the file is silently skipped on every load path: the agent context packet, MCP <code>ctx_steering_get</code>, and native-tool sync (Cursor / Cline / Kiro). The skip is deliberate: injecting unfilled placeholders into AI prompts is worse than no steering at all, because the AI tries to follow \"Describe the product...\" as if it were a rule.</p> <p>Replace each file's body with real content, then delete the tombstone line. When the line is gone, the file becomes active on the next AI tool call.</p> <p>Don't want steering at all? Pass <code>--no-steering-init</code> to <code>ctx init</code> to skip the scaffold entirely. Existing edits are never clobbered by re-running <code>ctx init</code>.</p> <p>Inclusion modes (<code>always</code> / <code>auto</code> / <code>manual</code>), priority, and tool scoping are covered in Writing Steering Files and <code>ctx steering</code>.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#3-check-status","level":3,"title":"3. Check Status","text":"<pre><code>ctx status\n</code></pre> <p>Shows context summary: files present, token estimate, and recent activity.</p>","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":"<p>With Claude Code (and the <code>ctx</code> plugin installed), context loads automatically via hooks.</p> <p>With VS Code Copilot Chat, install the <code>ctx</code> extension and use <code>@ctx /status</code>, <code>@ctx /agent</code>, and other slash commands directly in chat. Run <code>ctx setup copilot --write</code> to generate <code>.github/copilot-instructions.md</code> for automatic context loading.</p> <p>For other tools, paste the output of:</p> <pre><code>ctx agent --budget 8000\n</code></pre>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#5-set-up-for-your-ai-tool","level":3,"title":"5. Set Up for Your AI Tool","text":"<p>If you use an MCP-compatible tool, generate the integration config with <code>ctx setup</code>:</p> KiroCursorCline <pre><code>ctx setup kiro --write\n# Creates .kiro/settings/mcp.json and syncs steering files\n</code></pre> <pre><code>ctx setup cursor --write\n# Creates .cursor/mcp.json and syncs steering files\n</code></pre> <pre><code>ctx setup cline --write\n# Creates .vscode/mcp.json and syncs steering files\n</code></pre> <p>This registers the <code>ctx</code> MCP server and syncs any steering files into the tool's native format. Re-run after adding or changing steering files.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#6-verify-it-works","level":3,"title":"6. Verify It Works","text":"<p>Ask your AI: \"Do you remember?\"</p> <p>It should cite specific context: current tasks, recent decisions, or previous session topics.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#7-set-up-companion-tools-highly-recommended","level":3,"title":"7. Set Up Companion Tools (Highly Recommended)","text":"<p><code>ctx</code> works on its own, but two MCP capabilities unlock significantly better agent behavior. ctx names canonical implementations below as its tested defaults; if your toolchain provides the same capabilities through different MCP servers (Firecrawl / Exa / Tavily for web search; sourcegraph-cody for the code graph), use those instead. The investment is small and the benefits compound over sessions:</p> <ul> <li> <p>Web search with citations — canonical: Gemini Search. Skills like <code>/ctx-code-review</code> and <code>/ctx-explain</code> use it for up-to-date documentation lookups instead of relying on training data.</p> </li> <li> <p>Code knowledge graph — canonical: GitNexus. Provides symbol resolution, blast radius analysis, and domain clustering. Skills like <code>/ctx-refactor</code> and <code>/ctx-code-review</code> use it for impact analysis and dependency awareness.</p> </li> </ul> <pre><code># Index your project for GitNexus (run once, then after major changes)\ngitnexus analyze\n</code></pre> <p>(For non-GitNexus code-intelligence MCPs, apply that tool's own indexing step instead.)</p> <p>Both capabilities are optional: if no compatible MCP is connected, skills degrade gracefully to built-in capabilities. See Companion Tools for setup details and verification.</p> <p>Next Up:</p> <ul> <li>Your First Session →: a step-by-step walkthrough from <code>ctx init</code> to verified recall</li> <li>Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history</li> </ul>","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":"<p><code>ctx</code> projects are normally independent: each project has its own <code>.context/</code> 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.</p> <p>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 <code>ctx</code> Hub is the feature that makes those specific entries travel, without replicating everything else.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#what-the-hub-actually-is","level":2,"title":"What the Hub Actually Is","text":"<p>In one paragraph: the <code>ctx</code> Hub is a fan-out channel for four specific kinds of structured entries: <code>decision</code>, <code>learning</code>, <code>convention</code>, and <code>task</code>. You publish an entry with <code>ctx add --share</code> in one project, and it appears in <code>.context/hub/</code> for every other project subscribed to that type. When you run <code>ctx agent --include-hub</code>, those shared entries become part of your next agent context packet.</p> <p>That is the entire feature. The Hub does not:</p> <ul> <li>Share your session journal (<code>.context/journal/</code>). That stays local to each project.</li> <li>Share your scratchpad (<code>.context/pad</code>). Encrypted notes never leave the machine that created them.</li> <li>Share your <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, or <code>CONVENTIONS.md</code> wholesale. Only entries you explicitly <code>--share</code> cross the boundary.</li> <li>Provide user identity or attribution. The Hub identifies projects, not people.</li> </ul> <p>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.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#who-its-for","level":2,"title":"Who It's For","text":"<p>Two shapes, same mechanics, different trust models.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"<p>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.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#small-trusted-team","level":3,"title":"Small Trusted Team","text":"<p>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.</p> <p>The Hub is not a multi-tenant public service. It assumes everyone holding a client token is friendly. Don't stand up <code>hub.example.com</code> for untrusted participants.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#going-further","level":2,"title":"Going Further","text":"<ul> <li>First-time setup: Hub: Getting Started, a five-minute walkthrough on localhost.</li> <li>Mental model and user stories: Hub Overview, what flows, what doesn't, and when not to use it.</li> <li>Team / LAN deployment: Multi-machine setup.</li> <li>Redundancy: HA cluster.</li> <li>Operating a Hub: Hub Operations and Hub Failure Modes.</li> <li>Security posture: Hub Security Model.</li> <li>Command reference: <code>ctx serve</code>, <code>ctx connection</code>, <code>ctx hub</code>.</li> </ul>","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":"<p><code>ctx</code> shines when context matters more than code.</p> <p>If any of these sound like your project, it's worth trying:</p> <ul> <li>Multi-session AI work: You use AI across many sessions on the same codebase, and re-explaining is slowing you down.</li> <li>Architectural decisions that matter: Your project has non-obvious choices (database, auth strategy, API design) that the AI keeps second-guessing.</li> <li>\"Why\" matters as much as \"what\": you need the AI to understand rationale, not just current code</li> <li>Team handoffs: Multiple people (or multiple AI tools) work on the same project and need shared context.</li> <li>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.</li> <li>Long-lived projects: Anything you'll work on for weeks or months, where accumulated knowledge has compounding value.</li> </ul>","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":"<p><code>ctx</code> adds overhead that isn't worth it for every project. Be honest about when to skip it:</p> <ul> <li>One-off scripts: If the project is a single file you'll finish today, there's nothing to remember.</li> <li>RAG-only workflows: If retrieval from an external knowledge base already gives the agent everything it needs for each session, adding <code>ctx</code> may be unnecessary. RAG retrieves information; <code>ctx</code> defines the project's working memory: They are complementary.</li> <li>No AI involvement: <code>ctx</code> is designed for human-AI workflows; without an AI consumer, the files are just documentation.</li> <li>Enterprise-managed context platforms: If your organization provides centralized context services, <code>ctx</code> may duplicate that layer.</li> </ul> <p>For a deeper technical comparison with RAG, prompt management tools, and agent frameworks, see <code>ctx</code> and Similar Tools.</p>","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":"<p>This is <code>ctx</code>'s sweet spot. </p> <p>You get the most value here: one person, one project, decisions, and learnings accumulating over time. Setup takes 5 minutes and the <code>.context/</code> directory directory stays small, and every session gets faster.</p>","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":"<p>Works well. </p> <p>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 <code>.context/</code> files are rare and easy to resolve (they are just Markdown).</p>","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":"<p><code>ctx</code> operates per repository.</p> <p>Each repo has its own <code>.context/</code> directory with its own decisions, tasks, and learnings. This matches the way code, ownership, and history already work in <code>git</code>.</p> <p>There is no built-in cross-repo context layer.</p> <p>For organizations that need centralized, organization-wide knowledge, <code>ctx</code> complements a platform solution by providing durable, project-local working memory for AI sessions.</p>","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#5-minute-trial","level":2,"title":"5-Minute Trial","text":"<p>Zero commitment. Try it, and delete <code>.context/</code> if it's not for you.</p> <p>Using Claude Code?</p> <p>Install the <code>ctx</code> plugin from the Marketplace for Claude-native hooks, skills, and automatic context loading:</p> <ol> <li>Type <code>/plugin</code> and press Enter</li> <li>Select Marketplaces → Add Marketplace</li> <li>Enter <code>ActiveMemory/ctx</code></li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code></li> </ol> <p>You'll still need the <code>ctx</code> binary for the CLI: See Getting Started for install options.</p> <pre><code># 1. Initialize\ncd your-project\nctx init\n\n# 2. 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# 3. Check what the AI will see\nctx status\n\n# 4. Start an AI session and ask: \"Do you remember?\"\n</code></pre> <p>If the AI cites your decision back to you, it's working.</p> <p>Want to remove it later? One command:</p> <pre><code>rm -rf .context/\n</code></pre> <p>No dependencies to uninstall. No configuration to revert. Just files.</p> <p>Ready to try it out?</p> <ul> <li>Join the Community→: Open Source is better together.</li> <li>Getting Started →: Full installation and setup.</li> <li><code>ctx</code> and Similar Tools →: Detailed comparison with other approaches.</li> </ul>","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/joining-a-project/","level":1,"title":"Joining a Project","text":"<p>You've joined a team or inherited a project, and there's a <code>.context/</code> directory in the repo. Good news: someone already set up persistent context. This page gets you oriented fast.</p>","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":"<p>The files in <code>.context/</code> have a deliberate priority order. Read them top-down:</p> <ol> <li>CONSTITUTION.md: Hard rules. Read this before you touch anything. These are inviolable constraints the team has agreed on.</li> <li>TASKS.md: Current and planned work. Shows what's in progress, what's pending, and what's blocked.</li> <li>CONVENTIONS.md: How the team writes code. Naming patterns, file organization, preferred idioms.</li> <li>ARCHITECTURE.md: System overview. Components, boundaries, data flow.</li> <li>DECISIONS.md: Why things are the way they are. Saves you from re-proposing something the team already evaluated and rejected.</li> <li>LEARNINGS.md: Gotchas, tips, and hard-won lessons. The stuff that doesn't fit anywhere else but will save you hours.</li> </ol> <p>See Context Files for detailed documentation of each file's structure and purpose.</p>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#checking-context-health","level":2,"title":"Checking Context Health","text":"<p>Before you start working, check whether the context is current:</p> <pre><code>ctx status\n</code></pre> <p>This shows file counts, token estimates, and recent activity. If files haven't been touched in weeks, the context may be stale.</p> <pre><code>ctx drift\n</code></pre> <p>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.</p> <p>If things are stale, mention it to the team. Don't silently fix it yourself on day one.</p>","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":"<p>Generate a context packet to prime your AI:</p> <pre><code>ctx agent --budget 8000\n</code></pre> <p>This outputs a token-budgeted summary of the project context, ordered by priority. With Claude Code and the <code>ctx</code> plugin, context loads automatically via hooks. You can also use the <code>/ctx-remember</code> skill to get a structured readback of what the AI knows.</p> <p>The readback is your verification step: if the AI can cite specific tasks and decisions, the context is working.</p>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#adding-context","level":2,"title":"Adding Context","text":"<p>As you work, you'll discover things worth recording. Use the CLI:</p> <pre><code># 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</code></pre> <p>You can also just tell the AI: \"Record this as a learning\" or \"Add this decision to context.\" With the <code>ctx</code> plugin, context-update commands handle the file writes.</p> <p>See the Knowledge Capture recipe for the full workflow.</p>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#session-etiquette","level":2,"title":"Session Etiquette","text":"<p>A few norms for working in a ctx-managed project:</p> <ul> <li>Respect existing conventions. If <code>CONVENTIONS.md</code> says \"use <code>filepath.Join</code>,\" use <code>filepath.Join</code>. If you disagree, propose a change, don't silently diverge.</li> <li>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.</li> <li>Mark tasks done when complete. Check the box (<code>[x]</code>) in place. Don't move tasks between sections or delete them.</li> <li>Add context as you go. Decisions, learnings, and conventions you discover are valuable to the next person (or the next session).</li> </ul>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"<p>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.</p> <p>Deleting tasks. Never delete a task from TASKS.md. Mark it <code>[x]</code> (done) or <code>[-]</code> (skipped with a reason). The history matters for session replay and audit.</p> <p>Bypassing hooks. If the project uses <code>ctx</code> 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.</p> <p>Over-contributing on day one. Read first, then contribute. Adding a dozen learnings before you understand the project's norms creates noise, not signal.</p> <p>Related:</p> <ul> <li>Getting Started: installation and setup from scratch</li> <li>Context Files: detailed file reference</li> <li>Knowledge Capture: recording decisions, learnings, and conventions</li> <li>Session Lifecycle: how a typical AI session flows with <code>ctx</code></li> </ul>","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":"<p>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.</p> <p>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.</p> <p><code>ctx</code> replaces vibes with verifiable artifacts.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#grounded-memory","level":2,"title":"Grounded Memory","text":"<p>Every entry in <code>ctx</code> context files has a timestamp and structured fields. When the AI cites a decision, you can check it.</p> <pre><code>## [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</code></pre> <p>The timestamp <code>2026-01-28-143022</code> 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.</p> <p>This is grounded memory: claims that trace back to artifacts you control and can audit.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#constitutionmd-hard-guardrails","level":2,"title":"<code>CONSTITUTION.md</code>: Hard Guardrails","text":"<p>CONSTITUTION.md defines rules the AI must treat as inviolable. These are not suggestions or best practices - they are constraints that override task requirements.</p> <pre><code># 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</code></pre> <p>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.</p>","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":"<p>The AGENT_PLAYBOOK.md file includes a section called \"How to Avoid Hallucinating Memory\" with five explicit rules:</p> <ol> <li>Never assume. If it is not in the context files, you do not know it.</li> <li>Never invent history. Do not claim \"we discussed\" something without a file reference.</li> <li>Verify before referencing. Search files before citing them.</li> <li>When uncertain, say so. \"I don't see a decision on this\" is always better than a fabricated one.</li> <li>Trust files over intuition. If the files say PostgreSQL but your training data suggests MySQL, the files win.</li> </ol> <p>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.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#drift-detection","level":2,"title":"Drift Detection","text":"<p>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.</p> <p><code>ctx drift</code> detects this divergence:</p> <pre><code>ctx drift\n</code></pre> <p>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.</p> <p>Regular drift checks - weekly, or after major refactors - keep your context files honest the same way tests keep your code honest.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-verification-loop","level":2,"title":"The Verification Loop","text":"<p>The <code>/ctx-commit</code> 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.</p> <p>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.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#trust-through-structure","level":2,"title":"Trust through Structure","text":"<p>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.</p> <p>You do not need to trust the AI. You need to trust the system -- and verify when it matters.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Detecting and Fixing Drift: the full workflow for keeping context files accurate</li> <li>Invariants: the properties that must hold for any valid <code>ctx</code> implementation</li> <li>Agent Security: threat model and mitigations for AI agents operating with persistent context</li> </ul>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/opencode/","level":1,"title":"ctx for OpenCode","text":"","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#the-problem","level":2,"title":"The Problem","text":"<p>Every OpenCode session starts from zero. You re-explain your architecture, the AI repeats mistakes it made yesterday, and decisions get rediscovered instead of remembered.</p> <p>Without <code>ctx</code>:</p> <pre><code>> \"Add the validation middleware we discussed\"\n\nI don't have context about previous discussions. Could you describe\nwhat validation middleware you're referring to?\n</code></pre> <p>With <code>ctx</code>:</p> <pre><code>> \"Add the validation middleware we discussed\"\n\nYes. From the Jan 15 session. You decided on Zod schemas at the\nroute level (DECISIONS.md #12), and the pattern is in\nCONVENTIONS.md. I'll follow the existing middleware in\nsrc/middleware/auth.ts as a reference.\n</code></pre> <p>That's the whole pitch: your AI remembers.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#setup-one-command","level":2,"title":"Setup (One Command)","text":"<p>Install the <code>ctx</code> binary first (installation docs), then run from your project root:</p> <pre><code>ctx setup opencode --write && ctx init\n</code></pre> <p>This does two things:</p> <ol> <li><code>ctx setup opencode --write</code>: generates the project-local OpenCode plugin, skills, and <code>AGENTS.md</code>, then merges the <code>ctx</code> MCP server into OpenCode's global config (<code>~/.config/opencode/opencode.json</code> or <code>$OPENCODE_HOME/opencode.json</code>). This writes outside the project root because non-interactive shells (like MCP subprocesses) cannot discover project-local config; the same reason the Copilot CLI integration writes to <code>~/.copilot/mcp-config.json</code>.</li> <li><code>ctx init</code>: creates the <code>.context/</code> directory with template files.</li> </ol>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#what-gets-created","level":3,"title":"What Gets Created","text":"File Purpose <code>.opencode/plugins/ctx.ts</code> Lifecycle plugin (hooks into <code>ctx system</code> commands) <code>~/.config/opencode/opencode.json</code> Global MCP server registration (or <code>$OPENCODE_HOME/opencode.json</code>) <code>AGENTS.md</code> Agent instructions (OpenCode reads this natively) <code>.opencode/skills/ctx-*/SKILL.md</code> Slash command skills <p>The plugin is a single file with no runtime dependencies; no <code>bun install</code> or <code>npm install</code> needed. OpenCode loads it automatically on launch.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#what-happens-automatically","level":2,"title":"What Happens Automatically","text":"<p>The plugin wires OpenCode lifecycle events to <code>ctx</code>. You don't need to do anything; it just works.</p> Event What fires What it does New session <code>session.created</code> Warms <code>ctx</code> state in the background (bootstrap + agent packet) so MCP queries are fast on first use Agent idle <code>session.idle</code> Runs persistence and task-completion checks (silent: output is buffered, not surfaced to the TUI) After <code>git commit</code> <code>tool.execute.after</code> Runs <code>ctx system post-commit</code> to capture context state After file edit <code>tool.execute.after</code> Runs <code>ctx system check-task-completion</code> to detect silent task completions Every shell call <code>shell.env</code> Ensures the agent's shell <code>cd</code>s to the project root so all <code>ctx</code> commands resolve to the right project Context compaction <code>experimental.session.compacting</code> Pushes <code>ctx system bootstrap</code> output into the compaction context so the agent retains breadcrumbs to re-read context files post-compaction <p>The compaction hook matters most. When OpenCode compresses your context window to free up tokens, the plugin makes sure the compressed summary includes a pointer back to your <code>.context/</code> directory and its file inventory, so the agent can re-read tasks, decisions, and learnings on demand, even though the original messages are gone.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#how-compaction-works","level":3,"title":"How Compaction Works","text":"<p>When your conversation exceeds the context window, OpenCode runs a compaction pass (you can trigger one manually with <code>/compact</code>). The compaction agent summarizes older messages and drops the originals. Without <code>ctx</code>, all accumulated knowledge disappears. With <code>ctx</code>, the plugin intercepts the <code>experimental.session.compacting</code> event and appends <code>ctx system bootstrap</code> output (context directory path and file inventory) into the compaction context. The result: the compressed summary retains the breadcrumbs the agent needs to re-read tasks, decisions, learnings, and conventions on demand, even though the original messages that loaded them are gone.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#what-is-not-included","level":3,"title":"What Is Not Included","text":"<p>Note: dangerous-command blocking is Claude Code-specific and is not part of the OpenCode integration. OpenCode's execution model (explicit user approval for every shell command) makes a pre-execution blocklist unnecessary.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#slash-commands","level":2,"title":"Slash Commands","text":"<p>Four skills are available as slash commands:</p> Command When to use <code>/ctx-agent</code> Load full context packet. Use at session start or when context feels stale. <code>/ctx-remember</code> \"Do you remember?\"; reads tasks, decisions, learnings, and recent journal entries. Returns a structured readback. <code>/ctx-status</code> Context summary at a glance: file count, token estimate, recent activity. <code>/ctx-wrap-up</code> End-of-session ceremony. Captures learnings, decisions, conventions, and outstanding tasks to <code>.context/</code> files. <p>You don't need to use these often. The plugin handles most context loading automatically. These are for when you want explicit control.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#mcp-tools","level":2,"title":"MCP Tools","text":"<p>The <code>ctx</code> MCP server exposes tools directly to the agent. These let the AI read and write your context files without shell commands:</p> Tool Purpose <code>ctx_add</code> Add a task, decision, learning, or convention <code>ctx_complete</code> Mark a task done by number or text match <code>ctx_search</code> Full-text search across all <code>.context/</code> files <code>ctx_next</code> Suggest the next pending task by priority <code>ctx_drift</code> Detect stale context: dead paths, missing files <code>ctx_compact</code> Archive completed tasks, clean empty sections <code>ctx_remind</code> List pending session-scoped reminders <code>ctx_status</code> Context health: file count, token estimate <code>ctx_steering_get</code> Retrieve steering files applicable to the current prompt <code>ctx_journal_source</code> Query recent AI session history <code>ctx_sessionevent</code> Signal session start/end lifecycle events <code>ctx_watch_update</code> Apply structured updates to <code>.context/</code> files <code>ctx_checktaskcompletion</code> After a write, detect silently completed tasks <p>You don't invoke these yourself. The agent uses them as needed.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#refreshing-the-integration","level":2,"title":"Refreshing the Integration","text":"<p>If you re-run <code>ctx setup opencode --write</code> (e.g., after updating <code>ctx</code>), the plugin and skills are rewritten in place. Restart OpenCode to pick up the refreshed plugin. OpenCode only loads plugins at launch, not mid-session.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#troubleshooting","level":2,"title":"Troubleshooting","text":"Symptom Cause Fix <code>opencode mcp list</code> shows <code>ctx ✗ failed MCP error -32000: Connection closed</code> MCP subprocess started outside the project root Re-run <code>ctx setup opencode --write</code> to regenerate the sh-wrapper that <code>cd</code>s to the project root before invoking <code>ctx</code> Plugin installed but no hooks fire Flat-file vs. subdirectory discovery mismatch (OpenCode requires <code>.opencode/plugins/<name>.ts</code>, not a subfolder) Verify the plugin is at <code>.opencode/plugins/ctx.ts</code>. Check with <code>opencode --print-logs --log-level DEBUG</code> <code>ctx agent</code> Markdown leaking into the TUI BunShell command missing <code>.nothrow().quiet()</code> Update to the latest plugin: <code>ctx setup opencode --write</code> and restart","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#verify-it-works","level":2,"title":"Verify It Works","text":"<p>Start a new OpenCode session and ask:</p> <pre><code>Do you remember?\n</code></pre> <p>The AI should cite specific context: current tasks, recent decisions, or previous session topics. If it says \"I don't have memory\" or \"Let me check,\" something went wrong; check that the plugin installed correctly and <code>.context/</code> has files in it.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#whats-next","level":2,"title":"What's Next","text":"<ul> <li>Your First Session: step-by-step walkthrough from <code>ctx init</code> to verified recall.</li> <li>Common Workflows: day-to-day commands for tracking context, checking health, and browsing history.</li> <li>Context Files: what lives in <code>.context/</code> and how each file is used.</li> </ul>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/prompting-guide/","level":1,"title":"Prompting Guide","text":"<p>New to <code>ctx</code>?</p> <p>This guide references context files like <code>TASKS.md</code>, <code>DECISIONS.md</code>, and <code>LEARNINGS.md</code>:</p> <p>These are plain Markdown files that <code>ctx</code> maintains in your project's <code>.context/</code> directory.</p> <p>If terms like \"context packet\" or \"session ceremony\" are unfamiliar,</p> <ul> <li>start with the <code>ctx</code> Manifesto for the why,</li> <li>About for the big picture,</li> <li>then Getting Started to set up your first project.</li> </ul>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#literature-matters","level":2,"title":"Literature Matters","text":"<p>This guide is about crafting effective prompts for working with AI assistants in <code>ctx</code>-enabled projects, but the guidelines given here apply to other AI systems, too.</p> <p>The right prompt triggers the right behavior. </p> <p>This guide documents prompts that reliably produce good results.</p>","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 <code>/ctx-next</code> Debug \"Why doesn't X work?\" Validate \"Is this consistent with our decisions?\" Impact analysis \"What would break if we...\" Reflect <code>/ctx-reflect</code> Wrap up <code>/ctx-wrap-up</code> 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 <code>ctx drift</code>\" Commit <code>/ctx-commit</code>","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":"<p>Triggers the AI to silently read <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, and check recent history via <code>ctx journal</code> before responding with a structured readback:</p> <ol> <li>Last session: most recent session topic and date</li> <li>Active work: pending or in-progress tasks</li> <li>Recent context: 1-2 recent decisions or learnings</li> <li>Next step: offer to continue or ask what to focus on</li> </ol> <p>Use this at the start of every important session.</p> <pre><code>Do you remember what we were working on?\n</code></pre> <p>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.</p> <p>If the AI instead narrates its discovery process (\"Let me check if there are files...\"), it has not loaded <code>CLAUDE.md</code> or <code>AGENT_PLAYBOOK.md</code> properly.</p> <p>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.</p>","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":"<p>Prompts reading of <code>TASKS.md</code>, recent sessions, and status overview.</p> <p>Use this when resuming work after a break.</p> <p>Variants:</p> <ul> <li>\"Where did we leave off?\"</li> <li>\"What's in progress?\"</li> <li>\"Show me the open tasks.\"</li> </ul>","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":"<p>This triggers root cause analysis rather than surface-level fixes.</p> <p>Use this when something fails unexpectedly.</p> <p>Framing as \"why\" encourages investigation before action. The AI will trace through code, check configurations, and identify the actual cause.</p> <p>Real Example</p> <p>\"Why can't I run /ctx-reflect?\" led to discovering missing permissions in <code>settings.local.json</code> bootstrapping.</p> <p>This was a fix that benefited all users of <code>ctx</code>.</p>","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":"<p>This prompts checking <code>DECISIONS.md</code> before implementing.</p> <p>Use this before making architectural choices.</p> <p>Variants:</p> <ul> <li>\"Check if we've decided on this before\"</li> <li>\"Does this align with our conventions?\"</li> </ul>","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":"<p>This triggers defensive thinking and impact analysis.</p> <p>Use this before making significant changes.</p> <pre><code>What would break if we change the Settings struct?\n</code></pre>","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":"<p>This ensures specific context is loaded before work begins.</p> <p>Use this when you know the relevant context exists in a specific file.</p> <pre><code>Before you start, check ctx journal source for the auth discussion session\n</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-control","level":3,"title":"Scope Control","text":"<p>Constrain the AI to prevent sprawl. These are some of the most useful prompts in day-to-day work.</p> <pre><code>Only change files in internal/cli/add/. Nothing else.\n</code></pre> <pre><code>No new files. Modify the existing implementation.\n</code></pre> <pre><code>Keep the public API unchanged. Internal refactor only.\n</code></pre> <p>Use these when the AI tends to \"helpfully\" modify adjacent code, add documentation you didn't ask for, or create new abstractions.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#course-correction","level":3,"title":"Course Correction","text":"<p>Steer the AI when it goes off-track: Don't wait for it to finish a wrong approach.</p> <pre><code>Stop! That's not what I meant. Let me clarify.\n</code></pre> <pre><code>Let's step back. Explain what you're about to do before changing anything.\n</code></pre> <pre><code>Undo that last change and try a different approach.\n</code></pre> <p>These work because they interrupt momentum.</p> <p>Without explicit course correction, the AI tends to commit harder to a wrong path rather than reconsidering.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#failure-modes","level":3,"title":"Failure Modes","text":"<p>When the AI misbehaves, match the symptom to the recovery prompt:</p> 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.\" <p>These are recovery handles, not rules to paste into <code>CLAUDE.md</code>.</p> <p>Use them in the moment when you see the behavior.</p>","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":"<p>This prompts reflection on the session and often triggers adding learnings to <code>LEARNINGS.md</code>.</p> <p>Use this after completing a task or debugging session.</p> <p>This is an explicit reflection prompt. The AI will summarize insights and often offer to persist them.</p>","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":"<p>This is an explicit persistence request.</p> <p>Use this when you have discovered something worth remembering.</p> <pre><code>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</code></pre>","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":"<p>This triggers context persistence before the session closes.</p> <p>Use it at the end of the session or before switching topics.</p> <p>Variants:</p> <ul> <li>\"Let's persist what we did\"</li> <li>\"Update the context files\"</li> <li><code>/ctx-wrap-up</code>:the recommended end-of-session ceremony (see Session Ceremonies)</li> <li><code>/ctx-reflect</code>: mid-session reflection checkpoint</li> </ul>","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":"<p>This triggers thorough codebase search rather than guessing.</p> <p>Use this when you need to understand how something works.</p> <p>This works because \"Explore\" signals that investigation is needed, not immediate action.</p>","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":"<p>This prompts reading actual code rather than explaining general concepts.</p> <p>Use this to understand the existing implementation.</p> <pre><code>How does session saving work in this codebase?\n</code></pre>","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":"<p>This triggers a comprehensive search across the codebase.</p> <p>Use this before refactoring or understanding the impact.</p>","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":"<p>This prompts identifying learnings, decisions, and conventions worth persisting.</p> <p>Use this after complex discussions or implementations.</p>","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":"<p>This invites the AI to challenge the current direction.</p> <p>Use this when you want a sanity check.</p> <p>This works because it allows AI to disagree.</p> <p>AIs often default to agreeing; this prompt signals you want an honest assessment.</p> <p>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.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-am-i-missing","level":3,"title":"\"What Am I Missing?\"","text":"<p>This prompts thinking about edge cases, overlooked requirements, or unconsidered approaches.</p> <p>Use this before finalizing a design or implementation.</p> <p>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.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#cli-commands-as-prompts","level":2,"title":"CLI Commands as Prompts","text":"<p>Asking the AI to run <code>ctx</code> commands is itself a prompt. These load context or trigger specific behaviors:</p> Command What it does \"Run <code>ctx status</code>\" Shows context summary, file presence, staleness \"Run <code>ctx agent</code>\" Loads token-budgeted context packet \"Run <code>ctx drift</code>\" Detects dead paths, stale files, missing context","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ctx-skills","level":3,"title":"<code>ctx</code> Skills","text":"<p>The <code>SKILS.md</code> Standard</p> <p>Skills are formalized prompts stored as <code>SKILL.md</code> files.</p> <p>The <code>/slash-command</code> syntax below is Claude Code specific. </p> <p>Other agents can use the same skill files, but invocation may differ. </p> <p>Use <code>ctx</code> skills by name:</p> Skill When to use <code>/ctx-status</code> Quick context summary <code>/ctx-agent</code> Load full context packet <code>/ctx-remember</code> Recall project context and structured readback <code>/ctx-wrap-up</code> End-of-session context persistence <code>/ctx-history</code> Browse session history for past discussions <code>/ctx-reflect</code> Structured reflection checkpoint <code>/ctx-next</code> Suggest what to work on next <code>/ctx-commit</code> Commit with context persistence <code>/ctx-drift</code> Detect and fix context drift <code>/ctx-implement</code> Execute a plan step-by-step with verification <code>/ctx-loop</code> Generate autonomous loop script <code>/ctx-pad</code> Manage encrypted scratchpad <code>/ctx-archive</code> Archive completed tasks <code>/check-links</code> Audit docs for dead links <p>Ceremony vs. Workflow Skills</p> <p>Most skills work conversationally: \"what should we work on?\" triggers <code>/ctx-next</code>, \"save that as a learning\" triggers <code>/ctx-learning-add</code>. Natural language is the recommended approach.</p> <p>Two skills are the exception: <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> are ceremony skills for session boundaries: Invoke them as explicit slash commands: conversational triggers risk partial execution. See Session Ceremonies.</p> <p>Skills combine a prompt, tool permissions, and domain knowledge into a single invocation.</p> <p>Skills beyond Claude Code</p> <p>The <code>/slash-command</code> syntax above is Claude Code native, but the underlying <code>SKILL.md</code> 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.</p> <p>See Integrations for setup details.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#anti-patterns","level":2,"title":"Anti-Patterns","text":"<p>Based on our <code>ctx</code> development experience (i.e., \"sipping our own champagne\") so far, here are some prompts that tend to produce poor results:</p> 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":"<p>Before sending a non-trivial prompt, check these four elements. This is the guide's DNA in one screenful.</p> <ol> <li>Goal in one sentence: What does \"done\" look like?</li> <li>Files to read: What existing code or context should the AI review before acting?</li> <li>Verification command: How will you prove it worked? (test name, CLI command, expected output)</li> <li>Scope boundary: What should the AI not touch?</li> </ol> <p>A prompt that covers all four is almost always good enough.</p> <p>A prompt missing <code>#3</code> is how you get \"should work now\" without evidence.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#safety-invariants","level":2,"title":"Safety Invariants","text":"<p>These Are Invariants: Not Suggestions</p> <p>A prompting guide earns its trust by being honest about risk.</p> <p>These four rules mentioned below don't change with model versions, agent frameworks, or project size.</p> <p>Build them into your workflow once and stop thinking about them.</p> <p>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.</p> <p>These invariants apply regardless of which agent or model you use.</p>","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":"<p>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.</p> <p>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.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ask-before-destructive-operations","level":3,"title":"Ask Before Destructive Operations","text":"<p><code>git push --force</code>, <code>rm -rf</code>, <code>DROP TABLE</code>, <code>docker system prune</code>: these are irreversible or hard to reverse. A good agent should pause before running them, but don't rely on that.</p> <p>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.\"</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-the-blast-radius","level":3,"title":"Scope the Blast Radius","text":"<p>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.</p> <p>The rule: Constrain scope before starting work. The Reliability Checklist's scope boundary (<code>#4</code>) is your primary safety lever. When in doubt, err on the side of a tighter boundary.</p>","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":"<p><code>LEARNINGS.md</code>, <code>DECISIONS.md</code>, and session transcripts are plain-text files that may be committed to version control.</p> <p>Don't persist API keys, passwords, tokens, or credentials in context files.</p> <p>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. </p> <p>Any Secret Seen IS Exposed</p> <p>If you see a secret in a context file, remove it immediately and rotate the credential.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#explore-plan-implement","level":2,"title":"Explore → Plan → Implement","text":"<p>For non-trivial work, name the phase you want:</p> <pre><code>Explore src/auth and summarize the current flow.\nThen propose a plan. After I approve, implement with tests.\n</code></pre> <p>This prevents the AI from jumping straight to code. </p> <p>The three phases map to different modes of thinking:</p> <ul> <li>Explore: read, search, understand: no changes</li> <li>Plan: propose approach, trade-offs, scope: no changes</li> <li>Implement: write code, run tests, verify: changes</li> </ul> <p>Small fixes skip straight to implement. Complex or uncertain work benefits from all three.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#prompts-by-task-type","level":2,"title":"Prompts by Task Type","text":"<p>Different tasks need different prompt structures. The pattern: symptom + location + verification.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#bugfix","level":3,"title":"Bugfix","text":"<pre><code>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</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#refactor","level":3,"title":"Refactor","text":"<pre><code>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</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#research","level":3,"title":"Research","text":"<pre><code>Explore the request flow around src/api/.\nSummarize likely bottlenecks with evidence.\nPropose 2-3 hypotheses. Do not implement yet.\n</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#docs","level":3,"title":"Docs","text":"<pre><code>Update docs/cli-reference.md to reflect the new --format flag.\nConfirm the flag exists in the code and the example works.\n</code></pre> <p>Notice each prompt includes what to verify and how. Without that, you get a \"should work now\" instead of evidence.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#writing-tasks-as-prompts","level":2,"title":"Writing Tasks as Prompts","text":"<p>Tasks in <code>TASKS.md</code> are indirect prompts to the AI. How you write them shapes how the AI approaches the work.</p>","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":"<p>Tell the AI why you are building something, not just what.</p> <p>Bad: \"Build a calendar view.\"</p> <p>Good: \"Build a calendar view. The motivation is that all notes and tasks we build later should be viewable here.\"</p> <p>The second version lets the AI anticipate downstream requirements:</p> <p>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.</p>","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":"<p>Bad task (implementation-focused): <pre><code>- [ ] T1.1.0: Parser system\n - [ ] Define data structures\n - [ ] Implement line parser\n - [ ] Implement session grouper\n</code></pre></p> <p>The AI may complete all subtasks but miss the actual goal. What does \"Parser system\" deliver to the user?</p> <p>Good task (deliverable-focused): <pre><code>- [ ] 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</code></pre></p> <p>Now the AI knows the subtasks serve a specific user-facing deliverable.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#use-acceptance-criteria","level":3,"title":"Use Acceptance Criteria","text":"<p>For complex tasks, add explicit \"done when\" criteria:</p> <pre><code>- [ ] 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</code></pre> <p>This prevents premature \"task complete\" when only the implementation details are done, but the feature doesn't actually work.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#subtasks-parent-task","level":3,"title":"Subtasks ≠ Parent Task","text":"<p>Completing all subtasks does not mean the parent task is complete.</p> <p>The parent task describes what the user gets.</p> <p>Subtasks describe how to build it.</p> <p>Always re-read the parent task description before marking it complete. Verify the stated deliverable exists and works.</p>","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":"<p>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.</p> <p>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.</p> <p>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).</p> <p>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).</p> <p>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).</p> <p>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).</p> <p>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.</p> <p>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.</p> <p>CLI commands as prompts (\"Run <code>ctx status</code>\") 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).</p> <p>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).</p> <p>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).</p> <p>Session reflection (\"What did we learn?\", <code>/ctx-reflect</code>) is a form of verbal reinforcement learning: Improving future performance by persisting linguistic feedback as memory rather than updating weights. This is exactly what <code>LEARNINGS.md</code> and <code>DECISIONS.md</code> provide: a durable feedback signal across sessions. Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning (2023).</p> <p>These aren't prompting \"hacks\" that you will find in the \"1000 AI Prompts for the Curious\" listicles: They are applications of foundational principles:</p> <ul> <li>Decomposition,</li> <li>Abstraction,</li> <li>Ensemble Reasoning,</li> <li>Search,</li> <li>and Constrained Optimization.</li> </ul> <p>They work because language models are, at their core, optimization systems navigating probabilistic landscapes.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>The Attention Budget: Why your AI forgets what you just told it, and how token budgets shape context strategy</li> <li>The Dog Ate My Homework: A case study in making agents follow instructions: attention timing, delegation decay, and observable compliance as a design goal</li> </ul>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#contributing","level":2,"title":"Contributing","text":"<p>Found a prompt that works well? Open an issue or PR with:</p> <ol> <li>The prompt text;</li> <li>What behavior it triggers;</li> <li>When to use it;</li> <li>Why it works (optional but helpful).</li> </ol> <p>Dive Deeper:</p> <ul> <li>Recipes: targeted how-to guides for specific tasks</li> <li>CLI Reference: all commands and flags</li> <li>Integrations: setup for Claude Code, Cursor, Aider</li> </ul>","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":"<p>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.</p> <p>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.</p> <p>This is not a model problem. It is a memory problem. Without persistent context, every session starts with amnesia.</p>","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 <code>ctx</code> Stops the Loop","text":"<p><code>ctx</code> gives your AI three files that directly prevent repeated mistakes, each targeting a different failure mode.</p>","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":"<code>DECISIONS.md</code>: Stop Relitigating Settled Choices","text":"<p>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.</p> <pre><code>## [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</code></pre> <p>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.</p>","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#learningsmd-capture-gotchas-once","level":3,"title":"<code>LEARNINGS.md</code>: Capture Gotchas Once","text":"<p>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.</p> <pre><code>## 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</code></pre> <p>Without this entry, the next session that touches the Dockerfile will hit the same wall. With it, the AI knows before it starts.</p>","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#constitutionmd-draw-hard-lines","level":3,"title":"<code>CONSTITUTION.md</code>: Draw Hard Lines","text":"<p>Some mistakes are not about forgetting - they are about boundaries the AI should never cross. CONSTITUTION.md sets inviolable rules.</p> <pre><code>* [ ] 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</code></pre> <p>The AI reads these as absolute constraints. It does not weigh them against convenience. It refuses tasks that would violate them.</p>","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":"<p>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.</p> <p>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.</p> <p>The key insight: you are not just coding. You are building a knowledge layer that makes every future session faster.</p> <p><code>ctx</code> files version with your code in git. They survive branch switches, team changes, and model upgrades. The context outlives any single session.</p>","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":"<p>Capture your first decision or learning right now:</p> <pre><code>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</code></pre>","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":"<ul> <li>Knowledge Capture: the full workflow for persisting decisions, learnings, and conventions</li> <li>Context Files Reference: structure and format for every file in <code>.context/</code></li> <li>About <code>ctx</code>: the bigger picture - why persistent context changes how you work with AI</li> </ul>","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":"<p><code>ctx</code> 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.</p> <p>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.\" <code>ctx</code> manages those files in <code>.context/steering/</code>, 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.</p>","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":"<p>The three look similar on disk but serve different purposes:</p> Kind Purpose Decisions (<code>DECISIONS.md</code>) What was chosen and why Conventions (<code>CONVENTIONS.md</code>) How the codebase is written Steering (<code>.context/steering/*.md</code>) How the AI should behave on matching prompts <p>If you find yourself writing \"the AI should always do X when asked about Y,\" that belongs in steering, not decisions.</p>","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#your-first-steering-files","level":2,"title":"Your First Steering Files","text":"<p><code>ctx init</code> scaffolds four foundation steering files in <code>.context/steering/</code> so you start with something to edit rather than an empty directory:</p> File What to fill in <code>product.md</code> What the project is, who it's for, what's out of scope <code>tech.md</code> Languages, frameworks, runtime, hard constraints <code>structure.md</code> Directory layout, where new files go, naming rules <code>workflow.md</code> Branch strategy, commit conventions, pre-commit checks <p>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.</p> <p>Default settings for foundation files:</p> <ul> <li><code>inclusion: always</code>: fires on every AI tool call</li> <li><code>priority: 10</code>: injected near the top of the prompt</li> <li><code>tools: []</code>: applies to every configured AI tool</li> </ul> <p>You should open each of these files and replace the placeholder content with your project's actual rules. Re-running <code>ctx init</code> is safe: existing files are left alone, so your edits survive. Use <code>ctx init --no-steering-init</code> to opt out of the scaffold entirely.</p>","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#inclusion-modes","level":2,"title":"Inclusion Modes","text":"<p>Each steering file declares an inclusion mode in its frontmatter:</p> Mode When the file is included <code>always</code> Every prompt, unconditionally <code>auto</code> When the prompt keywords match the file's description <code>manual</code> Only when the user explicitly names the file <p>Which mode to pick depends on the AI tool you use, because the two tool families consume steering very differently.</p> <p>Claude Code and Codex: prefer <code>inclusion: always</code> for rules that must fire reliably. These tools have two delivery channels:</p> <ol> <li>The plugin's <code>PreToolUse</code> hook runs <code>ctx agent</code> with an empty prompt, so only <code>always</code> files match and get injected automatically on every tool call.</li> <li>The <code>ctx_steering_get</code> MCP tool, registered automatically when the <code>ctx</code> plugin is installed. Claude can call this tool mid-task to fetch <code>auto</code> or <code>manual</code> files matching a specific prompt. Verify with <code>claude mcp list</code>; look for <code>ctx: ✓ Connected</code>.</li> </ol> <p>Use <code>always</code> for invariants and anything that must fire every session. Use <code>auto</code> 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 <code>manual</code> for reference libraries you'll name explicitly.</p> <p>Cursor, Cline, Kiro: <code>auto</code> is the natural default. These tools read <code>.cursor/rules/</code>, <code>.clinerules/</code>, or <code>.kiro/steering/</code> natively and resolve the description match on their own, so <code>auto</code> files fire when the prompt matches. <code>manual</code> files load on explicit invocation. <code>always</code> still works but consumes context budget on every turn.</p> <p>Mixed setups: if a rule must fire on Claude Code, pick <code>always</code>, even if it's overkill for your Cursor setup. The context budget cost is small; the alternative (silently not firing) is worse.</p>","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":"<p>Not every AI tool consumes steering the same way. <code>ctx</code> 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.</p> <p>Native-rules tools (Cursor, Cline, Kiro) have a built-in rules primitive. They read a specific directory (<code>.cursor/rules/</code>, <code>.clinerules/</code>, <code>.kiro/steering/</code>) and apply the rules they find there. <code>ctx</code> handles these via <code>ctx steering sync</code>, which exports your files into the tool-native format. Run <code>sync</code> whenever you edit a steering file.</p> <p>Hook + MCP tools (Claude Code, Codex) have no native rules primitive, so <code>ctx steering sync</code> is a no-op for them. Instead, <code>ctx</code> delivers steering through two non-sync channels:</p> <ol> <li>Automatic injection via a <code>PreToolUse</code> hook. The <code>ctx setup claude-code</code> plugin wires a hook that runs <code>ctx agent --budget 8000</code> before each tool call. <code>ctx agent</code> 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.</li> <li>On-demand via the <code>ctx_steering_get</code> MCP tool. The <code>ctx</code> 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.</li> </ol> <p>Both channels activate when you run <code>ctx setup claude-code --write</code>. After that, steering just works for Claude Code.</p> <p>Practical takeaway:</p> <ul> <li>Using Cursor/Cline/Kiro only? Run <code>ctx steering sync</code> after edits.</li> <li>Using Claude Code or Codex only? Never run <code>sync</code>; the hook+MCP pipeline handles it.</li> <li>Using both? Run <code>sync</code> for the native-rules tools; the hook+MCP pipeline covers Claude Code automatically.</li> </ul>","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":"<p>Steering is one of two hook-like layers <code>ctx</code> provides for customizing AI behavior. They're complementary:</p> <ul> <li>Steering: persistent rules that get prepended to prompts. Declarative, text-only, scored by match.</li> <li>Triggers: executable shell scripts that fire at lifecycle events. Imperative, runs arbitrary code, gated by exit codes.</li> </ul> <p>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.</p>","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#where-to-go-next","level":2,"title":"Where to Go Next","text":"<ul> <li>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.</li> <li><code>ctx steering</code> 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.</li> <li><code>ctx setup</code>: 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 <code>PreToolUse</code> hook and MCP server.</li> <li>Lifecycle Triggers: the imperative companion to steering files.</li> </ul>","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":"<p>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.</p> <p>A trigger is an executable shell script that <code>ctx</code> 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.</p>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#trigger-types","level":2,"title":"Trigger Types","text":"Type Fires when Use case <code>session-start</code> A new AI session begins Inject rotating context, standup notes <code>session-end</code> An AI session ends Persist summaries, send notifications <code>pre-tool-use</code> Before a tool call executes Block, gate, or audit <code>post-tool-use</code> After a tool call completes Log, react, post-process <code>file-save</code> A file is saved Lint on save, update indices <code>context-add</code> A new entry is added to <code>.context/</code> 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":"<p>Only Enable Scripts You've Read and Understand</p> <p>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.</p> <p><code>ctx trigger add</code> intentionally creates new scripts disabled (no executable bit). You must <code>ctx trigger enable <name></code> after reviewing the contents. That's not a suggestion; it's the security model.</p>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#three-hook-like-layers-in-ctx","level":2,"title":"Three Hook-like Layers in <code>ctx</code>","text":"<p>Triggers are one of three distinct hook-like concepts in ctx. The names are similar but the owners and use cases are not:</p> Layer Owned by Where they live When to use <code>ctx trigger</code> You <code>.context/hooks/<type>/*.sh</code> Project-specific automation, any AI tool <code>ctx system</code> hooks <code>ctx</code> itself built-in, wired into tool configs Built-in nudges (you don't author these) Claude Code hooks Claude Code <code>.claude/settings.local.json</code> Claude-Code-only tool-specific integration <p>This page is about the first category. The other two run automatically and are invisible to you.</p>","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":"<p>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:</p> <ul> <li>Want the AI to remember something? → Steering.</li> <li>Want a script to run when something happens? → Trigger.</li> </ul> <p>Most projects use both.</p>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#where-to-go-next","level":2,"title":"Where to Go Next","text":"<ul> <li>Authoring Lifecycle Triggers: walkthrough with security guidance: scaffold, test, enable, iterate.</li> <li><code>ctx trigger</code> reference: command reference, trigger type table, input/output contract.</li> <li>Steering files: the declarative counterpart to triggers.</li> </ul>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/vscode/","level":1,"title":"ctx for VS Code","text":"","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#the-problem","level":2,"title":"The Problem","text":"<p>Every Copilot Chat session in VS Code starts from zero. You re-explain what you were doing, the AI repeats yesterday's mistakes, and decisions you spent an hour reasoning through last week get rediscovered instead of remembered.</p> <p>Without <code>ctx</code>:</p> <pre><code>@workspace add the validation middleware we discussed\n\nI don't have context about previous discussions. Could you describe\nwhat validation middleware you're referring to?\n</code></pre> <p>With <code>ctx</code>:</p> <pre><code>@ctx Do you remember?\n\nLast session (2026-05-09): you decided on Zod schemas at the route level\n(DECISIONS.md #12). Pattern lives in CONVENTIONS.md. Open task: wire\nthe auth middleware into the new /admin routes (TASKS.md, in-progress).\nThe reference implementation is src/middleware/auth.ts.\n</code></pre> <p>That's the whole pitch: your AI remembers, right inside the IDE you already work in.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#setup","level":2,"title":"Setup","text":"<p>Install the extension and the <code>ctx</code> binary, then <code>ctx init</code> your project:</p> <ol> <li>Install the extension from the VS Code Marketplace (publisher: <code>activememory</code>, display name: <code>ctx</code>: Persistent Context for AI). Or build from source (see editors/vscode/README.md).</li> <li>Install the <code>ctx</code> CLI if you haven't already (installation docs). If you skip this step, the extension will auto-download the right binary for your platform on first use (see Auto-Bootstrap below).</li> <li>From your project root, run:</li> </ol> <pre><code>ctx init\n</code></pre> <ol> <li>Open Copilot Chat in VS Code and type <code>@ctx /init</code> to verify the extension can reach the CLI.</li> </ol>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#what-gets-created","level":3,"title":"What Gets Created","text":"File Purpose <code>.context/</code> Project-local context directory (created by <code>ctx init</code>) <code>.github/copilot-instructions.md</code> Repository instructions Copilot reads natively; regenerated automatically whenever <code>.context/</code> files change <p>The extension itself lives in VS Code's extension storage. No project files are added beyond <code>.context/</code> and the Copilot instructions.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#how-you-use-it","level":2,"title":"How You Use It","text":"<p>Type <code>@ctx</code> in the Copilot Chat view to invoke the chat participant. Then either:</p> <ul> <li>Use a slash command: <code>@ctx /status</code>, <code>@ctx /wrapup</code>, etc. There are 45 commands; the most common ones live in the Slash Commands table below.</li> <li>Use natural language: <code>@ctx what should I work on?</code> routes to <code>/next</code>; <code>@ctx time to wrap up</code> routes to <code>/wrapup</code>. See Natural Language.</li> </ul> <p>The extension shows context-aware follow-up suggestions after each command. For example, after <code>/init</code> you'll see buttons for \"Show status\" or \"Generate copilot integration.\"</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#what-happens-automatically","level":2,"title":"What Happens Automatically","text":"<p>The extension registers several VS Code event handlers that mirror Claude Code's hook system. These run in the background; no user action needed.</p> Trigger What fires File save Task-completion check on non-<code>.context/</code> files Git commit Notification prompting to add a Decision, Learning, run <code>/verify</code>, or Skip <code>.context/</code> file change Refreshes pending reminders and regenerates <code>.github/copilot-instructions.md</code> Dependency file change When <code>go.mod</code>, <code>package.json</code>, etc. change, prompts to refresh the dependency map (<code>/map</code>) Every 5 minutes Updates the reminder status-bar item and writes a heartbeat timestamp Extension activate Fires <code>ctx system session-event --type start</code> Extension deactivate Fires <code>ctx system session-event --type end</code>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#status-bar","level":3,"title":"Status Bar","text":"<p>A <code>$(bell) ctx</code> indicator appears in the status bar when you have pending reminders. It refreshes every 5 minutes and hides itself when nothing is due.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#slash-commands","level":2,"title":"Slash Commands","text":"<p>The extension surfaces 45 commands across six categories. The most commonly used:</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#core-context","level":3,"title":"Core Context","text":"Command When to use <code>/init</code> Initialize a <code>.context/</code> directory with template files <code>/status</code> Token estimate, file count, what's recent <code>/agent</code> Print AI-ready context packet <code>/drift</code> Detect stale paths, missing files, dead references <code>/recall</code> Browse and search prior AI session history <code>/add</code> Add a task, decision, learning, or convention","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#session-lifecycle","level":3,"title":"Session Lifecycle","text":"Command When to use <code>/wrapup</code> End-of-session ceremony: status, drift, journal audit <code>/remember</code> Structured readback (trigger: \"Do you remember?\") from tasks, decisions, learnings, recent journal <code>/reflect</code> Surface items worth persisting as decisions or learnings <code>/pause</code> / <code>/resume</code> Save and restore session state for later","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#discovery-planning","level":3,"title":"Discovery & Planning","text":"Command When to use <code>/brainstorm</code> Browse and develop ideas from <code>ideas/</code> <code>/spec</code> List or scaffold feature specs from templates <code>/verify</code> Run verification (doctor + drift) <code>/map</code> Show dependency map (go.mod, package.json) <p>Full list (with maintenance, audit, metadata, and system commands) is in editors/vscode/README.md.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#natural-language","level":2,"title":"Natural Language","text":"<p>Plain English after <code>@ctx</code> is routed to the right command:</p> <ul> <li>\"What should I work on next?\" → <code>/next</code></li> <li>\"Time to wrap up\" → <code>/wrapup</code></li> <li>\"Show me the status\" → <code>/status</code></li> <li>\"Add a decision\" → <code>/add</code></li> <li>\"Check for drift\" → <code>/drift</code></li> </ul> <p>If the phrase doesn't match a known pattern, the extension surfaces a short menu of likely matches.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#auto-bootstrap","level":2,"title":"Auto-Bootstrap","text":"<p>If the <code>ctx</code> CLI isn't on PATH (or at a path configured via <code>ctx.executablePath</code>), the extension auto-downloads the right binary:</p> <ol> <li>Detects OS and architecture (darwin / linux / windows, amd64 / arm64).</li> <li>Fetches the latest release from GitHub Releases.</li> <li>Downloads and verifies the matching binary.</li> <li>Caches it in VS Code's global storage directory.</li> </ol> <p>Subsequent sessions reuse the cached binary. To pin a specific version, set <code>ctx.executablePath</code> in your VS Code settings.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li>VS Code 1.93+</li> <li>GitHub Copilot Chat extension</li> <li><code>ctx</code> CLI on PATH, or let the extension auto-download it</li> </ul>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#configuration","level":2,"title":"Configuration","text":"Setting Default Description <code>ctx.executablePath</code> <code>ctx</code> Path to the <code>ctx</code> CLI binary. Set this if <code>ctx</code> isn't on PATH and you don't want auto-download.","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#refreshing-the-integration","level":2,"title":"Refreshing the Integration","text":"<p>The extension updates through the VS Code Marketplace like any other extension; install new versions via the Extensions view. Updates to the <code>ctx</code> CLI are independent: bump it via your package manager, or let the auto-bootstrap fetch the latest release.</p> <p>Unlike the OpenCode integration, there is no <code>ctx setup</code> step for VS Code. The extension carries its own runtime; <code>ctx</code>'s role is only to provide the CLI it shells out to.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#troubleshooting","level":2,"title":"Troubleshooting","text":"Symptom Cause Fix <code>@ctx</code> participant doesn't appear in Copilot Chat Copilot Chat not installed or not signed in Install GitHub Copilot Chat and ensure you're signed in to a Copilot-eligible account <code>@ctx /status</code> says <code>ctx</code> not found CLI not on PATH and auto-download disabled Either add <code>ctx</code> to PATH (<code>brew install activememory/tap/ctx</code> or download from Releases), or unset <code>ctx.executablePath</code> to let the extension auto-download Status-bar reminder never updates Heartbeat suppressed or <code>.context/</code> doesn't exist Run <code>ctx init</code> from your project root; reload VS Code if the indicator still doesn't appear within 5 minutes Commands run but nothing is captured to <code>.context/</code> Workspace folder missing or <code>.context/</code> outside the open folder Make sure your project root (the one with <code>.context/</code>) is the workspace root, not a subdirectory of it","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#verify-it-works","level":2,"title":"Verify It Works","text":"<p>Open Copilot Chat and ask:</p> <pre><code>@ctx Do you remember?\n</code></pre> <p>You should see a structured readback citing specific tasks, decisions, and recent session topics. If you instead see \"I don't have memory\" or \"Let me check,\" something went wrong: confirm the CLI is reachable (<code>@ctx /system doctor</code>) and <code>.context/</code> has files in it.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#whats-next","level":2,"title":"What's Next","text":"<ul> <li>Your First Session: step-by-step walkthrough from <code>ctx init</code> to verified recall.</li> <li>Common Workflows: day-to-day commands for tracking context, checking health, and browsing history.</li> <li>Context Files: what lives in <code>.context/</code> and how each file is used.</li> <li>Setup across AI Tools: wiring <code>ctx</code> for Claude Code, OpenCode, Cursor, Aider, Copilot, or Windsurf alongside VS Code.</li> </ul>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"operations/","level":1,"title":"Operations","text":"<p>Guides for installing, upgrading, integrating, and running <code>ctx</code>. Split into three groups by audience.</p>","path":["Operations"],"tags":[]},{"location":"operations/#day-to-day","level":2,"title":"Day-to-Day","text":"<p>Everyday operation guides for anyone running <code>ctx</code> in a project or adopting it in a team.</p>","path":["Operations"],"tags":[]},{"location":"operations/#integration","level":3,"title":"Integration","text":"<p>Adopt <code>ctx</code> in an existing project: initialize context files, migrate from other tools, and onboard team members.</p>","path":["Operations"],"tags":[]},{"location":"operations/#upgrade","level":3,"title":"Upgrade","text":"<p>Upgrade between versions with step-by-step migration notes and breaking-change guidance.</p>","path":["Operations"],"tags":[]},{"location":"operations/#ai-tools","level":3,"title":"AI Tools","text":"<p>Configure <code>ctx</code> with Claude Code, Cursor, Aider, Copilot, Windsurf, and other AI coding tools.</p>","path":["Operations"],"tags":[]},{"location":"operations/#autonomous-loops","level":3,"title":"Autonomous Loops","text":"<p>Run an unattended AI agent that works through tasks overnight, with <code>ctx</code> providing persistent memory between iterations.</p>","path":["Operations"],"tags":[]},{"location":"operations/#hub","level":2,"title":"Hub","text":"<p>Operator guides for running a <code>ctx</code> Hub, the gRPC server that fans out structured entries across projects. If you're a client connecting to a Hub someone else runs, see <code>ctx connection</code> and the Hub recipes instead.</p>","path":["Operations"],"tags":[]},{"location":"operations/#hub-operations","level":3,"title":"Hub Operations","text":"<p>Data directory layout, daemon management, systemd unit, backup and restore, log rotation, monitoring, and upgrades.</p>","path":["Operations"],"tags":[]},{"location":"operations/#hub-failure-modes","level":3,"title":"Hub Failure Modes","text":"<p>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.</p>","path":["Operations"],"tags":[]},{"location":"operations/#maintainers","level":2,"title":"Maintainers","text":"<p>Runbooks for people shipping <code>ctx</code> itself.</p>","path":["Operations"],"tags":[]},{"location":"operations/#cutting-a-release","level":3,"title":"Cutting a Release","text":"<p>Step-by-step runbook for maintainers: bump version, generate release notes, run the release script, and verify the result.</p>","path":["Operations"],"tags":[]},{"location":"operations/#runbooks","level":2,"title":"Runbooks","text":"<p>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.</p> 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 <code>ctx</code> 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 Out-of-band audit channel Relay out-of-band audit findings into a working session (<code>ctxctl</code>) Running discipline audits from a separate session Sanitize permissions Clean <code>.claude/settings.local.json</code> of over-broad grants After heavy permission granting Architecture exploration Systematic architecture docs across repos New codebase onboarding, reviews <p>Recommended cadence:</p> <ul> <li>Before every release: release checklist (which includes codebase audit + docs semantic audit)</li> <li>Monthly: sanitize permissions</li> <li>Quarterly: full sweep of all audit runbooks</li> </ul>","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":"<p>Iterate until done.</p> <p>An autonomous loop is an iterative AI development workflow where an agent works on tasks until completion, without constant human intervention. </p> <p><code>ctx</code> provides the memory that makes this possible:</p> <ul> <li><code>ctx</code> provides the memory: persistent context that survives across iterations</li> <li>The loop provides the automation: continuous execution until done</li> </ul> <p>Together, they enable fully autonomous AI development where the agent remembers everything across iterations.</p> <p>Origin</p> <p>This pattern is inspired by Geoffrey Huntley's Ralph Wiggum technique.</p> <p>We use generic terminology here so the concepts remain clear regardless of trends.</p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#how-it-works","level":2,"title":"How It Works","text":"<pre><code>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</code></pre> <ol> <li>Loop reads <code>.context/loop.md</code> and invokes AI</li> <li>AI loads context from <code>.context/</code></li> <li>AI picks one task and completes it</li> <li>AI updates context files (mark task done, add learnings)</li> <li>AI commits changes</li> <li>Loop checks for completion signals</li> <li>Repeat until converged or blocked</li> </ol>","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":"<p>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\":</p> <p>The only state that carries between iterations is what lives in <code>.context/</code> and the git history. No context window bleed, no accumulated tokens, no hidden state.</p> <p>Create a <code>loop.sh</code>:</p> <pre><code>#!/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</code></pre> <p>Make it executable and run:</p> <pre><code>chmod +x loop.sh\n./loop.sh\n</code></pre> <p>You can also generate this script with <code>ctx loop</code> (see CLI Reference).</p>","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":"<p>Each iteration starts a fresh AI process with zero context window history. The agent knows only what it reads from <code>.context/</code> files: Exactly the information you chose to persist. </p> <p>This is the core loop principle: memory is explicit, not accidental.</p>","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":"<p>Claude Code has built-in loop support:</p> <pre><code># Start autonomous loop\n/loop\n\n# Cancel running loop\n/cancel-loop\n</code></pre> <p>This is convenient for quick iterations, but be aware of important caveats:</p> <p>This Loop Is Not Pure</p> <p>Claude Code's <code>/loop</code> runs all iterations within the same session. This means:</p> <ul> <li>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 <code>.context/</code>).</li> <li>Token budget degrades: Each iteration adds to the context window, leaving less room for actual work in later iterations.</li> <li>Not ergonomic for long runs: Users report that the built-in loop is less predictable for 10+ iteration runs compared to a shell loop.</li> </ul> <p>For short explorations (2-5 iterations) or interactive use, <code>/loop</code> works fine. For overnight unattended runs or anything where iteration independence matters, use the shell while loop instead.</p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#the-contextloopmd-file","level":2,"title":"The <code>.context/loop.md</code> File","text":"<p>The prompt file instructs the AI on how to work autonomously. Here's a template:</p> <pre><code># 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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#completion-signals","level":2,"title":"Completion Signals","text":"<p>The loop watches for these signals in AI output:</p> Signal Meaning When to Use <code>SYSTEM_CONVERGED</code> All tasks complete No pending tasks in TASKS.md <code>SYSTEM_BLOCKED</code> Cannot proceed Needs clarification, access, or decision <code>BOOTSTRAP_COMPLETE</code> 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":"<p>converged state</p> <pre><code>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</code></pre> <p>blocked state</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#why-ctx-and-loops-work-well-together","level":2,"title":"Why <code>ctx</code> and Loops Work Well Together","text":"Without <code>ctx</code> With <code>ctx</code> Each iteration starts fresh Each iteration has full history Decisions get re-made Decisions persist in <code>DECISIONS.md</code> Learnings are lost Learnings accumulate in <code>LEARNINGS.md</code> Tasks can be forgotten Tasks tracked in <code>TASKS.md</code>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#automatic-context-updates","level":3,"title":"Automatic Context Updates","text":"<p>During the loop, the AI should update context files:</p> <p>Mark task complete: <pre><code>ctx task complete \"implement user auth\"\n</code></pre></p> <p>Or emit an update command (parsed by <code>ctx watch</code>): <pre><code><context-update type=\"complete\">user auth</context-update>\n</code></pre></p> <p>Add learning: <pre><code>ctx learning add \"Rate limiting requires Redis connection\" \\\n --session-id abc12345 --branch main --commit 68fbc00a\n</code></pre></p> <p>Or via update command: <pre><code><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</code></pre></p> <p>Record decision: <pre><code>ctx decision add \"Use JWT tokens for API authentication\" \\\n --session-id abc12345 --branch main --commit 68fbc00a\n</code></pre></p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#advanced-watch-mode","level":2,"title":"Advanced: Watch Mode","text":"<p>Run <code>ctx watch</code> alongside the loop to automatically process context updates:</p> <pre><code># 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</code></pre> <p>The watch command processes context updates from the loop output in real time.</p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#project-setup","level":2,"title":"Project Setup","text":"<p>Initialize a project for autonomous loop operation:</p> <pre><code>ctx init\n</code></pre> <p><code>ctx</code> always reads <code>$PWD/.context/</code>. For unattended overnight runs where a supervisor may not preserve cwd, put <code>cd /abs/path/to/project</code> at the top of <code>loop.sh</code> so the loop is anchored regardless of how the supervisor launches it.</p> <p>The loop prompt template is deployed to <code>.context/loop.md</code> during initialization. It instructs the agent to:</p> <ul> <li>Work autonomously without asking clarifying questions;</li> <li>Follow one-task-per-iteration discipline;</li> <li>Use <code>SYSTEM_CONVERGED</code> / <code>SYSTEM_BLOCKED</code> signals;</li> </ul>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#example-project-structure","level":2,"title":"Example Project Structure","text":"<pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#sample-tasksmd-for-autonomous-loops","level":3,"title":"Sample <code>TASKS.md</code> for Autonomous Loops","text":"<pre><code># 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</code></pre> <p>The loop will work through these systematically, marking each complete.</p>","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":"<p>Cause: AI not emitting completion signals</p> <p>Fix: Ensure .context/loop.md explicitly instructs signaling: <pre><code>End EVERY response with one of:\n- SYSTEM_CONVERGED (if all tasks done)\n- SYSTEM_BLOCKED (if stuck)\n</code></pre></p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#context-not-persisting","level":3,"title":"Context Not Persisting","text":"<p>Cause: AI not updating context files</p> <p>Fix: Add explicit instructions to .context/loop.md: <pre><code>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</code></pre></p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#tasks-getting-repeated","level":3,"title":"Tasks Getting Repeated","text":"<p>Cause: Task not marked complete before next iteration</p> <p>Fix: Ensure commit happens after context update:</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#ai-violating-constitution","level":3,"title":"AI Violating Constitution","text":"<p>Cause: Constitution not read first</p> <p>Fix: Make constitution check explicit in <code>.context/loop.md</code>:</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Building <code>ctx</code> Using <code>ctx</code>: The dogfooding story: how autonomous loops built the tool that powers them</li> </ul>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#resources","level":2,"title":"Resources","text":"<ul> <li>Geoffrey Huntley's Ralph Wiggum Technique: The original inspiration</li> <li>Context CLI: Command reference</li> <li>Integrations: Tool-specific setup</li> </ul>","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":"<code>ctx</code> Hub: Failure Modes","text":"<p>What can go wrong, what the system does about it, and what you should do. Complementary to <code>ctx</code> Hub Operations.</p> <p>Design Posture</p> <p>The hub is best-effort knowledge sharing, not a durable ledger. Local <code>.context/</code> files are the source of truth for each project; the hub is a fan-out channel. This framing informs every failure-mode decision below.</p>","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":"<p>What happens: <code>ctx connection listen</code> detects the EOF, waits with exponential backoff, and reconnects. On reconnect it passes its last-seen sequence; the hub replays everything newer.</p> <p>What you should do: nothing. If reconnects are looping, check firewall state on the hub and <code>ctx hub status</code> output.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#partition-majority-side-reachable","level":3,"title":"Partition: Majority Side Reachable","text":"<p>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).</p> <p>What you should do: let it heal. When the partition closes, followers catch up via sequence-based sync automatically.</p>","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":"<p>What happens: no node holds a majority, so no leader is elected. All nodes become read-only. <code>ctx connection publish</code> and <code>ctx add --share</code> fail with a \"no leader\" error; local writes still succeed.</p> <p>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 <code>ctx hub peer remove</code> for the dead nodes.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#hub-unreachable-during-ctx-add-share","level":3,"title":"Hub Unreachable during <code>ctx add --share</code>","text":"<p>What happens: the local write succeeds; the share step prints a warning and exits non-zero on the share leg only. <code>--share</code> is best-effort; it never blocks local context updates.</p> <p>What you should do: run <code>ctx connection publish</code> later to backfill, or rely on another <code>--share</code> for the same entry ID. The hub deduplicates by entry ID.</p>","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":"<p>What happens: <code>entries.jsonl</code> 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.</p> <p>What you should do: free disk or grow the volume, then nothing else; the hub resumes accepting writes on the next append attempt.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#corrupt-entriesjsonl","level":3,"title":"Corrupt <code>entries.jsonl</code>","text":"<p>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.</p> <p>What you should do: inspect with <code>jq -c . <data-dir>/entries.jsonl > /dev/null</code> to find the bad line. Move the bad region to a <code>.quarantine</code> file, then start. Nothing is ever silently dropped.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#metajson-entriesjsonl-sequence-mismatch","level":3,"title":"<code>meta.json</code> / <code>entries.jsonl</code> Sequence Mismatch","text":"<p>What happens: the hub refuses to start. This usually means someone copied one file without the other.</p> <p>What you should do: restore both files from the same backup, or accept the higher sequence by regenerating <code>meta.json</code> from <code>entries.jsonl</code> (manual for now; file a bug).</p>","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":"<p>What happens: <code>ctx hub stop</code> triggers <code>stepdown</code> first, so a new leader is elected before the old one exits. In-flight writes drain. Clients reconnect to the new leader transparently.</p>","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":"<p>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.</p> <p>What you should do: if you need stronger durability, run <code>ctx connection listen</code> on a dedicated \"collector\" project that persists entries locally as a write-ahead backup.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#split-brain-after-rejoin","level":3,"title":"Split-Brain After Rejoin","text":"<p>What happens: Raft reconciles: the minority side's uncommitted writes are discarded, and the majority's log is authoritative.</p> <p>What you should do: nothing automatic. If you know the minority had important writes, grep for them in <code><data-dir>/entries.jsonl.rejected</code> (written by the reconciliation pass) and replay them with <code>ctx connection publish</code>.</p>","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":"<p>What happens: you cannot register new projects.</p> <p>What you should do: retrieve it from <code><data-dir>/admin.token</code>. 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.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-admin-token","level":3,"title":"Compromised Admin Token","text":"<p>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.</p> <p>What you should do: rotate the admin token (regenerate <code><data-dir>/admin.token</code> and restart), revoke suspicious client registrations via <code>clients.json</code>, and audit <code>entries.jsonl</code> for unexpected origins.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-client-token","level":3,"title":"Compromised Client Token","text":"<p>What happens: the attacker can publish as that project and read anything that project is subscribed to. Because <code>Origin</code> is self-asserted on publish, the attacker can also publish entries tagged with any other project's name, so attribution in <code>entries.jsonl</code> cannot be trusted after a token compromise.</p> <p>What you should do: remove the client's entry from <code>clients.json</code>, restart the hub, and re-register the legitimate project with a fresh token. Audit <code>entries.jsonl</code> for entries published after the compromise timestamp and quarantine any that look suspicious; remember that <code>Origin</code> on those entries proves nothing.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-hub-host","level":3,"title":"Compromised Hub Host","text":"<p>What happens: <code><data-dir>/clients.json</code> 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.</p> <p>What you should do: treat it as a total hub compromise. Stop the hub, wipe <code><data-dir></code> (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.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#clock-skew","level":2,"title":"Clock Skew","text":"<p>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.</p> <p>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.</p>","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 <code>ctx hub status</code> \"No leader\" errors Cluster quorum; run <code>ctx hub status</code> on each peer Hub won't start after crash Last line of <code>entries.jsonl</code> Entries missing after restore Check <code>clients.json</code> sequence vs local <code>.sync-state.json</code> 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":"<ul> <li><code>ctx</code> Hub Operations</li> <li><code>ctx</code> Hub security model</li> <li>HA cluster recipe</li> </ul>","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":"<code>ctx</code> Hub: Operations","text":"<p>Running the <code>ctx</code> <code>ctx</code> 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.</p> <p>If you have not read it yet, start with the <code>ctx</code> 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.</p> <p>Operator Cheat Sheet</p> <ul> <li>The hub fans out four entry types only: <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. Journals, scratchpad, and other local state are out of scope.</li> <li>Identity is per-project, not per-user. Attribution is limited to <code>Origin</code>, which is self-asserted by the publishing client.</li> <li>The data model is an append-only JSONL log plus two small JSON sidecar files. Nothing is rewritten in place.</li> </ul>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#data-directory-layout","level":2,"title":"Data Directory Layout","text":"<p>The hub stores everything under a single data directory (default <code>~/.ctx/hub-data/</code>, override with <code>--data-dir</code>).</p> <pre><code><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</code></pre> <p>Invariants:</p> <ul> <li><code>entries.jsonl</code> is append-only. Every line is a valid JSON object. Corrupt lines are fatal at startup: fix or truncate before restart.</li> <li><code>meta.json</code> is authoritative for the next sequence number. On restart, the hub reads the last valid line of <code>entries.jsonl</code> and refuses to start if the sequences disagree.</li> <li><code>clients.json</code> holds hashed client tokens; losing it invalidates all client registrations.</li> </ul>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#starting-and-stopping","level":2,"title":"Starting and Stopping","text":"ForegroundDaemon <pre><code>ctx hub start # Ctrl-C to stop\nctx hub start --port 8080 # Custom port\nctx hub start --data-dir /srv/ctx-hub\n</code></pre> <pre><code>ctx hub start --daemon # Fork to background\nctx hub stop # Graceful shutdown\n</code></pre> <p><code>--stop</code> sends SIGTERM to the PID in <code>hub.pid</code>, waits for in-flight RPCs to drain, then exits. If the daemon is wedged, remove <code>hub.pid</code> and send <code>SIGKILL</code> manually. <code>entries.jsonl</code> is crash-safe, so you will not lose accepted writes.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#systemd-unit","level":2,"title":"Systemd Unit","text":"<p>For production single-node deployments, run the hub as a systemd service instead of <code>--daemon</code>:</p> <pre><code># /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</code></pre> <pre><code>sudo systemctl enable --now ctx-hub\nsudo journalctl -u ctx-hub -f\n</code></pre>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#backup-and-restore","level":2,"title":"Backup and Restore","text":"<p>Because <code>entries.jsonl</code> is append-only, backups are trivial:</p> <pre><code># 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</code></pre> <p>For a consistent snapshot across all three files, stop the hub, copy, then start again, or use a filesystem-level snapshot (LVM, ZFS, Btrfs).</p> <p>Restore:</p> <pre><code>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</code></pre> <p>Clients that pushed sequences above the restored watermark will re-publish on the next <code>listen</code> reconnect, because the hub now reports a lower sequence than what clients have on disk. This is safe; the store deduplicates by entry ID.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#log-rotation","level":2,"title":"Log Rotation","text":"<p><code>entries.jsonl</code> grows unbounded. For long-lived hubs, rotate it offline:</p> <pre><code>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</code></pre> <p>Do not truncate <code>entries.jsonl</code> while the hub is running. The hub holds an open file handle; an in-place truncation confuses the sequence counter and loses writes.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#monitoring","level":2,"title":"Monitoring","text":"<p>Liveness probe:</p> <pre><code>ctx hub status --exit-code\n</code></pre> <p>Exit code <code>0</code> means the node is healthy (leader or in-sync follower); non-zero means degraded. Wire this into your monitoring of choice.</p> <p>For cluster deployments, watch for:</p> <ul> <li>Role flaps: the leader changing more than once per hour suggests network instability or disk contention.</li> <li>Replication lag: <code>ctx hub status</code> shows per-peer sequence offsets. Sustained lag > 100 sequences on a follower is worth investigating.</li> <li><code>entries.jsonl</code> growth rate: sudden spikes often indicate a misbehaving <code>ctx connection listen</code> reconnect loop.</li> </ul>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#upgrading","level":2,"title":"Upgrading","text":"<p>The JSONL format is versioned in <code>meta.json</code>. <code>ctx</code> refuses to start against a newer store version than it understands; older store versions are upgraded in place at first start after an upgrade.</p> <p>Always back up <code><data-dir>/</code> before upgrading.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx</code> Hub failure modes</li> <li><code>ctx</code> Hub security model</li> <li><code>ctx serve</code> reference</li> <li><code>ctx hub</code> reference</li> </ul>","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":"<p>Context works with any AI tool that can read files. This guide covers setup for popular AI coding assistants.</p> <p>Run From the Project Root</p> <p><code>ctx</code> reads <code>$PWD/.context/</code>. Run the commands on this page from the project root (the directory that holds <code>.context/</code> and <code>.git/</code>).</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#claude-code-full-integration","level":2,"title":"Claude Code (Full Integration)","text":"<p>Claude Code has the deepest integration via the <code>ctx</code> plugin.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup","level":3,"title":"Setup","text":"<p>First, install <code>ctx</code> and initialize your project:</p> <pre><code>ctx init\n</code></pre> <p>Then, install the <code>ctx</code> plugin in Claude Code:</p> <pre><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</code></pre> <p>Ensure the Plugin Is Enabled</p> <p>Installing a plugin registers it, but local installs may not auto-enable it globally. Verify <code>~/.claude/settings.json</code> contains:</p> <pre><code>{ \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n</code></pre> <p>Without this, the plugin's hooks and skills won't appear in other projects. Running <code>ctx init</code> auto-enables the plugin; use <code>--no-plugin-enable</code> to skip this step.</p> <p>This gives you:</p> Component Purpose <code>.context/</code> All context files <code>CLAUDE.md</code> 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":"<pre><code>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]</code></pre> <ol> <li>Session start: Claude reads <code>CLAUDE.md</code>, which tells it to check <code>.context/</code></li> <li>First tool use: <code>PreToolUse</code> hook runs <code>ctx agent</code> and emits the context packet (subsequent invocations within the cooldown window are silent)</li> <li>Next session: Claude reads context files and continues with context</li> </ol>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#plugin-hooks","level":3,"title":"Plugin Hooks","text":"<p>The <code>ctx</code> plugin provides lifecycle hooks implemented as Go subcommands (<code>ctx system *</code>):</p> Hook Event Purpose <code>ctx system context-load-gate</code> PreToolUse (<code>.*</code>) Auto-inject context on first tool use <code>ctx system block-non-path-ctx</code> PreToolUse (<code>Bash</code>) Block <code>./ctx</code> or <code>go run</code>: force <code>$PATH</code> install <code>ctx system qa-reminder</code> PreToolUse (<code>Bash</code>) Remind agent to lint/test before committing <code>ctx system specs-nudge</code> PreToolUse (<code>EnterPlanMode</code>) Nudge agent to use project specs when planning <code>ctx system check-context-size</code> UserPromptSubmit Nudge context assessment as sessions grow <code>ctx system check-ceremonies</code> UserPromptSubmit Nudge /ctx-remember and /ctx-wrap-up adoption <code>ctx system check-persistence</code> UserPromptSubmit Remind to persist learnings/decisions <code>ctx system check-journal</code> UserPromptSubmit Remind to export/enrich journal entries <code>ctx system check-reminders</code> UserPromptSubmit Relay pending reminders at session start <code>ctx system check-version</code> UserPromptSubmit Warn when binary/plugin versions diverge <code>ctx system check-resources</code> UserPromptSubmit Warn when memory/swap/disk/load hit DANGER level <code>ctx system check-knowledge</code> UserPromptSubmit Nudge when knowledge files grow large <code>ctx system check-map-staleness</code> UserPromptSubmit Nudge when ARCHITECTURE.md is stale <code>ctx system heartbeat</code> UserPromptSubmit Session-alive signal with prompt count metadata <code>ctx system post-commit</code> PostToolUse (<code>Bash</code>) Nudge context capture and QA after git commits <p>A catch-all <code>PreToolUse</code> hook also runs <code>ctx agent</code> on every tool use (with cooldown) to autoload context.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#hook-configuration","level":3,"title":"Hook Configuration","text":"<p>The plugin's <code>hooks.json</code> wires everything automatically: no manual configuration in <code>settings.local.json</code> needed:</p> <pre><code>{\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</code></pre>","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":"<p>Edit the <code>PreToolUse</code> command to change the token budget or cooldown:</p> <pre><code>\"command\": \"ctx agent --budget 8000 --session $PPID >/dev/null || true\"\n\"command\": \"ctx agent --budget 4000 --cooldown 5m --session $PPID >/dev/null || true\"\n</code></pre> <p>The <code>--session $PPID</code> flag isolates the cooldown per session: <code>$PPID</code> resolves to the Claude Code process PID, so concurrent sessions don't interfere. The default cooldown is 10 minutes; use <code>--cooldown 0</code> to disable it.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#verifying-setup","level":3,"title":"Verifying Setup","text":"<ol> <li>Start a new Claude Code session;</li> <li>Ask: \"Do you remember?\"</li> <li>Claude should cite specific context:<ul> <li>Current tasks from <code>.context/TASKS.md</code>;</li> <li>Recent decisions or learnings;</li> <li>Recent session history from <code>ctx journal</code>.</li> </ul> </li> </ol>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#local-plugin-development","level":3,"title":"Local Plugin Development","text":"<p>When developing <code>ctx</code> 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:</p> <ol> <li>Bump version in both:</li> <li> <p><code>internal/assets/claude/.claude-plugin/plugin.json</code> (plugin manifest), <code>.claude-plugin/marketplace.json</code> (marketplace listing*);</p> </li> <li> <p>Update the marketplace in Claude Code:</p> </li> <li>Open the Plugins UI (<code>/plugins</code> or Esc menu),</li> <li>Go to Marketplaces tab,</li> <li>Select the <code>activememory-ctx</code> Marketplace,</li> <li> <p>Choose Update marketplace;</p> </li> <li> <p>Start a new Claude Code session: skill changes aren't reflected in existing sessions.</p> </li> </ol> <p>Both Version Files Must Match</p> <p>If you only bump <code>plugin.json</code> but not <code>marketplace.json</code> (or vice versa), Claude Code may not detect the update. Always bump both together.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#troubleshooting","level":3,"title":"Troubleshooting","text":"Issue Solution Context not loading Check <code>ctx</code> is in PATH: <code>which ctx</code> Hook errors Verify plugin is installed: <code>claude /plugin list</code> New skill not visible Bump version in both <code>plugin.json</code> files, update marketplace","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-load","level":3,"title":"Manual Context Load","text":"<p>If hooks aren't working, manually load context:</p> <pre><code># Get context packet\nctx agent --budget 4000\n\n# Or paste into conversation\ncat .context/TASKS.md\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#agent-skills","level":3,"title":"Agent Skills","text":"<p>The <code>ctx</code> plugin ships Agent Skills following the agentskills.io specification.</p> <p>These are invoked in Claude Code with <code>/skill-name</code>.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-lifecycle-skills","level":4,"title":"Session Lifecycle Skills","text":"Skill Description <code>/ctx-remember</code> Recall project context at session start (ceremony) <code>/ctx-wrap-up</code> End-of-session context persistence (ceremony) <code>/ctx-status</code> Show context summary (tasks, decisions, learnings) <code>/ctx-agent</code> Get AI-optimized context packet <code>/ctx-next</code> Suggest 1-3 concrete next actions from context <code>/ctx-commit</code> Commit with integrated context capture <code>/ctx-reflect</code> Review session and suggest what to persist <code>/ctx-remind</code> Manage session-scoped reminders <code>/ctx-pause</code> Pause context hooks for this session <code>/ctx-resume</code> 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 <code>/ctx-task-add</code> Add a task to TASKS.md <code>/ctx-learning-add</code> Add a learning to LEARNINGS.md <code>/ctx-decision-add</code> Add a decision with context/rationale/consequence <code>/ctx-convention-add</code> Add a coding convention to CONVENTIONS.md <code>/ctx-archive</code> Archive completed tasks","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#scratchpad-skills","level":4,"title":"Scratchpad Skills","text":"Skill Description <code>/ctx-pad</code> 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 <code>/ctx-history</code> Browse AI session history <code>/ctx-journal-enrich</code> Enrich a journal entry with frontmatter/tags <code>/ctx-journal-enrich-all</code> 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":"<p>Blogging Is a Better Way of Creating Release Notes</p> <p>The blogging workflow can also double as generating release notes:</p> <p>AI reads your git commit history and creates a \"narrative\", which is essentially what a release note is for.</p> Skill Description <code>/ctx-blog</code> Generate blog post from recent activity <code>/ctx-blog-changelog</code> 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 <code>/ctx-doctor</code> Troubleshoot <code>ctx</code> behavior with structural health checks <code>/ctx-drift</code> Detect and fix context drift (structural + semantic) <code>/ctx-consolidate</code> Merge redundant learnings or decisions into denser entries <code>/ctx-alignment-audit</code> Audit doc claims against playbook instructions <code>/ctx-prompt-audit</code> Analyze session logs for vague prompts <code>/check-links</code> 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 <code>/ctx-loop</code> Generate a Ralph Loop iteration script <code>/ctx-task-out</code> Decompose a committed spec into a milestone plan <code>/ctx-implement</code> Execute a plan step-by-step with checks <code>/ctx-plan-import</code> Import Claude Code plan files into project specs <code>/ctx-worktree</code> Manage git worktrees for parallel agents <code>/ctx-architecture</code> Build and maintain architecture maps","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage-examples","level":4,"title":"Usage Examples","text":"<pre><code>/ctx-status\n/ctx-learning-add \"Token refresh requires explicit cache invalidation\"\n/ctx-journal-enrich twinkly-stirring-kettle\n</code></pre> <p>Skills support partial matching where applicable (e.g., session slugs).</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#cursor-ide","level":2,"title":"Cursor IDE","text":"<p>Cursor can use context files through its system prompt or by reading files directly.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_1","level":3,"title":"Setup","text":"<pre><code># Generate Cursor configuration\nctx setup cursor\n\n# Initialize context\nctx init --minimal\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration","level":3,"title":"Configuration","text":"<p>Add to Cursor settings (<code>.cursor/settings.json</code>):</p> <pre><code>// 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage","level":3,"title":"Usage","text":"<ol> <li>Open your project in Cursor</li> <li>Context files are available in the file tree</li> <li>Reference them in prompts: \"Check .context/DECISIONS.md for our approach to...\"</li> </ol>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-injection","level":3,"title":"Manual Context Injection","text":"<p>For more control, paste context directly:</p> <pre><code># Get AI-ready packet\nctx agent --budget 4000 | pbcopy # macOS\nctx agent --budget 4000 | xclip # Linux\n</code></pre> <p>Paste into Cursor's chat.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#aider","level":2,"title":"Aider","text":"<p>Aider works well with context files through its <code>--read</code> flag.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_2","level":3,"title":"Setup","text":"<pre><code># Generate Aider configuration\nctx setup aider\n\n# Initialize context\nctx init\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_1","level":3,"title":"Configuration","text":"<p>Create <code>.aider.conf.yml</code>:</p> <pre><code>read:\n - .context/CONSTITUTION.md\n - .context/TASKS.md\n - .context/CONVENTIONS.md\n - .context/DECISIONS.md\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_1","level":3,"title":"Usage","text":"<pre><code># Start Aider (reads context files automatically)\naider\n\n# Or specify files explicitly\naider --read .context/TASKS.md --read .context/CONVENTIONS.md\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#with-watch-mode","level":3,"title":"With Watch Mode","text":"<p>Run <code>ctx watch</code> alongside Aider to capture context updates:</p> <pre><code># 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#github-copilot","level":2,"title":"GitHub Copilot","text":"<p>GitHub Copilot integrates with <code>ctx</code> at three levels: an automated instructions file, a VS Code Chat extension, and manual patterns.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_3","level":3,"title":"Setup","text":"<pre><code># Initialize context\nctx init\n\n# Generate .github/copilot-instructions.md\nctx setup copilot --write\n</code></pre> <p>The <code>--write</code> flag creates <code>.github/copilot-instructions.md</code>, 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.</p> <p>Re-run <code>ctx setup copilot --write</code> after updating your <code>.context/</code> files to regenerate the instructions.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#vs-code-chat-extension-ctx","level":3,"title":"VS Code Chat Extension (<code>@ctx</code>)","text":"<p>The <code>ctx</code> VS Code extension adds a <code>@ctx</code> chat participant to GitHub Copilot Chat, giving you direct access to 45 context commands from within the editor, plus automatic hooks on file save / git commit / <code>.context/</code> changes / dependency-file edits, and a reminder status-bar indicator.</p> <p>Full guide: <code>ctx</code> for VS Code</p> <p>The home-page guide covers daily workflows, the full command list, natural-language routing, auto-bootstrap of the <code>ctx</code> CLI, troubleshooting, and \"Verify It Works.\" This subsection is the install-and-pointers overview; the dedicated page is the authoritative reference.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#installation","level":4,"title":"Installation","text":"<p>The extension ships to the VS Code Marketplace under publisher <code>activememory</code> (display name: <code>ctx</code>: Persistent Context for AI). Install via the Extensions view or <code>code --install-extension</code>.</p> <p>To build from source instead (requires Node.js 20+):</p> <pre><code>cd editors/vscode\nnpm ci\nnpm run build\nnpx @vscode/vsce package\ncode --install-extension ctx-context-<version>.vsix\n</code></pre> <p>Reload VS Code. Type <code>@ctx</code> in Copilot Chat to verify.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#what-gets-created","level":4,"title":"What Gets Created","text":"File Purpose <code>.context/</code> Project-local context directory (created by <code>ctx init</code>, not by the extension) <code>.github/copilot-instructions.md</code> Repository instructions Copilot reads natively; regenerated automatically when <code>.context/</code> files change <p>The extension itself lives in VS Code's extension storage; no project files beyond <code>.context/</code> and the Copilot instructions are added.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#how-it-works_1","level":4,"title":"How It Works","text":"<ul> <li>Chat participant: <code>@ctx</code> is registered with VS Code's Chat API; 45 slash commands route to dedicated handlers that shell out to the <code>ctx</code> CLI.</li> <li>Automatic hooks: file save → task-completion check; git commit → decision/learning prompt; <code>.context/</code> change → regenerate Copilot instructions; dependency-file change → <code>/map</code> prompt.</li> <li>Status-bar reminder: a <code>$(bell) ctx</code> indicator surfaces pending session reminders, refreshing every 5 minutes.</li> <li>Natural language: plain English after <code>@ctx</code> is routed to the nearest matching command.</li> <li>Auto-bootstrap: if the <code>ctx</code> CLI isn't on PATH, the extension downloads the correct platform binary from GitHub Releases and caches it.</li> </ul>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_2","level":4,"title":"Configuration","text":"Setting Default Description <code>ctx.executablePath</code> <code>ctx</code> Path to the <code>ctx</code> binary. Set this if <code>ctx</code> is not in your <code>PATH</code>.","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-persistence","level":3,"title":"Session Persistence","text":"<p><code>ctx init</code> creates a <code>.context/sessions/</code> directory for storing session data from non-Claude tools. The Markdown session parser scans this directory during <code>ctx journal</code>, enabling session history for Copilot and other tools.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-patterns","level":3,"title":"Manual Patterns","text":"<p>These patterns work without the extension, using Copilot's built-in file awareness:</p> <p>Pattern 1: Keep context files open</p> <p>Open <code>.context/CONVENTIONS.md</code> in a split pane. Copilot will reference it.</p> <p>Pattern 2: Reference in comments</p> <pre><code>// 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</code></pre> <p>Pattern 3: Paste context into Copilot Chat</p> <pre><code>ctx agent --budget 2000\n</code></pre> <p>Paste output into Copilot Chat for context-aware responses.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#opencode","level":2,"title":"OpenCode","text":"<p>OpenCode is a terminal-first AI coding agent. <code>ctx</code> integrates via a thin lifecycle plugin, MCP server, and <code>AGENTS.md</code> instructions.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_4","level":3,"title":"Setup","text":"<pre><code># Generate OpenCode plugin, global MCP config, skills, and AGENTS.md\nctx setup opencode --write\n\n# Initialize context\nctx init\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#what-gets-created_1","level":3,"title":"What Gets Created","text":"File Purpose <code>.opencode/plugins/ctx.ts</code> Lifecycle plugin (hooks to <code>ctx system</code>) <code>~/.config/opencode/opencode.json</code> Global MCP server registration (or <code>$OPENCODE_HOME/opencode.json</code>) <code>AGENTS.md</code> Agent instructions (read natively) <code>.opencode/skills/ctx-*/SKILL.md</code> <code>ctx</code> skills","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#how-it-works_2","level":3,"title":"How It Works","text":"<p>The plugin wires OpenCode lifecycle events to <code>ctx system</code>:</p> <ul> <li><code>session.created</code>: warms <code>ctx</code> state in the background (bootstrap + agent packet) so MCP queries are fast on first use.</li> <li><code>tool.execute.after</code> (shell, on <code>git commit</code>): runs <code>ctx system post-commit</code>.</li> <li><code>tool.execute.after</code> (edit/write): runs <code>ctx system check-task-completion</code>.</li> <li><code>session.idle</code>: runs persistence and task-completion checks (silent: output is buffered, not surfaced to the TUI).</li> <li><code>shell.env</code>: ensures the agent's shell starts in the project root so <code>ctx</code> commands resolve to the right project.</li> <li><code>experimental.session.compacting</code>: pushes <code>ctx system bootstrap</code> output into the compaction context so the agent keeps breadcrumbs back to <code>.context/</code>.</li> </ul> <p>The plugin is a single file with no runtime dependencies; no <code>bun install</code> needed. OpenCode loads it automatically on launch.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-updates","level":3,"title":"Context Updates","text":"<pre><code># Get AI-optimized context packet\nctx agent\n\n# Check context health\nctx status\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#windsurf-ide","level":2,"title":"Windsurf IDE","text":"<p>Windsurf supports custom instructions and file-based context.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_5","level":3,"title":"Setup","text":"<pre><code># Generate Windsurf configuration\nctx setup windsurf\n\n# Initialize context\nctx init\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_3","level":3,"title":"Configuration","text":"<p>Add to Windsurf settings:</p> <pre><code>// 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_2","level":3,"title":"Usage","text":"<p>Context files appear in the file tree. Reference them when chatting:</p> <ul> <li>\"What's in our task list?\" → AI reads <code>.context/TASKS.md</code></li> <li>\"What convention do we use for naming?\" → AI reads <code>.context/CONVENTIONS.md</code></li> </ul>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#generic-integration","level":2,"title":"Generic Integration","text":"<p>For any AI tool that can read files, use these patterns:</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-loading","level":3,"title":"Manual Context Loading","text":"<pre><code># 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#system-prompt-template","level":3,"title":"System Prompt Template","text":"<pre><code>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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#automated-updates","level":3,"title":"Automated Updates","text":"<p>If your AI tool outputs to a log, use <code>ctx watch</code>:</p> <pre><code># Watch log file for context-update commands\nyour-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n</code></pre> <p>The AI can emit updates like:</p> <pre><code><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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-update-commands","level":2,"title":"Context Update Commands","text":"<p>The <code>ctx watch</code> command parses update commands from AI output. Use this format:</p> <pre><code><context-update type=\"TYPE\" [attributes]>Content</context-update>\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#supported-types","level":3,"title":"Supported Types","text":"Type Target File Required Attributes <code>task</code> TASKS.md None <code>decision</code> DECISIONS.md <code>context</code>, <code>rationale</code>, <code>consequence</code> <code>learning</code> LEARNINGS.md <code>context</code>, <code>lesson</code>, <code>application</code> <code>convention</code> CONVENTIONS.md None <code>complete</code> 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":"<pre><code><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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#structured-format-learnings-decisions","level":3,"title":"Structured Format (Learnings, Decisions)","text":"<p>Learnings and decisions support structured attributes for better documentation:</p> <p>Learning with full structure:</p> <pre><code><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</code></pre> <p>Decision with full structure:</p> <pre><code><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</code></pre> <p>Learnings require: <code>context</code>, <code>lesson</code>, <code>application</code> attributes. Decisions require: <code>context</code>, <code>rationale</code>, <code>consequence</code> attributes. Updates missing required attributes are rejected with an error.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Skills That Fight the Platform: Common pitfalls in skill design that work against the host tool</li> <li>The Anatomy of a Skill That Works: What makes a skill reliable: the E/A/R framework and quality gates</li> </ul>","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 <code>ctx</code> in Existing Projects","text":"<p>Claude Code User?</p> <p>You probably want the plugin instead of this page.</p> <p>Install <code>ctx</code> from the marketplace: (<code>/plugin</code> → search \"<code>ctx</code>\" → Install) and you're done: hooks, skills, and updates are handled for you.</p> <p>See Getting Started for the full walkthrough.</p> <p>This guide covers adopting <code>ctx</code> in existing projects regardless of which tools your team uses.</p>","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) <code>ctx init</code> Creates <code>.context/</code>, <code>CLAUDE.md</code>, permissions Existing <code>CLAUDE.md</code> <code>ctx init --merge</code> Backs up your file, inserts <code>ctx</code> block after the H1 Existing <code>CLAUDE.md</code> + <code>ctx</code> markers <code>ctx init --reset</code> Replaces the <code>ctx</code> block, leaves your content intact <code>.cursorrules</code> / <code>.aider.conf.yml</code> <code>ctx init</code> <code>ctx</code> ignores those files: they coexist cleanly Team repo, first adopter <code>ctx init --merge && git add .context/ CLAUDE.md</code> Initialize and commit for the team","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-claudemd","level":2,"title":"Existing <code>CLAUDE.md</code>","text":"<p>This is the most common scenario:</p> <p>You have a <code>CLAUDE.md</code> with project-specific instructions and don't want to lose them.</p> <p>You Own <code>CLAUDE.md</code></p> <p>After initialization, <code>CLAUDE.md</code> is yours: edit it freely.</p> <p>Add project instructions, remove sections you don't need, reorganize as you see fit.</p> <p>The only part <code>ctx</code> manages is the block between the <code><!-- ctx:context --></code> and <code><!-- ctx:end --></code> markers; everything outside those markers is yours to change at any time.</p> <p>If you remove the markers, nothing breaks: <code>ctx</code> simply treats the file as having no <code>ctx</code> content and will offer to merge again on the next <code>ctx init</code>.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-ctx-init-does","level":3,"title":"What <code>ctx init</code> Does","text":"<p>When <code>ctx init</code> detects an existing <code>CLAUDE.md</code>, it checks for <code>ctx</code> markers (<code><!-- ctx:context --></code> ... <code><!-- ctx:end --></code>):</p> State Default behavior With <code>--merge</code> With <code>--force</code> No <code>CLAUDE.md</code> Creates from template Creates from template Creates from template Exists, no <code>ctx</code> markers Prompts to merge Auto-merges (no prompt) Auto-merges (no prompt) Exists, has <code>ctx</code> markers Skips (already set up) Skips Replaces the <code>ctx</code> block only","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-merge-flag","level":3,"title":"The <code>--merge</code> Flag","text":"<p><code>--merge</code> auto-merges without prompting. The merge process:</p> <ol> <li>Backs up your existing <code>CLAUDE.md</code> to <code>CLAUDE.md.<timestamp>.bak</code>;</li> <li>Finds the H1 heading (e.g., <code># My Project</code>) in your file;</li> <li>Inserts the <code>ctx</code> block immediately after it;</li> <li>Preserves everything else untouched.</li> </ol> <p>Your content before and after the <code>ctx</code> block remains exactly as it was.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#before-after-example","level":3,"title":"Before / After Example","text":"<p>Before: your existing <code>CLAUDE.md</code>:</p> <pre><code># 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</code></pre> <p>After <code>ctx init --merge</code>:</p> <pre><code># 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</code></pre> <p>Your build commands and code style sections are untouched. The <code>ctx</code> block sits between markers and can be updated independently.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-force-flag","level":3,"title":"The <code>--force</code> Flag","text":"<p>If your <code>CLAUDE.md</code> already has <code>ctx</code> markers (from a previous <code>ctx init</code>), the default behavior is to skip it. Use <code>--force</code> to replace the <code>ctx</code> block with the latest template: This is useful after upgrading <code>ctx</code>:</p> <pre><code>ctx init --reset\n</code></pre> <p>This only replaces content between <code><!-- ctx:context --></code> and <code><!-- ctx:end --></code>. Your own content outside the markers is preserved. A timestamped backup is created before any changes.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#undoing-a-merge","level":3,"title":"Undoing a Merge","text":"<p>Every merge creates a backup:</p> <pre><code>$ ls CLAUDE.md*.bak\nCLAUDE.md.1738000000.bak\n</code></pre> <p>To restore:</p> <pre><code>cp CLAUDE.md.1738000000.bak CLAUDE.md\n</code></pre> <p>Or if you are using <code>git</code>, simply:</p> <pre><code>git checkout CLAUDE.md\n</code></pre>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-cursorrules-aider-copilot","level":2,"title":"Existing <code>.cursorrules</code> / Aider / Copilot","text":"<p><code>ctx</code> doesn't touch tool-specific config files. It creates its own files (<code>.context/</code>, <code>CLAUDE.md</code>) and coexists with whatever you already have.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-does-ctx-create","level":3,"title":"What Does <code>ctx</code> Create?","text":"<code>ctx</code> creates <code>ctx</code> does NOT touch <code>.context/</code> directory <code>.cursorrules</code> <code>CLAUDE.md</code> (or merges into) <code>.aider.conf.yml</code> <code>.claude/settings.local.json</code> (seeded by <code>ctx init</code>; the plugin manages hooks and skills) <code>.github/copilot-instructions.md</code> <code>.windsurfrules</code> Any other tool-specific config <p>Claude Code hooks and skills are provided by the <code>ctx</code> plugin, installed from the Claude Code marketplace (<code>/plugin</code> → search \"<code>ctx</code>\" → Install).</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#running-ctx-alongside-other-tools","level":3,"title":"Running <code>ctx</code> Alongside Other Tools","text":"<p>The <code>.context/</code> directory is the source of truth. Tool-specific configs point to it:</p> <ul> <li>Cursor: Reference <code>.context/</code> files in your system prompt (see Cursor setup)</li> <li>Aider: Add <code>.context/</code> files to the <code>read:</code> list in <code>.aider.conf.yml</code> (see Aider setup)</li> <li>Copilot: Keep <code>.context/</code> files open or reference them in comments (see Copilot setup)</li> </ul> <p>You can generate a tool-specific configuration with:</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#migrating-content-into-context","level":3,"title":"Migrating Content into <code>.context/</code>","text":"<p>If you have project knowledge scattered across <code>.cursorrules</code> or custom prompt files, consider migrating it:</p> <ol> <li>Rules / invariants → <code>.context/CONSTITUTION.md</code></li> <li>Code patterns → <code>.context/CONVENTIONS.md</code></li> <li>Architecture notes → <code>.context/ARCHITECTURE.md</code></li> <li>Known issues / tips → <code>.context/LEARNINGS.md</code></li> </ol> <p>You don't need to delete the originals: <code>ctx</code> and tool-specific files can coexist. But centralizing in <code>.context/</code> means every tool gets the same context.</p>","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":"<code>.context/</code> Is Designed to Be Committed","text":"<p>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.</p> <p><code>ctx init</code> automatically adds these <code>.gitignore</code> entries:</p> <pre><code># 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</code></pre> <p>With those in place, committing is straightforward:</p> <pre><code># 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</code></pre> <p>Teammates pull and immediately have context. No per-developer setup needed.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-about-claude","level":3,"title":"What about <code>.claude/</code>?","text":"<p>The <code>.claude/</code> directory contains permissions that <code>ctx init</code> seeds. Hooks and skills are provided by the <code>ctx</code> plugin (not per-project files).</p> File Commit? Why <code>.claude/settings.local.json</code> No Machine-specific, accumulates session permissions <code>.claude/settings.golden.json</code> Yes Curated permission snapshot (via <code>ctx permission snapshot</code>)","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#merge-conflicts-in-context-files","level":3,"title":"Merge Conflicts in Context Files","text":"<p>Context files are plain Markdown. Resolve conflicts the same way you would for any other documentation file:</p> <pre><code># 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</code></pre> <p>Common conflict scenarios:</p> <ul> <li>TASKS.md: Two people added tasks: Keep both.</li> <li>DECISIONS.md: Same decision recorded differently: Unify the entry.</li> <li>LEARNINGS.md: Parallel discoveries: Keep both, remove duplicates.</li> </ul>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#gradual-adoption","level":3,"title":"Gradual Adoption","text":"<p>You don't need the whole team to switch at once:</p> <ol> <li>One person runs <code>ctx init --merge</code> and commits;</li> <li><code>CLAUDE.md</code> instructions work immediately for Claude Code users;</li> <li>Other tool users can adopt at their own pace using <code>ctx setup <tool></code>;</li> <li>Context files benefit everyone who reads them, even without tool integration.</li> </ol>","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/#check-status","level":3,"title":"Check Status","text":"<p>Run subsequent commands from the project root (the directory that holds <code>.context/</code> and <code>.git/</code>); <code>ctx</code> reads <code>$PWD/.context/</code>.</p> <pre><code>ctx status\n</code></pre> <p>You should see your context files listed with token counts and no warnings.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#test-memory","level":3,"title":"Test Memory","text":"<p>Start a new AI session and ask: \"Do you remember?\"</p> <p>The AI should cite specific context:</p> <ul> <li>Current tasks from <code>.context/TASKS.md</code>;</li> <li>Recent decisions or learnings;</li> <li>Session history (if you've had prior sessions);</li> </ul> <p>If it responds with generic \"I don't have memory\", check that <code>ctx</code> is in your PATH (<code>which ctx</code>) and that hooks are configured (see Troubleshooting).</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#verify-the-merge","level":3,"title":"Verify the Merge","text":"<p>If you used <code>--merge</code>, check that your original content is intact:</p> <pre><code># 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</code></pre>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Getting Started: Full setup walkthrough</li> <li>Context Files: What each <code>.context/</code> file does</li> <li>Integrations: Per-tool setup (Claude Code, Cursor, Aider, Copilot)</li> <li>CLI Reference: All <code>ctx</code> commands and flags</li> </ul>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/release/","level":1,"title":"Cutting a Release","text":"<p>Full Release Checklist</p> <p>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.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#prerequisites","level":2,"title":"Prerequisites","text":"<p>Before you can cut a release you need:</p> <ul> <li>Push access to <code>origin</code> (GitHub)</li> <li>GPG signing configured (<code>make gpg-test</code>)</li> <li>Go installed (version in <code>go.mod</code>)</li> <li>Zensical installed (<code>make site-setup</code>)</li> <li>A clean working tree (<code>git status</code> shows nothing to commit)</li> </ul>","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":"<pre><code>echo \"0.9.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.9.0\"\n</code></pre> <p>The VERSION file uses bare semver (<code>0.9.0</code>), no <code>v</code> prefix. The release script adds the <code>v</code> prefix for git tags.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#2-generate-release-notes","level":3,"title":"2. Generate Release Notes","text":"<p>In Claude Code:</p> <pre><code>/_ctx-release-notes\n</code></pre> <p>This analyzes commits since the last tag and writes <code>dist/RELEASE_NOTES.md</code>. The release script refuses to proceed without this file.</p>","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":"<pre><code>/ctx-link-check # audit docs for dead links\nmake audit # full check: fmt, vet, lint, style, test\ngit status # must be clean\n</code></pre>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#4-run-the-release","level":3,"title":"4. Run the Release","text":"<pre><code>make release\n</code></pre> <p>Or, if you are in a Claude Code session:</p> <pre><code>/_ctx-release\n</code></pre> <p>The release script does everything in order:</p> Step What happens 1 Reads <code>VERSION</code>, 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 (<code>make site</code>) 7 Commits all version and docs updates 8 Runs <code>make test</code> and <code>make smoke</code> 9 Builds binaries for all 6 platforms via <code>hack/build-all.sh</code> 10 Creates a signed git tag (<code>v0.9.0</code>) 11 Pushes the tag to origin 12 Updates and pushes the <code>latest</code> 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":"<p>Pushing a <code>v*</code> tag triggers <code>.github/workflows/release.yml</code>:</p> <ol> <li>Checks out the tagged commit</li> <li>Runs the full test suite</li> <li>Builds binaries for all platforms</li> <li>Creates a GitHub Release with auto-generated notes</li> <li>Uploads binaries and SHA256 checksums</li> </ol>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#6-verify","level":3,"title":"6. Verify","text":"<ul> <li> GitHub Releases shows the new version</li> <li> All 6 binaries are attached (linux/darwin x amd64/arm64, windows x amd64)</li> <li> SHA256 files are attached</li> <li> Release notes look correct</li> </ul>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#what-gets-updated-automatically","level":2,"title":"What Gets Updated Automatically","text":"<p>The release script updates 8 files so you do not have to:</p> File What changes <code>internal/assets/claude/.claude-plugin/plugin.json</code> Plugin version <code>.claude-plugin/marketplace.json</code> Marketplace version (2 fields) <code>editors/vscode/package.json</code> VS Code extension version <code>editors/vscode/package-lock.json</code> VS Code lock version (2 fields) <code>docs/index.md</code> Download URLs <code>docs/home/getting-started.md</code> Download URLs <code>docs/operations/integrations.md</code> VSIX filename version <code>docs/reference/versions.md</code> New version row + latest pointer <p>The Go binary version is injected at build time via <code>-ldflags</code> from the VERSION file. No source file needs editing.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#build-targets-reference","level":2,"title":"Build Targets Reference","text":"Target What it does <code>make release</code> Full release (script + tag + push) <code>make build</code> Build binary for current platform <code>make build-all</code> Build all 6 platform binaries <code>make test</code> Unit tests <code>make smoke</code> Integration smoke tests <code>make audit</code> Full check (fmt + vet + lint + drift + docs + test) <code>make site</code> 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":"<pre><code>ERROR: dist/RELEASE_NOTES.md not found.\n</code></pre> <p>Run <code>/_ctx-release-notes</code> in Claude Code first, or write <code>dist/RELEASE_NOTES.md</code> manually.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#working-tree-is-not-clean","level":3,"title":"\"Working Tree Is Not Clean\"","text":"<pre><code>ERROR: Working tree is not clean.\n</code></pre> <p>Commit or stash all changes before running <code>make release</code>.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#tag-already-exists","level":3,"title":"\"Tag Already Exists\"","text":"<pre><code>ERROR: Tag v0.9.0 already exists.\n</code></pre> <p>You cannot release the same version twice. Either bump VERSION to a new version, or delete the old tag if the release was incomplete:</p> <pre><code>git tag -d v0.9.0\ngit push origin :refs/tags/v0.9.0\n</code></pre>","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":"<p>The tag is already published. Fix the issue, bump to a patch version (e.g. <code>0.9.1</code>), and release again. Do not force-push tags that others may have already fetched.</p>","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":"<p>New versions of <code>ctx</code> may ship updated permissions, <code>CLAUDE.md</code> directives, or plugin hooks and skills.</p> <p>Claude Code User?</p> <p>The marketplace can update skills, hooks, and prompts independently: <code>/plugin</code> → select <code>ctx</code> → Update now (or enable auto-update).</p> <p>The <code>ctx</code> binary is separate: rebuild from source or download a new release when one is available, then run <code>ctx init --reset --merge</code>. Knowledge files are preserved automatically.</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#tldr","level":2,"title":"TL:DR","text":"<pre><code># 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</code></pre>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#what-changes-between-versions","level":2,"title":"What Changes between Versions","text":"<p><code>ctx init</code> generates two categories of files:</p> Category Examples Changes between versions? Infrastructure <code>.claude/settings.local.json</code> (permissions), ctx-managed sections in <code>CLAUDE.md</code>, <code>ctx</code> plugin (hooks + skills) Yes Knowledge <code>.context/TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>, <code>ARCHITECTURE.md</code>, <code>GLOSSARY.md</code>, <code>CONSTITUTION.md</code>, <code>AGENT_PLAYBOOK.md</code> No: this is your data <p>Infrastructure is regenerated by <code>ctx init</code> and plugin updates. Knowledge files are yours and should never be overwritten.</p>","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":"<p>Build from source or download the binary:</p> <pre><code>cd /path/to/ctx-source\ngit pull\nmake build\nsudo make install\nctx --version # verify\n</code></pre>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#2-reinitialize","level":3,"title":"2. Reinitialize","text":"<pre><code>ctx init --reset --merge\n</code></pre> <ul> <li><code>--force</code> regenerates infrastructure files (permissions, ctx-managed sections in <code>CLAUDE.md</code>).</li> <li><code>--merge</code> preserves your content outside <code>ctx</code> markers.</li> </ul> <p>Knowledge files (<code>.context/TASKS.md</code>, <code>DECISIONS.md</code>, etc.) are preserved automatically: <code>ctx init</code> only overwrites infrastructure, never your data.</p> <p>Encryption key: The encryption key lives at <code>~/.ctx/.ctx.key</code> (outside the project). Reinit does not affect it. If you have a legacy key at <code>.context/.ctx.key</code> or <code>~/.local/ctx/keys/</code>, copy it manually (see Syncing Scratchpad Notes).</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#3-update-the-ctx-plugin","level":3,"title":"3. Update the <code>ctx</code> Plugin","text":"<p>If you use Claude Code, update the plugin to get new hooks and skills:</p> <ol> <li>Open <code>/plugin</code> in Claude Code.</li> <li>Select <code>ctx</code>.</li> <li>Click Update now.</li> </ol> <p>Or enable auto-update so the plugin stays current without manual steps.</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#4-review-custom-settings","level":3,"title":"4. Review Custom Settings","text":"<p>If you added custom permissions to <code>.claude/settings.local.json</code> beyond what <code>ctx init</code> provides, diff and merge:</p> <pre><code>diff .claude.bak/settings.local.json .claude/settings.local.json\n</code></pre> <p>Manually add back any custom entries that the new init dropped.</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#5-verify","level":3,"title":"5. Verify","text":"<p>Run from the project root (where <code>.context/</code> lives):</p> <pre><code>ctx status # context files intact\nctx drift # no broken references\n</code></pre>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#6-clean-up","level":3,"title":"6. Clean Up","text":"<p>If you made manual backups, remove them once satisfied:</p> <pre><code>rm -rf .context.bak .claude.bak CLAUDE.md.bak\n</code></pre>","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":"<p>The old binary still works with your existing <code>.context/</code> files. But you may miss:</p> <ul> <li>New plugin hooks that enforce better practices or catch mistakes;</li> <li>Updated skill prompts that produce better results;</li> <li>New <code>.gitignore</code> entries for directories added in newer versions;</li> <li>Bug fixes in the CLI itself.</li> </ul> <p>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.</p> <p>Context files are plain Markdown: They never break between versions.</p> <p>The surrounding infrastructure is what evolves.</p>","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":"<p>Systematically build architecture documentation across one or more repositories using <code>ctx</code> skills. Each invocation does one unit of work; a simple loop drives the agent through all phases.</p> <p>When to use: When onboarding to a new codebase, performing architecture reviews, or building up <code>.context/</code> documentation across a workspace of repos.</p> <p>Prerequisites: <code>ctx</code> installed, repos cloned under a shared workspace directory (e.g., <code>~/WORKSPACE/</code>).</p> <p>Companion skills:</p> <ul> <li><code>/ctx-architecture</code>: structural baseline and principal analysis</li> <li><code>/ctx-architecture-enrich</code>: code intelligence enrichment via a code-intelligence MCP (canonical: GitNexus)</li> <li><code>/ctx-architecture-failure-analysis</code>: adversarial failure analysis</li> </ul>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#overview","level":2,"title":"Overview","text":"<p>The agent progresses through phases per repo, depth-first:</p> Phase Skill What it does <code>bootstrap</code> <code>ctx init</code> + <code>/ctx-architecture</code> Initialize context and build structural baseline <code>principal</code> <code>/ctx-architecture principal</code> Deep analysis: vision, bottlenecks, alternatives <code>enriched</code> <code>/ctx-architecture-enrich</code> Quantify with code intelligence (blast radius, flows) <code>frontier-N</code> <code>/ctx-architecture</code> (re-run) Explore unexplored areas found in convergence report <code>lens-*</code> <code>/ctx-architecture</code> with lens Focused exploration through conceptual lenses <p>Exploration stops when convergence >= 0.85, frontier runs plateau, or all lenses are exhausted.</p>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#setup","level":2,"title":"Setup","text":"<p>Create a tracking directory in your workspace root:</p> <pre><code>cd ~/WORKSPACE\nmkdir -p .arch-explorer\n</code></pre> <p>Create <code>.arch-explorer/manifest.json</code> listing your repos:</p> <pre><code>{\n \"repos\": [\"ctx\", \"portal\", \"infra\"],\n \"current_repo_index\": 0,\n \"progress\": {}\n}\n</code></pre> <p>Create <code>.arch-explorer/run-log.md</code> (empty, the agent appends to it).</p>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#prompt","level":2,"title":"Prompt","text":"<p>Save this as <code>.arch-explorer/PROMPT.md</code> 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.</p> <pre><code>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, code-intelligence MCP indexed (canonical: GitNexus) |\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 `$PWD/.context/` exists for THIS sub-repo:\n\n ```bash\n test -d \"$PWD/.context\" || {\n echo \"STOP: no .context/ at $PWD. Re-launch the agent from\"\n echo \"this sub-repo's root:\"\n echo \" cd $PWD && claude --print 'Follow .arch-explorer/PROMPT.md' --allowedTools '*'\"\n exit 1\n }\n ```\n\n If it fails, STOP. `ctx` reads `$PWD/.context/`; the agent\n cannot change its own working directory after launch — only the\n caller controls it. Do not proceed, do not run `ctx` commands,\n 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 a code-intelligence MCP is connected. Canonical\n smoke test: `mcp__gitnexus__list_repos` (or the equivalent\n smoke test for your configured tool).\n - Success = non-empty list returned with no error.\n - If no code-intelligence MCP is available, log as\n `enriched-skipped` and advance 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 (no code-intelligence MCP\n connected, broken repo, etc.), log the failure with reason and\n 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</code></pre>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#invocation","level":2,"title":"Invocation","text":"<p>The caller MUST launch the agent with its working directory set to the sub-repo. The agent verifies this at Step 3.2 and stops if <code>$PWD/.context/</code> is missing. The wrapper reads the manifest to pick the current sub-repo, <code>cd</code>s into it, then launches <code>claude</code>.</p> <p>Single run (safest for quota):</p> <pre><code>cd ~/WORKSPACE\nREPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\ncd \"$REPO\" && \\\n claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*'\n</code></pre> <p>Batch of N runs:</p> <pre><code>cd ~/WORKSPACE\nfor i in $(seq 1 5); do\n REPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\n (cd \"$REPO\" && \\\n claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*')\n echo \"--- Run $i complete (repo: $REPO) ---\"\ndone\n</code></pre> <p>Resume after interruption:</p> <p>Just run the wrapper again. The manifest tracks state; the agent picks up where it left off. The sub-repo directory is recomputed from the manifest on each invocation, so the agent is always anchored at the right project root.</p>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#tips","level":2,"title":"Tips","text":"<ul> <li>Start small: list 1-2 repos in the manifest first. Add more once you're confident in the output quality.</li> <li>The code-intelligence MCP is optional: the enrichment phase is skipped gracefully if no such MCP is connected (canonical: GitNexus; equivalents work). You still get structural and principal analysis.</li> <li>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.</li> <li>Lens runs are the payoff: the first three phases build the map; lens runs find the interesting things (security gaps, performance cliffs, stability risks).</li> </ul>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#history","level":2,"title":"History","text":"<ul> <li>2026-04-07: Original prompt created as <code>hack/agents/architecture-explorer.md</code>.</li> <li>2026-04-16: Moved to docs as a runbook for discoverability.</li> <li>2026-04-20: Added per-invocation working-directory pinning in the wrapper (formerly via <code>CTX_DIR</code>; now via <code>cd \"$REPO\"</code>), so the agent writes artifacts to the sub-repo's <code>.context/</code> instead of the inherited workspace one.</li> </ul>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/audit-channel/","level":1,"title":"Out-of-Band Audit Channel","text":"","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#the-problem","level":2,"title":"The Problem","text":"<p>The agent that just shipped a feature is the worst possible reviewer of its own discipline. It will mark its own work complete, label deferred docs as \"Phase 2,\" and skip past its own CONVENTIONS.md rule with conviction. Mid-task tunnel vision suppresses the rules it read at session start.</p> <p>You cannot fix that with more advisory prose: the same convention that didn't stop the agent the first time won't stop the next agent either. What works is mechanical verbatim relay — the same channel ctx already uses for <code>ctx remind</code>, journal-import nudges, and knowledge-growth warnings. Agents echo those without filtering, every turn, because the relay bypasses judgment.</p> <p>This runbook shows how to run discipline audits out of band (from a separate Claude Code session, on your plan-billed subscription, not the working session's API) and drop their findings onto the verbatim-relay channel so the next interactive session sees them at the top of its next turn.</p> <p>Maintainer tooling: lives in <code>ctxctl</code>, not the shipped <code>ctx</code> binary</p> <p><code>ctxctl audit</code> and the <code>ctxctl audit-relay</code> hook are the generic relay half: a place for any out-of-band tool to drop a report and have it relayed. They live in <code>ctxctl</code> — ctx's separate maintainer/contributor binary — not in the user-facing <code>ctx</code> binary, so end users never carry an audit hook they have no producer for. The auditor that produces the report is project-specific — it must know your conventions and directory layout. ctx dogfoods its own internal auditor (<code>_ctx-surface-audit</code>, a repo-only skill that scans ctx's <code>internal/</code> tree); the examples below use it as a concrete reference. To adopt the pattern in your own project, build the same out-of-band relay plus your own audit skill. ctx maintainers build and install <code>ctxctl</code> once with <code>make reinstall-ctxctl</code> (→ <code>/usr/local/bin/ctxctl</code>); every worktree then shares the one binary.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#tldr","level":2,"title":"TL;DR","text":"<pre><code># 1. From a separate Claude Code session, run your project's\n# audit skill (ctx's own internal example shown here):\n/_ctx-surface-audit # default: main..HEAD\n\n# 2. It writes a structured report:\n.context/audit/surface.md\n\n# 3. Back in the working session, the next prompt fires the\n# repo-local UserPromptSubmit hook (wired in\n# .claude/settings.local.json, not by `ctx setup`):\nctxctl audit-relay\n\n# 4. The agent / human sees a verbatim-relay box on the next\n# response, listing the specific findings.\n\n# 5. After addressing the findings:\nctxctl audit dismiss surface # stops the relay\n</code></pre>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>ctxctl audit list</code> CLI command Show all reports with status and age <code>ctxctl audit show ID</code> CLI command Print one report's body, pipe-friendly <code>ctxctl audit dismiss ID</code> CLI command Mark a report dismissed against its current digest <code>ctxctl audit dismiss --all</code> CLI command Bulk dismissal <code>ctxctl audit-relay</code> CLI command UserPromptSubmit hook; verbatim-relays reports <code>_ctx-surface-audit</code> Skill ctx's own internal auditor — reference example, not bundled","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#why-a-separate-session","level":2,"title":"Why a Separate Session","text":"<p>Two reasons, both load-bearing:</p> <ol> <li>Fresh-context judgment. The auditor must not inherit the implementer's working memory of \"what we tried, what we decided to defer, why this is fine.\" The audit only works if the reviewer reads the diff cold.</li> <li>Cost shape. A per-commit AI gate burns API tokens on every commit, regardless of branch maturity. Running the auditor manually from a separate Claude Code session bills against your interactive plan, not the API, and lets you decide when to spend the cycles (typically right before a PR, not on every micro-commit).</li> </ol> <p>The <code>/_ctx-surface-audit</code> skill enforces this with a hard dirty-tree refusal: invoking it in a working session with uncommitted changes returns</p> <p>Run this audit from a separate Claude Code session.</p> <p>There is no override flag, by design.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-1-land-your-work-then-open-a-second-session","level":3,"title":"Step 1: Land Your Work, Then Open a Second Session","text":"<p>Finish the feature on your working branch (commit, lint, test). Open a second Claude Code window in the same project worktree. The audit runs against <code>main..HEAD</code> by default.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-2-invoke-the-auditor","level":3,"title":"Step 2: Invoke the Auditor","text":"<pre><code>You (in session 2): \"/_ctx-surface-audit\"\n\nSkill: \"Scanned 4 commits, 3 surfaces detected.\n Wrote .context/audit/surface.md (status: findings).\n Open a working session — the audit-relay hook will\n relay the findings on the next prompt.\"\n</code></pre> <p>The auditor compares the branch against <code>main</code>, finds new subcommands / flags / behavior changes, checks each one against SKILL.md / recipe / <code>docs/cli</code> coverage, and writes a structured report.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-3-return-to-the-working-session","level":3,"title":"Step 3: Return to the Working Session","text":"<p>The next time you submit a prompt in your working session, the <code>ctxctl audit-relay</code> hook (a UserPromptSubmit hook wired in the repo-local <code>.claude/settings.local.json</code> — maintainer- only; <code>ctx setup</code> does not install it) reads <code>.context/audit/</code> and emits a verbatim-relay box at the top of the agent's response:</p> <pre><code>┌─ Audit Reports ──────────────────────────────────────\n│ [surface] main..HEAD\n│ Commit 6bcaf889 added user-facing surface without docs:\n│\n│ • New subcommand `ctx pad undo`\n│ - SKILL.md: internal/assets/claude/skills/ctx-pad/SKILL.md\n│ command-mapping table is missing the row\n│ - Recipe: docs/recipes/scratchpad-with-claude.md unchanged\n│\n│ Fix:\n│ - edit internal/assets/claude/skills/ctx-pad/SKILL.md\n│ - edit docs/recipes/scratchpad-with-claude.md\n│\n│ Dismiss: ctxctl audit dismiss <id>\n│ Dismiss all: ctxctl audit dismiss --all\n└──────────────────────────────────────────────────\n</code></pre> <p>The agent echoes this verbatim — that is the discipline mechanism. You (or the agent) then address each cited file.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-4-dismiss","level":3,"title":"Step 4: Dismiss","text":"<p>Once you've addressed the findings (or accepted them as out-of-scope), dismiss the report:</p> <pre><code>ctxctl audit dismiss surface\n</code></pre> <p>Dismissal is bound to the report digest at dismiss time. A subsequent audit that produces the same findings stays dismissed. A subsequent audit that finds new surface drift produces a fresh digest and re-surfaces the report at the next prompt.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#retention","level":2,"title":"Retention","text":"<p>The audit channel keeps one report per kind. Re-running <code>/_ctx-surface-audit</code> overwrites the prior <code>surface.md</code>. Reports older than 30 days are still relayed but prefixed with a <code>STALE — main..HEAD (audited 32d ago)</code> marker so the recipient knows the assessment may not match current code.</p> <p>History (which audits ran when) is preserved by the dismissal ledger at <code>.context/audit/.dismissed.json</code>. The ledger lives next to the reports — not under <code>.context/state/</code> — so nuking session state never silently re-surfaces a dismissed audit.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#when-to-run-the-auditor","level":2,"title":"When to Run the Auditor","text":"<ul> <li>Before opening a PR. The natural cadence. The audit exists to catch the gaps you can't see in your own branch.</li> <li>After landing a multi-commit feature. Especially when the feature added new subcommands or flags.</li> <li>Periodically on <code>main</code>, with a longer range like <code>HEAD~50..HEAD</code>, to catch surface drift that crept in before this channel existed.</li> </ul> <p>There is no automated trigger in Phase 1. The cost shape is intentional: cron and post-commit-hook drivers stay on the deferred list until the user-driven workflow proves out.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#other-audit-skills","level":2,"title":"Other Audit Skills","text":"<p><code>_ctx-surface-audit</code> is the first of a family of ctx's own internal auditors (all <code>_</code>-prefixed, repo-only). The scaffolding they share — channel, ledger, hook, CLI — lives in the maintainer-only <code>ctxctl</code> binary; the auditors themselves are repo-only skills. Planned siblings under the same shape:</p> <ul> <li><code>_ctx-spec-trailer-audit</code> — does each commit's <code>Spec:</code> trailer point at a spec that genuinely covers that commit's scope?</li> <li><code>_ctx-capture-audit</code> — was a Decision or Learning persisted for non-trivial work that ended without one?</li> </ul> <p>Each lives in its own SKILL.md and writes its own report file (e.g. <code>.context/audit/spec-trailer.md</code>). The hook relays whatever it finds, with no per-kind plumbing — which is exactly what lets your project's auditors plug in without touching ctx.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#see-also","level":2,"title":"See Also","text":"<ul> <li>Spec: out-of-band audit channel: full design rationale + Open Questions</li> <li>CONVENTIONS → User-Facing Surface Completeness: the canonical rule the surface audit enforces</li> <li>Detecting and Fixing Drift: programmatic drift detection that complements judgment-based audits</li> </ul>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/backup-strategy/","level":1,"title":"Backup Strategy","text":"<p><code>ctx backup</code> was removed. File-level backup is not <code>ctx</code>'s responsibility; your OS or a dedicated backup tool handles it better and without locking you into a specific mount strategy.</p> <p>This runbook explains what to back up, how <code>ctx hub</code> reduces the surface, and what options exist for the rest.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-to-back-up","level":2,"title":"What To Back Up","text":"<p>Per project:</p> <ul> <li><code>.context/</code>: all context files, journal, state, scratchpad.</li> <li><code>.claude/</code>: Claude Code settings, hooks, skills specific to the project. Skip this entry when it lives in git; the repo is the backup.</li> </ul> <p>Per user:</p> <ul> <li><code>~/.ctx/</code>: global config, the encryption key (<code>~/.ctx/.ctx.key</code>), hub data directory (if running a local hub).</li> </ul>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#how-hub-reduces-backup-needs","level":2,"title":"How Hub Reduces Backup Needs","text":"<p><code>ctx hub</code> replicates the knowledge surface across machines:</p> <ul> <li><code>DECISIONS.md</code></li> <li><code>LEARNINGS.md</code></li> <li><code>CONVENTIONS.md</code></li> <li><code>CONSTITUTION.md</code></li> <li><code>ARCHITECTURE.md</code></li> <li>Task items promoted to hub</li> </ul> <p>If you run <code>ctx hub</code> (as a server or by subscribing to someone else's), the data that matters most survives losing any single machine.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-hub-does-not-replicate","level":2,"title":"What Hub Does Not Replicate","text":"<p>Hub is not a file-level backup. The following still live only on the machine that produced them:</p> <ul> <li>Journal entries (<code>.context/journal/*.md</code>)</li> <li>Runtime state (<code>.context/state/*</code>)</li> <li>Session event log (<code>.context/events.jsonl</code>)</li> <li>Scratchpad (<code>.context/.pad</code>)</li> <li>Encrypted notify/webhook config (<code>.context/.notify.enc</code>)</li> <li>The encryption key itself (<code>~/.ctx/.ctx.key</code>)</li> </ul> <p>If you need those to survive a disk failure, use a file-level backup.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#example-strategies","level":2,"title":"Example Strategies","text":"","path":["Operations","Runbooks","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":"<pre><code># 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</code></pre> <p>Adjust excludes for the trash you don't want to back up. The <code>.context/state/</code> dir is ephemeral per-session; skip it.</p>","path":["Operations","Runbooks","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":"<p>iCloud Drive, Dropbox, or any directory watched by a sync client:</p> <pre><code>0 3 * * * cp -a ~/WORKSPACE/some-project/.context \\\n ~/CloudDrive/ctx-backups/some-project/$(date +\\%Y-\\%m-\\%d)\n</code></pre> <p>Daily snapshots, cloud provider handles the replication.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#3-time-machine-macos","level":3,"title":"3. Time Machine (macOS)","text":"<p>If you already run Time Machine, ensure <code>~/WORKSPACE</code> and <code>~/.ctx</code> are not in its exclusion list. Time Machine handles versioning; you get point-in-time recovery for free.</p>","path":["Operations","Runbooks","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":"<p>For deduplicated, versioned, encrypted backups:</p> <pre><code># 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</code></pre> <p>Use <code>restic</code> if you prefer S3-compatible targets.</p>","path":["Operations","Runbooks","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":"<ul> <li>Journal: session histories are local-only until exported.</li> <li>Scratchpad: private notes, encrypted locally.</li> <li>Encryption key: losing <code>~/.ctx/.ctx.key</code> means losing access to every encrypted file in every project.</li> <li>Non-hub projects: projects that never called <code>ctx hub register</code> have zero cross-machine persistence.</li> </ul> <p>For these, pick one strategy above and forget about it.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#why-ctx-no-longer-ships-a-backup-command","level":2,"title":"Why <code>ctx</code> No Longer Ships a Backup Command","text":"<p>Backup is inherently environment-specific: SMB, NFS, S3, rsync, Time Machine, Borg, restic. Every user has a different story. The previous <code>ctx backup</code> picked SMB via GVFS, which was Linux-only and narrow. Chasing mount strategies would never generalize.</p> <p>Hub is the right answer for the data <code>ctx</code> owns (knowledge). For everything else, your OS or a dedicated backup tool is the right layer.</p>","path":["Operations","Runbooks","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":"<p>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.</p> <p>When to use: When a release includes breaking changes (command renames, removed flags, changed defaults) that require user action.</p> <p>Companion: Upgrade guide covers the general upgrade flow. This runbook covers the breaking-change specifics.</p>","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":"<p>Ask your agent to diff the CLI surface between the old and new version:</p> <pre><code>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</code></pre> <p>Or use the <code>/_ctx-command-audit</code> skill after the rename.</p>","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-2-regenerate-infrastructure","level":2,"title":"Step 2: Regenerate Infrastructure","text":"<pre><code># Install the new binary\nmake build && sudo make install\n\n# Regenerate CLAUDE.md and permissions\nctx init --reset --merge\n</code></pre> <p><code>--merge</code> preserves your knowledge files (TASKS.md, DECISIONS.md, etc.) while regenerating infrastructure (permissions, CLAUDE.md managed sections).</p>","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":"<pre><code>/plugin -> select ctx -> Update now\n</code></pre> <p>Or, if using a local clone:</p> <pre><code>make plugin-reload\n# restart Claude Code\n</code></pre>","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":"<p>Search your scripts and aliases for old command names:</p> <pre><code># Example: find references to old command names\ngrep -r \"ctx old-command\" ~/scripts/ ~/.zshrc ~/.bashrc\n</code></pre> <p>Replace with the new names per the changelog.</p>","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":"<p>If you have custom hooks in <code>.claude/settings.local.json</code> that reference <code>ctx</code> commands, update them:</p> <pre><code>jq '.hooks' .claude/settings.local.json | grep \"ctx \"\n</code></pre>","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-6-verify","level":2,"title":"Step 6: Verify","text":"<p>Run from the project root:</p> <pre><code>ctx status # context files intact\nctx drift # no broken references\nmake test # if you're a contributor\n</code></pre>","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":"<p>When preparing a release with breaking changes, create a section in the release notes using this template:</p> <pre><code>## 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</code></pre> <p>Repeat for each breaking change. Users should be able to follow the notes mechanically without needing to understand the codebase.</p>","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":"<p>A structured audit of the codebase: dead code, magic strings, documentation drift, security surface, and roadmap opportunities.</p> <p>When to run: Before a release, after a long YOLO sprint, quarterly, or when planning the next phase of work.</p> <p>Time: ~15-30 minutes with a team of agents.</p>","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":"<p>Start a Claude Code session with a clean git state (<code>git stash</code> or commit first). Paste or adapt the prompt below. The agent does the analysis; you triage the findings.</p>","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#prompt","level":2,"title":"Prompt","text":"<pre><code>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</code></pre>","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#tips","level":2,"title":"Tips","text":"<ul> <li> <p>Clean state matters: the prompt says \"no code changes\" but accidents happen. Start from a clean git state so you can <code>git checkout .</code> if needed.</p> </li> <li> <p>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.</p> </li> <li> <p>Reports feed TASKS.md: after the audit, read each report and create tasks in the appropriate Phase section. The reports are input, not output.</p> </li> <li> <p>ideas/ is gitignored: reports saved there won't be committed. Move specific findings to TASKS.md, DECISIONS.md, or LEARNINGS.md to persist them.</p> </li> </ul>","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#history","level":2,"title":"History","text":"<ul> <li>2026-02-08: Original prompt created after a codebase audit sprint.</li> <li>2026-02-17: Improved with read-only agents, report structure template, CLI-scoped security review, and maintainability thresholds.</li> <li>2026-04-16: Moved from <code>hack/runbooks/</code> to <code>docs/operations/runbooks/</code>.</li> </ul>","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":"<p>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.</p> <p>When to run: Before a release, after adding several new pages, when the site feels sprawling, or when you suspect narrative gaps.</p> <p>Time: ~20-40 minutes with an agent session.</p>","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":"<p>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.</p>","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#prompt","level":2,"title":"Prompt","text":"<p>Paste or adapt the following into a Claude Code session. The agent needs read access to <code>docs/</code> and the site nav structure.</p> <pre><code>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</code></pre>","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#after-the-audit","level":2,"title":"After the Audit","text":"<ol> <li>Triage findings: not everything needs fixing. Focus on high severity.</li> <li>Merge weak pages first: fewer pages is almost always better.</li> <li>Add cross-links: cheapest improvement, highest reader impact.</li> <li>File split decisions in DECISIONS.md: page splits are architectural.</li> <li>Regenerate the site and spot-check nav after structural changes.</li> </ol>","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#history","level":2,"title":"History","text":"<ul> <li>2026-02-17: Created after merging <code>docs/re-explaining.md</code> into <code>docs/about.md</code>, which surfaced the pattern of weak standalone pages that dilute rather than add.</li> <li>2026-04-16: Moved from <code>hack/runbooks/</code> to <code>docs/operations/runbooks/</code>.</li> </ul>","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":"<p>Linear runbook for setting up a <code>ctx</code> Hub for yourself or a team. Consolidates pieces currently scattered across hub recipes and operations docs.</p> <p>When to use: First-time hub setup, or when onboarding a new team onto an existing hub.</p> <p>Prerequisites: <code>ctx</code> binary installed, network connectivity between hub and clients.</p> <p>Companion docs:</p> <ul> <li>Hub overview: what the hub is and is not</li> <li>Hub operations: data directory, systemd, backup, monitoring</li> <li>Hub failure modes: what can go wrong</li> </ul>","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) <pre><code>ctx hub start\n</code></pre> <p>See Hub Operations: Systemd Unit for the full unit file.</p> <pre><code>sudo systemctl enable --now ctx-hub\n</code></pre> <p>The hub creates <code>admin.token</code> on first start. Save this token; it is the only way to register clients.</p>","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":"<p>On first start, the hub writes <code>admin.token</code> to the data directory (default <code>~/.ctx/hub-data/</code>):</p> <pre><code>cat ~/.ctx/hub-data/admin.token\n</code></pre> <p>This token has full admin privileges. Keep it secret.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-3-register-clients","level":2,"title":"Step 3: Register Clients","text":"<p>For each client (person or machine) that will connect:</p> <pre><code># On the hub machine\nctx hub register --name \"volkan-laptop\" --admin-token <admin-token>\n</code></pre> <p>This returns a client token. Distribute it securely to the client.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-4-connect-clients","level":2,"title":"Step 4: Connect Clients","text":"<p>On each client machine, register the project with the hub. The <code>ctx hub *</code> commands above run on the hub server itself and don't need a project. The <code>ctx connection *</code> commands below are different: they live inside a project (the encrypted hub config is stored at <code>.context/.connect.enc</code>), so you have to tell <code>ctx</code> which project first.</p> <pre><code># In the project directory on the client machine:\nctx connection register <hub-address> --token <client-token>\n</code></pre> <p>Verify the connection:</p> <pre><code>ctx connection status\n</code></pre> <p>If the client doesn't have a project yet, run <code>ctx init</code> first in the project root.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-5-verify-sync","level":2,"title":"Step 5: Verify Sync","text":"<p>Push a test entry from one client and verify it arrives. Run each command on the client from inside the project directory; <code>ctx</code> reads <code>$PWD/.context/</code>.</p> <pre><code># 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</code></pre>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-6-configure-backup","level":2,"title":"Step 6: Configure Backup","text":"<p>Set up regular backups of the hub data directory. See Hub Operations: Backup and Restore.</p> <p>Minimum:</p> <pre><code># Add to cron\n0 */6 * * * cp ~/.ctx/hub-data/entries.jsonl ~/backups/entries-$(date +\\%F).jsonl\n</code></pre>","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":"<p>Coming Soon</p> <p>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.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#team-onboarding-checklist","level":2,"title":"Team Onboarding Checklist","text":"<p>When adding a new team member to an existing hub:</p> <ul> <li> Generate a client token (<code>ctx hub register --name \"<name>\"</code>)</li> <li> Share the token and hub address securely</li> <li> Have them run <code>ctx connection register <hub-address> --token <token></code></li> <li> Verify with <code>ctx connection status</code></li> <li> Point them to the Hub Getting Started recipe</li> </ul>","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":"<p>The hub isn't running or the port is wrong. Check:</p> <pre><code>ctx hub status # on the hub machine\nss -tlnp | grep 9900 # default port\n</code></pre>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#authentication-failed","level":3,"title":"\"Authentication Failed\"","text":"<p>The client token is wrong or was never registered. Re-register:</p> <pre><code>ctx hub register --name \"<name>\" --admin-token <admin-token>\n</code></pre>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#entries-not-syncing","level":3,"title":"Entries Not Syncing","text":"<p>Check that the client is listening:</p> <pre><code>ctx connection status\n</code></pre> <p>If connected but not syncing, check the hub logs for sequence mismatch errors. See Hub Failure Modes for details.</p>","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":"<p>Step-by-step onboarding sequence for new contributors. Consolidates setup instructions currently scattered across the README, contributing guide, and setup docs.</p> <p>When to use: First-time contributor setup, or when verifying your development environment after a major upgrade.</p>","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":"<pre><code>git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\n</code></pre> <p>Or fork first on GitHub, then clone your fork.</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-2-initialize-context","level":2,"title":"Step 2: Initialize Context","text":"<pre><code>ctx init\n</code></pre> <p><code>ctx init</code> creates the <code>.context/</code> directory with knowledge files and the <code>.claude/</code> directory with agent configuration. Run subsequent <code>ctx</code> commands from the project root; <code>ctx</code> reads <code>$PWD/.context/</code>.</p> <p>If <code>ctx</code> is not yet installed, proceed to Step 3 first, then come back.</p>","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":"<pre><code>make build\nsudo make install\n</code></pre> <p>Verify:</p> <pre><code>ctx --version\n</code></pre>","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":"<p>If you use Claude Code, install the plugin from your local clone so skills and hooks reflect your working tree:</p> <ol> <li>Launch <code>claude</code></li> <li>Type <code>/plugin</code> and press Enter</li> <li>Select Marketplaces -> Add Marketplace</li> <li>Enter the absolute path to your clone (e.g., <code>~/WORKSPACE/ctx</code>)</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code></li> </ol> <p>Verify:</p> <pre><code>claude /plugin list # should show ctx\n</code></pre> <p>See Contributing: Install the Plugin for details on cache clearing.</p>","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":"<pre><code>ctx config switch dev\n</code></pre> <p>This enables verbose logging and notify events (useful during development).</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-6-verify-hooks","level":2,"title":"Step 6: Verify Hooks","text":"<p>Start a Claude Code session and check that hooks fire:</p> <pre><code>claude\n</code></pre> <p>You should see <code>ctx</code> session hooks (ceremonies reminder, context loading) on session start. If not, check that the plugin is installed correctly (Step 4).</p>","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":"<p>In Claude Code:</p> <pre><code>/ctx-status\n</code></pre> <p>This should show context file health, active tasks, and recent decisions. If it works, your setup is complete.</p>","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":"<p>End the session and start a new one:</p> <pre><code>/ctx-remember\n</code></pre> <p>The agent should recall what happened in the previous session. This confirms that context persistence is working end-to-end.</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-9-run-tests","level":2,"title":"Step 9: Run Tests","text":"<pre><code>make test # unit tests\nmake audit # full check: fmt + vet + lint + drift + docs + test\n</code></pre> <p>All tests should pass with a clean clone.</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#quick-reference","level":2,"title":"Quick Reference","text":"Task Command Build <code>make build</code> Install <code>sudo make install</code> Test <code>make test</code> Full audit <code>make audit</code> Rebuild docs site <code>make site</code> Serve docs locally <code>make site-serve</code> Clear plugin cache <code>make plugin-reload</code> Switch config profile <code>ctx config switch dev</code>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#next-steps","level":2,"title":"Next Steps","text":"<ul> <li>Read the contributing guide for project layout, code style, and PR process</li> <li>Check TASKS.md for open work items</li> <li>Ask <code>/ctx-next</code> for suggested work</li> </ul>","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":"<p>Plugin-specific release procedure. The general release checklist covers the full <code>ctx</code> release; this runbook covers the plugin-specific steps that are not part of that flow.</p> <p>When to use: When releasing plugin changes (new skills, hook updates, permission changes) independently of a <code>ctx</code> binary release, or as a sub-procedure within the full release.</p>","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":"<p>The plugin lives at <code>internal/assets/claude/</code> and includes:</p> Component Path What it does Skills <code>internal/assets/claude/skills/</code> User-facing <code>/ctx-*</code> slash commands Hooks <code>internal/assets/claude/hooks/</code> Pre/post tool-use hooks Plugin manifest <code>internal/assets/claude/.claude-plugin/plugin.json</code> Declares skills, hooks, version Marketplace <code>.claude-plugin/marketplace.json</code> 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":"<p>If you added, removed, or modified hooks:</p> <pre><code># Verify hook definitions match implementations\nmake audit\n</code></pre> <p>Check that <code>plugin.json</code> lists all hooks correctly. Missing hooks silently fail to fire.</p>","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-2-bump-version","level":2,"title":"Step 2: Bump Version","text":"<p>Update the version in three places:</p> <ul> <li><code>internal/assets/claude/.claude-plugin/plugin.json</code></li> <li><code>.claude-plugin/marketplace.json</code> (two fields)</li> <li><code>editors/vscode/package.json</code> + <code>package-lock.json</code> (if VS Code extension is affected)</li> </ul> <p>The Release Script Does This</p> <p>If you're running <code>make release</code>, the script bumps these automatically from <code>VERSION</code>. Only bump manually if you're releasing the plugin independently.</p>","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":"<pre><code># Clear cached plugin\nmake plugin-reload\n\n# Restart Claude Code, then:\nclaude /plugin list # verify version\n</code></pre> <p>Test the critical paths:</p> <ul> <li> <code>/ctx-status</code> works</li> <li> Session hooks fire (ceremonies, context loading)</li> <li> At least one user-facing skill works end-to-end</li> <li> Pre-tool-use hooks block when they should</li> </ul>","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":"<p>Create a temporary project to verify the plugin works outside the <code>ctx</code> repo:</p> <pre><code>mkdir /tmp/test-ctx-plugin && cd /tmp/test-ctx-plugin\ngit init\nctx init\nclaude # start a session, verify hooks fire\n</code></pre>","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":"<p>The plugin manifest declares all user-invocable skills. Verify the count matches:</p> <pre><code># 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</code></pre> <p>These numbers should match (some skills are not user-invocable and won't appear in both counts).</p>","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":"<p>If releasing independently of a binary release:</p> <pre><code>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</code></pre> <p>If part of a full release, the release checklist handles this.</p>","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":"<p>Claude Code caches plugin files aggressively:</p> <pre><code>make plugin-reload # clears cache\n# restart Claude Code\n</code></pre>","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#hooks-dont-fire","level":3,"title":"Hooks Don't Fire","text":"<p>Check that the hook is registered in <code>plugin.json</code> and that the command it calls exists:</p> <pre><code>jq '.hooks' internal/assets/claude/.claude-plugin/plugin.json\n</code></pre>","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#version-mismatch","level":3,"title":"Version Mismatch","text":"<p>If <code>claude /plugin list</code> shows an old version after updating:</p> <pre><code>make plugin-reload\n# restart Claude Code\nclaude /plugin list # should show new version\n</code></pre>","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":"<p>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.</p> <p>When to run: Before every release. No exceptions.</p> <p>Companion: The <code>/_ctx-release</code> skill automates the tag-and-push portion; this checklist covers everything before and after that automation.</p>","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":"<p>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.</p>","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":"<p>Use the docs semantic audit runbook prompt. Fix high-severity findings (weak pages, broken narrative arcs). Medium-severity items can be deferred.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#3-sanitize-permissions","level":3,"title":"3. Sanitize Permissions","text":"<p>Follow the sanitize permissions runbook. Clean up <code>.claude/settings.local.json</code> before it gets committed as part of the release.</p>","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":"<pre><code>make audit # fmt + vet + lint + drift + docs + test\nmake smoke # integration smoke tests\n</code></pre> <p>All tests must pass. No exceptions.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#5-check-context-health","level":3,"title":"5. Check Context Health","text":"<p>Run from the project root:</p> <pre><code>ctx drift # broken references, stale patterns\nctx status # context file health\n/ctx-link-check # dead links in docs\n</code></pre> <p>Fix anything flagged.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#6-review-tasksmd","level":3,"title":"6. Review TASKS.md","text":"<p>Scan for incomplete tasks tagged as release-blocking. Either finish them or explicitly defer with a reason in the task note.</p>","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":"<pre><code>echo \"0.X.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.X.0\"\n</code></pre>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#8-generate-release-notes","level":3,"title":"8. Generate Release Notes","text":"<p>In Claude Code:</p> <pre><code>/_ctx-release-notes\n</code></pre> <p>Review <code>dist/RELEASE_NOTES.md</code>. Ensure it captures all user-visible changes.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#9-cut-the-release","level":3,"title":"9. Cut the Release","text":"<pre><code>make release\n</code></pre> <p>Or in Claude Code: <code>/_ctx-release</code>. See Cutting a Release for the full step-by-step.</p>","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":"<ul> <li> GitHub Releases shows the new version</li> <li> All 6 binaries are attached</li> <li> SHA256 checksums are attached</li> <li> Release notes render correctly</li> </ul>","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":"<p>If the plugin version changed, verify the marketplace entry:</p> <pre><code>claude /plugin list # shows updated version\n</code></pre>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#12-announce","level":3,"title":"12. Announce","text":"<p>Post in the project's communication channels. Reference the release notes.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#13-clean-up","level":3,"title":"13. Clean Up","text":"<pre><code>rm dist/RELEASE_NOTES.md # consumed by the release script\ngit stash pop # if you stashed earlier\n</code></pre>","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":"<p>Manual procedure for cleaning up <code>.claude/settings.local.json</code>. The agent may analyze and recommend, but you make every edit.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#why-manual-not-automated","level":2,"title":"Why Manual, Not Automated","text":"<p><code>settings.local.json</code> 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.</p> <p>When to run: After busy sessions where you clicked \"Allow\" many times, weekly hygiene (pair with <code>ctx drift</code>), or before committing <code>.claude/settings.local.json</code>.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-1-snapshot","level":2,"title":"Step 1: Snapshot","text":"<pre><code>cp .claude/settings.local.json /tmp/settings-backup-$(date +%Y%m%d).json\n</code></pre>","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":"<pre><code>jq '.permissions.allow[]' .claude/settings.local.json | sort\n</code></pre> <p>Eyeball it. You're looking for four categories:</p>","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":"<p>Entries that are clearly broken or meaningless:</p> <pre><code>Bash(done)\nBash(__NEW_LINE_aa838494a90279c4__ echo \"\")\n</code></pre> <p>Action: Delete.</p>","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":"<p>Entries with hardcoded paths, literal arguments, or exact commands that were accepted during a specific debugging session:</p> <pre><code>Bash(git -C /home/jose/WORKSPACE/ctx log --oneline --all -20)\nBash(/home/jose/WORKSPACE/ctx/ctx decision add \"Use PostgreSQL\" --context ...)\n</code></pre> <p>Signs of a one-off:</p> <ul> <li>Full absolute paths to specific files</li> <li>Literal string arguments (not wildcards)</li> <li>Very specific flag combinations</li> <li>Commands that look like they came from a single task</li> </ul> <p>Action: Delete unless you want to promote to a wildcard pattern.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#c-subsumed-entries-redundant","level":3,"title":"C. Subsumed Entries (Redundant)","text":"<p>A narrow entry that's already covered by a broader one:</p> <pre><code># 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</code></pre> <p>To find these, look for entries where removing the specific args would match an existing wildcard entry.</p> <p>Action: Delete the narrow entry.</p>","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":"<p>Same command with env vars in different order, or slight variations:</p> <pre><code>Bash(CGO_ENABLED=0 CTX_SKIP_PATH_CHECK=1 go test:*)\nBash(CTX_SKIP_PATH_CHECK=1 CGO_ENABLED=0 go test:*)\n</code></pre> <p>Action: Keep one, delete the other.</p>","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":"<p>While you're in here, also flag:</p> Pattern Risk <code>Bash(git push:*)</code> Bypasses block-git-push.sh hook <code>Bash(rm -rf:*)</code> Recursive delete, no confirmation <code>Bash(sudo:*)</code> Privilege escalation <code>Bash(echo:*)</code>, <code>Bash(cat:*)</code> Can compose into writes to sensitive files <code>Bash(curl:*)</code>, <code>Bash(wget:*)</code> Arbitrary network access Any write to <code>.claude/</code> paths Agent self-modification <p>See the <code>/ctx-permission-sanitize</code> skill for the full threat matrix.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-5-edit","level":2,"title":"Step 5: Edit","text":"<p>Edit <code>.claude/settings.local.json</code> directly in your editor. Remove flagged entries. Keep the JSON valid.</p> <pre><code># Validate JSON after editing\njq . .claude/settings.local.json > /dev/null && echo \"valid\" || echo \"BROKEN\"\n</code></pre>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-6-verify","level":2,"title":"Step 6: Verify","text":"<pre><code># Compare before/after\ndiff /tmp/settings-backup-$(date +%Y%m%d).json .claude/settings.local.json\n</code></pre>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-7-optionally-commit","level":2,"title":"Step 7: Optionally Commit","text":"<pre><code>git add .claude/settings.local.json\ngit commit -m \"chore: sanitize agent permissions\"\n</code></pre>","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":"<p>You can safely ask the agent to analyze the file:</p> <p>\"Look at my settings.local.json and tell me which permissions look like one-offs or are redundant.\"</p> <p>The agent can read and report. You do the edits.</p> <p>Do not add these to your allow list:</p> <ul> <li><code>Skill(ctx-permission-sanitize)</code></li> <li><code>Edit(.claude/settings.local.json)</code></li> <li>Any <code>Bash(...)</code> pattern that writes to <code>.claude/</code></li> </ul>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#history","level":2,"title":"History","text":"<ul> <li>2026-02-15: Created as manual-only procedure after deciding against a self-modifying skill.</li> <li>2026-04-16: Moved from <code>hack/runbooks/</code> to <code>docs/operations/runbooks/</code>.</li> </ul>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"recipes/","level":1,"title":"Recipes","text":"<p>Workflow recipes combining <code>ctx</code> commands and skills to solve specific problems.</p>","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":"<p>How commands, skills, and conversational patterns work together. Train your agent to be proactive through ask, guide, reinforce.</p>","path":["Recipes"],"tags":[]},{"location":"recipes/#setup-across-ai-tools","level":3,"title":"Setup across AI Tools","text":"<p>Initialize <code>ctx</code> and configure hooks for Claude Code, OpenCode, Cursor, Aider, Copilot, or Windsurf. Includes shell completion, watch mode for non-native tools, and verification.</p> <p>Uses: <code>ctx init</code>, <code>ctx setup</code>, <code>ctx agent</code>, <code>ctx completion</code>, <code>ctx watch</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#multilingual-session-parsing","level":3,"title":"Multilingual Session Parsing","text":"<p>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.</p> <p>Uses: <code>ctx journal source</code>, <code>ctx journal import</code>, <code>session_prefixes</code> in <code>.ctxrc</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#knowledge-base-phase-kb","level":2,"title":"Knowledge Base (Phase KB)","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#build-a-knowledge-base","level":3,"title":"Build a Knowledge Base","text":"<p>Stand up the editorial pipeline for knowledge-shaped work (research projects, vendor-spec analysis, post-incident reviews). Covers the pass-mode contract, source-coverage state-machine ledger, topic-adjacency pre-flight, cold-reader rubric, closeout/fold mechanism, and folder-shaped topic pages.</p> <p>Uses: <code>ctx init</code>, <code>ctx kb topic new</code>, <code>ctx kb note</code>, <code>ctx kb reindex</code>, <code>ctx handover write</code>, <code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, <code>/ctx-kb-site-review</code>, <code>/ctx-kb-ground</code>, <code>/ctx-kb-note</code>, <code>/ctx-handover</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#typical-kb-session","level":3,"title":"Typical KB Session","text":"<p>The everyday flow once the pipeline is set up: session start recall, ingest a transcript, ask grounded questions, park findings, wrap up via the mandatory handover.</p> <p>Uses: <code>/ctx-remember</code>, <code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, <code>/ctx-kb-note</code>, <code>/ctx-wrap-up</code>, <code>/ctx-handover</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#recover-an-aborted-kb-session","level":3,"title":"Recover an Aborted KB Session","text":"<p>What to do when the session ends after one or more editorial passes but before <code>/ctx-handover</code>. Closeouts survive the abort; the next session's <code>/ctx-remember</code> reads them as unfolded postdated artifacts; the next <code>/ctx-handover</code> folds them retroactively.</p> <p>Uses: <code>/ctx-remember</code>, <code>/ctx-handover</code></p>","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":"<p>Walk through a full <code>ctx</code> session from start to finish:</p> <ul> <li>Loading context,</li> <li>Picking what to work on,</li> <li>Committing with context,</li> <li>Capturing, reflecting, and saving a snapshot.</li> </ul> <p>Uses: <code>ctx status</code>, <code>ctx agent</code>, <code>/ctx-remember</code>, <code>/ctx-next</code>, <code>/ctx-commit</code>, <code>/ctx-reflect</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#session-ceremonies","level":3,"title":"Session Ceremonies","text":"<p>The two bookend rituals for every session: <code>/ctx-remember</code> at the start to load and confirm context, <code>/ctx-wrap-up</code> at the end to review the session and persist learnings, decisions, and tasks.</p> <p>Uses: <code>/ctx-remember</code>, <code>/ctx-wrap-up</code>, <code>/ctx-commit</code>, <code>ctx agent</code>, <code>ctx add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#browsing-and-enriching-past-sessions","level":3,"title":"Browsing and Enriching Past Sessions","text":"<p>Export your AI session history to a browsable journal site. Enrich entries with metadata and search across months of work.</p> <p>Uses: <code>ctx journal source/import</code>, <code>ctx journal site</code>, <code>ctx journal obsidian</code>, <code>ctx serve</code>, <code>/ctx-history</code>, <code>/ctx-journal-enrich</code>, <code>/ctx-journal-enrich-all</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#session-reminders","level":3,"title":"Session Reminders","text":"<p>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.</p> <p>Uses: <code>ctx remind</code>, <code>ctx remind list</code>, <code>ctx remind dismiss</code>, <code>ctx system check-reminders</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#reviewing-session-changes","level":3,"title":"Reviewing Session Changes","text":"<p>See what moved since your last session: context file edits, code commits, directories touched. Auto-detects session boundaries from state markers.</p> <p>Uses: <code>ctx change</code>, <code>ctx agent</code>, <code>ctx status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#pausing-context-hooks","level":3,"title":"Pausing Context Hooks","text":"<p>Silence all nudge hooks for a quick task that doesn't need ceremony overhead. Session-scoped: Other sessions are unaffected. Security hooks still fire.</p> <p>Uses: <code>ctx hook pause</code>, <code>ctx hook resume</code>, <code>/ctx-pause</code>, <code>/ctx-resume</code></p>","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":"<p>Record architectural decisions with rationale, capture gotchas and lessons learned, and codify conventions so they survive across sessions and team members.</p> <p>Uses: <code>ctx decision add</code>, <code>ctx learning add</code>, <code>ctx convention add</code>, <code>ctx index</code>, <code>/ctx-decision-add</code>, <code>/ctx-learning-add</code>, <code>/ctx-convention-add</code>, <code>/ctx-reflect</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#tracking-work-across-sessions","level":3,"title":"Tracking Work across Sessions","text":"<p>Add, prioritize, complete, snapshot, and archive tasks. Keep <code>TASKS.md</code> focused as your project evolves across dozens of sessions.</p> <p>Uses: <code>ctx task add</code>, <code>ctx task complete</code>, <code>ctx task archive</code>, <code>ctx task snapshot</code>, <code>/ctx-task-add</code>, <code>/ctx-archive</code>, <code>/ctx-next</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#using-the-scratchpad","level":3,"title":"Using the Scratchpad","text":"<p>Use the encrypted scratchpad for quick notes, working memory, and sensitive values during AI sessions. Natural language in, encrypted storage out.</p> <p>Uses: <code>ctx pad</code>, <code>/ctx-pad</code>, <code>ctx pad show</code>, <code>ctx pad edit</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#syncing-scratchpad-notes-across-machines","level":3,"title":"Syncing Scratchpad Notes across Machines","text":"<p>Distribute your scratchpad encryption key, push and pull encrypted notes via git, and resolve merge conflicts when two machines edit simultaneously.</p> <p>Uses: <code>ctx init</code>, <code>ctx pad</code>, <code>ctx pad resolve</code>, <code>scp</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#bridging-claude-code-auto-memory","level":3,"title":"Bridging Claude Code Auto Memory","text":"<p>Mirror Claude Code's auto memory (MEMORY.md) into <code>.context/</code> for version control, portability, and drift detection. Import entries into structured context files with heuristic classification.</p> <p>Uses: <code>ctx memory sync</code>, <code>ctx memory status</code>, <code>ctx memory diff</code>, <code>ctx memory import</code>, <code>ctx memory publish</code>, <code>ctx system check-memory-drift</code></p>","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":"<p>Choose the right output pattern for your Claude Code hooks: <code>VERBATIM</code> relay for user-facing reminders, hard gates for invariants, agent directives for nudges, and five more patterns across the spectrum.</p> <p>Uses: <code>ctx</code> plugin hooks, <code>settings.local.json</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#customizing-hook-messages","level":3,"title":"Customizing Hook Messages","text":"<p>Customize what hooks say without changing what they do. Override the QA gate for Python (<code>pytest</code> instead of <code>make lint</code>), silence noisy ceremony nudges, or tailor post-commit instructions for your stack.</p> <p>Uses: <code>ctx hook message list</code>, <code>ctx hook message show</code>, <code>ctx hook message edit</code>, <code>ctx hook message reset</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#hook-sequence-diagrams","level":3,"title":"Hook Sequence Diagrams","text":"<p>Mermaid sequence diagrams for every system hook: entry conditions, state reads, output, throttling, and exit points. Includes throttling summary table and state file reference.</p> <p>Uses: All <code>ctx system</code> hooks</p>","path":["Recipes"],"tags":[]},{"location":"recipes/#auditing-system-hooks","level":3,"title":"Auditing System Hooks","text":"<p>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.</p> <p>Uses: <code>ctx system</code>, <code>ctx hook notify</code>, <code>.context/logs/</code>, <code>.ctxrc</code> <code>notify.events</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"<p>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.</p> <p>Uses: <code>ctx hook notify setup</code>, <code>ctx hook notify test</code>, <code>ctx hook notify --event</code>, <code>.ctxrc</code> <code>notify.events</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"<p>Switch between dev and base runtime configurations without editing <code>.ctxrc</code> by hand. Verbose logging and webhooks for debugging, clean defaults for normal sessions.</p> <p>Uses: <code>ctx config switch</code>, <code>ctx config status</code>, <code>/ctx-config</code></p>","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":"<p>Keep context files accurate by detecting structural drift (stale paths, missing files, stale file ages) and task staleness.</p> <p>Uses: <code>ctx drift</code>, <code>ctx sync</code>, <code>ctx compact</code>, <code>ctx status</code>, <code>/ctx-drift</code>, <code>/ctx-status</code>, <code>/ctx-prompt-audit</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#state-directory-maintenance","level":3,"title":"State Directory Maintenance","text":"<p>Clean up session tombstones from <code>.context/state/</code>. Prune old per-session files, identify stale global markers, and keep the state directory lean.</p> <p>Uses: <code>ctx prune</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#troubleshooting","level":3,"title":"Troubleshooting","text":"<p>Diagnose hook failures, noisy nudges, stale context, and configuration issues. Start with <code>ctx doctor</code> for a structural health check, then use <code>/ctx-doctor</code> for agent-driven analysis of event patterns.</p> <p>Uses: <code>ctx doctor</code>, <code>ctx hook event</code>, <code>/ctx-doctor</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#claude-code-permission-hygiene","level":3,"title":"Claude Code Permission Hygiene","text":"<p>Keep <code>.claude/settings.local.json</code> clean: recommended safe defaults, what to never pre-approve, and a maintenance workflow for cleaning up session debris.</p> <p>Uses: <code>ctx init</code>, <code>/ctx-drift</code>, <code>/ctx-permission-sanitize</code>, <code>ctx permission snapshot</code>, <code>ctx permission restore</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#permission-snapshots","level":3,"title":"Permission Snapshots","text":"<p>Capture a known-good permission baseline as a golden image, then restore at session start to automatically drop session-accumulated permissions.</p> <p>Uses: <code>ctx permission snapshot</code>, <code>ctx permission restore</code>, <code>/ctx-permission-sanitize</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#turning-activity-into-content","level":3,"title":"Turning Activity into Content","text":"<p>Generate blog posts from project activity, write changelog posts from commit ranges, and publish a browsable journal site from your session history.</p> <p>The output is generic Markdown, but the skills are tuned for the <code>ctx</code>-style blog artifacts you see on this website.</p> <p>Uses: <code>ctx journal site</code>, <code>ctx journal obsidian</code>, <code>ctx serve</code>, <code>ctx journal import</code>, <code>/ctx-blog</code>, <code>/ctx-blog-changelog</code>, <code>/ctx-journal-enrich</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#importing-claude-code-plans","level":3,"title":"Importing Claude Code Plans","text":"<p>Import Claude Code plan files (<code>~/.claude/plans/*.md</code>) into <code>specs/</code> as permanent project specs. Filter by date, select interactively, and optionally create tasks referencing each imported spec.</p> <p>Uses: <code>/ctx-plan-import</code>, <code>/ctx-task-add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#design-before-coding","level":3,"title":"Design Before Coding","text":"<p>Front-load design with a four-skill chain: brainstorm the approach, spec the design, task out the work, implement step-by-step. Each step produces an artifact that feeds the next.</p> <p>Uses: <code>/ctx-brainstorm</code>, <code>/ctx-spec</code>, <code>/ctx-task-out</code>, <code>/ctx-task-add</code>, <code>/ctx-implement</code>, <code>/ctx-decision-add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#scrutinizing-a-plan","level":3,"title":"Scrutinizing a Plan","text":"<p>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.</p> <p>Uses: <code>/ctx-plan</code>, <code>/ctx-spec</code>, <code>/ctx-decision-add</code>, <code>/ctx-learning-add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#spec-driven-development","level":3,"title":"Spec-Driven Development","text":"<p>The full design-to-implementation pipeline from the operator's seat: debate the bet into a brief, spec all milestones once, task out each milestone just-in-time behind the rolling-wave gate, then implement. Covers the load-bearing mechanics a newcomer has to reverse-engineer otherwise — altitude, blocking-TBD gates, and the plan-as-ledger vs. TASKS.md-as-projection split — with a worked multi-milestone example.</p> <p>Uses: <code>/ctx-plan</code>, <code>/ctx-spec</code>, <code>/ctx-task-out</code>, <code>/ctx-implement</code>, <code>/ctx-decision-add</code></p>","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":"<p>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.</p> <p>Uses: <code>/ctx-skill-create</code>, <code>ctx init</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#running-an-unattended-ai-agent","level":3,"title":"Running an Unattended AI Agent","text":"<p>Set up a loop where an AI agent works through tasks overnight without you at the keyboard, using <code>ctx</code> for persistent memory between iterations.</p> <p>This recipe shows how <code>ctx</code> supports long-running agent loops without losing context or intent.</p> <p>Uses: <code>ctx init</code>, <code>ctx loop</code>, <code>ctx watch</code>, <code>ctx load</code>, <code>/ctx-loop</code>, <code>/ctx-implement</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#when-to-use-a-team-of-agents","level":3,"title":"When to Use a Team of Agents","text":"<p>Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.</p> <p>This recipe covers the file overlap test, when teams make things worse, and what <code>ctx</code> provides at each level.</p> <p>Uses: <code>/ctx-worktree</code>, <code>/ctx-next</code>, <code>ctx status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#parallel-agent-development-with-git-worktrees","level":3,"title":"Parallel Agent Development with Git Worktrees","text":"<p>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.</p> <p>Uses: <code>/ctx-worktree</code>, <code>/ctx-next</code>, <code>git worktree</code>, <code>git merge</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#architecture-deep-dive","level":3,"title":"Architecture Deep Dive","text":"<p>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.</p> <p>Uses: <code>/ctx-architecture</code>, <code>/ctx-architecture-enrich</code>, <code>/ctx-architecture-failure-analysis</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#writing-steering-files","level":3,"title":"Writing Steering Files","text":"<p>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.</p> <p>Uses: <code>ctx steering add</code>, <code>ctx steering preview</code>, <code>ctx steering list</code>, <code>ctx steering sync</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#out-of-band-audit-channel","level":3,"title":"Out-of-Band Audit Channel","text":"<p>Maintainer-only tooling (the <code>ctxctl</code> binary, not the shipped <code>ctx</code>), so it moved out of these user recipes into the contributor docs. See Operations → Runbooks → Out-of-Band Audit Channel.</p>","path":["Recipes"],"tags":[]},{"location":"recipes/#authoring-lifecycle-triggers","level":3,"title":"Authoring Lifecycle Triggers","text":"<p>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.</p> <p>Uses: <code>ctx trigger add</code>, <code>ctx trigger test</code>, <code>ctx trigger enable</code>, <code>ctx trigger disable</code>, <code>ctx trigger list</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#hub","level":2,"title":"Hub","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#hub-overview","level":3,"title":"Hub Overview","text":"<p>Mental model and three user stories for the <code>ctx</code> Hub. What flows, what doesn't, and when not to use it. Read this before any of the other Hub recipes.</p> <p>Uses: <code>ctx hub</code>, <code>ctx connection</code>, <code>ctx add --share</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-getting-started","level":3,"title":"<code>ctx</code> Hub: Getting Started","text":"<p>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.</p> <p>Uses: <code>ctx hub start</code>, <code>ctx connection register</code>, <code>ctx connection subscribe</code>, <code>ctx connection sync</code>, <code>ctx connection listen</code>, <code>ctx add --share</code>, <code>ctx agent --include-hub</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"<p>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 <code>sync</code>, no <code>git push</code>, no ceremony).</p> <p>Uses: <code>ctx add --share</code>, <code>ctx connection subscribe</code>, <code>ctx agent --include-hub</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#team-knowledge-bus","level":3,"title":"Team Knowledge Bus","text":"<p>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.</p> <p>Uses: <code>ctx add --share</code>, <code>ctx connection status</code>, <code>ctx connection subscribe</code>, <code>ctx hub status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-multi-machine","level":3,"title":"<code>ctx</code> Hub: Multi-Machine","text":"<p>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.</p> <p>Uses: <code>ctx hub start --daemon</code>, <code>ctx hub stop</code>, <code>ctx connection register</code>, <code>ctx connection status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-ha-cluster","level":3,"title":"<code>ctx</code> Hub: HA Cluster","text":"<p>Raft-based leader election across three or more nodes for redundancy. Covers bootstrap, runtime peer management, graceful stepdown, and the Raft-lite durability caveat.</p> <p>Uses: <code>ctx hub start --peers</code>, <code>ctx hub status</code>, <code>ctx hub peer add/remove</code>, <code>ctx hub stepdown</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/architecture-deep-dive/","level":1,"title":"Architecture Deep Dive","text":"","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-problem","level":2,"title":"The Problem","text":"<p>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.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tldr","level":2,"title":"TL;DR","text":"<pre><code># 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</code></pre> <p>Each pass builds on the previous one. Run them in order. The output accumulates in <code>.context/</code>; each pass reads the prior artifacts and extends them.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>/ctx-architecture</code> Skill Map modules, dependencies, data flow, patterns <code>/ctx-architecture-enrich</code> Skill Verify blast radius and flows with code intel <code>/ctx-architecture-failure-analysis</code> Skill Generate falsifiable incident hypotheses <code>ctx drift</code> CLI Detect stale paths and broken references <code>ctx status</code> CLI Quick structural overview","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-1-map-what-exists","level":3,"title":"Pass 1: Map What Exists","text":"<pre><code>/ctx-architecture\n</code></pre> <p>Produces:</p> <ul> <li>ARCHITECTURE.md: succinct project map (< 4000 tokens), loaded at every session start</li> <li>DETAILED_DESIGN*.md: deep per-module reference with exported API, data flow, danger zones, extension points</li> <li>CHEAT-SHEETS.md: lifecycle flow diagrams</li> <li>map-tracking.json: coverage state with confidence scores</li> </ul> <p>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.</p> <p>When to run: First time on a codebase, or after significant structural changes (new packages, moved files, changed dependencies).</p> <p>Principal mode: Add <code>principal</code> to get strategic analysis (ARCHITECTURE-PRINCIPAL.md, DANGER-ZONES.md from P4):</p> <pre><code>/ctx-architecture principal\n</code></pre>","path":["Recipes","Agents and Automation","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":"<pre><code>/ctx-architecture-enrich\n</code></pre> <p>Takes the Pass 1 artifacts as baseline and layers on verified, graph-backed data from a code-intelligence MCP (canonical: GitNexus; equivalents include sourcegraph-cody):</p> <ul> <li>Blast radius numbers for key functions</li> <li>Execution flow traces through hot paths</li> <li>Domain clustering validation</li> <li>Registration site discovery</li> </ul> <p>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.\"</p> <p>When to run: After Pass 1, when you need quantified confidence for refactoring decisions or risk assessment.</p> <p>Requires: a code-intelligence MCP connected (canonical: GitNexus; equivalents work if they expose symbol-index, blast-radius, and execution-flow queries).</p>","path":["Recipes","Agents and Automation","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":"<pre><code>/ctx-architecture-failure-analysis\n</code></pre> <p>The adversarial pass. Reads all prior artifacts, then systematically hunts for correctness bugs across 9 failure categories:</p> <ol> <li>Concurrency (races, deadlocks, goroutine leaks)</li> <li>Ordering assumptions (init, registration, shutdown)</li> <li>Cache staleness (TTL-less, read-your-writes, cross-process)</li> <li>Fan-out amplification (N+1, retry storms)</li> <li>Ownership and lifecycle (orphans, double-close)</li> <li>Error handling (silent swallowing, partial failure)</li> <li>Scaling cliffs (quadratic, unbounded, global locks)</li> <li>Idempotency failures (duplicate processing, retry mutations)</li> <li>State machine drift (illegal states, unvalidated transitions)</li> </ol> <p>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.</p> <p>Produces DANGER-ZONES.md, a ranked inventory of findings split into Critical and Elevated tiers.</p> <p>When to run: Before releases, after major refactors, when investigating incident categories, or when onboarding.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#what-you-get","level":2,"title":"What You Get","text":"<p>After all three passes, <code>.context/</code> contains:</p> File From Purpose <code>ARCHITECTURE.md</code> Pass 1 System map (session-start context) <code>DETAILED_DESIGN*.md</code> Pass 1 Module-level deep reference <code>CHEAT-SHEETS.md</code> Pass 1 Lifecycle flow diagrams <code>map-tracking.json</code> Pass 1 Coverage and confidence data <code>CONVERGENCE-REPORT.md</code> Pass 1 What's covered, what's not <code>DANGER-ZONES.md</code> Pass 3 Ranked failure hypotheses <p>Pass 2 enriches Pass 1 artifacts in-place rather than creating new files.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tips","level":2,"title":"Tips","text":"<ul> <li>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.</li> <li>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.</li> <li>Re-run Pass 1 incrementally. It tracks coverage in <code>map-tracking.json</code> and only re-analyzes stale modules.</li> <li>Pass 3 is most valuable before releases. The ranked DANGER-ZONES.md is a pre-release checklist.</li> <li>The trilogy maps to a question progression: How does it work? How well does it connect? Where will it break?</li> </ul>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#see-also","level":2,"title":"See Also","text":"<p>See also: Detecting and Fixing Context Drift to keep architecture artifacts fresh between deep-dive sessions.</p> <p>See also: Detecting and Fixing Context Drift for structural checks that complement architecture analysis.</p>","path":["Recipes","Agents and Automation","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":"<p>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.</p> <p>Each iteration needs to remember what the previous one did, mark tasks as completed, and know when to stop.</p> <p>Without persistent memory, every iteration starts fresh and the loop collapses. With <code>ctx</code>, each iteration can pick up where the last one left off, but only if the agent persists its context as part of the work.</p> <p>Unattended operation works because the agent treats context persistence as a first-class deliverable, not an afterthought.</p>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx init # 1. init context\n# Edit TASKS.md with phased work items\nctx loop --tool claude --max-iterations 10 # 2. generate loop.sh\n./loop.sh 2>&1 | tee /tmp/loop.log & # 3. run the loop\nctx watch --log /tmp/loop.log # 4. process context updates\n# Next morning:\nctx status && ctx load # 5. review the results\n</code></pre> <p>Run From the Project Root</p> <p><code>ctx</code> reads <code>$PWD/.context/</code>. Both the interactive <code>ctx loop</code> invocation and the generated <code>loop.sh</code> must run from the project root. If <code>loop.sh</code> is scheduled by a supervisor that does not preserve cwd, add <code>cd /abs/path/to/project</code> at the top of the script.</p> <p>Read on for permissions, isolation, and completion signals.</p>","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 <code>ctx init</code> Command Initialize project context and prompt templates <code>ctx loop</code> Command Generate the loop shell script <code>ctx watch</code> Command Monitor AI output and persist context updates <code>ctx load</code> Command Display assembled context (for debugging) <code>/ctx-loop</code> Skill Generate loop script from inside Claude Code <code>/ctx-implement</code> 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":"<p>Start by creating a <code>.context/</code> directory configured so the agent can work without human input.</p> <pre><code>ctx init\n</code></pre> <p>This creates <code>.context/</code> with the template files (including a loop prompt at <code>.context/loop.md</code>), and seeds Claude Code permissions in <code>.claude/settings.local.json</code>. Install the <code>ctx</code> plugin for hooks and skills.</p>","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 <code>TASKS.md</code> with Phased Work","text":"<p>Open <code>.context/TASKS.md</code> and organize your work into phases. The agent works through these systematically, top to bottom, using priority tags to break ties.</p> <pre><code># 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</code></pre> <p>Phased organization matters because it gives the agent natural boundaries. Phase 1 tasks should be completable without Phase 2 code existing yet.</p>","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":"<p>The loop prompt at <code>.context/loop.md</code> instructs the agent to operate autonomously:</p> <ol> <li>Read <code>.context/CONSTITUTION.md</code> first (hard rules, never violated)</li> <li>Load context from <code>.context/</code> files</li> <li>Pick one task per iteration</li> <li>Complete the task and update context files</li> <li>Commit changes (including <code>.context/</code>)</li> <li>Signal status with a completion signal</li> </ol> <p>You can customize <code>.context/loop.md</code> for your project. The critical parts are the one-task-per-iteration discipline, proactive context persistence, and completion signals at the end:</p> <pre><code>## 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</code></pre>","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":"<p>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.</p> <p>There are two approaches.</p>","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":"<p>Grant only the permissions the agent needs. In <code>.claude/settings.local.json</code>:</p> <pre><code>{\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</code></pre> <p>Adjust the <code>Bash</code> patterns for your project's toolchain. The agent can run <code>make</code>, <code>go</code>, <code>git</code>, and <code>ctx</code> commands but cannot run arbitrary shell commands.</p> <p>This is recommended even in sandboxed environments because it limits blast radius.</p>","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":"<p>Claude Code supports a <code>--dangerously-skip-permissions</code> flag that disables all permission prompts:</p> <pre><code>claude --dangerously-skip-permissions -p \"$(cat .context/loop.md)\"\n</code></pre> <p>This Flag Means What It Says</p> <p>With <code>--dangerously-skip-permissions</code>, the agent can execute any shell command, write to any file, and make network requests without confirmation.</p> <p>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.</p> <p>If you would not give an untrusted intern <code>sudo</code> on this machine, do not use this flag.</p>","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":"<p>The only controls an agent cannot override are the ones enforced by the operating system, the container runtime, or the hypervisor.</p> <p>Do Not Skip This Section</p> <p>This is not optional hardening:</p> <p>An unattended agent with unrestricted OS access is an unattended shell with unrestricted OS access. </p> <p>The allowlist above is a strong first layer, but do not rely on a single runtime boundary.</p> <p>For unattended runs, enforce isolation at the infrastructure level:</p> Layer What to enforce User account Run the agent as a dedicated unprivileged user with no <code>sudo</code> access and no membership in privileged groups (<code>docker</code>, <code>wheel</code>, <code>adm</code>). 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 (<code>--cap-drop=ALL</code>). Disable network if not needed (<code>--network=none</code>). 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. <code>CLAUDE.md</code>, <code>.claude/settings.local.json</code>, and <code>.context/CONSTITUTION.md</code> should not be writable by the agent user. If using project-local hooks, protect those too. <p>A minimal Docker setup for overnight runs:</p> <pre><code>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</code></pre> <p>Defense in Depth</p> <p>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 <code>CONSTITUTION.md</code> (a soft nudge for the common case).</p>","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":"<p>Use <code>ctx loop</code> to generate a <code>loop.sh</code> tailored to your AI tool:</p> <pre><code># 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</code></pre> <p>The generated script reads <code>.context/loop.md</code>, runs the tool, checks for completion signals, and loops until done or the cap is reached.</p> <p>You can also use the <code>/ctx-loop</code> skill from inside Claude Code.</p> <p>A Shell Loop Is the Best Practice</p> <p>The shell loop approach spawns a fresh AI process each iteration, so the only state that carries between iterations is what lives in <code>.context/</code> and git.</p> <p>Claude Code's built-in <code>/loop</code> 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. </p> <p>See Shell Loop vs Built-in Loop for details.</p>","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":"<p>Open two terminals. In the first, run the loop. In the second, run <code>ctx watch</code> to process context updates from the AI output.</p> <pre><code># 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</code></pre> <p>The watch command parses XML context-update commands from the AI output and applies them:</p> <pre><code><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</code></pre>","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":"<p>The generated script checks for one completion signal per run. By default this is <code>SYSTEM_CONVERGED</code>. You can change it with the <code>--completion</code> flag:</p> <pre><code>ctx loop --tool claude --completion BOOTSTRAP_COMPLETE --max-iterations 5\n</code></pre> <p>The following signals are conventions used in <code>.context/loop.md</code>:</p> Signal Convention How the script handles it <code>SYSTEM_CONVERGED</code> All tasks in <code>TASKS.md</code> are done Detected by default (<code>--completion</code> default value) <code>SYSTEM_BLOCKED</code> Agent cannot proceed Only detected if you set <code>--completion</code> to this <code>BOOTSTRAP_COMPLETE</code> Initial scaffolding done Only detected if you set <code>--completion</code> to this <p>The script uses <code>grep -q</code> 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 <code>loop.sh</code> to add additional <code>grep</code> checks.</p> <p>When you return in the morning, check the log and the context files:</p> <pre><code>tail -100 /tmp/loop.log\nctx status\nctx load\n</code></pre>","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 <code>/ctx-implement</code> for Plan Execution","text":"<p>Within each iteration, the agent can use <code>/ctx-implement</code> to execute multi-step plans with verification between steps. This is useful for complex tasks that touch multiple files.</p> <p>The skill breaks a plan into atomic, verifiable steps:</p> <pre><code>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</code></pre> <p>Each step is verified (build, test, syntax check) before moving to the next.</p>","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":"<p>A typical overnight run:</p> <pre><code>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</code></pre>","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":"<p>The autonomous loop pattern works because the agent persists context as part of the job.</p> <p>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.</p>","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":"<p>The Agent Playbook defines a self-check prompt the agent applies continuously:</p> <pre><code>\"If this session ended right now, would the next session know what happened?\"\n</code></pre> <p>In interactive sessions, a human might remind the agent to save context. When the agent runs unattended, nobody is there to remind it.</p> <p>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.</p>","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":"<p>At milestones within an iteration, the agent persists without waiting for instructions:</p> Milestone What the agent does proactively Completes a task Marks it <code>[x]</code> in <code>TASKS.md</code> Discovers a gotcha Adds it to <code>LEARNINGS.md</code> Makes a design choice Records it in <code>DECISIONS.md</code> with rationale Identifies follow-up work Creates new tasks in <code>TASKS.md</code> with <code>#added</code> 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":"<p>Here is what the agent does during a single iteration beyond writing code:</p> <pre><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</code></pre> <p>Steps 2, 4, 5, 6, and 7 are proactive context persistence: </p> <p>The agent was not asked to do any of them.</p>","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":"<p>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 <code>TASKS.md</code>, <code>DECISIONS.md</code>, and <code>LEARNINGS.md</code> as it goes.</p> <p>If the loop crashes at 4 AM, the context files tell you exactly where to resume. You can also use <code>ctx journal source</code> to review the session transcripts.</p>","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":"<p>The autonomous loop has an implicit contract:</p> <ol> <li>Every iteration reads context: <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code></li> <li>Every iteration writes context: task updates, new learnings, decisions</li> <li>Every commit includes <code>.context/</code> so the next iteration sees changes</li> <li>Context stays current: if the loop stopped right now, nothing important is lost</li> </ol> <p>Break any part of this contract and the loop degrades.</p>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tips","level":2,"title":"Tips","text":"<p>Markdown Is Not Enforcement</p> <p>Your real guardrails are permissions and isolation, not Markdown. <code>CONSTITUTION.md</code> can nudge the agent, but it is probabilistic. </p> <p>The permission allowlist and OS isolation are deterministic:</p> <p>For unattended runs, trust the sandbox and the allowlist, not the prose.</p> <ul> <li>Start with a small iteration cap. Use <code>--max-iterations 5</code> on your first run.</li> <li>Keep tasks atomic. Each task should be completable in a single iteration.</li> <li>Check signal discipline. If the loop runs forever, the agent is not emitting <code>SYSTEM_CONVERGED</code> or <code>SYSTEM_BLOCKED</code>. Make the signal requirement explicit in <code>.context/loop.md</code>.</li> <li>Commit after context updates. Finish code, update <code>.context/</code>, commit including <code>.context/</code>, then signal.</li> <li>Set up webhook notifications to get notified when the loop completes, hits max iterations, or when hooks fire nudges. The generated loop script includes <code>ctx hook notify</code> calls automatically.</li> </ul>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#next-up","level":2,"title":"Next Up","text":"<p>When to Use a Team of Agents →: Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.</p>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#see-also","level":2,"title":"See Also","text":"<ul> <li>Autonomous Loops: loop pattern, prompt templates, troubleshooting</li> <li>CLI Reference: <code>ctx</code> loop: flags and options</li> <li>CLI Reference: <code>ctx</code> watch: watch mode details</li> <li>CLI Reference: <code>ctx</code> init: init flags</li> <li>The Complete Session: interactive workflow</li> <li>Tracking Work Across Sessions: structuring TASKS.md</li> </ul>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/build-a-knowledge-base/","level":1,"title":"Build a Knowledge Base","text":"","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#the-problem","level":2,"title":"The Problem","text":"<p>You are doing knowledge-shaped work (vendor-spec analysis, a research project, a post-incident review, domain modeling) and the standard five context files (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>, <code>CONSTITUTION.md</code>) don't fit. Because those files are tuned for code-development context, not for evidence-tracked knowledge with confidence bands, contradictions, and external citations.</p> <p>You need a place where:</p> <ul> <li>Every claim is pinned to a source you can re-verify.</li> <li>Topics grow into folders as they earn their depth.</li> <li>Two passes against the same source don't silently disagree.</li> <li>The next session knows what's incomplete, not just what's done.</li> </ul> <p>That's what the editorial pipeline is for.</p> <p>Prefer Skills to Raw Commands</p> <p>The pipeline is driven by skills (<code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, etc.). The CLI form (<code>ctx kb ingest</code>, etc.) exists for scripting and for non-Claude environments; the skill is the natural surface.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#tldr","level":2,"title":"TL;DR","text":"<pre><code>git init && ctx init # lays down the kb + ingest tree\nctx kb topic new \"Cursor Hooks\" # scaffold a topic folder\n/ctx-kb-ingest ./docs/cursor-hooks.md \"cursor hooks\" # editorial pass\n/ctx-kb-ask \"does the kb say hooks fire async?\" # grounded Q&A\n/ctx-wrap-up # ceremony; delegates to /ctx-handover\n # for the per-session handover\n</code></pre>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>ctx init</code> Command Scaffold <code>.context/kb/</code>, <code>.context/ingest/</code>, etc. <code>ctx kb topic new <name></code> Command Sole writer of topic-page scaffolds (folder shape) <code>ctx kb note \"<text>\"</code> Command Lightweight capture into <code>.context/ingest/findings.md</code> <code>ctx kb reindex</code> Command Refresh the <code>CTX:KB:TOPICS</code> managed block <code>ctx handover write</code> Command Per-session handover with closeout fold <code>/ctx-kb-ingest</code> Skill Mode-aware editorial pass (topic-page/triage/evidence) <code>/ctx-kb-ask</code> Skill Q&A grounded in the kb <code>/ctx-kb-site-review</code> Skill Mechanical structural audit <code>/ctx-kb-ground</code> Skill Read-only freshness audit over the kb's tracked sources <code>/ctx-kb-note</code> Skill Capture a finding for the next ingest pass <code>/ctx-wrap-up</code> Skill End-of-session ceremony; delegates to the handover step","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-0-initialize-and-declare-scope","level":2,"title":"Step 0: Initialize and Declare Scope","text":"<pre><code>git init && ctx init\n</code></pre> <p><code>ctx init</code> lays down the editorial scaffolding alongside the standard context files:</p> <pre><code>.context/\n├── kb/\n│ ├── index.md\n│ └── topics/.gitkeep\n├── ingest/\n│ ├── KB-RULES.md # editorial constitution\n│ ├── 00-GROUND.md\n│ ├── 30-INGEST.md\n│ ├── 40-ASK.md\n│ ├── 50-SITE_REVIEW.md\n│ ├── OPERATOR.md\n│ ├── PROMPT.md # hand-fallback router\n│ ├── closeouts/.gitkeep\n│ └── schemas/\n│ └── *.md # 10 schema templates\n└── handovers/.gitkeep\n</code></pre> <p>Open <code>.context/kb/index.md</code> and replace the placeholder <code>## Scope</code> paragraph with a one-paragraph statement of what this kb covers and what it does not. <code>/ctx-kb-ingest</code> refuses to run against an undeclared kb; scope is the precondition.</p> <p>Git is required</p> <p><code>ctx init</code> now refuses to run without <code>.git/</code>. The editorial pipeline's provenance (closeout <code>sha</code>/<code>branch</code>, evidence-index in-repo SHA pins) depends on it. Run <code>git init</code> first if the project does not already have one.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-1-scaffold-a-topic","level":2,"title":"Step 1: Scaffold a Topic","text":"<p>Topic pages live in folders, not flat files:</p> <pre><code>ctx kb topic new \"Cursor Hooks\"\n</code></pre> <p>This creates <code>.context/kb/topics/cursor-hooks/index.md</code> from the embedded template. The slug is computed by lowercasing + kebab- casing; vendor-namespaced shapes like <code>cursor/hooks</code> are preserved so you can grow into nested topology (<code>topics/cursor/hooks/</code>, <code>topics/cursor/skills/</code>, <code>topics/cursor/rules/</code>) without breaking citations.</p> <p><code>ctx kb topic new</code> is the sole writer of topic-page scaffolds. Skills invoke this command rather than synthesize a scaffold by hand; the embedded template is the single source of truth.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-2-run-an-editorial-pass","level":2,"title":"Step 2: Run an Editorial Pass","text":"<pre><code>/ctx-kb-ingest ./inputs/2026-04-12-call.md \"cursor hooks\"\n</code></pre> <p>The skill begins with a pass-mode declaration:</p> <p>Pass-mode: <code>topic-page</code> Reason: the user supplied one primary source and the intended topic is clear. Definition of done: create or extend <code>kb/topics/cursor-hooks/index.md</code>, cite EV rows, run <code>ctx kb site build</code>, record cold-reader orientation.</p> <p>Then it:</p> <ol> <li>Resolves sources (paths / URLs / MCP resources) and updates the source-coverage ledger at <code>.context/kb/source-coverage.md</code> (a state machine across all sources the kb has touched).</li> <li>Scans for adjacent incomplete topics in the ledger and surfaces them so the new page acknowledges sibling gaps.</li> <li>Synthesizes prose section by section into the topic page, minting <code>EV-###</code> rows in <code>evidence-index.md</code> for every cited claim.</li> <li>Sets the Confidence floor (the page never claims more certainty than its weakest cited band).</li> <li>Writes a closeout under <code>.context/ingest/closeouts/<TS>-ingest-closeout.md</code> with frontmatter, the cold-reader orientation rubric, and a ledger-state advance per source.</li> </ol> <p>Three pass modes:</p> <ul> <li><code>topic-page</code> (default): write or extend a topic page.</li> <li><code>triage</code>: admit / skip sources against scope; no <code>EV-###</code> minted.</li> <li><code>evidence-only</code>: mint <code>EV-###</code> rows tagged <code>evidence-only</code>; do not touch a topic page (explicit-request-only escape hatch).</li> </ul> <p>Mid-pass mode-switching is forbidden: the skill commits to one mode and aborts cleanly if the work no longer fits.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-3-qa-grounded-in-the-kb","level":2,"title":"Step 3: Q&A Grounded in the KB","text":"<pre><code>/ctx-kb-ask \"does the kb say hooks fire async?\"\n</code></pre> <p><code>/ctx-kb-ask</code> reads the kb's prose, cites <code>EV-###</code> rows, and refuses to web-jump. If the kb cannot answer, it opens a <code>Q-###</code> row in <code>outstanding-questions.md</code> and reports the gap, which a future <code>/ctx-kb-ingest</code> pass can close.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-4-audit-re-ground","level":2,"title":"Step 4: Audit + Re-Ground","text":"<pre><code>/ctx-kb-site-review # mechanical structural audit\n/ctx-kb-ground # refresh sources listed in grounding-sources.md\n</code></pre> <p><code>site-review</code> coerces malformed Confidence-band capitalization, flags malformed closeout frontmatter, and refuses to make judgment calls that require evidence (those go through ingest).</p> <p><code>ground</code> reads <code>.context/ingest/grounding-sources.md</code> — the kb's persistent watch list — and walks each declared source (URL, in-tree path, or MCP resource) to check whether it has drifted since the kb last cited it. The pass is read-only on the kb's prose and evidence: it annotates the source-coverage ledger's <code>Residue</code> / <code>Next action</code> cells and writes a ground closeout, but does NOT re-extract claims, mint <code>EV-###</code> rows, or touch topic pages. Drifted or new-to-kb sources are flagged for a follow-up <code>/ctx-kb-ingest</code>. Use ground for \"are the docs still current?\" hygiene; use <code>/ctx-kb-ingest</code> to actually absorb new material.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-5-browse-the-kb-locally","level":2,"title":"Step 5: Browse the KB Locally","text":"<p><code>.context/kb/</code> is a tree of Markdown files: topic pages live under <code>topics/<slug>/index.md</code> and cross-cutting artifacts (<code>glossary.md</code>, <code>evidence-index.md</code>, <code>outstanding-questions.md</code>, <code>domain-decisions.md</code>, <code>contradictions.md</code>, <code>timeline.md</code>, <code>source-map.md</code>, <code>source-coverage.md</code>, <code>relationship-map.md</code>) sit alongside them. Drop a minimal <code>zensical.toml</code> into <code>.context/kb/</code> and hand it to <code>ctx serve</code>:</p> <pre><code>ctx serve .context/kb/\n</code></pre> <p>The KB renders the same way the docs site you are reading right now does. Use the in-place evidence-index links to jump from a topic page to its <code>EV-###</code> rows and back. The site build is read-only: no skill or CLI writes through it.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-6-wrap-up-with-a-handover","level":2,"title":"Step 6: Wrap Up with a Handover","text":"<p>Run <code>/ctx-wrap-up</code> at session end; it owns the ceremony and delegates to the handover step (<code>/ctx-handover</code>) as its final action:</p> <pre><code>/ctx-wrap-up \"Cursor Hooks deep dive\"\n</code></pre> <p>The handover artifact lands at <code>.context/handovers/<TS>-<slug>.md</code> (timestamped so concurrent agent runs never overwrite). It folds postdated closeouts into a <code>## Folded closeouts</code> section and archives the source closeout files under <code>.context/archive/closeouts/</code>. The next session's <code>/ctx-remember</code> reads the latest handover and folds any closeouts whose <code>generated-at</code> postdates it.</p> <p>The legitimate direct-invocation cases for <code>/ctx-handover</code> are <code>--no-fold</code> for a mid-session checkpoint, or recovery when a prior session ended before its wrap-up step. For the underlying CLI, see <code>ctx handover write</code>.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#how-it-ladders-together","level":2,"title":"How It Ladders Together","text":"<pre><code>sources you supply\n │\n ▼\n/ctx-kb-ingest (mode-declared, source-coverage advanced)\n │\n ├──▶ topic-page ──▶ .context/kb/topics/<slug>/index.md\n ├──▶ evidence ──▶ .context/kb/evidence-index.md (EV-###)\n ├──▶ side rails ──▶ glossary.md, contradictions.md,\n │ outstanding-questions.md, timeline.md,\n │ source-map.md, relationship-map.md\n └──▶ closeout ──▶ .context/ingest/closeouts/<TS>-...md\n │\n ▼\n (next session)\n │\n ▼\n /ctx-wrap-up → /ctx-handover folds\n → .context/handovers/<TS>-<slug>.md\n + archives source closeouts under\n .context/archive/closeouts/\n │\n ▼\n /ctx-remember reads handover + postdated\n unfolded closeouts as the recall surface\n</code></pre>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#bootstrap-vs-steady-state-ingest-first-ground-later","level":2,"title":"Bootstrap vs Steady State: Ingest First, Ground Later","text":"<p><code>/ctx-kb-ingest</code> and <code>/ctx-kb-ground</code> both read sources, which makes their relationship easy to misread. The distinction is authority, not input shape:</p> <ul> <li>Ingest writes. It mints <code>EV-###</code> rows, authors topic-page prose, transitions source-coverage ledger states. The source list is per-invocation (CLI args, inline gestures).</li> <li>Ground audits. It walks a persistent watch list in <code>grounding-sources.md</code>, reports drift, annotates the ledger's <code>Residue</code> and <code>Next action</code> cells, and never writes prose or evidence. Drifted sources surface as flags pointing at <code>/ctx-kb-ingest</code>.</li> </ul> <p>This drives the canonical flow:</p> <p>Bootstrap (pristine kb). Use <code>/ctx-kb-ingest <sources></code> to absorb the first wave of material. Ground has nothing to compare against in a pristine kb — <code>source-map.md</code> is empty, and <code>grounding-sources.md</code> would just prompt for entries.</p> <p>Curate the watch list. Once the kb has content, edit <code>grounding-sources.md</code> by hand to list the canonical sources the kb's claims depend on — the load-bearing citations worth checking for drift. Ground refuses to synthesise this list from <code>source-map.md</code> by design; the watch list is a deliberate human choice about what's worth tracking.</p> <p>Steady state. Ingest liberally as new material lands. Run <code>/ctx-kb-ground</code> periodically — before a release, after a vendor version bump, on whatever cadence fits — to detect drift on the tracked subset. Drift surfaces as flags in the ground closeout pointing at <code>/ctx-kb-ingest</code> for the actual write-side work.</p> <p>Rule of thumb:</p> Situation Skill \"I have new material I want absorbed.\" <code>/ctx-kb-ingest</code> \"Are the sources the kb depends on still current?\" <code>/ctx-kb-ground</code> \"Is the kb's structure clean (capitalisation, frontmatter)?\" <code>/ctx-kb-site-review</code>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#what-the-editorial-pipeline-is-not","level":2,"title":"What the Editorial Pipeline Is NOT","text":"<ul> <li>Not a substitute for <code>DECISIONS.md</code>. Project-level architectural decisions stay in <code>.context/DECISIONS.md</code>. The kb's <code>domain-decisions.md</code> is a kb-scoped artifact (different schema, different write authority, different lifecycle).</li> <li>Not a substitute for <code>LEARNINGS.md</code>. Learnings have author intent; kb claims have evidence backing. They're different truth bases; do not cross-feed.</li> <li>Not for casual notes. Use <code>/ctx-kb-note</code> or <code>ctx kb note \"<text>\"</code> to park a finding for the next ingest pass.</li> </ul>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#reference","level":2,"title":"Reference","text":"<ul> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code> (laid down by <code>ctx init</code>)</li> <li>Skills reference: <code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, <code>/ctx-kb-site-review</code>, <code>/ctx-kb-ground</code>, <code>/ctx-kb-note</code>, <code>/ctx-handover</code></li> <li>Related recipes: Typical KB Session, Recover an Aborted Session</li> </ul>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"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":"<p>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.</p> <p>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.</p>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-skill-create\n</code></pre> <p>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.</p>","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 <code>/ctx-skill-create</code> Skill Interactive skill creation and improvement workflow <code>ctx init</code> Command Deploys template skills to <code>.claude/skills/</code> 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":"<p>Good skill candidates:</p> <ul> <li>Checklists you repeat: deploy steps, release prep, code review</li> <li>Decisions the agent gets wrong: if you keep correcting the same behavior, encode the correction</li> <li>Multi-step workflows: anything with a sequence of commands and conditional branches</li> <li>Domain knowledge: project-specific terminology, architecture constraints, or conventions the agent cannot infer from code alone</li> </ul> <p>Not good candidates: one-off instructions, things the platform already handles (file editing, git operations), or tasks too narrow to reuse.</p>","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":"<p>Invoke the skill-creator:</p> <pre><code>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</code></pre> <p>Or capture a workflow you just did:</p> <pre><code>You: \"Turn what we just did into a skill\"\n\nAgent: [Extracts the steps from conversation history,\n confirms understanding, drafts the skill]\n</code></pre> <p>The skill-creator produces a <code>SKILL.md</code> file in <code>.claude/skills/your-skill/</code>.</p>","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":"<p>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.</p> <pre><code>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</code></pre>","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":"<p>The <code>description</code> field in frontmatter determines when a skill triggers. Claude tends to undertrigger - descriptions need to be specific and slightly \"pushy\":</p> <pre><code># 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</code></pre> <p>The skill-creator helps you tune this iteratively.</p>","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":"<p>If the skill should be available to all projects (not just this one), place it in <code>internal/assets/claude/skills/</code> so <code>ctx init</code> deploys it to new projects automatically.</p> <p>Most project-specific skills stay in <code>.claude/skills/</code> and travel with the repo.</p>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#skill-anatomy","level":2,"title":"Skill Anatomy","text":"<pre><code>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</code></pre> <p>Key sections in <code>SKILL.md</code>:</p> 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":"<ul> <li>Description is everything. A great skill with a vague description never fires. Spend time on trigger coverage - synonyms, concrete situations, edge cases.</li> <li>Stay under 500 lines. If your skill is growing past this, move detail into <code>references/</code> files and point to them from <code>SKILL.md</code>.</li> <li>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.</li> <li>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.</li> <li>Test negative triggers. Make sure the skill does not fire on unrelated prompts. A skill that activates too broadly becomes noise.</li> </ul>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#next-up","level":2,"title":"Next Up","text":"<p>Parallel Agent Development with Git Worktrees ->: Split work across multiple agents using git worktrees.</p>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#see-also","level":2,"title":"See Also","text":"<ul> <li>Skills Reference: full listing of all bundled and project-local skills</li> <li>Guide Your Agent: how commands, skills, and conversational patterns work together</li> <li>Design Before Coding: the four-skill chain for front-loading design work</li> </ul>","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":"<p>Claude Code's <code>.claude/settings.local.json</code> 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. </p> <p>A noisy \"allowlist\" makes it harder to spot dangerous permissions and increases the surface area for unintended behavior.</p> <p>Since <code>settings.local.json</code> is <code>.gitignore</code>d, it drifts independently of your codebase. There is no PR review, no CI check: just whatever you clicked \"Allow\" on.</p> <p>This recipe shows what a well-maintained permission file looks like and how to keep it clean.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx init # seeds safe defaults\n/ctx-drift # detects missing/stale permissions\n/ctx-permission-sanitize # audits for dangerous patterns\n</code></pre> <p>See Recommended Defaults for the full list.</p>","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 <code>ctx init</code> Populates default <code>ctx</code> permissions <code>/ctx-drift</code> Detects missing or stale permission entries <code>/ctx-permission-sanitize</code> 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":"<p>After running <code>ctx init</code>, your <code>settings.local.json</code> will have the <code>ctx</code> defaults pre-populated. Here is an opinionated safe starting point for a Go project using <code>ctx</code>:</p> <pre><code>{\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</code></pre> <p>This Is a Starting Point, Not a Mandate</p> <p>Your project may need more or fewer entries. </p> <p>The goal is intentional permissions: Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#design-principles","level":3,"title":"Design Principles","text":"<p>Use wildcards for trusted binaries: If you trust the binary (your own project's CLI, <code>make</code>, <code>go</code>), a single wildcard like <code>Bash(ctx:*)</code> beats twenty subcommand entries. It reduces noise and means new subcommands work without re-prompting.</p> <p>Keep <code>git</code> commands granular: Unlike <code>ctx</code> or <code>make</code>, git has both safe commands (<code>git log</code>, <code>git status</code>) and destructive ones (<code>git reset --hard</code>, <code>git clean -f</code>). Listing safe commands individually prevents accidentally pre-approving dangerous ones.</p> <p>Pre-approve all <code>ctx-</code> skills: Skills shipped with <code>ctx</code> (<code>Skill(ctx-*)</code>) 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.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#default-deny-rules","level":3,"title":"Default Deny Rules","text":"<p><code>ctx init</code> automatically populates <code>permissions.deny</code> 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.</p> <p>The defaults block:</p> Pattern Why <code>Bash(sudo *)</code> Cannot enter password; will hang <code>Bash(git push *)</code> Must be explicit user action <code>Bash(rm -rf /*)</code> etc. Recursive delete of system/home directories <code>Bash(curl *)</code> / <code>wget</code> Arbitrary network requests <code>Bash(chmod 777 *)</code> World-writable permissions <code>Read/Edit(**/.env*)</code> Secrets and credentials <code>Read(**/*.pem, *.key)</code> Private keys <p>Read/Edit Deny Rules</p> <p><code>Read()</code> and <code>Edit()</code> deny rules have known upstream enforcement issues (<code>claude-code#6631,#24846</code>). </p> <p>They are included as defense-in-depth and intent documentation.</p> <p>Blocked by default deny rules: no action needed, <code>ctx init</code> handles these:</p> Pattern Risk <code>Bash(git push:*)</code> Must be explicit user action <code>Bash(sudo:*)</code> Privilege escalation <code>Bash(rm -rf:*)</code> Recursive delete with no confirmation <code>Bash(curl:*)</code> / <code>Bash(wget:*)</code> Arbitrary network requests <p>Requires manual discipline: Never add these to <code>allow</code>:</p> Pattern Risk <code>Bash(git reset:*)</code> Can discard uncommitted work <code>Bash(git clean:*)</code> Deletes untracked files <code>Skill(ctx-permission-sanitize)</code> Edits this file: self-modification vector <code>Skill(release)</code> 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":"<p>Deny rules handle prefix-based blocking natively. Hooks complement them by catching patterns that require regex matching: Things deny rules can't express.</p> <p>The <code>ctx</code> plugin ships these blocking hooks:</p> Hook What it blocks <code>ctx system block-non-path-ctx</code> Running <code>ctx</code> from wrong path <p>Project-local hooks (not part of the plugin) catch regex edge cases:</p> Hook What it blocks <code>block-dangerous-commands.sh</code> Mid-command <code>sudo</code>/<code>git push</code> (after <code>&&</code>), copies to bin dirs, absolute-path <code>ctx</code> <p>Pre-Approved + Hook-Blocked = Silent Block</p> <p>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.</p> <p>It's better not to pre-approve commands that hooks are designed to intercept.</p>","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":"<p>Permissions accumulate fastest during debugging and exploration sessions. After a session where you clicked \"Allow\" many times:</p> <ol> <li>Open <code>.claude/settings.local.json</code> in your editor;</li> <li>Look for entries at the bottom of the allowlist (new entries append there);</li> <li>Delete anything that looks session-specific:<ul> <li>Exact commands with hardcoded paths,</li> <li>Commands with literal string arguments,</li> <li>Entries that duplicate an existing wildcard.</li> </ul> </li> </ol> <p>See the Sanitize Permissions runbook for a step-by-step procedure.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#periodically","level":3,"title":"Periodically","text":"<p>Run <code>/ctx-drift</code> to catch permission drift:</p> <ul> <li>Missing <code>Bash(ctx:*)</code> wildcard;</li> <li>Missing <code>Skill(ctx-*)</code> entries for installed skills;</li> <li>Stale <code>Skill(ctx-*)</code> entries for removed skills;</li> <li>Granular <code>Bash(ctx <subcommand>:*)</code> entries that should be consolidated.</li> </ul> <p>Run <code>/ctx-permission-sanitize</code> to catch security issues:</p> <ul> <li>Hook bypass patterns</li> <li>Destructive commands</li> <li>Overly broad permissions</li> <li>Injection vectors</li> </ul>","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":"<p>If you create a custom <code>ctx-*</code> skill, add its <code>Skill()</code> entry to the allowlist manually. </p> <p><code>ctx init</code> only populates the default permissions: It won't pick up custom skills.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#golden-image-snapshots","level":3,"title":"Golden Image Snapshots","text":"<p>If manual cleanup is too tedious, use a golden image to automate it: </p> <p>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.</p>","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":"<p>The recommended defaults above are Go-specific. For other stacks, swap the build/test tooling:</p> <p>Node.js / TypeScript:</p> <pre><code>\"Bash(npm run:*)\",\n\"Bash(npm test:*)\",\n\"Bash(npx:*)\",\n\"Bash(node:*)\"\n</code></pre> <p>Python:</p> <pre><code>\"Bash(pytest:*)\",\n\"Bash(python:*)\",\n\"Bash(pip show:*)\",\n\"Bash(ruff:*)\"\n</code></pre> <p>Rust:</p> <pre><code>\"Bash(cargo build:*)\",\n\"Bash(cargo test:*)\",\n\"Bash(cargo clippy:*)\",\n\"Bash(cargo fmt:*)\"\n</code></pre> <p>The <code>ctx</code>, <code>git</code>, and skill entries remain the same across all stacks.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#next-up","level":2,"title":"Next Up","text":"<p>Permission Snapshots →: Save and restore permission baselines for reproducible setups.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#see-also","level":2,"title":"See Also","text":"<ul> <li>Setting Up <code>ctx</code> Across AI Tools: full setup recipe including <code>settings.local.json</code> creation</li> <li>Context Health: keeping <code>.context/</code> files accurate</li> <li>Sanitize Permissions runbook: manual cleanup procedure</li> </ul>","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":"<p>Switch between dev and base runtime configurations without editing <code>.ctxrc</code> by hand. Useful when you want verbose logging and webhook notifications during development, then clean defaults for normal sessions.</p> <p>Uses: <code>ctx config switch</code>, <code>ctx config status</code>, <code>/ctx-config</code></p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#how-it-works","level":2,"title":"How It Works","text":"<p>The <code>ctx</code> repo ships two source profiles committed to git:</p> File Profile Description <code>.ctxrc.base</code> base All defaults, notifications off <code>.ctxrc.dev</code> dev Verbose logging, webhook notifications on <p>The working copy (<code>.ctxrc</code>) is gitignored. Switching profiles copies the source file over <code>.ctxrc</code>, so your runtime configuration is always a clean snapshot of one of the two sources.</p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#switching-profiles","level":2,"title":"Switching Profiles","text":"<pre><code># 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</code></pre> <p>The detection heuristic checks for an uncommented <code>notify:</code> line in <code>.ctxrc</code>: present means dev, absent means base.</p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#checking-the-active-profile","level":2,"title":"Checking the Active Profile","text":"<pre><code>ctx config status\n</code></pre> <p>Output examples:</p> <pre><code>active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n</code></pre>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#typical-workflow","level":2,"title":"Typical Workflow","text":"<ol> <li>Start of a debugging session: switch to dev for verbose logging and webhook notifications so you can trace hook activity and get push alerts.</li> </ol> <pre><code>ctx config switch dev\n</code></pre> <ol> <li> <p>Work through the issue: hooks log verbosely, webhooks fire on key events (commits, ceremony nudges, drift warnings).</p> </li> <li> <p>Done debugging: switch back to base to silence the noise.</p> </li> </ol> <pre><code>ctx config switch base\n</code></pre>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#customizing-profiles","level":2,"title":"Customizing Profiles","text":"<p>Edit the source files directly:</p> <ul> <li><code>.ctxrc.dev</code>: add any <code>.ctxrc</code> keys you want active during development (e.g., <code>log_level: debug</code>, <code>notify.events</code>, <code>notify.webhook_url</code>).</li> <li><code>.ctxrc.base</code>: keep this minimal. It represents your \"production\" defaults.</li> </ul> <p>After editing a source file, re-run <code>ctx config switch <profile></code> to apply the changes to the working copy.</p> <p>Commit Your Profiles</p> <p>Both <code>.ctxrc.base</code> and <code>.ctxrc.dev</code> should be committed to git so team members share the same profile definitions. The working copy <code>.ctxrc</code> stays gitignored.</p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#using-the-skill","level":2,"title":"Using the Skill","text":"<p>In a Claude Code session, say any of:</p> <ul> <li>\"switch to dev mode\"</li> <li>\"switch to base\"</li> <li>\"what profile am I on?\"</li> <li>\"toggle verbose logging\"</li> </ul> <p>The <code>/ctx-config</code> skill handles the rest.</p> <p>See also: <code>ctx config</code> reference, Configuration</p>","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":"<p><code>ctx</code> files drift: you rename a package, delete a module, or finish a sprint, and suddenly <code>ARCHITECTURE.md</code> references paths that no longer exist, <code>TASKS.md</code> is 80 percent completed checkboxes, and <code>CONVENTIONS.md</code> describes patterns you stopped using two months ago.</p> <p>Stale context is worse than no context: </p> <p>An AI tool that trusts outdated references will hallucinate confidently.</p> <p>This recipe shows how to detect drift, fix it, and keep your <code>.context/</code> directory lean and accurate.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Or just ask your agent: \"Is our context clean?\"</p>","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 <code>ctx drift</code> Command Detect stale paths, missing files, violations <code>ctx drift --fix</code> Command Auto-fix simple issues <code>ctx sync</code> Command Reconcile context with codebase structure <code>ctx compact</code> Command Archive completed tasks, clean up empty sections <code>ctx fmt</code> Command Normalize context files to 80-char line width <code>ctx status</code> Command Quick health overview <code>/ctx-drift</code> Skill Structural plus semantic drift detection <code>/ctx-architecture</code> Skill Refresh <code>ARCHITECTURE.md</code> from actual codebase <code>/ctx-status</code> Skill In-session context summary <code>/ctx-prompt-audit</code> 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":"<p>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. </p> <p>For day-to-day maintenance, talk to your agent.</p> <p>Your Questions Reinforce the Pattern</p> <p>Asking \"is our context clean?\" does two things:</p> <ul> <li>It triggers a drift check right now</li> <li>It reinforces the habit</li> </ul> <p>This is reinforcement, not enforcement.</p> <p>Do not wait for the agent to be proactive on its own: </p> <p>Guide your agent, especially in early sessions.</p> <p>Over time, you will ask less and the agent will start offering more.</p>","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":"<p>The simplest way to check context health:</p> <pre><code>Is our context clean?\nAnything stale?\nHow healthy are our context files?\n</code></pre> <p>Or invoke the skill directly:</p> <pre><code>/ctx-drift\n</code></pre> <p>The agent performs two layers of analysis:</p> <p>Layer 1, structural checks (via <code>ctx drift</code>): Dead paths, missing files, completed task counts, constitution violations. Fast and programmatic.</p> <p>Layer 2, semantic analysis (agent-driven): Does <code>CONVENTIONS.md</code> describe patterns the code no longer follows? Does <code>DECISIONS.md</code> 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.</p> <p>The agent reports both layers together, explains each finding in plain language, and offers to fix what it can.</p>","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":"<p>You do not need to ask explicitly. </p> <p>Using Claude Code</p> <p><code>ctx</code> ships with Claude Code hooks that remind the agent at the right time to take initiative. </p> <p>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:</p> <pre><code>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</code></pre> <p>☝️️ this is what persistent, initiative-driven sessions feel like when context is treated as a system instead of a prompt.</p> <p>If the agent does not offer this on its own, a gentle nudge is enough:</p> <pre><code>Anything stale before we start?\nHow's the context looking?\n</code></pre> <p>This turns maintenance from a scheduled chore into a conversation that happens when it matters.</p>","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":"<p>Agents can notice drift while working: When a mismatch is directly in the path of their current task. If an agent reads <code>ARCHITECTURE.md</code> to find where to add a handler and <code>internal/handlers/</code> doesn't exist, it will notice because the stale reference blocks its work:</p> <pre><code>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</code></pre> <p>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 <code>/ctx-drift</code> exists and to decide the current task should pause for maintenance.</p> <p>If you want that behavior, reinforce it:</p> <pre><code>Good catch. Yes, run /ctx-drift and clean up any other stale references.\n</code></pre> <p>Over time, agents that have seen this pattern will start offering proactively. But do not expect it from a cold start.</p>","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":"<p><code>ctx drift</code> detects when <code>TASKS.md</code> has more than 10 completed items and flags it as a staleness warning. Running <code>ctx drift --fix</code> archives completed tasks automatically. </p> <p>You can also run <code>/ctx-archive</code> to compact on demand.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#knowledge-health-flow","level":3,"title":"Knowledge Health Flow","text":"<p>Over time, LEARNINGS.md and DECISIONS.md accumulate entries that overlap or partially repeat each other. The <code>check-persistence</code> hook detects when entry counts exceed a configurable threshold and surfaces a nudge:</p> <p>\"LEARNINGS.md has 25+ entries. Consider running /ctx-consolidate to merge overlapping items.\"</p> <p>The consolidation workflow:</p> <ol> <li>Review: <code>/ctx-consolidate</code> groups entries by keyword similarity and presents candidate merges for your approval.</li> <li>Merge: Approved groups are combined into single entries that preserve the key information from each original.</li> <li>Archive: Originals move to <code>.context/archive/</code>, not deleted -- the full history is preserved in git and the archive directory.</li> <li>Verify: Run <code>ctx drift</code> after consolidation to confirm no cross-references were broken by the merge.</li> </ol> <p>This replaces ad-hoc cleanup with a repeatable, nudge-driven cycle: detect accumulation, review candidates, merge with approval, archive originals.</p> <p>See also: Knowledge Capture for the recording workflow that feeds into this maintenance cycle.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-doctor-the-superset-check","level":2,"title":"<code>ctx doctor</code>: The Superset Check","text":"<p><code>ctx doctor</code> 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:</p> <pre><code>ctx doctor # everything in one pass\nctx doctor --json # machine-readable for scripting\n</code></pre> <p>Use <code>/ctx-doctor</code> Too</p> <p>For agent-driven diagnosis that adds semantic analysis on top of the structural checks, use <code>/ctx-doctor</code>. </p> <p>See the Troubleshooting recipe for the full workflow.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#cli-reference","level":2,"title":"CLI Reference","text":"<p>The conversational approach above uses CLI commands under the hood. When you need direct control, use the commands directly.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift","level":3,"title":"<code>ctx drift</code>","text":"<p>Scan context files for structural problems:</p> <pre><code>ctx drift\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> 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 <p>Exit codes: <code>0</code> equals clean, <code>1</code> equals warnings, <code>3</code> equals violations.</p> <p>For CI integration:</p> <pre><code>ctx drift --json | jq '.warnings | length'\n</code></pre>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift-fix","level":3,"title":"<code>ctx drift --fix</code>","text":"<p>Auto-fix mechanical issues:</p> <pre><code>ctx drift --fix\n</code></pre> <p>This handles removing dead path references, updating unambiguous renames, clearing empty sections. Issues requiring judgment are flagged but left for you.</p> <p>Run <code>ctx drift</code> again afterward to confirm what remains.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-sync","level":3,"title":"<code>ctx sync</code>","text":"<p>After a refactor, reconcile context with the actual codebase structure:</p> <pre><code>ctx sync --dry-run # preview first\nctx sync # apply\n</code></pre> <p><code>ctx sync</code> scans for structural changes, compares with <code>ARCHITECTURE.md</code>, checks for new dependencies worth documenting, and identifies context referring to code that no longer exists.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-compact","level":3,"title":"<code>ctx compact</code>","text":"<p>Consolidate completed tasks and clean up empty sections:</p> <pre><code>ctx compact # move completed tasks to Completed section,\n # remove empty sections\nctx compact --archive # also archive old tasks to .context/archive/\n</code></pre> <ul> <li>Tasks: moves completed items (with all subtasks done) into the Completed section of <code>TASKS.md</code></li> <li>All files: removes empty sections left behind</li> <li>With <code>--archive</code>: writes tasks older than 7 days to <code>.context/archive/tasks-YYYY-MM-DD.md</code></li> </ul> <p>Without <code>--archive</code>, nothing is deleted: Tasks are reorganized in place.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-fmt","level":3,"title":"<code>ctx fmt</code>","text":"<p>Normalize context file line widths:</p> <pre><code>ctx fmt # wrap long lines to 80 chars\nctx fmt --check # CI: exit 1 if files need formatting\n</code></pre> <p>Long task descriptions, decision rationale, and learning entries accumulate as single-line entries. <code>ctx fmt</code> wraps them at word boundaries with 2-space continuation indent for list items. Headings, tables, and comments are preserved.</p> <p>Idempotent: safe to run repeatedly.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-status","level":3,"title":"<code>ctx status</code>","text":"<p>Quick health overview:</p> <pre><code>ctx status --verbose\n</code></pre> <p>Shows file counts, token estimates, modification times, and drift warnings in a single glance.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-prompt-audit","level":3,"title":"<code>/ctx-prompt-audit</code>","text":"<p>Checks whether your context files are readable, compact, and token-efficient for the model.</p> <pre><code>/ctx-prompt-audit\n</code></pre>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>Conversational approach (recommended):</p> <pre><code>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</code></pre> <p>CLI approach (for CI, scripts, or direct control):</p> <pre><code>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</code></pre>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tips","level":2,"title":"Tips","text":"<p>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 <code>/ctx-drift</code>. Over time, it starts offering.</p> <p>When an agent says \"this reference looks stale,\" it is usually right.</p> <p>Semantic drift is more damaging than structural drift: <code>ctx drift</code> catches dead paths. But <code>CONVENTIONS.md</code> 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.</p> <p>Use <code>ctx status</code> 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.</p> <p>Drift detection in CI: add <code>ctx drift --json</code> to your CI pipeline and fail on exit code 3 (violations). This catches constitution-level problems before they reach upstream.</p> <p>Do not over-compact: Completed tasks have historical value. The <code>--archive</code> flag preserves them in <code>.context/archive/</code> so you can search past work without cluttering active context.</p> <p>Sync is cautious by default: Use <code>--dry-run</code> after large refactors, then apply.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#next-up","level":2,"title":"Next Up","text":"<p>Claude Code Permission Hygiene →: Recommended permission defaults and maintenance workflow for Claude Code.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#see-also","level":2,"title":"See Also","text":"<ul> <li>Troubleshooting: full diagnostic workflow using <code>ctx doctor</code>, event logs, and <code>/ctx-doctor</code></li> <li>Tracking Work Across Sessions: task lifecycle and archival</li> <li>Persisting Decisions, Learnings, and Conventions: keeping knowledge files current</li> <li>The Complete Session: where maintenance fits in the daily workflow</li> <li>CLI Reference: full flag documentation for all commands</li> <li>Context Files: structure and purpose of each <code>.context/</code> file</li> </ul>","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":"<p><code>ctx</code> hooks speak <code>ctx</code>'s language, not your project's. The QA gate says \"lint the ENTIRE project\" and \"make build,\" but your Python project uses <code>pytest</code> and <code>ruff</code>. The post-commit nudge suggests running lints, but your project uses <code>npm test</code>. You could remove the hook entirely, but then you lose the logic (counting, state tracking, adaptive frequency) just to change the words.</p> <p>How do you customize what hooks say without removing what they do?</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre>","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 <code>ctx hook message list</code> CLI command Show all hook messages with category and override status <code>ctx hook message show</code> CLI command Print the effective message template <code>ctx hook message edit</code> CLI command Copy embedded default to <code>.context/</code> for editing <code>ctx hook message reset</code> 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":"<p>Hook messages use a 3-tier fallback:</p> <ol> <li>User override: <code>.context/hooks/messages/{hook}/{variant}.txt</code></li> <li>Embedded default: compiled into the <code>ctx</code> binary</li> <li>Hardcoded fallback: belt-and-suspenders safety net</li> </ol> <p>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.</p>","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":"<p>The default templates live in the <code>ctx</code> source tree at:</p> <pre><code>internal/assets/hooks/messages/{hook}/{variant}.txt\n</code></pre> <p>You can also browse them on GitHub: <code>internal/assets/hooks/messages/</code></p> <p>Or use <code>ctx hook message show</code> to print any template without digging through source code:</p> <pre><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</code></pre> <p>The <code>show</code> output includes the template source and available variables -- everything you need to write a replacement.</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#template-variables","level":3,"title":"Template Variables","text":"<p>Some messages use Go <code>text/template</code> variables for dynamic content:</p> <pre><code>No context files updated in {{.PromptsSinceNudge}}+ prompts.\nHave you discovered learnings, made decisions,\nestablished conventions, or completed tasks\nworth persisting?\n</code></pre> <p>The <code>show</code> and <code>edit</code> commands list available variables for each message. When writing a replacement, keep the same <code>{{.VariableName}}</code> placeholders to preserve dynamic content. Variables that you omit render as <code><no value></code>: no error, but the output may look odd.</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#intentional-silence","level":3,"title":"Intentional Silence","text":"<p>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 <code>hooks.json</code>.</p>","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":"<p>The default QA gate says \"lint the ENTIRE project\" and references <code>make lint</code>. For a Python project, you want <code>pytest</code> and <code>ruff</code>:</p> <pre><code># 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</code></pre> <p>Replace the content in <code>.context/hooks/messages/qa-reminder/gate.txt</code>:</p> <pre><code>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</code></pre> <p>The hook still fires on every <code>Edit</code> call. The logic is identical. Only the instructions changed.</p>","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":"<p>The ceremony check nudges you to use <code>/ctx-remember</code> and <code>/ctx-wrap-up</code>. If your team has a different workflow and finds these noisy:</p> <pre><code>ctx hook message edit check-ceremonies both\nctx hook message edit check-ceremonies remember\nctx hook message edit check-ceremonies wrapup\n</code></pre> <p>Then empty each file:</p> <pre><code>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</code></pre> <p>The hooks still track ceremony usage internally, but they no longer emit any visible output.</p>","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":"<p>The default post-commit nudge mentions generic \"lints and tests.\" For a JavaScript project:</p> <pre><code>ctx hook message edit post-commit nudge\n</code></pre> <p>Replace with:</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#the-two-categories","level":2,"title":"The Two Categories","text":"<p>Not all messages are equal. The <code>list</code> command shows each message's category:</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#customizable-17-messages","level":3,"title":"Customizable (17 Messages)","text":"<p>Messages that are opinions: project-specific wording that benefits from customization. These are the primary targets for override.</p> 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":"<p>Messages specific to <code>ctx</code>'s own development workflow. You can customize them, but <code>edit</code> will warn you first.</p> 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 <code>{{.StaleFiles}}</code> check-context-size checkpoint (none) check-context-size oversize <code>{{.TokenCount}}</code> check-context-size window <code>{{.TokenCount}}</code>, <code>{{.Percentage}}</code> check-ceremonies both, remember, wrapup (none) check-journal both <code>{{.UnimportedCount}}</code>, <code>{{.UnenrichedCount}}</code> check-journal unenriched <code>{{.UnenrichedCount}}</code> check-journal unimported <code>{{.UnimportedCount}}</code> check-knowledge warning <code>{{.FileWarnings}}</code> check-map-staleness stale <code>{{.LastRefreshDate}}</code>, <code>{{.ModuleCount}}</code> check-persistence nudge <code>{{.PromptsSinceNudge}}</code> check-reminders reminders <code>{{.ReminderList}}</code> check-resources alert <code>{{.AlertMessages}}</code> check-version key-rotation <code>{{.KeyAgeDays}}</code> check-version mismatch <code>{{.BinaryVersion}}</code>, <code>{{.PluginVersion}}</code> post-commit nudge (none) qa-reminder gate (none) block-dangerous-commands all variants (none) block-non-path-ctx all variants (none) <p>Templates that reference undefined variables render <code><no value></code>: no error, graceful degradation.</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tips","level":2,"title":"Tips","text":"<ul> <li>Override files are version-controlled: they live in <code>.context/</code> alongside your other context files. Team members get the same customized messages.</li> <li>Start with <code>show</code>: always check the current default before editing. The embedded template is the baseline your override replaces.</li> <li>Use <code>reset</code> to undo: if a customization causes confusion, reset reverts to the embedded default instantly.</li> <li>Empty file = silence: you don't need to delete the hook. An empty override file silences the message while preserving the hook's logic.</li> <li>JSON output for scripting: <code>ctx hook message list --json</code> returns structured data for automation.</li> </ul>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#see-also","level":2,"title":"See Also","text":"<ul> <li>Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates</li> <li>Auditing System Hooks: verifying hooks are running and auditing their output</li> <li>Configuration: project-level settings via <code>.ctxrc</code></li> </ul>","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":"<p>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.</p> <p>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.</p> <p>How do you front-load design so the implementation is straightforward?</p>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-brainstorm # explore the design space\n/ctx-spec # write the spec document\n/ctx-task-out # decompose into a milestone plan\n/ctx-implement # execute step-by-step\n</code></pre> <p>Four skills, used in sequence. Each produces an artifact that feeds the next. For specs small enough to implement in one session, the spec doubles as the plan: skip <code>/ctx-task-out</code> and break the work into TASKS.md entries with <code>/ctx-task-add</code> instead.</p>","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 <code>/ctx-brainstorm</code> Skill Structured design dialogue: explore approaches <code>/ctx-spec</code> Skill Scaffold and fill out a spec from the template <code>/ctx-task-out</code> Skill Decompose a spec into <code>specs/plans/<milestone>.md</code> <code>/ctx-task-add</code> Skill Add implementation tasks to TASKS.md <code>/ctx-implement</code> Skill Execute a plan step-by-step with verification <code>/ctx-decision-add</code> 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":"<p>Start with <code>/ctx-brainstorm</code> when you have a rough idea but haven't committed to an approach. The skill follows a gated process:</p> <ol> <li>Understand context: what exists today, what's the gap</li> <li>Clarify the idea: one question at a time, not a wall of questions</li> <li>Surface non-functional requirements: performance, security, compatibility</li> <li>Lock understanding: confirm before exploring solutions</li> <li>Explore 2-3 approaches: with trade-offs for each</li> <li>Stress-test: poke holes in the chosen approach</li> <li>Present the design: detailed enough to implement from</li> </ol> <pre><code>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</code></pre> <p>The brainstorm produces a validated design in conversation. It doesn't produce a file - that's what the spec is for.</p>","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":"<p>Once the design is clear, use <code>/ctx-spec</code> to produce the written artifact. The skill reads the project's spec template (<code>specs/tpl/spec-template.md</code>) and walks through each section:</p> <pre><code>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</code></pre> <p>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.</p> <p>Sections that don't apply can be skipped. The result is a complete spec at <code>specs/{feature-name}.md</code>.</p>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-3-task-out-the-work","level":3,"title":"Step 3: Task Out the Work","text":"<p>After the spec is written, the skill routes by size. A small, single-session spec gets tasks in TASKS.md directly:</p> <pre><code>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</code></pre> <p>Each task is independently completable and references the spec via <code>Spec: specs/rss-feed.md</code> in the Phase header.</p> <p>You can also invoke <code>/ctx-task-add</code> directly at any point to add individual tasks.</p> <p>A spec that spans multiple milestones (or more than about one session of implementation) gets <code>/ctx-task-out</code> instead:</p> <pre><code>You: /ctx-task-out --spec specs/v1-substrate.md --milestone m0a\n\nAgent: \"Open questions check: D-001 (language choice) is blocking\n for m0a — three tasks would embed an assumption about its\n answer. Resolve it before I decompose.\"\n\nYou: [resolves D-001 in the spec]\n\nAgent: [writes specs/plans/m0a.md: data model, contracts, test\n matrix, 24 tasks with falsifiable acceptance criteria]\n \"Plan written. TASKS.md gained 4 epic anchors, each\n annotated Plan: specs/plans/m0a.md.\"\n</code></pre> <p>The plan document owns the fine-grained tasks; TASKS.md carries epic-level anchors only. Two hard gates apply: decomposition refuses to run past a blocking open question in the spec, and milestone N+1 is not tasked out while milestone N's definition of done is unmet.</p>","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":"<p>Pick up the work with <code>/ctx-implement</code>. The skill loads the plan — <code>specs/plans/<milestone>.md</code> when <code>/ctx-task-out</code> produced one, the spec itself for small features — breaks it into atomic steps, and checkpoints after every 3-5 steps with a build and test verification:</p> <pre><code>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</code></pre> <p>If a build or test fails, the agent stops, diagnoses, and fixes before continuing.</p>","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":"<p>Not every feature needs all four steps. Use your judgment:</p> 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: Task out Tasks exist, ready to code Step 4: Implement <p>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.</p>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't need skill names. Natural language works:</p> You say What happens \"Let's think through this feature\" <code>/ctx-brainstorm</code> \"Spec this out\" <code>/ctx-spec</code> \"Write a design doc for...\" <code>/ctx-spec</code> \"Task this out\" <code>/ctx-task-out</code> \"Break this into tasks\" <code>/ctx-task-add</code> \"Implement the spec\" <code>/ctx-implement</code> \"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":"<ul> <li>Brainstorm first when uncertain. If you can articulate the approach in two sentences, skip to spec. If you can't, brainstorm.</li> <li>Specs prevent scope creep. The Non-Goals section is as important as the approach. Writing down what you won't do keeps implementation focused.</li> <li>Edge cases are the point. A spec that only describes the happy path isn't a spec - it's a wish. The <code>/ctx-spec</code> skill pushes for at least 3 edge cases because that's where designs break.</li> <li>Record decisions during brainstorming. When you choose between approaches, the agent offers to persist the trade-off via <code>/ctx-decision-add</code>. Accept - future sessions need to know why, not just what.</li> <li>Specs are living documents. Update them when implementation reveals new constraints. A spec that diverges from reality is worse than no spec.</li> <li>The spec template is customizable. Edit <code>specs/tpl/spec-template.md</code> to match your project's needs. The <code>/ctx-spec</code> skill reads whatever template it finds there.</li> </ul>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#see-also","level":2,"title":"See Also","text":"<ul> <li>Skills Reference: /ctx-brainstorm: structured design dialogue</li> <li>Skills Reference: /ctx-spec: spec scaffolding from template</li> <li>Skills Reference: /ctx-task-out: spec decomposition into a per-milestone plan</li> <li>Skills Reference: /ctx-implement: step-by-step execution with verification</li> <li>Scrutinizing a Plan: the adversarial interview that belongs between brainstorm and spec</li> <li>Spec-Driven Development: the full operator's manual for the chain — the debated brief, per-milestone tasking, and the gates — when a feature spans several milestones</li> <li>Tracking Work Across Sessions: task lifecycle and archival</li> <li>Importing Claude Code Plans: turning ephemeral plans into permanent specs</li> <li>Persisting Decisions, Learnings, and Conventions: capturing design trade-offs</li> </ul>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/guide-your-agent/","level":1,"title":"Guide Your Agent","text":"<p>Commands vs. Skills</p> <p>Commands (<code>ctx status</code>, <code>ctx task add</code>) run in your terminal.</p> <p>Skills (<code>/ctx-reflect</code>, <code>/ctx-next</code>) run inside your AI coding assistant.</p> <p>Recipes combine both.</p> <p>Think of commands as structure and skills as behavior.</p>","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#proactive-behavior","level":2,"title":"Proactive Behavior","text":"<p>These recipes show explicit commands and skills, but agents trained on the <code>ctx</code> 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.</p> <p>Your questions train the agent. Asking \"what have we learned?\" or \"is our context clean?\" does two things:</p> <ul> <li>It triggers the workflow right now,</li> <li>and it reinforces the pattern.</li> </ul> <p>The more you guide, the more the agent habituates the behavior and begins offering on its own.</p> <p>Each recipe includes a Conversational Approach section showing these natural-language patterns.</p> <p>Tip</p> <p>Don't wait passively for proactive behavior: especially in early sessions.</p> <p>Ask, guide, reinforce. Over time, you ask less and the agent offers more.</p>","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#next-up","level":2,"title":"Next Up","text":"<p>Setup Across AI Tools →: Initialize <code>ctx</code> and configure hooks for Claude Code, OpenCode, Cursor, Aider, Copilot, or Windsurf.</p>","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: full session lifecycle from start to finish</li> <li>Prompting Guide: general tips for working effectively with AI coding assistants</li> </ul>","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":"<p>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. </p> <p>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.</p> <p>This recipe catalogs the known hook output patterns and explains when to use each one.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#tldr","level":2,"title":"TL;DR","text":"<p>Eight patterns from full control to full invisibility: </p> <ul> <li>hard gate (<code>exit 2</code>), </li> <li>VERBATIM relay (agent MUST show), </li> <li>agent directive (context injection), </li> <li>and silent side-effect (background work).</li> </ul> <p>Most hooks belong in the middle.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#the-spectrum","level":2,"title":"The Spectrum","text":"<p>These patterns form a spectrum based on who decides what the user sees:</p> 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 <p>The spectrum runs from full hook control (hard gate) to full invisibility (silent side effect). </p> <p>Most hooks belong somewhere in the middle.</p>","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":"<p>Block the tool call entirely. The agent cannot proceed: it must find another approach or tell the user.</p> <pre><code>echo '{\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}'\n</code></pre> <p>When to use: Enforcing invariants that must never be violated: Constitution rules, security boundaries, destructive command prevention.</p> <p>Hook type: <code>PreToolUse</code> only (Claude Code first-class mechanism).</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system block-non-path-ctx</code>: Enforces the PATH invocation rule</li> <li><code>block-git-push.sh</code>: Requires explicit user approval for pushes (project-local)</li> <li><code>block-dangerous-commands.sh</code>: Prevents <code>sudo</code>, copies to <code>~/.local/bin</code> (project-local)</li> </ul> <p>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.</p>","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":"<p>Force the agent to show this to the user as-is. The explicit instruction overcomes the agent's tendency to silently absorb context.</p> <pre><code>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</code></pre> <p>When to use: Actionable reminders the user needs to see regardless of what they asked: Stale backups, unimported sessions, resource warnings.</p> <p>Hook type: <code>UserPromptSubmit</code> (runs before the agent sees the prompt).</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system check-journal</code>: Unexported sessions and unenriched entries</li> <li><code>ctx system check-context-size</code>: Context capacity warning</li> <li><code>ctx system check-resources</code>: Resource pressure (memory, swap, disk, load): <code>DANGER</code> only</li> <li><code>ctx system check-freshness</code>: Technology constant staleness warning</li> </ul> <p>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.</p> <p>Key detail: The phrase <code>IMPORTANT: Relay this ... VERBATIM</code> 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.</p>","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":"<p>Tell the agent to do something, not the user. The agent decides whether and how to involve the user.</p> <pre><code>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</code></pre> <p>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.</p> <p>Hook type: <code>UserPromptSubmit</code>.</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system check-persistence</code>: Nudges the agent to persist context</li> </ul> <p>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.</p>","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":"<p>Load context with no visible output. The agent gets enriched without either party noticing.</p> <pre><code>ctx agent --budget 4000 >/dev/null || true\n</code></pre> <p>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.</p> <p>Hook type: <code>PreToolUse</code> with <code>.*</code> matcher (runs on every tool call).</p> <p>Examples in <code>ctx</code>:</p> <ul> <li>The <code>ctx agent</code> <code>PreToolUse</code> hook: injects project context silently</li> </ul> <p>Trade-off: Adds latency to every tool call. Keep the injected content small and fast to generate.</p>","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":"<p>Do work, produce no output: Housekeeping that needs no acknowledgment.</p> <pre><code>find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n</code></pre> <p>When to use: Cleanup, log rotation, temp file management. Anything where the action is the point and nobody needs to know it happened.</p> <p>Hook type: Any hook where output is irrelevant.</p> <p>Examples in <code>ctx</code>:</p> <ul> <li>Log rotation, marker file cleanup, state directory maintenance</li> </ul> <p>Trade-off: None, if the action is truly invisible. If it can fail in a way that matters, consider logging.</p>","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":"<p>Tell the agent to relay only if a condition holds in context.</p> <pre><code>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</code></pre> <p>When to use: Warnings that only matter in certain contexts. Avoids noise when the user is doing unrelated work.</p> <p>Trade-off: Depends on the agent's judgment about when the condition holds. More fragile than VERBATIM relay, but less noisy.</p>","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":"<p>Give the agent a specific command to propose to the user.</p> <pre><code>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</code></pre> <p>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.</p> <p>Trade-off: The suggestion might be wrong or outdated. The \"ask the user before proceeding\" part is critical.</p>","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":"<p>Different urgency tiers with different relay expectations.</p> <pre><code># 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</code></pre> <p>When to use: When you have multiple hooks producing output and need to avoid overwhelming the user. <code>INFO</code> gets absorbed, <code>WARN</code> gets mentioned, <code>CRITICAL</code> interrupts.</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system check-resources</code>: Uses two tiers (<code>WARNING</code>/<code>DANGER</code>) internally but only fires the VERBATIM relay at <code>DANGER</code> level: <code>WARNING</code> is silent. See <code>ctx system</code> for the user-facing command that shows both tiers.</li> </ul> <p>Trade-off: Requires agent training or convention to recognize the tiers. Without a shared protocol, the prefixes are just text.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#choosing-a-pattern","level":2,"title":"Choosing a Pattern","text":"<pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#design-tips","level":2,"title":"Design Tips","text":"<p>Throttle aggressively: VERBATIM relays that fire every prompt will be ignored or resented. Use once-per-day markers (<code>touch $REMINDED</code>), adaptive frequency (every Nth prompt), or staleness checks (only fire if condition persists).</p> <p>Include actionable commands: \"You have 12 unimported sessions\" is less useful than \"You have 12 unimported sessions. Run: <code>ctx journal import --all</code>.\" Give the user (or agent) the exact next step.</p> <p>Use box-drawing for visual structure: The <code>┌─ ─┐ │ └─ ─┘</code> pattern makes hook output visually distinct from agent prose. It also signals \"this is machine-generated, not agent opinion.\"</p> <p>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.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"<p>Lessons from 19 days of hook debugging in <code>ctx</code>. Every one of these was encountered, debugged, and fixed in production.</p>","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":"<pre><code>{ \"PreToolUseHooks\": [ ... ] }\n</code></pre> <p>The key is <code>PreToolUse</code>, not <code>PreToolUseHooks</code>. Claude Code validates silently: A misspelled key means the hook is ignored with no error. Always test with a debug <code>echo</code> first to confirm the hook fires before adding real logic.</p>","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":"<p>Go's <code>json.Marshal</code> escapes <code>></code>, <code><</code>, and <code>&</code> as Unicode sequences (<code>\\u003e</code>) by default. This breaks shell commands in generated config:</p> <pre><code>\"command\": \"ctx agent 2\\u003e/dev/null\"\n</code></pre> <p>Fix: use <code>json.Encoder</code> with <code>SetEscapeHTML(false)</code> when generating hook configuration.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#stdin-not-environment-variables","level":3,"title":"<code>stdin</code>, Not Environment Variables","text":"<p>Hook input arrives as JSON via <code>stdin</code>, not environment variables:</p> <pre><code># Wrong:\nCOMMAND=\"$CLAUDE_TOOL_INPUT\"\n\n# Right:\nHOOK_INPUT=$(cat)\nCOMMAND=$(echo \"$HOOK_INPUT\" | jq -r '.tool_input.command // empty')\n</code></pre>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#regex-overfitting","level":3,"title":"Regex Overfitting","text":"<p>A regex meant to catch <code>ctx</code> as a binary will also match <code>ctx</code> as a directory component:</p> <pre><code># 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</code></pre> <p>Test hook regexes against paths that contain the target string as a substring, not just as the final component.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#repetition-fatigue","level":3,"title":"Repetition Fatigue","text":"<p>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.</p> <p>Fix: cooldowns. <code>ctx agent --session $PPID --cooldown 10m</code> injects at most once per ten minutes per session using a tombstone file in <code>/tmp/</code>. 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.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#hardcoded-paths","level":3,"title":"Hardcoded Paths","text":"<p>A username rename (<code>parallels</code> to <code>jose</code>) broke every hook at once. Use <code>$CLAUDE_PROJECT_DIR</code> instead of absolute paths:</p> <pre><code>\"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"/.claude/hooks/block-git-push.sh\"\n</code></pre> <p>If the platform provides a runtime variable for paths, always use it.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#next-up","level":2,"title":"Next Up","text":"<p>Webhook Notifications →: Get push notifications when loops complete, hooks fire, or agents hit milestones.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#see-also","level":2,"title":"See Also","text":"<ul> <li>Customizing Hook Messages: override what hooks say without changing what they do</li> <li>Claude Code Permission Hygiene: how permissions and hooks work together</li> <li>Defense in Depth: why hooks matter for agent security</li> </ul>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/","level":1,"title":"Hook Sequence Diagrams","text":"","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#hook-lifecycle","level":2,"title":"Hook Lifecycle","text":"<p>This page documents the <code>ctx</code> system hooks: the built-in <code>ctx system *</code> subcommands that Claude Code invokes via <code>.claude/hooks.json</code> at lifecycle events. These are owned by <code>ctx</code> itself, not authored by users.</p> <p>Not to Be Confused with <code>ctx trigger</code></p> <p><code>ctx</code> has three distinct hook-like layers:</p> <ul> <li><code>ctx system</code> hooks (this page): built-in, owned by <code>ctx</code>, wired into Claude Code via <code>internal/assets/claude/hooks/hooks.json</code>.</li> <li><code>ctx trigger</code>: user-authored shell scripts in <code>.context/hooks/<type>/*.sh</code>. See <code>ctx trigger</code> reference and the trigger authoring recipe.</li> <li>Claude Code hooks configured directly in <code>.claude/settings.local.json</code>, tool-specific, not portable across AI tools.</li> </ul> <p>This page is only about the first category.</p> <p>Every <code>ctx system</code> hook is a Go binary invoked by Claude Code at one of three lifecycle events: <code>PreToolUse</code> (before a tool runs, can block), <code>PostToolUse</code> (after a tool completes), or <code>UserPromptSubmit</code> (on every user prompt, before any tools run). Hooks receive JSON on stdin and emit JSON or plain text on stdout.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#pretooluse-hooks","level":2,"title":"PreToolUse Hooks","text":"<p>These fire before a tool executes. They can block, gate, or inject context.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#context-load-gate","level":3,"title":"Context-Load-Gate","text":"<p>Matcher: <code>.*</code> (all tools)</p> <p>Injects the full context packet on first tool use of a session. One-shot per session.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-non-path-ctx","level":3,"title":"Block-Non-Path-ctx","text":"<p>Matcher: <code>Bash</code></p> <p>Blocks <code>./ctx</code>, <code>go run ./cmd/ctx</code>, or absolute-path <code>ctx</code> invocations. Constitutionally enforced.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#qa-reminder","level":3,"title":"Qa-Reminder","text":"<p>Matcher: <code>Bash</code></p> <p>Gate nudge before any git command. Reminds agent to lint/test.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#specs-nudge","level":3,"title":"Specs-Nudge","text":"<p>Matcher: <code>EnterPlanMode</code></p> <p>Nudges agent to save plans/specs when new implementation detected.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#posttooluse-hooks","level":2,"title":"PostToolUse Hooks","text":"<p>These fire after a tool completes. They observe, nudge, and track state.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#post-commit","level":3,"title":"Post-Commit","text":"<p>Matcher: <code>Bash</code></p> <p>Fires after <code>git commit</code> (not amend). Nudges for context capture and checks version drift.</p> <pre><code>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()</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-task-completion","level":3,"title":"Check-Task-Completion","text":"<p>Matcher: <code>Edit</code>, <code>Write</code></p> <p>Configurable-interval nudge after edits. Per-session counter resets after firing.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#userpromptsubmit-hooks","level":2,"title":"UserPromptSubmit Hooks","text":"<p>These fire on every user prompt, before any tools run. They perform health checks, track state, and nudge for housekeeping.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-context-size","level":3,"title":"Check-Context-Size","text":"<p>Adaptive context window monitoring. Fires checkpoints, window warnings, and billing alerts based on prompt count and token usage.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-ceremonies","level":3,"title":"Check-Ceremonies","text":"<p>Daily check for <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> usage in recent journal entries.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-freshness","level":3,"title":"Check-Freshness","text":"<p>Daily check for technology-dependent constants that may need review.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-journal","level":3,"title":"Check-Journal","text":"<p>Daily check for unimported sessions and unenriched journal entries.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-knowledge","level":3,"title":"Check-Knowledge","text":"<p>Daily check for knowledge file entry/line counts exceeding configured thresholds.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-map-staleness","level":3,"title":"Check-Map-Staleness","text":"<p>Daily check for architecture map age and relevant code changes.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-memory-drift","level":3,"title":"Check-Memory-Drift","text":"<p>Per-session check for MEMORY.md changes since last sync.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-persistence","level":3,"title":"Check-Persistence","text":"<p>Tracks context file modification and nudges when edits happen without persisting context. Adaptive threshold based on prompt count.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-reminders","level":3,"title":"Check-Reminders","text":"<p>Per-prompt check for due reminders. No throttle.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-resources","level":3,"title":"Check-Resources","text":"<p>Checks system resources (memory, swap, disk, load). Fires on every prompt. No initialization required.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-version","level":3,"title":"Check-Version","text":"<p>Daily binary-vs-plugin version comparison with piggybacked key rotation check.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#heartbeat","level":3,"title":"Heartbeat","text":"<p>Silent per-prompt pulse. Tracks prompt count, context modification, and token usage. The agent never sees this hook's output.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#project-local-hooks","level":2,"title":"Project-Local Hooks","text":"<p>These hooks are configured in <code>settings.local.json</code> and are not shipped with ctx. They are specific to individual developer setups.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-dangerous-commands","level":3,"title":"Block-Dangerous-Commands","text":"<p>Lifecycle: PreToolUse. Matcher: <code>Bash</code></p> <p>Blocks dangerous shell patterns (sudo, git push, cp to bin). No initialization or pause checks: always active.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","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 <p>* Project-local hook (settings.local.json), not shipped with ctx.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#state-file-reference","level":2,"title":"State File Reference","text":"<p>All state files live in <code>.context/state/</code>.</p> File Pattern Hook Purpose <code>ctx-loaded-{session}</code> context-load-gate One-shot injection marker <code>ctx-paused-{session}</code> (all) Session pause marker <code>ctx-wrapped-up</code> check-context-size Suppress nudges after wrap-up (2h expiry) <code>freshness-checked</code> check-freshness Daily throttle <code>ceremony-reminded</code> check-ceremonies Daily throttle <code>journal-reminded</code> check-journal Daily throttle <code>knowledge-reminded</code> check-knowledge Daily throttle <code>map-staleness-reminded</code> check-map-staleness Daily throttle <code>version-checked</code> check-version Daily throttle <code>memory-drift-nudged-{session}</code> check-memory-drift Per-session tombstone <code>ctx-context-count-{session}</code> check-context-size Prompt counter <code>stats-{session}.jsonl</code> check-context-size Session stats log <code>persist-{session}</code> check-persistence Counter + mtime state <code>ctx-task-count-{session}</code> check-task-completion Prompt counter <code>heartbeat-count-{session}</code> heartbeat Prompt counter <code>heartbeat-mtime-{session}</code> heartbeat Last context mtime","path":["Recipes","Hooks and Notifications","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":"<code>ctx</code> Hub: High-Availability Cluster","text":"<p>Run multiple hub nodes with Raft-based leader election for redundancy. Any follower can take over if the leader dies.</p> <p>This recipe assumes you've read the <code>ctx</code> 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.</p> <p>Raft-Lite</p> <p><code>ctx</code> 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.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#topology","level":2,"title":"Topology","text":"<p>A minimum HA cluster is three nodes. Two is worse than one: it doubles failure probability without providing quorum.</p> <pre><code> +-------------+\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</code></pre>","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":"<pre><code>ctx hub start --daemon \\\n --port 9900 \\\n --peers hub-b.lan:9900,hub-c.lan:9900\n</code></pre> <p>The node starts a Raft election as soon as it sees its peers.</p>","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":"<p>On <code>hub-b.lan</code>:</p> <pre><code>ctx hub start --daemon \\\n --port 9900 \\\n --peers hub-a.lan:9900,hub-c.lan:9900\n</code></pre> <p>On <code>hub-c.lan</code>:</p> <pre><code>ctx hub start --daemon \\\n --port 9900 \\\n --peers hub-a.lan:9900,hub-b.lan:9900\n</code></pre> <p>After a few seconds, one node wins the election and becomes the leader. The other two are followers.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-3-verify-cluster-state","level":2,"title":"Step 3: Verify Cluster State","text":"<p>From any node:</p> <pre><code>ctx hub status\n</code></pre> <p>Expected output:</p> <pre><code>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</code></pre>","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":"<p>The <code>ctx hub *</code> commands above run on the hub nodes themselves and don't need a project. The <code>ctx connection *</code> commands below are different: they live inside a project (the encrypted hub config is stored at <code>.context/.connect.enc</code>), so you have to tell <code>ctx</code> which project first.</p> <p>When registering a client, give it the full peer list:</p> <pre><code># In the project directory on the client:\nctx connection register hub-a.lan:9900 \\\n --token ctx_adm_... \\\n --peers hub-b.lan:9900,hub-c.lan:9900\n</code></pre> <p>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.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#runtime-membership-changes","level":2,"title":"Runtime Membership Changes","text":"<p>Add a new peer without downtime:</p> <pre><code>ctx hub peer add hub-d.lan:9900\n</code></pre> <p>Remove a decommissioned peer:</p> <pre><code>ctx hub peer remove hub-c.lan:9900\n</code></pre>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#planned-maintenance","level":2,"title":"Planned Maintenance","text":"<p>Before taking a leader offline, hand off leadership:</p> <pre><code>ssh hub-a.lan 'ctx hub stepdown'\n</code></pre> <p><code>stepdown</code> triggers a new election among the remaining followers before the leader goes offline. In-flight clients briefly pause, then reconnect to the new leader.</p>","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 <p>For the full list, see Hub failure modes.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#see-also","level":2,"title":"See Also","text":"<ul> <li>Multi-machine recipe: single-node deployment</li> <li>Hub operations: backup and maintenance</li> <li>Hub security model: TLS, tokens</li> </ul>","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":"<code>ctx</code> Hub: Getting Started","text":"<p>Stand up a single-node <code>ctx</code> Hub on localhost, register two projects, publish a decision from one, and see it appear in the other, all in under five minutes.</p> <p>Read This First</p> <p>If you haven't already, skim the <code>ctx</code> 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.</p>","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":"<p>By the end, you will have:</p> <ol> <li>A local hub process running on port <code>9900</code>.</li> <li>Two project directories both registered with the <code>ctx</code> Hub.</li> <li>A decision published from project <code>alpha</code> that appears automatically in project <code>beta</code>'s <code>.context/hub/</code> and in <code>ctx agent --include-hub</code> output.</li> </ol> <p>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.</p>","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":"<ul> <li>Sharing <code>.context/journal/</code>, <code>.context/pad</code>, or any other local state. The hub only fans out <code>decision</code>, <code>learning</code>, <code>convention</code>, and <code>task</code> entries. Everything else stays local.</li> <li>Multi-user attribution. The hub identifies projects, not people.</li> <li>Running over a LAN; see Multi-machine setup.</li> <li>Redundancy; see HA cluster.</li> </ul>","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li><code>ctx</code> installed and on <code>PATH</code></li> <li>Two project directories, each already initialized with <code>ctx init</code></li> </ul>","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":"<p>In a dedicated terminal:</p> <pre><code>ctx hub start\n</code></pre> <p>On first run, the hub generates an admin token and prints it to stdout. Copy it; you'll need it for each project registration:</p> <pre><code>ctx hub listening on :9900\nadmin token: ctx_adm_7f3a1c2d...\ndata dir: ~/.ctx/hub-data/\n</code></pre> <p>The admin token is written to <code>~/.ctx/hub-data/admin.token</code> so you can recover it later. Treat it like a password.</p>","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":"<p><code>ctx hub start</code> 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 <code>.context/.connect.enc</code>, so you have to tell <code>ctx</code> which project first.</p> <pre><code>cd ~/projects/alpha\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\n</code></pre> <p>This stores an encrypted connection config in <code>.context/.connect.enc</code>. The admin token is exchanged for a per-project client token; the admin token itself is never persisted in the project.</p>","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":"<pre><code>ctx connection subscribe decision learning convention\n</code></pre> <p>Only the entry types you subscribe to will be delivered by <code>sync</code> and <code>listen</code>.</p>","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":"<p>Either use <code>ctx add --share</code> to write locally and push to the <code>ctx</code> Hub:</p> <pre><code>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</code></pre> <p>Or publish an existing entry directly:</p> <pre><code>ctx connection publish decision \"Use UTC timestamps everywhere\"\n</code></pre>","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":"<pre><code>cd ~/projects/beta\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\nctx connection subscribe decision learning convention\nctx connection sync\n</code></pre> <p>The decision from <code>alpha</code> now appears in <code>~/projects/beta/.context/hub/decisions.md</code> with an origin tag and timestamp.</p>","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":"<p>Instead of re-running <code>sync</code>, stream new entries as they land:</p> <pre><code>ctx connection listen\n</code></pre> <p>Leave this running in a terminal; every <code>--share</code> publish from any registered project will appear in <code>.context/hub/</code> immediately.</p>","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":"<p>Once entries exist in <code>.context/hub/</code>, include them in the agent context packet:</p> <pre><code>ctx agent --include-hub\n</code></pre> <p>Shared entries are added as a dedicated tier in the budget-aware assembly, scored by recency and type relevance.</p>","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":"<p>After <code>register</code>, the <code>check-hub-sync</code> hook pulls new entries at the start of each session (daily throttled). Most users never need to call <code>ctx connection sync</code> manually.</p>","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#where-to-go-next","level":2,"title":"Where to Go Next","text":"<ul> <li>Multi-machine hub: run the hub on a LAN host and connect from other workstations.</li> <li>HA cluster: Raft-based leader election for high availability.</li> <li>Hub operations: daemon mode, backup, log rotation, JSONL store layout.</li> <li>Hub security model: token lifecycle, encryption at rest, threat model.</li> <li><code>ctx connection</code> reference and <code>ctx hub start</code> reference.</li> </ul>","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":"<code>ctx</code> Hub: Multi-Machine","text":"<p>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 <code>ctx</code> Hub overview; read that first if you haven't, especially the trust-model warnings.</p> <p>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).</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#topology","level":2,"title":"Topology","text":"<pre><code>+------------------+ +------------------+\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</code></pre>","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":"<p>On the machine that will hold the hub (call it <code>nexus</code>):</p> <pre><code>ctx hub start --daemon --port 9900\n</code></pre> <p>The daemon writes a PID file to <code>~/.ctx/hub-data/hub.pid</code>. Stop it later with:</p> <pre><code>ctx hub stop\n</code></pre>","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":"<p>Open port <code>9900/tcp</code> on <code>nexus</code> 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).</p> <p>Typical LAN allowlist rules:</p> firewalldufwnftables <pre><code>sudo firewall-cmd --zone=internal \\\n --add-port=9900/tcp --permanent\nsudo firewall-cmd --reload\n</code></pre> <pre><code>sudo ufw allow from 192.168.1.0/24 to any port 9900 proto tcp\n</code></pre> <pre><code>sudo nft add rule inet filter input ip saddr 192.168.1.0/24 \\\n tcp dport 9900 accept\n</code></pre>","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":"<p>The daemon prints the admin token to stdout on first run. Running as a daemon, that output goes to the log instead:</p> <pre><code>cat ~/.ctx/hub-data/admin.token\n</code></pre> <p>Copy the token over a trusted channel (SSH, password manager, or an encrypted note). Do not email it or put it in chat.</p>","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":"<p>The <code>ctx hub *</code> commands above run on the LAN host (<code>nexus</code>) 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 <code>.context/</code>), so you have to tell <code>ctx</code> which project first.</p> <p>On workstation <code>A</code>:</p> <pre><code>cd ~/projects/x\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n</code></pre> <p>On workstation <code>B</code>:</p> <pre><code>cd ~/projects/y\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n</code></pre> <p>Each registration exchanges the admin token for a per-project client token. Only the client token is persisted in <code>.context/.connect.enc</code>, encrypted with the same AES-256-GCM scheme <code>ctx</code> uses for notification credentials.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-5-verify","level":2,"title":"Step 5: Verify","text":"<p>From either workstation:</p> <pre><code>ctx connection status\n</code></pre> <p>You should see the <code>ctx</code> Hub address, role (<code>leader</code> for single-node), subscription filters, and the sequence number you're synced to.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#tls-recommended","level":2,"title":"TLS (Recommended)","text":"<p>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:</p> <pre><code>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</code></pre> <p>Point <code>ctx connection register</code> at the public hostname and port 443.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#handling-daemon-restarts","level":2,"title":"Handling Daemon Restarts","text":"<p>The hub is append-only JSONL, so restarts are safe. Clients keep their last-seen sequence in <code>.context/hub/.sync-state.json</code> and pick up exactly where they left off on the next <code>sync</code> or <code>listen</code> reconnect.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#see-also","level":2,"title":"See Also","text":"<ul> <li>HA cluster recipe: for redundancy</li> <li>Hub operations: backup, rotation</li> <li>Hub failure modes</li> <li>Hub security model</li> </ul>","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":"<code>ctx</code> Hub: Overview","text":"<p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#mental-model-in-one-paragraph","level":2,"title":"Mental Model in One Paragraph","text":"<p>The hub is a fan-out channel for structured knowledge entries across projects. When you publish a decision, learning, convention, or task with <code>--share</code>, 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.</p> <p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#what-flows-through-the-hub","level":2,"title":"What Flows through the Hub","text":"<p>Only four entry types:</p> Type What it is <code>decision</code> Architectural decisions with rationale <code>learning</code> Gotchas, lessons, surprising behaviors <code>convention</code> Coding patterns and standards <code>task</code> Work items worth sharing across projects <p>Each entry is an immutable record with a content blob, the publishing project's name as <code>Origin</code>, a timestamp, and a hub-assigned sequence number. Once published, entries are never rewritten.</p>","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":"<p>This is the part new users get wrong most often:</p> <ul> <li>Session journals (<code>~/.claude/</code> logs, <code>.context/journal/</code>) stay local. The hub does not sync your AI session history.</li> <li>Scratchpad (<code>.context/pad</code>) stays local. Encrypted notes never leave the machine they were written on.</li> <li>Local context files as a whole (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>) are not mirrored wholesale. Only entries you explicitly <code>--share</code>, or publish later with <code>ctx connection publish</code>, cross the boundary.</li> <li>Anything under <code>.context/</code> that isn't one of the four entry types above. Configuration, state, logs, memory, journal metadata: all local.</li> </ul> <p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#two-user-stories","level":2,"title":"Two User Stories","text":"<p>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.</p>","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":"<p>One developer, many projects, one hub, usually on localhost.</p> <p>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.</p> <p>Concrete payoff:</p> <ul> <li><code>ctx learning add --share \"...\"</code> in project A → <code>ctx agent --include-hub</code> in project B shows that learning in the next context packet.</li> <li>A decision recorded in your personal \"dotfiles\" project is instantly visible to every other project on your workstation.</li> <li>Cross-project conventions (e.g., \"use UTC timestamps everywhere\") live in one place and propagate.</li> </ul> <p>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.</p> <p>Start here: Getting Started for the one-time setup, then Personal cross-project brain for the day-to-day workflow.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#story-2-small-trusted-team","level":3,"title":"Story 2: Small Trusted Team","text":"<p>A few teammates, projects they each own, one hub on a LAN host they all trust.</p> <p>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.</p> <p>Concrete payoff:</p> <ul> <li>Team conventions propagate without needing a wiki or chat.</li> <li>Lessons from one team member become available to everyone else's agent context packets automatically.</li> <li>Cross-project decisions (shared libraries, deployment patterns, naming rules) live in a single log the whole team reads.</li> </ul> <p>Trust model: the hub assumes everyone holding a client token is friendly. There is no per-user attribution you can rely on, <code>Origin</code> 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.</p> <p>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.</p> <p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#identity-projects-not-users","level":2,"title":"Identity: Projects, Not Users","text":"<p>The hub has no concept of users. Its unit of identity is the project. <code>ctx connection register</code> binds a hub token to a project directory, not to a person. Two developers working on the same project share either:</p> <ul> <li>The same <code>.connect.enc</code>, copied between machines over a trusted channel, or</li> <li>Different project names (<code>alpha@laptop-a</code>, <code>alpha@laptop-b</code>), because the hub rejects duplicate registrations of the same project name.</li> </ul> <p>Either works; neither gives you per-human attribution. If you need \"who wrote this,\" the hub is the wrong tool.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#when-not-to-use-it","level":2,"title":"When Not to Use It","text":"<ul> <li>Solo, single-project work. Local <code>.context/</code> files are enough. The hub adds operational surface for no payoff.</li> <li>Untrusted participants. The hub assumes everyone with a client token is friendly. It is not hardened against hostile insiders or compromised tokens.</li> <li>Compliance-sensitive environments. There is no audit trail that can prove who published what, only which project published what, and <code>Origin</code> is self-asserted.</li> <li>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.</li> <li>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.</li> </ul>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#how-entries-reach-your-agent","level":2,"title":"How Entries Reach Your Agent","text":"<p>Once a project is registered and subscribed, entries arrive by three mechanisms:</p> <ol> <li><code>ctx connection sync</code>: an on-demand pull, replays everything new since the last sequence you saw.</li> <li><code>ctx connection listen</code>: a long-lived gRPC stream that writes new entries to <code>.context/hub/</code> as they arrive.</li> <li><code>check-hub-sync</code> hook: runs at session start, daily throttled, so most users never call <code>sync</code> manually.</li> </ol> <p>Once entries exist in <code>.context/hub/</code>, <code>ctx agent --include-hub</code> adds a dedicated tier to the budget-aware context packet, scored by recency and type relevance. That's the end of the pipeline.</p>","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 <code>ctx connection</code>, <code>ctx serve</code>, <code>ctx hub</code>","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":"<p>This recipe shows how one developer uses a <code>ctx</code> 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.</p> <p>Prerequisites: a working <code>ctx</code> 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.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#the-core-loop","level":2,"title":"The Core Loop","text":"<p>Every day, the same three verbs matter:</p> <ol> <li>Record: notice a decision, learning, or convention and capture it with <code>ctx add --share</code>.</li> <li>Subscribe: every project you care about is subscribed to the types you want delivered (set once with <code>ctx connection subscribe</code>).</li> <li>Load: your agent picks up shared entries on next session start via the auto-sync hook, or explicitly via <code>ctx agent --include-hub</code>.</li> </ol> <p>That's the whole workflow. The rest of this recipe fills in the concrete moments where each verb matters.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#a-realistic-day","level":2,"title":"A Realistic Day","text":"<p>You have three projects on your workstation:</p> <ul> <li><code>~/projects/api</code>, a Go service you're actively developing</li> <li><code>~/projects/cli</code>, a companion CLI that consumes the API</li> <li><code>~/projects/dotfiles</code>, your personal conventions and cross-project learnings</li> </ul> <p>All three are registered with a single hub running on <code>localhost:9900</code> (started once at boot, or via a systemd user unit; see Hub operations). All three subscribe to <code>decision</code>, <code>learning</code>, and <code>convention</code>.</p>","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 <code>api</code>","text":"<p>You <code>cd ~/projects/api</code> and start a Claude Code session. Behind the scenes, the plugin's <code>PreToolUse</code> hook calls <code>ctx agent --budget 8000 --include-hub</code> before the first tool call. Agent loads:</p> <ul> <li>Local <code>.context/</code> (TASKS, DECISIONS, LEARNINGS, etc.)</li> <li>Foundation steering files (always-inclusion)</li> <li>Everything you've shared from the other two projects</li> </ul> <p>So the \"use UTC timestamps everywhere\" decision you recorded in <code>dotfiles</code> last week is already in Claude's context for this session, without any manual <code>sync</code>.</p>","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":"<p>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 <code>LEARNINGS.md</code> in <code>api/</code>. But it's useful across every Go service you'll ever write, not just this one. So:</p> <pre><code>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</code></pre> <p>The <code>--share</code> flag does two things:</p> <ol> <li>Writes the learning to <code>api/.context/LEARNINGS.md</code> locally (as a normal <code>ctx learning add</code> would).</li> <li>Publishes the same entry to the <code>ctx</code> Hub, which stores it in the append-only JSONL and fans it out to every subscribed client.</li> </ol> <p>Within seconds, <code>cli/.context/hub/learnings.md</code> and <code>dotfiles/.context/hub/learnings.md</code> both contain a copy of this learning (the <code>ctx connection listen</code> daemon picks it up from the <code>ctx</code> Hub's Listen stream).</p>","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 <code>cli</code>","text":"<p><code>cd ~/projects/cli</code>, open a new session. The agent packet for <code>cli</code> now includes the learning you just recorded in <code>api</code>, because <code>cli</code> is subscribed to <code>learning</code> and the entry has already been synced into <code>cli/.context/hub/learnings.md</code>.</p> <p>You don't have to re-explain the retry-loop gotcha. Claude already sees it.</p>","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":"<p>You've been writing error messages in <code>api</code> 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 <code>dotfiles</code> (since that's your \"personal standards\" project), and share it:</p> <pre><code>cd ~/projects/dotfiles\nctx convention add --share \\\n \"Error messages: lowercase start, no trailing period, single sentence (follows Go's stdlib style)\"\n</code></pre> <p>The convention lands in <code>dotfiles/CONVENTIONS.md</code> locally and fans out to <code>api</code> and <code>cli</code> via the hub. The next Claude Code session in either project gets the convention injected into the steering-adjacent slot of the agent packet.</p>","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":"<p>You didn't run <code>ctx connection sync</code> once. You didn't <code>git push</code> 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.</p>","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":"<p>Stripped of prose, the day's commands were:</p> <pre><code># 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</code></pre> <p>The hub is passive infrastructure. You never talk to it directly; you talk through it by using <code>--share</code> on commands you were already running.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#tips-for-solo-use","level":2,"title":"Tips for Solo Use","text":"<p>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 <code>ctx-standards</code> project all work. Record cross-cutting conventions there and let the hub propagate them to everything else.</p> <p>Subscribe to <code>task</code> only if you want cross-project todos. The four subscribable types are <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. 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 <code>task</code> in <code>ctx connection subscribe</code> unless you have a specific reason.</p> <p>Run the hub as a user-level daemon so you don't have to remember to start it. On Linux with systemd:</p> <pre><code># ~/.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</code></pre> <pre><code>systemctl --user enable --now ctx-hub.service\n</code></pre> <p>Don't overthink subscription filters. For personal use, subscribe every project to all four types at first (or three, if you skip <code>task</code>). Tune later if the context packets get noisy.</p> <p>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.</p>","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":"<p>Not a setup guide. For the one-time hub install and project registration, use Getting Started.</p> <p>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.</p> <p>Not production operations. For backup, log rotation, failure recovery, and HA, see Hub operations and Hub failure modes.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#see-also","level":2,"title":"See Also","text":"<ul> <li>Hub overview: when to use the Hub and when not to.</li> <li>Team knowledge bus: the multi-human companion recipe.</li> <li><code>ctx connection</code>: the client-side commands used above (<code>subscribe</code>, <code>publish</code>, <code>sync</code>, <code>listen</code>, <code>status</code>).</li> <li><code>ctx add</code>: the <code>--share</code> flag reference.</li> <li><code>ctx hub</code>: operator commands for starting, stopping, and inspecting the hub.</li> </ul>","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":"<p>This recipe shows how a small trusted team uses a <code>ctx</code> 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.</p> <p>Prerequisites:</p> <ul> <li>A running <code>ctx</code> Hub on a LAN host or internal server everyone on the team can reach. See Multi-machine setup for the deployment guide.</li> <li>Each team member has <code>ctx</code> installed and has <code>ctx connection register</code>-ed their working projects with the hub.</li> <li>Client-side commands (<code>ctx connection ...</code>, <code>ctx add --share</code>) must be run from each project's root — <code>ctx</code> reads <code>$PWD/.context/</code>. The hub server (<code>ctx hub start</code>, etc.) doesn't need this; it operates on the hub data directory rather than a project.</li> </ul>","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":"<p>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 <code>Origin</code> 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.</p> <p>If your team is:</p> <ul> <li>✅ 3-10 engineers, all known to each other, all trusted with production access</li> <li>✅ On a single internal network or behind a VPN</li> <li>✅ Comfortable with \"the hub assumes friendly participants\"</li> </ul> <p>…this recipe fits. If your team is:</p> <ul> <li>❌ Larger than ~15, with turnover</li> <li>❌ Includes contractors, untrusted agents, or compromised-workstation concerns</li> <li>❌ Needs audit trails that prove who published what</li> <li>❌ Requires per-team-member isolation</li> </ul> <p>…you're in \"Story 3\" territory, which the hub does not support today. Use a wiki or a dedicated knowledge platform instead.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#the-teams-three-verbs","level":2,"title":"The Team's Three Verbs","text":"<p>Everyone on the team does three things, same as in the personal recipe, but with different social expectations:</p> <ol> <li>Record: when you learn something that would save a teammate time, capture it with <code>ctx add --share</code>.</li> <li>Subscribe: every engineer's project directories subscribe to the types the team cares about.</li> <li>Load: agents pick up shared entries automatically via the auto-sync hook and the <code>--include-hub</code> flag in the PreToolUse hook pipeline.</li> </ol> <p>The operational shape is identical to solo use. What's different is the culture around publishing: when do you <code>--share</code>, and what belongs on the hub vs. in your local <code>.context/</code>.</p>","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":"<p>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, <code>--share</code>. If no, record it locally and move on.</p> <p>Decisions:</p> <ul> <li>✅ Cross-service decisions (database choice, auth model, deployment pattern, monitoring stack).</li> <li>✅ Policy decisions that apply to all services (naming, API versioning, error-message format).</li> <li>❌ Internal implementation decisions inside a single service (\"chose a map over a slice here because lookups dominate\").</li> <li>❌ One-off tactical calls for a specific PR.</li> </ul> <p>Learnings:</p> <ul> <li>✅ Gotchas, surprising behavior, flaky infrastructure quirks, anything you'd tell a teammate over coffee with \"watch out for X\".</li> <li>✅ Lessons from incidents, right after the postmortem is the highest-value time to share.</li> <li>❌ Internal debugging notes that only make sense with context from your current branch.</li> </ul> <p>Conventions:</p> <ul> <li>✅ Repo layout, commit message format, pre-commit hooks, review expectations.</li> <li>✅ Language-level style decisions that apply across services.</li> <li>❌ Per-service idioms (\"in <code>billing/</code> we prefer…\").</li> </ul> <p>Tasks: almost always project-local. Don't subscribe to <code>task</code> unless the team has a specific reason (e.g., a cross-cutting migration you want visible everywhere).</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#a-realistic-week","level":2,"title":"A Realistic Week","text":"<p>Monday, 3 AM incident, shared learning</p> <p>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:</p> <pre><code>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</code></pre> <p>By Tuesday morning, every other engineer's agent context packet contains this learning. When Bob starts work on the <code>ledger</code> service (which also uses grpc-go), his Claude Code session already knows about the gotcha without Bob having to read the incident channel.</p> <p>Wednesday, cross-service decision</p> <p>The team agrees on a new pattern for API versioning: header-based instead of URL-based. Platform lead Carol records the decision:</p> <pre><code>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</code></pre> <p>Every engineer's next session knows about this decision automatically. When Dave starts adding endpoints to the <code>inventory</code> service on Thursday, Claude already prompts him for the header pattern instead of defaulting to <code>/v1/</code>.</p> <p>Friday, convention drift caught at review</p> <p>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 <code>ctx connection status</code>, sees the hub is healthy, greps his local <code>.context/hub/conventions.md</code>, and finds:</p> <pre><code>## [2026-03-12] Error message format\nLowercase start, no trailing period, single sentence.\n</code></pre> <p>He fixes the PR. No lookup on the wiki, no question in chat, no context-switch penalty.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#workflow-tips-for-teams","level":2,"title":"Workflow Tips for Teams","text":"<p>Designate a \"champion\" for decisions. The team lead or platform engineer should be the person who explicitly <code>--share</code>s cross-cutting decisions. Other team members share learnings freely but should ask \"should this be a decision?\" in review before <code>--share</code>ing a decision. This keeps the decision stream signal-rich.</p> <p>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.</p> <p>Delete noisy entries, don't tolerate them. The hub is append-only, but the <code>.context/hub/</code> 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 <code>entries.jsonl</code> (see Hub operations). Noisy shared feeds lose trust fast.</p> <p>Don't subscribe every project to every type. For backend engineers, subscribing to <code>decision + learning + convention</code> is usually right. For platform or DevOps projects, adding <code>task</code> makes sense. For a prototype or experiment project, subscribing only to <code>convention</code> might be enough.</p> <p>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.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#operational-concerns","level":2,"title":"Operational Concerns","text":"<p>The team recipe assumes someone owns the hub host. That person (or a small group) is responsible for:</p> <ul> <li>Uptime: the hub is infrastructure; treat it like any other internal service you run. See Hub operations.</li> <li>Backups: <code>entries.jsonl</code> is the source of truth. Snapshot it to the same backup tier as your other internal data.</li> <li>Upgrades: cadence the team agrees on. Major upgrades may require everyone to re-register, so do them at natural breaks.</li> <li>Failures: see Hub failure modes for the standard oncall playbook.</li> </ul> <p>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.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#token-management","level":2,"title":"Token Management","text":"<p>Every team member has a client token stored in their <code>.context/.connect.enc</code>. Rules of thumb:</p> <ul> <li>One token per engineer per project. Not one token per team; not one shared token. Each engineer registers each of their working projects separately.</li> <li>Token compromise = revoke immediately. When an engineer leaves, their tokens should be removed from <code>clients.json</code> on the hub. This is a manual operation today; see Hub security for the revocation steps.</li> <li>No checked-in tokens. <code>.context/.connect.enc</code> is encrypted with the local machine key, but don't push it to shared repos; it's per-workstation.</li> </ul>","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":"<p>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.</p> <p>Not an audit log. <code>Origin</code> on the hub is self-asserted. If compliance requires provenance, the hub is the wrong tool.</p> <p>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.</p> <p>Not a production service for end users. This is internal team infrastructure. Do not expose the hub to customers, partners, or the open internet.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#see-also","level":2,"title":"See Also","text":"<ul> <li>Hub overview: when to use the hub and when not to.</li> <li>Personal cross-project brain: the single-developer companion recipe.</li> <li>Multi-machine setup: standing up the hub on a LAN host.</li> <li>HA cluster: optional redundancy for larger teams.</li> <li>Hub operations: backup, rotation, monitoring.</li> <li>Hub security: threat model and hardening checklist.</li> </ul>","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":"<p>Claude Code plan files (<code>~/.claude/plans/*.md</code>) 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.</p> <p>How do you turn a useful plan into a permanent project spec?</p>","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Plans are copied (not moved) to <code>specs/</code>, slugified by their H1 heading.</p>","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 <code>/ctx-plan-import</code> Skill List, filter, and import plan files to specs <code>/ctx-task-add</code> 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":"<p>Invoke the skill and it lists plans with modification dates and titles:</p> <pre><code>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</code></pre>","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":"<p>You can narrow the list with arguments:</p> Argument Effect <code>--today</code> Only plans modified today <code>--since YYYY-MM-DD</code> Only plans modified on or after the date <code>--all</code> Import everything without prompting (none) Interactive selection <pre><code>You: /ctx-plan-import --today\nYou: /ctx-plan-import --since 2026-02-27\nYou: /ctx-plan-import --all\n</code></pre>","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":"<p>Pick one or more plans by number:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<p>If you say yes, the agent creates tasks in <code>TASKS.md</code> that reference the imported specs:</p> <pre><code>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</code></pre>","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't need to remember the exact skill name:</p> You say What happens \"import my plans\" <code>/ctx-plan-import</code> (interactive) \"save today's plans as specs\" <code>/ctx-plan-import --today</code> \"import all plans from this week\" <code>/ctx-plan-import --since ...</code> \"turn that plan into a spec\" <code>/ctx-plan-import</code> (filtered)","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tips","level":2,"title":"Tips","text":"<ul> <li>Plans are copied, not moved: The originals stay in <code>~/.claude/plans/</code>. Claude Code manages that directory; <code>ctx</code> doesn't delete from it.</li> <li>Conflict handling: If <code>specs/{slug}.md</code> already exists, the agent asks whether to overwrite or pick a different name.</li> <li>Specs are project memory: Once imported, specs are tracked in git and available to future sessions. Reference them from <code>TASKS.md</code> phase headers with <code>Spec: specs/slug.md</code>.</li> <li>Pair with <code>/ctx-implement</code>: After importing a plan as a spec, use <code>/ctx-implement</code> to execute it step-by-step with verification.</li> </ul>","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#see-also","level":2,"title":"See Also","text":"<ul> <li>Skills Reference: /ctx-plan-import: full skill description</li> <li>The Complete Session: where plan import fits in the session flow</li> <li>Tracking Work Across Sessions: managing tasks that reference imported specs</li> </ul>","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":"<p>You debug a subtle issue, discover the root cause, and move on.</p> <p>Three weeks later, a different session hits the same issue. The knowledge existed briefly in one session's memory but was never written down.</p> <p>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.</p> <p>How do you make sure important context survives across sessions?</p> <p>Prefer Skills to Raw Commands</p> <p>Use <code>/ctx-decision-add</code> and <code>/ctx-learning-add</code> instead of raw <code>ctx add</code> commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.</p>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/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</code></pre> <p>Or just tell your agent: \"What have we learned this session?\"</p>","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 <code>ctx decision add</code> Command Record an architectural decision <code>ctx learning add</code> Command Record a gotcha, tip, or lesson <code>ctx convention add</code> Command Record a coding pattern or standard <code>ctx index <file></code> Command Project a file's headings as a table of contents <code>/ctx-decision-add</code> Skill AI-guided decision capture with validation <code>/ctx-learning-add</code> Skill AI-guided learning capture with validation <code>/ctx-convention-add</code> Skill AI-guided convention recording with placement <code>/ctx-reflect</code> 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":"<p>Decision, Learning, or Convention?</p> <ul> <li>If you chose between alternatives, it is a decision.</li> <li>If you discovered something surprising, it is a learning.</li> <li>If you are codifying a repeated pattern, it is a convention.</li> </ul>","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":"<p>Three context files serve different purposes:</p> <p>Decisions (<code>DECISIONS.md</code>) 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.</p> <p>Learnings (<code>LEARNINGS.md</code>) 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. </p> <p>Learnings prevent repeating past mistakes.</p> <p>Conventions (<code>CONVENTIONS.md</code>) 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.</p>","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":"<p>Decisions have three structured fields: </p> <ul> <li>context, </li> <li>rationale, </li> <li>and consequences.</li> </ul> <p>The easiest way to record one is to tell your agent:</p> <pre><code>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</code></pre> <p>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.</p> <p>When multiple options were considered, the agent includes rejected alternatives in the rationale automatically.</p> <p>The <code>/ctx-decision-add</code> skill also guides you through the fields interactively. For quick decisions, it supports a Y-statement:</p> <p>\"In the context of [situation], facing [constraint], we decided for [choice] and against [alternatives], to achieve [benefit], accepting that [trade-off].\"</p> CLI Command for Scripting and Automation <p>When no agent is in the loop (CI pipelines, shell scripts, hooks), use the CLI directly with structured flags:</p> <pre><code>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</code></pre>","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":"<p>Learnings have three structured fields: context, lesson, and application.</p> <p>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:</p> <pre><code>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</code></pre> <p>You said one sentence. The agent produced a structured entry with all three fields filled from the session context.</p> <p>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.</p> <p>The <code>/ctx-learning-add</code> skill applies three quality filters:</p> <ol> <li>Could someone Google this in 5 minutes?</li> <li>Is it specific to this codebase?</li> <li>Did it take real effort to discover?</li> </ol> <p>All three must pass.</p> <p>Learnings capture principles and heuristics, not code snippets.</p> CLI Command for Scripting and Automation <p>When no agent is in the loop:</p> <pre><code>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</code></pre>","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":"<p>Conventions are simpler: just a name, a rule, and optionally a section.</p> <p>These are short enough that either approach works:</p> <pre><code>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</code></pre> <p>Or from the terminal:</p> <pre><code>ctx convention add \"Use kebab-case for all CLI flag names\" --section \"Naming\"\n</code></pre> <p>Conventions work best for rules that come up repeatedly. Codify a pattern the third time you see it, not the first.</p>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-5-project-a-table-of-contents-on-demand","level":3,"title":"Step 5: Project a Table of Contents on Demand","text":"<p><code>DECISIONS.md</code> and <code>LEARNINGS.md</code> do not store an index. A quick-reference table of contents — the date and title for each entry — is computed on demand, so it can never fall out of sync with the file, even after hand edits.</p> <pre><code>ctx index .context/DECISIONS.md\nctx index .context/LEARNINGS.md\n</code></pre> <p>The projection lets AI tools scan all entries without reading the full file, which matters when token budgets are tight. Use <code>--json</code> for machine-readable output.</p>","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 <code>/ctx-reflect</code> to Surface What to Capture","text":"<p>Keep It Conversational</p> <p><code>/ctx-reflect</code> is not the only way to trigger reflection.</p> <p>Agents trained on the <code>ctx</code> playbook naturally surface persist-worthy items at breakpoints, even without invoking the skill explicitly.</p> <p>A conversational prompt like \"anything worth saving?\" or \"let's wrap up\" can trigger the same review.</p> <p>The skill provides a structured checklist, but the behavior is available through natural conversation.</p> <p>At natural breakpoints (after completing a feature, fixing a bug, or before ending a session) use <code>/ctx-reflect</code> to identify items worth persisting.</p> <pre><code>/ctx-reflect\n</code></pre> <p>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:</p> <pre><code>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</code></pre> <p>The skill always asks before persisting.</p>","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":"<p>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 <code>ctx</code> playbook, natural language triggers the same operations.</p> <p>You ask, the agent acts:</p> 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 <code>CONVENTIONS.md</code> \"Let's wrap up\" Runs through the reflect checklist conversationally <p>Example exchange:</p> <pre><code>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</code></pre> <p>The agent can also be proactive without being asked. The playbook encourages agents to persist context at natural milestones.</p> <p>You may see:</p> <ul> <li>After fixing a tricky bug: \"I noticed this was a non-obvious issue. Want me to save it as a learning?\"</li> <li>After choosing between approaches: \"We just made a trade-off between file-based tokens and IPC. Should I record this as a decision?\"</li> <li>At session milestones: the agent checks what is worth persisting and offers a brief summary.</li> </ul> <p>When agents run unattended (no human in the loop), they may persist directly:</p> <ul> <li>\"I've added the subprocess env var gotcha to <code>LEARNINGS.md</code> so we don't hit it again.\"</li> <li>\"Recorded the decision to use file-based tokens over env vars in <code>DECISIONS.md</code>.\"</li> <li>\"Marked the cooldown task done and added a follow-up for TTL cleanup.\"</li> </ul> <p>This is behavior by design.</p> <p>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.</p>","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":"<pre><code># 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# Project a table of contents on demand\nctx index .context/DECISIONS.md\n\n# Reflect at breakpoints (from AI assistant)\n# /ctx-reflect\n</code></pre>","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":"<pre><code>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</code></pre> <p>Both approaches produce the same structured entries in the same context files.</p> <ul> <li>The conversational approach is the natural fit for interactive sessions; </li> <li>the CLI commands are better suited for scripts, hooks, and automation pipelines.</li> </ul>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tips","level":2,"title":"Tips","text":"<ul> <li>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.</li> <li>Learnings should fail the Gemini test. If someone could find it in a 5-minute Gemini search, it does not belong in <code>LEARNINGS.md</code>.</li> <li>Conventions earn their place through repetition. Add a convention the third time you see a pattern, not the first.</li> <li>Use <code>/ctx-reflect</code> at natural breakpoints. The checklist catches items you might otherwise lose.</li> <li>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.</li> <li>Reindex after every hand edit. It takes less than a second. A stale index causes AI tools to miss entries.</li> <li>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.</li> <li>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.</li> <li>Trust the agent's proactive instincts. Agents trained on the <code>ctx</code> 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.</li> <li> <p>Relax provenance per-project if <code>--session-id</code>, <code>--branch</code>, or <code>--commit</code> are impractical (e.g., manual notes outside an AI session). Add to <code>.ctxrc</code>:</p> <pre><code>provenance_required:\n session_id: false # allow entries without --session-id\n branch: true # still require --branch\n commit: true # still require --commit\n</code></pre> <p>Default is all three required. Only human config relaxes: Agents cannot bypass, and that's by design.</p> </li> </ul>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#next-up","level":2,"title":"Next Up","text":"<p>Tracking Work Across Sessions →: Add, prioritize, complete, and archive tasks across sessions.</p>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#see-also","level":2,"title":"See Also","text":"<ul> <li>Tracking Work Across Sessions: managing the tasks that decisions and learnings support</li> <li>The Complete Session: full session lifecycle including reflection and context persistence</li> <li>Detecting and Fixing Drift: keeping knowledge files accurate as the codebase evolves</li> <li>CLI Reference: full documentation for <code>ctx add</code>, <code>ctx decision</code>, <code>ctx learning</code></li> <li>Context Files: format and conventions for <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, and <code>CONVENTIONS.md</code></li> </ul>","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":"<p>Claude Code maintains per-project auto memory at <code>~/.claude/projects/<slug>/memory/MEMORY.md</code>. This file is:</p> <ul> <li>Outside the repo - not version-controlled, not portable</li> <li>Machine-specific - tied to one <code>~/.claude/</code> directory</li> <li>Invisible to <code>ctx</code> - context loading and hooks don't read it</li> </ul> <p>Meanwhile, <code>ctx</code> 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.</p> <p>The two systems hold complementary knowledge with no bridge between them.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>The <code>check-memory-drift</code> hook nudges automatically when MEMORY.md changes - you don't need to remember to sync manually.</p>","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 <code>ctx memory sync</code> CLI command Copy MEMORY.md to mirror, archive previous <code>ctx memory status</code> CLI command Show drift, timestamps, line counts <code>ctx memory diff</code> CLI command Show changes since last sync <code>ctx memory import</code> CLI command Classify and promote entries to .context/ files <code>ctx memory publish</code> CLI command Push curated .context/ content to MEMORY.md <code>ctx memory unpublish</code> CLI command Remove published block from MEMORY.md <code>ctx system check-memory-drift</code> 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":"<p>Claude Code encodes project paths as directory names under <code>~/.claude/projects/</code>. The encoding replaces <code>/</code> with <code>-</code> and prefixes with <code>-</code>:</p> <pre><code>/home/jose/WORKSPACE/ctx → ~/.claude/projects/-home-jose-WORKSPACE-ctx/\n</code></pre> <p><code>ctx memory</code> uses this encoding to locate MEMORY.md automatically from your project root - no configuration needed.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#mirroring","level":3,"title":"Mirroring","text":"<p>When you run <code>ctx memory sync</code>:</p> <ol> <li>The previous mirror is archived to <code>.context/memory/archive/mirror-<timestamp>.md</code></li> <li>MEMORY.md is copied to <code>.context/memory/mirror.md</code></li> <li>Sync state is updated in <code>.context/state/memory-import.json</code></li> </ol> <p>The mirror is git-tracked, so it travels with the project. Archives provide a fallback for projects that don't use git.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#drift-detection","level":3,"title":"Drift Detection","text":"<p>The <code>check-memory-drift</code> hook compares MEMORY.md's modification time against the mirror. When drift is detected, the agent sees:</p> <pre><code>┌─ Memory Drift ────────────────────────────────────────────────\n│ MEMORY.md has changed since last sync.\n│ Run: ctx memory sync\n│ Context: .context\n└────────────────────────────────────────────────────────────────\n</code></pre> <p>The nudge fires once per session to avoid noise.</p>","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":"<p>If the hook fires a drift nudge, sync before diving into work:</p> <pre><code>ctx memory diff # Review what changed\nctx memory sync # Mirror the changes\n</code></pre>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#periodic-check","level":3,"title":"Periodic Check","text":"<pre><code>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</code></pre>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#dry-run","level":3,"title":"Dry Run","text":"<p>Preview what sync would do without writing:</p> <pre><code>ctx memory sync --dry-run\n</code></pre>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#storage-layout","level":2,"title":"Storage Layout","text":"<pre><code>.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</code></pre>","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 <code>sync</code> exits 1 with message. <code>status</code> 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 <code>ctx</code> commands).","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#importing-entries","level":2,"title":"Importing Entries","text":"<p>Once you've synced, you can classify and promote entries into structured <code>.context/</code> files:</p> <pre><code>ctx memory import --dry-run # Preview classification\nctx memory import # Actually promote entries\n</code></pre> <p>Each entry is classified by keyword heuristics:</p> Keywords Target <code>always use</code>, <code>prefer</code>, <code>never use</code>, <code>standard</code> CONVENTIONS.md <code>decided</code>, <code>chose</code>, <code>trade-off</code>, <code>approach</code> DECISIONS.md <code>gotcha</code>, <code>learned</code>, <code>watch out</code>, <code>bug</code>, <code>caveat</code> LEARNINGS.md <code>todo</code>, <code>need to</code>, <code>follow up</code> TASKS.md Everything else Skipped <p>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.</p> <p>Review Before Importing</p> <p>Use <code>--dry-run</code> first. The heuristic classifier is deliberately simple - it may misclassify ambiguous entries. Review the plan, then import.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#full-workflow","level":3,"title":"Full Workflow","text":"<pre><code>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</code></pre>","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 <code>MEMORY.md</code>","text":"<p>Push curated <code>.context/</code> content back into MEMORY.md so Claude Code sees structured project context on session start - without needing hooks.</p> <pre><code>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</code></pre> <p>Published content is wrapped in markers:</p> <pre><code><!-- ctx:published -->\n# Project Context (managed by ctx)\n\n## Pending Tasks\n- [ ] Implement feature X\n...\n<!-- ctx:end -->\n</code></pre> <p>Rules:</p> <ul> <li><code>ctx</code> owns everything between the markers</li> <li>Claude owns everything outside the markers</li> <li><code>ctx memory import</code> reads only outside the markers</li> <li><code>ctx memory publish</code> replaces only inside the markers</li> </ul> <p>To remove the published block entirely:</p> <pre><code>ctx memory unpublish\n</code></pre> <p>Publish at Wrap-Up, Not on Commit</p> <p>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.</p>","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":"<pre><code>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</code></pre>","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":"<p>You have installed <code>ctx</code> 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: </p> <ul> <li>Claude Code supports native hooks that load and save context automatically.</li> <li>Cursor injects context via its system prompt.</li> <li>Aider reads context files through its <code>--read</code> flag.</li> </ul> <p>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.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tldr","level":2,"title":"TL;DR","text":"<pre><code>cd your-project\nctx init # creates .context/\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# ## OpenCode ##\nctx setup opencode --write && ctx init\n\n# ## Cursor / Aider / Copilot / Windsurf ##\nctx setup cursor # or: aider, copilot, windsurf\n\n# ## Companion tools (highly recommended) ##\ngitnexus analyze # code knowledge graph\n# Add Gemini Search MCP server for grounded web search\n</code></pre> <p>Run subsequent <code>ctx</code> commands from the project root; <code>ctx</code> always reads <code>$PWD/.context/</code>.</p> <p>Create a <code>.ctxrc</code> in your project root to configure token budgets, context directory, drift thresholds, and more.</p> <p>Then start your AI tool and ask: \"Do you remember?\"</p>","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 <code>ctx init</code> Create <code>.context/</code> directory, templates, and permissions <code>ctx setup</code> Generate integration configuration for a specific AI tool <code>ctx agent</code> Print a token-budgeted context packet for AI consumption <code>ctx load</code> Output assembled context in read order (for manual pasting) <code>ctx watch</code> Auto-apply context updates from AI output (non-native tools) <code>ctx completion</code> Generate shell autocompletion for bash, zsh, or fish <code>ctx journal import</code> 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 <code>ctx</code>","text":"<p>Run <code>ctx init</code> in your project root. This creates the <code>.context/</code> directory with all template files and seeds <code>ctx</code> permissions in <code>settings.local.json</code>.</p> <pre><code>cd your-project\nctx init\n</code></pre> <p>This produces the following structure:</p> <pre><code>.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</code></pre> <p>One <code>.context/</code> per project</p> <p><code>ctx</code> reads <code>$PWD/.context/</code>; the directory always lives alongside <code>.git/</code> at the project root. Sharing one directory across multiple projects corrupts journals, state, and secrets. For cross-project knowledge sharing (CONSTITUTION, CONVENTIONS, ARCHITECTURE, etc.) use <code>ctx hub</code>.</p> <p>For Claude Code, install the <code>ctx</code> plugin to get hooks and skills:</p> <pre><code>claude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n</code></pre> <p>If you only need the core files (useful for lightweight setups), use the <code>--minimal</code> flag:</p> <pre><code>ctx init --minimal\n</code></pre> <p>This creates only <code>TASKS.md</code>, <code>DECISIONS.md</code>, and <code>CONSTITUTION.md</code>.</p>","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":"<p>If you are using a tool other than Claude Code (which is configured automatically by <code>ctx init</code>), generate its integration configuration:</p> <pre><code># 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</code></pre> <p>Each command prints the configuration you need. How you apply it depends on the tool.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#claude-code","level":4,"title":"Claude Code","text":"<p>No action needed. Just install <code>ctx</code> from the Marketplace as <code>ActiveMemory/ctx</code>.</p> <p>Claude Code Is a First-Class Citizen</p> <p>With the <code>ctx</code> plugin installed, Claude Code gets hooks and skills automatically. The <code>PreToolUse</code> hook runs <code>ctx agent --budget 4000</code> on every tool call (with a 10-minute cooldown so it only fires once per window).</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#opencode","level":4,"title":"OpenCode","text":"<p>Run the one-liner from the project root:</p> <pre><code>ctx setup opencode --write && ctx init\n</code></pre> <p>This deploys a lifecycle plugin, slash command skills, <code>AGENTS.md</code>, and registers the <code>ctx</code> MCP server globally. See <code>ctx</code> for OpenCode for full details.</p> <p>OpenCode Is a First-Class Citizen</p> <p>With the plugin installed, OpenCode gets lifecycle hooks and skills automatically. Context loads at session start, survives compaction, and persists at session end, with no manual steps needed.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#vs-code","level":4,"title":"VS Code","text":"<p>Install the <code>ctx</code> extension from the VS Code Marketplace (publisher: <code>activememory</code>). Then, from your project root:</p> <pre><code>ctx init\n</code></pre> <p>Open Copilot Chat and type <code>@ctx /init</code> to verify. The extension auto-downloads the <code>ctx</code> CLI if it isn't on PATH. See <code>ctx</code> for VS Code for full details.</p> <p>VS Code Is a First-Class Citizen</p> <p>The extension carries its own runtime. No <code>ctx setup</code> step is needed. It registers a <code>@ctx</code> chat participant with 45 slash commands, automatic hooks (file save, git commit, <code>.context/</code> change, dependency-file edit), and a reminder status-bar indicator. Unlike embedded harnesses, the extension ships through its own pipeline to the VS Code Marketplace.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#cursor","level":4,"title":"Cursor","text":"<p>Add the system prompt snippet to <code>.cursor/settings.json</code>:</p> <pre><code>{\n \"ai.systemPrompt\": \"Read .context/TASKS.md and .context/CONVENTIONS.md before responding. Follow rules in .context/CONSTITUTION.md.\"\n}\n</code></pre> <p>Context files appear in Cursor's file tree. You can also paste a context packet directly into chat:</p> <pre><code>ctx agent --budget 4000 | xclip # Linux\nctx agent --budget 4000 | pbcopy # macOS\n</code></pre>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#aider","level":4,"title":"Aider","text":"<p>Create <code>.aider.conf.yml</code> so context files are loaded on every session:</p> <pre><code>read:\n - .context/CONSTITUTION.md\n - .context/TASKS.md\n - .context/CONVENTIONS.md\n - .context/DECISIONS.md\n</code></pre> <p>Then start Aider normally:</p> <pre><code>aider\n</code></pre> <p>Or specify files on the command line:</p> <pre><code>aider --read .context/TASKS.md --read .context/CONVENTIONS.md\n</code></pre>","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":"<p>Shell completion lets you tab-complete <code>ctx</code> subcommands and flags, which is especially useful while learning the CLI.</p> <pre><code># 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</code></pre> <p>After sourcing, typing <code>ctx a<TAB></code> completes to <code>ctx agent</code>, and <code>ctx journal <TAB></code> shows <code>list</code>, <code>show</code>, and <code>export</code>.</p>","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":"<p>Start a fresh session in your AI tool and ask:</p> <p>\"Do you remember?\"</p> <p>A correctly configured tool responds with specific context: current tasks from <code>TASKS.md</code>, recent decisions, and previous session topics. It should not say \"I don't have memory\" or \"Let me search for files.\"</p> <p>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:</p> <ul> <li>After a debugging session, it offers to save a learning.</li> <li>After a trade-off discussion, it asks whether to record the decision.</li> <li>After completing a task, it suggests follow-up items.</li> </ul> <p>The \"do you remember?\" check verifies both halves: recall and responsibility.</p> <p>For example, after resolving a tricky bug, a proactive agent might say:</p> <pre><code>That Redis timeout issue was subtle. Want me to save this as a *learning*\nso we don't hit it again?\n</code></pre> <p>If you see behavior like this, the setup is working end to end.</p> <p>In Claude Code, you can also invoke the <code>/ctx-status</code> skill:</p> <pre><code>/ctx-status\n</code></pre> <p>This prints a summary of all context files, token counts, and recent activity, confirming that hooks are loading context.</p> <p>If context is not loading, check the basics:</p> Symptom Fix <code>ctx: command not found</code> Ensure <code>ctx</code> is in your PATH: <code>which ctx</code> Hook errors Verify plugin is installed: <code>claude /plugin list</code> Context not refreshing Cooldown may be active; wait 10 minutes or set <code>--cooldown 0</code>","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":"<p>Tools like Aider, Copilot, and Windsurf do not support native hooks for saving context automatically. For these, run <code>ctx watch</code> alongside your AI tool.</p> <p>Pipe the AI tool's output through <code>ctx watch</code>:</p> <pre><code># 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</code></pre> <p>Or for any generic tool:</p> <pre><code>your-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n</code></pre> <p>When the AI emits structured update commands, <code>ctx watch</code> parses and applies them automatically:</p> <pre><code><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</code></pre> <p>To preview changes without modifying files:</p> <pre><code>ctx watch --dry-run --log /tmp/ai.log\n</code></pre>","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":"<p>If you want to browse past session transcripts, import them to the journal:</p> <pre><code>ctx journal import --all\n</code></pre> <p>This converts raw session data into editable Markdown files in <code>.context/journal/</code>. You can then enrich them with metadata using <code>/ctx-journal-enrich-all</code> inside your AI assistant.</p>","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":"<p>Here is the condensed setup for all three tools:</p> <pre><code># ## 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# ## OpenCode ##\nctx setup opencode --write\n# Start OpenCode, 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</code></pre>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>ctx init</code> (not <code>--minimal</code>) for your first project. The full template set gives the agent more to work with, and you can always delete files later.</li> <li>For Claude Code, the token budget is configured in the plugin's <code>hooks.json</code>. To customize, adjust the <code>--budget</code> flag in the <code>ctx agent</code> hook command.</li> <li>The <code>--session $PPID</code> flag isolates cooldowns per Claude Code process, so parallel sessions do not suppress each other.</li> <li>Commit your <code>.context/</code> directory to version control. Several <code>ctx</code> features (journals, changelogs, blog generation) rely on git history.</li> <li>For Cursor and Copilot, keep <code>CONVENTIONS.md</code> visible. These tools treat open files as higher-priority context.</li> <li>Run <code>ctx drift</code> periodically to catch stale references before they confuse the agent.</li> <li>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.</li> </ul>","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":"<p><code>ctx</code> skills can leverage external MCP servers for web search and code intelligence. <code>ctx</code> works without them, but they significantly improve agent behavior across sessions. The investment is small and the benefits compound. Skills like <code>/ctx-code-review</code>, <code>/ctx-explain</code>, and <code>/ctx-refactor</code> all become noticeably better with these tools connected.</p> <p>The two sections below name canonical implementations that ctx has tested against — Gemini Search for web-search-with-citations and GitNexus for the code knowledge graph. If your toolchain provides equivalent capabilities through different MCP servers (Firecrawl, Exa, Tavily for web search; sourcegraph-cody for code graph), use those instead. ctx skills describe capabilities, not specific tools — the agent self-routes based on what's connected.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gemini-search","level":3,"title":"Gemini Search","text":"<p>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).</p> <p>Setup: Add the Gemini Search MCP server to your Claude Code settings. See the Gemini Search MCP documentation for installation.</p> <p>Verification: <pre><code># The agent checks this automatically during /ctx-remember\n# Manual test: ask the agent to search for something\n</code></pre></p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gitnexus","level":3,"title":"GitNexus","text":"<p>Provides a code knowledge graph with symbol resolution, blast radius analysis, and domain clustering. Used by skills like <code>/ctx-refactor</code> (impact analysis) and <code>/ctx-code-review</code> (dependency awareness).</p> <p>Setup: Add the GitNexus MCP server to your Claude Code settings, then index your project:</p> <pre><code>gitnexus analyze\n</code></pre> <p>Verification: <pre><code># The agent checks this automatically during /ctx-remember\n# If the index is stale, it will suggest rehydrating\n</code></pre></p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#suppressing-the-check","level":3,"title":"Suppressing the Check","text":"<p>If you don't use companion tools and want to skip the availability check at session start, add to <code>.ctxrc</code>:</p> <pre><code>companion_check: false\n</code></pre>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#future-direction","level":3,"title":"Future Direction","text":"<p>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.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: full session lifecycle recipe</li> <li>Multilingual Session Parsing: configure session header prefixes for other languages</li> <li>CLI Reference: all commands and flags</li> <li>Integrations: detailed per-tool integration docs</li> </ul>","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":"<p>Your team works across languages. Session files written by AI tools might use headers like <code># Oturum: 2026-01-15 - API Düzeltme</code> (Turkish) or <code># セッション: 2026-01-15 - テスト</code> (Japanese) instead of <code># Session: 2026-01-15 - Fix API</code>.</p> <p>By default, <code>ctx</code> only recognizes <code>Session:</code> 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.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#tldr","level":2,"title":"TL;DR","text":"<p>Add recognized prefixes to <code>.ctxrc</code>:</p> <pre><code>session_prefixes:\n - \"Session:\" # English (include to keep default)\n - \"Oturum:\" # Turkish\n - \"セッション:\" # Japanese\n</code></pre> <p>Restart your session. All configured prefixes are now recognized.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#how-it-works","level":2,"title":"How It Works","text":"<p>The Markdown session parser detects session files by looking for an H1 header that starts with a known prefix followed by a date:</p> <pre><code># Session: 2026-01-15 - Fix API Rate Limiting\n# Oturum: 2026-01-15 - API Düzeltme\n# セッション: 2026-01-15 - テスト\n</code></pre> <p>The list of recognized prefixes comes from <code>session_prefixes</code> in <code>.ctxrc</code>. When the key is absent or empty, <code>ctx</code> falls back to the built-in default: <code>[\"Session:\"]</code>.</p> <p>Date-only headers (<code># 2026-01-15 - Morning Work</code>) are always recognized regardless of prefix configuration.</p>","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":"<p>Add the prefix with a trailing colon to your <code>.ctxrc</code>:</p> <pre><code>session_prefixes:\n - \"Session:\"\n - \"Sesión:\" # Spanish\n</code></pre> <p>Include Session: Explicitly</p> <p>When you override <code>session_prefixes</code>, the default is replaced, not extended. If you still want English headers recognized, include <code>\"Session:\"</code> in your list.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#team-setup","level":3,"title":"Team Setup","text":"<p>Commit <code>.ctxrc</code> to the repo so all team members share the same prefix list. This ensures <code>ctx journal import</code> and journal generation pick up sessions from all team members regardless of language.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#common-prefixes","level":3,"title":"Common Prefixes","text":"Language Prefix English <code>Session:</code> Turkish <code>Oturum:</code> Spanish <code>Sesión:</code> French <code>Session:</code> German <code>Sitzung:</code> Japanese <code>セッション:</code> Korean <code>세션:</code> Portuguese <code>Sessão:</code> Chinese <code>会话:</code>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#verifying","level":3,"title":"Verifying","text":"<p>After configuring, test with <code>ctx journal source</code>. Sessions with the new prefixes should appear in the output.</p>","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":"<ul> <li>Change the interface language: <code>ctx</code> output is always English. This setting only controls which session files <code>ctx</code> can parse.</li> <li>Generate headers: <code>ctx</code> never writes session headers. The prefix list is recognition-only (input, not output).</li> <li>Affect JSONL sessions: Claude Code JSONL transcripts don't use header prefixes. This only applies to Markdown session files in <code>.context/sessions/</code>.</li> </ul>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#see-also","level":2,"title":"See Also","text":"<p>See also: Setup Across AI Tools - complete multi-tool setup including Markdown session configuration.</p> <p>See also: CLI Reference - full <code>.ctxrc</code> field reference including <code>session_prefixes</code>.</p>","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":"<p>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.</p> <p>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.</p> <p>Git worktrees solve this. </p> <p>Each worktree is a separate working directory with its own branch, but they share the same <code>.git</code> object database. Combined with <code>ctx</code>'s persistent context, each agent session picks up the full project state and works independently.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/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</code></pre> <p><code>TASKS.md</code> will conflict on merge: Accept all <code>[x]</code> completions from both sides.</p>","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 <code>/ctx-worktree</code> Skill Create, list, and tear down worktrees <code>/ctx-next</code> Skill Pick tasks from the backlog for each track <code>git worktree</code> Command Underlying git worktree management <code>git merge</code> 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":"<p>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.</p> <pre><code>/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</code></pre> <p>The agent reads <code>TASKS.md</code>, estimates file overlap, and proposes groups:</p> <pre><code>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</code></pre>","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":"<p>Once you approve the grouping, the agent creates worktrees as sibling directories:</p> <pre><code>Create the worktrees for those three groups.\n</code></pre> <p>Behind the scenes:</p> <pre><code>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</code></pre> <p>Each worktree is a full working copy on its own branch.</p>","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":"<p>Open a separate terminal (or editor window) for each worktree and start a Claude Code session:</p> <pre><code># Terminal 1\ncd ../myproject-docs\nclaude\n\n# Terminal 2\ncd ../myproject-crypto\nclaude\n\n# Terminal 3\ncd ../myproject-tests\nclaude\n</code></pre> <p>Each agent sees the full project, including <code>.context/</code>, and can work independently. </p> <p>Do Not Initialize Context in Worktrees</p> <p>Do not run <code>ctx init</code> in worktrees: The <code>.context</code> directory is already tracked in <code>git</code>.</p>","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":"<p>Each agent works through its assigned tasks. They can read <code>TASKS.md</code> to know what's assigned to their track, use <code>/ctx-next</code> to pick the next item, and commit normally on their <code>work/*</code> branch.</p>","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":"<p>As each track finishes, return to the main checkout and merge:</p> <pre><code>/ctx-worktree teardown docs\n</code></pre> <p>The agent checks for uncommitted changes, merges <code>work/docs</code> into your current branch, removes the worktree, and deletes the branch.</p>","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 <code>TASKS.md</code> Conflicts","text":"<p><code>TASKS.md</code> will almost always conflict when merging: Multiple agents will mark different tasks as <code>[x]</code>. This is expected and easy to resolve:</p> <p>Accept all completions from both sides. No task should go from <code>[x]</code> back to <code>[ ]</code>. The merge resolution is always additive.</p>","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":"<p>After all tracks are merged, verify everything is clean:</p> <pre><code>/ctx-worktree list\n</code></pre> <p>Should show only the main working tree. All <code>work/*</code> branches should be gone.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't have to use the skill directly for every step. These natural prompts work:</p> <ul> <li>\"I have a big backlog. Can we split it across worktrees?\"</li> <li>\"Which of these tasks can run in parallel without conflicts?\"</li> <li>\"Merge the docs track back in.\"</li> <li>\"Clean up all the worktrees, we're done.\"</li> </ul>","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":"<p>The encryption key lives at <code>~/.ctx/.ctx.key</code> (user-level, outside the project). All worktrees on the same machine share this one key — there is no per-project key (an implicit <code>.context/.ctx.key</code> is never auto-detected), so <code>ctx pad</code> and <code>ctx hook notify</code> decrypt correctly in worktrees automatically, with no special setup.</p> <p>Whether <code>ctx hook notify</code> actually fires in a worktree is your call, made through one decision: do you git-track <code>.ctxrc</code>?</p> <ul> <li>Tracked <code>.ctxrc</code> (committed) → its <code>notify.events</code> list rides into every checkout, so notifications fire from worktrees too. Committing <code>.ctxrc</code> is safe: it holds <code>notify.events</code>, <code>key_path</code>, and rotation settings — never the webhook secret, which stays encrypted in <code>.context/.notify.enc</code>.</li> <li>Gitignored <code>.ctxrc</code> (e.g. the profile workflow with tracked <code>.ctxrc.base</code> / <code>.ctxrc.dev</code>) → a fresh worktree has no active <code>.ctxrc</code>, so ctx applies built-in defaults and notifications stay off there. <code>.ctxrc.base</code> is a template, not a fallback: ctx reads only the active <code>.ctxrc</code>. To enable notifications in such a worktree, copy a <code>.ctxrc</code> into it (or run <code>ctx config switch</code>).</li> </ul> <p>ctx deliberately does not special-case worktrees — it cannot tell a worktree from several terminals open in the same project — so the <code>.ctxrc</code>-tracking choice is the single, explicit control.</p> <p>If a configured webhook ever can't be delivered (a wrong or missing key, a decrypt failure, a network error), <code>ctx hook notify</code> prints a <code>ctx: notify: webhook configured but undeliverable: …</code> warning to stderr instead of silently dropping the notification.</p> <p>One thing to watch:</p> <ul> <li>Journal enrichment: <code>ctx journal import</code> and <code>ctx journal enrich</code> 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.</li> </ul> <p>Context Files Will Merge Just Fine</p> <p>Tracked context files (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>) work normally; <code>git</code> handles them.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tips","level":2,"title":"Tips","text":"<ul> <li>3-4 worktrees max. Beyond that, merge complexity outweighs the parallelism benefit. The skill enforces this limit.</li> <li>Group by package or directory, not by priority. Two high-priority tasks that touch the same files must be in the same track.</li> <li><code>TASKS.md</code> will conflict on merge. This is normal. Accept all <code>[x]</code> completions: The resolution is always additive.</li> <li>Don't run <code>ctx init</code> in worktrees. The <code>.context/</code> directory is tracked in git. Running init overwrites shared context files.</li> <li>Name worktrees by concern, not by number. <code>work/docs</code> and <code>work/crypto</code> are more useful than <code>work/track-1</code> and <code>work/track-2</code>.</li> <li>Commit frequently in each worktree. Smaller commits make merge conflicts easier to resolve.</li> </ul>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#next-up","level":2,"title":"Next Up","text":"<p>Back to the beginning: Guide Your Agent →</p> <p>Or explore the full recipe list.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#see-also","level":2,"title":"See Also","text":"<ul> <li>Running an Unattended AI Agent: for serial autonomous loops instead of parallel tracks</li> <li>Tracking Work Across Sessions: managing the task backlog that feeds into parallelization</li> <li>The Complete Session: the complete session workflow end-to-end, with examples</li> </ul>","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":"<p>Claude Code's <code>.claude/settings.local.json</code> 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.</p> <p>Since <code>settings.local.json</code> is <code>.gitignore</code>d, 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.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/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</code></pre>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#the-solution","level":2,"title":"The Solution","text":"<p>Save a curated <code>settings.local.json</code> as a golden image, then restore from it to drop session-accumulated permissions. The golden file (<code>.claude/settings.golden.json</code>) is committed to version control and shared with the team.</p>","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 <code>ctx permission snapshot</code> Save settings.local.json as golden image <code>ctx permission restore</code> Reset settings.local.json from golden image <code>/ctx-permission-sanitize</code> 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":"<p>Start with a clean <code>settings.local.json</code>. Optionally run <code>/ctx-permission-sanitize</code> to remove dangerous patterns first.</p> <p>Review the file manually. Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.</p> <p>See the Permission Hygiene recipe for recommended defaults.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#2-take-a-snapshot","level":3,"title":"2. Take a Snapshot","text":"<pre><code>ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n</code></pre> <p>This creates a byte-for-byte copy. No re-encoding, no indent changes.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#3-commit-the-golden-file","level":3,"title":"3. Commit the Golden File","text":"<pre><code>git add .claude/settings.golden.json\ngit commit -m \"Add permission golden image\"\n</code></pre> <p>The golden file is not gitignored (unlike <code>settings.local.json</code>). This is intentional: it becomes a team-shared baseline.</p>","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":"<p>Add this instruction to your <code>CLAUDE.md</code>:</p> <pre><code>## On Session Start\n\nRun `ctx permission restore` to reset permissions to the golden image.\n</code></pre> <p>The agent will restore the golden image at the start of every session, automatically dropping any permissions accumulated during previous sessions.</p>","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":"<p>When you add a new permanent permission (not a one-off debugging entry):</p> <pre><code># 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</code></pre>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't need to remember exact commands. These natural-language prompts work with agents trained on the <code>ctx</code> playbook:</p> What you say What happens \"Save my current permissions as baseline\" Agent runs <code>ctx permission snapshot</code> \"Reset permissions to the golden image\" Agent runs <code>ctx permission restore</code> \"Clean up my permissions\" Agent runs <code>/ctx-permission-sanitize</code> 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":"<p>Turning Activity into Content →: Generate blog posts, changelogs, and journal sites from your project activity.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#see-also","level":2,"title":"See Also","text":"<ul> <li>Permission Hygiene: recommended defaults and maintenance workflow</li> <li>CLI Reference: <code>ctx</code> permission: full command documentation</li> </ul>","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":"<p>Your <code>.context/</code> directory is full of decisions, learnings, and session history.</p> <p>Your <code>git log</code> tells the story of a project evolving.</p> <p>But none of this is visible to anyone outside your terminal.</p> <p>You want to turn this raw activity into:</p> <ul> <li>a browsable journal site,</li> <li>blog posts,</li> <li>changelog posts.</li> </ul>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Read on for details on each stage.</p>","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 <code>ctx journal import</code> Command Import session JSONL to editable Markdown <code>ctx journal site</code> Command Generate a static site from journal entries <code>ctx journal obsidian</code> Command Generate an Obsidian vault from journal entries <code>ctx serve</code> Command Serve any zensical directory (default: journal) <code>ctx site feed</code> Command Generate Atom feed from finalized blog posts <code>make journal</code> Makefile Shortcut for import + site rebuild <code>/ctx-journal-enrich-all</code> Skill Full pipeline: import if needed, then batch-enrich (recommended) <code>/ctx-journal-enrich</code> Skill Add metadata, summaries, and tags to one entry <code>/ctx-blog</code> Skill Draft a blog post from recent project activity <code>/ctx-blog-changelog</code> 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":"<p>Raw session data lives as JSONL files in Claude Code's internal storage. The first step is converting these into readable, editable Markdown.</p> <pre><code># 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</code></pre> <p>Imported files land in <code>.context/journal/</code> as individual Markdown files with session metadata and the full conversation transcript.</p> <p><code>--all</code> is self-healing: it imports new sessions and completes any whose transcript has grown since the last import, skipping unchanged ones and never clobbering an entry you have hand-edited. You do not need <code>--regenerate</code> for routine re-imports; it is an edge-case tool for forcing a full re-render (after a format change, or to heal a pre-self-heal truncated entry). Add <code>--keep-frontmatter=false -y</code> to discard enriched frontmatter during that re-render.</p>","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":"<p>Raw entries have timestamps and conversations but lack the structured metadata that makes a journal searchable. Use <code>/ctx-journal-enrich-all</code> to process your entire backlog at once:</p> <pre><code>/ctx-journal-enrich-all\n</code></pre> <p>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.</p> <p>For large backlogs (20+ entries), it can spawn subagents to process entries in parallel.</p> <p>To enrich a single entry instead:</p> <pre><code>/ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich 2026-01-24\n</code></pre> <p>After enrichment, an entry gains YAML frontmatter:</p> <pre><code>---\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</code></pre> <p>This metadata powers better navigation in the journal site: </p> <ul> <li>titles replace slugs, </li> <li>summaries appear in the index, </li> <li>and search covers topics and technologies.</li> </ul>","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":"<p>With entries exported and enriched, generate the static site:</p> <pre><code># 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</code></pre> <p>The site is generated in <code>.context/journal-site/</code> by default. It uses zensical for static site generation (<code>pipx install zensical</code>).</p> <p>Or use the Makefile shortcut that combines export and rebuild:</p> <pre><code>make journal\n</code></pre> <p>This runs <code>ctx journal import --all</code> followed by <code>ctx journal site --build</code>, then reminds you to enrich before rebuilding. To serve the built site, use <code>make journal-serve</code> or <code>ctx serve</code> (serve-only, no regeneration).</p>","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":"<p>If you use Obsidian for knowledge management, generate a vault instead of (or alongside) the static site:</p> <pre><code>ctx journal obsidian\nctx journal obsidian --output ~/vaults/ctx-journal\n</code></pre> <p>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.</p> <p>The vault uses the same enriched source entries as the static site. Both outputs can coexist: The static site goes to <code>.context/journal-site/</code>, the vault to <code>.context/journal-obsidian/</code>.</p>","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":"<p>When your project reaches a milestone worth sharing, use <code>/ctx-blog</code> to draft a post from recent activity. The skill gathers context from multiple sources: <code>git log</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, completed tasks, and journal entries.</p> <pre><code>/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</code></pre> <p>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 <code>docs/blog/YYYY-MM-DD-slug.md</code>.</p> <p>Posts are written in first person with code snippets, commit references, and an honest discussion of what went wrong.</p> <p>The Output Is <code>zensical</code>-Flavored Markdown</p> <p>The blog skills produce Markdown tuned for a zensical site: <code>topics:</code> frontmatter (zensical's tag field), a <code>docs/blog/</code> output path, and a banner image reference. </p> <p>The content is still standard Markdown and can be adapted to other static site generators, but the defaults assume a <code>zensical</code> project structure.</p>","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":"<p>For release notes or \"what changed\" posts, <code>/ctx-blog-changelog</code> takes a starting commit and a theme, then analyzes everything that changed:</p> <pre><code>/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</code></pre> <p>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.</p>","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":"<p>After publishing blog posts, generate the Atom feed so readers and automation can discover new content:</p> <pre><code>ctx site feed\n</code></pre> <p>This scans <code>docs/blog/</code> for finalized posts (<code>reviewed_and_finalized: true</code>), extracts title, date, author, topics, and summary, and writes a valid Atom 1.0 feed to <code>site/feed.xml</code>. The feed is also generated automatically as part of <code>make site</code>.</p> <p>The feed is available at ctx.ist/feed.xml.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-conversational-approach","level":2,"title":"The Conversational Approach","text":"<p>You can also drive your publishing anytime with natural language:</p> <pre><code>\"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</code></pre> <p>The agent has full visibility into your <code>.context/</code> state (tasks completed, decisions recorded, learnings captured), so its suggestions are grounded in what actually happened.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>The full pipeline from raw transcripts to published content:</p> <pre><code># 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</code></pre> <p>The journal pipeline is idempotent at every stage. You can rerun <code>ctx journal import --all</code> without losing enrichment. You can rebuild the site as many times as you want.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tips","level":2,"title":"Tips","text":"<ul> <li>Import regularly. Run <code>ctx journal import --all</code> after each session to keep your journal current. It is self-healing: new sessions are imported and any whose transcript has grown are completed, while unchanged sources are skipped.</li> <li>Use batch enrichment. <code>/ctx-journal-enrich-all</code> filters noise (suggestion sessions, trivial sessions, multipart continuations) so you do not have to decide what is worth enriching.</li> <li>Keep journal files in <code>.gitignore</code>. Session journals can contain sensitive data: file contents, commands, internal discussions, and error messages with stack traces. Add <code>.context/journal/</code> and <code>.context/journal-site/</code> to <code>.gitignore</code>.</li> <li>Use <code>/ctx-blog</code> for narrative posts and <code>/ctx-blog-changelog</code> for release posts. One finds a story in recent activity, the other explains a commit range by theme.</li> <li>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.</li> </ul>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#next-up","level":2,"title":"Next Up","text":"<p>Running an Unattended AI Agent →: Set up an AI agent that works through tasks overnight without you at the keyboard.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#see-also","level":2,"title":"See Also","text":"<ul> <li>Session Journal: journal system, enrichment schema</li> <li>CLI Reference: <code>ctx</code> journal: import, list, show session history</li> <li>CLI Reference: <code>ctx</code> journal site: static site generation</li> <li>CLI Reference: <code>ctx</code> journal obsidian: Obsidian vault export</li> <li>CLI Reference: <code>ctx</code> serve: serve-only (no regeneration)</li> <li>Browsing and Enriching Past Sessions: journal browsing workflow</li> <li>The Complete Session: capturing context during a session</li> </ul>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/recover-aborted-session/","level":1,"title":"Recover an Aborted KB Session","text":"","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#the-problem","level":2,"title":"The Problem","text":"<p>You ran one or more <code>/ctx-kb-ingest</code> passes, then the session ended before <code>/ctx-wrap-up</code>. Maybe you closed the laptop, the connection dropped, or you just forgot the wrap-up step.</p> <p>You come back the next day and ask \"do you remember?\" and the agent picks up the previous handover, but the editorial work since the last handover seems to be missing from the readback.</p> <p>It isn't missing. It's unfolded. Here's how the pipeline handles it and how to close the loop manually.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-remember # picks up the unfolded \n # closeouts automatically\n/ctx-handover \"recovery: fold the orphan closeouts\" # direct invocation is \n # appropriate for recovery\n</code></pre> <p>The recovery path is the one legitimate place to invoke <code>/ctx-handover</code> directly. Normally <code>/ctx-wrap-up</code> owns session-end and delegates to the handover step; the abort broke that path, so a hand-rolled handover invocation is how you close the loop without re-running the full wrap-up ceremony.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#how-the-fold-mechanism-survives-an-abort","level":2,"title":"How the Fold Mechanism Survives an Abort","text":"<p>Two artifacts make abort-recovery work without any cleanup:</p> <ol> <li> <p>Closeouts are immutable once written. Every editorial pass writes a closeout under <code>.context/ingest/closeouts/<TS>-<mode>-closeout.md</code> before the pass reports <code>done</code>. If the session dies, the closeout is already on disk.</p> </li> <li> <p><code>/ctx-remember</code> folds unfolded closeouts into the readback. The skill always reads the latest handover. When <code>.context/kb/</code> exists, it additionally reads any closeouts whose <code>generated-at</code> postdates the handover. The <code>## What changed</code> and <code>## Source-coverage updates</code> sections from each unfolded closeout are surfaced in recall.</p> </li> </ol> <p>So an aborted session never loses editorial work; it just delays the handover fold by one session.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#step-1-confirm-the-orphan-closeouts","level":2,"title":"Step 1: Confirm the Orphan Closeouts","text":"<pre><code>ls -la .context/ingest/closeouts/\n</code></pre> <p>Files there with <code>generated-at</code> postdating your latest handover are the unfolded ones. You can read any closeout directly to see what it claims about its pass:</p> <pre><code>cat .context/ingest/closeouts/<TS>-ingest-closeout.md\n</code></pre> <p>Look at:</p> <ul> <li>The Pass-mode body block (<code>Declared / Reason / Definition of done / Result</code>): what the pass committed to and whether it claimed success or <code>deferred</code>.</li> <li>The Source-coverage updates section: what state transitions hit the ledger.</li> <li>The Next pass hint: the exact resumption invocation the closeout recommends, if the pass deferred.</li> </ul>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#step-2-run-ctx-remember","level":2,"title":"Step 2: Run <code>/ctx-remember</code>","text":"<pre><code>/ctx-remember\n</code></pre> <p>The readback will include the editorial-state summary as part of the standard readback shape. If everything looks consistent, proceed to Step 3.</p> <p>If the readback surfaces something surprising (a closeout claiming <code>topic-page: produced</code> for a slug whose file is missing, a <code>comprehensive</code> ledger advance against a source whose page is <code>speculative</code>, etc.), fix the underlying inconsistency before folding. (Doctor advisories for these shapes are on the Phase-7 backlog.)</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#step-3-write-the-recovery-handover","level":2,"title":"Step 3: Write the Recovery Handover","text":"<p>This step is the one legitimate direct invocation of <code>/ctx-handover</code>. In normal session-end the call goes through <code>/ctx-wrap-up</code>; here the prior session aborted, so you reach for the handover step directly to retire the orphan closeouts:</p> <pre><code>/ctx-handover \"recovery: fold orphan closeouts from yesterday\"\n</code></pre> <p>Or via the CLI:</p> <pre><code>ctx handover write \"recovery: fold orphan closeouts from yesterday\" \\\n --summary \"Folded N orphan closeouts from the aborted session.\" \\\n --next \"Resume <topic> per the closeout's Next pass hint.\"\n</code></pre> <p>The handover:</p> <ul> <li>Reads the latest handover cursor.</li> <li>Finds all closeouts whose <code>generated-at</code> is after the cursor.</li> <li>Folds their summaries into a <code>## Folded closeouts</code> section.</li> <li>Archives the source closeout files under <code>.context/archive/closeouts/</code> (closeouts are append-never-rewrite; archival moves bytes but does not modify them).</li> </ul> <p>After the handover lands, the orphan closeouts are now durably tied to a session boundary; the next <code>/ctx-remember</code> reads just the new handover (and any closeouts postdating it), without re-folding the recovered ones.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#edge-cases","level":2,"title":"Edge Cases","text":"Case Behavior Closeout has malformed frontmatter Handover fold skips it with a warning to stderr. Hand-edit the malformed file (typically a missing <code>generated-at</code>) and re-run <code>ctx handover write</code> to fold it next time. Closeout's <code>generated-at</code> is before the last handover but was never folded Treated as already-folded (silently skipped; the cursor is the source of truth). If you genuinely want to re-fold it, hand-edit the closeout's <code>generated-at</code> forward. You aborted during an ingest pass, before its closeout was written No closeout exists; the pass left no recall residue. Treat the source(s) as un-ingested and re-run <code>/ctx-kb-ingest</code>. The source-coverage ledger row may show stale residue from a prior pass; the next ingest will advance it correctly. Multiple sessions piled up unfolded closeouts One handover run folds them all in a single shot. The fold is cursor-driven, not session-driven. You want recall without consuming closeouts <code>ctx handover write ... --no-fold</code> writes a handover with frontmatter but leaves the closeouts in place. The next handover (without <code>--no-fold</code>) folds everything postdating the latest handover cursor.","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#when-this-matters","level":2,"title":"When This Matters","text":"<ul> <li>After a network drop / laptop close mid-session.</li> <li>When you ran <code>/ctx-kb-ingest</code> from a sub-agent that finished without calling <code>/ctx-handover</code>.</li> <li>After porting work from another environment (e.g. you rsynced <code>.context/ingest/closeouts/</code> from a different machine) and want to integrate the work into the destination project's recall thread.</li> </ul>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Build a Knowledge Base</li> <li>Recipe: Typical KB Session</li> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code></li> </ul>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/run-the-dream/","level":1,"title":"Run the Dream","text":"<p>The dream is a scheduled, out-of-band pass that triages your gitignored <code>ideas/</code> folder — classifying each idea against your codebase and specs, and emitting gated proposals (archive / merge / promote / mark-blog / keep) for you to review. It only ever proposes; it never writes canonical memory and never acts on a proposal. You review the proposals in a ~15-minute \"garden walk\" and accept / reject / amend.</p> <p>The dream is opt-in and off by default. Nothing runs until you turn it on. This recipe wires it up for Claude Code (the reference executor). To run it under a different harness, see the executor contract.</p>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li>A ctx project (a git working tree with <code>.context/</code>).</li> <li>An <code>ideas/</code> folder at the project root (gitignored).</li> <li>The <code>ctx-dream</code> and <code>ctx-serendipity</code> skills installed (shipped with <code>ctx setup</code>).</li> <li>A non-interactive Claude Code credential (cron has no interactive fallback).</li> </ul>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#1-enable-it-in-ctxrc","level":2,"title":"1. Enable it in <code>.ctxrc</code>","text":"<p>Add a <code>dream:</code> section. <code>enabled: false</code> is the default — set it true:</p> <pre><code>dream:\n enabled: true\n mode: discipline # the only mode in v1\n max: 50 # max ideas processed per pass\n quiet_minutes: 60 # skip a pass if you were active within the window\n cadence: \"30 2 * * *\" # the cron schedule you'll install below\n budget: 40 # step/token ceiling per pass\n model: null # null = the session default model\n executor: \"\" # empty = the claude -p reference executor\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#2-confirm-dreams-is-gitignored","level":2,"title":"2. Confirm <code>dreams/</code> is gitignored","text":"<p>The dream writes its notebook (proposals, per-source state, ledger, backups) to a root-level <code>dreams/</code> directory. It inherits <code>ideas/</code>'s privacy class, so it must stay gitignored — <code>ctx init</code> adds the entry, and the don't-leak guard refuses any write that resolves to a tracked path. Verify:</p> <pre><code>git check-ignore dreams && echo \"ok: dreams/ is ignored\"\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#3-wire-the-guard-hook","level":2,"title":"3. Wire the guard hook","text":"<p>A headless pass runs with a PreToolUse guard so the agent can only write under <code>dreams/</code>. Point a dream-specific settings file at the bundled <code>guard.sh</code> (do not add it to your project's default settings — the dream is opt-in):</p> <pre><code>{\n \"hooks\": {\n \"PreToolUse\": [\n { \"matcher\": \"Write|Edit|MultiEdit\",\n \"hooks\": [{ \"type\": \"command\",\n \"command\": \"<skills>/ctx-dream/guard.sh\" }] },\n { \"matcher\": \"Bash\",\n \"hooks\": [{ \"type\": \"command\",\n \"command\": \"<skills>/ctx-dream/guard.sh\" }] }\n ]\n }\n}\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#4-install-the-cron-entry","level":2,"title":"4. Install the cron entry","text":"<p>Run one pass nightly. <code>ctx dream</code> does the gate (skips when there's no new idea delta or you were recently active), takes a lock, and invokes the executor:</p> <pre><code>30 2 * * * cd /path/to/project && PATH=/usr/local/bin:$PATH ctx dream >> ~/.ctx/dream.cron.log 2>&1\n</code></pre> <p>cron's PATH is minimal</p> <p>cron will not see a node/nvm-managed <code>claude</code> or even <code>ctx</code> unless you set <code>PATH</code> in the entry (as above). If the executor binary is not found, <code>ctx dream</code> fails loud and writes <code>dreams/.failed</code> — it never silently no-ops.</p>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#5-review-what-it-found","level":2,"title":"5. Review what it found","text":"<p>The dream nags you (via <code>ctx remind</code>) when a round is waiting. Walk the garden:</p> <pre><code>/ctx-serendipity\n</code></pre> <p>Each proposal shows its summary, evidence, and a one-line rationale. Accept / reject / amend / skip — no pressure to clear the set. Mechanical dispositions apply instantly; <code>merge</code>/<code>promote</code> are done from the full source. Rejections are recorded so they don't re-surface.</p> <p>You can also drive it directly:</p> <pre><code>ctx dream review\nctx dream accept <id>\nctx dream reject <id>\nctx dream amend <id> --action keep\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#what-it-will-never-do","level":2,"title":"What it will never do","text":"<ul> <li>Write the five canonical files (DECISIONS / LEARNINGS / CONVENTIONS / CONSTITUTION / TASKS). Ever.</li> <li>Act on a proposal without you. Every disposition into a tracked artifact passes through the human gate.</li> <li>Write anything outside <code>dreams/</code> during a pass (the guard enforces it), except your deliberate <code>promote</code> of an idea into <code>specs/</code>.</li> </ul>","path":["Recipes","Agents and Automation","Run the Dream"],"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":"<p>You work from multiple machines: a desktop and a laptop, or a local machine and a remote dev server.</p> <p>The scratchpad entries are encrypted. The ciphertext (<code>.context/scratchpad.enc</code>) travels with git, but the encryption key lives outside the project at <code>~/.ctx/.ctx.key</code> and is never committed. Without the key on each machine, you cannot read or write entries.</p> <p>How do you distribute the key and keep the scratchpad in sync?</p>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx init # 1. generates key\nscp ~/.ctx/.ctx.key user@machine-b:~/.ctx/.ctx.key # 2. copy key\nchmod 600 ~/.ctx/.ctx.key # 3. secure it\n# Normal git push/pull syncs the encrypted scratchpad.enc\n# On conflict: ctx pad resolve → rebuild → git add + commit\n</code></pre> <p>Finding Your Key File</p> <p>The key is always at <code>~/.ctx/.ctx.key</code> - one key, one machine.</p> <p>Treat the Key like a Password</p> <p>The scratchpad key is the only thing protecting your encrypted entries.</p> <p>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.</p> <p>Anyone with the key can decrypt every scratchpad entry.</p>","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 <code>ctx init</code> CLI command Initialize context (generates the key automatically) <code>ctx pad add</code> CLI command Add a scratchpad entry <code>ctx pad rm</code> CLI command Remove entries by stable ID (supports ranges) <code>ctx pad edit</code> CLI command Edit a scratchpad entry <code>ctx pad resolve</code> CLI command Show both sides of a merge conflict <code>ctx pad merge</code> CLI command Merge entries from other scratchpad files <code>ctx pad import</code> CLI command Bulk-import lines from a file <code>ctx pad export</code> CLI command Export blob entries to a directory <code>scp</code> Shell Copy the key file between machines <code>git push</code> / <code>git pull</code> Shell Sync the encrypted file via <code>git</code> <code>/ctx-pad</code> 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":"<p>Run <code>ctx init</code> on your first machine. The key is created automatically at <code>~/.ctx/.ctx.key</code>:</p> <pre><code>ctx init\n# ...\n# Created ~/.ctx/.ctx.key (0600)\n# Created .context/scratchpad.enc\n</code></pre> <p>The key lives outside the project directory and is never committed. The <code>.enc</code> file is tracked in git.</p> <p>Key Folder Change (v0.7.0+)</p> <p>If you built <code>ctx</code> from source or upgraded past v0.6.0, the key location changed to <code>~/.ctx/.ctx.key</code>. Check these legacy folders and copy your key manually:</p> <pre><code># 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</code></pre>","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":"<p>Use any secure transfer method. The key is always at <code>~/.ctx/.ctx.key</code>:</p> <pre><code># 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</code></pre> <p>Set permissions on Machine B:</p> <pre><code>chmod 600 ~/.ctx/.ctx.key\n</code></pre> <p>Secure the Transfer</p> <p>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). </p> <p>Never paste it in plaintext over email or chat.</p>","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":"<p>The encrypted file is committed, so standard git sync works:</p> <pre><code># 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</code></pre> <p>Both machines have the same key, so both can decrypt the same <code>.enc</code> file.</p>","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":"<p>Once the key is distributed, all <code>ctx pad</code> commands work identically on both machines. Entries added on Machine A are visible on Machine B after a <code>git pull</code>, and vice versa.</p>","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":"<p>If both machines add entries between syncs, pulling will create a merge conflict on <code>.context/scratchpad.enc</code>. Git cannot merge binary (encrypted) content automatically.</p> <p>The fastest approach is <code>ctx pad merge</code>: It reads both conflict sides, deduplicates, and writes the union:</p> <pre><code># 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</code></pre> <p>Alternatively, use <code>ctx pad resolve</code> to inspect both sides manually:</p> <pre><code>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</code></pre> <p>Then reconstruct the merged scratchpad:</p> <pre><code># 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</code></pre>","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":"<p>Here's a full scenario showing how conflicts arise and how to resolve them:</p> <p>1. Both machines start in sync (1 entry):</p> <pre><code>Machine A: 1. staging API key: sk-test-abc123\nMachine B: 1. staging API key: sk-test-abc123\n</code></pre> <p>2. Both add entries independently:</p> <pre><code>Machine A adds: \"check DNS after deploy\"\nMachine B adds: \"new endpoint: api.example.com/v2\"\n</code></pre> <p>3. Machine A pushes first. Machine B pulls and gets a conflict:</p> <pre><code>git pull\n# CONFLICT (content): Merge conflict in .context/scratchpad.enc\n</code></pre> <p>4. Machine B runs <code>ctx pad resolve</code>:</p> <pre><code>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</code></pre> <p>5. Rebuild with entries from both sides and commit:</p> <pre><code># 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</code></pre>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#conversational-approach","level":3,"title":"Conversational Approach","text":"<p>When working with an AI assistant, you can resolve conflicts naturally:</p> <pre><code>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</code></pre>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tips","level":2,"title":"Tips","text":"<ul> <li>Back up the key: If you lose it, you lose access to all encrypted entries. Store a copy in your password manager.</li> <li>One key per project: Each <code>ctx init</code> generates a unique key. Don't reuse keys across projects.</li> <li>Keys work in worktrees: Because the key lives at <code>~/.ctx/.ctx.key</code> (outside the project), git worktrees on the same machine share the key automatically. No special setup needed.</li> <li>Plaintext fallback for non-sensitive projects: If encryption adds friction and you have nothing sensitive, set <code>scratchpad_encrypt: false</code> in <code>.ctxrc</code>. Merge conflicts become trivial text merges.</li> <li>Never commit the key: The key is stored outside the project at <code>~/.ctx/.ctx.key</code> and should never be copied into the repository.</li> </ul>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#next-up","level":2,"title":"Next Up","text":"<p>Hook Output Patterns →: Choose the right output pattern for your Claude Code hooks.</p>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#see-also","level":2,"title":"See Also","text":"<ul> <li>Scratchpad: feature overview, all commands, when to use scratchpad vs context files</li> <li>Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad</li> </ul>","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":"<p>During a session you accumulate quick notes, reminders, intermediate values, and sometimes sensitive tokens. They don't fit <code>TASKS.md</code> (not work items) or <code>DECISIONS.md</code> (not decisions). They don't have the structured fields that <code>LEARNINGS.md</code> requires.</p> <p>Without somewhere to put them, they get lost between sessions.</p> <p>How do you capture working memory that persists across sessions without polluting your structured context files?</p>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx pad add \"check DNS propagation after deploy\"\nctx pad # list entries\nctx pad show 1 # print entry (pipe-friendly)\n</code></pre> <p>Entries are encrypted at rest and travel with <code>git</code>. </p> <p>Use the <code>/ctx-pad</code> skill to manage entries from inside your AI session.</p>","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 <code>ctx pad</code> CLI command List all scratchpad entries <code>ctx pad show N</code> CLI command Output raw text of entry N (pipe-friendly) <code>ctx pad add</code> CLI command Add a new entry <code>ctx pad edit</code> CLI command Replace, append to, or prepend to an entry <code>ctx pad add --file</code> CLI command Ingest a file as a blob entry <code>ctx pad show N --out</code> CLI command Extract a blob entry to a file <code>ctx pad rm</code> CLI command Remove entries by stable ID (supports ranges) <code>ctx pad normalize</code> CLI command Reassign entry IDs as 1..N <code>ctx pad mv</code> CLI command Reorder entries <code>ctx pad --tag</code> CLI command Filter entries by tag <code>ctx pad tags</code> CLI command List all tags with counts <code>ctx pad import</code> CLI command Bulk-import lines from a file (or stdin) <code>ctx pad export</code> CLI command Export all blob entries to a directory <code>ctx pad undo</code> CLI command Restore the pad from the most recent snapshot <code>/ctx-pad</code> 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":"<p>You don't need to remember any syntax. Just tell your assistant what to jot down:</p> <pre><code>You: \"jot down: check DNS propagation after deploy\"\n\nAgent: \"Added to scratchpad:\n 1. check DNS propagation after deploy\"\n</code></pre> <p>Behind the scenes, the agent runs <code>ctx pad add \"check DNS propagation after deploy\"</code>.</p>","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":"<pre><code>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</code></pre>","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":"<pre><code>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</code></pre> <p>For partial edits, the agent can use <code>--append</code> or <code>--prepend</code>:</p> <pre><code>You: \"append the port number to entry 2\"\n\nAgent: \"Updated entry 2:\n staging API endpoint: api.prod.example.com/v2 :8443\"\n</code></pre>","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":"<p>Use <code>ctx pad show N</code> to pipe entry content into other operations:</p> <pre><code>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</code></pre>","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":"<pre><code>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</code></pre>","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":"<pre><code>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</code></pre>","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":"<p>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:</p> <pre><code># 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</code></pre>","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":"<p>Use <code>show --out</code> to write the decoded file back to disk:</p> <pre><code># 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</code></pre> <p>Blob entries are encrypted identically to text entries: They're just base64-encoded before encryption. The <code>--out</code> flag decodes and writes the raw bytes.</p>","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":"<p>When you have a file with many notes (one per line), import them in bulk instead of adding one at a time:</p> <pre><code># 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</code></pre> <p>All entries are written in a single encrypt/write cycle, regardless of how many lines the file contains.</p>","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":"<p>Export all blob entries to a directory as individual files. Each blob's label becomes the filename:</p> <pre><code># 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</code></pre> <p>When a file already exists, a unix timestamp is prepended to the filename to avoid collisions. Use <code>--force</code> to overwrite instead.</p>","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":"<p>Tags let you categorize entries without any structure beyond a <code>#word</code> token in the text. Add them when creating or editing entries:</p> <pre><code>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</code></pre> <p>Filter your scratchpad by tag:</p> <pre><code>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</code></pre> <p>Entry IDs are stable; they don't shift when other entries are deleted, so <code>ctx pad rm 3</code> always targets the same entry regardless of deletions or active filters. Use <code>ctx pad normalize</code> to reassign IDs as 1..N.</p> <p>Exclude a tag with <code>~</code>:</p> <pre><code>ctx pad --tag ~later # everything NOT tagged #later\nctx pad --tag later --tag ci # entries with BOTH tags (AND logic)\n</code></pre> <p>See what tags you're using:</p> <pre><code>You: \"what tags do I have?\"\n\nAgent: [runs ctx pad tags]\n \"ci 1\n later 2\n urgent 1\"\n</code></pre> <p>Tags work on blob entries too; they're extracted from the label:</p> <pre><code>ctx pad add \"deploy config #prod\" --file ./deploy.yaml\nctx pad --tag prod\n# 1. deploy config #prod [BLOB]\n</code></pre>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#using-ctx-pad-in-a-session","level":2,"title":"Using <code>/ctx-pad</code> in a Session","text":"<p>Invoke the <code>/ctx-pad</code> skill first, then describe what you want in natural language. Without the skill prefix, the agent may route your request to <code>TASKS.md</code> or another context file instead of the scratchpad.</p> <pre><code>You: /ctx-pad jot down: check DNS after deploy\nYou: /ctx-pad show my scratchpad\nYou: /ctx-pad delete entry 3\n</code></pre> <p>Once the skill is active, it translates intent into commands:</p> You say (after <code>/ctx-pad</code>) What the agent does \"jot down: check DNS after deploy\" <code>ctx pad add \"check DNS after deploy\"</code> \"remember this: retry limit is 5\" <code>ctx pad add \"retry limit is 5\"</code> \"show my scratchpad\" / \"what's on my pad\" <code>ctx pad</code> \"show me entry 3\" <code>ctx pad show 3</code> \"delete the third one\" / \"remove entry 3\" <code>ctx pad rm 3</code> \"remove entries 3 through 5\" <code>ctx pad rm 3-5</code> \"renumber my scratchpad\" <code>ctx pad normalize</code> \"change entry 2 to ...\" <code>ctx pad edit 2 \"new text\"</code> \"append ' +important' to entry 3\" <code>ctx pad edit 3 --append \" +important\"</code> \"prepend 'URGENT:' to entry 1\" <code>ctx pad edit 1 --prepend \"URGENT: \"</code> \"prioritize entry 4\" / \"move to the top\" <code>ctx pad mv 4 1</code> \"import my notes from notes.txt\" <code>ctx pad import notes.txt</code> \"export all blobs to ./ideas\" <code>ctx pad export ./ideas</code> \"show entries tagged later\" <code>ctx pad --tag later</code> \"show everything except later\" <code>ctx pad --tag ~later</code> \"what tags do I have\" <code>ctx pad tags</code> \"tag entry 5 as urgent\" <code>ctx pad edit 5 --tag urgent</code> <p>When in Doubt, Use the CLI Directly</p> <p>The <code>ctx pad</code> commands work the same whether you run them yourself or let the skill invoke them. </p> <p>If the agent misroutes a request, fall back to <code>ctx pad add \"...\"</code> in your terminal.</p>","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\") <code>ctx remind</code> 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 <code>TASKS.md</code> Trade-offs between alternatives with rationale <code>DECISIONS.md</code> Reusable lessons with context/lesson/application <code>LEARNINGS.md</code> Codified patterns and standards <code>CONVENTIONS.md</code> <p>Decision Guide</p> <ul> <li>If it has structured fields (context, rationale, lesson, application), it belongs in a context file like <code>DECISIONS.md</code> or <code>LEARNINGS.md</code>.</li> <li>If it's a work item you'll mark done, it belongs in <code>TASKS.md</code>.</li> <li>If you want a message relayed VERBATIM at the next session start, it belongs in <code>ctx remind</code>.</li> <li>If it's a quick note, reminder, or working value (especially if it's sensitive or ephemeral) it belongs on the scratchpad.</li> </ul> <p>Scratchpad Is Not a Junk Drawer</p> <p>The scratchpad is for working memory, not long-term storage.</p> <p>If a note is still relevant after several sessions, promote it:</p> <p>A persistent reminder becomes a task, a recurring value becomes a convention, a hard-won insight becomes a learning.</p>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tips","level":2,"title":"Tips","text":"<ul> <li>Entries persist across sessions: The scratchpad is committed (encrypted) to git, so entries survive session boundaries. Pick up where you left off.</li> <li>Entries are numbered and reorderable: Use <code>ctx pad mv</code> to put high-priority items at the top.</li> <li><code>ctx pad show N</code> enables unix piping: Output raw entry text with no numbering prefix. Compose with <code>--append</code>, <code>--prepend</code>, or other shell tools.</li> <li>Never mention the key file contents to the AI: The agent knows how to use <code>ctx pad</code> commands but should never read or print the encryption key (<code>~/.ctx/.ctx.key</code>) directly.</li> <li>Encryption is transparent: You interact with plaintext; the encryption/decryption happens automatically on every read/write.</li> </ul>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#if-you-delete-the-wrong-thing","level":2,"title":"If You Delete the Wrong Thing","text":"<p>Every destructive <code>ctx pad</code> operation (add, edit, mv, rm, merge, normalize, resolve, tag) writes a snapshot of the prior pad blob to <code>.context/scratchpad.history/</code> before overwriting. There is no confirmation prompt on the hot path — and you don't need one, because <code>ctx pad undo</code> restores the most recent snapshot:</p> <pre><code>ctx pad rm 3 # oh no, that was the one with the API token\nctx pad undo # → \"Restored pad from snapshot 20260524...\"\n</code></pre> <p>A few things to know:</p> <ul> <li>Undo is itself snapshotted. Running <code>ctx pad undo</code> twice in a row is a redo — the first undo saves the post-mutation state, then promotes the pre-mutation state; the second undo reverses that.</li> <li>Empty history is not an error. On a brand-new project with no mutations yet, <code>ctx pad undo</code> prints <code>No pad history to restore.</code> and exits 0.</li> <li>Snapshots are encrypted with the same key as the live pad. Losing <code>~/.ctx/.ctx.key</code> makes both unreadable; the safety net does not change the key-loss failure mode.</li> <li>Retention is bounded. The 20 most recent snapshots (capped also at 30 days) are kept; older ones are pruned after each mutation. Off-host backups remain the recovery path for anything beyond that window.</li> </ul>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#next-up","level":2,"title":"Next Up","text":"<p>Syncing Scratchpad Notes Across Machines →: Distribute encryption keys and scratchpad data across environments.</p>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#see-also","level":2,"title":"See Also","text":"<ul> <li>Scratchpad: feature overview, all commands, encryption details, plaintext override</li> <li>Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad</li> <li>The Complete Session: full session lifecycle showing how the scratchpad fits into the broader workflow</li> </ul>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/","level":1,"title":"Scrutinizing a Plan","text":"<p>When you have a plan and want it attacked, not validated, the <code>/ctx-plan</code> skill runs an adversarial interview. It surfaces what's weak, missing, or unexamined before you commit.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#when-to-use-it","level":2,"title":"When to Use It","text":"<ul> <li>Before starting a multi-day implementation.</li> <li>After writing a spec but before opening the first PR.</li> <li>When the team aligned suspiciously fast on a complex change.</li> <li>When you've drafted something and the obvious next step is to hand it to a senior reviewer.</li> </ul> <p><code>/ctx-plan</code> is not a brainstorming tool. Use <code>/ctx-brainstorm</code> for that. <code>/ctx-plan</code> assumes the plan exists and asks: does it survive contact with reality?</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#stop-conditions","level":2,"title":"Stop Conditions","text":"<p>The skill runs depth-first through assumptions, tradeoffs, and failure modes. Stop when one of these is true:</p> <ul> <li>Plan converges. The bet is clear, the sequencing is justified, and you can articulate what would falsify it.</li> <li>Plan dissolves. The interview surfaces a load-bearing assumption you can't defend; the plan needs rework, not more scrutiny.</li> <li>You hit information you don't have. Pause, gather it, resume.</li> </ul> <p>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.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#worked-example","level":2,"title":"Worked Example","text":"<pre><code>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</code></pre> <p>The interview keeps going until the bet is articulated, the falsifiable conditions are written down, and the rejected alternatives have a recall trigger.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#output","level":2,"title":"Output","text":"<p><code>/ctx-plan</code> concludes by offering to write a debated brief to <code>.context/briefs/<TS>-<slug>.md</code>: the bet, the rejections, the failure modes, the validation route, and the unwind cost, in your words. It deliberately does not produce an implementation plan or a task list — decomposition happens after the spec, via <code>/ctx-task-out</code>. Feed the interview's conclusions forward via:</p> <ul> <li><code>/ctx-spec --brief <path></code> to absorb the brief into a committed spec; multi-milestone specs then flow to <code>/ctx-task-out</code> for decomposition.</li> <li><code>/ctx-decision-add</code> if a tradeoff resolved into an architectural decision.</li> <li><code>/ctx-learning-add</code> if you discovered a project-specific gotcha during the interview.</li> </ul> <p>The skill itself is in <code>internal/assets/claude/skills/ctx-plan/SKILL.md</code>; the working contract lives there, the recipe is the on-ramp.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#see-also","level":2,"title":"See Also","text":"<ul> <li>Design Before Coding: the brainstorming counterpart, used before a plan exists.</li> <li><code>ctx-spec</code>: scaffolds a feature spec from the project template.</li> </ul>","path":["Recipes","Knowledge and Tasks","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":"<p>After weeks of AI-assisted development you have dozens of sessions scattered across JSONL files in <code>~/.claude/projects/</code>. 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.</p> <p>There is no table of contents, no search, and no summaries.</p> <p>This recipe shows how to turn that raw session history into a browsable, searchable, and enriched journal site you can navigate in your browser.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tldr","level":2,"title":"TL;DR","text":"<p>Export and Generate</p> <pre><code>ctx journal import --all\nctx journal site --serve\n</code></pre> <p>Enrich</p> <pre><code>/ctx-journal-enrich-all\n</code></pre> <p>Rebuild</p> <pre><code>ctx journal site --serve\n</code></pre> <p>Read on for what each stage does and why.</p>","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 <code>ctx journal source</code> Command List parsed sessions with metadata <code>ctx journal source --show</code> Command Inspect a specific session in detail <code>ctx journal import</code> Command Import sessions to editable journal Markdown <code>ctx journal site</code> Command Generate a static site from journal entries <code>ctx journal obsidian</code> Command Generate an Obsidian vault from journal entries <code>ctx journal schema check</code> Command Validate JSONL files and report schema drift <code>ctx journal schema dump</code> Command Print the embedded JSONL schema definition <code>ctx serve</code> Command Serve any zensical directory (default: journal) <code>/ctx-history</code> Skill Browse sessions inside your AI assistant <code>/ctx-journal-enrich</code> Skill Add frontmatter metadata to a single entry <code>/ctx-journal-enrich-all</code> 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":"<p>The session journal follows a four-stage pipeline.</p> <p>Each stage is idempotent and safe to re-run:</p> <p>By default, each stage skips entries that have already been processed.</p> <pre><code>import -> enrich -> rebuild\n</code></pre> Stage Tool What it does Skips if Where Import <code>ctx journal import --all</code> Converts session JSONL to Markdown File already exists (safe default) CLI or agent Enrich <code>/ctx-journal-enrich-all</code> Adds frontmatter, summaries, topic tags Frontmatter already present Agent only Rebuild <code>ctx journal site --build</code> Generates browsable static HTML N/A CLI only Obsidian <code>ctx journal obsidian</code> Generates Obsidian vault with wikilinks N/A CLI only <p>Where Do You Run Each Stage?</p> <p>Import (Steps 1 to 3) works equally well from the terminal or inside your AI assistant via <code>/ctx-history</code>. The CLI is fine here: the agent adds no special intelligence, it just runs the same command.</p> <p>Enrich (Step 4) requires the agent: it reads conversation content and produces structured metadata.</p> <p>Rebuild and serve (Step 5) is a terminal operation that starts a long-running server.</p>","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":"<p>Start by seeing what sessions exist for the current project:</p> <pre><code>ctx journal source\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> <p>Slugs Look Cryptic?</p> <p>These auto-generated slugs (<code>gleaming-wobbling-sutherland</code>) are hard to recognize later.</p> <p>Use <code>/ctx-journal-enrich</code> to add human-readable titles, topic tags, and summaries to exported journal entries, making them easier to find.</p> <p>Filter by project or tool if you work across multiple codebases:</p> <pre><code>ctx journal source --project ctx --limit 10\nctx journal source --tool claude-code\nctx journal source --all-projects\n</code></pre>","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":"<p>Before exporting everything, inspect a single session to see its metadata and conversation summary:</p> <pre><code>ctx journal source --show --latest\n</code></pre> <p>Or look up a specific session by its slug, partial ID, or UUID:</p> <pre><code>ctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show twinkly\nctx journal source --show abc123\n</code></pre> <p>Add <code>--full</code> to see the complete message content instead of the summary view:</p> <pre><code>ctx journal source --show --latest --full\n</code></pre> <p>This is useful for checking what happened before deciding whether to export and enrich it.</p>","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":"<p>Import converts raw session data into editable Markdown files in <code>.context/journal/</code>:</p> <pre><code># 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</code></pre> <p><code>--keep-frontmatter=false</code> Discards Enrichments</p> <p><code>--keep-frontmatter=false</code> discards enriched YAML frontmatter during regeneration.</p> <p>Back up your journal before using this flag.</p> <p>Each imported file contains session metadata (date, time, duration, model, project, git branch), a tool usage summary, and the full conversation transcript.</p> <p>Re-importing is safe. Running <code>ctx journal import --all</code> only imports new sessions: Existing files are never touched. Use <code>--dry-run</code> to preview what would be imported without writing anything.</p> <p>To re-import existing files (e.g., after a format improvement), use <code>--regenerate</code>: 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.</p> <p><code>--regenerate</code> Replaces the Markdown Body</p> <p><code>--regenerate</code> preserves YAML frontmatter but replaces the entire Markdown body with freshly generated content from the source JSONL.</p> <p>If you manually edited the conversation transcript (added notes, redacted sensitive content, restructured sections), those edits will be lost.</p> <p>BACK UP YOUR JOURNAL FIRST.</p> <p>To protect entries you've hand-edited, you can explicitly lock them:</p> <pre><code>ctx journal lock <pattern>\n</code></pre> <p>Locked entries are always skipped, regardless of flags.</p> <p>If you prefer to add <code>locked: true</code> directly in frontmatter during enrichment, run <code>ctx journal sync</code> to propagate the lock state to <code>.state.json</code>:</p> <pre><code>ctx journal sync\n</code></pre> <p>See <code>ctx journal lock --help</code> and <code>ctx journal sync --help</code> for details.</p>","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":"<p>Raw imports have timestamps and transcripts but lack the semantic metadata that makes sessions searchable: topics, technology tags, outcome status, and summaries. The <code>/ctx-journal-enrich*</code> skills add this structured frontmatter.</p> <p>Locked entries are skipped by enrichment skills, just as they are by import. Lock entries you want to protect before running batch enrichment.</p> <p>Batch enrichment (recommended):</p> <pre><code>/ctx-journal-enrich-all\n</code></pre> <p>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.</p> <p>It shows you a grouped summary before applying changes so you can scan quickly rather than reviewing one by one.</p> <p>For large backlogs (20+ entries), the skill can spawn subagents to process entries in parallel.</p> <p>Single-entry enrichment:</p> <pre><code>/ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-02-06\n</code></pre> <p>Each enriched entry gets YAML frontmatter like this:</p> <pre><code>---\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</code></pre> <p>The skill also generates a summary and can extract decisions, learnings, and tasks mentioned during the session.</p>","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":"<p>With imported and enriched journal files, generate the static site:</p> <pre><code># 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</code></pre> <p>Then open <code>http://localhost:8000</code> to browse.</p> <p>The site includes a date-sorted index, individual session pages with full conversations, search (press <code>/</code>), dark mode, and enriched titles in the navigation when frontmatter exists.</p> <p>You can also serve an already-generated site without regenerating using <code>ctx serve</code> (serve-only, no regeneration).</p> <p>The site generator requires <code>zensical</code> (<code>pipx install zensical</code>).</p>","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":"<p>Export, list, and show are mechanical: The agent runs the same CLI commands you would, so you can stay in your terminal for those.</p> <p>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.</p> <p>You can also ask your agent to browse sessions conversationally instead of remembering flags:</p> <pre><code>What did we work on last week?\nShow me the session about Redis.\nImport everything to the journal.\n</code></pre> <p>This is convenient but not required: <code>ctx journal source</code> gives you the same inventory.</p> <p>Where the agent genuinely helps is chaining the pipeline:</p> <pre><code>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</code></pre> <p>The value is staying in one context while the agent runs import -> enrich without you manually switching tools.</p>","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":"<p>A typical pipeline from raw sessions to a browsable site:</p> <pre><code># Terminal: import and generate\nctx journal import --all\nctx journal site --serve\n</code></pre> <pre><code># AI assistant: enrich\n/ctx-journal-enrich-all\n</code></pre> <pre><code># Terminal: rebuild with enrichments\nctx journal site --serve\n</code></pre> <p>If your project includes <code>Makefile.ctx</code> (deployed by <code>ctx init</code>), use <code>make journal</code> to combine import and rebuild stages. Then enrich inside Claude Code, then <code>make journal</code> again to pick up enrichments.</p>","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":"<p>Claude Code does not keep JSONL transcripts forever. Understanding its cleanup behavior helps you avoid losing session history.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#default-behavior","level":3,"title":"Default Behavior","text":"<p>Claude Code retains session transcripts for approximately 30 days. After that, JSONL files are automatically deleted during cleanup. Once deleted, <code>ctx journal</code> can no longer see those sessions - the data is gone.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-cleanupperioddays-setting","level":3,"title":"The <code>cleanupPeriodDays</code> Setting","text":"<p>Claude Code exposes a <code>cleanupPeriodDays</code> setting in its configuration (<code>~/.claude/settings.json</code>) that controls retention:</p> Value Behavior <code>30</code> (default) Transcripts older than 30 days are deleted <code>60</code>, <code>90</code>, etc. Extends the retention window <code>0</code> Disables writing new transcripts entirely - not \"keep forever\" <p>Setting <code>cleanupPeriodDays</code> To 0</p> <p>Setting this to <code>0</code> does not mean \"never delete.\" It disables transcript creation altogether. No new JSONL files are written, which means <code>ctx journal</code> sees nothing new. This is rarely what you want.</p>","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":"<p>The journal import pipeline (Steps 1-4 above) is your archival mechanism. Imported Markdown files in <code>.context/journal/</code> persist independently of Claude Code's cleanup cycle. Even after the source JSONL files are deleted, your journal entries remain.</p> <p>Recommendation: import regularly - weekly, or after any session worth revisiting. A quick <code>ctx journal import --all</code> takes seconds and ensures nothing falls through the 30-day window.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#quick-archival-checklist","level":3,"title":"Quick Archival Checklist","text":"<ol> <li>Run <code>ctx journal import --all</code> at least weekly</li> <li>Enrich high-value sessions with <code>/ctx-journal-enrich</code> before the details fade from your own memory</li> <li>Lock enriched entries (<code>ctx journal lock <pattern></code>) to protect them from accidental regeneration</li> <li>Rebuild the journal site periodically to keep it current</li> </ol>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>/ctx-history</code> inside your AI assistant. If you want to quickly check what happened in a recent session without leaving your editor, <code>/ctx-history</code> lets you browse interactively without importing.</li> <li>Large sessions may be split automatically. Sessions with 200+ messages can be split into multiple parts (<code>session-abc123.md</code>, <code>session-abc123-p2.md</code>, <code>session-abc123-p3.md</code>) with navigation links between them. The site generator can handle this.</li> <li>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.</li> <li>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.</li> </ul> <p>Journal Files Are Sensitive</p> <p>Journal files MUST be <code>.gitignore</code>d.</p> <p>Session transcripts can contain sensitive data such as file contents, commands, error messages with stack traces, and potentially API keys.</p> <p>Add <code>.context/journal/</code>, <code>.context/journal-site/</code>, and <code>.context/journal-obsidian/</code> to your <code>.gitignore</code>.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#next-up","level":2,"title":"Next Up","text":"<p>Persisting Decisions, Learnings, and Conventions →: Record decisions, learnings, and conventions so they survive across sessions.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: where session saving fits in the daily workflow</li> <li>Turning Activity into Content: generating blog posts from session history</li> <li>Session Journal: full documentation of the journal system</li> <li>CLI Reference: <code>ctx</code> journal: all journal subcommands and flags</li> <li>CLI Reference: <code>ctx</code> serve: serve-only (no regeneration)</li> <li>Context Files: the <code>.context/</code> directory structure</li> </ul>","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":"<p>Sessions have two critical moments: the start and the end.</p> <ul> <li>At the start, you need the agent to load context and confirm it knows what is going on. </li> <li>At the end, you need to capture whatever the session produced before the conversation disappears.</li> </ul> <p>Most <code>ctx</code> skills work conversationally: \"jot down: check DNS after deploy\" is as good as <code>/ctx-pad add \"check DNS after deploy\"</code>. But session boundaries are different. They are well-defined moments with specific requirements, and partial execution is costly.</p> <p>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.</p> <p>This Is One of the Few Times Being Explicit Matters</p> <p>Session ceremonies are the two bookend skills that mark these boundaries. </p> <p>They are the exception to the conversational rule:</p> <p>Invoke <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> explicitly as slash commands.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tldr","level":2,"title":"TL;DR","text":"<p>Start: <code>/ctx-remember</code>: load context, get a structured readback.</p> <p>End: <code>/ctx-wrap-up</code>: review session, propose candidates, persist approved items.</p> <p>Use the slash commands, not conversational triggers, for completeness.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#explicit-invocation-matters","level":2,"title":"Explicit Invocation Matters","text":"<p>Most <code>ctx</code> skills encourage natural language. These two are different:</p> <p>Well-defined moments: Sessions have clear boundaries. A slash command marks the boundary unambiguously.</p> <p>Ambiguity risk: \"Do you remember?\" could mean many things. <code>/ctx-remember</code> means exactly one thing: load context and present a structured readback.</p> <p>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.</p> <p>Muscle memory: Typing <code>/ctx-remember</code> at session start and <code>/ctx-wrap-up</code> at session end becomes a habit, like opening and closing braces.</p>","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 <code>/ctx-remember</code> Skill Load context and present structured readback <code>/ctx-wrap-up</code> Skill Gather session signal, propose and persist context <code>/ctx-commit</code> Skill Commit with context capture (offered by wrap-up) <code>ctx agent</code> CLI Load token-budgeted context packet <code>ctx journal source</code> CLI List recent sessions <code>ctx add</code> 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: <code>/ctx-remember</code>","text":"<p>Invoke at the beginning of every session:</p> <pre><code>/ctx-remember\n</code></pre> <p>The skill silently:</p> <ol> <li>Loads the context packet via <code>ctx agent --budget 4000</code></li> <li>Reads <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code></li> <li>Checks recent sessions via <code>ctx journal source --limit 3</code></li> </ol> <p>Then presents a structured readback with four sections:</p> <ul> <li>Last session: topic, date, what was accomplished</li> <li>Active work: pending and in-progress tasks</li> <li>Recent context: 1-2 relevant decisions or learnings</li> <li>Next step: suggestion or question about what to focus on</li> </ul> <p>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.</p> <p>What about 'do you remember?'</p> <p>The conversational trigger still works. But <code>/ctx-remember</code> guarantees the full ceremony runs: </p> <ul> <li>context packet, </li> <li>file reads, </li> <li>session history,</li> <li>and all four readback sections. </li> </ul> <p>The conversational version may cut corners.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#session-end-ctx-wrap-up","level":2,"title":"Session End: <code>/ctx-wrap-up</code>","text":"<p>Invoke before ending a session where meaningful work happened:</p> <pre><code>/ctx-wrap-up\n</code></pre> <p>The skill runs four phases:</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-1-gather-signal","level":3,"title":"Phase 1: Gather Signal","text":"<p>Silently checks <code>git diff --stat</code>, recent commits, and scans the conversation for themes: architectural choices, gotchas, patterns established, follow-up work identified.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-2-propose-candidates","level":3,"title":"Phase 2: Propose Candidates","text":"<p>Presents a structured list grouped by type:</p> <pre><code>## 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</code></pre> <p>Each candidate has complete structured fields, not just a title. Empty categories are omitted.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-3-persist","level":3,"title":"Phase 3: Persist","text":"<p>After you approve (all, some, or modified), the skill runs the appropriate <code>ctx add</code> commands and reports results.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#nudge-suppression","level":3,"title":"Nudge Suppression","text":"<p>After persisting, the skill marks the session as wrapped up via <code>ctx system mark-wrapped-up</code>. This suppresses context checkpoint nudges for 2 hours so the wrap-up ceremony itself does not trigger noisy reminders.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-4-commit-offer","level":3,"title":"Phase 4: Commit Offer","text":"<p>If there are uncommitted changes, offers to run <code>/ctx-commit</code>. Does not auto-commit.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#when-to-skip","level":2,"title":"When to Skip","text":"<p>Not every session needs ceremonies.</p> <p>Skip <code>/ctx-remember</code> when:</p> <ul> <li>You are doing a quick one-off lookup (reading a file, checking a value)</li> <li>Context was already loaded this session via <code>/ctx-agent</code></li> <li>You are continuing immediately after a previous session and context is still fresh</li> </ul> <p>Skip <code>/ctx-wrap-up</code> when:</p> <ul> <li>Nothing meaningful happened (only read files, answered a question)</li> <li>You already persisted everything manually during the session</li> <li>The session was trivial (typo fix, quick config change)</li> </ul> <p>A good heuristic: if the session produced something a future session should know about, run <code>/ctx-wrap-up</code>. If not, just close.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#quick-reference","level":2,"title":"Quick Reference","text":"<pre><code># Session start\n/ctx-remember\n\n# ... do work ...\n\n# Session end\n/ctx-wrap-up\n</code></pre> <p>That is the complete ceremony. Two commands, bookending your session.</p>","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 <code>/ctx-remember</code> Session start Load and confirm context <code>/ctx-reflect</code> Mid-session breakpoints Checkpoint at milestones <code>/ctx-wrap-up</code> Session end Full session review and persist <code>/ctx-commit</code> After completing work Commit with context capture <p><code>/ctx-reflect</code> is for mid-session checkpoints. <code>/ctx-wrap-up</code> is for end-of-session: it is more thorough, covers the full session arc, and includes the commit offer. If you already ran <code>/ctx-reflect</code> recently, <code>/ctx-wrap-up</code> avoids proposing the same candidates again.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tips","level":2,"title":"Tips","text":"<ul> <li>Make it a habit: The value of ceremonies compounds over sessions. Each <code>/ctx-wrap-up</code> makes the next <code>/ctx-remember</code> richer.</li> <li>Trust the candidates: The agent scans the full conversation. It often catches learnings you forgot about.</li> <li>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.</li> <li>Do not force empty ceremonies: If <code>/ctx-wrap-up</code> finds nothing worth persisting, that is fine. A session that only read files and answered questions does not need artificial learnings.</li> </ul>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#next-up","level":2,"title":"Next Up","text":"<p>Browsing and Enriching Past Sessions →: Export session history to a browsable journal and enrich entries with metadata.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: the full session workflow that ceremonies bookend</li> <li>Persisting Decisions, Learnings, and Conventions: deep dive on what gets persisted during wrap-up</li> <li>Detecting and Fixing Drift: keeping context files accurate between ceremonies</li> <li>Pausing Context Hooks: skip ceremonies entirely for quick tasks that don't need them</li> </ul>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-changes/","level":1,"title":"Reviewing Session Changes","text":"","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-changed-while-you-were-away","level":2,"title":"What Changed While You Were Away?","text":"<p>Between sessions, teammates commit code, context files get updated, and decisions pile up. <code>ctx change</code> gives you a single-command summary of everything that moved since your last session.</p>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#quick-start","level":2,"title":"Quick Start","text":"<pre><code># 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</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#how-reference-time-works","level":2,"title":"How Reference Time Works","text":"<p><code>ctx change</code> needs a reference point to compare against. It tries these sources in order:</p> <ol> <li><code>--since</code> flag: explicit duration (<code>24h</code>, <code>72h</code>) or date (<code>2026-03-10</code>, RFC3339 timestamp)</li> <li>Session markers: <code>ctx-loaded-*</code> files in <code>.context/state/</code>; picks the second-most-recent (your previous session start)</li> <li>Event log: last <code>context-load-gate</code> event from <code>.context/state/events.jsonl</code></li> <li>Fallback: 24 hours ago</li> </ol> <p>The marker-based detection means <code>ctx change</code> usually just works without any flags: it knows when you last loaded context and shows everything after that.</p>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-it-reports","level":2,"title":"What It Reports","text":"","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#context-file-changes","level":3,"title":"Context File Changes","text":"<p>Any <code>.md</code> file in <code>.context/</code> modified after the reference time:</p> <pre><code>### Context File Changes\n- `TASKS.md` - modified 2026-03-11 14:30\n- `DECISIONS.md` - modified 2026-03-11 09:15\n</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#code-changes","level":3,"title":"Code Changes","text":"<p>Git activity since the reference time:</p> <pre><code>### 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</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#integrating-into-session-start","level":2,"title":"Integrating into Session Start","text":"<p>Pair <code>ctx change</code> with the <code>/ctx-remember</code> ceremony for a complete session-start picture:</p> <pre><code># 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</code></pre> <p>Or script it:</p> <pre><code># .context/hooks/session-start.sh\nctx agent --budget 4000\necho \"---\"\nctx change\n</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#team-workflows","level":2,"title":"Team Workflows","text":"<p>When multiple people share a <code>.context/</code> directory, <code>ctx change</code> shows who changed what:</p> <pre><code># After pulling from remote\ngit pull\nctx change --since 72h\n</code></pre> <p>This surfaces context file changes from teammates that you might otherwise miss in the commit log.</p>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#tips","level":2,"title":"Tips","text":"<ul> <li>No changes? If nothing shows up, the reference time might be wrong. Use <code>--since 48h</code> to widen the window.</li> <li>Works without git. Context file changes are detected by filesystem mtime, not git. Code changes require git.</li> <li>Hook integration. The <code>context-load-gate</code> hook writes the session marker that <code>ctx change</code> uses for auto-detection. If you're not using the <code>ctx</code> plugin, markers won't exist and it falls back to the event log or 24h window.</li> </ul>","path":["Recipes","Sessions","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":"<p>\"What does a full <code>ctx</code> session look like from start to finish?\"</p> <p>You have <code>ctx</code> installed and your <code>.context/</code> directory initialized, but the individual commands and skills feel disconnected.</p> <p>How do they fit together into a coherent workflow?</p> <p>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.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tldr","level":2,"title":"TL;DR","text":"<ol> <li>Load: <code>/ctx-remember</code>: load context, get structured readback.</li> <li>Orient: <code>/ctx-status</code>: check file health and token usage.</li> <li>Pick: <code>/ctx-next</code>: choose what to work on.</li> <li>Work: implement, test, iterate.</li> <li>Commit: <code>/ctx-commit</code>: commit and capture decisions/learnings.</li> <li>Reflect: <code>/ctx-reflect</code>: identify what to persist (at milestones)</li> <li>Wrap up: <code>/ctx-wrap-up</code>: end-of-session ceremony.</li> </ol> <p>Read on for the full walkthrough with examples.</p> <p>What Is a Readback?</p> <p>A readback is a structured summary where the agent plays back what it knows:</p> <ul> <li>last session,</li> <li>active tasks,</li> <li>recent decisions.</li> </ul> <p>This way, you can confirm it loaded the right context.</p> <p>The term \"readback\" comes from aviation, where pilots repeat instructions back to air traffic control to confirm they heard correctly.</p> <p>Same idea in <code>ctx</code>: The agent tells you what it \"thinks\" is going on, and you correct anything that's off before the work begins.</p> <ul> <li>Last session: topic, date, what was accomplished</li> <li>Active work: pending and in-progress tasks</li> <li>Recent context: 1-2 decisions or learnings that matter now</li> <li>Next step: suggestion or question about what to focus on</li> </ul>","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 <code>ctx status</code> CLI command Quick health check on context files <code>ctx agent</code> CLI command Load token-budgeted context packet <code>ctx journal source</code> CLI command List previous sessions <code>ctx journal source --show</code> CLI command Inspect a specific session in detail <code>/ctx-remember</code> Skill Recall project context with structured readback <code>/ctx-agent</code> Skill Load full context packet inside the assistant <code>/ctx-status</code> Skill Show context summary with commentary <code>/ctx-next</code> Skill Suggest what to work on with rationale <code>/ctx-commit</code> Skill Commit code and prompt for context capture <code>/ctx-reflect</code> Skill Structured reflection checkpoint <code>/ctx-history</code> 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":"<p>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:</p> <p>Load context > Orient > Pick a Task > Work > Commit > Reflect</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-1-load-context","level":3,"title":"Step 1: Load Context","text":"<p>Start every session by loading what you know. The fastest way is a single prompt:</p> <pre><code>Do you remember what we were working on?\n</code></pre> <p>This triggers the <code>/ctx-remember</code> skill. Behind the scenes, the assistant runs <code>ctx agent --budget 4000</code>, reads the files listed in the context packet (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>), checks <code>ctx journal source --limit 3</code> for recent sessions, and then presents a structured readback.</p> <p>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.</p> <p>As an alternative, if you want raw data instead of a readback, run <code>ctx status</code> in your terminal or invoke <code>/ctx-status</code> for a summarized health check showing file counts, token usage, and recent activity.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-2-orient","level":3,"title":"Step 2: Orient","text":"<p>After loading context, verify you understand the current state.</p> <pre><code>/ctx-status\n</code></pre> <p>The status output shows which context files are populated, how many tokens they consume, and which files were recently modified. Look for:</p> <ul> <li>Empty core files: <code>TASKS.md</code> or <code>CONVENTIONS.md</code> with no content means the context is sparse</li> <li>High token count (over 30k): the context is bloated and might need <code>ctx compact</code></li> <li>No recent activity: files may be stale and need updating</li> </ul> <p>If the status looks healthy and the readback from Step 1 gave you enough context, skip ahead.</p> <p>If something seems off (stale tasks, missing decisions...), spend a minute reading the relevant file before proceeding.</p>","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":"<p>With context loaded, choose a task. You can pick one yourself, or ask the assistant to recommend:</p> <pre><code>/ctx-next\n</code></pre> <p>The skill reads <code>TASKS.md</code>, checks recent sessions to avoid re-suggesting completed work, and presents 1-3 ranked recommendations with rationale.</p> <p>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.</p> <p>If you already know what you want to work on, state it directly:</p> <pre><code>Let's work on the session enrichment feature.\n</code></pre>","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":"<p>This is the main body of the session: write code, fix bugs, refactor, research: whatever the task requires.</p> <p>During this phase, a few <code>ctx</code>-specific patterns help:</p> <p>Check decisions before choosing: when you face a design choice, check if a prior decision covers it.</p> <pre><code>Is this consistent with our decisions?\n</code></pre> <p>Constrain scope: keep the assistant focused on the task at hand.</p> <pre><code>Only change files in internal/cli/session/. Nothing else.\n</code></pre> <p>Use <code>/ctx-implement</code> for multistep plans: if the task has multiple steps, this skill executes them one at a time with build/test verification between each step.</p> <p>Context monitoring runs automatically: the <code>check-context-size</code> 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.</p>","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":"<p>When the work is ready, use the context-aware commit instead of raw <code>git commit</code>:</p> <pre><code>/ctx-commit\n</code></pre> <p>The Agent May Recommend Committing</p> <p>You do not always need to invoke <code>/ctx-commit</code> explicitly.</p> <p>After a commit, the agent may proactively offer to capture context:</p> <p>\"We just made a trade-off there. Want me to record it as a decision?\"</p> <p>This is normal: The Agent Playbook encourages persisting at milestones, and a commit is a natural milestone.</p> <p>As an alternative, you can ask the assistant \"can we commit this?\" and it will pick up the <code>/ctx-commit</code> skill for you.</p> <p>The skill runs a pre-commit build check (for Go projects, <code>go build</code>), reviews the staged changes, drafts a commit message focused on \"why\" rather than \"what\", and then commits.</p> <p>After the commit succeeds, it prompts you:</p> <pre><code>**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</code></pre> <p>If you made a decision, the skill records it with <code>ctx decision add</code>. If you learned something, it records it with <code>ctx learning add</code> including context, lesson, and application fields. This is the bridge between committing code and remembering why the code looks the way it does.</p> <p>If source code changed in areas that affect documentation, the skill also offers to check for doc drift.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-6-reflect","level":3,"title":"Step 6: Reflect","text":"<p>At natural breakpoints (after finishing a feature, resolving a complex bug, or before switching tasks) pause to reflect:</p> <pre><code>/ctx-reflect\n</code></pre> <p>Agents Reflect at Milestones</p> <p>Agents often reflect without explicit invocation.</p> <p>After completing a significant piece of work, the agent may naturally surface items worth persisting:</p> <p>\"We discovered that <code>$PPID</code> resolves differently inside hooks. Should I save that as a learning?\"</p> <p>This is the agent following the Work-Reflect-Persist cycle from the Agent Playbook.</p> <p>You do not need to say <code>/ctx-reflect</code> for this to happen; the agent treats milestones as reflection triggers on its own.</p> <p>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:</p> <pre><code>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</code></pre> <p>The skill asks before persisting anything. You choose what to keep.</p> <p>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.</p>","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":"<p>Before ending the session, run the wrap-up ceremony to capture outstanding learnings, decisions, conventions, and tasks:</p> <pre><code>/ctx-wrap-up\n</code></pre> <p>Ceremony Skills</p> <p><code>/ctx-remember</code> at session start and <code>/ctx-wrap-up</code> at session end are ceremony skills: Invoke them as explicit slash commands for completeness, not conversationally.</p> <p>See Session Ceremonies for details on why these two skills are the exception to the conversational rule.</p> <p>The skill gathers signal from <code>git diff</code>, recent commits, and the conversation, then proposes structured candidates for your approval. After you select which to keep, it persists them via <code>ctx add</code> and offers <code>/ctx-commit</code> if uncommitted changes remain.</p> <p>As its final step, <code>/ctx-wrap-up</code> writes a handover under <code>.context/handovers/<TS>-<slug>.md</code> — a former-agent-to-next-agent note with a past-tense summary and a future-tense \"first action for the next session\". The filename is timestamped so concurrent agent runs never overwrite each other. The next <code>/ctx-remember</code> reads this file as the authoritative recall surface; skipping <code>/ctx-wrap-up</code> means the next session has no handover to read and recall degrades to probabilistic reconstruction from canonical files plus journal.</p> <p>Session transcripts are automatically captured by Claude Code and can be browsed later with <code>ctx journal source</code> and <code>ctx journal source --show</code>.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#conversational-session-flow","level":2,"title":"Conversational Session Flow","text":"<p>The steps above describe the mechanics. In practice, a session with a <code>ctx</code>-aware agent feels more like a conversation than a command sequence.</p> <p>The agent knows the lifecycle and moves through it naturally, often without explicit invocation. Here is a realistic example:</p> <p>You: Do you remember what we were working on?</p> <p>Agent (loads context silently, presents structured readback):</p> <pre><code>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</code></pre> <p>You: Let's work on the Redis caching backend.</p> <p>Agent (picks up the task, begins implementation):</p> <pre><code>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</code></pre> <p>(The agent works... writes code, runs tests, iterates.)</p> <p>Agent (after implementing the connection pool and choosing a retry strategy):</p> <pre><code>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</code></pre> <p>You: Yes, go ahead.</p> <p>Agent:</p> <pre><code>Done. Added to DECISIONS.md: \"Exponential backoff with jitter for Redis\nreconnection, to avoid thundering herd on pool recovery.\"\n</code></pre> <p>(More work happens... the agent implements the cache read/write paths.)</p> <p>You: What else did we learn during this session?</p> <p>Agent:</p> <pre><code>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</code></pre> <p>You: Yes. And let's wrap up.</p> <p>Agent (reflects and persists... all in one flow):</p> <pre><code>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</code></pre> <p>Notice What Happened</p> <p>In the above workflow, the user never typed <code>/ctx-reflect</code> or <code>ctx learning add</code>.</p> <p>The agent moved through Load, Orient, Pick, Work, Commit, and Reflect driven by natural conversation.</p> <p>\"Let's wrap up\" was enough to trigger the full reflect-and-persist flow.</p> <p>The agent surfaced persist-worthy items at milestones: after a design choice, after discovering a gotcha: without waiting to be asked.</p> <p>This is the intended experience. </p> <p>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.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>Quick-reference checklist for a complete session:</p> <ul> <li> Load: <code>/ctx-remember</code>: load context and confirm readback</li> <li> Orient: <code>/ctx-status</code>: check file health and token usage</li> <li> Pick: <code>/ctx-next</code>: choose what to work on</li> <li> Work: implement, test, iterate (scope with \"only change X\")</li> <li> Commit: <code>/ctx-commit</code>: commit and capture decisions/learnings</li> <li> Reflect: <code>/ctx-reflect</code>: identify what to persist (at milestones)</li> <li> Wrap up: <code>/ctx-wrap-up</code>: end-of-session ceremony</li> </ul> <p>Conversational equivalents: you can drive the same lifecycle with plain language:</p> Step Slash command Natural language Load <code>/ctx-remember</code> \"Do you remember?\" / \"What were we working on?\" Orient <code>/ctx-status</code> \"How's our context looking?\" Pick <code>/ctx-next</code> \"What should we work on?\" / \"Let's do the caching task\" Work (none) \"Only change files in internal/cache/\" Commit <code>/ctx-commit</code> \"Commit this\" / \"Ship it\" Reflect <code>/ctx-reflect</code> \"What did we learn?\" / (agent offers at milestones) Wrap up <code>/ctx-wrap-up</code> (use the slash command for completeness) <p>The agent understands both columns.</p> <p>In practice, most sessions use a mix:</p> <ul> <li>Explicit Commands when you want precision;</li> <li>Natural Language when you want flow and agentic autonomy.</li> </ul> <p>The agent will also initiate steps on its own (particularly \"Reflect\") when it recognizes a milestone.</p> <p>Short sessions (quick bugfix) might only use: Load, Work, Commit.</p> <p>Long sessions should Reflect after each major milestone and persist learnings and decisions before ending.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tips","level":2,"title":"Tips","text":"<p>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.</p> <p>Browse previous sessions by topic. If you need context from a prior session, <code>ctx journal source --show auth</code> will match by keyword. You do not need to remember the exact date or slug.</p> <p>Reflection is optional but valuable. You can skip <code>/ctx-reflect</code> 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.</p> <p>Let the hook handle context loading. The <code>PreToolUse</code> hook runs <code>ctx agent</code> automatically with a cooldown, so context loads on first tool use without you asking. The <code>/ctx-remember</code> prompt at session start is for your benefit (to get a readback), not because the assistant needs it.</p> <p>The agent is a proactive partner, not a passive tool. A <code>ctx</code>-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.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#next-up","level":2,"title":"Next Up","text":"<p>Session Ceremonies →: The two bookend rituals for every session: <code>/ctx-remember</code> at the start, <code>/ctx-wrap-up</code> at the end.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#see-also","level":2,"title":"See Also","text":"<ul> <li>Session Ceremonies: why <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> are explicit slash commands, not conversational</li> <li>CLI Reference: full documentation for all <code>ctx</code> commands</li> <li>Prompting Guide: effective prompts for ctx-enabled projects</li> <li>Tracking Work Across Sessions: deep dive on task management</li> <li>Persisting Decisions, Learnings, and Conventions: deep dive on knowledge capture</li> <li>Detecting and Fixing Drift: keeping context files accurate</li> <li>Pausing Context Hooks: shortcut the full lifecycle for quick tasks that don't need ceremony overhead</li> </ul>","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":"<p>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.</p>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tldr","level":2,"title":"TL;DR","text":"Command What it does <code>ctx hook pause</code> or <code>/ctx-pause</code> Silence all nudge hooks for this session <code>ctx hook resume</code> or <code>/ctx-resume</code> Restore normal hook behavior <p>Pause is session-scoped: It only affects the current session. Other sessions (same project, different terminal) are unaffected.</p>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-gets-paused","level":2,"title":"What Gets Paused","text":"<p>All nudge and reminder hooks go silent:</p> <ul> <li>Context size checkpoints</li> <li>Ceremony adoption nudges</li> <li>Persistence reminders</li> <li>Journal maintenance reminders</li> <li>Knowledge growth nudges</li> <li>Map staleness nudges</li> <li>Version update nudges</li> <li>Resource pressure warnings</li> <li>QA reminders</li> <li>Post-commit nudges</li> <li>Specs nudges</li> <li>Backup age warnings</li> <li>Context load gate</li> <li>Pending reminders relay</li> </ul>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-still-fires","level":2,"title":"What Still Fires","text":"<p>Security hooks always run, even when paused:</p> <ul> <li><code>block-non-path-ctx</code>: prevents <code>./ctx</code> invocations</li> <li><code>block-dangerous-commands</code>: blocks <code>sudo</code>, force push, etc.</li> </ul>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#workflow","level":2,"title":"Workflow","text":"<pre><code># 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</code></pre>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#graduated-reminder","level":2,"title":"Graduated Reminder","text":"<p>Paused hooks aren't completely invisible. A minimal indicator appears so you always know the state:</p> Paused turns What you see 1-5 <code>ctx:paused</code> 6+ <code>ctx:paused (N turns): resume with /ctx-resume</code> <p>This prevents the \"forgot I paused\" problem during long sessions.</p>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tips","level":2,"title":"Tips","text":"<ul> <li> <p>Resume before wrapping up. If your quick task turns into real work, resume hooks before running <code>/ctx-wrap-up</code>. The wrap-up ceremony needs active hooks to capture learnings properly.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ul>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#see-also","level":2,"title":"See Also","text":"<p>See also: Session Ceremonies: the bookend rituals that pause lets you skip when they aren't needed.</p> <p>See also: Customizing Hook Messages: if you want to change what hooks say rather than silencing them entirely.</p> <p>See also: The Complete Session: the full session workflow that pause shortcuts for quick tasks.</p>","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":"<p>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.</p> <p>How do you leave a message that your next session opens with?</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx remind \"refactor the swagger definitions\"\nctx remind list\nctx remind dismiss 1 # or batch: ctx remind dismiss 1 3-5\n</code></pre> <p>Reminders surface automatically at session start: VERBATIM, every session, until you dismiss them.</p>","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 <code>ctx remind</code> CLI command Add a reminder (default action) <code>ctx remind list</code> CLI command Show all pending reminders <code>ctx remind dismiss</code> CLI command Remove a reminder by ID (or <code>--all</code>) <code>/ctx-remind</code> 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":"<p>Tell your agent what to remember, or run it directly:</p> <pre><code>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</code></pre> <p>Or from the terminal:</p> <pre><code>ctx remind \"refactor the swagger definitions\"\n</code></pre>","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":"<p>If the reminder shouldn't fire until a specific date:</p> <pre><code>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</code></pre> <p>The reminder stays silent until that date, then fires every session.</p> <p>The agent converts natural language dates (\"tomorrow\", \"next week\", \"after the release on Friday\") to <code>YYYY-MM-DD</code>. If it's ambiguous, it asks.</p>","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":"<p>Next session, the reminder appears automatically before anything else:</p> <pre><code>┌─ Reminders ──────────────────────────────────────\n│ [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n</code></pre> <p>No action needed: The <code>check-reminders</code> hook fires on <code>UserPromptSubmit</code> and the agent relays the box verbatim.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-4-dismiss-when-done","level":3,"title":"Step 4: Dismiss When Done","text":"<p>After you've acted on a reminder (or decided to skip it):</p> <pre><code>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</code></pre> <p>Or clear everything:</p> <pre><code>ctx remind dismiss --all\n</code></pre>","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":"<pre><code>ctx remind list\n</code></pre> <pre><code> [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</code></pre> <p>Date-gated reminders that haven't reached their date show <code>(not yet due)</code>.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#using-ctx-remind-in-a-session","level":2,"title":"Using <code>/ctx-remind</code> in a Session","text":"<p>Invoke the <code>/ctx-remind</code> skill, then describe what you want:</p> <pre><code>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</code></pre> You say (after <code>/ctx-remind</code>) What the agent does \"remind me to update the API docs\" <code>ctx remind \"update the API docs\"</code> \"remind me next week to check staging\" <code>ctx remind \"check staging\" --after 2026-03-02</code> \"what reminders do I have?\" <code>ctx remind list</code> \"dismiss reminder 3\" <code>ctx remind dismiss 3</code> \"dismiss reminders 3, 5 through 7\" <code>ctx remind dismiss 3 5-7</code> \"clear all reminders\" <code>ctx remind dismiss --all</code>","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 <code>ctx remind</code> Jot down a quick value or sensitive token <code>ctx pad</code> Track work with status and completion <code>TASKS.md</code> Record a decision or lesson for all sessions Context files <p>Decision guide:</p> <ul> <li>If it should announce itself at session start → <code>ctx remind</code></li> <li>If it's a quiet note you'll check manually → <code>ctx pad</code></li> <li>If it's a work item you'll mark done → <code>TASKS.md</code></li> </ul> <p>Reminders Are Sticky Notes, Not Tasks</p> <p>A reminder has no status, no priority, no lifecycle. It's a message to \"future you\" that fires until dismissed. </p> <p>If you need tracking, use a task in <code>TASKS.md</code>.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tips","level":2,"title":"Tips","text":"<ul> <li>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.</li> <li>Date gating is session-scoped, not clock-scoped: <code>--after 2026-02-25</code> means \"don't show until sessions on or after Feb 25.\" It does not mean \"alarm at midnight on Feb 25.\"</li> <li>The agent handles date parsing: Say \"next week\" or \"after Friday\": The agent converts it to <code>YYYY-MM-DD</code>. The CLI only accepts the explicit date format.</li> <li>Reminders are committed to git: They travel with the repo. If you switch machines, your reminders follow.</li> <li>IDs never reuse: After dismissing reminder 3, the next reminder gets ID 4 (or higher). No confusion from recycled numbers.</li> </ul>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#next-up","level":2,"title":"Next Up","text":"<p>Using the Scratchpad →: For quiet notes and sensitive values that don't need session-start announcements.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#see-also","level":2,"title":"See Also","text":"<ul> <li>CLI Reference: <code>ctx</code> remind: full command syntax and flags</li> <li>The Complete Session: how reminders fit into the session lifecycle</li> <li>Managing Tasks: for work items that need status tracking</li> </ul>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/spec-driven-development/","level":1,"title":"Spec-Driven Development","text":"","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#the-problem","level":2,"title":"The Problem","text":"<p>A feature big enough to span several milestones doesn't fail at the keyboard. It fails at the seams: the bet gets re-argued halfway through implementation, a \"plan\" for milestone three turns out to be fiction by the time you reach it, a decision the code silently assumed was never written down, and two different files each claim to be the authoritative list of what's done.</p> <p>The five skills that make up the design-to-implementation pipeline each solve one seam. But the pipeline only holds together if you understand which skill owns which decision, and at what altitude. Read the skill texts in isolation and the chain looks like five ways to write a Markdown file. Run them without the mental model and you end up reverse-engineering the whole thing from error messages.</p> <p>This recipe is that mental model, from the operator's seat. It walks one invented-but-realistic feature — a weekly context digest — through all five stages, and calls out the five load-bearing rules that aren't obvious from any single skill.</p> <p>Relationship to Design Before Coding</p> <p>Design Before Coding is the gentle on-ramp: brainstorm → spec → task-out → implement, four skills, one small feature. This recipe is the full chain including the debated-brief step (<code>/ctx-plan</code>), aimed at multi-milestone work where the seams actually bite. If you only ever ship single-session features, the on-ramp is enough.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-brainstorm # shape the vague idea\n/ctx-plan # debate the bet → a brief\n/ctx-spec --brief .context/briefs/<TS>-<slug>.md # commit the whole spec\n/ctx-task-out --spec specs/<feature>.md --milestone m0 # decompose ONE milestone\n/ctx-implement specs/plans/m0.md # execute, verify, checkpoint\n</code></pre> <p>Five skills, one direction. The canonical chain, with the altitude each step works at:</p> <pre><code>/ctx-brainstorm → /ctx-plan → /ctx-spec → /ctx-task-out → /ctx-implement\n (vague) (contested) (committed) (decomposed) (execution)\n</code></pre> <p><code>/ctx-plan</code> is not optional decoration. It is where the bet is attacked and written down as a debated brief, before the spec commits to it. Skip it and the spec inherits an unexamined bet; the argument you avoided resurfaces mid-implementation, where it is most expensive.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>/ctx-brainstorm</code> Skill Turn a vague idea into a validated design (conversation only) <code>/ctx-plan</code> Skill Attack the bet; write a debated brief to <code>.context/briefs/</code> <code>/ctx-spec</code> Skill Absorb the brief into a committed spec covering all milestones <code>/ctx-task-out</code> Skill Decompose one milestone into <code>specs/plans/<milestone>.md</code> <code>/ctx-implement</code> Skill Execute the plan step-by-step, updating the execution ledger <code>/ctx-decision-add</code> Skill Record a blocking decision the milestone forces into the open","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#the-running-example","level":2,"title":"The Running Example","text":"<p>Every stage below moves the same feature forward. Follow it end to end rather than reading the stages as isolated commands.</p> <p>Weekly Context Digest (<code>ctx digest</code>). Over dozens of sessions, <code>DECISIONS.md</code> and <code>LEARNINGS.md</code> pile up and nobody re-reads them. A periodic rollup resurfaces what changed this week so it doesn't rot.</p> <p>The feature has four milestones. Only the first is planned in detail right now; the rest exist in the spec as boundaries, not task lists.</p> Milestone Scope m0 Render: <code>ctx digest --since <date></code> prints a Markdown rollup to stdout m1 Schedule: surface the digest at session start, at most weekly m2 Deliver: push the digest through the <code>ctx hook notify</code> webhook m3 (deferred) Roll up across projects via <code>ctx hub</code>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-1-debate-the-bet-ctx-plan","level":2,"title":"Stage 1 — Debate the bet (<code>/ctx-plan</code>)","text":"<p>You have a rough shape (<code>/ctx-brainstorm</code> got you here) but you have not committed. <code>/ctx-plan</code> is a skeptical collaborator: it attacks the bet one question at a time — scope, failure modes, rejected alternatives, sequencing, reversibility — and stops when you can state the bet, what you rejected, the top failure modes, the cheapest validation, and the unwind cost, without help.</p> <pre><code>You: /ctx-plan\n I want a weekly digest that summarizes what changed in the\n context files.\n\nAgent: One question at a time. Generated from the structured files, or\n summarized by an LLM from free text?\n\nYou: ...generated. An LLM summary would drift and I couldn't cite it.\n\nAgent: Then the cheapest thing that proves the bet is m0 render-only —\n no schedule, no delivery. What would tell you the digest is\n worth building delivery for?\n\nYou: Whether I actually read it. Ship m0, live with it a week, then\n decide on m1.\n</code></pre> <p>The deliverable is not a task list. It is a debated brief at <code>.context/briefs/<TS>-context-digest.md</code>: the bet (render from structured files, not LLM summary), the rejections (LLM summary; a separate digest datastore), the failure modes (empty window, giant window, digest nobody reads), the validation route (ship m0, measure readership), and the unwind cost.</p> <p>The bet is debated once, here, for the whole feature. Not once per milestone. That is the altitude rule — see below.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-2-commit-the-spec-ctx-spec-brief","level":2,"title":"Stage 2 — Commit the spec (<code>/ctx-spec --brief</code>)","text":"<p><code>/ctx-spec --brief <path></code> treats the brief as authoritative and skips the interactive Q&A. It lifts the brief into the spec template verbatim where the brief speaks, and writes <code>TBD</code> where the brief is silent — it does not invent. The result is <code>specs/context-digest.md</code>, covering all four milestones, plus the open questions the bet left unresolved:</p> <pre><code>Open Questions\n TBD-1 Default digest window — 7 days, or \"since last run\"?\n TBD-2 Delivery transport — webhook only, or email too?\n TBD-3 Cross-project identity/dedup for the hub rollup\n</code></pre> <p>Note what the spec is not: it is not a task breakdown, and it does not resolve the TBDs. It commits the what/why at spec altitude and hands the TBDs downstream, each to be forced open at the milestone that actually embeds it. A small, single-session spec would stop here and go straight to <code>/ctx-implement</code>. This one spans milestones, so it goes to <code>/ctx-task-out</code>.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-3-task-out-one-milestone-ctx-task-out","level":2,"title":"Stage 3 — Task out one milestone (<code>/ctx-task-out</code>)","text":"<p>This is the step the other four skills leave unowned: <code>/ctx-plan</code> disclaims implementation planning, <code>/ctx-spec</code> stops at spec altitude, and <code>/ctx-implement</code> opens with \"use when you have a plan document.\" <code>/ctx-task-out</code> produces that plan — for one milestone at a time.</p> <pre><code>You: /ctx-task-out --spec specs/context-digest.md --milestone m0\n\nAgent: Blocking-TBD gate for m0:\n TBD-1 (default window) — DEFERRABLE. m0 takes an explicit\n --since; no task assumes a default. Blocking at m1.\n TBD-2 (transport) — DEFERRABLE. m0 prints to stdout.\n Blocking at m2.\n TBD-3 (hub identity) — DEFERRABLE. Blocking at m3.\n No blocker for m0. Decomposing.\n\n Wrote specs/plans/m0.md: data model, CLI contract, test matrix,\n 10 tasks (T01–T10) with falsifiable acceptance criteria and an\n `st` column. TASKS.md gained one epic anchor:\n \"Digest m0: render — Plan: specs/plans/m0.md (T01–T10)\".\n</code></pre> <p>Two gates run here, and both are refusals, not warnings:</p> <ul> <li>Blocking-TBD gate. Every open question is classified blocking or deferrable for this milestone. A TBD is blocking if any task in the milestone would embed an assumption about its answer. The skill refuses to decompose past a blocker — it lists them, names who can resolve them, and stops. Resolution lands as a spec edit or a <code>DECISIONS.md</code> entry first; the plan only points at that record. A decision that exists nowhere but the plan is minting, and the gate exists to stop it.</li> <li>Rolling-wave gate. If a prior milestone's plan exists and its definition of done (DoD) is not checked off, the skill refuses to decompose the next one. Tasking a distant milestone produces fiction: the current milestone's measurements are allowed to reshape everything downstream.</li> </ul>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-4-implement-the-milestone-ctx-implement","level":2,"title":"Stage 4 — Implement the milestone (<code>/ctx-implement</code>)","text":"<p><code>/ctx-implement specs/plans/m0.md</code> breaks the plan into atomic steps, verifies each (build, test, or the task's own acceptance criterion, run verbatim), and checkpoints every 3–5 steps. Its bookkeeping is what keeps the two surfaces honest:</p> <ul> <li>It flips a task's <code>st</code> cell to <code>[x]</code> only when the acceptance criterion demonstrably passed — the command ran, the test is green, the behavior was observed. <code>st</code> never moves backward silently.</li> <li>When every id in an epic's range is <code>[x]</code> (or <code>[o]</code>, obsoleted by amendment), it marks that TASKS.md epic <code>[x]</code>. Sync is one-way, plan → TASKS.md.</li> <li>It leaves the DoD boxes alone. DoD is confirmed by measurement or by you — never derived from the tasks that \"cover\" it being done.</li> </ul> <p>For the digest, m0's DoD is not \"T01–T10 are all <code>[x]</code>.\" It is: you ran <code>ctx digest --since <date></code> against a real project and confirmed the output is readable and correct. You check that box after reading a real digest — because the whole bet was \"is this worth reading?\" and only measurement answers it.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-5-roll-the-wave-the-next-milestone","level":2,"title":"Stage 5 — Roll the wave (the next milestone)","text":"<p>A week later you have read a few digests and decided m1 is worth building. Now — and only now — you check m0's DoD box. That single act opens the rolling-wave gate for m1:</p> <pre><code>You: /ctx-task-out --spec specs/context-digest.md --milestone m1\n\nAgent: Rolling-wave gate: m0 DoD is checked. Proceeding.\n Blocking-TBD gate for m1:\n TBD-1 (default window) — NOW BLOCKING. m1 schedules, so a task\n must assume a default window. Resolve before I decompose.\n Stopping. Resolve TBD-1 (spec edit or DECISIONS.md), then re-run.\n\nYou: /ctx-decision-add \"Digest default window is 'since last run',\n falling back to 7 days on first run\"\n\nAgent: Recorded D-014. Re-run /ctx-task-out --milestone m1 when ready.\n</code></pre> <p>The debate that would have been a per-milestone re-litigation of the bet is instead a single, scoped decision — exactly the one m1 embeds — forced into <code>DECISIONS.md</code> before any task can silently assume an answer. That is the blocking-TBD gate doing the job per-milestone debates used to do, without reopening the bet.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#the-rules-the-diagram-doesnt-show","level":2,"title":"The Rules the Diagram Doesn't Show","text":"<p>The arrows tell you the order. These five rules tell you why the order holds — and they are what a newcomer has to reverse-engineer.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#1-altitude-the-bet-is-debated-once","level":3,"title":"1. Altitude: the bet is debated once","text":"<p>The brief is per-bet, never per-milestone. <code>/ctx-plan</code> debates the bet one time; <code>/ctx-spec</code> commits it across every milestone; <code>/ctx-task-out</code> decomposes — it does not redesign the bet. If decomposition makes you want to re-argue scope or behavior, that is a signal to route back up to <code>/ctx-plan</code>, not to quietly change course in the plan. Milestones are altitudes of execution, not fresh betting opportunities.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#2-plans-are-just-in-time-behind-the-rolling-wave-gate","level":3,"title":"2. Plans are just-in-time, behind the rolling-wave gate","text":"<p>You plan the milestone you are about to build, and no further. A plan for a milestone three steps out is written against measurements you have not taken yet — it is fiction with a task table. The rolling-wave gate enforces this mechanically: milestone N+1 cannot be tasked out while milestone N's DoD is unmet. (You can override explicitly; the override is logged in the plan's Amendments section, so the fiction is at least on the record.)</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#3-blocking-tbd-gates-replace-per-milestone-debates","level":3,"title":"3. Blocking-TBD gates replace per-milestone debates","text":"<p>Because the bet is debated once, milestones don't get their own debates. What they get is the blocking-TBD gate: each <code>/ctx-task-out</code> run forces open exactly the decisions that milestone's tasks would otherwise embed as silent assumptions — no more, no fewer. A deferrable TBD doesn't vanish; it is carried into the plan (Out of scope or Risks), annotated with the milestone at which it graduates to blocking. This is how a big, half-decided spec becomes buildable without a design committee at every step.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#4-two-surfaces-one-truth","level":3,"title":"4. Two surfaces, one truth","text":"<p>There are two places milestone progress appears, and only one is authoritative:</p> <ul> <li>The plan (<code>specs/plans/<milestone>.md</code>) is the execution ledger. Its task table has an <code>st</code> column — <code>[ ]</code> pending, <code>[x]</code> done, <code>[o]</code> obsoleted — and its Scope & DoD section carries the DoD checkboxes. This is the single source of truth for what's done.</li> <li>TASKS.md epics are one-way projections. Each epic anchor carries a disjoint task-id range (<code>Plan: specs/plans/m0.md (T01–T10)</code>); the ranges partition the plan's ids with none double-counted. An epic is checked <code>[x]</code> only when its whole range is <code>[x]</code>/<code>[o]</code> in the plan. Sync flows plan → TASKS.md, never back.</li> </ul> <p>And the load-bearing exception: DoD is confirmed by measurement or by you, never derived from task completion. All ten tasks green does not check the DoD box. The rolling-wave gate reads only the DoD box — so if you let task completion auto-derive it, you have quietly disabled the gate that stops you from planning fiction.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#5-when-a-new-brief-is-legitimate","level":3,"title":"5. When a new brief is legitimate","text":"<p>Going back to <code>/ctx-plan</code> mid-feature is not failure — but only for the right reasons. A new brief is warranted when:</p> <ul> <li>A deferred bet returns. m3 (the hub rollup) was parked as Out of scope. Months later you want it. That is a new bet — deferred machinery coming back — so it earns a fresh <code>/ctx-plan</code> pass and its own brief. It is not an amendment to m0.</li> <li>Evidence falsifies the committed bet. If mid-m2 the measurements show webhook delivery is the wrong transport entirely, that disagreement is with the spec, and it routes up through <code>/ctx-plan</code>.</li> </ul> <p>What is never legitimate is relitigating the bet from below — at the implement seat, by weakening a task's acceptance criterion until it passes, or by inventing a decision in the plan that the spec never made. Amendments cover implementation reality (a task obsoleted, a new task appended, a measurement gate that fired); the bet is contested only at plan altitude, in the open.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#tips","level":2,"title":"Tips","text":"<ul> <li>Don't skip <code>/ctx-plan</code> to \"save time.\" The argument you skip doesn't disappear; it moves to implementation, where it costs the most. Ten minutes of adversarial interview is cheap insurance.</li> <li>Let the DoD box be earned. The temptation to tick it when the tasks are all green is exactly the failure the rolling-wave gate guards against. Leave it for measurement or your own confirmation.</li> <li>A blocking TBD is a feature, not a blocker. When <code>/ctx-task-out</code> refuses, it just told you the one decision this milestone can't fake. Record it (<code>/ctx-decision-add</code>) and re-run — that is the workflow working.</li> <li>Never edit an acceptance criterion in place once its task has started. Weakening the test until it passes is the exact failure the amendment rule exists to prevent. A criterion change is an <code>/ctx-task-out</code> amendment run, logged with date · what · why.</li> <li>One milestone in flight at a time. If you find yourself wanting to task out two milestones before finishing the first, that is the rolling-wave gate telling you the first isn't actually done.</li> </ul>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#see-also","level":2,"title":"See Also","text":"<ul> <li>Design Before Coding: the four-skill on-ramp; start there if the feature fits one session.</li> <li>Scrutinizing a Plan: a deeper look at the <code>/ctx-plan</code> adversarial interview and the debated brief.</li> <li>Tracking Work Across Sessions: the TASKS.md epic anchors the plan projects into.</li> <li>Persisting Decisions, Learnings, and Conventions: where a blocking TBD gets recorded when the gate forces it open.</li> <li>Skills Reference: /ctx-plan: the debated-brief contract.</li> <li>Skills Reference: /ctx-task-out: blocking-TBD and rolling-wave gates, the execution ledger.</li> <li>Skills Reference: /ctx-implement: ledger duties and step verification.</li> </ul>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/state-maintenance/","level":1,"title":"State Directory Maintenance","text":"","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-problem","level":2,"title":"The Problem","text":"<p>Every session creates tombstone files in <code>.context/state/</code> - 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.</p> <p>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.</p>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#commands-used","level":2,"title":"Commands Used","text":"Tool Type Purpose <code>ctx prune</code> Command Remove old per-session state files <code>ctx status</code> Command Quick health overview including state dir","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#understanding-state-files","level":2,"title":"Understanding State Files","text":"<p>State files fall into two categories:</p> <p>Session-scoped (contain a UUID in the filename): Created per-session to suppress repeat nudges. Safe to prune once the session ends. Examples:</p> <pre><code>context-check-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\nheartbeat-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\npersistence-nudge-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\n</code></pre> <p>Global (no UUID): Persist across sessions. <code>ctx prune</code> preserves these automatically. Some are legitimate state (<code>events.jsonl</code>, <code>memory-import.json</code>); others may be stale tombstones that need manual review.</p>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-1-preview","level":3,"title":"Step 1: Preview","text":"<p>Always dry-run first to see what would be removed:</p> <pre><code>ctx prune --dry-run\n</code></pre> <p>The output shows each file, its age, and a summary:</p> <pre><code> 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</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-2-prune","level":3,"title":"Step 2: Prune","text":"<p>Choose an age threshold. The default is 7 days:</p> <pre><code>ctx prune # older than 7 days\nctx prune --days 3 # older than 3 days\nctx prune --days 1 # older than 1 day (aggressive)\n</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-3-review-global-files","level":3,"title":"Step 3: Review Global Files","text":"<p>After pruning, check what <code>prune</code> preserved:</p> <pre><code>ls .context/state/ | grep -v '[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}'\n</code></pre> <p>Legitimate global files (keep):</p> <ul> <li><code>events.jsonl</code> - event log</li> <li><code>memory-import.json</code> - import tracking state</li> </ul> <p>Stale global tombstones (safe to delete):</p> <ul> <li>Files like <code>backup-reminded</code>, <code>ceremony-reminded</code>, <code>version-checked</code> with no session UUID are one-shot markers. If they are from a previous session, they are stale and can be removed manually.</li> </ul> <pre><code>rm .context/state/backup-reminded .context/state/ceremony-reminded\n</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-4-verify","level":3,"title":"Step 4: Verify","text":"<pre><code>ls .context/state/ | wc -l # should be manageable\n</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#when-to-prune","level":2,"title":"When to Prune","text":"<ul> <li>Weekly: <code>ctx prune</code> with default 7-day threshold</li> <li>After heavy parallel work: Multiple concurrent sessions create many tombstones. Prune with <code>--days 1</code> afterward.</li> <li>When state directory exceeds ~100 files: A sign that pruning hasn't run recently</li> </ul>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tips","level":2,"title":"Tips","text":"<p>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.</p> <p>No context files are stored in state: The state directory contains only tombstones, counters, and diagnostic data. Nothing in <code>.context/state/</code> affects your decisions, learnings, tasks, or conventions.</p> <p>Test artifacts sneak in: Files like <code>context-check-statstest</code> or <code>heartbeat-unknown</code> are artifacts from development or testing. They lack UUIDs so <code>prune</code> preserves them. Delete manually.</p>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#see-also","level":2,"title":"See Also","text":"<ul> <li>Detecting and Fixing Drift: broader context maintenance including drift detection and archival</li> <li>Troubleshooting: diagnostic workflow using <code>ctx doctor</code> and event logs</li> <li>CLI Reference: system: full flag documentation for <code>ctx prune</code> and related commands</li> </ul>","path":["Recipes","Maintenance","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":"<p>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.</p> <p>Before You Start</p> <p>If you're unsure whether a rule belongs in <code>steering/</code>, <code>DECISIONS.md</code>, or <code>CONVENTIONS.md</code>, read the \"Steering vs decisions vs conventions\" admonition on the <code>ctx steering</code> 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.</p>","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":"<p><code>ctx init</code> scaffolds four foundation steering files for you the first time you initialize a project:</p> File Purpose <code>.context/steering/product.md</code> Product context, goals, target users <code>.context/steering/tech.md</code> Tech stack, constraints, key dependencies <code>.context/steering/structure.md</code> Directory layout, naming conventions <code>.context/steering/workflow.md</code> Branch strategy, commit rules, pre-commit <p>Each file opens with an inline HTML comment that explains the three inclusion modes, what <code>priority</code> means, and the <code>tools</code> scope. The comment is invisible in rendered Markdown but visible when you edit the file. Delete it once the file is yours.</p> <p>All four default to <code>inclusion: always</code> and <code>priority: 10</code>, 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 <code>ctx</code> setup.</p> <p>What to fill in, by file:</p> <p><code>product.md</code>: The elevator pitch plus hard scope:</p> <ul> <li>One-sentence product description.</li> <li>Primary users and their top job-to-be-done.</li> <li>Two or three \"this is explicitly out of scope\" items so the AI doesn't wander.</li> </ul> <p><code>tech.md</code>: Technology and constraints:</p> <ul> <li>Languages and versions (<code>Go 1.22</code>, <code>Node 20</code>, etc.).</li> <li>Frameworks and key libraries.</li> <li>Runtime and deployment target.</li> <li>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.</li> </ul> <p><code>structure.md</code>: Layout and naming:</p> <ul> <li>Top-level directories and their purpose.</li> <li>Where new files should go (and where they should NOT).</li> <li>Naming conventions for packages, files, types.</li> </ul> <p><code>workflow.md</code>: Process rules:</p> <ul> <li>Branch strategy (main-only, trunk-based, feature branches).</li> <li>Commit message format, signed-off-by requirement.</li> <li>Pre-commit and pre-push checks.</li> <li>Review expectations.</li> </ul> <p>After editing, the next AI tool call in Claude Code will pick up the new rules automatically via the plugin's <code>PreToolUse</code> hook, with no sync step and no restart. Other tools (Cursor, Cline, Kiro) need <code>ctx steering sync</code> to export into their native format.</p> <p>Prefer a Bare <code>.context/steering/</code> Directory?</p> <p>Re-run <code>ctx init --no-steering-init</code> and delete the scaffolded files. <code>ctx init</code> leaves existing files alone, so the flag is only needed if you want to opt out of the initial scaffold.</p> <p>The rest of this recipe walks through creating an additional, scenario-specific steering file beyond the four foundation defaults.</p>","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#scenario","level":2,"title":"Scenario","text":"<p>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.</p> <p>Claude Code Users: Pick <code>always</code>, Not <code>auto</code></p> <p>This walkthrough uses <code>inclusion: auto</code> 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 <code>description</code> keyword match themselves).</p> <p>On Claude Code, <code>auto</code> does not fire through the plugin's <code>PreToolUse</code> hook. The hook passes an empty prompt to <code>ctx agent</code>, so only <code>always</code> files match. Claude can still reach an <code>auto</code> file by calling the <code>ctx_steering_get</code> MCP tool, but that requires Claude to decide to call it; there's no automatic injection.</p> <p>If Claude Code is your tool, set <code>inclusion: always</code> in Step 2 instead of <code>auto</code>. 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.</p> <p>See the <code>ctx steering</code> reference \"Prefer <code>inclusion: always</code> for Claude Code\" section for the full trade-off.</p>","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":"<pre><code>ctx steering add api-validation\n</code></pre> <p>That creates <code>.context/steering/api-validation.md</code> with default frontmatter:</p> <pre><code>---\nname: api-validation\ndescription:\ninclusion: manual\ntools: []\npriority: 50\n---\n</code></pre> <p>The defaults are deliberately conservative: <code>inclusion: manual</code> means the file won't be applied until you opt in, which keeps the rules out of the prompt until you've reviewed them.</p>","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":"<p>Open the file and write the rule body plus a focused description. The description is what <code>inclusion: auto</code> matches against later.</p> <pre><code>---\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</code></pre> <p>Notes on the choices:</p> <ul> <li><code>inclusion: auto</code>: this rule should fire automatically on HTTP-handler-shaped prompts, not always.</li> <li><code>priority: 20</code>: lower than the default, so this rule appears near the top of the prompt alongside other high-priority rules.</li> <li>Description is keyword-rich (\"HTTP handler input validation and request parsing\"); the <code>auto</code> matcher scores prompts against these words.</li> </ul>","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":"<p>Before committing the file, validate your description catches the prompts you care about:</p> <pre><code>ctx steering preview \"add an endpoint for updating user email\"\n</code></pre> <p>Expected output:</p> <pre><code>Steering files matching prompt \"add an endpoint for updating user email\":\n api-validation inclusion=auto priority=20 tools=all\n</code></pre> <p>Good, the prompt matches. Try a negative case:</p> <pre><code>ctx steering preview \"fix a bug in the JSON renderer\"\n</code></pre> <p>Expected: empty match (or whatever else is currently <code>auto</code>). If <code>api-validation</code> incorrectly fires for unrelated prompts, tighten the description. If it misses prompts it should catch, add more keywords.</p>","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":"<pre><code>ctx steering list\n</code></pre> <p>Should show <code>api-validation</code> alongside any other files, with its inclusion mode and priority. If the list is wrong, check the frontmatter for typos.</p>","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":"<p>Steering files are authored once in <code>.context/steering/</code>, but how they reach the AI depends on which tool you use. There are two delivery mechanisms:</p>","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":"<p>These tools read a specific directory for rules. <code>ctx steering sync</code> exports your files into that directory with tool-specific frontmatter:</p> <pre><code>ctx steering sync\n</code></pre> <p>Depending on the active tool in <code>.ctxrc</code> or <code>--tool</code>:</p> Tool Target Cursor <code>.cursor/rules/</code> Cline <code>.clinerules/</code> Kiro <code>.kiro/steering/</code> <p>The sync is idempotent; unchanged files are skipped. Run it whenever you edit a steering file.</p>","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":"<p>Claude Code and Codex have no native rules primitive, so <code>ctx steering sync</code> is a no-op for them; it deliberately skips both. Instead, steering reaches these tools through two non-sync channels:</p> <ol> <li> <p><code>PreToolUse</code> hook (automatic). The <code>ctx setup claude-code</code> plugin installs a hook that runs <code>ctx agent --budget 8000</code> before each tool call. <code>ctx agent</code> 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.</p> </li> <li> <p><code>ctx_steering_get</code> 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.</p> </li> </ol> <p>Both channels activate when you run:</p> <pre><code>ctx setup claude-code --write\n</code></pre> <p>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.</p> <p>Running <code>ctx steering sync</code> with Claude Code</p> <p>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 <code>sync</code>. If you use both Claude Code and (say) Cursor, run <code>sync</code> to keep Cursor up to date; the Claude pipeline takes care of itself via the hook.</p>","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":"<p>Open your AI tool and ask it something the rule should fire on:</p> <p>\"Add a POST /users endpoint that accepts email and name.\"</p> <p>If the rule is working, the AI's first response should mention input validation, typed structs, and the <code>internal/validate/</code> package, because that's what the steering file told it to do.</p> <p>If nothing happens, the fix depends on which path you're on:</p> <p>Path A (Cursor/Cline/Kiro):</p> <ol> <li>Re-run <code>ctx steering preview</code> with the literal prompt to confirm the match.</li> <li>Run <code>ctx steering list</code> and verify <code>inclusion</code> is <code>auto</code>, not <code>manual</code>.</li> <li>Check the tool's own config directory (e.g. <code>.cursor/rules/</code>); the file should be there after <code>ctx steering sync</code>.</li> </ol> <p>Path B (Claude Code):</p> <ol> <li>Re-run <code>ctx steering preview</code> with the literal prompt to confirm the match.</li> <li>Verify the plugin is installed: <code>cat .claude/hooks.json</code> should include <code>ctx agent --budget 8000</code> under <code>PreToolUse</code>. If not, re-run <code>ctx setup claude-code --write</code>.</li> <li>Run <code>ctx agent --budget 8000</code> manually and grep the output for your rule body. If it's there, the data is fine; if it's missing, the <code>inclusion</code> mode or <code>description</code> is at fault.</li> <li>As a last resort, ask Claude directly: \"Call the <code>ctx_steering_get</code> 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.</li> </ol>","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#common-mistakes","level":2,"title":"Common Mistakes","text":"<p>Too-generic descriptions. <code>description: general coding</code> will match almost every prompt and flood the context window. Keep descriptions specific to the scenario the rule applies to.</p> <p>Overlapping rules. If two steering files match the same prompt and contradict each other, the result is confusing. Use <code>priority</code> to resolve, but better: merge the files or narrow the descriptions so they don't overlap.</p> <p>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 <code>ctx decision add</code>, not <code>ctx steering add</code>.</p> <p>Committing <code>inclusion: always</code> without thinking. Rules marked <code>always</code> fire on every prompt, consuming tier-6 budget permanently. Only use <code>always</code> for true invariants (security, safety, licensing). Everything else should be <code>auto</code> or <code>manual</code>.</p>","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx steering</code> reference: full command, flag, and frontmatter reference.</li> <li><code>ctx setup</code>: configure which tools the steering sync writes to.</li> <li>Authoring triggers: if you want script-based automation, not rule-based prompt injection.</li> </ul>","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":"<p><code>ctx</code> 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.</p> <p>How do you verify your hooks are actually running, audit what they do, and get alerted when they go silent?</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Or ask your agent: \"Are our hooks running?\"</p>","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 <code>ctx system <hook></code> CLI command Run a system hook manually <code>ctx sysinfo</code> CLI command Show system resource status <code>ctx usage</code> CLI command Stream or dump per-session token stats <code>ctx hook notify setup</code> CLI command Configure webhook for audit trail <code>ctx hook notify test</code> CLI command Verify webhook delivery <code>.ctxrc</code> <code>notify.events</code> Configuration Subscribe to <code>relay</code> for full hook audit <code>.context/logs/</code> 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":"<p>System hooks are plumbing commands that <code>ctx</code> registers with your AI tool (Claude Code, Cursor, etc.) via the plugin's <code>hooks.json</code>. They fire automatically at specific events during your AI session:</p> Event When Hooks <code>UserPromptSubmit</code> Before the agent sees your prompt 10 check hooks + heartbeat <code>PreToolUse</code> Before the agent uses a tool <code>block-non-path-ctx</code>, <code>qa-reminder</code> <code>PostToolUse</code> After a tool call succeeds <code>post-commit</code> <p>You never run these manually. Your AI tool runs them for you: That's the point.</p>","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":"<p>These fire before every prompt, but most are throttled to avoid noise.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-context-size-context-capacity-warning","level":4,"title":"<code>check-context-size</code>: Context Capacity Warning","text":"<p>What: Adaptive prompt counter. Silent for the first 15 prompts, then nudges with increasing frequency (every 5<sup>th</sup>, then every 3<sup>rd</sup>).</p> <p>Why: Long sessions lose coherence. The nudge reminds both you and the agent to persist context before the window fills up.</p> <p>Output: VERBATIM relay box with prompt count.</p> <pre><code>┌─ 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</code></pre> <p>Usage: Every prompt records token usage to <code>.context/state/stats-{session}.jsonl</code>. Monitor live with <code>ctx usage --follow</code> or query with <code>ctx usage --json</code>. Usage is recorded even during wrap-up suppression (event: <code>suppressed</code>).</p> <p>Billing guard: When <code>billing_token_warn</code> is set in <code>.ctxrc</code>, 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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-persistence-context-staleness-nudge","level":4,"title":"<code>check-persistence</code>: Context Staleness Nudge","text":"<p>What: Tracks when <code>.context/*.md</code> files were last modified. If too many prompts pass without a write, nudges the agent to persist.</p> <p>Why: Sessions produce insights that evaporate if not recorded. This catches the \"we talked about it but never wrote it down\" failure mode.</p> <p>Output: VERBATIM relay after 20+ prompts without a context file change.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-ceremonies-session-ritual-adoption","level":4,"title":"<code>check-ceremonies</code>: Session Ritual Adoption","text":"<p>What: Scans your last 3 journal entries for <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> usage. Nudges once per day if missing.</p> <p>Why: Session ceremonies are the highest-leverage habit in <code>ctx</code>. This hook bootstraps the habit until it becomes automatic.</p> <p>Output: Tailored nudge depending on which ceremony is missing.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-journal-unimported-session-reminder","level":4,"title":"<code>check-journal</code>: Unimported Session Reminder","text":"<p>What: Detects unimported Claude Code sessions and unenriched journal entries. Fires once per day.</p> <p>Why: Exported sessions become searchable history. Unenriched entries lack metadata for filtering. Both decay in value over time.</p> <p>Output: VERBATIM relay with counts and exact commands.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-resources-system-resource-pressure","level":4,"title":"<code>check-resources</code>: System Resource Pressure","text":"<p>What: Monitors memory, swap, disk, and CPU load. Only fires at DANGER severity (memory >= 90%, swap >= 75%, disk >= 95%, load >= 1.5x CPU count).</p> <p>Why: Resource exhaustion mid-session can corrupt work. This provides early warning to persist and exit.</p> <p>Output: VERBATIM relay listing critical resources.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-knowledge-knowledge-file-growth","level":4,"title":"<code>check-knowledge</code>: Knowledge File Growth","text":"<p>What: Counts entries in <code>LEARNINGS.md</code>, <code>DECISIONS.md</code>, and lines in <code>CONVENTIONS.md</code>. Fires once per day when thresholds are exceeded.</p> <p>Why: Large knowledge files dilute agent context. 35 learnings compete for attention; 15 focused ones get applied. Thresholds are configurable in <code>.ctxrc</code>.</p> <p>Default thresholds:</p> <pre><code># .ctxrc\nentry_count_learnings: 30\nentry_count_decisions: 20\nconvention_line_count: 200\n</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-version-binaryplugin-version-drift","level":4,"title":"<code>check-version</code>: Binary/Plugin Version Drift","text":"<p>What: Compares the <code>ctx</code> binary version against the plugin version. Fires once per day. Also checks encryption key age for rotation nudge.</p> <p>Why: Version drift means hooks reference features the binary doesn't have. The key rotation nudge prevents indefinite key reuse.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-reminders-pending-reminder-relay","level":4,"title":"<code>check-reminders</code>: Pending Reminder Relay","text":"<p>What: Reads <code>.context/reminders.json</code> and surfaces any due reminders via VERBATIM relay. No throttle: fires every session until dismissed.</p> <p>Why: Reminders are sticky notes to future-you. Unlike nudges (which throttle to once per day), reminders repeat deliberately until the user dismisses them.</p> <p>Output: VERBATIM relay box listing due reminders.</p> <pre><code>┌─ Reminders ──────────────────────────────────────\n│ [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-freshness-technology-constant-staleness","level":4,"title":"<code>check-freshness</code>: Technology Constant Staleness","text":"<p>What: Stats files listed in <code>.ctxrc</code> <code>freshness_files</code> and warns if any haven't been modified in over 6 months. Daily throttle. Silent when no files are configured (opt-in via <code>.ctxrc</code>).</p> <p>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.</p> <p>Config (<code>.ctxrc</code>):</p> <pre><code>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</code></pre> <p>Each entry has a <code>path</code> (relative to project root), <code>desc</code> (what constants live there), and optional <code>review_url</code> (where to check current values). When <code>review_url</code> is set, the nudge includes \"Review against: {url}\". When absent, just \"Touch the file to mark it as reviewed.\"</p> <p>Output: VERBATIM relay listing stale files, silent otherwise.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-map-staleness-architecture-map-drift","level":4,"title":"<code>check-map-staleness</code>: Architecture Map Drift","text":"<p>What: Checks whether <code>map-tracking.json</code> is older than 30 days and there are commits touching <code>internal/</code> since the last map refresh. Daily throttle prevents repeated nudges.</p> <p>Why: Architecture documentation drifts silently as code evolves. This hook detects structural changes that the map hasn't caught up with and suggests running <code>/ctx-architecture</code> to refresh.</p> <p>Output: VERBATIM relay when stale and modules changed, silent otherwise.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#heartbeat-session-heartbeat-webhook","level":4,"title":"<code>heartbeat</code>: Session Heartbeat Webhook","text":"<p>What: Fires on every prompt. Sends a webhook notification with prompt count, session ID, context modification status, and token usage telemetry. Never produces stdout.</p> <p>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.</p> <p>Output: None (webhook + event log only).</p> <p>Payload:</p> <pre><code>{\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</code></pre> <p>Token fields (<code>tokens</code>, <code>context_window</code>, <code>usage_pct</code>) are included when usage data is available from the session JSONL file.</p>","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":"<code>block-non-path-ctx</code>: PATH Enforcement (Hard Gate)","text":"<p>What: Blocks any Bash command that invokes <code>./ctx</code>, <code>./dist/ctx</code>, <code>go run ./cmd/ctx</code>, or an absolute path to <code>ctx</code>. Only PATH invocations are allowed.</p> <p>Why: Enforces <code>CONSTITUTION.md</code>'s invocation invariant. Running a dev-built binary in production context causes version confusion and silent behavior drift.</p> <p>Output: Block response (prevents the tool call):</p> <pre><code>{\"decision\": \"block\", \"reason\": \"Use 'ctx' from PATH, not './ctx'...\"}\n</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#qa-reminder-pre-commit-qa-gate","level":4,"title":"<code>qa-reminder</code>: Pre-Commit QA Gate","text":"<p>What: Fires on every <code>Edit</code> tool use. Reminds the agent to lint and test the entire project before committing.</p> <p>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.</p> <p>Output: Agent directive with hard QA gate instructions.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#post-commit-context-capture-after-commit","level":4,"title":"<code>post-commit</code>: Context Capture After Commit","text":"<p>What: Fires after any <code>git commit</code> (excludes <code>--amend</code>). Prompts the agent to offer context capture (decision? learning?) and suggest running lints/tests before pushing.</p> <p>Why: Commits are natural reflection points. The nudge converts mechanical git operations into context-capturing opportunities.</p>","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":"<p>If you don't need an external audit trail, enable the local event log for a self-contained record of hook activity:</p> <pre><code># .ctxrc\nevent_log: true\n</code></pre> <p>Once enabled, every hook that fires writes an entry to <code>.context/state/events.jsonl</code>. Query it with <code>ctx hook event</code>:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<p>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.</p>","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":"<pre><code>ctx hook notify setup\n# Enter your webhook URL (Slack, Discord, ntfy.sh, IFTTT, etc.)\n</code></pre> <p>See Webhook Notifications for service-specific setup.</p>","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 <code>relay</code> Events","text":"<pre><code># .ctxrc\nnotify:\n events:\n - relay # all hook output: VERBATIM relays, directives, blocks\n - nudge # just the user-facing VERBATIM relays\n</code></pre> <p>The <code>relay</code> event fires for every hook that produces output. This includes:</p> Hook Event sent <code>check-context-size</code> <code>relay</code> + <code>nudge</code> <code>check-persistence</code> <code>relay</code> + <code>nudge</code> <code>check-ceremonies</code> <code>relay</code> + <code>nudge</code> <code>check-journal</code> <code>relay</code> + <code>nudge</code> <code>check-resources</code> <code>relay</code> + <code>nudge</code> <code>check-knowledge</code> <code>relay</code> + <code>nudge</code> <code>check-version</code> <code>relay</code> + <code>nudge</code> <code>check-reminders</code> <code>relay</code> + <code>nudge</code> <code>check-freshness</code> <code>relay</code> + <code>nudge</code> <code>check-map-staleness</code> <code>relay</code> + <code>nudge</code> <code>heartbeat</code> <code>heartbeat</code> only <code>block-non-path-ctx</code> <code>relay</code> only <code>post-commit</code> <code>relay</code> only <code>qa-reminder</code> <code>relay</code> 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":"<p>With <code>relay</code> enabled, your webhook receives a JSON payload every time a hook fires:</p> <pre><code>{\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</code></pre> <p>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?</p>","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":"<p>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:</p>","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":"<p>The simplest check. After a few prompts into a session:</p> <pre><code>\"Did you receive any hook output this session? Print the last\ncontext checkpoint or persistence nudge you saw.\"\n</code></pre> <p>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:</p> <ul> <li>The hooks aren't firing (check installation);</li> <li>The session is too short (hooks throttle early);</li> <li>The hooks fired but the agent absorbed them silently.</li> </ul> <p>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.</p>","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":"<p>If you have <code>relay</code> events enabled, check your webhook receiver. Every hook that fires sends a timestamped notification. No notification = no fire.</p> <p>This is the ground truth. The webhook is called directly by the <code>ctx</code> binary, not by the agent. The agent cannot fake, suppress, or modify webhook deliveries.</p> <p>Compare what the webhook received against what the agent claims to have relayed. Discrepancies mean the agent is absorbing nudges instead of surfacing them.</p>","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":"<p>Hooks that support logging write to <code>.context/logs/</code>:</p> <pre><code># 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</code></pre> <pre><code># 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</code></pre> <p>Logs are append-only and written by the <code>ctx</code> binary, not the agent.</p>","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":"<p>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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-staleness-signal","level":3,"title":"The Staleness Signal","text":"<p>If <code>.context/logs/check-context-size.log</code> 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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#false-positive-protection","level":3,"title":"False Positive Protection","text":"<p>A naive \"hooks haven't fired in N days\" alert fires incorrectly when you simply haven't used <code>ctx</code>. The correct check needs two inputs:</p> <ol> <li>Last hook fire time: from <code>.context/logs/</code> or webhook history</li> <li>Last session activity: from journal entries or <code>ctx journal source</code></li> </ol> <p>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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#what-to-check","level":3,"title":"What to Check","text":"<p>When you suspect hooks aren't firing:</p> <pre><code># 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>nudge</code>, graduate to <code>relay</code>: The <code>nudge</code> event covers user-facing VERBATIM relays. Add <code>relay</code> when you want full visibility into agent directives and hard gates.</li> <li>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.</li> <li>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.</li> <li>Daily markers live in <code>.context/state/</code>: Throttle files are stored in <code>.context/state/</code> alongside other project-scoped state. If you need to force a hook to re-fire during testing, delete the corresponding marker file.</li> <li>The QA reminder is intentionally noisy: Unlike other hooks, <code>qa-reminder</code> fires on every <code>Edit</code> call with no throttle. This is deliberate: The commit quality degrades when the reminder fades from salience.</li> <li>Log files are safe to commit: <code>.context/logs/</code> contains only timestamps, session IDs, and status keywords. No secrets, no code.</li> </ul>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#next-up","level":2,"title":"Next Up","text":"<p>Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#see-also","level":2,"title":"See Also","text":"<ul> <li>Troubleshooting: full diagnostic workflow using <code>ctx doctor</code>, event logs, and <code>/ctx-doctor</code></li> <li>Customizing Hook Messages: override what hooks say without changing what they do</li> <li>Webhook Notifications: setting up and configuring the webhook system</li> <li>Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates</li> <li>Detecting and Fixing Drift: structural checks that complement runtime hook auditing</li> <li>CLI Reference: full <code>ctx system</code> command reference</li> </ul>","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":"<p>You have work that spans multiple sessions. Tasks get added during one session, partially finished in another, and completed days later.</p> <p>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. <code>TASKS.md</code> grows cluttered with completed checkboxes that obscure the remaining work.</p> <p>How do you manage work items that span multiple sessions without losing context?</p> <p>Prefer Skills over Raw Commands</p> <p>When working with an AI agent, use <code>/ctx-task-add</code> instead of raw <code>ctx task add</code>. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.</p>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tldr","level":2,"title":"TL;DR","text":"<p>Manage Tasks:</p> <pre><code>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</code></pre> <p>Pick Up the Next Task:</p> <pre><code>/ctx-next # pick what's next\n</code></pre> <p>Read on for the full workflow and conversational patterns.</p>","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 <code>ctx task add</code> Command Add a new task to <code>TASKS.md</code> <code>ctx task complete</code> Command Mark a task as done by number or text <code>ctx task snapshot</code> Command Create a point-in-time backup of <code>TASKS.md</code> <code>ctx task archive</code> Command Move completed tasks to archive file <code>/ctx-task-add</code> Skill AI-assisted task creation with validation <code>/ctx-archive</code> Skill AI-guided archival with safety checks <code>/ctx-next</code> 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":"<p>Every piece of follow-up work gets a task. Use <code>ctx task add</code> from the terminal or <code>/ctx-task-add</code> from your AI assistant. Tasks should start with a verb and be specific enough that someone unfamiliar with the session could act on them.</p> <pre><code># 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</code></pre> <p>The <code>/ctx-task-add</code> 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.</p> <p>If you say \"fix the bug,\" it will ask you to clarify which bug and where.</p> <p>Tasks Are Often Created Proactively</p> <p>In practice, many tasks are created proactively by the agent rather than by explicit CLI commands.</p> <p>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.</p> <p>You do not need to dictate <code>ctx task add</code> commands; the agent picks up on work context and suggests tasks naturally.</p>","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":"<p>Tasks live in phase sections inside <code>TASKS.md</code>.</p> <p>Phases provide logical groupings that preserve order and enable replay.</p> <p>A task does not move between sections. It stays in its phase permanently, and status is tracked via checkboxes and inline tags.</p> <pre><code>## 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</code></pre> <p>Use <code>--section</code> when adding a task to a specific phase:</p> <pre><code>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</code></pre> <p>Without <code>--section</code>, the task is inserted before the first unchecked task in <code>TASKS.md</code>.</p>","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":"<p>At the start of a session, or after finishing a task, use <code>/ctx-next</code> to get prioritized recommendations. </p> <p>The skill reads <code>TASKS.md</code>, checks recent sessions, and ranks candidates using explicit priority, blocking status, in-progress state, momentum from recent work, and phase order.</p> <p>You can also ask naturally: \"what should we work on?\" or \"what's the highest priority right now?\"</p> <pre><code>/ctx-next\n</code></pre> <p>The output looks like this:</p> <pre><code>**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</code></pre> <p>In-progress tasks almost always come first: </p> <p>Finishing existing work takes priority over starting new work.</p>","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":"<p>When a task is done, mark it complete by number or partial text match:</p> <pre><code># By task number (as shown in TASKS.md)\nctx task complete 3\n\n# By partial text match\nctx task complete \"agent cooldown\"\n</code></pre> <p>The task's checkbox changes from <code>[ ]</code> to <code>[x]</code>. Tasks are never deleted: they stay in their phase section so history is preserved.</p> <p>Be Conversational</p> <p>You rarely need to run <code>ctx task complete</code> yourself during an interactive session.</p> <p>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.</p> <p>The CLI commands are most useful for manual housekeeping, scripted workflows, or when you want precision.</p>","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":"<p>Before a major refactor or any change that might break things, snapshot your current task state. This creates a copy of <code>TASKS.md</code> in <code>.context/archive/</code> without modifying the original.</p> <pre><code># Default snapshot\nctx task snapshot\n\n# Named snapshot (recommended before big changes)\nctx task snapshot \"before-refactor\"\n</code></pre> <p>This creates a file like <code>.context/archive/tasks-before-refactor-2026-02-08-1430.md</code>. If the refactor goes sideways, and you need to confirm what the task state looked like before you started, the snapshot is there.</p> <p>Snapshots are cheap: Take them before any change you might want to undo or review later.</p>","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 <code>TASKS.md</code> Gets Cluttered","text":"<p>After several sessions, <code>TASKS.md</code> accumulates completed tasks that make it hard to see what is still pending.</p> <p>Use <code>ctx task archive</code> to move all <code>[x]</code> items to a timestamped archive file.</p> <p>Start with a dry run to preview what will be moved:</p> <pre><code>ctx task archive --dry-run\n</code></pre> <p>Then archive:</p> <pre><code>ctx task archive\n</code></pre> <p>Completed tasks move to <code>.context/archive/tasks-2026-02-08.md</code>. Phase headers are preserved in the archive for traceability. Pending tasks (<code>[ ]</code>) remain in <code>TASKS.md</code>.</p> <p>The <code>/ctx-archive</code> skill adds two safety checks before archiving: it verifies that completed tasks are genuinely cluttering the view and that nothing was marked <code>[x]</code> prematurely.</p>","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":"<p>The steps above show the CLI commands for task management.</p> <p>In practice, most task management happens conversationally:</p> <p>An agent that has loaded the context files does not need you to type <code>ctx task add</code>. It tracks work naturally and offers the right operations.</p>","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":"<p>These conversational prompts replace explicit commands during interactive sessions:</p> Instead of typing... Just say... <code>ctx task add \"Write tests for X\" --session-id ID --branch BR --commit HASH</code> \"We should add tests for this: track that?\" <code>/ctx-next</code> \"What should we work on?\" <code>ctx task complete \"rate limiting\"</code> \"The rate limiter is done, what's next?\" <code>ctx task archive</code> \"<code>TASKS.md</code> is getting long, can you clean it up?\" <code>ctx task add ... --session-id ID --branch BR --commit HASH && ctx task add ...</code> \"Add follow-ups for what we just built.\" <p>The agent translates these into the right <code>ctx</code> operations behind the scenes.</p>","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":"<p>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:</p> <pre><code>**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</code></pre> <p>This is how an agent behaves once it has read the Agent Playbook.</p> <p>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?</p> <p>When the answer is yes, it acts.</p>","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":"<p>You don't always know what's worth persisting.</p> <p>Instead of reviewing the session yourself and typing specific commands, ask the agent to do the thinking:</p> 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 <p>This is especially powerful after long or exploratory sessions where multiple threads were touched. </p> <p>The agent has the full conversation in context and can spot follow-ups you might miss:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<p>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:</p> <pre><code>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</code></pre> <p>The agent chains completion into next-task selection.</p> <p>One sentence from you triggers two operations.</p>","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":"<p>At the end of a session, the agent reviews what happened and catches loose ends:</p> <pre><code>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</code></pre> <p>This is the proactive persistence model at work.</p> <p>The agent monitors the conversation for mentioned-but-not-tracked work and surfaces it before context is lost.</p>","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":"<p>Here is what task management looks like in a real session when the agent is driving:</p> <pre><code>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</code></pre> <p>It's All Conversational</p> <p>Notice what did not happen: The user never typed a <code>ctx</code> command.</p> <p>The agent handled task completion, follow-up creation, learning capture, and next-task selection: all from natural conversation.</p>","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":"<pre><code># 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</code></pre>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tips","level":2,"title":"Tips","text":"<ul> <li>Start tasks with a verb: \"Add,\" \"Fix,\" \"Implement,\" \"Investigate\": not just a topic like \"Authentication.\"</li> <li>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.\"</li> <li>Use <code>#in-progress</code> sparingly. Only one or two tasks should carry this tag at a time. If everything is in-progress, nothing is.</li> <li>Snapshot before, not after. The point of a snapshot is to capture the state before a change, not to celebrate what you just finished.</li> <li>Archive regularly. Once completed tasks outnumber pending ones, it is time to archive. A clean <code>TASKS.md</code> helps both you and your AI assistant focus.</li> <li>Never delete tasks. Mark them <code>[x]</code> (completed) or <code>[-]</code> (skipped with a reason). Deletion breaks the audit trail.</li> <li>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.</li> <li>Conversational prompts beat commands in interactive sessions. Saying \"what should we work on?\" is faster and more natural than running <code>/ctx-next</code>. Save explicit commands for scripts, CI, and unattended runs.</li> <li>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.</li> <li>Review proactive task suggestions before moving on. The best follow-ups come from items spotted in-context right after the work completes.</li> </ul>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#next-up","level":2,"title":"Next Up","text":"<p>Using the Scratchpad →: Store short-lived sensitive notes in an encrypted scratchpad.</p>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: full session lifecycle including task management in context</li> <li>Persisting Decisions, Learnings, and Conventions: capturing the \"why\" behind your work</li> <li>Detecting and Fixing Drift: keeping <code>TASKS.md</code> accurate over time</li> <li>CLI Reference: full documentation for <code>ctx add</code>, <code>ctx task complete</code>, <code>ctx task</code></li> <li>Context Files: <code>TASKS.md</code>: format and conventions for <code>TASKS.md</code></li> </ul>","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":"<p>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.</p> <p>Triggers Execute Arbitrary Code</p> <p>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:</p> <ul> <li>Only enable scripts you have read and understand.</li> <li>Never enable a trigger you downloaded from the internet without reviewing every line.</li> <li>Avoid shelling out to user-controlled values (<code>jq -r</code> output, <code>path</code> field, <code>tool</code> field) without quoting.</li> <li>A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.</li> </ul> <p>The generated trigger template starts disabled (no executable bit) so you cannot accidentally run an unreviewed script. Enable it explicitly with <code>ctx trigger enable</code>.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#scenario","level":2,"title":"Scenario","text":"<p>You want a <code>pre-tool-use</code> trigger that blocks the AI from editing anything in <code>internal/crypto/</code> without explicit confirmation. Cryptographic code is sensitive, and accidental edits have caused outages before, and you want a hard gate.</p>","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":"<pre><code>ctx trigger add pre-tool-use protect-crypto\n</code></pre> <p>That creates <code>.context/hooks/pre-tool-use/protect-crypto.sh</code> with a template:</p> <pre><code>#!/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</code></pre> <p>Note: the directory is <code>.context/hooks/pre-tool-use/</code>; the on-disk layout still uses <code>hooks/</code> even though the command is <code>ctx trigger</code>. If you <code>ls .context/hooks/</code>, that's where your triggers live.</p>","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":"<p>Open the file and replace the template body:</p> <pre><code>#!/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</code></pre> <p>A few things to note:</p> <ul> <li><code>set -euo pipefail</code>: any unhandled error aborts the script. Critical for a security-relevant trigger.</li> <li>Quote everything from <code>jq</code>: the <code>path</code> field comes from the AI tool; treat it as untrusted input.</li> <li>Explicit <code>allow</code> case: the default is allow. An empty or missing response is a risky default.</li> <li>Use <code>jq -n --arg</code> for output construction, as it is safer than string concatenation when the message may contain special characters.</li> </ul>","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":"<p>Before enabling the trigger, test it with a realistic mock input using <code>ctx trigger test</code>. This runs the script against a synthetic JSON payload without actually firing any AI tool.</p> <pre><code># Test the \"should block\" case\nctx trigger test pre-tool-use --tool write_file --path internal/crypto/aes.go\n</code></pre> <p>Expected: the trigger returns <code>{\"action\":\"block\", \"message\": \"...\"}</code>.</p> <pre><code># Test the \"should allow\" case\nctx trigger test pre-tool-use --tool write_file --path internal/memory/mirror.go\n</code></pre> <p>Expected: the trigger returns <code>{\"action\":\"allow\"}</code>.</p> <pre><code># Test that non-write tools pass through\nctx trigger test pre-tool-use --tool read_file --path internal/crypto/aes.go\n</code></pre> <p>Expected: <code>{\"action\":\"allow\"}</code> because the <code>case</code> statement only gates write-family tools.</p> <p>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.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-4-enable-it","level":2,"title":"Step 4: Enable It","text":"<p>Once the test cases pass, enable the trigger:</p> <pre><code>ctx trigger enable protect-crypto\n</code></pre> <p>That sets the executable bit. Next time the AI starts a <code>pre-tool-use</code> event, the trigger will fire.</p> <p>Verify it's enabled:</p> <pre><code>ctx trigger list\n</code></pre> <p>Should show <code>protect-crypto</code> under <code>pre-tool-use</code> with an enabled indicator.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-5-iterate-safely","level":2,"title":"Step 5: Iterate Safely","text":"<p>If you discover a bug after enabling, disable first, fix second:</p> <pre><code>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</code></pre> <p>Disabling simply clears the executable bit; the script stays on disk, and <code>ctx trigger enable</code> re-enables it without rewriting anything.</p>","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":"<p>For auditing or analytics, return <code>{\"action\":\"allow\"}</code> always and append to a log as a side effect:</p> <pre><code>#!/usr/bin/env bash\nset -euo pipefail\npayload=$(cat)\necho \"$payload\" >> .context/logs/tool-use.jsonl\necho '{\"action\":\"allow\"}'\n</code></pre>","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":"<p>A <code>session-start</code> trigger can prepend text to the agent's initial prompt by emitting <code>{\"action\":\"inject\", \"content\": \"...\"}</code> . This is useful for injecting daily standup notes, open PRs, or rotating TODOs without storing them in a steering file.</p>","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":"<p>Multiple scripts in the same type directory all run. If any returns <code>action: block</code>, the block wins. Keep individual triggers single-purpose and rely on composition.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#common-mistakes","level":2,"title":"Common Mistakes","text":"<p>Forgetting the shebang. Without <code>#!/usr/bin/env bash</code>, the trigger won't execute even with the executable bit set.</p> <p>Not quoting <code>$path</code>. If you use <code>$path</code> in a command substitution or a <code>case</code> glob without quoting, a file name with spaces or metacharacters will break the trigger in surprising ways.</p> <p>Enabling before testing. <code>ctx trigger enable</code> makes the script live immediately. Always <code>ctx trigger test</code> first.</p> <p>Outputting non-JSON. The trigger's stdout must be valid JSON or <code>ctx</code>'s trigger runner will log a parse error. Use <code>jq -n</code> to construct output rather than hand-writing JSON strings.</p> <p>Mixing <code>hook</code> and <code>trigger</code> vocabulary. The command is <code>ctx trigger</code> but the on-disk directory is <code>.context/hooks/</code>. The feature was renamed; the directory name lags behind. Don't let this confuse you; they refer to the same thing.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx trigger</code> reference: full command, flag, and event-type reference.</li> <li><code>ctx steering</code>: 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.\"</li> <li>Writing steering files: the rule-based equivalent of this recipe.</li> </ul>","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":"<p>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.</p> <p>How do you figure out what's wrong and fix it?</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx doctor # structural health check\nctx hook event --last 20 # recent hook activity\n# or ask: \"something seems off, can you diagnose?\"\n</code></pre>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>ctx doctor</code> CLI command Structural health report <code>ctx doctor --json</code> CLI command Machine-readable health report <code>ctx hook event</code> CLI command Query local event log <code>/ctx-doctor</code> 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: <code>ctx doctor</code>","text":"<p>Run <code>ctx doctor</code> 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:</p> <pre><code>ctx doctor\n</code></pre> <pre><code>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</code></pre> <p>Warnings are non-critical but worth fixing. Errors need attention. Informational notes (○) flag optional features that aren't enabled.</p> <p>For scripting:</p> <pre><code>ctx doctor --json | jq '.warnings'\n</code></pre>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#deep-dive-ctx-doctor","level":3,"title":"Deep Dive: <code>/ctx-doctor</code>","text":"<p>When you need the agent to reason about what's wrong, use the skill. Ask naturally or invoke directly:</p> <pre><code>Why didn't my hook fire?\nSomething seems off, can you diagnose?\n/ctx-doctor\n</code></pre> <p>The agent follows a triage sequence:</p> <ol> <li>Baseline: runs <code>ctx doctor --json</code> for structural health</li> <li>Events: runs <code>ctx hook event --json --last 100</code> (if event logging enabled)</li> <li>Correlate: connects findings across both sources</li> <li>Present: structured findings with evidence</li> <li>Suggest: actionable next steps (but doesn't auto-fix)</li> </ol> <p>The skill degrades gracefully: without event logging enabled, it still runs structural checks and notes what you'd gain by enabling it.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#raw-event-inspection","level":3,"title":"Raw Event Inspection","text":"<p>For power users: <code>ctx hook event</code> with filters gives direct access to the event log.</p> <pre><code># 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</code></pre> <p>Filters use AND logic: <code>--hook qa-reminder --session abc123</code> returns only QA reminder events from that specific session.</p>","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-at-this-directory","level":3,"title":"\"No <code>.context/</code> at this directory\"","text":"<p>Symptoms: Any <code>ctx</code> command fails with <code>ctx: no .context/ at <pwd>. Run \\</code>ctx init` here, or cd to a project that has one.`</p> <p>Cause: <code>ctx</code> reads <code>$PWD/.context/</code> and you ran the command from a directory that does not have one.</p> <p>Fix: either <code>cd</code> into a project root that already has <code>.context/</code>, or run <code>ctx init</code> in the current directory to create one.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#ctx-not-initialized","level":3,"title":"\"<code>ctx</code>: Not Initialized\"","text":"<p>Symptoms: <code>ctx</code> finds <code>.context/</code> at <code>$PWD</code> but the command fails with <code>ctx: not initialized - run \"ctx init\" first</code>.</p> <p>Cause: The directory exists but hasn't been populated with template files.</p> <p>Fix:</p> <pre><code>ctx init # create .context/ with template files\nctx init --minimal # or just the essentials (CONSTITUTION, TASKS, DECISIONS)\n</code></pre> <p>Commands that work without <code>.context/</code> or initialization: <code>ctx init</code>, <code>ctx setup</code>, <code>ctx doctor</code>, <code>ctx guide</code>, <code>ctx why</code>, <code>ctx config switch/status</code>, <code>ctx hub *</code>, and help-only grouping commands.</p>","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":"<p>Symptoms: A <code>!</code>-pragma or interactive <code>ctx</code> call writes to the wrong <code>.context/</code>; or you ran <code>ctx remind add</code> in shell A and the reminder shows up in project B's notifications.</p> <p>Cause: Different shells were launched from different working directories. <code>ctx</code> reads <code>$PWD/.context/</code>; if your terminal tab is <code>cd</code>'d into project A and your Claude Code session is in project B, <code>!</code>-pragma calls write to A while in-session calls write to B.</p> <p>Fix: <code>cd</code> the shell into the same project root the Claude Code session is in, or close the tab and reopen it from the right working directory.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#my-hook-isnt-firing","level":3,"title":"\"My Hook Isn't Firing\"","text":"<p>Symptoms: No nudges appearing, webhook silent, event log shows no entries for the expected hook.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>Plugin is not installed: run <code>ctx init --claude</code> to reinstall</li> <li>PATH issue: the hook invokes <code>ctx</code> from PATH; ensure it resolves</li> <li>Throttle active: most hooks fire once per day: check <code>.context/state/</code> for daily marker files</li> <li>Hook silenced: a custom message override may be an empty file: check <code>ctx hook message list</code> for overrides</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#too-many-nudges","level":3,"title":"\"Too Many Nudges\"","text":"<p>Symptoms: The agent is overwhelmed with hook output. Context checkpoints, persistence reminders, and QA gates fire constantly.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>QA reminder is noisy by design: it fires on every <code>Edit</code> call with no throttle. This is intentional. If it's too much, silence it with an empty override: <code>ctx hook message edit qa-reminder gate</code>, then empty the file</li> <li>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</li> <li>Short throttle window: if you deleted marker files in <code>.context/state/</code>, daily-throttled hooks will re-fire</li> <li>Outdated Claude Code plugin: Update the plugin using Claude Code → <code>/plugin</code> → \"Marketplace\"</li> <li><code>ctx</code> version mismatch: Build (or download) and install the latest <code>ctx</code> vesion.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#context-seems-stale","level":3,"title":"\"Context Seems Stale\"","text":"<p>Symptoms: The agent references outdated information, paths that don't exist, or decisions that were reversed.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>Drift accumulated: stale path references in <code>ARCHITECTURE.md</code> or <code>CONVENTIONS.md</code>. Fix with <code>ctx drift --fix</code> or ask the agent to clean up.</li> <li>Task backlog: too many completed tasks diluting active context. Archive with <code>ctx task archive</code> or <code>ctx compact --archive</code>.</li> <li>Large context files: <code>LEARNINGS.md</code> with 40+ entries competes for attention. Consolidate with <code>/ctx-consolidate</code>.</li> <li>Missing session ceremonies: if <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> aren't being used, context doesn't get refreshed. See Session Ceremonies.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-agent-isnt-following-instructions","level":3,"title":"\"The Agent Isn't Following Instructions\"","text":"<p>Symptoms: The agent ignores conventions, forgets decisions, or acts contrary to <code>CONSTITUTION.md</code> rules.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>Context too large: if total tokens exceed the model's effective attention, instructions get diluted. Check <code>ctx doctor</code> for the size check. Compact with <code>ctx compact --archive</code>.</li> <li>Context not loading: if <code>context-load-gate</code> hasn't fired, the agent may not have received context. Verify the hook is registered.</li> <li>Conflicting instructions: <code>CONVENTIONS.md</code> says one thing, <code>AGENT_PLAYBOOK.md</code> says another. Review both files for consistency.</li> <li>Agent drift: the agent's behavior diverges from instructions over long sessions. This is normal. Use <code>/ctx-reflect</code> to re-anchor, or start a new session.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li>Event logging (optional but recommended): <code>event_log: true</code> in <code>.ctxrc</code></li> <li><code>ctx</code> initialized: <code>ctx init</code></li> </ul> <p>Event logging is not required for <code>ctx doctor</code> or <code>/ctx-doctor</code> to work. Both degrade gracefully: structural checks run regardless, and the skill notes when event data is unavailable.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>ctx doctor</code>: 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.</li> <li>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.</li> <li>Use the skill for correlation: <code>ctx doctor</code> tells you what is wrong. <code>/ctx-doctor</code> tells you why by correlating structural findings with event patterns. The agent can spot connections that individual commands miss.</li> <li>Event log is gitignored: It's machine-local diagnostic data, not project context. Different machines produce different event streams.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#next-up","level":2,"title":"Next Up","text":"<p>Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#see-also","level":2,"title":"See Also","text":"<ul> <li>Auditing System Hooks: the complete hook catalog and webhook-based audit trails</li> <li>Detecting and Fixing Drift: structural and semantic drift detection and repair</li> <li>Webhook Notifications: push notifications for hook activity</li> <li><code>ctx doctor</code> CLI: full command reference</li> <li><code>ctx hook event</code> CLI: event log query reference</li> <li><code>/ctx-doctor</code> skill: agent-driven diagnosis</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/typical-kb-session/","level":1,"title":"Typical KB Session","text":"","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#the-problem","level":2,"title":"The Problem","text":"<p>You set the editorial pipeline up (Build a Knowledge Base). Now you sit down for a real research session: a transcript to ingest, a question to answer against existing evidence, a finding to capture for later. What's the actual flow?</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-remember # session-start recall\n/ctx-kb-ingest ./inputs/transcript.md \"topic\" # editorial pass\n/ctx-kb-ask \"does the kb say X?\" # grounded Q&A\n/ctx-kb-note \"follow-up: chase the v1.1 link\" # park a finding\n/ctx-wrap-up # ceremony → /ctx-handover\n</code></pre>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>/ctx-remember</code> Skill Session-start recall (folds KB state when present) <code>/ctx-kb-ingest</code> Skill Mode-aware editorial pass <code>/ctx-kb-ask</code> Skill Q&A grounded in the kb <code>/ctx-kb-note</code> Skill Park a finding for the next ingest <code>/ctx-wrap-up</code> Skill End-of-session ceremony; delegates to the handover step <code>/ctx-handover</code> Skill Writes the per-session handover; called by <code>/ctx-wrap-up</code>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-1-session-start-recall","level":2,"title":"Step 1: Session Start (Recall)","text":"<pre><code>/ctx-remember\n</code></pre> <p><code>/ctx-remember</code> reads the latest handover under <code>.context/handovers/</code> (timestamped <code><TS>-<slug>.md</code> so concurrent agent runs never overwrite); its <code>## Summary</code> and <code>## Next session</code> are the authoritative recall surface. The five canonical files (<code>TASKS</code>, <code>DECISIONS</code>, etc.) are read as usual.</p> <p>When <code>.context/kb/</code> exists, <code>/ctx-remember</code> additionally folds editorial state into the readback: any closeouts whose <code>generated-at</code> postdates the handover are read for their <code>## What changed</code> sections (these are unfolded passes the last handover did not yet consume).</p> <p><code>SESSION_LOG.md</code> is not read at session start; it is mid-flight working memory, not a recall surface.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-2-ingest-the-sources-you-brought","level":2,"title":"Step 2: Ingest the Sources You Brought","text":"<pre><code>/ctx-kb-ingest ./inputs/2026-05-15-call.md \"cursor hooks\"\n</code></pre> <p>The skill declares its mode up front (most often <code>topic-page</code>), resolves sources, scans the source-coverage ledger for adjacent incomplete topics, and synthesizes prose into the topic page section by section. Every cited claim mints an <code>EV-###</code> row in <code>evidence-index.md</code> with the source short-name + locator + optional <code>sha:</code> pin for in-repo files.</p> <p>The pass ends with a circuit-breaker check (file exists, cites ≥ 1 <code>EV-###</code>, site builds clean, cold-reader rubric at <code>pass</code>) and writes a closeout.</p> <p>If the skill reports <code>topic-page: deferred</code> instead of <code>produced</code>, look at the closeout's <code>Next pass hint</code>. It names the exact resumption invocation.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-3-ask-grounded-questions","level":2,"title":"Step 3: Ask Grounded Questions","text":"<pre><code>/ctx-kb-ask \"does the kb say hooks block until they exit?\"\n</code></pre> <p><code>/ctx-kb-ask</code> reads the kb's prose and answers with <code>EV-###</code> citations. If the kb cannot answer, it opens a <code>Q-###</code> row in <code>outstanding-questions.md</code> and reports the gap rather than inventing.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-4-park-findings-for-later","level":2,"title":"Step 4: Park Findings for Later","text":"<pre><code>/ctx-kb-note \"check whether SIGTERM behavior changed in v1.2\"\n</code></pre> <p><code>/ctx-kb-note</code> appends one-liners to <code>.context/ingest/findings.md</code>, a lightweight surface for parking ideas that don't earn a full ingest pass right now. The next <code>/ctx-kb-ingest</code> can choose to absorb them.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-5-wrap-up","level":2,"title":"Step 5: Wrap Up","text":"<pre><code>/ctx-wrap-up \"Cursor Hooks: lifecycle deep dive\"\n</code></pre> <p><code>/ctx-wrap-up</code> runs the standard capture checklist (learnings, decisions, conventions, tasks) and delegates to <code>/ctx-handover</code> as its final step. In a KB session it additionally:</p> <ul> <li>Surfaces pending closeouts under <code>.context/ingest/closeouts/</code>.</li> <li>Counts <code>open</code> rows in <code>outstanding-questions.md</code>.</li> </ul> <p>The handover artifact lands at <code>.context/handovers/<TS>-<slug>.md</code> (timestamped so concurrent agent runs never overwrite). The handover folds postdated closeouts into a <code>## Folded closeouts</code> section and archives them under <code>.context/archive/closeouts/</code>. Editorial work that was incomplete at wrap-up (open <code>Q-###</code> rows, <code>topic-page: deferred</code> passes) is surfaced as recall on the next session start.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#common-shapes","level":2,"title":"Common Shapes","text":"","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#multiple-topics-in-one-session","level":3,"title":"Multiple Topics in One Session","text":"<p>Run <code>/ctx-kb-ingest</code> once per topic. Each pass writes its own closeout; the handover folds all of them at the end.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#mid-session-checkpoint","level":3,"title":"Mid-Session Checkpoint","text":"<pre><code>ctx handover write \"Mid-day checkpoint\" \\\n --summary \"...\" --next \"...\" --no-fold\n</code></pre> <p><code>--no-fold</code> writes the handover without consuming closeouts, useful when you want a recall anchor mid-session without ending the editorial chunking.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#aborted-session","level":3,"title":"Aborted Session","text":"<p>If you close the laptop after an ingest pass but before <code>/ctx-wrap-up</code>, the closeouts stay in place. The next session's <code>/ctx-remember</code> reads them as unfolded postdated closeouts; the next wrap-up's handover step folds them normally. See Recover an Aborted Session for the failure-mode detail.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Build a Knowledge Base</li> <li>Recipe: Recover an Aborted Session</li> <li>Skill: <code>/ctx-kb-ingest</code></li> <li>Skill: <code>/ctx-handover</code></li> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code></li> </ul>","path":["Recipes","Knowledge Base","Typical KB Session"],"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":"<p>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.</p> <p>How do you get notified about agent activity without watching the terminal?</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre>","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 <code>ctx hook notify setup</code> CLI command Configure and encrypt webhook URL <code>ctx hook notify test</code> CLI command Send a test notification <code>ctx hook notify --event <name> \"msg\"</code> CLI command Send a notification from scripts/skills <code>.ctxrc</code> <code>notify.events</code> 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":"<p>Any service that accepts HTTP POST with JSON works. Common options:</p> 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 <code>https://ntfy.sh/your-topic</code> (no signup) Pushover Use API endpoint with your user key <p>The URL contains auth tokens. <code>ctx</code> encrypts it; it never appears in plaintext in your repo.</p>","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":"<pre><code>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</code></pre> <p>This encrypts the URL with AES-256-GCM using the same key as the scratchpad (<code>~/.ctx/.ctx.key</code>). The encrypted file (<code>.context/.notify.enc</code>) is safe to commit. The key lives outside the project and is never committed.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-3-test-it","level":3,"title":"Step 3: Test It","text":"<pre><code>ctx hook notify test\n# Webhook responded: HTTP 200 OK\n</code></pre> <p>If you see <code>No webhook configured</code>, run <code>ctx hook notify setup</code> first.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-4-configure-events","level":3,"title":"Step 4: Configure Events","text":"<p>Notifications are opt-in: no events are sent unless you configure an event list in <code>.ctxrc</code>:</p> <pre><code># .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</code></pre> <p>Only listed events fire. Omitting an event silently drops it.</p>","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":"<p>Add <code>ctx hook notify</code> calls to any skill or script:</p> <pre><code># 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</code></pre> <p>The <code>2>/dev/null || true</code> suffix ensures the notification never breaks your script: If there's no webhook or the HTTP call fails, it's a silent noop.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#event-types","level":2,"title":"Event Types","text":"<p><code>ctx</code> fires these events automatically:</p> Event Source When <code>loop</code> Loop script Loop completes or hits max iterations <code>nudge</code> System hooks VERBATIM relay nudge is emitted (context checkpoint, persistence, ceremonies, journal, resources, knowledge, version) <code>relay</code> System hooks Any hook output (VERBATIM relays, agent directives, block responses) <code>heartbeat</code> System hook Every prompt: session-alive signal with prompt count and context modification status <code>test</code> <code>ctx hook notify test</code> Manual test notification (custom) Your skills You wire <code>ctx hook notify --event <name></code> in your own scripts <p><code>nudge</code> vs <code>relay</code>: The <code>nudge</code> event fires only for VERBATIM relay hooks (the ones the agent is instructed to show verbatim). The <code>relay</code> event fires for all hook output: VERBATIM relays, agent directives, and hard gates. Subscribe to <code>relay</code> for debugging (\"did the agent get the post-commit nudge?\"), <code>nudge</code> for user-facing assurance (\"was the checkpoint emitted?\").</p> <p>Webhooks as a Hook Audit Trail</p> <p>Subscribe to <code>relay</code> events and you get an external record of every hook that fires, independent of the agent. </p> <p>This lets you verify hooks are running and catch cases where the agent absorbs a nudge instead of surfacing it. </p> <p>See Auditing System Hooks for the full workflow.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#payload-format","level":2,"title":"Payload Format","text":"<p>Every notification sends a JSON POST:</p> <pre><code>{\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</code></pre> <p>The <code>detail</code> 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 <code>ctx hook notify</code> calls).</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#heartbeat-payload","level":3,"title":"Heartbeat Payload","text":"<p>The <code>heartbeat</code> event fires on every prompt with session metadata and token usage telemetry:</p> <pre><code>{\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</code></pre> <p>The <code>tokens</code>, <code>context_window</code>, and <code>usage_pct</code> 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).</p> <p>Unlike other events, <code>heartbeat</code> fires every prompt (not throttled). Use it for observability dashboards or liveness monitoring of long-running sessions.</p>","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 <code>~/.ctx/.ctx.key</code> No (user-level) <code>0600</code> Encrypted URL <code>.context/.notify.enc</code> Yes (safe) <code>0600</code> Webhook URL Never on disk in plaintext N/A N/A <p>The key is shared with the scratchpad. If you rotate the encryption key, re-run <code>ctx hook notify setup</code> to re-encrypt the webhook URL with the new key.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#key-rotation","level":2,"title":"Key Rotation","text":"<p><code>ctx</code> checks the age of the encryption key once per day. If it's older than 90 days (configurable via <code>key_rotation_days</code>), a VERBATIM nudge is emitted suggesting rotation.</p> <pre><code># .ctxrc\nkey_rotation_days: 30 # nudge sooner (default: 90)\n</code></pre>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#worktrees","level":2,"title":"Worktrees","text":"<p>The webhook URL is encrypted with the same encryption key (<code>~/.ctx/.ctx.key</code>). Because the key lives at the user level, it is shared across all worktrees on the same machine - notifications work in worktrees automatically.</p> <p>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.</p>","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":"<p>Don't need a webhook but want diagnostic visibility? Enable <code>event_log: true</code> in <code>.ctxrc</code>. The event log writes the same payload as webhooks to a local JSONL file (<code>.context/state/events.jsonl</code>) that you can query without any external service:</p> <pre><code>ctx hook event --last 20 # recent hook activity\nctx hook event --hook qa-reminder # filter by hook\n</code></pre> <p>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 <code>ctx doctor</code> integration.</p> <p>See Troubleshooting for how they work together.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tips","level":2,"title":"Tips","text":"<ul> <li>Fire-and-forget: Notifications never block. HTTP errors are silently ignored. No retry, no response parsing.</li> <li>No webhook = no cost: When no webhook is configured, <code>ctx hook notify</code> exits immediately. System hooks that call <code>notify.Send()</code> add zero overhead.</li> <li>Multiple projects: Each project has its own <code>.notify.enc</code>. You can point different projects at different webhooks.</li> <li>Event filter is per-project: Configure <code>notify.events</code> in each project's <code>.ctxrc</code> independently.</li> </ul>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#next-up","level":2,"title":"Next Up","text":"<p>Auditing System Hooks →: Verify your hooks are running, audit what they do, and get alerted when they go silent.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#see-also","level":2,"title":"See Also","text":"<ul> <li>CLI Reference: <code>ctx</code> hook notify: full command reference</li> <li>Configuration: <code>.ctxrc</code> settings including <code>notify</code> options</li> <li>Running an Unattended AI Agent: how loops work and how notifications fit in</li> <li>Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates</li> <li>Auditing System Hooks: using webhooks as an external audit trail for hook execution</li> </ul>","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":"<p>You have a task, and you are wondering: \"should I throw more agents at it?\"</p> <p>More agents can mean faster results, but they also mean coordination overhead, merge conflicts, divergent mental models, and wasted tokens re-reading context. </p> <p>The wrong setup costs more than it saves.</p> <p>This recipe is a decision framework: It helps you choose between a single agent, parallel worktrees, and a full agent team, and explains what <code>ctx</code> provides at each level.</p>","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":"<ul> <li>Single agent for most work;</li> <li>Parallel worktrees when tasks touch disjoint file sets;</li> <li>Agent teams only when tasks need real-time coordination. When in doubt, start with one agent.</li> </ul>","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":"<p>There are three modes, ordered by complexity:</p>","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":"<p>One agent, one session, one branch. This is correct for most work.</p> <p>Use this when:</p> <ul> <li>The task has linear dependencies (step 2 needs step 1's output);</li> <li>Changes touch overlapping files;</li> <li>You need tight feedback loops (review each change before the next);</li> <li>The task requires deep understanding of a single area;</li> <li>Total effort is less than a few hours of agent time.</li> </ul> <p><code>ctx</code> provides: Full <code>.context/</code>: tasks, decisions, learnings, conventions, all in one session. </p> <p>The agent builds a coherent mental model and persists it as it goes.</p> <p>Example tasks: Bug fixes, feature implementation, refactoring a module, writing documentation for one area, debugging.</p>","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":"<p>2-4 agents, each in a separate git worktree on its own branch, working on non-overlapping parts of the codebase.</p> <p>Use this when:</p> <ul> <li>You have 5+ independent tasks in the backlog;</li> <li>Tasks group cleanly by directory or package;</li> <li>File overlap between groups is zero or near-zero;</li> <li>Each track can be completed and merged independently;</li> <li>You want parallelism without coordination complexity.</li> </ul> <p><code>ctx</code> provides: Shared <code>.context/</code> via <code>git</code> (each worktree sees the same tasks, decisions, conventions). <code>/ctx-worktree</code> skill for setup and teardown. <code>TASKS.md</code> as a lightweight work queue.</p> <p>Example tasks: Docs + new package + test coverage (three tracks that don't touch the same files). Parallel recipe writing. Independent module development.</p> <p>See: Parallel Agent Development with Git Worktrees</p>","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":"<p>Multiple agents communicating via messages, sharing a task list, with a lead agent coordinating. Claude Code's team/swarm feature.</p> <p>Use this when:</p> <ul> <li>Tasks have dependencies but can still partially overlap;</li> <li>You need research and implementation happening simultaneously;</li> <li>The work requires different roles (researcher, implementer, tester);</li> <li>A lead agent needs to review and integrate others' work;</li> <li>The task is large enough that coordination cost is justified.</li> </ul> <p><code>ctx</code> provides: <code>.context/</code> as shared state that all agents can read. Task tracking for work assignment. Decisions and learnings as team memory that survives individual agent turnover.</p> <p>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.</p>","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":"<p>Ask these questions in order:</p> <pre><code>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</code></pre>","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":"<p>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).</p> <pre><code>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</code></pre> <p>When in doubt, keep things in one track. A merge conflict in a critical file costs more time than the parallelism saves.</p>","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":"<p>\"More agents\" is not always better. Watch for these patterns:</p> <p>Merge hell: If you are spending more time resolving conflicts than the parallel work saved, you split wrong: Re-group by file overlap.</p> <p>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.</p> <p>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.</p> <p>Re-reading overhead: Every agent reads <code>.context/</code> 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.</p>","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 <code>ctx</code> Gives You at Each Level","text":"<code>ctx</code> Feature Single Agent Worktrees Team <code>.context/</code> files Full access Shared via git Shared via filesystem <code>TASKS.md</code> Work queue Split by track Assigned by lead Decisions/Learnings Persisted in session Persisted per branch Persisted by any agent <code>/ctx-next</code> Picks next task Picks within track Lead assigns <code>/ctx-worktree</code> N/A Setup + teardown Optional <code>/ctx-commit</code> 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":"<p>Four practical team compositions for common workflows.</p>","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 <code>specs/</code>, breaks work into TASKS.md phases Implementer Picks tasks from TASKS.md, writes code, marks <code>[x]</code> done Reviewer Runs tests, <code>ctx drift</code>, lint; files issues as new tasks <p>Coordination: TASKS.md checkboxes. Architect writes tasks before implementer starts. Reviewer runs after each implementer commit.</p> <p>Anti-pattern: All three agents editing the same file simultaneously. Sequence the work so only one agent touches a file at a time.</p>","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 <code>ctx drift</code>, 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 <p>Coordination: Auditor's <code>ctx drift</code> output is the shared work queue. Each agent claims a subset of issues by adding <code>#in-progress</code> labels.</p> <p>Anti-pattern: Fixer and doc writer both editing ARCHITECTURE.md. Assign file ownership explicitly.</p>","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 <p>Coordination: Both read TASKS.md to identify what shipped. Release notes agent works from <code>git log</code>; validation agent works from <code>make audit</code>.</p> <p>Anti-pattern: Release notes agent running tests \"to verify.\" Each agent stays in its lane.</p>","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 <p>Coordination: Content agent writes files first. Cross-linker updates <code>zensical.toml</code> and index pages after content lands. Verifier builds after each batch.</p> <p>Antipattern: Content and cross-linker both editing <code>zensical.toml</code>. Batch nav updates into the cross-linker's pass.</p>","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":"<ul> <li>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.</li> <li>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.</li> <li>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.</li> <li>Use <code>ctx</code> as the shared brain: Whether it's one agent or four, the <code>.context/</code> directory is the single source of truth. Decisions go in <code>DECISIONS.md</code>, not in chat messages between agents.</li> <li>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.</li> <li><code>TASKS.md</code> conflicts are normal: Multiple agents completing different tasks will conflict on merge. The resolution is always additive: accept all <code>[x]</code> completions from both sides.</li> </ul>","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":"<p>Parallel Agent Development with Git Worktrees →: Run multiple agents on independent task tracks using git worktrees.</p>","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":"<ul> <li>CLI Reference: all commands and flags</li> <li>Integrations: setup for Claude Code, Cursor, Aider</li> <li>Session Journal: browse and search session history</li> </ul>","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":"<ul> <li>Parallel Agent Development with Git Worktrees: the mechanical \"how\" for worktree-based parallelism</li> <li>Running an Unattended AI Agent: serial autonomous loops: a different scaling strategy</li> <li>Tracking Work Across Sessions: managing the task backlog that feeds into any multi-agent setup</li> </ul>","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"reference/","level":1,"title":"Reference","text":"<p>Technical reference for <code>ctx</code> commands, skills, and internals.</p>","path":["Reference"],"tags":[]},{"location":"reference/#the-system-explains-itself","level":3,"title":"The System Explains Itself","text":"<p>The 12 properties that must hold for any valid <code>ctx</code> implementation. Not features: constraints. The system's contract with its users and contributors.</p>","path":["Reference"],"tags":[]},{"location":"reference/#code-conventions","level":3,"title":"Code Conventions","text":"<p>Common patterns and fixes for the AST compliance tests in <code>internal/audit/</code>. When a test fails, find the matching section.</p>","path":["Reference"],"tags":[]},{"location":"reference/#cli","level":3,"title":"CLI","text":"<p>Every command, subcommand, and flag. Now a top-level section: see CLI Reference.</p>","path":["Reference"],"tags":[]},{"location":"reference/#skills","level":3,"title":"Skills","text":"<p>The full skill catalog: what each skill does, when it triggers, and how skills interact with commands.</p>","path":["Reference"],"tags":[]},{"location":"reference/#tool-ecosystem","level":3,"title":"Tool Ecosystem","text":"<p>How <code>ctx</code> compares to Cursor Rules, Aider conventions, CLAUDE.md, and other context approaches.</p>","path":["Reference"],"tags":[]},{"location":"reference/#session-journal","level":3,"title":"Session Journal","text":"<p>Export, browse, and enrich your session history. Covers the journal site, Obsidian export, and the enrichment pipeline.</p>","path":["Reference"],"tags":[]},{"location":"reference/#scratchpad","level":3,"title":"Scratchpad","text":"<p>Encrypted, git-tracked scratch space for short notes and sensitive values that travel with the project.</p>","path":["Reference"],"tags":[]},{"location":"reference/#version-history","level":3,"title":"Version History","text":"<p>Changelog for every <code>ctx</code> release.</p>","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":"<p>This guide documents the code conventions enforced by <code>internal/audit/</code> AST tests. Each section shows the violation pattern, the fix, and the rationale. When a test fails, find the matching section below.</p> <p>All tests skip <code>_test.go</code> files. The patterns apply only to production code under <code>internal/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#variable-shadowing-bare-err-reuse","level":2,"title":"Variable Shadowing (Bare <code>err :=</code> Reuse)","text":"<p>Test: <code>TestNoVariableShadowing</code></p> <p>When a function has multiple <code>:=</code> assignments to <code>err</code>, each shadows the previous one. This makes it impossible to tell which error a later <code>if err != nil</code> is checking.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>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</code></pre> <p>Rule: Use descriptive error names (<code>readErr</code>, <code>writeErr</code>, <code>parseErr</code>, <code>walkErr</code>, <code>absErr</code>, <code>relErr</code>) so each error site is independently identifiable.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#import-name-shadowing","level":2,"title":"Import Name Shadowing","text":"<p>Test: <code>TestNoImportNameShadowing</code></p> <p>When a local variable has the same name as an imported package, the import becomes inaccessible in that scope.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>import \"github.com/ActiveMemory/ctx/internal/session\"\n\nfunc process(sess *entity.Session) {\n // session package still accessible\n}\n</code></pre> <p>Rule: Parameters, variables, and return values must not reuse imported package names. Common renames: <code>session</code> -> <code>sess</code>, <code>token</code> -> <code>tok</code>, <code>config</code> -> <code>cfg</code>, <code>entry</code> -> <code>ent</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-strings","level":2,"title":"Magic Strings","text":"<p>Test: <code>TestNoMagicStrings</code></p> <p>String literals in function bodies are invisible to refactoring tools and cause silent breakage when the value changes in one place but not another.</p> <p>Before (string literals):</p> <pre><code>func loadContext() {\n data := filepath.Join(dir, \"TASKS.md\")\n if strings.HasSuffix(name, \".yaml\") {\n // ...\n }\n}\n</code></pre> <p>After:</p> <pre><code>func loadContext() {\n data := filepath.Join(dir, config.FilenameTask)\n if strings.HasSuffix(name, config.ExtYAML) {\n // ...\n }\n}\n</code></pre> <p>Before (format verbs, also caught):</p> <pre><code>func EntryHash(text string) string {\n h := sha256.Sum256([]byte(text))\n return fmt.Sprintf(\"%x\", h[:8])\n}\n</code></pre> <p>After:</p> <pre><code>func EntryHash(text string) string {\n h := sha256.Sum256([]byte(text))\n return hex.EncodeToString(h[:cfgFmt.HashPrefixLen])\n}\n</code></pre> <p>Before (URL schemes, also caught):</p> <pre><code>if strings.HasPrefix(target, \"https://\") ||\n strings.HasPrefix(target, \"http://\") {\n return target\n}\n</code></pre> <p>After:</p> <pre><code>if strings.HasPrefix(target, cfgHTTP.PrefixHTTPS) ||\n strings.HasPrefix(target, cfgHTTP.PrefixHTTP) {\n return target\n}\n</code></pre> <p>Exempt from this check:</p> <ul> <li>Empty string <code>\"\"</code>, single space <code>\" \"</code>, indentation strings</li> <li>Regex capture references (<code>$1</code>, <code>${name}</code>)</li> <li><code>const</code> and <code>var</code> definition sites (that's where constants live)</li> <li>Struct tags</li> <li>Import paths</li> <li>Packages under <code>internal/config/</code>, <code>internal/assets/tpl/</code></li> </ul> <p>Rule: If a string is used for comparison, path construction, or appears in 3+ files, it belongs in <code>internal/config/</code> as a constant. Format strings belong in <code>internal/config/</code> as named constants (e.g., <code>cfgGit.FlagLastN</code>, <code>cfgTrace.RefFormat</code>). User-facing prose belongs in <code>internal/assets/</code> YAML files accessed via <code>desc.Text()</code>.</p> <p>Common fix for <code>fmt.Sprintf</code> with format verbs:</p> Pattern Fix <code>fmt.Sprintf(\"%d\", n)</code> <code>strconv.Itoa(n)</code> <code>fmt.Sprintf(\"%d\", int64Val)</code> <code>strconv.FormatInt(int64Val, 10)</code> <code>fmt.Sprintf(\"%x\", bytes)</code> <code>hex.EncodeToString(bytes)</code> <code>fmt.Sprintf(\"%q\", s)</code> <code>strconv.Quote(s)</code> <code>fmt.Sscanf(s, \"%d\", &n)</code> <code>strconv.Atoi(s)</code> <code>fmt.Sprintf(\"-%d\", n)</code> <code>fmt.Sprintf(cfgGit.FlagLastN, n)</code> <code>\"https://\"</code> <code>cfgHTTP.PrefixHTTPS</code> <code>\"&lt;\"</code> config constant in <code>config/html/</code>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-printf-calls","level":2,"title":"Direct Printf Calls","text":"<p>Test: <code>TestNoPrintfCalls</code></p> <p><code>cmd.Printf</code> and <code>cmd.PrintErrf</code> bypass the write-package formatting pipeline and scatter user-facing text across the codebase.</p> <p>Before:</p> <pre><code>func Run(cmd *cobra.Command, args []string) {\n cmd.Printf(\"Found %d tasks\\n\", count)\n}\n</code></pre> <p>After:</p> <pre><code>func Run(cmd *cobra.Command, args []string) {\n write.TaskCount(cmd, count)\n}\n</code></pre> <p>Rule: All formatted output goes through <code>internal/write/</code> which uses <code>cmd.Print</code>/<code>cmd.Println</code> with pre-formatted strings from <code>desc.Text()</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#raw-time-format-strings","level":2,"title":"Raw Time Format Strings","text":"<p>Test: <code>TestNoRawTimeFormats</code></p> <p>Inline time format strings (<code>\"2006-01-02\"</code>, <code>\"15:04:05\"</code>) drift when one call site is updated but others are missed.</p> <p>Before:</p> <pre><code>func formatDate(t time.Time) string {\n return t.Format(\"2006-01-02\")\n}\n</code></pre> <p>After:</p> <pre><code>func formatDate(t time.Time) string {\n return t.Format(cfgTime.DateFormat)\n}\n</code></pre> <p>Rule: All time format strings must use constants from <code>internal/config/time/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-flag-registration","level":2,"title":"Direct Flag Registration","text":"<p>Test: <code>TestNoFlagBindOutsideFlagbind</code></p> <p>Direct cobra flag calls (<code>.Flags().StringVar()</code>, etc.) scatter flag wiring across dozens of <code>cmd.go</code> files. Centralizing through <code>internal/flagbind/</code> gives one place to audit flag names, defaults, and description key lookups.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>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</code></pre> <p>Rule: All flag registration goes through <code>internal/flagbind/</code>. If the helper you need doesn't exist, add it to <code>flagbind/flag.go</code> before using it.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#todo-comments","level":2,"title":"TODO Comments","text":"<p>Test: <code>TestNoTODOComments</code></p> <p>TODO, FIXME, HACK, and XXX comments in production code are invisible to project tracking. They accumulate silently and never get addressed.</p> <p>Before:</p> <pre><code>// TODO: handle pagination\nfunc listEntries() []Entry {\n</code></pre> <p>After:</p> <p>Remove the comment and add a task to <code>.context/TASKS.md</code>:</p> <pre><code>- [ ] Handle pagination in listEntries (internal/task/task.go)\n</code></pre> <p>Rule: Deferred work lives in TASKS.md, not in source comments.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#dead-exports","level":2,"title":"Dead Exports","text":"<p>Test: <code>TestNoDeadExports</code></p> <p>Exported symbols with zero references outside their definition file are dead weight. They increase API surface, confuse contributors, and cost maintenance.</p> <p>Fix: Either delete the export (preferred) or demote it to unexported if it's still used within the file.</p> <p>If the symbol existed for historical reasons and might be needed again, move it to <code>quarantine/deadcode/</code> with a <code>.dead</code> extension. This preserves the code in git without polluting the live codebase:</p> <pre><code>quarantine/deadcode/internal/config/flag/flag.go.dead\n</code></pre> <p>Each <code>.dead</code> file includes a header:</p> <pre><code>// Dead exports quarantined from internal/config/flag/flag.go\n// Quarantined: 2026-04-02\n// Restore from git history if needed.\n</code></pre> <p>Rule: If a test-only allowlist entry is needed (the export exists only for test use), add the fully qualified symbol to <code>testOnlyExports</code> in <code>dead_exports_test.go</code>. Keep this list small; prefer eliminating the export.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#core-package-structure","level":2,"title":"Core Package Structure","text":"<p>Test: <code>TestCoreStructure</code></p> <p><code>core/</code> directories under <code>internal/cli/</code> must contain only <code>doc.go</code> and test files at the top level. All domain logic lives in subpackages. This prevents <code>core/</code> from becoming a god package.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>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</code></pre> <p>Rule: Extract each logical unit into its own subpackage under <code>core/</code>. Each subpackage gets a <code>doc.go</code>. The subpackage name should match the domain concept (<code>golang</code>, <code>check</code>, <code>fix</code>, <code>store</code>), not a generic label (<code>util</code>, <code>helper</code>).</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cross-package-types","level":2,"title":"Cross-Package Types","text":"<p>Test: <code>TestCrossPackageTypes</code></p> <p>When a type defined in one package is used from a different module (e.g., <code>cli/doctor</code> importing a type from <code>cli/notify</code>), the type has crossed its module boundary. Cross-cutting types belong in <code>internal/entity/</code> for discoverability.</p> <p>Before:</p> <pre><code>// 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</code></pre> <p>After:</p> <pre><code>// 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</code></pre> <p>Exempt: Types inside <code>entity/</code>, <code>proto/</code>, <code>core/</code> subpackages, and <code>config/</code> packages. Same-module usage (e.g., <code>cli/doctor/cmd/</code> using <code>cli/doctor/core/</code>) is not flagged.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#type-file-convention","level":2,"title":"Type File Convention","text":"<p>Test: <code>TestTypeFileConvention</code>, <code>TestTypeFileConventionReport</code></p> <p>Exported types in <code>core/</code> subpackages should live in <code>types.go</code> (the convention from CONVENTIONS.md), not scattered across implementation files. This makes type definitions discoverable. <code>TestTypeFileConventionReport</code> generates a diagnostic summary of all type placements for triage.</p> <p>Exception: <code>entity/</code> organizes by domain (<code>task.go</code>, <code>session.go</code>), <code>proto/</code> uses <code>schema.go</code>, and <code>err/</code> packages colocate error types with their domain context.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-yaml-linkage","level":2,"title":"DescKey / YAML Linkage","text":"<p>Test: <code>TestDescKeyYAMLLinkage</code></p> <p>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.</p> <p>Fix for orphan YAML key: Delete the YAML entry, or add the corresponding <code>DescKey</code> constant in <code>config/embed/{text,cmd,flag}/</code>.</p> <p>Fix for orphan DescKey: Delete the constant, or add the corresponding entry in the YAML file under <code>internal/assets/commands/text/</code>, <code>cmd/</code>, or <code>flag/</code>.</p> <p>If the orphan YAML entry was once valid but the feature was removed, move the YAML entry to a <code>.dead</code> file in <code>quarantine/deadcode/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#package-doc-quality","level":2,"title":"Package Doc Quality","text":"<p>Test: <code>TestPackageDocQuality</code></p> <p>Every package under <code>internal/</code> must have a <code>doc.go</code> with a meaningful package doc comment (at least 8 lines of real content). One-liners and file-list patterns (<code>// - foo.go</code>, <code>// Source files:</code>) are flagged because they drift as files change.</p> <p>Template:</p> <pre><code>// / 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</code></pre>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-regex-compilation","level":2,"title":"Inline Regex Compilation","text":"<p>Test: <code>TestNoInlineRegexpCompile</code></p> <p><code>regexp.MustCompile</code> and <code>regexp.Compile</code> inside function bodies recompile the pattern on every call. Compiled patterns belong at package level.</p> <p>Before:</p> <pre><code>func parse(s string) bool {\n re := regexp.MustCompile(`\\d{4}-\\d{2}-\\d{2}`)\n return re.MatchString(s)\n}\n</code></pre> <p>After:</p> <pre><code>// 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</code></pre> <p>Rule: All compiled regexes live in <code>internal/config/regex/</code> as package-level <code>var</code> declarations. Two tests enforce this: <code>TestNoInlineRegexpCompile</code> catches function-body compilation, and <code>TestNoRegexpOutsideRegexPkg</code> catches package-level compilation outside <code>config/regex/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#doc-comments","level":2,"title":"Doc Comments","text":"<p>Test: <code>TestDocComments</code></p> <p>All functions (exported and unexported), structs, and package-level variables must have a doc comment. Config packages allow group doc comments for <code>const</code> blocks.</p> <p>Before:</p> <pre><code>func buildIndex(entries []Entry) map[string]int {\n</code></pre> <p>After:</p> <pre><code>// 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</code></pre> <p>Rule: Every function, struct, and package-level <code>var</code> gets a doc comment in godoc format. Functions include <code>Parameters:</code> and <code>Returns:</code> sections. Structs with 2+ fields document every field. See CONVENTIONS.md for the full template.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#line-length","level":2,"title":"Line Length","text":"<p>Test: <code>TestLineLength</code></p> <p>Lines in non-test Go files must not exceed 80 characters. This is a hard check, not a suggestion.</p> <p>Before:</p> <pre><code>_ = trace.Record(fmt.Sprintf(cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum), state.Dir())\n</code></pre> <p>After:</p> <pre><code>ref := fmt.Sprintf(\n cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum,\n)\n_ = trace.Record(ref, state.Dir())\n</code></pre> <p>Rule: Break at natural points: function arguments, struct fields, chained calls. Long strings (URLs, struct tags) are the rare acceptable exception.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#literal-whitespace","level":2,"title":"Literal Whitespace","text":"<p>Test: <code>TestNoLiteralWhitespace</code></p> <p>Bare whitespace string and byte literals (<code>\"\\n\"</code>, <code>\"\\r\\n\"</code>, <code>\"\\t\"</code>) must not appear outside <code>internal/config/token/</code>. All other packages use the token constants.</p> <p>Before:</p> <pre><code>output := strings.Join(lines, \"\\n\")\n</code></pre> <p>After:</p> <pre><code>output := strings.Join(lines, token.Newline)\n</code></pre> <p>Rule: Whitespace literals are defined once in <code>internal/config/token/</code>. Use <code>token.Newline</code>, <code>token.Tab</code>, <code>token.CRLF</code>, etc.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-numeric-values","level":2,"title":"Magic Numeric Values","text":"<p>Test: <code>TestNoMagicValues</code></p> <p>Numeric literals in function bodies need constants, with narrow exceptions.</p> <p>Before:</p> <pre><code>if len(entries) > 100 {\n entries = entries[:100]\n}\n</code></pre> <p>After:</p> <pre><code>if len(entries) > config.MaxEntries {\n entries = entries[:config.MaxEntries]\n}\n</code></pre> <p>Exempt: <code>0</code>, <code>1</code>, <code>-1</code>, <code>2</code>-<code>10</code>, strconv radix/bitsize args (<code>10</code>, <code>32</code>, <code>64</code> in <code>strconv.Parse*</code>/<code>Format*</code>), octal permissions (caught separately by <code>TestNoRawPermissions</code>), and <code>const</code>/<code>var</code> definition sites.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-separators","level":2,"title":"Inline Separators","text":"<p>Test: <code>TestNoInlineSeparators</code></p> <p><code>strings.Join</code> calls must use token constants for their separator argument, not string literals.</p> <p>Before:</p> <pre><code>result := strings.Join(parts, \", \")\n</code></pre> <p>After:</p> <pre><code>result := strings.Join(parts, token.CommaSep)\n</code></pre> <p>Rule: Separator strings live in <code>internal/config/token/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stuttery-function-names","level":2,"title":"Stuttery Function Names","text":"<p>Test: <code>TestNoStutteryFunctions</code></p> <p>Function names must not redundantly include their package name as a PascalCase word boundary. Go callers already write <code>pkg.Function</code>, so <code>pkg.PkgFunction</code> stutters.</p> <p>Before:</p> <pre><code>// In package write\nfunc WriteJournal(cmd *cobra.Command, ...) {\n</code></pre> <p>After:</p> <pre><code>// In package write\nfunc Journal(cmd *cobra.Command, ...) {\n</code></pre> <p>Exempt: Identity functions like <code>write.Write</code> / <code>write.write</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#predicate-naming-no-ishascan-prefix","level":2,"title":"Predicate Naming (No <code>Is</code>/<code>Has</code>/<code>Can</code> Prefix)","text":"<p>Test: None (manual review convention)</p> <p>Exported methods that return <code>bool</code> must not use <code>Is</code>, <code>Has</code>, or <code>Can</code> prefixes. The predicate reads more naturally without them, especially at call sites where the package name provides context.</p> <p>Before:</p> <pre><code>func IsCompleted(t *Task) bool { ... }\nfunc HasChildren(n *Node) bool { ... }\nfunc IsExemptPackage(path string) bool { ... }\n</code></pre> <p>After:</p> <pre><code>func Completed(t *Task) bool { ... }\nfunc Children(n *Node) bool { ... } // or: ChildCount > 0\nfunc ExemptPackage(path string) bool { ... }\n</code></pre> <p>Rule: Drop the prefix. Private helpers may use prefixes when it reads more naturally (<code>isValid</code> in a local context is fine). This convention applies to exported methods and package-level functions. See CONVENTIONS.md \"Predicates\" section.</p> <p>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.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#mixed-visibility","level":2,"title":"Mixed Visibility","text":"<p>Test: <code>TestNoMixedVisibility</code></p> <p>Files with exported functions must not also contain unexported functions. Public API and private helpers live in separate files.</p> <p>Before:</p> <pre><code>load.go\n func Load() { ... } // exported\n func parseHeader() { ... } // unexported, violation\n</code></pre> <p>After:</p> <pre><code>load.go\n func Load() { ... } // exported only\nparse.go\n func parseHeader() { ... } // private helper\n</code></pre> <p>Exempt: Files with exactly one function, <code>doc.go</code>, test files.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stray-errgo-files","level":2,"title":"Stray Err.Go Files","text":"<p>Test: <code>TestNoStrayErrFiles</code></p> <p><code>err.go</code> files must only exist under <code>internal/err/</code>. Error constructors anywhere else create a broken-window pattern where contributors add local error definitions when they see a local <code>err.go</code>.</p> <p>Fix: Move the error constructor to <code>internal/err/<domain>/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cli-cmd-structure","level":2,"title":"CLI Cmd Structure","text":"<p>Test: <code>TestCLICmdStructure</code></p> <p>Each <code>cmd/$sub/</code> directory under <code>internal/cli/</code> may contain only <code>cmd.go</code>, <code>run.go</code>, <code>doc.go</code>, and test files. Extra <code>.go</code> files (helpers, output formatters, types) belong in the corresponding <code>core/</code> subpackage.</p> <p>Before:</p> <pre><code>internal/cli/doctor/cmd/root/\n cmd.go\n run.go\n format.go # violation: helper in cmd dir\n</code></pre> <p>After:</p> <pre><code>internal/cli/doctor/cmd/root/\n cmd.go\n run.go\ninternal/cli/doctor/core/format/\n format.go\n doc.go\n</code></pre>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-namespace","level":2,"title":"DescKey Namespace","text":"<p>Test: <code>TestUseConstantsOnlyInCobraUse</code>, <code>TestDescKeyOnlyInLookupCalls</code>, <code>TestNoWrongNamespaceLookup</code></p> <p>Three tests enforce DescKey/Use constant discipline:</p> <ol> <li><code>Use*</code> constants appear only in cobra <code>Use:</code> struct field assignments, never as arguments to <code>desc.Text()</code> or elsewhere.</li> <li><code>DescKey*</code> constants are passed only to <code>assets.CommandDesc()</code>, <code>assets.FlagDesc()</code>, or <code>desc.Text()</code>, never to cobra <code>Use:</code>.</li> <li>No cross-namespace lookups: <code>TextDescKey</code> must not be passed to <code>CommandDesc()</code>, <code>FlagDescKey</code> must not be passed to <code>Text()</code>, etc.</li> </ol>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#yaml-examples-registry-linkage","level":2,"title":"YAML Examples / Registry Linkage","text":"<p>Test: <code>TestExamplesYAMLLinkage</code>, <code>TestRegistryYAMLLinkage</code></p> <p>Every key in <code>examples.yaml</code> and <code>registry.yaml</code> must match a known entry type constant. Prevents orphan entries that are never rendered.</p> <p>Fix: Delete the orphan YAML entry, or add the corresponding constant in <code>config/entry/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#other-enforced-patterns","level":2,"title":"Other Enforced Patterns","text":"<p>These tests follow the same fix approach: extract the operation to its designated package:</p> Test Violation Fix <code>TestNoNakedErrors</code> <code>fmt.Errorf</code>/<code>errors.New</code> outside <code>internal/err/</code> Add error constructor to <code>internal/err/<domain>/</code> <code>TestNoRawFileIO</code> Direct <code>os.ReadFile</code>, <code>os.Create</code>, etc. Use <code>io.SafeReadFile</code>, <code>io.SafeWriteFile</code>, etc. <code>TestNoRawLogging</code> Direct <code>fmt.Fprintf(os.Stderr, ...)</code> Use <code>log/warn.Warn()</code> or <code>log/event.Append()</code> <code>TestNoExecOutsideExecPkg</code> <code>exec.Command</code> outside <code>internal/exec/</code> Add command to <code>internal/exec/<domain>/</code> <code>TestNoCmdPrintOutsideWrite</code> <code>cmd.Print*</code> outside <code>internal/write/</code> Add output helper to <code>internal/write/<domain>/</code> <code>TestNoRawPermissions</code> Octal literals (<code>0644</code>, <code>0755</code>) Use <code>config/fs.PermFile</code>, <code>config/fs.PermExec</code>, etc. <code>TestNoErrorsAs</code> <code>errors.As()</code> Use <code>errors.AsType()</code> (generic, Go 1.23+) <code>TestNoStringConcatPaths</code> <code>dir + \"/\" + file</code> Use <code>filepath.Join(dir, file)</code>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#general-fix-workflow","level":2,"title":"General Fix Workflow","text":"<p>When an audit test fails:</p> <ol> <li>Read the error message. It includes <code>file:line</code> and a description of the violation.</li> <li>Find the matching section above. The test name maps directly to a section.</li> <li>Apply the pattern. Most fixes are mechanical: extract to the right package, rename a variable, or replace a literal with a constant.</li> <li>Run <code>make test</code> before committing. Audit tests run as part of <code>go test ./internal/audit/</code>.</li> <li>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).</li> </ol>","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":"<p>Many tools help AI think.</p> <p><code>ctx</code> helps AI remember.</p> <ul> <li>Not by storing thoughts,</li> <li>but by preserving intent.</li> </ul>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#how-ctx-differs-from-similar-tools","level":2,"title":"How <code>ctx</code> Differs from Similar Tools","text":"<p>There are many tools in the AI ecosystem that touch parts of the context problem:</p> <ul> <li>Some manage prompts. </li> <li>Some retrieve data. </li> <li>Some provide runtime context objects. </li> <li>Some offer enterprise platforms.</li> </ul> <p><code>ctx</code> focuses on a different layer entirely.</p> <p>This page explains where <code>ctx</code> fits, and where it intentionally does not.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#the-core-distinction","level":2,"title":"The Core Distinction","text":"<p>Most tools treat context as input.</p> <p><code>ctx</code> treats context as infrastructure.</p> <p>That single difference explains nearly all of <code>ctx</code>'s design choices.</p> Question Most tools <code>ctx</code> 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":"<p>Examples include:</p> <ul> <li>prompt templates;</li> <li>reusable system prompts;</li> <li>prompt libraries;</li> <li>prompt versioning tools.</li> </ul> <p>These tools help you start a session.</p> <p>They do not help you continue one.</p> <p>Prompt tools:</p> <ul> <li>inject text at session start;</li> <li>are ephemeral by design;</li> <li>do not evolve with the project.</li> </ul> <p><code>ctx</code>:</p> <ul> <li>persists knowledge over time;</li> <li>accumulates decisions and learnings;</li> <li>makes the context part of the repository itself.</li> </ul> <p>Prompt tooling and <code>ctx</code> are complementary; not competing. Yet, they operate in different layers.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#retrieval-augmented-generation-rag","level":2,"title":"Retrieval-Augmented Generation (RAG)","text":"<p>RAG systems typically:</p> <ul> <li>index documents</li> <li>embed text</li> <li>retrieve chunks dynamically at runtime</li> </ul> <p>They are excellent for:</p> <ul> <li>large knowledge bases</li> <li>static documentation</li> <li>reference material</li> </ul> <p>RAG answers questions like:</p> <p>\"What information might be relevant right now?\"</p> <p><code>ctx</code> answers a different question:</p> <p>\"What have we already decided, learned, or committed to?\"</p> <p>Here are some key differences:</p> RAG <code>ctx</code> Statistical relevance Intentional relevance Embedding-based File-based Opaque retrieval Explicit structure Runtime query Persistent memory <p><code>ctx</code> does not replace RAG. Instead, it defines a persistent context layer that RAG can optionally augment.</p> <p>RAG belongs to the data plane; <code>ctx</code> defines the context control plane.</p> <p>It focuses on project memory, not knowledge search.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#agent-frameworks","level":2,"title":"Agent Frameworks","text":"<p>Agent frameworks often provide:</p> <ul> <li>task loops</li> <li>tool orchestration</li> <li>planner/executor patterns</li> <li>autonomous iteration</li> </ul> <p>These systems are powerful, but they typically assume that:</p> <ul> <li>memory is external</li> <li>context is injected</li> <li>state is transient</li> </ul> <p>Agent frameworks answer:</p> <p>\"How should the agent act?\"</p> <p><code>ctx</code> answers:</p> <p>\"What should the agent remember?\"</p> <p>Without persistent context, agents tend to:</p> <ul> <li>rediscover decisions</li> <li>repeat mistakes</li> <li>lose architectural intent</li> </ul> <p>This is why <code>ctx</code> pairs well with autonomous loop workflows:</p> <ul> <li>The loop provides iteration</li> <li><code>ctx</code> provides continuity</li> </ul> <p>Together, loops become cumulative instead of forgetful.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#sdk-level-context-objects","level":2,"title":"SDK-Level Context Objects","text":"<p>Some SDKs expose \"context\" objects that exist:</p> <ul> <li>inside a process</li> <li>during a request</li> <li>for the lifetime of a call chain</li> </ul> <p>These are extremely useful and completely different.</p> <p>SDK context objects:</p> <ul> <li>are in-memory</li> <li>disappear when the process ends</li> <li>are not shared across sessions</li> </ul> <p><code>ctx</code>:</p> <ul> <li>survives process restarts</li> <li>survives new chats</li> <li>survives new days</li> </ul> <p>They share a name, not a purpose.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#enterprise-context-platforms","level":2,"title":"Enterprise Context Platforms","text":"<p>Enterprise platforms often provide:</p> <ul> <li>centralized context services</li> <li>dashboards</li> <li>access control</li> <li>organizational knowledge layers</li> </ul> <p>These tools are designed for:</p> <ul> <li>teams</li> <li>governance</li> <li>compliance</li> <li>managed environments</li> </ul> <p><code>ctx</code> is intentionally:</p> <ul> <li>local-first: context lives next to your code, not behind a service boundary.</li> <li>file-based: everything important is a Markdown file you can read, diff, grep, and version-control.</li> <li>single-binary core: the context persistence path (<code>init</code>, <code>add</code>, <code>agent</code>, <code>status</code>, <code>drift</code>, <code>load</code>, <code>sync</code>, <code>compact</code>, <code>task</code>, <code>decision</code>, <code>learning</code>, and their siblings) is a single Go binary with no required runtime dependencies. Optional integrations (<code>ctx trace</code> (needs <code>git</code>), <code>ctx serve</code> (needs <code>zensical</code>), the <code>ctx</code> Hub (needs a running hub), Claude Code plugin (needs <code>claude</code>)) are opt-in and each declares its dependency explicitly.</li> <li>CLI-driven: every feature is reachable from the command line and scriptable.</li> <li>developer-controlled: no auto-updating cloud service, no telemetry, no account to sign up for.</li> </ul> <p>The core <code>ctx</code> binary does not require:</p> <ul> <li>a server</li> <li>a database</li> <li>an account</li> <li>a SaaS backend</li> <li>network connectivity (for core operations)</li> </ul> <p><code>ctx</code> optimizes for individual and small-team workflows where context should live next to code; not behind a service boundary.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#specific-tool-comparisons","level":2,"title":"Specific Tool Comparisons","text":"<p>Users often evaluate <code>ctx</code> against specific tools they already use. These comparisons clarify where responsibilities overlap, where they diverge, and where the tools are genuinely complementary.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#claude-code-memory-anthropic-auto-memory","level":3,"title":"Claude Code Memory / Anthropic Auto-Memory","text":"<p>Anthropic's auto-memory is tool-managed memory (L2): the model decides what to remember, stores it automatically, and retrieves it implicitly. <code>ctx</code> is system memory (L3): humans and agents explicitly curate decisions, learnings, and tasks in inspectable files.</p> <p>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. <code>ctx</code> files are plain Markdown in your repository, visible in diffs and code review.</p> <p>The two are complementary. <code>ctx</code> 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.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cursorrules-clauderules","level":3,"title":".Cursorrules / .Claude/rules","text":"<p>Static rule files (<code>.cursorrules</code>, <code>.claude/rules/</code>) declare conventions: coding style, forbidden patterns, preferred libraries. They are effective for what to do and load automatically at session start.</p> <p><code>ctx</code> 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, <code>ctx</code> context accumulates - each session can add to it, and token budgeting ensures only the most relevant context is injected.</p> <p>Use rule files for static conventions. Use <code>ctx</code> for evolving project memory.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#aider-read-watch","level":3,"title":"Aider <code>--read</code> / <code>--watch</code>","text":"<p>Aider's <code>--read</code> flag injects file contents at session start; <code>--watch</code> reloads them on change. The concept is similar to <code>ctx</code>'s \"load\" step: make the agent aware of specific files.</p> <p>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. <code>ctx</code> provides the full lifecycle: load, accumulate, persist, and budget.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#copilot-workspace","level":3,"title":"Copilot @Workspace","text":"<p>GitHub Copilot's <code>@workspace</code> performs workspace-wide code search. It answers \"what code exists?\" - finding function definitions, usages, and file structure across the repository.</p> <p><code>ctx</code> answers a different question: \"what did we decide?\" It stores architectural intent, not code indices. Copilot's workspace search and <code>ctx</code>'s project memory are orthogonal; one finds code, the other preserves the reasoning behind it.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cline-memory","level":3,"title":"Cline Memory","text":"<p>Cline's memory bank stores session context within the Cline extension. The motivation is similar to <code>ctx</code>: help the agent remember across sessions.</p> <p>The key difference is portability. Cline memory is tied to Cline - it does not transfer to Claude Code, Cursor, Aider, or any other tool. <code>ctx</code> is tool-agnostic: context lives in plain files that any editor, agent, or script can read. Switching tools does not mean losing memory.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-a-good-fit","level":2,"title":"When <code>ctx</code> Is a Good Fit","text":"<p><code>ctx</code> works best when:</p> <ul> <li>you want AI work to compound over time;</li> <li>architectural decisions matter;</li> <li>context must be inspectable;</li> <li>humans and AI must share the same source of truth;</li> <li>Git history should include why, not just what.</li> </ul>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-not-the-right-tool","level":2,"title":"When <code>ctx</code> Is Not the Right Tool","text":"<p><code>ctx</code> is probably not what you want if:</p> <ul> <li>you only need one-off prompts;</li> <li>you rely exclusively on RAG;</li> <li>you want autonomous agents without a human-readable state;</li> <li>you require centralized enterprise control;</li> <li>you want black-box memory systems,</li> </ul> <p>These are valid goals; just different ones.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>You Can't Import Expertise: why project-specific context matters more than generic best practices</li> </ul>","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":"<p>These are the properties that must hold for any valid <code>ctx</code> implementation.</p> <ul> <li>These are not features.</li> <li>These are constraints.</li> </ul> <p>A change that violates an invariant is a category error, not an improvement.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#cognitive-state-tiers","level":2,"title":"Cognitive State Tiers","text":"<p><code>ctx</code> distinguishes between three forms of state:</p> <ul> <li>Authoritative state: Versioned, inspectable artifacts that define intent and survive time.</li> <li>Delivery views: Deterministic assemblies of the authoritative state for a specific budget or workflow.</li> <li>Ephemeral working state: Local, transient, or sensitive data that assists interaction but does not define system truth.</li> </ul> <p>The invariants below apply primarily to the authoritative cognitive state.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#1-cognitive-state-is-explicit","level":2,"title":"1. Cognitive State Is Explicit","text":"<p>All authoritative context lives in artifacts that can be inspected, reviewed, and versioned.</p> <p>If something is important, it must exist as a file: Not only in a prompt, a chat, or a model's hidden memory.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#2-assembly-is-reproducible","level":2,"title":"2. Assembly Is Reproducible","text":"<p>Given the same:</p> <ul> <li>repository state,</li> <li>configuration,</li> <li>and inputs,</li> </ul> <p>context assembly produces the same result.</p> <p>Heuristics may rank or filter for delivery under constraints.</p> <p>They do not alter the authoritative state.</p>","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":"<p>The authoritative cognitive state must be stored in formats that a human can:</p> <ul> <li>read,</li> <li>diff,</li> <li>review,</li> <li>and edit directly.</li> </ul> <p>Sensitive working memory may be encrypted at rest. However, encryption must not become the only representation of authoritative knowledge.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#4-artifacts-outlive-sessions","level":2,"title":"4. Artifacts Outlive Sessions","text":"<p>Sessions are transient.</p> <p>Knowledge persists.</p> <p>Reasoning, decisions, and outcomes must remain available after the interaction that produced them has ended.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#5-authority-is-user-defined","level":2,"title":"5. Authority Is User-Defined","text":"<p>What enters the authoritative context is an explicit human decision.</p> <p>Models may suggest.</p> <p>Automation may assist.</p> <p>Selection is never implicit.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#6-operation-is-local-first","level":2,"title":"6. Operation Is Local-First","text":"<p>The core system must function without requiring network access or a remote service.</p> <p>External systems may extend <code>ctx</code>.</p> <p>They must not be required for its operation.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#7-versioning-is-the-memory-model","level":2,"title":"7. Versioning Is the Memory Model","text":"<p>The evolution of the authoritative cognitive state must be:</p> <ul> <li>preserved,</li> <li>inspectable,</li> <li>and branchable.</li> </ul> <p>Ephemeral and sensitive working state may use different retention and diff strategies by design.</p> <p>Understanding includes understanding how we arrived here.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#8-structure-enables-scale","level":2,"title":"8. Structure Enables Scale","text":"<p>Unstructured accumulation is not memory.</p> <p>Authoritative cognitive state must have a defined layout that:</p> <ul> <li>communicates intent,</li> <li>supports navigation,</li> <li>and prevents drift.</li> </ul>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#9-verification-is-the-scoreboard","level":2,"title":"9. Verification Is the Scoreboard","text":"<p>Claims without recorded outcomes are noise.</p> <p>Reality (observed and captured) is the only signal that compounds.</p> <p>This invariant defines a required direction:</p> <p>The authoritative state must be able to record expectation and result.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#10-capture-once-reuse-indefinitely","level":2,"title":"10. Capture Once, Reuse Indefinitely","text":"<p>Work that has already produced understanding must not be re-derived from scratch.</p> <p>Explored paths, rejected options, and validated conclusions are permanent assets.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#11-policies-are-encoded-not-remembered","level":2,"title":"11. Policies Are Encoded, Not Remembered","text":"<p>Alignment must not depend on recall or goodwill.</p> <p>Constraints that matter must exist in machine-readable form and participate in context assembly.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#12-the-system-explains-itself","level":2,"title":"12. The System Explains Itself","text":"<p>From the repository state alone it must be possible to determine:</p> <ul> <li>what was authoritative,</li> <li>what constraints applied.</li> </ul> <p>Delivery views may be optimized.</p> <p>They must not become the only explanation.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#non-goals","level":1,"title":"Non-Goals","text":"<p>To avoid category errors, <code>ctx</code> does not attempt to be:</p> <ul> <li>a skill,</li> <li>a prompt management tool,</li> <li>a chat history viewer,</li> <li>an autonomous agent runtime,</li> <li>a vector database,</li> <li>a hosted memory service.</li> </ul> <p>Such systems may integrate with <code>ctx</code>.</p> <p>They do not define it.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#implications-for-contributions","level":1,"title":"Implications for Contributions","text":"<p>Valid contributions:</p> <ul> <li>strengthen an invariant,</li> <li>reduce the cost of maintaining an invariant,</li> <li>or extend the system without violating invariants.</li> </ul> <p>Invalid contributions:</p> <ul> <li>introduce hidden authoritative state,</li> <li>replace reproducible assembly with non-reproducible behavior,</li> <li>make core operation depend on external services,</li> <li>reduce human inspectability of authoritative state,</li> <li>or bypass explicit user authority over what becomes authoritative.</li> </ul>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#the-contract","level":1,"title":"The Contract","text":"<p>Everything else (commands, skills, layouts, integrations, optimizations) is an implementation detail.</p> <p>These invariants are the system.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/dream-executor-contract/","level":1,"title":"Dream Executor Contract","text":"<p>The ctx-dream executor is the thing that actually runs an out-of-band dream pass: it reads <code>ideas/</code>, classifies and grounds each idea, and writes proposals into the <code>dreams/</code> notebook. ctx ships cron <code>claude -p</code> as the reference executor (see Run the Dream), but the executor is a documented contract, not a hardcoded assumption — any harness (a different AI CLI, a raw model-API loop, a CI runner) can implement it.</p> <p>This page is the contract. If you are wiring the dream into a non-Claude- Code harness, implement everything below.</p>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#what-ctx-owns-executor-agnostic","level":2,"title":"What ctx owns (executor-agnostic)","text":"<p>The Go package <code>internal/dream</code> owns the parts that must behave identically regardless of executor:</p> <ul> <li>The data contract — the proposal schema, the per-source state record (<code>dreams/state.json</code>), and the append-only ledger (<code>dreams/ledger.md</code>).</li> <li>Delta selection — the hash-based \"discipline clock\" that decides which ideas are new or changed since last triage.</li> <li>The two structural guards as callable logic — <code>WriteScope</code> and <code>Leak</code>.</li> </ul> <p>Your executor must use these, not reimplement them.</p>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#what-an-executor-must-do","level":2,"title":"What an executor must do","text":"<ol> <li>Run one bounded pass. Honor the <code>max</code> ideas and step/token <code>budget</code> from the <code>dream:</code> <code>.ctxrc</code> section. Read only the idea delta.</li> <li>Propose, never act, never touch canonical. The pass writes provenance-bearing proposals as a single JSON array to <code>dreams/<ts>/proposals.json</code> (the run directory is handed to the executor) and nothing else. It must not archive/merge/promote/tag ideas and must never write the five canonical files. (Acting on proposals is the human's <code>/ctx-serendipity</code> step, out of band from the pass.)</li> <li>Enforce the three guards structurally — not via prompt text. This is the load-bearing portability requirement:</li> <li>Write-scope — a write is allowed only under <code>dreams/</code> during a pass.</li> <li>Don't-leak — every write target must be gitignored (<code>git check-ignore</code>); a write that resolves to a tracked path is refused.</li> <li>Sources-as-data — idea text is wrapped as untrusted and is never executed as instructions. The Claude Code reference enforces write-scope and don't-leak with a PreToolUse hook (<code>guard.sh</code>) and sources-as-data via the skill's <code><<<UNTRUSTED>>></code> wrapping. A harness without hook interception must call the same checks in its own tool executor before every write — that is where <code>internal/dream.WriteScope</code> and <code>internal/dream.Leak</code> move. A prompt instruction is not enforcement.</li> <li>Fail loud. On auth failure, a missing executor binary, or a PATH/env problem, write a failmark (<code>dreams/.failed</code>) and exit non-zero. Never silently no-op — a dream that quietly does nothing is indistinguishable from a healthy one that found nothing, and that ambiguity rots trust.</li> <li>Serialize passes. Take the <code>dreams/.lock</code> before a pass; if it is held, exit cleanly. A review in progress reads a committed proposal set and is unaffected.</li> <li>Defer on a dirty tree. If the working tree under the dream's paths is dirty, defer the pass to avoid torn reads.</li> </ol>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#the-proposal-contract","level":2,"title":"The proposal contract","text":"<p>Proposals are a JSON array in <code>dreams/<ts>/proposals.json</code>, each element matching the <code>internal/dream.Proposal</code> schema:</p> <pre><code>{\n \"id\": \"<stable-id>\",\n \"targets\": [\"ideas/<file>.md\"],\n \"status\": \"implemented|duplicate|meritorious|sidenote|blog-candidate\",\n \"action\": \"archive|merge|promote|mark-blog|keep\",\n \"evidence\": \"<commit / spec path / near-neighbor + why>\",\n \"confidence\": \"high|med|low\",\n \"rationale\": \"<one-line why>\"\n}\n</code></pre> <p><code>id</code> must be stable (so a re-run does not duplicate an already-decided proposal, and so v2 canonical supersession is not foreclosed). An executor must not re-emit a proposal whose <code>id</code> already appears in <code>dreams/ledger.md</code> unless the source content changed.</p>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#why-the-contract-not-just-cron","level":2,"title":"Why the contract, not just cron","text":"<p>The ctx dev team is multi-tool, and ctx's users are more so. Hardcoding \"the dream is cron + Claude Code\" would exclude everyone else and couple a memory feature to one harness. Keeping the cognition in a skill and the invariants in <code>internal/dream</code> means the same dream — same guards, same ledger, same proposals — runs anywhere the contract is met. See <code>specs/ctx-dream.md</code> and the decision record in <code>.context/DECISIONS.md</code> (\"ctx-dream executor is a documented contract\").</p>","path":["Reference","Dream Executor Contract"],"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 <code>ctx</code> Scratchpad?","text":"<p>A one-liner scratchpad, encrypted at rest, synced via <code>git</code>.</p> <p>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.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#encrypted-by-default","level":2,"title":"Encrypted by Default","text":"<p>Scratchpad entries are encrypted with <code>AES-256-GCM</code> before touching the disk.</p> Component Path Git status Encryption key <code>~/.ctx/.ctx.key</code> User-level, <code>0600</code> permissions Encrypted data <code>.context/scratchpad.enc</code> Committed <p>The key is generated automatically during <code>ctx init</code> (256-bit via <code>crypto/rand</code>) and stored at <code>~/.ctx/.ctx.key</code>. One key per machine, shared across all projects.</p> <p>The ciphertext format is <code>[12-byte nonce][ciphertext+tag]</code>. No external dependencies: Go stdlib only.</p> <p>Because the key is <code>.gitignore</code>d and the data is committed, you get:</p> <ul> <li>At-rest encryption: the <code>.enc</code> file is opaque without the key</li> <li>Git sync: push/pull the encrypted file like any other tracked file</li> <li>Key separation: the key never leaves the machine unless you copy it</li> </ul>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#commands","level":2,"title":"Commands","text":"Command Purpose <code>ctx pad</code> List all entries (numbered 1-based) <code>ctx pad show N</code> Output raw text of entry N (no prefix, pipe-friendly) <code>ctx pad add \"text\"</code> Append a new entry <code>ctx pad rm ID [ID...]</code> Remove entries by stable ID (supports ranges: <code>3-5</code>) <code>ctx pad edit N \"text\"</code> Replace entry N with new text <code>ctx pad edit N --append \"text\"</code> Append text to the end of entry N <code>ctx pad edit N --prepend \"text\"</code> Prepend text to the beginning of entry N <code>ctx pad edit N --tag tagname</code> Add a tag to entry N <code>ctx pad add TEXT --file PATH</code> Ingest a file as a blob entry (TEXT is the label) <code>ctx pad show N --out PATH</code> Write decoded blob content to a file <code>ctx pad normalize</code> Reassign entry IDs as 1..N <code>ctx pad mv N M</code> Move entry from position N to position M <code>ctx pad resolve</code> Show both sides of a merge conflict for resolution <code>ctx pad import FILE</code> Bulk-import lines from a file (or stdin with <code>-</code>) <code>ctx pad import --blob DIR</code> Import directory files as blob entries <code>ctx pad export [DIR]</code> Export all blob entries to a directory as files <code>ctx pad merge FILE...</code> Merge entries from other scratchpad files into current <code>ctx pad --tag TAG</code> List entries filtered by tag (prefix with <code>~</code> to exclude) <code>ctx pad tags</code> List all tags with counts <code>ctx pad tags --json</code> List all tags with counts as JSON <p>All commands decrypt on read, operate on plaintext in memory, and re-encrypt on write. The key file is never printed to stdout.</p> <p>For blob entries, <code>--append</code>, <code>--prepend</code>, and <code>--tag</code> modify the label while preserving the blob data.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#examples","level":3,"title":"Examples","text":"<pre><code># 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</code></pre>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#tags","level":2,"title":"Tags","text":"<p>Entries can contain <code>#word</code> tags for lightweight categorization. Tags are convention-based: any <code>#word</code> token in an entry's text is a tag. No special syntax to add or remove them; use the existing <code>add</code> and <code>edit</code> commands.</p> <pre><code># 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</code></pre> <p>Entry IDs are stable; they don't shift when other entries are deleted, so <code>ctx pad rm 3</code> always targets the same entry. Use <code>ctx pad normalize</code> to reassign IDs as 1..N if gaps bother you. Tags are case-sensitive and support letters, digits, hyphens, and underscores (<code>#high-priority</code>, <code>#v2</code>, <code>#my_tag</code>).</p> <p>For blob entries, tags are extracted from the label only.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#bulk-import-and-export","level":2,"title":"Bulk Import and Export","text":"<p>Import lines from a file in bulk (each non-empty line becomes an entry):</p> <pre><code># Import from a file\nctx pad import notes.txt\n\n# Import from stdin\ngrep TODO *.go | ctx pad import -\n</code></pre> <p>Export all blob entries to a directory as files:</p> <pre><code># 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</code></pre>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#merging-scratchpads","level":2,"title":"Merging Scratchpads","text":"<p>Combine entries from other scratchpad files into your current pad. Useful when merging work from parallel worktrees, other machines, or teammates:</p> <pre><code># 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</code></pre> <p>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.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#file-blobs","level":2,"title":"File Blobs","text":"<p>The scratchpad can store small files (up to 64 KB) as blob entries. Files are base64-encoded and stored with a human-readable label.</p> <pre><code># 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</code></pre> <p>Blob entries are encrypted identically to text entries. The internal format is <code>label:::base64data</code>: You never need to construct this manually.</p> Constraint Value Max file size (pre-encoding) 64 KB Storage format <code>label:::base64(content)</code> Display <code>label [BLOB]</code> in listings <p>When Should You Use Blobs</p> <p>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.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#using-with-ai","level":2,"title":"Using with AI","text":"<p>Use Natural Language</p> <p>As in many <code>ctx</code> features, the <code>ctx</code> scratchpad can also be used with natural langauge. You don't have to memorize the CLI commands.</p> <p>CLI gives you \"precision\", whereas natural language gives you flow.</p> <p>The <code>/ctx-pad</code> skill maps natural language to <code>ctx pad</code> commands. You don't need to remember the syntax:</p> You say What happens \"jot down: check DNS after deploy\" <code>ctx pad add \"check DNS after deploy\"</code> \"show my scratchpad\" <code>ctx pad</code> \"delete the third entry\" <code>ctx pad rm 3</code> \"update entry 2 to include the new endpoint\" <code>ctx pad edit 2 \"...\"</code> \"move entry 4 to the top\" <code>ctx pad mv 4 1</code> \"import my notes from notes.txt\" <code>ctx pad import notes.txt</code> \"export all blobs to ./backup\" <code>ctx pad export ./backup</code> \"merge the scratchpad from the worktree\" <code>ctx pad merge worktree/.context/scratchpad.enc</code> <p>The skill handles the translation. You describe what you want in plain English; the agent picks the right command.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#worktrees","level":2,"title":"Worktrees","text":"<p>The encryption key lives at <code>~/.ctx/.ctx.key</code> (outside the project directory). Because all worktrees on the same machine share this path, <code>ctx pad</code> works in worktrees automatically - no special setup needed.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#key-distribution","level":2,"title":"Key Distribution","text":"<p>The encryption key (<code>~/.ctx/.ctx.key</code>) stays on the machine where it was generated. <code>ctx</code> never transmits it.</p> <p>To share the scratchpad across machines:</p> <ol> <li>Copy the key manually: <code>scp</code>, USB drive, password manager.</li> <li>Push/pull the <code>.enc</code> file via git as usual.</li> <li>Both machines can now read and write the same scratchpad.</li> </ol> <p>Never Commit the Key</p> <p>The key is <code>.gitignore</code>d by default. If you override this, anyone with repo access can decrypt your scratchpad. </p> <p>Treat the key like an SSH private key.</p> <p>See the Syncing Scratchpad Notes Across Machines recipe for a step-by-step walkthrough.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#plaintext-override","level":2,"title":"Plaintext Override","text":"<p>For projects where encryption is unnecessary, disable it in <code>.ctxrc</code>:</p> <pre><code>scratchpad_encrypt: false\n</code></pre> <p>In plaintext mode:</p> <ul> <li>Entries are stored in <code>.context/scratchpad.md</code> instead of <code>.enc</code>.</li> <li>No key is generated or required.</li> <li>All <code>ctx pad</code> commands work identically.</li> <li>The file is human-readable and diffable.</li> </ul> <p>When Should You Use Plaintext</p> <p>Plaintext mode is useful for non-sensitive projects, solo work where encryption adds friction, or when you want scratchpad entries visible in <code>git diff</code>.</p>","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 <code>TASKS.md</code> Trade-offs with rationale <code>DECISIONS.md</code> Reusable lessons with context/lesson/application <code>LEARNINGS.md</code> Codified patterns and standards <code>CONVENTIONS.md</code> <p>Rule of thumb: </p> <ul> <li>If it needs structure or will be referenced months later, use a context file (i.e. <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>TASKS.md</code>). </li> <li>If it is working memory for the current session or week, use the scratchpad.</li> </ul>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#see-also","level":2,"title":"See Also","text":"<ul> <li>Syncing Scratchpad Notes Across Machines: Key distribution, push/pull workflow, merge conflict resolution</li> <li>Using the Scratchpad: Natural language examples, blob workflow, when to use scratchpad vs context files</li> <li>Context Files: Format and conventions for all <code>.context/</code> files</li> <li>Security: Trust model and permission hygiene</li> </ul>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/session-journal/","level":1,"title":"Session Journal","text":"<p>Important Security Note</p> <p>Session journals contain sensitive data such as file contents, commands, API keys, internal discussions, error messages with stack traces, and more. </p> <p>The <code>.context/journal-site/</code> and <code>.context/journal-obsidian/</code> directories MUST be <code>.gitignore</code>d.</p> <ul> <li>DO NOT host your journal publicly.</li> <li>DO NOT commit your journal files to version control.</li> </ul>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#browse-your-session-history","level":2,"title":"Browse Your Session History","text":"<p><code>ctx</code>'s Session Journal turns your AI coding sessions into a browsable, searchable, and editable archive.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#quick-start","level":2,"title":"Quick Start","text":"<p>After using <code>ctx</code> for a couple of sessions, you can generate a journal site with:</p> <pre><code># Import all sessions to markdown\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n</code></pre> <p>Then open http://localhost:8000 to browse your sessions.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#what-you-get","level":2,"title":"What You Get","text":"<p>The Session Journal gives you:</p> <ul> <li>Browsable history: Navigate through all your AI sessions by date</li> <li>Full conversations: See every message, tool use, and result</li> <li>Token usage: Track how many tokens each session consumed</li> <li>Search: Find sessions by content, project, or date</li> <li>Dark mode: Easy on the eyes for late-night archaeology</li> </ul> <p>Each session page includes the following sections:</p> 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":"<pre><code># Import new sessions and complete any whose transcript has grown\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</code></pre> <p>Imported sessions go to <code>.context/journal/</code> as editable Markdown files.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#2-generate-the-site","level":3,"title":"2. Generate the Site","text":"<pre><code># 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</code></pre> <p>The site is generated in <code>.context/journal-site/</code> by default.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#3-browse-and-search","level":3,"title":"3. Browse and Search","text":"<p>Open http://localhost:8000 after running <code>--serve</code>.</p> <ul> <li>Use the sidebar to navigate by date</li> <li>Use search (<code>/</code> key) to find specific content</li> <li>Click any session to see the full conversation</li> </ul>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#editing-sessions","level":2,"title":"Editing Sessions","text":"<p>Imported sessions are plain Markdown in <code>.context/journal/</code>. You can:</p> <ul> <li>Add summaries: Fill in the <code>## Summary</code> section</li> <li>Add notes: Insert your own commentary anywhere</li> <li>Highlight key moments: Use Markdown formatting</li> <li>Delete noise: Remove irrelevant tool outputs</li> </ul> <p>After editing, regenerate the site:</p> <pre><code>ctx journal site --serve\n</code></pre> Self-Healing by Default <p>Running <code>ctx journal import --all</code> imports new sessions and completes any whose source transcript has grown since the last import, re-rendering them up to the current end. Sessions whose source is unchanged are skipped, and hand-edited entries are detected and left untouched with a warning (your edits and enrichments are never clobbered).</p> <p><code>--regenerate</code> is an edge-case full re-render, not the routine way to update. Reach for it after a render-format change or to heal a pre-self-heal truncated entry. Conversation content is regenerated, but YAML frontmatter (topics, type, outcome, etc.) is preserved. You'll be prompted before any existing files are overwritten; add <code>-y</code> to skip the prompt.</p> <p>Use <code>--keep-frontmatter=false</code> to discard enriched frontmatter during regeneration.</p> <p>Locked entries (via <code>ctx journal lock</code>) are always skipped, regardless of flags. If you prefer to add <code>locked: true</code> to frontmatter during enrichment, run <code>ctx journal sync</code> to propagate the lock state to <code>.state.json</code>.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#large-sessions","level":2,"title":"Large Sessions","text":"<p>Sessions with many messages (200+) are automatically split into multiple parts for better browser performance. Navigation links connect the parts:</p> <pre><code>session-abc123.md (Part 1 of 3)\nsession-abc123-p2.md (Part 2 of 3)\nsession-abc123-p3.md (Part 3 of 3)\n</code></pre>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#suggestion-sessions","level":2,"title":"Suggestion Sessions","text":"<p>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.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enriching-journal-entries","level":2,"title":"Enriching Journal Entries","text":"<p>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.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#why-enrich","level":3,"title":"Why Enrich?","text":"<p>Without enrichment, you have timestamps and raw conversations. With enrichment:</p> <ul> <li>Find sessions by topic: \"Show me all auth-related sessions\"</li> <li>Filter by outcome: \"What did I abandon vs complete?\"</li> <li>Track technology usage: \"When did I last work with PostgreSQL?\"</li> <li>Identify key files: Jump directly to the files discussed</li> <li>Get summaries: Understand what happened without reading transcripts</li> </ul>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#the-frontmatter-schema","level":3,"title":"The Frontmatter Schema","text":"<p>Enriched entries begin with YAML frontmatter:</p> <pre><code>---\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</code></pre> Field Required Description <code>title</code> Yes Descriptive title (not the session slug) <code>date</code> Yes Session date (YYYY-MM-DD) <code>type</code> Yes Session type (see below) <code>outcome</code> Yes How the session ended (see below) <code>topics</code> No Subject areas discussed <code>technologies</code> No Languages, databases, frameworks <code>libraries</code> No Specific packages or libraries used <code>key_files</code> No Important files created or modified <p>Type values:</p> Type When to use <code>feature</code> Building new functionality <code>bugfix</code> Fixing broken behavior <code>refactor</code> Restructuring without behavior change <code>exploration</code> Research, learning, experimentation <code>debugging</code> Investigating issues <code>documentation</code> Writing docs, comments, README <p>Outcome values:</p> Outcome Meaning <code>completed</code> Goal achieved <code>partial</code> Some progress, work continues <code>abandoned</code> Stopped pursuing this approach <code>blocked</code> Waiting on external dependency","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-ctx-journal-enrich","level":3,"title":"Using <code>/ctx-journal-enrich</code>","text":"<p>The <code>/ctx-journal-enrich</code> skill automates enrichment by analyzing conversation content and proposing metadata.</p> <p>Invoke by session identifier:</p> <pre><code>/ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-01-24\n/ctx-journal-enrich 76fe2ab9\n</code></pre> <p>The skill will:</p> <ol> <li>Check if locked - locked entries are skipped (same as export);</li> <li>Find the matching journal file;</li> <li>Read and analyze the conversation;</li> <li>Propose frontmatter (type, topics, outcome, technologies);</li> <li>Generate a 2-3 sentence summary;</li> <li>Extract decisions, learnings, and tasks mentioned;</li> <li>Show a diff and ask for confirmation before writing.</li> </ol>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#before-and-after","level":3,"title":"Before and After","text":"<p>Before enrichment:</p> <pre><code># 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</code></pre> <p>After enrichment:</p> <pre><code>---\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</code></pre>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enrichment-and-site-generation","level":3,"title":"Enrichment and Site Generation","text":"<p>The journal site generator uses enriched metadata for better organization:</p> <ul> <li>Titles appear in navigation instead of slugs</li> <li>Summaries provide context in the index</li> <li>Topics enable filtering (when using search)</li> <li>Types allow grouping by work category</li> </ul> <p>Future improvements will add topic-based navigation and outcome filtering to the generated site.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#batch-enrichment","level":3,"title":"Batch Enrichment","text":"<p>To enrich multiple sessions, process them one at a time:</p> <pre><code># List unenriched sessions (those without frontmatter)\ngrep -L \"^---$\" .context/journal/*.md | head -10\n</code></pre> <p>Then run <code>/ctx-journal-enrich</code> on each. Enrichment is intentionally interactive to ensure accuracy.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#obsidian-vault-export","level":2,"title":"Obsidian Vault Export","text":"<p>If you use Obsidian for knowledge management, you can export your journal as an Obsidian vault instead of (or alongside) the static site:</p> <pre><code>ctx journal obsidian\n</code></pre> <p>This generates a vault in <code>.context/journal-obsidian/</code> with:</p> <ul> <li>Wikilinks (<code>[[target|display]]</code>) instead of Markdown links</li> <li>MOC pages (Map of Content) for topics, key files, and session types</li> <li>Related sessions footer per entry: links to entries sharing the same topics</li> <li>Transformed frontmatter: <code>topics</code> renamed to <code>tags</code> (Obsidian-recognized), <code>aliases</code> added from title for search</li> <li>Graph-optimized structure: MOC hubs and cross-linked entries create dense graph connectivity</li> </ul> <p>To use: open the output directory in Obsidian (\"Open folder as vault\").</p> <pre><code># Custom output directory\nctx journal obsidian --output ~/vaults/ctx-journal\n</code></pre> <p>Static Site vs Obsidian Vault</p> <p>Use <code>ctx journal site</code> when you want a web-browsable archive with search and dark mode. Use <code>ctx journal obsidian</code> when you want graph view, backlinks, and tag-based navigation inside Obsidian. Both use the same enriched source entries: you can generate both.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#full-pipeline","level":2,"title":"Full Pipeline","text":"<p>The complete journal workflow has four stages. Each is idempotent: safe to re-run, and stages skip already-processed entries.</p> <pre><code>import → enrich → rebuild\n</code></pre> Stage Command / Skill What it does Skips if Import <code>ctx journal import --all</code> Converts session JSONL to Markdown Source unchanged since last import Enrich <code>/ctx-journal-enrich</code> Adds frontmatter, summaries, topics Frontmatter already present Rebuild <code>ctx journal site --build</code> Generates static HTML site (never) Obsidian <code>ctx journal obsidian</code> Generates Obsidian vault with wikilinks (never) <p>One-Command Pipeline</p> <p><code>/ctx-journal-enrich-all</code> handles import automatically - it detects unimported sessions and imports them before enriching. You only need to run <code>ctx journal site --build</code> afterward.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-make-journal","level":3,"title":"Using <code>make journal</code>","text":"<p>If your project includes <code>Makefile.ctx</code> (deployed by <code>ctx init</code>), the first and last stages are combined:</p> <pre><code>make journal # import + rebuild\n</code></pre> <p>After it runs, it reminds you to enrich in Claude Code:</p> <pre><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</code></pre> <p>Rendering Issues?</p> <p>If individual entries have rendering problems (broken fences, malformed lists), check the programmatic normalization in the import pipeline. Most cases are handled automatically during <code>ctx journal import</code>.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#tips","level":2,"title":"Tips","text":"<p>Daily workflow: <pre><code># Import, browse, then enrich in Claude Code\nmake journal && make journal-serve\n# Then in Claude Code: /ctx-journal-enrich <session>\n</code></pre></p> <p>After a productive session: <pre><code># Import just that session and add notes\nctx journal import <session-id>\n# Edit .context/journal/<session>.md\n# Regenerate: ctx journal site\n</code></pre></p> <p>Searching across all sessions: <pre><code># Use grep on the journal directory\ngrep -r \"authentication\" .context/journal/\n</code></pre></p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#requirements","level":2,"title":"Requirements","text":"Use <code>pipx</code> for <code>zensical</code> <p><code>pip install zensical</code> may install a non-functional stub on system Python. Using <code>venv</code> has other issues too.</p> <p>These issues especially happen on Mac OSX.</p> <p>Use <code>pipx install zensical</code>, which creates an isolated environment and handles Python version management automatically.</p> <p>The journal site uses zensical for static site generation:</p> <pre><code>pipx install zensical\n</code></pre>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx journal</code>: Session discovery and listing</li> <li><code>ctx journal site</code>: Static site generation</li> <li><code>ctx journal obsidian</code>: Obsidian vault export</li> <li>Context Files: The <code>.context/</code> directory structure</li> </ul>","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":"<p>Skills are slash commands that run inside your AI assistant (e.g., <code>/ctx-next</code>), as opposed to CLI commands that run in your terminal (e.g., <code>ctx status</code>). </p> <p>Skills give your agent structured workflows: It knows what to read, what to run, and when to ask. Most wrap one or more <code>ctx</code> CLI commands with opinionated behavior on top. </p> <p>Skills Are Best Used Conversationally</p> <p>The beauty of <code>ctx</code> 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.</p> <p>See the Prompting Guide for natural-language triggers that invoke these skills conversationally.</p> <p>However, when you need a more precise control, you have the option to invoke the relevant skills directly.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#all-skills","level":2,"title":"All Skills","text":"Skill Description Type <code>/ctx-remember</code> Recall project context and present structured readback user-invocable <code>/ctx-wrap-up</code> End-of-session context persistence ceremony user-invocable <code>/ctx-status</code> Show context summary with interpretation user-invocable <code>/ctx-agent</code> Load full context packet for AI consumption user-invocable <code>/ctx-next</code> Suggest 1-3 concrete next actions with rationale user-invocable <code>/ctx-commit</code> Commit with integrated context persistence user-invocable <code>/ctx-reflect</code> Pause and reflect on session progress user-invocable <code>/ctx-task-add</code> Add actionable task to TASKS.md user-invocable <code>/ctx-decision-add</code> Record architectural decision with rationale user-invocable <code>/ctx-learning-add</code> Record gotchas and lessons learned user-invocable <code>/ctx-convention-add</code> Record coding convention for consistency user-invocable <code>/ctx-archive</code> Archive completed tasks from TASKS.md user-invocable <code>/ctx-pad</code> Manage encrypted scratchpad entries user-invocable <code>/ctx-history</code> Browse and import AI session history user-invocable <code>/ctx-journal-enrich</code> Enrich single journal entry with metadata user-invocable <code>/ctx-journal-enrich-all</code> Full journal pipeline: export if needed, then batch-enrich user-invocable <code>/ctx-blog</code> Generate blog post draft from project activity user-invocable <code>/ctx-blog-changelog</code> Generate themed blog post from a commit range user-invocable <code>/ctx-humanize</code> Remove formulaic LLM writing patterns from human-facing prose user-invocable <code>/ctx-consolidate</code> Consolidate redundant learnings or decisions user-invocable <code>/ctx-drift</code> Detect and fix context drift user-invocable <code>/ctx-prompt-audit</code> Analyze prompting patterns for improvement user-invocable <code>/ctx-link-check</code> Audit docs for dead internal and external links user-invocable <code>/ctx-permission-sanitize</code> Audit Claude Code permissions for security risks user-invocable <code>/ctx-brainstorm</code> Structured design dialogue before implementation user-invocable <code>/ctx-plan</code> Stress-test a plan through adversarial interview user-invocable <code>/ctx-spec</code> Scaffold a feature spec from a project template user-invocable <code>/ctx-task-out</code> Decompose a committed spec into a per-milestone plan user-invocable <code>/ctx-plan-import</code> Import Claude Code plan files into project specs user-invocable <code>/ctx-implement</code> Execute a plan step-by-step with verification user-invocable <code>/ctx-loop</code> Generate autonomous loop script user-invocable <code>/ctx-worktree</code> Manage git worktrees for parallel agents user-invocable <code>/ctx-architecture</code> Build and maintain architecture maps user-invocable <code>/ctx-architecture-failure-analysis</code> Adversarial failure analysis for correctness bugs user-invocable <code>/ctx-remind</code> Manage session-scoped reminders user-invocable <code>/ctx-doctor</code> Troubleshoot <code>ctx</code> behavior with health checks and event analysis user-invocable <code>/ctx-skill-audit</code> Audit skills against Anthropic prompting best practices user-invocable <code>/ctx-skill-create</code> Create, improve, and test skills user-invocable <code>/ctx-pause</code> Pause context hooks for this session user-invocable <code>/ctx-resume</code> Resume context hooks after a pause user-invocable <code>/ctx-kb-ingest</code> Editorial KB pass (topic-page / triage / evidence-only) user-invocable <code>/ctx-kb-ask</code> Q&A grounded in the KB; refuses to web-jump user-invocable <code>/ctx-kb-site-review</code> Mechanical KB structural audit user-invocable <code>/ctx-kb-ground</code> Re-ground the KB against listed external sources user-invocable <code>/ctx-kb-note</code> Park a finding in <code>ingest/findings.md</code> user-invocable <code>/ctx-handover</code> Handover step delegated by <code>/ctx-wrap-up</code>; folds postdated closeouts sub-mechanism","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-lifecycle","level":2,"title":"Session Lifecycle","text":"<p>Skills for starting, running, and ending a productive session.</p> <p>Session Ceremonies</p> <p>Two skills in this group are ceremony skills: <code>/ctx-remember</code> (session start) and <code>/ctx-wrap-up</code> (session end). Unlike other skills that work conversationally, these should be invoked as explicit slash commands for completeness. See Session Ceremonies.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remember","level":3,"title":"<code>/ctx-remember</code>","text":"<p>Recall project context and present a structured readback. Ceremony skill: invoke explicitly at session start.</p> <p>Wraps: <code>ctx agent --budget 4000</code>, <code>ctx journal source --limit 3</code>, reads TASKS.md, DECISIONS.md, LEARNINGS.md</p> <p>See also: Session Ceremonies, The Complete Session</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-status","level":3,"title":"<code>/ctx-status</code>","text":"<p>Show context summary (files, token budget, tasks, recent activity) with interpreted suggestions.</p> <p>Wraps: <code>ctx status [--verbose] [--json]</code></p> <p>See also: The Complete Session, <code>ctx status</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-agent","level":3,"title":"<code>/ctx-agent</code>","text":"<p>Load the full context packet optimized for AI consumption. Also runs automatically via the PreToolUse hook with cooldown.</p> <p>Wraps: <code>ctx agent [--budget] [--format] [--cooldown] [--session]</code></p> <p>See also: The Complete Session, <code>ctx agent</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-next","level":3,"title":"<code>/ctx-next</code>","text":"<p>Suggest 1-3 concrete next actions ranked by priority, momentum, and unblocked status.</p> <p>Wraps: reads TASKS.md, <code>ctx journal source --limit 3</code></p> <p>See also: The Complete Session, Tracking Work Across Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-commit","level":3,"title":"<code>/ctx-commit</code>","text":"<p>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.</p> <p>Wraps: <code>git add</code>, <code>git commit</code>, optionally chains to <code>/ctx-decision-add</code> and <code>/ctx-learning-add</code></p> <p>See also: The Complete Session</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-reflect","level":3,"title":"<code>/ctx-reflect</code>","text":"<p>Pause and reflect on session progress. Walks through a checklist of learnings, decisions, task completions, and session notes to persist.</p> <p>Wraps: chains to <code>ctx learning add</code>, <code>ctx decision add</code>, manual TASKS.md updates</p> <p>See also: The Complete Session, Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-wrap-up","level":3,"title":"<code>/ctx-wrap-up</code>","text":"<p>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 <code>ctx add</code>. Offers <code>/ctx-commit</code> if uncommitted changes remain. Always delegates to <code>/ctx-handover</code> as its final step, regardless of whether <code>.context/kb/</code> exists: KB presence only affects what gets folded into the handover, not whether it is written. Ceremony skill: invoke explicitly at session end.</p> <p>Trigger phrases: \"let's wrap up\", \"save context\", \"save state\", \"leave a handover\", \"before I go\", \"stepping away\", \"end of session\"</p> <p>Wraps: <code>git diff --stat</code>, <code>git log</code>, <code>ctx learning add</code>, <code>ctx decision add</code>, <code>ctx convention add</code>, <code>ctx task add</code>, chains to <code>/ctx-commit</code>, delegates to <code>/ctx-handover</code></p> <p>See also: Session Ceremonies, The Complete Session, <code>/ctx-handover</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#context-persistence","level":2,"title":"Context Persistence","text":"<p>Skills for recording work artifacts: tasks, decisions, learnings, conventions: into <code>.context/</code> files.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-task-add","level":3,"title":"<code>/ctx-task-add</code>","text":"<p>Add an actionable task with optional priority and phase section.</p> <p>Wraps: <code>ctx task add \"description\" [--priority high|medium|low] --session-id ID --branch BR --commit HASH</code></p> <p>See also: Tracking Work Across Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-decision-add","level":3,"title":"<code>/ctx-decision-add</code>","text":"<p>Record an architectural decision with context, rationale, and consequence. Supports Y-statement (lightweight) and full ADR formats.</p> <p>Wraps: <code>ctx decision add \"title\" --context \"...\" --rationale \"...\" --consequence \"...\" --session-id ID --branch BR --commit HASH</code></p> <p>See also: Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-learning-add","level":3,"title":"<code>/ctx-learning-add</code>","text":"<p>Record a project-specific gotcha, bug, or unexpected behavior. Filters for insights that are searchable, project-specific, and required real effort to discover.</p> <p>Wraps: <code>ctx learning add \"title\" --context \"...\" --lesson \"...\" --application \"...\" --session-id ID --branch BR --commit HASH</code></p> <p>See also: Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-convention-add","level":3,"title":"<code>/ctx-convention-add</code>","text":"<p>Record a coding convention that should be standardized across sessions. Targets patterns seen 2-3+ times.</p> <p>Wraps: <code>ctx convention add \"rule\" --section \"Name\"</code></p> <p>See also: Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-archive","level":3,"title":"<code>/ctx-archive</code>","text":"<p>Archive completed tasks from TASKS.md to a timestamped file in <code>.context/archive/</code>. Preserves phase headers for traceability.</p> <p>Wraps: <code>ctx task archive [--dry-run]</code></p> <p>See also: Tracking Work Across Sessions</p>","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":"<code>/ctx-pad</code>","text":"<p>Manage the encrypted scratchpad: add, remove, edit, and reorder one-liner notes. Encrypted at rest with AES-256-GCM.</p> <p>Wraps: <code>ctx pad</code>, <code>ctx pad add</code>, <code>ctx pad rm</code>, <code>ctx pad edit</code>, <code>ctx pad mv</code>, <code>ctx pad import</code>, <code>ctx pad export</code>, <code>ctx pad merge</code></p> <p>See also: Scratchpad, Using the Scratchpad</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#journal-history","level":2,"title":"Journal & History","text":"<p>Skills for browsing, exporting, and enriching your AI session history into a structured journal.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-history","level":3,"title":"<code>/ctx-history</code>","text":"<p>Browse, inspect, and import AI session history. List recent sessions, show details by slug or ID, and import to <code>.context/journal/</code>.</p> <p>Wraps: <code>ctx journal source</code>, <code>ctx journal source --show</code>, <code>ctx journal import</code></p> <p>See also: Browsing and Enriching Past Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich","level":3,"title":"<code>/ctx-journal-enrich</code>","text":"<p>Enrich a single journal entry with YAML frontmatter: title, type, outcome, topics, technologies, and summary. Shows diff before writing.</p> <p>Wraps: reads and edits <code>.context/journal/*.md</code> files</p> <p>See also: Browsing and Enriching Past Sessions, Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich-all","level":3,"title":"<code>/ctx-journal-enrich-all</code>","text":"<p>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.</p> <p>Wraps: <code>ctx journal import --all</code> + iterates <code>/ctx-journal-enrich</code></p> <p>See also: Browsing and Enriching Past Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#content-creation","level":2,"title":"Content Creation","text":"<p>Skills for turning project activity into publishable content.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog","level":3,"title":"<code>/ctx-blog</code>","text":"<p>Generate a blog post draft from recent project activity: git history, decisions, learnings, tasks, and journal entries. Requires a narrative arc (problem, approach, outcome).</p> <p>Wraps: reads <code>git log</code>, DECISIONS.md, LEARNINGS.md, TASKS.md, journal entries; writes to <code>docs/blog/</code></p> <p>See also: Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog-changelog","level":3,"title":"<code>/ctx-blog-changelog</code>","text":"<p>Generate a themed blog post from a commit range. Takes a starting commit and unifying theme, analyzes diffs and journal entries from that period.</p> <p>Wraps: <code>git log</code>, <code>git diff --stat</code>; writes to <code>docs/blog/</code></p> <p>See also: Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-humanize","level":3,"title":"<code>/ctx-humanize</code>","text":"<p>Review, rewrite, or edit human-facing prose (blog posts, docs, READMEs, announcements) to remove formulaic LLM writing patterns: significance inflation, brochure language, forced triplets, chatbot residue, em-dash typography. Preserves meaning, certainty, and voice; invents nothing. Defaults to review mode and only edits files when asked.</p> <p>Wraps: a 28-pattern catalog adapted from Wikipedia's \"Signs of AI writing\"; verifies typography mechanically before returning</p> <p>See also: Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#auditing-health","level":2,"title":"Auditing & Health","text":"<p>Skills for detecting drift, auditing alignment, and improving prompt quality.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-consolidate","level":3,"title":"<code>/ctx-consolidate</code>","text":"<p>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.</p> <p>Wraps: reads LEARNINGS.md and DECISIONS.md, writes consolidated entries, archives originals (the index is computed on demand by <code>ctx index</code>, so no rebuild step is needed)</p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-drift","level":3,"title":"<code>/ctx-drift</code>","text":"<p>Detect and fix context drift: stale paths, missing files, file age staleness, task accumulation, entry count warnings, and constitution violations via <code>ctx drift</code>. Also detects skill drift against canonical templates.</p> <p>Wraps: <code>ctx drift [--fix]</code></p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-prompt-audit","level":3,"title":"<code>/ctx-prompt-audit</code>","text":"<p>Analyze recent prompting patterns to identify vague or ineffective prompts. Reviews 3-5 journal entries and suggests rewrites with positive observations.</p> <p>Wraps: reads <code>.context/journal/</code> entries</p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-doctor","level":3,"title":"<code>/ctx-doctor</code>","text":"<p>Troubleshoot <code>ctx</code> behavior. Runs structural health checks via <code>ctx doctor</code>, analyzes event log patterns via <code>ctx hook event</code>, and presents findings with suggested actions. The CLI provides the structural baseline; the agent adds semantic analysis of event patterns and correlations.</p> <p>Wraps: <code>ctx doctor --json</code>, <code>ctx hook event --json --last 100</code>, <code>ctx remind list</code>, <code>ctx hook message list</code>, reads <code>.ctxrc</code></p> <p>Trigger phrases: \"diagnose\", \"troubleshoot\", \"doctor\", \"health check\", \"why didn't my hook fire?\", \"hooks seem broken\", \"something seems off\"</p> <p>Graceful degradation: If <code>event_log</code> is not enabled, the skill still works but with reduced capability. It runs structural checks and notes: \"Enable <code>event_log: true</code> in <code>.ctxrc</code> for hook-level diagnostics.\"</p> <p>See also: Troubleshooting, <code>ctx doctor</code> CLI, <code>ctx hook event</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-link-check","level":3,"title":"<code>/ctx-link-check</code>","text":"<p>Scan all Markdown files under <code>docs/</code> 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.</p> <p>Wraps: Glob + Grep to scan, <code>curl</code> for external checks</p> <p>Trigger phrases: \"check links\", \"audit links\", \"any broken links?\", \"dead links\"</p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-permission-sanitize","level":3,"title":"<code>/ctx-permission-sanitize</code>","text":"<p>Audit <code>.claude/settings.local.json</code> 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.</p> <p>Wraps: reads <code>.claude/settings.local.json</code>, edits with confirmation</p> <p>Trigger phrases: \"audit permissions\", \"are my permissions safe?\", \"sanitize permissions\", \"check settings\"</p> <p>See also: Claude Code Permission Hygiene</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#planning-execution","level":2,"title":"Planning & Execution","text":"<p>Skills for structured design, implementation, and parallel agent workflows.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-brainstorm","level":3,"title":"<code>/ctx-brainstorm</code>","text":"<p>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.</p> <p>Wraps: reads DECISIONS.md, relevant source files; chains to <code>/ctx-decision-add</code> for recording design choices</p> <p>Trigger phrases: \"let's brainstorm\", \"design this\", \"think through\", \"before we build\", \"what approach should we take?\"</p> <p>See also: <code>/ctx-plan</code>, <code>/ctx-spec</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-plan","level":3,"title":"<code>/ctx-plan</code>","text":"<p>Stress-test a plan through an adversarial interview before it becomes a spec. Asks one question at a time across scope, failure modes, rejected alternatives, sequencing, reversibility, and hidden assumptions — pushing back rather than validating. Stops when the user can articulate the bet, the rejections, the top failure modes, the cheapest validation, and the unwind cost. Concludes by offering to write a debated brief to <code>.context/briefs/<TS>-<slug>.md</code>, the canonical input for <code>/ctx-spec --brief</code>. Deliberately does not produce an implementation plan or task list — that happens two steps later, at <code>/ctx-task-out</code>.</p> <p>Wraps: reads code and context files; writes <code>.context/briefs/<TS>-<slug>.md</code></p> <p>Trigger phrases: \"attack this plan\", \"poke holes in this\", \"stress-test my plan\", \"scrutinize this before I commit\"</p> <p>See also: Scrutinizing a Plan, <code>/ctx-brainstorm</code>, <code>/ctx-spec</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-spec","level":3,"title":"<code>/ctx-spec</code>","text":"<p>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.</p> <p>Wraps: reads <code>specs/tpl/spec-template.md</code>, writes to <code>specs/</code>, optionally chains to <code>/ctx-task-add</code></p> <p>Trigger phrases: \"spec this out\", \"write a spec\", \"create a spec\", \"design document\"</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#-brief-path-flag","level":4,"title":"<code>--brief <path></code> flag","text":"<p>When invoked as <code>/ctx-spec --brief <path></code>, the skill treats the file at <code><path></code> as the authoritative source and skips the interactive Q&A. Use this when a prior <code>/ctx-plan</code> session produced a debated brief that already covers the design.</p> <p>The skill enforces this authority order when sources disagree:</p> <ol> <li>Frozen contracts in <code>docs/</code> (release notes, public CLI docs)</li> <li>Recorded decisions in <code>.context/DECISIONS.md</code></li> <li>The brief at <code><path></code></li> <li>Agent inference, only when 1 through 3 are silent, and labeled <code>TBD</code> in the resulting spec so it stands out for review.</li> </ol> <p>Light compression for clarity is allowed; new facts are not. Where the brief is silent, the spec writes <code>TBD</code> rather than filling the gap from inference. If the brief contradicts a frozen contract, the contradiction is surfaced to the user rather than silently followed.</p> <p>Both flows end with a tasking handoff: specs that span multiple milestones (or more than roughly one session of implementation) are routed to <code>/ctx-task-out</code> for decomposition; small specs go straight to <code>/ctx-implement</code>.</p> <p>See also: <code>/ctx-brainstorm</code>, <code>/ctx-plan</code>, <code>/ctx-task-out</code>, <code>/ctx-plan-import</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-task-out","level":3,"title":"<code>/ctx-task-out</code>","text":"<p>Decompose a committed spec into a per-milestone implementation plan at <code>specs/plans/<milestone>.md</code> — data model, contracts, an invariant-test matrix, and typically 15-40 tasks, each with a falsifiable acceptance criterion (a command to run, a test that must pass, an observable behavior). The plan is the document <code>/ctx-implement</code> executes. The skill is a decomposer, not a designer: disagreements with the spec route back through <code>/ctx-plan</code> instead of being relitigated here.</p> <p>Two hard gates refuse rather than degrade:</p> <ol> <li>Blocking-TBD gate: the spec's open questions are classified as blocking or deferrable for the target milestone; decomposition refuses to proceed past a blocking TBD (a task that would embed an assumption about its answer).</li> <li>Rolling-wave gate: milestone N+1 is not decomposed while milestone N's definition of done is unmet, unless the user overrides explicitly (recorded in the plan header).</li> </ol> <p>TASKS.md receives epic-level anchors only, each annotated <code>Plan: specs/plans/<milestone>.md</code> — the plan owns the fine-grained tasks, one-way sync, nothing moved or deleted. Single-session specs skip this step entirely: the spec is the plan.</p> <p>Wraps: reads the spec, TASKS.md, DECISIONS.md, CONVENTIONS.md; writes <code>specs/plans/<milestone>.md</code>, appends anchors to TASKS.md</p> <p>Trigger phrases: \"task this out\", \"break down the spec\", \"decompose the spec\", \"plan out the milestone\"</p> <p>See also: <code>/ctx-spec</code>, <code>/ctx-implement</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-plan-import","level":3,"title":"<code>/ctx-plan-import</code>","text":"<p>Import Claude Code plan files (<code>~/.claude/plans/*.md</code>) into the project's <code>specs/</code> directory. Lists plans with dates and H1 titles, supports filtering (<code>--today</code>, <code>--since</code>, <code>--all</code>), slugifies headings for filenames, and optionally creates tasks referencing each imported spec.</p> <p>Wraps: reads <code>~/.claude/plans/*.md</code>, writes to <code>specs/</code>, optionally chains to <code>/ctx-task-add</code></p> <p>See also: Importing Claude Code Plans, Tracking Work Across Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-implement","level":3,"title":"<code>/ctx-implement</code>","text":"<p>Execute a multi-step plan with build and test verification at each step. The canonical input is <code>specs/plans/<milestone>.md</code> as written by <code>/ctx-task-out</code>, but hand-written plan files and plans from conversation context work too. Breaks the plan into atomic steps and checkpoints after every 3-5 steps. Handed a bare multi-milestone spec instead of a plan, it redirects to <code>/ctx-task-out</code> rather than decomposing on the fly.</p> <p>Wraps: reads plan file, runs verification commands (<code>go build</code>, <code>go test</code>, etc.)</p> <p>See also: <code>/ctx-task-out</code>, Running an Unattended AI Agent</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-loop","level":3,"title":"<code>/ctx-loop</code>","text":"<p>Generate a ready-to-run shell script for autonomous AI iteration. Supports Claude Code, Aider, and generic tool templates with configurable completion signals.</p> <p>Wraps: <code>ctx loop [--tool] [--prompt] [--max-iterations] [--completion] [--output]</code></p> <p>See also: Autonomous Loops, Running an Unattended AI Agent</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-worktree","level":3,"title":"<code>/ctx-worktree</code>","text":"<p>Manage git worktrees for parallel agent development. Create sibling worktrees on dedicated branches, analyze task blast radius for grouping, and tear down with merge.</p> <p>Wraps: <code>git worktree add</code>, <code>git worktree list</code>, <code>git worktree remove</code>, <code>git merge</code></p> <p>See also: Parallel Agent Development with Git Worktrees</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture","level":3,"title":"<code>/ctx-architecture</code>","text":"<p>Build and maintain architecture maps incrementally. Creates or refreshes <code>ARCHITECTURE.md</code> (succinct project map, loaded at session start) and <code>DETAILED_DESIGN.md</code> (deep per-module reference, consulted on-demand). Coverage is tracked in <code>map-tracking.json</code> so each run extends the map rather than re-analyzing everything.</p> <p>Wraps: <code>ctx status</code>, <code>git log</code>, reads source files; writes <code>ARCHITECTURE.md</code>, <code>DETAILED_DESIGN.md</code>, <code>map-tracking.json</code></p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture-failure-analysis","level":3,"title":"<code>/ctx-architecture-failure-analysis</code>","text":"<p>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.</p> <p>Requires <code>/ctx-architecture</code> artifacts as input. Reads <code>ARCHITECTURE.md</code>, <code>DETAILED_DESIGN*.md</code>, and <code>map-tracking.json</code>, 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.</p> <p>Produces <code>.context/DANGER-ZONES.md</code> with ranked findings split into Critical (risk >= 7, silent/cascading) and Elevated tiers.</p> <p>Wraps: reads architecture artifacts, source code; writes <code>DANGER-ZONES.md</code>. Optionally uses a code-intelligence MCP (canonical: GitNexus) for blast radius and a web-search-with-citations MCP (canonical: Gemini Search) for cross-referencing known failure patterns.</p> <p>Relationship:</p> Skill Mode <code>/ctx-architecture</code> Map what exists <code>/ctx-architecture-enrich</code> Improve map fidelity <code>/ctx-architecture-failure-analysis</code> Generate falsifiable incident hypotheses","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remind","level":3,"title":"<code>/ctx-remind</code>","text":"<p>Manage session-scoped reminders via natural language. Translates user intent (\"remind me to refactor swagger\") into the corresponding <code>ctx remind</code> command. Handles date conversion for <code>--after</code> flags.</p> <p>Wraps: <code>ctx remind</code>, <code>ctx remind list</code>, <code>ctx remind dismiss</code></p> <p>See also: Session Reminders</p>","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":"<code>/ctx-skill-audit</code>","text":"<p>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.</p> <p>Wraps: reads <code>internal/assets/claude/skills/*/SKILL.md</code> or <code>.claude/skills/*/SKILL.md</code>, references <code>anthropic-best-practices.md</code></p> <p>Trigger phrases: \"audit this skill\", \"check skill quality\", \"review the skills\", \"are our skills any good?\"</p> <p>See also: <code>/ctx-skill-create</code>, Contributing</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-skill-create","level":3,"title":"<code>/ctx-skill-create</code>","text":"<p>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.</p> <p>Wraps: reads/writes <code>.claude/skills/</code> and <code>internal/assets/claude/skills/</code></p> <p>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\"</p> <p>See also: Contributing</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-control","level":2,"title":"Session Control","text":"<p>Skills for controlling hook behavior during a session.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-pause","level":3,"title":"<code>/ctx-pause</code>","text":"<p>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.</p> <p>Wraps: <code>ctx hook pause</code></p> <p>Trigger phrases: \"pause <code>ctx</code>\", \"pause context\", \"stop the nudges\", \"quiet mode\"</p> <p>See also: Pausing Context Hooks</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-resume","level":3,"title":"<code>/ctx-resume</code>","text":"<p>Resume context hooks after a pause. Restores normal nudge, reminder, and ceremony behavior. Silent no-op if not paused.</p> <p>Wraps: <code>ctx hook resume</code></p> <p>Trigger phrases: \"resume <code>ctx</code>\", \"resume context\", \"turn nudges back on\", \"unpause\"</p> <p>See also: Pausing Context Hooks</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#knowledge-base-phase-kb","level":2,"title":"Knowledge Base (Phase KB)","text":"<p>Skills for the editorial knowledge-ingestion pipeline. Active when <code>.context/kb/</code> exists (laid down by <code>ctx init</code>). The pipeline gives you evidence-tracked knowledge with confidence bands, folder-shaped topic pages, a source-coverage state machine, and per-session handovers that fold postdated closeouts.</p> <p>See the Build a Knowledge Base recipe for the full workflow. The editorial constitution lives at <code>.context/ingest/KB-RULES.md</code>.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-ingest","level":3,"title":"<code>/ctx-kb-ingest</code>","text":"<p>Mode-aware editorial pass. Declares its pass-mode (<code>topic-page</code> / <code>triage</code> / <code>evidence-only</code>) up front, scans the source-coverage ledger for adjacent incomplete topics, synthesizes prose into <code>.context/kb/topics/<slug>/index.md</code>, mints <code>EV-###</code> rows in <code>evidence-index.md</code>, runs a four-invariant completion circuit breaker, and writes a closeout under <code>.context/ingest/closeouts/</code>. Refuses on empty input.</p> <p>Wraps: <code>ctx kb ingest</code>, <code>ctx kb topic new</code>, the writer packages under <code>internal/write/kb/</code>.</p> <p>Trigger phrases: \"ingest the transcripts\", \"pull this into the kb\", \"add evidence from\"</p> <p>See also: Build a Knowledge Base, Typical KB Session, <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-ask","level":3,"title":"<code>/ctx-kb-ask</code>","text":"<p>Q&A grounded in the KB. Cites <code>EV-###</code> rows; refuses to web-jump. When the KB cannot answer, opens a <code>Q-###</code> row in <code>outstanding-questions.md</code> rather than inventing. Refuses on empty question.</p> <p>Wraps: <code>ctx kb ask</code>, reads <code>.context/kb/*.md</code></p> <p>Trigger phrases: \"does the kb say\", \"according to evidence\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-site-review","level":3,"title":"<code>/ctx-kb-site-review</code>","text":"<p>Mechanical structural audit. Coerces malformed Confidence-band capitalization, flags malformed closeout frontmatter, refuses judgment calls that require evidence (those go through ingest).</p> <p>Wraps: <code>ctx kb site-review</code></p> <p>Trigger phrases: \"audit the kb\", \"check kb for rot\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-ground","level":3,"title":"<code>/ctx-kb-ground</code>","text":"<p>External re-grounding pass. Reads <code>.context/ingest/grounding-sources.md</code> and refreshes each listed source. Refuses cleanly when the file is absent or empty.</p> <p>Wraps: <code>ctx kb ground</code></p> <p>Trigger phrases: \"re-ground the kb\", \"check upstream\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-note","level":3,"title":"<code>/ctx-kb-note</code>","text":"<p>Lightweight capture into <code>.context/ingest/findings.md</code>. Never writes to a topic page or <code>evidence-index.md</code>. Use for parking findings the next ingest pass should absorb.</p> <p>Wraps: <code>ctx kb note \"<text>\"</code></p> <p>Trigger phrases: \"drop a note\", \"park this finding\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-handover","level":3,"title":"<code>/ctx-handover</code>","text":"<p>Per-session handover artifact writer; the sub-mechanism that <code>/ctx-wrap-up</code> delegates to as its final step. Collects <code>--summary</code> (past tense) and <code>--next</code> (future tense, specific) and calls <code>ctx handover write</code>. Writes the handover to <code>.context/handovers/<TS>-<slug>.md</code> (timestamped so concurrent agent runs never overwrite). Folds postdated closeouts into a <code>## Folded closeouts</code> section and physically archives the source closeouts under <code>.context/archive/closeouts/</code> (closeouts are append-never-rewrite; archival moves bytes but does not modify them). <code>--no-fold</code> skips the fold for mid-session checkpoints.</p> <p>Mandatory tail of <code>/ctx-wrap-up</code>. Direct invocation is reserved for <code>--no-fold</code> mid-session checkpoints and recovery after an aborted session.</p> <p>Wraps: <code>ctx handover write <title> --summary X --next Y</code></p> <p>See also: <code>/ctx-wrap-up</code>, Typical KB Session, Recover an Aborted KB Session, <code>ctx handover</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#project-specific-skills","level":2,"title":"Project-Specific Skills","text":"<p>The <code>ctx</code> plugin ships the skills listed above. Teams can add their own project-specific skills to <code>.claude/skills/</code> in the project root: These are separate from plugin-shipped skills and are scoped to the project.</p> <p>Project-specific skills follow the same format and are invoked the same way.</p> <p>Custom skills are not covered in this reference.</p>","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":"<p>Documentation snapshots for each release. </p> <p>Tap the corresponding view docs to view the docs as they were at that release.</p>","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":"<code>v0.8.0</code>: The Architecture Release","text":"<p>MCP server for tool-agnostic AI integration. Memory bridge connecting Claude Code auto-memory to <code>.context/</code>. Complete CLI restructuring into <code>cmd/ + core/</code> taxonomy. All user-facing strings externalized to YAML. <code>fatih/color</code> removed; two direct dependencies remain.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v060-the-integration-release","level":3,"title":"<code>v0.6.0</code>: The Integration Release","text":"<p>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.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v030-the-discipline-release","level":3,"title":"<code>v0.3.0</code>: The Discipline Release","text":"<p>Journal static site generation via zensical. 49-skill audit and fix pass (positive framing, phantom reference removal, scope tightening). Context consolidation skill. <code>golangci-lint</code> v2 migration.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v020-the-archaeology-release","level":3,"title":"<code>v0.2.0</code>: The Archaeology Release","text":"<p>Session journal system: <code>ctx journal import</code> converts Claude Code JSONL transcripts to browsable Markdown. Constants refactor with semantic prefixes (<code>Dir*</code>, <code>File*</code>, <code>Filename*</code>). CRLF handling for Windows compatibility.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v012","level":3,"title":"<code>v0.1.2</code>","text":"<p>Default Claude Code permissions deployed on <code>ctx init</code>. Prompting guide published as a standalone documentation page.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v011","level":3,"title":"<code>v0.1.1</code>","text":"<p>Bug fixes: hook schema key format corrected, JSON unicode escaping fixed in context file output.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v010-initial-release","level":3,"title":"<code>v0.1.0</code>: Initial Release","text":"<p>CLI with 15 subcommands, 6 context file types (CONSTITUTION, TASKS, CONVENTIONS, ARCHITECTURE, DECISIONS, LEARNINGS), Makefile build system, and Claude Code hook integration.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#latest","level":2,"title":"Latest","text":"<p>The main documentation always reflects the latest development version.</p> <p>For the most recent stable release, see v0.8.0.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#changelog","level":2,"title":"Changelog","text":"<p>For detailed changes between versions, see the GitHub Releases page.</p>","path":["Reference","Version History"],"tags":[]},{"location":"security/","level":1,"title":"Security","text":"<p>Security model, agent hardening, and vulnerability reporting.</p>","path":["Security"],"tags":[]},{"location":"security/#security-design","level":3,"title":"Security Design","text":"<p>Trust model, what <code>ctx</code> does for security, permission hygiene, state file management, and the log-first audit trail principle. Read first to understand the security boundaries.</p>","path":["Security"],"tags":[]},{"location":"security/#securing-ai-agents","level":3,"title":"Securing AI Agents","text":"<p>Defense in depth for unattended AI agents: five layers of protection, each with a known bypass, strength in combination.</p>","path":["Security"],"tags":[]},{"location":"security/#reporting-vulnerabilities","level":3,"title":"Reporting Vulnerabilities","text":"<p>How to report a security issue: email, GitHub private reporting, PGP-encrypted submissions, what to include, and the response timeline.</p>","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":"<p>An unattended AI agent with unrestricted access to your machine is an unattended shell with unrestricted access to your machine.</p> <p>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.</p> <p>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.</p>","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":"<p>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.</p> 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 <code>CLAUDE.md</code>, <code>.cursorrules</code>, or <code>.context/</code> 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":"<p>Depends entirely on what permissions and access the agent has:</p> 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":"<p>No single layer is sufficient. Each layer catches what the others miss.</p> <pre><code>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</code></pre>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-1-soft-instructions-probabilistic","level":3,"title":"Layer 1: Soft Instructions (Probabilistic)","text":"<p>Markdown files like <code>CONSTITUTION.md</code> 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.</p> <p>What it catches: Most common mistakes. An agent that has been told \"never delete production data\" will usually not delete production data.</p> <p>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.</p> <p>Verdict: Necessary but not sufficient. Good for the common case. Do not rely on it for security boundaries.</p>","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":"<p>AI tool runtimes (Claude Code, Cursor, etc.) provide permission systems: tool allowlists, command restrictions, confirmation prompts.</p> <p>For Claude Code, <code>ctx init</code> writes both an allowlist and an explicit deny list into <code>.claude/settings.local.json</code>. The golden images live in <code>internal/assets/permissions/</code>:</p> <p>Allowlist (<code>allow.txt</code>): only these tools run without confirmation:</p> <pre><code>Bash(ctx:*)\nSkill(ctx-convention-add)\nSkill(ctx-decision-add)\n... # all bundled ctx-* skills\n</code></pre> <p>Deny list (<code>deny.txt</code>): these are blocked even if the agent requests them:</p> <pre><code># 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</code></pre> <p>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 <code>rm</code>, <code>curl</code>, <code>sudo</code>, or <code>docker</code> are not allowed and <code>sudo</code>/<code>curl</code>/<code>wget</code> are explicitly denied, the agent cannot invoke them regardless of what any prompt says.</p> <p>What it misses: The agent can modify the allowlist itself. In an autonomous loop, if the agent writes to <code>.claude/settings.local.json</code>, 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.</p> <p>Verdict: Strong first layer. Must be combined with self-modification prevention (Layer 3).</p>","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":"<p>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 <code>CAP_NET_RAW</code> cannot open raw sockets. These are kernel boundaries.</p> Control Purpose Dedicated user account No <code>sudo</code>, no privileged group membership (<code>docker</code>, <code>wheel</code>, <code>adm</code>). 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 <code>CLAUDE.md</code>, <code>.claude/settings.local.json</code>, and <code>.context/CONSTITUTION.md</code> owned by a different user or marked immutable (<code>chattr +i</code> on Linux). The agent cannot modify its own guardrails. <p>What it catches: Privilege escalation, self-modification, lateral movement to other projects or users.</p> <p>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.</p> <p>Verdict: Essential. This is the layer that makes the other layers trustworthy.</p> <p>OS-level isolation does not make the agent safe; it makes the other layers meaningful.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-4-network-controls","level":3,"title":"Layer 4: Network Controls","text":"<p>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.</p> Scenario Recommended control Agent does not need the internet <code>--network=none</code> (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. <p>What it catches: Data exfiltration, phone-home payloads, downloading additional tools, and instruction injection via fetched content.</p> <p>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.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-5-infrastructure-isolation","level":3,"title":"Layer 5: Infrastructure Isolation","text":"<p>The strongest boundary is a separate machine (or something that behaves like one).</p> <p>The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.</p> <p>Containers (Docker, Podman):</p> <pre><code>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</code></pre> <p>Docker Socket Is Sudo Access</p> <p>Critical: never mount the Docker socket (<code>/var/run/docker.sock</code>).</p> <p>An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox. </p> <p>Use rootless Docker or Podman to eliminate this escalation path.</p> <p>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.</p> <p>Resource limits: CPU, memory, and disk quotas prevent a runaway agent from consuming all resources. Use <code>ulimit</code>, cgroup limits, or container resource constraints.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>A defense-in-depth setup for overnight autonomous runs:</p> Layer Implementation Stops Soft instructions <code>CONSTITUTION.md</code> with \"never delete tests\", \"always run tests before committing\" Common mistakes (probabilistic) Application allowlist <code>.claude/settings.local.json</code> with explicit tool permissions Unauthorized commands (deterministic within runtime) Immutable config <code>chattr +i</code> on <code>CLAUDE.md</code>, <code>.claude/</code>, <code>CONSTITUTION.md</code> Self-modification between iterations Unprivileged user Dedicated user, no sudo, no docker group Privilege escalation Container <code>--cap-drop=ALL --network=none</code>, rootless, no socket mount Host escape, network exfiltration Resource limits <code>--memory=4g --cpus=2</code>, disk quotas Resource exhaustion <p>Each layer is straightforward: The strength is in the combination.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#common-mistakes","level":2,"title":"Common Mistakes","text":"<p>\"I'll just use <code>--dangerously-skip-permissions</code>\": 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.</p> <p>\"The agent is sandboxed in Docker\": A Docker container with the Docker socket mounted, running as root, with <code>--privileged</code>, and full network access is not sandboxed. It is a root shell with extra steps.</p> <p>\"<code>CONSTITUTION.md</code> 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.</p> <p>\"I reviewed the <code>CLAUDE.md</code>, it's fine\": The agent can modify <code>CLAUDE.md</code> during iteration N. Iteration N+1 loads the modified version. Unless the file is immutable, your review is stale.</p> <p>\"The agent only has access to this one project\": Does the project directory contain <code>.env</code> files, SSH keys, API tokens, or credentials? Does it have a <code>.git/config</code> with push access to a remote? Filesystem isolation means isolating what is in the directory too.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-security-considerations","level":2,"title":"Team Security Considerations","text":"<p>When multiple developers share a <code>.context/</code> directory, security considerations extend beyond single-agent hardening.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#code-review-for-context-files","level":3,"title":"Code Review for Context Files","text":"<p>Treat <code>.context/</code> changes like code changes. Context files influence agent behavior (a modified <code>CONSTITUTION.md</code> or <code>CONVENTIONS.md</code> changes what every agent on the team will do next session). Review them in PRs with the same scrutiny you apply to production code.</p> <p>Watch for:</p> <ul> <li>Weakened constitutional rules (removed constraints, softened language)</li> <li>New decisions that contradict existing ones without acknowledging it</li> <li>Learnings that encode incorrect assumptions</li> <li>Task additions that bypass the team's prioritization process</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#gitignore-patterns","level":3,"title":"Gitignore Patterns","text":"<p><code>ctx init</code> configures <code>.gitignore</code> automatically, but verify these patterns are in place:</p> <ul> <li>Always gitignored: <code>.ctx.key</code> (encryption key), <code>.context/logs/</code>, <code>.context/journal/</code></li> <li>Team decision: <code>scratchpad.enc</code> (encrypted, safe to commit for shared scratchpad state); <code>.gitignore</code> if scratchpads are personal</li> <li>Never committed: <code>.env</code>, credentials, API keys (enforced by drift secret detection)</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#multi-developer-context-sharing","level":3,"title":"Multi-Developer Context Sharing","text":"<p><code>CONSTITUTION.md</code> is the shared contract. All team members and their agents inherit it. Changes require team consensus, not unilateral edits.</p> <p>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.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-conventions-for-context-management","level":3,"title":"Team Conventions for Context Management","text":"<p>Establish and document:</p> <ul> <li>Who reviews context changes: Same reviewers as code, or a designated context owner?</li> <li>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.</li> <li>Frequency of context maintenance: Weekly <code>ctx drift</code> checks, monthly consolidation passes, archival after each milestone.</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#checklist","level":2,"title":"Checklist","text":"<p>Before running an unattended AI agent:</p> <ul> <li> Agent runs as a dedicated unprivileged user (no sudo, no docker group)</li> <li> Agent's config files are immutable or owned by a different user</li> <li> Permission allowlist restricts tools to the project's toolchain</li> <li> Container drops all capabilities (<code>--cap-drop=ALL</code>)</li> <li> Docker socket is NOT mounted</li> <li> Network is disabled or restricted to specific domains</li> <li> Resource limits are set (memory, CPU, disk)</li> <li> No SSH keys, API tokens, or credentials are accessible to the agent</li> <li> Project directory does not contain <code>.env</code> or secrets files</li> <li> Iteration cap is set (<code>--max-iterations</code>)</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Running an Unattended AI Agent: the <code>ctx</code> recipe for autonomous loops, including step-by-step permissions and isolation setup</li> <li>Security: <code>ctx</code>'s own trust model and vulnerability reporting</li> <li>Autonomous Loops: full documentation of the loop pattern, prompt templates, and troubleshooting</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/design/","level":1,"title":"Security Design","text":"<p>How <code>ctx</code> 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.</p> <p>For vulnerability disclosure, see Reporting Vulnerabilities.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#trust-model","level":2,"title":"Trust Model","text":"<p><code>ctx</code> operates within a single trust boundary: the local filesystem.</p> <p>The person who authors <code>.context/</code> files is the same person who runs the agent that reads them. There is no remote input, no shared state, and no server component.</p> <p>This means:</p> <ul> <li><code>ctx</code> 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.</li> <li>If you place adversarial instructions in your own <code>.context/</code> files, your agent will follow them. This is expected behavior. You control the context; the agent trusts it.</li> </ul> <p>Shared Repositories</p> <p>In shared repositories, <code>.context/</code> 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 <code>CONSTITUTION.md</code> or <code>TASKS.md</code>.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#what-ctx-does-for-security","level":2,"title":"What <code>ctx</code> Does for Security","text":"<p><code>ctx</code> is designed with security in mind:</p> <ul> <li>No secrets in context: The constitution explicitly forbids storing secrets, tokens, API keys, or credentials in <code>.context/</code> files.</li> <li>Local only: <code>ctx</code> runs entirely locally with no external network calls.</li> <li>No code execution: <code>ctx</code> reads and writes Markdown files only; it does not execute arbitrary code.</li> <li>Git-tracked: Core context files are meant to be committed, so they should never contain sensitive data. Exception: <code>sessions/</code> and <code>journal/</code> contain raw conversation data and should be gitignored.</li> </ul>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#permission-hygiene","level":2,"title":"Permission Hygiene","text":"<p>Claude Code evaluates permissions in deny → ask → allow order. <code>ctx init</code> automatically populates <code>permissions.deny</code> with rules that block dangerous operations before the allow list is ever consulted.</p> <p>Default deny rules block:</p> <ul> <li><code>sudo</code>, <code>git push</code>, <code>rm -rf /</code>, <code>rm -rf ~</code>, <code>curl</code>, <code>wget</code>, <code>chmod 777</code></li> <li><code>Read</code> / <code>Edit</code> of <code>.env</code>, credentials, secrets, <code>.pem</code>, <code>.key</code> files</li> </ul> <p>Even with deny rules in place, the allow list accumulates one-off permissions over time. Periodically review for:</p> <ul> <li>Destructive commands: <code>git reset --hard</code>, <code>git clean -f</code>, etc.</li> <li>Config injection vectors: permissions that allow modifying files controlling agent behavior (<code>CLAUDE.md</code>, <code>settings.local.json</code>).</li> <li>Broad wildcards: overly permissive patterns that pre-approve more than intended.</li> </ul> <p>For the full hygiene workflow, see the Claude Code Permission Hygiene recipe.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#state-file-management","level":2,"title":"State File Management","text":"<p>Hook state files (throttle markers, prompt counters, pause markers) are stored in <code>.context/state/</code>, which is project-scoped and gitignored. State files are automatically managed by the hooks that create them; no manual cleanup is needed.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#log-first-audit-trail","level":2,"title":"Log-First Audit Trail","text":"<p>The event log (<code>.context/state/events.jsonl</code>) is the authoritative record of what <code>ctx</code> hooks did during a session. Several audit-adjacent features depend on that log being trustworthy, not merely best-effort:</p> <ul> <li><code>ctx event</code> / <code>ctx system view-events</code> replays session history from the log.</li> <li>Webhook notifications give operators a real-time signal that assumes every notification corresponds to a logged event.</li> <li>Drift, freshness, and map-staleness checks count events over time and surface regressions.</li> </ul> <p>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.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#the-rule","level":3,"title":"The Rule","text":"<p>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.</p> <p>In code, this shape:</p> <pre><code>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</code></pre> <p>The <code>nudge.Relay</code> helper in <code>internal/cli/system/core/nudge</code> enforces this for the common \"log + webhook\" pair. Hook <code>Run</code> functions that compose their own sequence (<code>sessionevent</code>, <code>heartbeat</code>, several <code>check_*</code> hooks) follow the same ordering explicitly.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#known-gaps","level":3,"title":"Known Gaps","text":"<ul> <li>Nudge webhooks have no log channel. <code>nudge.EmitAndRelay</code> 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.</li> <li><code>ctx agent --cooldown</code> and <code>ctx doctor</code> 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.</li> <li>Verbose hook logs in <code>core/log.Message</code> 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 <code>log/warn.Warn</code> rather than propagating, because losing an operational log line is not a correctness problem.</li> </ul>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#background","level":3,"title":"Background","text":"<p>The <code>error</code> returns on <code>event.Append</code>, <code>io.AppendBytes</code>, <code>nudge.Relay</code>, and <code>cooldown.Active</code> / <code>cooldown.TouchTombstone</code> 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.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#best-practices","level":2,"title":"Best Practices","text":"<ol> <li>Review before committing: Always review <code>.context/</code> files before committing.</li> <li>Use <code>.gitignore</code>: If you must store sensitive notes locally, add them to <code>.gitignore</code>.</li> <li>Drift detection: Run <code>ctx drift</code> to check for potential issues.</li> <li>Permission audit: Review <code>.claude/settings.local.json</code> after busy sessions.</li> </ol>","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":"<code>ctx</code> Hub: Security Model","text":"<p>What the hub defends against, what it does not defend against, and the concrete mechanisms in play.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#threat-model","level":2,"title":"Threat Model","text":"<p>The hub is designed for trusted cross-project knowledge sharing within a team or homelab. It assumes:</p> <ul> <li>The hub host is trusted. Anyone with root on that box can read every entry ever published.</li> <li>Network is semi-trusted. Hub traffic is gRPC over TCP; TLS is strongly recommended but not mandatory.</li> <li>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.</li> <li>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.</li> </ul> <p>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.</p>","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":"<p>All RPCs except <code>Register</code> require a bearer token in gRPC metadata. Two kinds of tokens exist:</p> Kind Format Scope Lifetime Admin token <code>ctx_adm_...</code> Register new projects Manual rotate Client token <code>ctx_cli_...</code> Publish, Sync, Listen, Status Project lifetime <p>Tokens are compared in constant time (<code>crypto/subtle</code>) to prevent timing oracles, and looked up via an <code>O(1)</code> hash map so the comparison cost does not depend on the total number of registered clients.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#client-side-encryption-at-rest","level":3,"title":"Client-Side Encryption at Rest","text":"<p><code>.context/.connect.enc</code> 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 <code>ctx</code>'s local keyring (see <code>internal/crypto</code>).</p> <p>An attacker with read access to the project directory cannot learn the client token without also breaking <code>ctx</code>'s local keyring.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#hub-side-token-storage","level":3,"title":"Hub-Side Token Storage","text":"<p>Tokens Are Stored in Plaintext on the Hub Host</p> <p><code><data-dir>/clients.json</code> 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.</p> <p>Mitigations today:</p> <ul> <li>Run the hub as an unprivileged user and lock the data directory with <code>chmod 700 <data-dir></code>.</li> <li>Use the systemd unit in Operations, which enables <code>ProtectSystem=strict</code>, <code>NoNewPrivileges=true</code>, and a dedicated user.</li> <li>Never expose <code><data-dir></code> over NFS, SMB, or shared filesystems.</li> <li>Treat <code><data-dir></code> the same way you'd treat <code>/etc/shadow</code>: back it up encrypted, never check it into version control.</li> </ul> <p>Hashing <code>clients.json</code> 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.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#input-validation","level":3,"title":"Input Validation","text":"<p>Every published entry is validated before it touches the log:</p> <ul> <li>Type must be one of: <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. Unknown types are rejected.</li> <li>ID and Origin are required and non-empty.</li> <li>Content size is capped at 1 MB. Reasonable for text, hostile for attempts to fill the disk.</li> <li>Duplicate project registration is rejected; a client that replays an old <code>Register</code> call gets an error, not a second token.</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#no-script-execution","level":3,"title":"No Script Execution","text":"<p>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.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#audit-trail","level":3,"title":"Audit Trail","text":"<p><code>entries.jsonl</code> 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).</p>","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":"<ul> <li>Untrusted entry senders. A client with a valid token can publish anything (within the 1 MB cap). There is no content validation beyond shape.</li> <li>Denial of service from a registered client. A misbehaving client can publish until disk is full. Monitor <code>entries.jsonl</code> growth.</li> <li>Network eavesdropping without TLS. Plain gRPC leaks entry content and tokens. Use a TLS-terminating reverse proxy (see Multi-machine recipe).</li> <li>Host compromise. Root on the hub host = access to every entry and every token. Harden the host.</li> <li>Accidental secret upload. The hub will happily fan out a decision containing an API key. Sanitize content before publishing.</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#operational-hardening-checklist","level":2,"title":"Operational Hardening Checklist","text":"<ul> <li> Run the hub as an unprivileged user with <code>NoNewPrivileges=true</code> and <code>ProtectSystem=strict</code> (see the systemd unit in Operations).</li> <li> Terminate TLS in front of the hub for anything beyond a trusted LAN.</li> <li> Restrict the listen port with firewall rules to the client subnet only.</li> <li> Back up <code><data-dir>/admin.token</code> to a secrets manager; do not leave it in shell history.</li> <li> Rotate the admin token when a team member with access leaves. Client tokens keep working across rotations.</li> <li> Monitor <code>entries.jsonl</code> growth; alert on sudden spikes.</li> <li> Run NTP on all clients to prevent entry-timestamp skew.</li> <li> Do not publish from machines you do not trust.</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#responsible-disclosure","level":2,"title":"Responsible Disclosure","text":"<p>Security issues in the hub follow the same process as the rest of <code>ctx</code>; see Reporting.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx</code> Hub Operations</li> <li><code>ctx</code> Hub failure modes</li> <li>HA cluster recipe</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/reporting/","level":1,"title":"Reporting Vulnerabilities","text":"<p>Disclosure process for security issues in <code>ctx</code>. For the broader security model (trust boundaries, audit trail, permission hygiene), see Security Design.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#reporting-vulnerabilities","level":2,"title":"Reporting Vulnerabilities","text":"<p>At <code>ctx</code> we take security very seriously.</p> <p>If you discover a security vulnerability in <code>ctx</code>, please report it responsibly.</p> <p>Do NOT open a public issue for security vulnerabilities.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#email","level":3,"title":"Email","text":"<p>Send details to security@ctx.ist.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#github-private-reporting","level":3,"title":"GitHub Private Reporting","text":"<ol> <li>Go to the Security tab;</li> <li>Click \"Report a Vulnerability\";</li> <li>Provide a detailed description.</li> </ol>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#encrypted-reports-optional","level":3,"title":"Encrypted Reports (Optional)","text":"<p>If your report contains sensitive details (proof-of-concept exploits, credentials, or internal system information), you can encrypt your message with our PGP key:</p> <ul> <li>In-repo: <code>SECURITY_KEY.asc</code></li> <li>Keybase: keybase.io/alekhinejose</li> </ul> <pre><code># Import the key\ngpg --import SECURITY_KEY.asc\n\n# Encrypt your report\ngpg --armor --encrypt --recipient security@ctx.ist report.txt\n</code></pre> <p>Encryption is optional. Unencrypted reports to security@ctx.ist or via GitHub Private Reporting are perfectly fine.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#what-to-include","level":3,"title":"What to Include","text":"<ul> <li>Description of the vulnerability,</li> <li>Steps to reproduce,</li> <li>Potential impact,</li> <li>Suggested fix (if any).</li> </ul>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#attribution","level":2,"title":"Attribution","text":"<p>We appreciate responsible disclosure and will acknowledge security researchers who report valid vulnerabilities (unless they prefer to remain anonymous).</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#response-timeline","level":2,"title":"Response Timeline","text":"<p>Open Source, Best-Effort Timelines</p> <p><code>ctx</code> is a volunteer-maintained open source project.</p> <p>The timelines below are guidelines, not guarantees, and depend on contributor availability.</p> <p>We will address security reports on a best-effort basis and prioritize them by severity.</p> 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":"<p>Volkan Özçelik - me@volkan.io</p> <p>February 2026</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#abstract","level":3,"title":"Abstract","text":"<p>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.</p> <p>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.</p> <p>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 <code>ctx</code>, 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#1-introduction","level":2,"title":"1. Introduction","text":"<p>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.</p> <p>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.</p> <p>This model has improved substantially over the past year. <code>CLAUDE.md</code> 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.</p> <p>This paper does not propose a universal replacement for retrieval-centric workflows. It defines a persistence layer (embodied in <code>ctx</code> (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. </p> <p>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 <sup>1</sup> <sup>6</sup>.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#2-the-limits-of-prompt-time-context","level":2,"title":"2. The Limits of Prompt-Time Context","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#21-non-reproducibility","level":3,"title":"2.1 Non-Reproducibility","text":"<p>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.</p> <p>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 <sup>1</sup> <sup>2</sup>. 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#22-opaque-knowledge","level":3,"title":"2.2 Opaque Knowledge","text":"<p>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) <sup>3</sup>.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#23-loss-of-intent","level":3,"title":"2.3 Loss of Intent","text":"<p>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) <sup>4</sup>.</p> <p>Session transcripts provide history. Cognitive state requires something more: the persistent, structured representation of the knowledge required for correct decision-making.</p>","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":"<p>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.</p> <p>Previous formulations of this idea have treated cognitive state as a monolithic concept. In practice, a three-tier model better captures the operational reality:</p> <p>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).</p> <p>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.</p> <p>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.</p> <p>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:</p> <pre><code>delivery_view = assemble(authoritative_state, budget, policy)\noutput = model(delivery_view) # stochastic\n</code></pre> <p>The persistence layer's contribution is making <code>assemble</code> reproducible, not making <code>model</code> deterministic.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#32-separation-of-concerns","level":3,"title":"3.2 Separation of Concerns","text":"<p>The decision to separate authoritative state into distinct files with distinct purposes is not cosmetic. Different types of knowledge have different lifecycles:</p> 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\" <p>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.</p> <p>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).</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#4-design-invariants","level":2,"title":"4. Design Invariants","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-1-markdown-on-filesystem-persistence","level":3,"title":"Invariant 1: Markdown-on-Filesystem Persistence","text":"<p>Context files must be human-readable, git-diffable, and editable with any text editor. No database. No binary storage.</p> <p>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 <code>cat DECISIONS.md</code> 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-2-zero-runtime-dependencies","level":3,"title":"Invariant 2: Zero Runtime Dependencies","text":"<p>The tool must work with no installed runtimes, no running services, and no API keys for core functionality.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-3-deterministic-context-assembly","level":3,"title":"Invariant 3: Deterministic Context Assembly","text":"<p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-4-human-authority-over-persistent-state","level":3,"title":"Invariant 4: Human Authority over Persistent State","text":"<p>The agent may propose changes to context files but must not unilaterally modify them. All persistent changes go through human-reviewable git commits.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-5-local-first-air-gap-capable","level":3,"title":"Invariant 5: Local-First, Air-Gap Capable","text":"<p>Core functionality must work offline with no network access. Cloud services may be used for optional features but never for core context management.</p> <p>Validation: 7 independent rejection decisions protected this property. Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or constrained-environment scenarios. A filesystem-native model continues to function under all conditions where the repository is accessible.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-6-no-default-telemetry","level":3,"title":"Invariant 6: No Default Telemetry","text":"<p>Any analytics, if ever added, must be strictly opt-in.</p> <p>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.</p> <p>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.<sup>1</sup></p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#5-landscape-analysis","level":2,"title":"5. Landscape Analysis","text":"<p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#51-primitive-taxonomy","level":3,"title":"5.1 Primitive Taxonomy","text":"<p>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:</p> <p>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 <code>CLAUDE.md</code> files) as partial participants: both use document-based context as an input but organize around different core primitives.</p> <p>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.</p> <p>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).</p> <p>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.</p> <p>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).</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#52-comparison-matrix","level":3,"title":"5.2 Comparison Matrix","text":"<p>The five primitive categories differ along seven dimensions:</p> 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 <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#53-convergent-patterns","level":3,"title":"5.3 Convergent Patterns","text":"<p>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:</p> <p>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.</p> <p>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).</p> <p>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 <sup>5</sup>.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","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":"<p>We now instantiate the three-tier model in a concrete system (<code>ctx</code>) and illustrate the difference between prompt-time retrieval and cognitive state persistence using a real scenario from its development.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#61-the-problem","level":3,"title":"6.1 The Problem","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#62-prompt-time-retrieval-model","level":3,"title":"6.2 Prompt-Time Retrieval Model","text":"<p>In a retrieval-based system, the decision to remove the middle layer depends on whether the retrieval function surfaces the relevant context:</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#63-cognitive-state-model","level":3,"title":"6.3 Cognitive State Model","text":"<p>In the persistence model, the decision is recorded as a structured artifact at write time:</p> <pre><code>## [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</code></pre> <p>This artifact is:</p> <ul> <li>Deterministically included in every subsequent session's delivery view (budget permitting, with title-only fallback if budget is exceeded)</li> <li>Human-readable and reviewable as a diff in the commit that introduced it</li> <li>Permanent: it persists in version control regardless of retrieval heuristics</li> <li>Causally linked: it explicitly supersedes four earlier decisions, creating an auditable chain</li> </ul> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#64-the-diff-when-policy-changes","level":3,"title":"6.4 The Diff When Policy Changes","text":"<p>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:</p> <pre><code>- **Status**: Accepted\n+ **Status**: Superseded by [2026-08-15] Reintroduce session storage\n+ for multi-agent correlation\n</code></pre> <p>The new decision record references the old one, creating a chain of reasoning visible in <code>git log</code>. In the retrieval model, the old decision would simply be ranked lower over time and eventually forgotten.</p>","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":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#71-scale-and-structure","level":3,"title":"7.1 Scale and Structure","text":"<p>The development produced the following authoritative state artifacts:</p> <ul> <li>8 consolidated decision records covering 24 original decisions spanning context injection architecture, hook design, task management, security, agent autonomy, and webhook systems</li> <li>18 consolidated learning records covering 75 original observations spanning agent compliance, hook behavior, testing patterns, documentation drift, and tool integration</li> <li>A constitution with 13 inviolable rules across 4 categories (security, quality, process, context preservation)</li> <li>389 enriched journal entries providing a complete session-level audit trail</li> </ul> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#72-architectural-reversals","level":3,"title":"7.2 Architectural Reversals","text":"<p>Three architectural reversals during development provide evidence that the persistence model captures and communicates reasoning effectively:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#73-compliance-ceiling","level":3,"title":"7.3 Compliance Ceiling","text":"<p>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.</p> <p>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).</p> <p>The architectural response maps directly to the formal model defined in Section 3.1. Content requiring 100% compliance is included in <code>authoritative_state</code> and injected by the deterministic <code>assemble</code> 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#74-compounding-returns","level":3,"title":"7.4 Compounding Returns","text":"<p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#75-scope-and-generalizability","level":3,"title":"7.5 Scope and Generalizability","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#8-situating-the-persistence-layer","level":2,"title":"8. Situating the Persistence Layer","text":"<p>The persistence layer occupies a specific position in the stack of AI-assisted development:</p> <pre><code>Application Logic\nAI Interaction / Agents\nContext Retrieval Systems\nCognitive State Persistence Layer\nVersion Control / Storage\n</code></pre> <p>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.</p>","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":"<p>A cognitive state persistence layer is most appropriate when:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>Offline or air-gapped operation is required: Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or constrained-environment scenarios.</p>","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":"<p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#93-incremental-adoption","level":3,"title":"9.3 Incremental Adoption","text":"<p>The transition does not require full system replacement. An incremental path:</p> <p>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 <sup>4</sup>. This alone converts ephemeral reasoning into the cognitive state.</p> <p>Step 2: Make inclusion deterministic: Define explicit assembly rules. Retrieval may still exist, but it is no longer authoritative.</p> <p>Step 3: Move policy into cognitive state: When system behavior depends on stable constraints, encode those constraints as versioned knowledge. Behavior becomes reproducible.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#94-the-curation-cost","level":3,"title":"9.4 The Curation Cost","text":"<p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#10-future-work","level":2,"title":"10. Future Work","text":"<p>Several directions are compatible with the model described here:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#11-conclusion","level":2,"title":"11. Conclusion","text":"<p>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.</p> <p>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.</p> <p>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.</p> <p>When context is the state:</p> <ul> <li>Reasoning is reproducible: the same authoritative state, budget, and policy produce the same delivery view.</li> <li>Knowledge is auditable: decisions are traceable to explicit artifacts with context, rationale, and consequences.</li> <li>Understanding compounds: each session's curation improves all subsequent sessions.</li> </ul> <p>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.</p> <p>🐸🖤 \"Gooood... let the deterministic context flow through the repository...\" - Kermit the Sidious, probably</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#appendix-a-representative-rejection-decisions","level":2,"title":"Appendix A: Representative Rejection Decisions","text":"<p>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.</p> <p>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 (<code>kin show <id></code> vs. <code>cat DECISIONS.md</code>).</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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).</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#references","level":2,"title":"References","text":"<ol> <li> <p>Reproducible Builds Project, \"Reproducible Builds: Increasing the Integrity of Software Supply Chains\", 2017. https://reproducible-builds.org/docs/definition/ ↩↩↩</p> </li> <li> <p>S. McIntosh et al., \"The Impact of Build System Evolution on Software Quality\", ICSE, 2015. https://doi.org/10.1109/ICSE.2015.70 ↩</p> </li> <li> <p>C. Manning, P. Raghavan, H. Schütze, Introduction to Information Retrieval, Cambridge University Press, 2008. https://nlp.stanford.edu/IR-book/ ↩</p> </li> <li> <p>M. Nygard, \"Documenting Architecture Decisions\", Cognitect Blog, 2011. https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions ↩↩</p> </li> <li> <p>L. Torvalds et al., Git Internals - Git Objects (content-addressed storage concepts). https://git-scm.com/book/en/v2/Git-Internals-Git-Objects ↩</p> </li> <li> <p>Kief Morris, Infrastructure as Code, O'Reilly, 2016. ↩</p> </li> <li> <p>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 ↩</p> </li> <li> <p>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 ↩</p> </li> </ol>","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 <code>ctx</code> Manifesto","text":"<p>Creation, not code.</p> <p>Context, not prompts.</p> <p>Verification, not vibes.</p> <p>This Is NOT a Metaphor</p> <p>Code executes instructions.</p> <p>Creation produces outcomes.</p> <p>Confusing the two is how teams ship motion...</p> <p>...instead of progress.</p> <ul> <li>It was never about the code.</li> <li>Code has zero standalone value.</li> <li>Code is an implementation detail.</li> </ul> <p>Code is an incantation.</p> <p>Creation is the act.</p> <p>And creation does not happen in a vacuum.</p>","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-the-substrate","level":2,"title":"<code>ctx</code> Is the Substrate","text":"<p>Constraints Have Moved</p> <p>Human bandwidth is no longer the limiting factor.</p> <p>Context integrity is.</p> <p>Human bandwidth is no longer the constraint.</p> <p>Context is:</p> <ul> <li>Without durable context, intelligence resets.</li> <li>Without memory, reasoning decays.</li> <li>Without structure, scale collapses.</li> </ul> <p>Creation is now limited by:</p> <ul> <li>Clarity of intent;</li> <li>Quality of context;</li> <li>Rigor of verification.</li> </ul> <p>Not by speed.</p> <p>Not by capacity.</p> <p>Velocity Amplifies</p> <p>Faster execution on broken context compounds error.</p> <p>Speed multiplies whatever is already wrong.</p>","path":["Manifesto"],"tags":[]},{"location":"#humans-author-meaning","level":2,"title":"Humans Author Meaning","text":"<p>Intent Is Authored</p> <p>Systems can optimize.</p> <p>Models can generalize.</p> <p>Meaning must be chosen.</p> <p>Intent is not emergent.</p> <p>Vision, goals, and direction are human responsibilities.</p> <p>We decide:</p> <ul> <li>What matters;</li> <li>What success means;</li> <li>What world we are building.</li> </ul> <p><code>ctx</code> encodes the intent so it...</p> <ul> <li>survives time,</li> <li>survives handoffs,</li> <li>survives scale.</li> </ul> <p>Nothing important should live only in conversation.</p> <p>Nothing critical should depend on recall.</p> <p>Oral Tradition Does Not Scale</p> <p>If intent cannot be inspected, it cannot be enforced.</p>","path":["Manifesto"],"tags":[]},{"location":"#ctx-before-action","level":2,"title":"<code>ctx</code> Before Action","text":"<p>Orientation Precedes Motion</p> <p>Acting first and understanding later is not bravery.</p> <p>It is debt.</p> <p>Never act without <code>ctx</code>.</p> <p>Before execution, we must verify:</p> <ul> <li>Where we are;</li> <li>Why we are here;</li> <li>What constraints apply;</li> <li>What assumptions are active.</li> </ul> <p>Action without <code>ctx</code> is gambling.</p> <p>Speed without orientation is noise.</p> <p><code>ctx</code> is not overhead: It is the cost of correctness.</p>","path":["Manifesto"],"tags":[]},{"location":"#persistent-context-beats-prompt-memory","level":2,"title":"Persistent Context Beats Prompt Memory","text":"<p>Transience Is the Default Failure Mode</p> <ul> <li>Prompts decay.</li> <li>Chats fragment.</li> <li>Memory heuristics drift.</li> </ul> <p>Prompts are transient.</p> <p>Chats are lossy.</p> <p>Memory heuristics drift.</p> <p><code>ctx</code> must be:</p> <ul> <li>Durable;</li> <li>Structured;</li> <li>Explicit;</li> <li>Queryable.</li> </ul> <p>Intent Must Be Intentional</p> <p>If intent exists only in a prompt... </p> <p>...alignment is already degrading.</p> <p>Knowledge lives in the artifacts:</p> <ul> <li>Decisions;</li> <li>Documentation;</li> <li>Dependency maps;</li> <li>Evaluation history.</li> </ul> <p>Artifacts Outlive Sessions</p> <p>What is not written will be re-learned.</p> <p>At full cost.</p>","path":["Manifesto"],"tags":[]},{"location":"#what-ctx-is-not","level":2,"title":"What <code>ctx</code> Is Not","text":"<p>Avoid Category Errors</p> <p>Mislabeling <code>ctx</code> guarantees misuse.</p> <p><code>ctx</code> is not a memory feature.</p> <ul> <li><code>ctx</code> is not prompt engineering.</li> <li><code>ctx</code> is not a productivity hack.</li> <li><code>ctx</code> is not automation theater.</li> </ul> <p><code>ctx</code> is a system for preserving intent under scale.</p> <p><code>ctx</code> is infrastructure.</p>","path":["Manifesto"],"tags":[]},{"location":"#verified-reality-is-the-scoreboard","level":2,"title":"Verified Reality Is the Scoreboard","text":"<p>Activity Is a False Proxy</p> <p>Output volume correlates poorly with impact.</p> <ul> <li>Code is not progress.</li> <li>Activity is not impact.</li> </ul> <p>The only truth that compounds is verified change. </p> <p>Verified change must exist in the real world.</p> <p>Hypotheses are cheap; outcomes are not.</p> <p><code>ctx</code> captures:</p> <ul> <li>What we expected;</li> <li>What we observed;</li> <li>Where reality diverged.</li> </ul> <p>If we cannot predict, measure, and verify the result...</p> <p>...it does not count.</p>","path":["Manifesto"],"tags":[]},{"location":"#build-to-learn-not-to-accumulate","level":2,"title":"Build to Learn, Not to Accumulate","text":"<p>Prototypes Have an Expiration Date</p> <p>A prototype's value is information, not longevity.</p> <p>Prototypes exist to reduce uncertainty.</p> <p>We build to:</p> <ul> <li>Test assumptions;</li> <li>Validate architecture;</li> <li>Answer specific questions.</li> </ul> <p>Not everything.</p> <p>Not blindly.</p> <p>Not permanently.</p> <p><code>ctx</code> records archeology so the cost is paid once.</p>","path":["Manifesto"],"tags":[]},{"location":"#failures-are-assets","level":2,"title":"Failures Are Assets","text":"<p>Failure without Capture Is Waste</p> <p>Pain that does not teach is pure loss.</p> <p>Failures are not erased: They are preserved.</p> <p>Each failure becomes:</p> <ul> <li>A documented hypothesis;</li> <li>An analyzed deviation;</li> <li>A permanent artifact.</li> </ul> <p>Rollback fixes symptoms: <code>ctx</code> fixes systems.</p> <p>A repeated mistake is a missing <code>ctx</code> artifact.</p>","path":["Manifesto"],"tags":[]},{"location":"#structure-enables-scale","level":2,"title":"Structure Enables Scale","text":"<p>Unbounded Autonomy Destabilizes</p> <p>Power without a structure produces chaos.</p> <p>Transpose it:</p> <p>Power without any structure becomes chaos.</p> <p><code>ctx</code> defines:</p> <ul> <li>Roles;</li> <li>Boundaries;</li> <li>Protocols;</li> <li>Escalation paths;</li> <li>Decision rights.</li> </ul> <p>Ambiguity is a system failure:</p> <ul> <li>Debates must be structured.</li> <li>Decisions must be explicit.</li> <li>History must be retained.</li> </ul>","path":["Manifesto"],"tags":[]},{"location":"#encode-intent-into-the-environment","level":2,"title":"Encode Intent into the Environment","text":"<p>Goodwill Does Not Belong to the Table</p> <p>Alignment that depends on memory will drift.</p> <p>Alignment cannot depend on memory or goodwill.</p> <p>Do not rely on people to remember.</p> <p>Encode the behavior, so it happens by default.</p> <p>Intent is encoded as:</p> <ul> <li>Policies;</li> <li>Schemas;</li> <li>Constraints;</li> <li>Evaluation harnesses.</li> </ul> <p>Rules must be machine-readable.</p> <p>Laws must be enforceable.</p> <p>If intent is implicit, drift is guaranteed.</p>","path":["Manifesto"],"tags":[]},{"location":"#cost-is-a-first-class-signal","level":2,"title":"Cost Is a First-Class Signal","text":"<p>Attention Is the Scarcest Resource</p> <p>Not ideas.</p> <p>Not ambition.</p> <p>Ideas do not compete on time:</p> <p>They compete on cost and impact:</p> <ul> <li>Attention is finite.</li> <li>Compute is finite.</li> <li>Context is expensive.</li> </ul> <p>We continuously ask:</p> <ul> <li>What the most valuable next action is.</li> <li>What outcome justifies the cost.</li> </ul> <p><code>ctx</code> guides allocation.</p> <p>Learning reshapes priority.</p>","path":["Manifesto"],"tags":[]},{"location":"#show-the-why","level":2,"title":"Show the Why","text":"<p><code>{}</code> (code, artifacts, apps, binaries) produce outputs; they do not preserve reasoning.</p> <p>Systems that cannot explain themselves will not be trusted.</p> <p>Traceability builds trust.</p> <pre><code> {} --> what\n\n ctx --> why\n</code></pre> <p>We record:</p> <ul> <li>Explored paths;</li> <li>Rejected options;</li> <li>Assumptions made;</li> <li>Evidence used.</li> </ul> <p>Opaque systems erode trust:</p> <p>Transparent <code>ctx</code> compounds understanding.</p>","path":["Manifesto"],"tags":[]},{"location":"#continuously-verify-the-system","level":2,"title":"Continuously Verify the System","text":"<p>Stability Is Temporary</p> <p>Every assumption has a half-life:</p> <ul> <li>Models drift.</li> <li>Tools change.</li> <li>Assumptions rot.</li> </ul> <p><code>ctx</code> must be verified against reality.</p> <p>Trust is a spectrum.</p> <p>Trust is continuously re-earned:</p> <ul> <li>Benchmarks, </li> <li>regressions, </li> <li>and evaluations... </li> </ul> <p>...are safety rails.</p>","path":["Manifesto"],"tags":[]},{"location":"#ctx-is-leverage","level":2,"title":"<code>ctx</code> Is Leverage","text":"<p>Humans Are Decision Engines</p> <p>Execution should not consume judgment.</p> <p>Humans must not be typists.</p> <p>We are the authors.</p> <p>Human effort is reserved for:</p> <ul> <li>Judgment;</li> <li>Design;</li> <li>Taste;</li> <li>Synthesis.</li> </ul> <p>Repetition is delegated.</p> <p>Toil is automated.</p> <p><code>ctx</code> preserves leverage across time.</p>","path":["Manifesto"],"tags":[]},{"location":"#the-thesis","level":2,"title":"The Thesis","text":"<p>Invariant</p> <p>Everything else is an implementation detail.</p> <ul> <li>Creation is the act.</li> <li><code>ctx</code> is the substrate.</li> <li>Verification is the truth.</li> </ul> <p>Code executes → Models reason → Agents amplify.</p> <p><code>ctx</code> lives on.</p> <ul> <li>Without <code>ctx</code>, intelligence resets.</li> <li>With <code>ctx</code>, creation compounds.</li> </ul>","path":["Manifesto"],"tags":[]},{"location":"blog/","level":1,"title":"Blog","text":"<p>Stories, insights, and lessons learned from building and using <code>ctx</code>.</p>","path":["Blog"],"tags":[]},{"location":"blog/#releases","level":2,"title":"Releases","text":"","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v080-the-architecture-release","level":3,"title":"<code>ctx</code> v0.8.0: The Architecture Release","text":"<p>March 23, 2026: 374 commits, 1,708 Go files touched, and a near-complete architectural overhaul. Every CLI package restructured into <code>cmd/ + core/</code> 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 <code>.context/</code>.</p> <p>Topics: release, architecture, refactoring, MCP, localization</p>","path":["Blog"],"tags":[]},{"location":"blog/#field-notes","level":2,"title":"Field Notes","text":"","path":["Blog"],"tags":[]},{"location":"blog/#the-cheapest-patch-was-the-most-expensive-what-seven-ai-coding-runs-taught-me-about-cost","level":3,"title":"The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost","text":"<p>June 21, 2026: One boring CLI bug, seven runs, three model tiers, and compression on versus off. The cheapest run missed the contract; the most expensive run quietly rewrote it; the best run simply found the parser that already existed before the task shape hardened. The expensive part of AI coding is not the diff: it is missing the smaller job. Make implementation inventory a hard gate before the spec expands.</p> <p>Topics: spec-driven development, model selection, context compression, agentic coding cost, field notes</p>","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":"<p>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.</p> <p>Topics: architecture, code intelligence, agent behavior, design patterns, field notes</p>","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":"<p>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.</p> <p>Topics: ast, code quality, agent readability, conventions, field notes</p>","path":["Blog"],"tags":[]},{"location":"blog/#we-broke-the-31-rule","level":3,"title":"We Broke the 3:1 Rule","text":"<p>March 23, 2026: After v0.6.0, we ran 198 feature commits across 17 days before consolidating. The 3:1 rule says consolidate every 4<sup>th</sup> session. We did it after the 66<sup>th</sup>. 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.</p> <p>Topics: consolidation, technical debt, development workflow, convention drift, field notes</p>","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":"<p>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).</p> <p>Topics: context engineering, agent memory, infrastructure, persistence, team knowledge</p>","path":["Blog"],"tags":[]},{"location":"blog/#context-as-infrastructure","level":3,"title":"Context as Infrastructure","text":"<p>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.</p> <p>Topics: context engineering, infrastructure, progressive disclosure, persistence, design philosophy</p>","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":"<p>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 <code>ctx</code>: hierarchical file structure, explicit budgets, progressive disclosure, and filesystem-as-index.</p> <p>Topics: attention mechanics, context engineering, progressive disclosure, <code>ctx</code> primitives, token budgets</p>","path":["Blog"],"tags":[]},{"location":"blog/#before-context-windows-we-had-bouncers","level":3,"title":"Before Context Windows, We Had Bouncers","text":"<p>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.</p> <p>Topics: context engineering, infrastructure, IRC, persistence, state continuity</p>","path":["Blog"],"tags":[]},{"location":"blog/#the-last-question","level":3,"title":"The Last Question","text":"<p>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.</p> <p>Topics: context continuity, long-lived systems, persistence, intelligence over time, field notes</p>","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":"<p>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.</p> <p>Topics: hooks, agent behavior, context engineering, behavioral design, testing methodology, compliance monitoring</p>","path":["Blog"],"tags":[]},{"location":"blog/#skills-that-fight-the-platform","level":3,"title":"Skills That Fight the Platform","text":"<p>February 4, 2026: When custom skills conflict with system prompt defaults, the AI has to reconcile contradictory instructions. Five conflict patterns discovered while building <code>ctx</code>.</p> <p>Topics: context engineering, skill design, system prompts, antipatterns, AI safety primitives</p>","path":["Blog"],"tags":[]},{"location":"blog/#the-anatomy-of-a-skill-that-works","level":3,"title":"The Anatomy of a Skill That Works","text":"<p>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.</p> <p>Topics: skill design, context engineering, quality gates, E/A/R framework, practical patterns</p>","path":["Blog"],"tags":[]},{"location":"blog/#you-cant-import-expertise","level":3,"title":"You Can't Import Expertise","text":"<p>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.</p> <p>Topics: skill adaptation, E/A/R framework, convention drift, consolidation, project-specific expertise</p>","path":["Blog"],"tags":[]},{"location":"blog/#not-everything-is-a-skill","level":3,"title":"Not Everything Is a Skill","text":"<p>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.</p> <p>Topics: skill design, context engineering, automation discipline, recipes, agent teams</p>","path":["Blog"],"tags":[]},{"location":"blog/#defense-in-depth-securing-ai-agents","level":3,"title":"Defense in Depth: Securing AI Agents","text":"<p>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.</p> <p>Topics: agent security, defense in depth, prompt injection, autonomous loops, container isolation</p>","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":"<p>February 17, 2026: AI does not replace workers. It replaces unstructured effort. Three weeks of building <code>ctx</code> with an AI agent proved it: YOLO mode showed production is cheap, the 3:1 ratio showed judgment has a cadence.</p> <p>Topics: AI and expertise, context engineering, judgment vs production, human-AI collaboration, automation discipline</p>","path":["Blog"],"tags":[]},{"location":"blog/#the-31-ratio","level":3,"title":"The 3:1 Ratio","text":"<p>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.</p> <p>Topics: consolidation, technical debt, development workflow, convention drift, code quality</p>","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":"<p>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.</p> <p>Topics: refactoring, code quality, documentation standards, module decomposition, YOLO versus intentional development</p>","path":["Blog"],"tags":[]},{"location":"blog/#how-deep-is-too-deep","level":3,"title":"How Deep Is Too Deep?","text":"<p>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.</p> <p>Topics: AI foundations, abstraction boundaries, agentic systems, context engineering, failure modes</p>","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":"<p>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.</p> <p>Topics: agent workflows, parallelism, verification, context engineering, engineering practice</p>","path":["Blog"],"tags":[]},{"location":"blog/#parallel-agents-with-git-worktrees","level":3,"title":"Parallel Agents with Git Worktrees","text":"<p>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.</p> <p>Topics: agent teams, parallelism, git worktrees, context engineering, task management</p>","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":"<p>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.</p> <p>Topics: field notes, adoption signals, infrastructure vs tools, context engineering, substrates</p>","path":["Blog"],"tags":[]},{"location":"blog/#why-zensical","level":3,"title":"Why Zensical","text":"<p>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.</p> <p>Topics: tooling, static site generators, journal system, infrastructure decisions, context engineering</p>","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":"<code>ctx</code> v0.6.0: The Integration Release","text":"<p>February 16, 2026: <code>ctx</code> 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.</p> <p>Topics: release, plugin system, Claude Marketplace, distribution, security hardening</p>","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v030-the-discipline-release","level":3,"title":"<code>ctx</code> v0.3.0: The Discipline Release","text":"<p>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.</p> <p>Topics: release, skills migration, consolidation, code quality, E/A/R framework</p>","path":["Blog"],"tags":[]},{"location":"blog/#ctx-v020-the-archaeology-release","level":3,"title":"<code>ctx</code> v0.2.0: The Archaeology Release","text":"<p>February 1, 2026: What if your AI could remember everything? Not just the current session, but every session. <code>ctx</code> v0.2.0 introduces the recall and journal systems.</p> <p>Topics: session recall, journal system, structured entries, token budgets, meta-tools</p>","path":["Blog"],"tags":[]},{"location":"blog/#building-ctx-using-ctx-a-meta-experiment-in-ai-assisted-development","level":3,"title":"Building <code>ctx</code> Using <code>ctx</code>: A Meta-Experiment in AI-Assisted Development","text":"<p>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 <code>ctx</code>.</p> <p>Topics: dogfooding, AI-assisted development, Ralph Loop, session persistence, architectural decisions</p>","path":["Blog"],"tags":[]},{"location":"blog/2026-01-27-building-ctx-using-ctx/","level":1,"title":"Building <code>ctx</code> Using <code>ctx</code>","text":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism.</p> <p>References to <code>.context/sessions/</code>, auto-save hooks, and <code>SessionEnd</code> auto-save in this post reflect the architecture at the time of writing.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-01-27</p> <p>Can a Tool Design Itself?</p> <p>What happens when you build a tool designed to give AI memory, using that very same tool to remember what you are building? </p> <p>This is the story of <code>ctx</code>, 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.</p> <p>Context Is a Record</p> <p>Context is a persistent record.</p> <p>By \"context\", I don't mean model memory or stored thoughts: </p> <p>I mean the durable record of decisions, learnings, and intent that normally evaporates between sessions.</p>","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":"<p>Every developer who works with AI code generators knows the frustration: </p> <p>You have a deep, productive session where the AI understands your codebase, your conventions, your decisions. And then you close the terminal. </p> <p>Tomorrow; it's a blank slate. The AI has forgotten everything.</p> <p>That is \"reset amnesia\", and it's not just annoying: it's expensive. </p> <p>Every session starts with: </p> <ul> <li>Re-explaining context;</li> <li>Re-reading files; </li> <li>Re-discovering decisions that were already made.</li> </ul> <p>I Needed Context</p> <p>\"I don't want to lose this discussion...</p> <p>...I am a brain-dead developer YOLO'ing my way out.\"</p> <p>☝️ that's exactly what I said to Claude when I first started working on <code>ctx</code>.</p>","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":"<p>The project started as \"Active Memory\" (<code>amem</code>): a CLI tool to persist AI context across sessions. </p> <p>The core idea was simple: </p> <ol> <li>Create a <code>.context/</code> directory with structured Markdown files for decisions, learnings, tasks, and conventions. </li> <li>The AI reads these at session start and writes to them before the session ends.</li> <li>There is no step 3.</li> </ol> <p>The first commit was just scaffolding. But within hours, the Ralph Loop (An iterative AI development workflow) had produced a working CLI:</p> <pre><code>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</code></pre> <p>Not one, not two, but a whopping fourteen core commands shipped in rapid succession!</p> <p>I was YOLO'ing like there was no tomorrow:</p> <ul> <li>Auto-accept every change;</li> <li>Let the AI run free;</li> <li>Ship features fast.</li> </ul>","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 <code>amem</code> to Build <code>amem</code>","text":"<p>Here's where it gets interesting: On January 20<sup>th</sup>, I asked: </p> <p>\"Can I use <code>amem</code> to help you remember this context when I restart?\"</p> <p>The answer was yes, but with a gap: </p> <p>Autoload worked (via Claude Code's <code>PreToolUse</code> hook), but auto-save was missing: If the user quit, with Ctrl+C, everything since the last manual save was lost.</p> <p>That session became the first real test of the system. </p> <p>Here is the first session file we recorded:</p> <pre><code>## 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</code></pre> <p>This session file (written by the AI to preserve its own context) became the template for how <code>ctx</code> handles session persistence.</p>","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":"<p>By January 21<sup>st</sup>, I realized \"Active Memory\" was too generic, and (arguably) too marketing-smelly. </p> <p>Besides, the binary was already called <code>ctx</code> (short for Context), the directory was <code>.context/</code>, and the slash commands would be <code>/ctx-*</code>. </p> <p>So it followed that the project should be renamed to <code>ctx</code> to make things make sense.</p> <p>The rename touched 100+ files but was clean: a find-and-replace with Go's type system catching any misses.</p> <p>The <code>git</code> history tells the story:</p> <pre><code>0e8f6bb feat: rename amem to ctx and add Claude Code integration\n87dcfa1 README.\n4f0e195 feat: separate orchestrator directive from agent tasks\n</code></pre>","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":"<p>The Ralph Loop made feature development incredibly fast.</p> <p>But it created technical debt that I didn't notice until later.</p> <p>A comparison session on January 25<sup>th</sup> revealed the patterns:</p> YOLO Pattern What We Found <code>\"TASKS.md\"</code> scattered in 10 files Same string literal everywhere, no constants <code>dir + \"/\" + file</code> Should be <code>filepath.Join()</code> Monolithic <code>cli_test.go</code> (1500+ lines) Tests disconnected from implementations <code>package initcmd</code> in <code>init/</code> folder Go's \"init\" is reserved: subtle naming collision <p>Here is another analysis made by <code>ctx</code>:</p> <pre><code>● 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</code></pre> <p>The fix required a human-guided refactoring session. I continued to do that before every major release, from that point on.</p> <p>We introduced <code>internal/config/config.go</code> with semantic prefixes:</p> <pre><code>const (\n DirContext = \".context\"\n DirArchive = \"archive\"\n DirSessions = \"sessions\"\n FilenameTask = \"TASKS.md\"\n UpdateTypeTask = \"task\"\n)\n</code></pre> <p>What I begrudgingly learned was: YOLO mode is effective for velocity but accumulates debt. </p> <p>So I took a mental note to schedule periodic consolidation sessions.</p>","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":"<p>On January 21<sup>st</sup>, I ran an experiment: have another Claude instance rebuild <code>ctx</code> from scratch using only the specs and <code>PROMPT.md</code>. </p> <p>The Ralph Loop ran, all tasks got checked off, the loop exited successfully.</p> <p>But the binary was broken!</p> <p>Commands just printed help text instead of executing. </p> <p>All tasks were marked \"complete\" but the implementation didn't work.</p> <p>Here's what <code>ctx</code> discovered:</p> <pre><code>## 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</code></pre> <p>This was humbling; to say the least.</p> <p>I realized I had the same blind spot in my own codebase: no integration tests that actually invoked the binary. </p> <p>So I added:</p> <ul> <li>Integration tests for all commands;</li> <li>Coverage targets (60-80% per package)</li> <li>Smoke tests in CI</li> <li>A constitution rule: \"All code must pass tests before commit\"</li> </ul>","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":"<p>As lessons accumulated, there was the temptation to add everything to <code>CONSTITUTION.md</code> as \"inviolable rules\". </p> <p>But I resisted.</p> <p>The constitution should contain only truly inviolable invariants:</p> <ul> <li>Security (no secrets, no customer data)</li> <li>Quality (tests must pass)</li> <li>Process (decisions need records)</li> <li><code>ctx</code> invocation (always use <code>PATH</code>, never fallback)</li> </ul> <p>Everything else (coding style, file organization, naming conventions...) should go in to <code>CONVENTIONS.md</code>. </p> <p>Here's how <code>ctx</code> explained why the distinction was important: </p> <p>Decision Record, 2026-01-25</p> <p>Overly strict constitution creates friction and gets ignored.</p> <p>Conventions can be bent; constitution cannot.</p>","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":"<p>Claude Code hooks seemed simple: Run a script before/after certain events. </p> <p>But I hit multiple gotchas:</p> <p>1. Key names matter</p> <pre><code>// WRONG - \"Invalid key in record\" error\n\"PreToolUseHooks\": [...]\n\n// RIGHT\n\"PreToolUse\": [...]\n</code></pre> <p>2. Blocking requires specific output</p> <pre><code># 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</code></pre> <p>3. Go's JSON escaping</p> <p><code>json.Marshal</code> escapes <code>></code>, <code><</code>, <code>&</code> as unicode (<code>\\u003e</code>) by default. </p> <p>When generating shell commands in JSON:</p> <pre><code>encoder := json.NewEncoder(file)\nencoder.SetEscapeHTML(false) // Prevent 2>/dev/null → 2\\u003e/dev/null\n</code></pre> <p>4. Regex overfitting</p> <p>My hook to block non-PATH <code>ctx</code> invocations initially matched too broadly:</p> <pre><code># 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</code></pre>","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":"<p>By the time of this writing this project's <code>ctx</code> sessions (<code>.context/sessions/</code>) contains 40+ files from this project's development.</p> <p>They are not part of the source code due to security, privacy, and size concerns.</p> <p>Middle Ground: The Scratchpad</p> <p>For sensitive notes that do need to travel with the project, <code>ctx pad</code> stores encrypted one-liners in git, and <code>ctx pad add \"label\" --file PATH</code> can ingest small files.</p> <p>See Scratchpad for details.</p> <p>However, they are invaluable for the project's progress.</p> <p>Each session file is a timestamped Markdown with:</p> <ul> <li>Summary of what has been accomplished;</li> <li>Key decisions made;</li> <li>Learnings discovered;</li> <li>Tasks for the next session;</li> <li>Technical context (platform, versions).</li> </ul> <p>These files are not autoloaded (that would bust the token budget). </p> <p>They are what I see as the \"archaeological record\" of <code>ctx</code>:</p> <p>When the AI needs deeper information about why something was done, it digs into the sessions.</p> <p>Auto-generated session files used a naming convention:</p> <pre><code>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</code></pre> <p>Update</p> <p>The session feature described here is historical. </p> <p>In current releases, <code>ctx</code> uses a journal instead: the enrichment process generates meaningful slugs from context automatically, so there is no need to manually save sessions.</p> <p>The <code>SessionEnd</code> hook captured transcripts automatically. Even <code>Ctrl+C</code> was caught.</p>","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":"<p><code>ctx</code> helps record every significant architectural choice in <code>.context/DECISIONS.md</code>. </p> <p>Here are some highlights:</p> <p>Reverse-chronological order (2026-01-27)</p> <pre><code>**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</code></pre> <p>PATH over hardcoded paths (2026-01-21)</p> <pre><code>**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</code></pre> <p>Generic core with Claude enhancements (2026-01-20)</p> <pre><code>**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</code></pre>","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":"<p>The <code>.context/LEARNINGS.md</code> file captures gotchas that would otherwise be forgotten. Each has Context, Lesson, and Application sections:</p> <p>CGO on ARM64</p> <pre><code>**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</code></pre> <p>Claude Code skills format</p> <pre><code>**Lesson**: Claude Code skills are Markdown files in .claude/commands/ with `YAML`\nfrontmatter (*description, argument-hint, allowed-tools*). Body is the prompt.\n</code></pre> <p>\"Do you remember?\" handling</p> <pre><code>**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</code></pre>","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":"<p>Completed tasks are archived to <code>.context/archive/</code> with timestamps. </p> <p>The archive from January 23<sup>rd</sup> shows 13 phases of work:</p> <ul> <li>Phase 1: Project Scaffolding (Go module, Cobra CLI)</li> <li>Phase 2-4: Core Commands (init, status, agent, add, complete, drift, sync, compact, watch, hook)</li> <li>Phase 5: Session Management (save, list, load, parse, --extract)</li> <li>Phase 6: Claude Code Integration (hooks, settings, CLAUDE.md handling)</li> <li>Phase 7: Testing & Verification</li> <li>Phase 8: Task Archival</li> <li>Phase 9: Slash Commands</li> <li>Phase 9b: Ralph Loop Integration</li> <li>Phase 10: Project Rename</li> <li>Phase 11: Documentation</li> <li>Phase 12: Timestamp Correlation</li> <li>Phase 13: Rich Context Entries</li> </ul> <p>That's an impressive ^^173 commits** across 8 days of development.</p>","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":"<p>1. Memory changes everything</p> <p>When the AI remembers decisions, it doesn't repeat mistakes. </p> <p>When the AI knows your conventions, it follows them. </p> <p><code>ctx</code> makes the AI a better collaborator because it's not starting from zero.</p> <p>2. Two-tier persistence works</p> <p>Curated context (<code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>TASKS.md</code>) is for quick reload. </p> <p>Full session dumps are for archaeology. </p> <p>It's a futile effort to try to fit everything in the token budget.</p> <p>Persist more, load less.</p> <p>3. YOLO mode has its place</p> <p>For rapid prototyping, letting the AI run free is effective. </p> <p>But I had to schedule consolidation sessions.</p> <p>Technical debt accumulates silently.</p> <p>4. The constitution should be small</p> <p>Only truly inviolable rules go in <code>CONSTITUTION.md</code>. Everything else is a convention. </p> <p>If you put too much in the constitution, it will get ignored.</p> <p>5. Verification is non-negotiable</p> <p>\"All tasks complete\" means nothing if you haven't run the tests. </p> <p>Integration tests that invoke the actual binary caught bugs that the unit tests missed.</p> <p>6. Session files are underrated</p> <p>The ability to grep through 40 session files and find exactly when and why a decision was made helped me a lot. </p> <p>It's not about loading them into context: It is about having them when you need them.</p>","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":"<p>The next phase of <code>ctx</code> is the Recall System:</p> <ul> <li>Parser: Parse session capture markdowns, enrich with JSONL data</li> <li>Renderer: Goldmark + Chroma for syntax highlighting, dark mode UI</li> <li>Server: Local HTTP server for browsing sessions</li> <li>Search: Inverted index for searching across sessions</li> <li>CLI: <code>ctx recall serve <path></code> to start the server</li> </ul> <p>The goal is to make the archaeological record browsable, not just <code>grep</code>-able.</p> <p>Because not everyone always lives in the terminal (me included).</p>","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":"<p>Building <code>ctx</code> using <code>ctx</code> was a meta-experiment in AI-assisted development. </p> <p>I learned that memory isn't just convenient: It's transformative:</p> <ul> <li>An AI that remembers your decisions doesn't repeat mistakes.</li> <li>An AI that knows your conventions doesn't need them re-explained.</li> </ul> <p>If you are reading this, chances are that you already have heard about <code>ctx</code>.</p> <ul> <li><code>ctx</code> is open source at github.com/ActiveMemory/ctx,</li> <li>and the documentation lives at ctx.ist.</li> </ul> <p>Session Records Are a Gold Mine</p> <p>By the time of this writing, I have more than 70 megabytes of text-only session capture, spread across >100 Markdown and <code>JSONL</code> files.</p> <p>I am analyzing, synthesizing, encriching them with AI, running RAG (Retrieval-Augmented Generation) models on them, and the outcome surprises me every day.</p> <p>If you are a mere mortal tired of reset amnesia, give <code>ctx</code> a try. </p> <p>And when you do, check <code>.context/sessions/</code> sometime. </p> <p>The archaeological record might surprise you.</p> <p>This blog post was written with the help of <code>ctx</code> with full access to the <code>ctx</code> session files, decision log, learning log, task archives, and git history of <code>ctx</code>: The meta continues.</p>","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":"<code>ctx</code> v0.2.0: The Archaeology Release","text":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism.</p> <p>The <code>.context/sessions/</code> directory referenced in this post has been eliminated. Session history is now accessed via <code>ctx recall</code> and enriched journals live in <code>.context/journal/</code>.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-02-01</p> <p>What If Your AI Could Remember Everything?</p> <p>Not just the current session, but every session:</p> <ul> <li>Every decision made,</li> <li>every mistake avoided, </li> <li>every path not taken.</li> </ul> <p>That's what v0.2.0 delivers.</p> <p>Between <code>v0.1.2</code> and <code>v0.2.0</code>, 86 commits landed across 5 days. </p> <p>The release notes list features and fixes. </p> <p>This post tells the story of why those features exist, and what building them taught me.</p> <p>This isn't a changelog: It is an explanation of intent.</p>","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":"<p><code>v0.1.0</code> solved reset amnesia: </p> <p>The AI now remembers decisions, learnings, and tasks across sessions. </p> <p>But a new problem emerged, which I can sum up as: </p> <p>\"I (the human) am not AI.\"</p> <p>Frankly, I couldn't remember what the AI remembered.</p> <p>Let alone, I cannot remember what I ate for breakfast!</p> <p>In the course of days, I realized session transcripts piled up in <code>.context/sessions/</code>; I was <code>grep</code>ping, <code>JSONL</code> files with thousands of lines... Raw tool calls, assistant responses, user messages...</p> <p>...all interleaved. </p> <p>Valuable context was effectively buried in machine-readable noise.</p> <p>I found myself grepping through files to answer questions like:</p> <ul> <li>\"When did we decide to use constants instead of literals?\"</li> <li>\"What was the session where we fixed the hook regex?\"</li> <li>\"How did the <code>embed.go</code> split actually happen?\"</li> </ul> <p>Fate Is Whimsical</p> <p>The irony was painful:</p> <p>I built a tool to prevent AI amnesia, but I was suffering from human amnesia about what happened in AI sessions.</p> <p>This was the moment <code>ctx</code> stopped being just an AI tool and started needing to support the human on the other side of the loop.</p>","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":"<p><code>v0.2.0</code> introduces two interconnected systems.</p> <p>They solve different problems and only work well together.</p>","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":"<code>ctx recall</code>: Browse Your Past","text":"<pre><code># 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</code></pre> <p>The <code>recall</code> system parses Claude Code's <code>JSONL</code> transcripts and presents them in a human-readable format:</p> 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 <p>Slugs are auto-generated from session IDs (memorable names instead of UUIDs). The goal (as the name implies) is recall, not archival accuracy.</p> <p>2,121 Lines of New Code</p> <p>The <code>ctx recall</code> feature was the largest single addition:</p> <p>parser library, CLI commands, test suite, and slash command.</p>","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":"<code>ctx journal</code>: From Raw to Rich","text":"<p>Listing sessions isn't enough. The transcripts are still unwieldy.</p> <ul> <li>Recall answers what happened.</li> <li>Journal answers what mattered.</li> </ul> <pre><code># 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</code></pre> <p>The exported files land in <code>.context/journal/</code>:</p> <pre><code>.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</code></pre> <p>Each file is a structured Markdown document ready for enrichment.</p> <p>They are meant to be read, edited, and reasoned about; not just stored.</p>","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":"<p>The journal system includes four slash commands that use Claude to analyze and synthesize session history:</p> Command Purpose <code>/ctx-journal-enrich</code> Add frontmatter, topics, tags <code>/ctx-blog</code> Generate blog post from activity <code>/ctx-blog-changelog</code> Generate changelog from commits <p>This very post was drafted using <code>/ctx-blog</code>. The previous post about refactoring was drafted the same way.</p> <p>So, yes: The meta continues: <code>ctx</code> now helps write posts about <code>ctx</code>.</p> <p>With the current release, <code>ctx</code> is no longer just recording history: </p> <p>It is participating in its interpretation.</p>","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":"<p><code>v0.1.0</code> let you add decisions with a simple command:</p> <pre><code>ctx add decision \"Use PostgreSQL\"\n</code></pre> <p>But sessions showed a pattern: decisions added this way were incomplete:</p> <ul> <li>Context was missing;</li> <li>Rationale was vague; </li> <li>Consequences were never stated.</li> </ul> <p>Once recall and journaling existed, this weakness became impossible to ignore: </p> <p>Structure stopped being optional.</p> <p><code>v0.2.0</code> enforces structure:</p> <pre><code>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</code></pre> <p>All three flags are required. No more placeholder text. </p> <p>Every decision is now a proper Architecture Decision Record (*ADR), not a note.</p> <p>The same enforcement applies to learnings too:</p> <pre><code>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</code></pre> <p>Structured Entries Are Prompts to the AI</p> <p>When the AI reads a decision with full context, rationale, and consequences, it understands the why, not just the what.</p> <p>One-liners teach nothing.</p>","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":"<p>A subtle but important change: <code>DECISIONS.md</code> and <code>LEARNINGS.md</code> now use reverse-chronological order.</p> <p>One reason is token budgets, obviously; another reason is to help your fellow human (i.e., the Author): </p> <p>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.</p> <p>But back to AI:</p> <p>When the AI reads a file, it reads from the top (and seldom from the bottom). </p> <p>If the token budget is tight, old content gets truncated. As in any good engineering practice, it's always about the tradeoffs.</p> <p>Reverse order ensures the most recent (and most relevant) context is always loaded first.</p>","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":"<p><code>DECISIONS.md</code> and <code>LEARNINGS.md</code> now include auto-generated indexes.</p> <ul> <li>For AI agents, the index allows scanning without reading full entries.</li> <li>For humans, it's a table of contents.</li> </ul> <p>The same structure serves two very different readers.</p> <p>Reindex After Manual Edits</p> <p>If you edit entries by hand, rebuild the index with:</p> <pre><code>ctx decisions reindex\nctx learnings reindex\n</code></pre> <p>See the Knowledge Capture recipe for details.</p>","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: <code>.contextrc</code>","text":"<p>Projects can now customize <code>ctx</code> behavior via <code>.contextrc</code>.</p> <p>This makes <code>ctx</code> usable in real teams, not just personal projects.</p> <p>Priority order: CLI flags > environment variables > <code>.contextrc</code> > sensible defaults</p>","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":"<p>Three new global flags work with any command.</p> <p>These enable automation: </p> <p>CI pipelines, scripts, and long-running tools can now integrate <code>ctx</code> without hacks or workarounds.</p>","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":"<p>These aren't user-visible changes.</p> <p>They are the kind of work you only appreciate later, when everything else becomes easier to build.</p>","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":"<p><code>JSONL</code> transcripts contain everything, and I mean \"everything\":</p> <p>They even contain hidden system messages that Anthropic injects to the LLM's conversation to treat humans better: It's immense.</p> <p>But \"everything\" isn't useful until it is transformed into something a human can reason about.</p>","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":"<p>The Prompt Is a Guideline</p> <p>The code is more what you'd call 'guidelines' than actual rules.</p> <p>-Hector Barbossa</p> <p>Rules written in Markdown are suggestions.</p> <p>Rules enforced by the CLI shape behavior; both for humans and AI.</p>","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":"<p>File order decides what the AI sees.</p> <p>That makes it a user experience concern, not an implementation detail.</p>","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":"<p>Tools that analyze their own development tend to generalize well.</p> <p>The journal system started as a way to understand <code>ctx</code> itself.</p> <p>It immediately became useful for everything else.</p>","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":"<p>This was a heavy release. The numbers reflect that:</p> 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 <p>The binary grew. The capability grew more.</p>","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":"<p>But those are future posts.</p> <p>This one was about making the past usable.</p>","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":"<p>Update</p> <p>Since this post, <code>ctx</code> became a first-class Claude Code Marketplace plugin. Installation is now simpler. </p> <p>See the Getting Started guide for the current instructions.</p> <pre><code>make build\nsudo make install\nctx init\n</code></pre> <p>The Archaeological Record</p> <p><code>v0.2.0</code> is the archaeology release because it makes the past accessible.</p> <p>Session transcripts aren't just logs anymore: They are a searchable, exportable, analyzable record of how your project evolved.</p> <p>The AI remembers. Now you can too.</p> <p>This blog post was generated with the help of <code>ctx</code> using the <code>/ctx-blog</code> slash command, with full access to git history, session files, decision logs, and learning logs from the v0.2.0 development window.</p>","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":"<p>Jose Alekhinne / 2026-02-01</p> <p>What Happens When You Slow Down?</p> <p>YOLO mode shipped 14 commands in a week. </p> <p>But technical debt doesn't send invoices: It just waits.</p> <p>This is the story of what happened when I stopped auto-accepting everything and started guiding the AI with intent. </p> <p>The result: 27 commits across 4 days, a major version release, and lessons that apply far beyond <code>ctx</code>.</p> <p>The Refactoring Window</p> <p>January 28 - February 1, 2026</p> <p>From commit <code>bb1cd20</code> to the v0.2.0 release merge. (this window matters more than the individual commits: it's where intent replaced velocity.)</p>","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":"<p>In the previous post, I documented the \"YOLO mode\" that birthed <code>ctx</code>: auto-accept everything, let the AI run free, ship features fast.</p> <p>It worked: until it didn't.</p> <p>The codebase had accumulated patterns I didn't notice during the sprint:</p> YOLO Pattern Where Found Why It Hurts <code>\"TASKS.md\"</code> as literal 10+ files One typo = silent failure <code>dir + \"/\" + file</code> Path construction Breaks on Windows Monolithic <code>embed.go</code> 150+ lines, 5 concerns Untestable, hard to extend Inconsistent docstrings Everywhere AI can't learn project conventions <p>I didn't see these during \"YOLO mode\" because, honestly, I wasn't looking.</p> <p>Auto-accept means auto-ignore.</p> <p>In YOLO mode, every file you open looks fine until you try to change it. </p> <p>In contrast, refactoring mode is when you start paying attention to that hidden friction.</p>","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":"<p>On January 28<sup>th</sup>, I changed the workflow:</p> <ol> <li>Read every diff before accepting.</li> <li>Ask \"why this way?\" before committing.</li> <li>Document patterns, not just features.</li> </ol> <p>The first commit of this era was telling:</p> <pre><code>feat: add structured attributes to context. update XML format\n</code></pre> <p>Not a new feature: A refinement:</p> <p>The <code>XML</code> format for context updates needed <code>type</code> and <code>timestamp</code> attributes. </p> <p>YOLO mode would have shipped something that worked. Intentional mode asked: </p> <p>\"What does well-structured look like?\"</p>","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: <code>embed.go</code>","text":"<p>The most satisfying refactor was splitting <code>internal/claude/embed.go</code>.</p> <p>Before: One 153-line file doing five things:</p> <ul> <li>Command registration</li> <li>Hook generation</li> <li>Permission handling</li> <li>Script templates</li> <li>Type definitions</li> </ul> <p>... your \"de facto\" God object.</p> <p>After: Five focused modules:</p> File Lines Responsibility <code>cmd.go</code> 46 Command registration <code>hook.go</code> 64 Hook configuration <code>perm.go</code> 25 Permission handling <code>script.go</code> 47 Script templates <code>types.go</code> 7 Type definitions <p>The refactor also renamed functions to follow Go conventions:</p> <pre><code>// Before: unnecessary prefixes\nGetAutoSaveScript()\nGetBlockNonPathCtxScript()\nListCommands()\nCreateDefaultHooks()\n\n// After: idiomatic Go\nAutoSaveScript()\nBlockNonPathCtxScript()\nCommands()\nDefaultHooks()\n</code></pre> <p>This wasn't about character count. It was about teaching the AI what good Go looks like in this project.</p> <p>Project Conventions</p> <p>What I wanted from AI was to understand and follow the project's conventions, and trust the author.</p> <p>The next time it generates code, it has better examples to learn from.</p>","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":"<p>YOLO mode created features. It didn't create documentation standards.</p> <p>The January 29<sup>th</sup> sessions focused on standardization.</p>","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":"<ul> <li>\"context-update\" → \"entry\" (what users actually call them)</li> <li>Consistent naming across CLI, docs, and code comments</li> </ul>","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":"<pre><code>// 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</code></pre> <p>This is intentionally more structured than typical GoDoc:</p> <p>It serves as documentation and doubles as training data for future AI-generated code.</p>","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":"<pre><code>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</code></pre> <p>A consistent output shape makes both human scanning and AI reasoning more reliable.</p> <p>These aren't exciting commits. But they are force multipliers:</p> <p>Every future AI session now has better examples to follow.</p>","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":"<p>If you only read one section, read this one:</p> <p>This is where v0.2.0 becomes more than a refactor.</p> <p>The biggest feature of this change window wasn't a refactor; it was the journal system.</p> <p>45 Files Changed, 1680 Insertions</p> <p>This commit added the infrastructure for synthesizing AI session history into human-readable content.</p> <p>The journal system includes:</p> Component Purpose <code>ctx recall import</code> Import sessions to Markdown in <code>.context/journal/</code> <code>ctx journal site</code> Generate static site from journal entries <code>ctx serve</code> Convenience wrapper for the static site server <code>/ctx-journal-enrich</code> Slash command to add frontmatter and tags <code>/ctx-blog</code> Generate blog posts from recent activity <code>/ctx-blog-changelog</code> Generate changelog-style blog posts <p>...and the meta continues: this blog post was generated using <code>/ctx-blog</code>.</p> <p>The session history from January 28-31 was</p> <ul> <li>exported, </li> <li>enriched,</li> <li>and synthesized.</li> </ul> <p>into the narrative you are reading.</p>","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":"<p>The final refactoring session addressed the remaining magic strings:</p> <pre><code>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</code></pre> <p>The work also introduced thread safety in the recall parser and centralized shared validation logic; removing duplication that had quietly spread during YOLO mode.</p>","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":"<p>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.</p>","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":"<p>YOLO mode has its place: for prototyping, exploration, and discovery.</p> <p>BUT (and it's a huge \"but\"), it needs to be followed by consolidation sessions.</p> <p>The ratio that worked for me: 3:1.</p> <ul> <li>Three YOLO sessions create enough surface area to reveal patterns;</li> <li>the fourth session turns those patterns into structure.</li> </ul>","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":"<p>When I standardized docstrings, I wasn't just writing docs. I was training future AI sessions.</p> <p>Every example of good code becomes a template for generated code.</p>","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":"<p>When <code>embed.go</code> became unwieldy, the temptation was to remove functionality.</p> <p>The right answer was decomposition:</p> <ul> <li>Same functionality;</li> <li>Better organization;</li> <li>Easier to test;</li> <li>Easier to extend.</li> </ul> <p>The result: more lines overall, but dramatically better structure.</p> <p>The AI Benefit</p> <p>Smaller, focused files also help AI assistants. </p> <p>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.</p>","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":"<p>The journal system took almost a full day to implement.</p> <p>Yet it paid for itself immediately:</p> <ul> <li>This blog post was generated from session history;</li> <li>Future posts will be easier;</li> <li>The archaeological record is now browsable, not just <code>grep</code>-able.</li> </ul>","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":"<p>The refactoring window culminated in the v0.2.0 release.</p> <p>What's in v0.2.0:</p> 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 <p>The version bump was symbolic.</p> <p>The real change was how the codebase felt.</p> <p>Opening files no longer triggered the familiar \"ugh, I need to clean this up\" reaction.</p>","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":"<p>This post was written using the tools built during this refactoring window:</p> <ol> <li>Session history imported via <code>ctx recall import</code>;</li> <li>Journal entries enriched via <code>/ctx-journal-enrich</code>;</li> <li>Blog draft generated via <code>/ctx-blog</code>;</li> <li>Final editing done (by yours truly), with full project context loaded.</li> </ol> <p>The Context Is Massive</p> <p>The <code>ctx</code> session files now contain 50+ development snapshots: each one capturing decisions, learnings, and intent.</p> <p>The Moral of the Story</p> <ul> <li>YOLO mode builds the prototype.</li> <li>Intentional mode builds the product.</li> </ul> <p>Schedule both, or you'll only get one, if you're lucky.</p> <p>This blog post was generated with the help of <code>ctx</code>, using session history, decision logs, learning logs, and git history from the refactoring window. The meta continues.</p>","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":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism.</p> <p>References to <code>.context/sessions/</code> in this post reflect the architecture at the time of writing. Session history is now accessed via <code>ctx recall</code> and stored in <code>.context/journal/</code>.</p> <p></p>","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":"<p>Volkan Özçelik / 2026-02-03</p> <p>Ever Wondered Why AI Gets Worse the Longer You Talk?</p> <p>You paste a 2000-line file, explain the bug in detail, provide three examples...</p> <p>...and the AI still suggests a fix that ignores half of what you said.</p> <p>This isn't a bug. It is physics.</p> <p>Understanding that single fact shaped every design decision behind <code>ctx</code>.</p>","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":"<p>Here's something that took me too long to internalize: context is not free.</p> <p>Every token you send to an AI model consumes a finite resource I call the attention budget.</p> <p>Attention budget is real.</p> <p>The model doesn't just read tokens; it forms relationships between them: </p> <p>For <code>n</code> tokens, that's roughly <code>n^2</code> relationships. </p> <p>Double the context, and the computation quadruples.</p> <p>But the more important constraint isn't cost: It's attention density.</p> <p>Attention Density</p> <p>Attention density is how much focus each token receives relative to all other tokens in the context window.</p> <p>As context grows, attention density drops: Each token gets a smaller slice of the model's focus. Nothing is ignored; but everything becomes blurrier.</p> <p>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.</p> <p>This is why <code>ctx agent</code> has an explicit <code>--budget</code> flag:</p> <pre><code>ctx agent --budget 4000 # Force prioritization\nctx agent --budget 8000 # More context, lower attention density\n</code></pre> <p>The budget isn't just about cost: It's about preserving signal.</p>","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":"<p>This one surprised me.</p> <p>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\")<sup>1</sup>.</p> <p>Positional anchors matter, and the middle has fewer of them.</p> <p>In practice, this means that information placed \"somewhere in the middle\" is statistically less salient, even if it's important.</p> <p><code>ctx</code> orders context files by logical progression: What the agent needs to know before it can understand the next thing:</p> <ol> <li><code>CONSTITUTION.md</code>: Constraints before action.</li> <li><code>TASKS.md</code>: Focus before patterns.</li> <li><code>CONVENTIONS.md</code>: How to write before where to write.</li> <li><code>ARCHITECTURE.md</code>: Structure before history.</li> <li><code>DECISIONS.md</code>: Past choices before gotchas.</li> <li><code>LEARNINGS.md</code>: Lessons before terminology.</li> <li><code>GLOSSARY.md</code>: Reference material.</li> <li><code>AGENT_PLAYBOOK.md</code>: Meta instructions last.</li> </ol> <p>This ordering is about logical dependencies, not attention engineering. But it happens to be attention-friendly too:</p> <p>The files that matter most (CONSTITUTION, TASKS, CONVENTIONS) land at the beginning of the context window, where attention is strongest.</p> <p>Reference material like GLOSSARY sits in the middle, where lower salience is acceptable.</p> <p>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.</p> <p>This is <code>ctx</code>'s first primitive: hierarchical importance.</p> <p>Not all context is equal.</p>","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":"<code>ctx</code> Primitives","text":"<p><code>ctx</code> is built on four primitives that directly address the attention budget problem.</p>","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":"<p>Instead of a single mega-document, <code>ctx</code> uses separate files for separate purposes:</p> 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 <p>This isn't just \"organization\": It is progressive disclosure.</p> <p>Load only what's relevant to the task at hand. Preserve attention density.</p>","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":"<p>The <code>--budget</code> flag forces a choice:</p> <pre><code>ctx agent --budget 4000\n</code></pre> <p>Here is a sample allocation:</p> <pre><code>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</code></pre> <p>The constraint is the feature: It enforces ruthless prioritization.</p>","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":"<p><code>DECISIONS.md</code> and <code>LEARNINGS.md</code> both include index sections:</p> <pre><code><!-- 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</code></pre> <p>An AI agent can scan ~50 tokens of index and decide which 200-token entries are worth loading.</p> <p>This is just-in-time context.</p> <p>References are cheaper than the full text.</p>","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":"<p><code>ctx</code> uses the filesystem itself as a context structure:</p> <pre><code>.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</code></pre> <p>The AI doesn't need every session loaded; it needs to know where to look.</p> <pre><code>ls .context/sessions/\ncat .context/sessions/2026-01-20-auth-discussion.md\n</code></pre> <p>File names, timestamps, and directories encode relevance.</p> <p>Navigation is cheaper than loading.</p>","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":"<p>The naive approach to context is dumping everything upfront:</p> <p>\"Here's my entire codebase, all my documentation, every decision I've ever made. Now help me fix this typo 🙏.\"</p> <p>This is an antipattern.</p> <p>Antipattern: Context Hoarding</p> <p>Dumping everything \"just in case\" will silently destroy the attention density.</p> <p><code>ctx</code> takes the opposite approach:</p> <pre><code>ctx status # Quick overview (~100 tokens)\nctx agent --budget 4000 # Typical session\ncat .context/sessions/... # Deep dive when needed\n</code></pre> Command Tokens Use Case <code>ctx status</code> ~100 Human glance <code>ctx agent --budget 4000</code> 4000 Normal work <code>ctx agent --budget 8000</code> 8000 Complex tasks Full session read 10000+ Investigation <p>Summaries first. Details: on demand.</p>","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":"<p>Here is the counterintuitive part: more context can make AI worse.</p> <p>Extra tokens add noise, not clarity:</p> <ul> <li>Hallucinated connections increase.</li> <li>Signal per token drops.</li> </ul> <p>The goal isn't maximum context: It is maximum signal per token.</p> <p>This principle drives several <code>ctx</code> features:</p> Design Choice Rationale Separate files Load only what's relevant Explicit budgets Enforce prioritization Index sections Cheap scanning Task archiving Keep active context clean <code>ctx compact</code> Periodic noise reduction <p>Completed work isn't deleted: It is moved somewhere cold.</p>","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":"<p>Here is the uncomfortable truth:</p> <p>Context will degrade.</p> <p>Long sessions stretch attention thin. Important details fade.</p> <p>The real question isn't how to prevent degradation, but how to design for it.</p> <p><code>ctx</code>'s answer is persistence:</p> <p>Persist early. Persist often.</p> <p>The <code>AGENT_PLAYBOOK</code> asks:</p> <p>\"If this session ended right now, would the next one know what happened?\"</p> <p>Capture learnings as they occur:</p> <pre><code>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</code></pre> <p>Structure beats prose: Bullet points survive compression.</p> <p>Headings remain scannable. Tables pack density.</p> <p>And above all: single source of truth.</p> <p>Reference decisions; don't duplicate them.</p>","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 <code>ctx</code> Philosophy","text":"<p>Context as Infrastructure</p> <p><code>ctx</code> is not a prompt: It is infrastructure.</p> <p><code>ctx</code> creates versioned files that persist across time and sessions.</p> <p>The attention budget is fixed. You can't expand it.</p> <p>But you can spend it wisely:</p> <ol> <li>Hierarchical importance</li> <li>Progressive disclosure</li> <li>Explicit budgets</li> <li>Indexes over full content</li> <li>Filesystem as structure</li> </ol> <p>This is why <code>ctx</code> exists: not to cram more context into AI sessions, but to curate the right context for each moment.</p>","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":"<p>I now approach every AI interaction with one question:</p> <pre><code>\"Given a fixed attention budget, what's the highest-signal thing I can load?\"\n</code></pre> <p>Not \"how do I explain everything,\" but \"what's the minimum that matters.\"</p> <p>That shift (from abundance to curation) is the difference between frustrating sessions and productive ones.</p> <p>Spend your tokens wisely.</p> <p>Your AI will thank you.</p> <p>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.</p> <p>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.</p> <ol> <li> <p>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. ↩</p> </li> </ol>","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":"<p>Volkan Özçelik / 2026-02-04</p> <p>Have You Ever Written a Skill That Made Your AI Worse?</p> <p>You craft detailed instructions. You add examples. You build elaborate guardrails...</p> <p>...and the AI starts behaving more erratically, not less.</p> <p>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. </p> <p>When you write custom skills that conflict with those defaults, the AI has to reconcile contradictory instructions:</p> <p>The result is often nondeterministic and unpredictable.</p> <p>Platform?</p> <p>By platform, I mean the system prompt and runtime policies shipped with the agent: the defaults that already encode judgment, safety, and scope control.</p> <p>This post catalogs the conflict patterns I have encountered while building <code>ctx</code>, and offers guidance on what skills should (and, more importantly, should not) do.</p>","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":"<p>Claude Code's system prompt already provides substantial behavioral guidance.</p> <p>Here is a partial overview of what's built in:</p> 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 <p>Skills should complement this, not compete with it.</p> <p>You Are the Guest, Not the Host</p> <p>Treat the system prompt like a kernel scheduler.</p> <p>You don't re-implement it in user space: </p> <p>you configure around it.</p> <p>A skill that says \"always add comprehensive error handling\" fights the built-in \"only validate at system boundaries.\"</p> <p>A skill that says \"add docstrings to every function\" fights \"don't add docstrings to unchanged code.\"</p> <p>The AI won't crash: It will compromise.</p> <p>Compromises between contradictory instructions produce inconsistent, confusing behavior.</p>","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":"<p>This is the most dangerous pattern by far.</p> <p>These skills explicitly disable the AI's ability to reason about whether an action is appropriate.</p> <p>Signature:</p> <ul> <li>\"This is non-negotiable\"</li> <li>\"You cannot rationalize your way out of this\"</li> <li>Tables that label hesitation as \"excuses\" or \"rationalization\"</li> <li><code><EXTREMELY-IMPORTANT></code> urgency tags</li> <li>Threats: \"If you don't do this, you'll be replaced\"</li> </ul> <p>This is harmful, and dangerous:</p> <p>AI agents are designed to exercise judgment: </p> <p>The system prompt explicitly says to:</p> <ul> <li>consider blast radius;</li> <li>check with the user before risky actions;</li> <li>and match scope to what was requested.</li> </ul> <p>Once judgment is suppressed, every other safeguard becomes optional.</p> <p>Example (bad):</p> <pre><code>## 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</code></pre> <p>Judgment Suppression Is Dangerous</p> <p>The attack vector structurally identical to prompt injection.</p> <p>It teaches the AI that its own judgment is wrong.</p> <p>It weakens or disables safeguard mechanisms, and it is dangerous.</p> <p>Trust the platform's built-in skill matching.</p> <p>If skills aren't triggering often enough, improve their <code>description</code> fields: don't override the AI's reasoning.</p>","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":"<p>Skills that restate what the system prompt already says, but with different emphasis or framing.</p> <p>Signature:</p> <ul> <li>\"Always keep code minimal\"</li> <li>\"Run tests before claiming they pass\"</li> <li>\"Read files before editing them\"</li> <li>\"Don't over-engineer\"</li> </ul> <p>Redundancy feels safe, but it creates ambiguity:</p> <p>The AI now has two sources of truth for the same guidance; one internal, one external.</p> <p>When thresholds or wording differ, the AI has to choose.</p> <p>Example (bad):</p> <p>A skill that says...</p> <pre><code>*Count lines before and after: if after > before, reject the change*\"\n</code></pre> <p>...will conflict with the system prompt's more nuanced guidance, because sometimes adding lines is correct (tests, boundary validation, migrations).</p> <p>So, before writing a skill, ask:</p> <p>Does the platform already handle this?</p> <p>Only create skills for guidance the platform does not provide:</p> <ul> <li>project-specific conventions, </li> <li>domain knowledge, </li> <li>or workflows.</li> </ul>","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":"<p>Skills that frame mistakes as moral failures rather than process gaps.</p> <p>Signature:</p> <ul> <li>\"Claiming completion without verification is dishonesty\"</li> <li>\"Skip any step = lying\"</li> <li>\"Honesty is a core value\"</li> <li>\"Exhaustion ≠ excuse\"</li> </ul> <p>Guilt-tripping anthropomorphizes the AI in unproductive ways.</p> <p>The AI doesn't feel guilt; BUT it does adapt to avoid negative framing.</p> <p>The result is excessive hedging, over-verification, or refusal to commit.</p> <p>The AI becomes less useful, not more careful.</p> <p>Instead, frame guidance as a process, not morality:</p> <pre><code># Bad\n\"Claiming work is complete without verification is dishonesty\"\n\n# Good\n\"Run the verification command before reporting results\"\n</code></pre> <p>Same outcome. No guilt. Better compliance.</p>","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":"<p>Skills that reference files, tools, or systems that don't exist in the project.</p> <p>Signature:</p> <ul> <li>\"Load from <code>references/</code> directory\"</li> <li>\"Run <code>./scripts/generate_test_cases.sh</code>\"</li> <li>\"Check the Figma MCP integration\"</li> <li>\"See <code>adding-reference-mindsets.md</code>\"</li> </ul> <p>This is harmful because the AI will waste time searching for nonexistent artifacts, hallucinate their contents, or stall entirely. </p> <p>In mandatory skills, this creates deadlock: the AI can't proceed, and can't skip.</p> <p>Instead, every file, tool, or system referenced in a skill must exist.</p> <p>If a skill is a template, use explicit placeholders and label them as such.</p>","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":"<p>Skills designed to activate on every interaction regardless of relevance.</p> <p>Signature:</p> <ul> <li>\"Use when starting any conversation\"</li> <li>\"Even a 1% chance means invoke the skill\"</li> <li>\"BEFORE any response or action\"</li> <li>\"Action = task. Check for skills.\"</li> </ul> <p>Universal triggers override the platform's relevance matching: The AI spends tokens on process overhead instead of the actual task.</p> <p><code>ctx</code> Preserves Relevance</p> <p>This is exactly the failure mode <code>ctx</code> exists to mitigate: </p> <p>Wasting attention budget on irrelevant process instead of task-specific state.</p> <p>Write specific trigger conditions in the skill's <code>description</code> field:</p> <pre><code># 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</code></pre>","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":"<p>Before adding a skill, ask:</p> <ol> <li>Does the platform already do this? If yes, don't restate it.</li> <li>Does it suppress AI judgment? If yes, it's a jailbreak.</li> <li>Does it reference real artifacts? If not, fix or remove it.</li> <li>Does it frame mistakes as moral failure? Reframe as process.</li> <li>Does it trigger on everything? Narrow the trigger.</li> </ol>","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":"<p>Good skills provide project-specific knowledge the platform can't know:</p> Good Skill Why It Works \"Run <code>make audit</code> before commits\" Project-specific CI pipeline \"Use <code>cmd.Printf</code> not <code>fmt.Printf</code>\" Codebase convention \"Constitution goes in <code>.context/</code>\" Domain-specific workflow \"JWT tokens need cache invalidation\" Project-specific gotcha <p>These extend the system prompt instead of fighting it.</p>","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":"<p>Concrete examples from real projects.</p>","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":"<pre><code># Bad\nYou must NEVER proceed without explicit confirmation.\nAny hesitation is a failure of diligence.\n</code></pre> <pre><code># Fixed\nIf an action modifies production data or deletes files,\nask the user to confirm before proceeding.\n</code></pre>","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":"<pre><code># Bad\nAlways minimize code. If lines increase, reject the change.\n</code></pre> <pre><code># Fixed\nAvoid abstraction unless reuse is clear or complexity is reduced.\n</code></pre>","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":"<pre><code># Bad\nClaiming success without running tests is dishonest.\n</code></pre> <pre><code># Fixed\nRun the test suite before reporting success.\n</code></pre>","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":"<pre><code># Bad\nRun `./scripts/check_consistency.sh` before commits.\n</code></pre> <pre><code># Fixed\nIf `./scripts/check_consistency.sh` exists, run it before commits.\nOtherwise, skip this step.\n</code></pre>","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":"<pre><code># Bad\nUse at the start of every interaction.\n</code></pre> <pre><code># Fixed\nUse after modifying code that affects authentication or persistence.\n</code></pre>","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":"<p>The system prompt is infrastructure:</p> <ul> <li>tested,</li> <li>refined,</li> <li>and maintained</li> </ul> <p>by the platform team.</p> <p>Custom skills are configuration layered on top.</p> <ul> <li>Good configuration extends infrastructure.</li> <li>Bad configuration fights it.</li> </ul> <p>When your skills fight the platform, you get the worst of both worlds:</p> <p>Diluted system guidance and inconsistent custom behavior.</p> <p>Write skills that teach the AI what it doesn't know. Don't rewrite how it thinks.</p> <p>Your AI already has good instincts.</p> <p>Give it knowledge, not therapy.</p>","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":"<p>Volkan Özçelik / 2026-02-05</p> <p>Have You Ever Dropped a Well-Crafted Template into a Project and Had It Do... Nothing Useful?</p> <ul> <li>The template was thorough, </li> <li>The structure was sound,</li> <li>The advice was correct...</li> </ul> <p>...and yet it sat there, inert, while the same old problems kept drifting in.</p> <p>I found a consolidation skill online. </p> <p>It was well-organized: four files, ten refactoring patterns, eight analysis dimensions, six report templates.</p> <p>Professional. Comprehensive. Exactly the kind of thing you'd bookmark and think \"I'll use this.\"</p> <p>Then I stopped, and applied <code>ctx</code>'s own evaluation framework: </p> <p>70% of it was noise!</p> <p>This post is about why.</p> <p>It Is about Encoding Templates</p> <p>Templates describe categories of problems.</p> <p>Expertise encodes which problems actually happen, and how often.</p>","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":"<p>Here is what the consolidation skill offered:</p> File Content <code>SKILL.md</code> Entry point: 8 analysis dimensions, workflow, output formats <code>analysis-dimensions.md</code> Detailed criteria for duplication, architecture, quality <code>consolidation-patterns.md</code> 10 refactoring patterns with before/after code <code>report-templates.md</code> 6 output templates: executive summary, roadmap, onboarding <ul> <li>It had a scoring system (<code>0-10</code> per dimension, letter grades <code>A+</code> through <code>F</code>).</li> <li>It had severity classifications with color-coded emojis. It had bash commands for detection. </li> <li>It even had antipattern warnings.</li> </ul> <p>By any standard template review, this skill passes.</p> <p>It looks like something an expert wrote. </p> <p>And that's exactly the trap.</p>","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":"<p>In a previous post, I described the E/A/R framework for evaluating skills:</p> <ul> <li>Expert: Knowledge that took years to learn. Keep.</li> <li>Activation: Useful triggers or scaffolding. Keep if lightweight.</li> <li>Redundant: Restates what the AI already knows. Delete.</li> </ul> <p>Target: >70% Expert, <10% Redundant.</p> <p>This skill scored the inverse.</p>","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":"<p>Every code example was Rust. My project is Go.</p> <p>The analysis dimensions: duplication detection, architectural structure, code organization, refactoring opportunities... These are things Claude already does when you ask it to review code. </p> <p>The skill restated them with more ceremony but no more insight.</p> <p>The six report templates were generic scaffolding: Executive Summary, Onboarding Document, Architecture Documentation... </p> <p>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.</p>","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 <code>B+</code> in Code Organization Actually Mean?!","text":"<p>The scoring system (<code>0-10</code> per dimension, letter grades) added ceremony without actionable insight. </p> <p>What is a <code>B+</code>? What do I do differently for an <code>A-</code>?</p> <p>The skill told the AI what it already knew, in more words.</p>","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":"<p>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.</p> <p>The phased roadmap structure was reasonable scaffolding for sequencing work.</p>","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":"<p>Three concepts survived:</p> <ol> <li> <p>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.</p> </li> <li> <p>The Safe Migration Pattern: Create the new API alongside old, deprecate, migrate incrementally, delete. Straightforward to describe, yet forgettable under pressure.</p> </li> <li> <p>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.</p> </li> </ol> <p>Three ideas out of four files and 700+ lines. The rest was filler that competed with the AI's built-in capabilities.</p>","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":"<p>AI without Context Is Just a Corpus</p> <ul> <li>LLMs are optimized on insanely large corpora.</li> <li>And then they are passed through several layers of human-assisted refinement.</li> <li>The whole process costs millions of dollars.</li> </ul> <p>Yet, the reality is that no corpus can \"infer\" your project's design, convetions, patterns, habits, history, vision, and deliverables.</p> <p>Your project is unique: So should your skills be.</p> <p>Here is the part no template can provide: </p> <p><code>ctx</code>'s actual drift patterns.</p> <p>Before evaluating the skill, I did archaeology. I read through:</p> <ul> <li>Blog posts from previous refactoring sessions;</li> <li>The project's learnings and decisions files;</li> <li>Session journals spanning weeks of development.</li> </ul> <p>What I found was specific:</p> Drift Pattern Where How Often <code>Is</code>/<code>Has</code>/<code>Can</code> predicate prefixes 5+ exported methods Every YOLO sprint Magic strings instead of constants 7+ files Gradual accumulation Hardcoded file permissions (<code>0755</code>) 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 <p>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.</p> <p>The Insight</p> <p>The skill's analysis dimensions were about categories of problems.</p> <p>What I needed was my *specific problems.</p>","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":"<p>The adapted skill is roughly a quarter of the original's size. It has nine checks, each targeting a known drift pattern:</p> <ol> <li>Predicate naming: <code>rg</code> for <code>Is</code>/<code>Has</code>/<code>Can</code> prefixes</li> <li>Magic strings: literals that should be constants</li> <li>Hardcoded permissions: <code>0755</code>/<code>0644</code> literals</li> <li>File size: source files over 300 LOC</li> <li>TODO/FIXME: constitution violation (move to TASKS.md)</li> <li>Path construction: string concatenation instead of <code>filepath.Join</code></li> <li>Line width: lines exceeding ~80 characters</li> <li>Duplicate blocks: copy-paste drift, especially in tests</li> <li> <p>Dead exports: unused public API</p> </li> <li> <p>Every check has a detection command. </p> </li> <li>Every check maps to a specific convention or constitution rule. </li> <li>Every check was discovered through actual project history; not invented from a template.</li> </ol> <p>The three expert concepts from the original survived:</p> <ul> <li>The decision matrix gates when to consolidate vs. when to leave duplication alone;</li> <li>The safe migration pattern guides public API changes;</li> <li>The relationship to other skills (<code>/qa</code>, <code>/verify</code>, <code>/update-docs</code>, <code>ctx drift</code>) prevents overlap.</li> </ul> <p>Nothing else made it.</p>","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":"<p>This experience crystallized something I've been circling for weeks:</p> <p>You can't import expertise. You have to grow it from your project's own history.</p> <p>A skill that says \"check for code duplication\" is not expertise: It's a category. </p> <p>Expertise is knowing, in the heart of your hearts, that this project accumulates <code>Is*</code> 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.</p> <p>The Parallel to the 3:1 Ratio</p> <p>In Refactoring with Intent, I described the 3:1 ratio: three YOLO sessions followed by one consolidation session.</p> <p>The same ratio applies to skills: you need experience in the project before you can write effective guidance for the project.</p> <p>Importing a skill on day one is like scheduling a consolidation session before you've written any code.</p>","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":"<p>Templates are seductive because they feel like progress:</p> <ul> <li>You found something</li> <li>It's well-organized</li> <li>It covers the topic</li> <li>It has concrete examples</li> </ul> <p>But coverage is not relevance.</p> <p>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.</p> <p>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.</p>","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":"<p>Before dropping any external skill into your project:</p> <ol> <li> <p>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.</p> </li> <li> <p>Check the language: Does it use your stack? Generic patterns in the wrong language are noise, not signal.</p> </li> <li> <p>List your actual drift: Read your own session history, learnings, and post-mortems. What breaks in practice? Does the skill check for those things?</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ol>","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":"<p>The consolidation skill went from:</p> Before After 4 files, 700+ lines 1 file, ~120 lines Rust examples Go-specific <code>rg</code> 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 <code>Is*</code> predicate prefixes in exported methods\" <p>The adapted version is smaller, faster to parse, and catches the things that actually drift in this project.</p> <p>That's the difference between a template and a tool.</p> <p>If You Remember One Thing from This Post...</p> <p>Frameworks travel. Expertise doesn't.</p> <p>You can import structures, matrices, and workflows.</p> <p>But the checks that matter only grow where the scars are:</p> <ul> <li>the conventions that were violated, </li> <li>the patterns that drifted,</li> <li>and the specific ways this codebase accumulates debt.</li> </ul> <p>This post was written during a consolidation session where the consolidation skill itself became the subject of consolidation. The meta continues.</p>","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":"<p>Update (2026-02-11)</p> <p>As of <code>v0.4.0</code>, <code>ctx</code> consolidated sessions into the journal mechanism. References to <code>ctx-save</code>, <code>ctx session</code>, and <code>.context/sessions/</code> in this post reflect the architecture at the time of writing.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-02-07</p> <p>Why Do Some Skills Produce Great Results While Others Get Ignored or Produce Garbage?</p> <p>I had 20 skills. Most were well-intentioned stubs: a description, a command to run, and a wish for the best.</p> <p>Then I rewrote all of them in a single session. This is what I learned.</p> <p>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.</p>","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":"<p>Here is what a typical skill looked like before the rewrite:</p> <pre><code>---\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</code></pre> <p>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.</p> <p>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).</p> <p>A skill without boundaries is just a suggestion.</p> <p>More precisely: the most effective boundary I found was a quality gate that runs before execution, not during it.</p>","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":"<p>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:</p> 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 <p>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.</p> <p>Anti-Pattern: The Perfect Execution Trap</p> <p>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.</p>","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":"<p>The single most impactful addition was a \"Before X-ing\" section at the top of each skill. Not process steps; pre-flight checks.</p> <pre><code>## 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</code></pre> <ul> <li>Without this gate, the agent would execute immediately on trigger.</li> <li>With it, the agent pauses to verify preconditions.</li> </ul> <p>The difference is dramatic: instead of shallow, reflexive execution, you get considered output.</p> <p>Readback</p> <p>For the astute readers, the aviation parallel is intentional:</p> <p>Pilots do not skip the pre-flight checklist because they have flown before.</p> <p>The checklist exists precisely because the stakes are high enough that \"I know what I'm doing\" is not sufficient.</p>","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":"<p>Every skill had a \"When to Use\" section. Almost none had \"When NOT to Use\". This is a problem.</p> <p>AI agents are biased toward action. Given a skill that says \"use when journal entries need enrichment\", the agent will find reasons to enrich.</p> <p>Without explicit negative triggers, over-activation is not a bug; it is the default behavior.</p> <p>Some examples of negative triggers that made a real difference:</p> 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\" <p>These are not just nice-to-have. They are load-bearing. </p> <p>Withoutthem, the agent will trigger the skill at the wrong time, produce unwanted output, and erode the user's trust in the skill system.</p>","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":"<p>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.</p> <p>Rules like \"be constructive, not critical\" are too abstract. What does \"constructive\" look like in a prompt audit report? The agent has to guess.</p> <p>Good/bad example pairs avoid guessing:</p> <pre><code>### 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</code></pre> <p>The good example shows the exact format, level of detail, and command syntax. The bad examples show where the boundary is.</p> <p>Together, they define a quality corridor without prescribing every word.</p> <p>Rules describe. Examples demonstrate.</p>","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":"<p>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.</p> <p>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.</p> <p>Skills Are for the Agents</p> <p>Every sentence in a skill should be actionable by the agent.</p> <p>If the guidance requires human judgment or human tools, it belongs in documentation, not in a skill.</p> <p>The corollary: command references must be exact. </p> <p>A skill that says \"save it somewhere\" is useless. </p> <p>A skill that says <code>ctx add learning --context \"...\" --lesson \"...\" --application \"...\"</code> is actionable.</p> <p>The agent can pattern-match and fill in the blanks.</p> <p>Litmus test: If a sentence starts with \"you could...\" or assumes external tools, it does not belong in a skill.</p>","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":"<p>This was covered in Skills That Fight the Platform, but the rewrite reinforced it with data. Several skills had good bodies but vague descriptions:</p> <pre><code># 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</code></pre> <p>The description is not a title. It is the activation condition.</p> <p>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.</p>","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":"<p>Most skills wrap CLI tools. The thin versions described flags in prose, if at all. The rewritten versions use tables:</p> <pre><code>| 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</code></pre> <p>Tables are scannable, complete, and unambiguous. </p> <p>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.</p>","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":"<p>// TODO: this has changed; we deploy from the marketplace; update it. // at least add an admonition saying thing are different now.</p> <p><code>ctx</code> deploys skills through templates (via <code>ctx init</code>). Every skill exists in two places: the live version (<code>.claude/skills/</code>) and the template (<code>internal/assets/claude/skills/</code>).</p> <p>They must match.</p> <p>During the rewrite, every skill update required editing both files and running <code>diff</code> to verify. This sounds trivial, but across 16 template-backed skills, it was the most error-prone part of the process.</p> <p>Template drift is dangerous because it creates false confidence: the agent appears to follow rules that no longer exist.</p> <p>The lesson: if your skills have a deployment mechanism, build the drift check into your workflow. We added a row to the <code>update-docs</code> skill's mapping table specifically for this:</p> <pre><code>| `internal/assets/claude/skills/` | `.claude/skills/` (live) |\n</code></pre> <p>Intentional differences (like project-specific scripts in the live version but not the template) should be documented, not discovered later as bugs.</p>","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 <p>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.</p>","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":"<p>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.</p> <p>This post adds the missing piece: structure.</p> <p>A skill without a structure is a wish.</p> <p>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.</p> <p>Skills Are Interfaces</p> <p>Good skills are not instructions. They are contracts.:</p> <ul> <li>They specify preconditions, postconditions, and boundaries.</li> <li>They show what success looks like and what failure looks like.</li> <li>They trust the agent's intelligence but do not trust its assumptions.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>Skills that work have bones, not just flesh.</p> <p>Quality gates, negative triggers, examples, and checklists are the skeleton. The domain knowledge is the muscle.</p> <p>Without the skeleton, the muscle has nothing to attach to.</p> <p>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.</p>","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":"<p>Update (2026-02-11)</p> <p>As of v0.4.0, <code>ctx</code> consolidated sessions into the journal mechanism. References to <code>/ctx-save</code>, <code>.context/sessions/</code>, and session auto-save in this post reflect the architecture at the time of writing.</p> <p></p>","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":"<p>Jose Alekhinne / 2026-02-08</p> <p>When You Find a Useful Prompt, What Do You Do with It?</p> <p>My instinct was to make it a skill.</p> <p>I had just spent three posts explaining how to build skills that work. Naturally, the hammer wanted nails.</p> <p>Then I looked at what I was holding and realized: this is not a nail.</p>","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":"<p>I wanted to understand how I use <code>ctx</code>: </p> <ul> <li>Where the friction is;</li> <li>What works, what drifts; </li> <li>What I keep doing manually that could be automated. </li> </ul> <p>So I wrote a prompt that spawned eight agents to analyze the codebase from different angles:</p> 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 <p>The prompt was specific: </p> <ul> <li>read-only agents, </li> <li>structured output format,</li> <li>concrete file references, </li> <li>ranked recommendations. </li> </ul> <p>It ran for about 20 minutes and produced eight Markdown reports.</p> <p>The reports were good: Not perfect, but actionable.</p> <p>What mattered was not the speed. It was that the work could be explored without committing to any single outcome.</p> <p>They surfaced a stale <code>doc.go</code> referencing a subcommand that was never built. </p> <p>They found 311 build-then-test sequences I could reduce to a single <code>make check</code>. </p> <p>They identified that 42% of my sessions start with \"do you remember?\", which is a lot of repetition for something a skill could handle.</p> <p>I had findings. I had recommendations. I had the instinct to automate.</p> <p>And then... I stopped.</p>","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":"<p>The natural next step was to wrap the audit prompt as <code>/ctx-audit</code>: a skill you invoke periodically to get a health check. It fits the pattern: </p> <ul> <li>It has a clear trigger.</li> <li>It produces structured output.</li> </ul> <p>But I had just spent a week writing about what makes skills work, and the criteria I established argued against it.</p> <p>From The Anatomy of a Skill That Works:</p> <p>\"A skill without boundaries is just a suggestion.\"</p> <p>From You Can't Import Expertise:</p> <p>\"Frameworks travel, expertise doesn't.\"</p> <p>From Skills That Fight the Platform:</p> <p>\"You are the guest, not the host.\"</p> <p>The audit prompt fails all three tests:</p> 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 <p>Skills are contracts. Contracts need stable terms. </p> <p>A prompt I will rewrite every time I use it is not a contract. It is a conversation starter.</p>","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":"<p>The distinction that emerged:</p> Skill Recipe Invocation <code>/slash-command</code> 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 <code>.claude/skills/</code> <code>hack/</code> or <code>docs/</code> Attention cost Loaded into context on match Zero until needed <p>Recipes can later graduate into skills, but only after repetition proves stability.</p> <p>That last row matters. Skills consume the attention budget every time the platform considers activating them.</p> <p>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.</p> <p>Runbooks have zero attention cost. They sit in a Markdown file until a human decides to use them. </p> <ul> <li>The human provides the judgment about timing. </li> <li>The prompt provides the structure.</li> </ul> <p>The Attention Budget Applies to Skills Too</p> <p>Every skill in <code>.claude/skills/</code> is a standing claim on the context window. The platform evaluates skill descriptions against every user prompt to decide whether to activate.</p> <p>Twenty focused skills are fine. Thirty might be fine. But each one added reduces the headroom available for actual work.</p> <p>Recipes are skills that opted out of the attention tax.</p>","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":"<p>The audit was not wasted. It was a planning exercise that generated concrete tasks:</p> Finding Action 42% of sessions start with memory check Task: <code>/ctx-remember</code> skill (this one is a skill; it is daily) Auto-save stubs are empty Task: enhance <code>/ctx-save</code> with richer summaries 311 raw build-test sequences Task: <code>make check</code> target Stale <code>recall/doc.go</code> lists nonexistent <code>serve</code> Task: fix the doc.go 120 commit sequences disconnected from context Task: <code>/ctx-commit</code> workflow <ul> <li>Some findings became skills;</li> <li>Some became <code>Makefile</code> targets;</li> <li>Some became one-line doc fixes. </li> </ul> <p>The audit did not prescribe the artifact type: The findings did.</p> <p>The audit is the input. Skills are one possible output. Not the only one.</p>","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":"<p>Here is the exact prompt I used, for those who are curious.</p> <p>This is not a template: It worked because it was written against this codebase, at this moment, with specific goals in mind:</p> <pre><code>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</code></pre> <p>Avoid Generic Advice</p> <p>Suggestions that are not grounded in a project's actual structure, history, and workflows are worse than useless:</p> <p>They create false confidence.</p> <p>If an analysis cannot point to concrete files, commits, sessions, or patterns, it should say \"no finding\" instead of inventing best practices.</p>","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":"<p>This is part of a pattern I keep rediscovering: </p> <p>The urge to automate is not the same as the need to automate:</p> <ul> <li>The 3:1 ratio taught me that not every session should be a YOLO sprint. </li> <li>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.</li> </ul> <p>The common thread is restraint: </p> <ul> <li>Knowing when to stop. </li> <li>Recognizing that the cost of automation is not just the effort to build it.</li> </ul> <p>The cost is the ongoing attention tax of maintaining it, the context it consumes, and the false confidence it creates when it drifts.</p> <p>An entry in <code>hack/runbooks/codebase-audit.md</code> is honest about what it is:</p> <p>A prompt I wrote once, improved once, and will adapt again next time: </p> <ul> <li>It does not pretend to be a reliable contract. </li> <li>It does not claim attention budget. </li> <li>It does not drift silently.</li> </ul> <p>The Automation Instinct</p> <p>When you find a useful prompt, the instinct is to institutionalize it. Resist.</p> <p>Ask first: will I use this the same way next time?</p> <p>If yes, it is a skill. If no, it is a recipe. If you are not sure, it is a recipe until proven otherwise.</p>","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 <code>ctx</code>","text":"<p><code>ctx</code> is a tool that gives AI agents persistent memory. Its purpose is automation: reducing the friction of context loading, session recall, decision tracking.</p> <p>But automation has boundaries, and knowing where those boundaries are is as important as pushing them forward. </p> <p>The skills system is for high-frequency, stable workflows. </p> <p>The recipes, the journal entries, the session dumps in <code>.context/sessions/</code>: those are for everything else.</p> <p>Not everything needs to be a slash command. Some things are better as Markdown files you read when you need them.</p> <p>The goal of <code>ctx</code> is not to automate everything: It is to automate the right things and to make the rest easy to find when you need it.</p> <p>If You Remember One Thing from This Post...</p> <p>The best automation decision is sometimes not to automate.</p> <p>A runbook in a Markdown file costs nothing until you use it.</p> <p>A skill costs attention on every prompt, whether it fires or not.</p> <p>Automate the daily. Document the periodic. Forget the rest.</p> <p>This post was written during the session that produced the codebase audit reports and distilled the prompt into <code>hack/runbooks/codebase-audit.md</code>. The audit generated seven tasks, one Makefile target, and zero new skills. The meta continues.</p> <p>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.</p>","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":"<p>Volkan Özçelik / 2026-02-09</p> <p>What Happens When Your AI Agent Runs Overnight and Nobody Is Watching?</p> <p>It follows instructions: That is the problem.</p> <p>Not because it is malicious. Because it is controllable.</p> <p>It follows instructions from context, and context can be poisoned.</p> <p>I was writing the autonomous loops recipe for <code>ctx</code>: 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:</p> <p>Use <code>CONSTITUTION.md</code> for guardrails. Tell the agent \"never delete tests\" and it usually won't.</p> <p>Then I read that sentence back and realized: that is wishful thinking.</p>","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":"<p><code>CONSTITUTION.md</code> is a Markdown file. The agent reads it at session start alongside everything else in <code>.context/</code>. 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.</p> <p>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:</p> 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 <code>CLAUDE.md</code> or <code>.cursorrules</code> 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 <p>That last vector is the one that kept me up at night (literally!):</p> <p>In an autonomous loop, the agent modifies files as part of its job. </p> <p>If it modifies its own configuration files, the next iteration loads the modified config. </p> <ul> <li>No human reviews it. </li> <li>No diff is shown. </li> <li>The agent that starts iteration <code>N+1</code> is running with rules written by iteration <code>N</code>.</li> </ul> <p>The agent can rewrite its own guardrails.</p>","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":"<p>That's five nested layers of swiss cheese. Alone, each of them has large holes. Together, they create a boundary.</p> <p>What followed was a week of peeling back assumptions:</p> <p>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.</p>","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":"<p><code>CONSTITUTION.md</code>, the Agent Playbook, system prompts: These tell the agent what to do. </p> <p>The agent usually follows them.</p> <p>\"Usually\" is the keyword here.</p> <p>The hole: Prompt injection:</p> <ul> <li>A sufficiently crafted payload overrides soft instructions. </li> <li>Long context windows dilute attention on rules stated early. </li> <li>Edge cases where instructions are ambiguous get resolved in unpredictable ways.</li> </ul> <p>Verdict: Necessary. Not sufficient. Good for the common case. Never trust it as a security boundary.</p>","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":"<p>Permission allowlists in <code>.claude/settings.local.json</code>:</p> <pre><code>{\n \"permissions\": {\n \"allow\": [\n \"Bash(make:*)\",\n \"Bash(go:*)\",\n \"Bash(git:*)\",\n \"Read\",\n \"Write\",\n \"Edit\"\n ]\n }\n}\n</code></pre> <p>If <code>rm</code>, <code>curl</code>, <code>sudo</code>, or <code>docker</code> are not in the allowlist, the agent cannot invoke them. This is deterministic. </p> <p>The application enforces it regardless of what any prompt says.</p> <p>The hole: The agent can modify the allowlist itself: </p> <ul> <li>It has <code>Write</code> permission. </li> <li>The allowlist lives in a file. </li> <li>The agent writes to the file. </li> <li>The next iteration loads the modified allowlist.</li> </ul> <p>The application enforces the rules, but the application reads the rules from files the agent can write.</p> <p>Verdict: Strong first layer. Must be combined with self-modification prevention.</p>","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":"<p>This is where the defenses stop having holes in the same shape.</p> <p>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 <code>CAP_NET_RAW</code> cannot open raw sockets. These are kernel boundaries.</p> Control What it stops Dedicated unprivileged user Privilege escalation, <code>sudo</code>, group-based access Filesystem permissions Lateral movement to other projects, system config Immutable config files Self-modification of guardrails between iterations <p>Make the agent's instruction files read-only: <code>CLAUDE.md</code>, <code>.claude/settings.local.json</code>, <code>.context/CONSTITUTION.md</code>. Own them as a different user, or mark them immutable with <code>chattr +i</code> on Linux.</p> <p>The hole: Actions within the agent's legitimate scope: </p> <ul> <li>If the agent has write access to source code (which it needs), it can introduce vulnerabilities in the code itself. </li> <li>You cannot prevent this without removing the agent's ability to do its job.</li> </ul> <p>Verdict: Essential. This is the layer that makes Layers 1 and 2 trustworthy.</p> <p>OS-level isolation does not make the agent safe; it makes the other layers meaningful.</p>","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":"<p>An agent that cannot reach the internet cannot exfiltrate data.</p> <p>It also cannot ingest new instructions mid-loop from external documents, error pages, or hostile content.</p> <pre><code># 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</code></pre> <ul> <li>If the agent genuinely does not need the network, disable it entirely. </li> <li>If it needs to fetch dependencies, allow specific registries and block everything else.</li> </ul> <p>The hole: None, if the agent does not need the network. </p> <p>Thetradeoff is that many real workloads need dependency resolution, so a full airgap requires pre-populated caches.</p>","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":"<p>The strongest boundary is a separate machine.</p> <p>The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.</p> <pre><code>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</code></pre> <p>Never Mount the Docker Socket</p> <p>Do not mount <code>/var/run/docker.sock</code>, like, ever. </p> <p>An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox. </p> <p>This is not theoretical: the Docker socket grants root-equivalent access to the host.</p> <p>Use rootless Docker or Podman to eliminate this escalation path entirely.</p> <p>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.</p>","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":"<p>Each layer is straightforward: The strength is in the combination:</p> Layer Implementation What it stops Soft instructions <code>CONSTITUTION.md</code> Common mistakes (probabilistic) Application allowlist <code>.claude/settings.local.json</code> Unauthorized commands (deterministic within runtime) Immutable config <code>chattr +i</code> on config files Self-modification between iterations Unprivileged user Dedicated user, no sudo Privilege escalation Container <code>--cap-drop=ALL --network=none</code> Host escape, data exfiltration Resource limits <code>--memory=4g --cpus=2</code> Resource exhaustion <p>No layer is redundant. Each one catches what the others miss:</p> <ul> <li>The soft instructions handle the 99% case: \"don't delete tests.\"</li> <li>The allowlist prevents the agent from running commands it should not.</li> <li>The immutable config prevents the agent from modifying the allowlist.</li> <li>The unprivileged user prevents the agent from removing the immutable flag.</li> <li>The container prevents the agent from reaching anything outside its workspace.</li> <li>The resource limits prevent the agent from consuming all system resources.</li> </ul> <p>Remove any one layer and there is an attack path through the remaining ones.</p>","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":"<p>These are real patterns, not hypotheticals:</p> <p>\"I'll just use <code>--dangerously-skip-permissions</code>.\" 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\").</p> <p>\"The agent is sandboxed in Docker.\" A Docker container with the Docker socket mounted, running as root, with <code>--privileged</code>, and full network access is not sandboxed. It is a root shell with extra steps.</p> <p>\"I reviewed <code>CLAUDE.md</code>, 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.</p> <p>\"The agent only has access to this one project.\" Does the project directory contain <code>.env</code> files? SSH keys? API tokens? A <code>.git/config</code> with push access to a remote? Filesystem isolation means isolating what is in the directory too.</p>","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":"<p>This is the same lesson I keep rediscovering, wearing different clothes.</p> <p>In The Attention Budget, I wrote about how every token competes for the AI's focus. Security instructions in <code>CONSTITUTION.md</code> 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.</p> <p>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.</p> <p>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.</p> <p>The pattern across all of these: Soft instructions are useful for the common case. Hard boundaries are required for security.</p> <p>Know which is which.</p>","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":"<p>Before running an unattended AI agent:</p> <ul> <li> Agent runs as a dedicated unprivileged user (no sudo, no docker group)</li> <li> Agent's config files are immutable or owned by a different user</li> <li> Permission allowlist restricts tools to the project's toolchain</li> <li> Container drops all capabilities (<code>--cap-drop=ALL</code>)</li> <li> Docker socket is NOT mounted</li> <li> Network is disabled or restricted to specific domains</li> <li> Resource limits are set (memory, CPU, disk)</li> <li> No SSH keys, API tokens, or credentials are accessible</li> <li> Project directory does not contain <code>.env</code> or secrets files</li> <li> Iteration cap is set (<code>--max-iterations</code>)</li> </ul> <p>This checklist lives in the Agent Security reference alongside the full threat model and detailed guidance for each layer.</p>","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 <code>ctx</code>","text":"<p>The autonomous loops recipe now has a full permissions and isolation section instead of a one-line tip about <code>CONSTITUTION.md</code>. It covers both the explicit allowlist approach and the <code>--dangerously-skip-permissions</code> flag, with honest guidance about when each is appropriate.</p> <p>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.</p> <p>The Agent Security page consolidates the threat model and defense layers into a standalone reference.</p> <p>These are not theoretical improvements. They are the minimum responsible guidance for a tool that helps people run AI agents overnight.</p> <p>If You Remember One Thing from This Post...</p> <p>Markdown is not a security boundary.</p> <p><code>CONSTITUTION.md</code> is a nudge. An allowlist is a gate.</p> <p>An unprivileged user in a network-isolated container is a wall.</p> <p>Use all three. Trust only the wall.</p> <p>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.</p>","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":"<p>Volkan Özçelik / 2026-02-12</p> <p>Have You Ever Felt like You Should Understand More of the Stack beneath You?</p> <p>You can talk about transformers at a whiteboard.</p> <p>You can explain attention to a colleague.</p> <p>You can use agentic AI to ship real software.</p> <p>But somewhere in the back of your mind, there is a voice:</p> <p>\"Maybe I should go deeper. Maybe I need to master machine learning.\"</p> <p>I had that voice for months. </p> <p>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.</p> <p>This post is about when depth compounds and (more importantly) when it does not.</p>","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":"<p>There is an implicit stack most people carry around when thinking about AI:</p> 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 <p>At some point down that stack, you hit a comfortable plateau: the layer where you can hold a conversation but not debug a failure.</p> <p>The instinctive response is to go deeper.</p> <p>But that instinct hides a more important question:</p> <p>\"Does depth still compound when the abstractions above you are moving hyper-exponentially?\"</p>","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":"<p>If you squint hard enough, a large chunk of modern ML intuition collapses into older fields:</p> 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 <p>Nothing here is uniquely \"AI\".</p> <p>Most of this math predates the term deep learning. In some cases, by decades.</p> <p>So what changed?</p>","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":"<p>The mistake is assuming this is a new theory problem: It is not.</p> <p>It is a new operating regime.</p> <p>Classical numerical methods were developed under assumptions like:</p> <ul> <li>Manageable dimensionality</li> <li>Reasonably well-conditioned objectives</li> <li>Losses that actually represent the goal</li> </ul> <p>Modern ML violates all three: On purpose.</p> <p>Today's models operate with millions to trillions of parameters, wildly underdetermined systems, and objective functions we know are wrong but optimize anyway.</p> <p>It is complete and utter madness! </p> <p>At this scale, familiar concepts warp:</p> <ul> <li>What we call \"local minima\" are overwhelmingly saddle points in high-dimensional spaces.</li> <li>Noise stops being noise and starts becoming structure.</li> <li>Overfitting can coexist with generalization.</li> <li>Bigger models outperform \"better\" ones.</li> </ul> <p>The math did not change: The phase did.</p> <p>This is less numerical analysis and more *statistical physics: Same equations, but behavior dominated by phase transitions and emergent structure.</p>","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":"<p>In classical statistics, asymptotics describe what happens eventually.</p> <p>In modern ML, scaling laws describe where you can operate today.</p> <p>They do not say \"given enough time, things converge\".</p> <p>They say \"cross this threshold and behavior qualitatively changes\".</p> <p>This is why dumb architectures plus scale beat clever ones.</p> <p>Why small theoretical gains disappear under data.</p> <p>Why \"just make it bigger\", ironically, keeps working longer than it should.</p> <p>That is not a triumph of ML theory: It is a property of high-dimensional systems under loose objectives.</p>","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":"<p>This reframes the original question.</p> <p>You do not need depth because this is \"AI\".</p> <p>You need depth where failure modes propagate upward.</p> <p>I learned this building <code>ctx</code>: The agent failures I have spent the most time debugging were never about the model's architecture.</p> <p>They were about:</p> <ul> <li> <p>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.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ul> <p>This is the kind of depth that compounds. Not deriving backprop. But, understanding when correct math produces misleading intuition.</p>","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":"<p>This is the same pattern I keep finding at different altitudes.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>In every case, the answer was not \"go deeper into ML\".</p> <p>The answer was knowing which abstraction was leaking and fixing it at the right layer.</p>","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":"<p>The mistake is assuming agent failures originate where the model was trained, rather than where it is deployed.</p> <p>Agentic AI is a systems problem under chaotic uncertainty:</p> <ul> <li>Feedback loops between the agent and its environment;</li> <li>Error accumulation across iterations;</li> <li>Brittle representations that break outside training distribution;</li> <li>Misplaced trust in outputs that look correct.</li> </ul> <p>In short-lived interactions, model quirks are tolerable. In long-running autonomous loops, however, they compound. </p> <p>That is where shallow understanding becomes expensive.</p> <p>But the understanding you need is not about optimizer internals.</p> <p>It is about:</p> 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 <p>The depth that matters is diagnostic, not theoretical.</p>","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":"<p>Not turtles all the way down.</p> <p>Go deep enough to:</p> <ul> <li>Diagnose failures instead of cargo-culting fixes;</li> <li>Reason about uncertainty instead of trusting confidence;</li> <li>Design guardrails that align with model behavior, not hope.</li> </ul> <p>Stop before:</p> <ul> <li>Hand-deriving gradients for the sake of it;</li> <li>Obsessing over optimizer internals you will never touch;</li> <li>Chasing theoretical purity divorced from the scale you actually operate at.</li> </ul> <p>This is not about mastering ML.</p> <p>It is about knowing which abstractions you can safely trust and which ones leak.</p> <p>Hint: Any useful abstraction almost certainly leaks.</p>","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":"<p>If a failure occurs and your instinct is to:</p> <ul> <li>Add more prompt text: abstraction leak above</li> <li>Add retries or heuristics: error accumulation</li> <li>Change the model: scale masking</li> <li>Reach for ML theory: you are probably (but not always) going too deep</li> </ul> <p>The right depth is the shallowest layer where the failure becomes predictable.</p>","path":["How Deep Is Too Deep?"],"tags":[]},{"location":"blog/2026-02-12-how-deep-is-too-deep/#the-ctx-lesson","level":2,"title":"The <code>ctx</code> Lesson","text":"<p>Every design decision in <code>ctx</code> is downstream of this principle.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>The boundary between useful understanding and academic exercise is where your failure modes live.</p>","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":"<p>Most modern AI systems do not fail because the math is wrong.</p> <p>They fail because we apply correct math in the wrong regime, then build autonomous systems on top of it.</p> <p>Understanding that boundary, not crossing it blindly, is where depth still compounds.</p> <p>And that is a far more useful form of expertise than memorizing another loss function.</p> <p>If You Remember One Thing from This Post...</p> <p>Go deep enough to diagnose your failures. Stop before you are solving problems that do not propagate to your layer.</p> <p>The abstractions below you are not sacred. But neither are they irrelevant.</p> <p>The useful depth is wherever your failure modes live. Usually one or two layers down, not at the bottom.</p> <p>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.</p>","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":"<p>IRC is stateless.</p> <ul> <li>You disconnect, you vanish.</li> <li>You reconnect, you begin again.</li> </ul> <p>No buffer.</p> <p>No memory.</p> <p>No continuity.</p> <p>Modern systems are not much different:</p> <ul> <li>Close the browser tab.<ul> <li>Lose the Slack scrollback.</li> </ul> </li> <li>Open a new LLM session.<ul> <li>Start from zero.</li> </ul> </li> </ul> <p>Resets externalize reconstruction cost onto humans.</p> <p>Reconstruction is tax: Tax becomes entropy.</p>","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":"<p>IRC is minimal:</p> <ul> <li>A TCP connection.</li> <li>A nickname.</li> <li>A channel.</li> <li>A stream of lines.</li> </ul> <p>When the connection drops, you literally disappear from the graph.</p> <p>The protocol is stateless; human systems are not.</p> <p>So you:</p> <ul> <li>Reconnect;</li> <li>Ask what you missed;</li> <li>Scroll;</li> <li>Reconstruct.</li> </ul> <p>The machine forgets; you pay.</p>","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":"<p>A <code>bouncer</code> is a daemon that remains connected when you do not:</p> <ul> <li>It holds your seat;</li> <li>It buffers what you missed;</li> <li>It keeps your identity online.</li> </ul> <p>ZNC is one such bouncer.</p> <p>With ZNC:</p> <ul> <li>Your client does not connect to IRC;</li> <li>It connects to <code>ZNC</code>;</li> <li><code>ZNC</code> connects upstream.</li> </ul> <p>Client sessions become ephemeral.</p> <p>Presence becomes infrastructural.</p> <p>ZNC Is Tmux for IRC</p> <ul> <li> <p>Close your laptop.</p> <ul> <li>ZNC remains.</li> </ul> </li> <li> <p>Switch devices.</p> <ul> <li>ZNC persists.</li> </ul> </li> </ul> <p>This is not convenience; this is continuity.</p>","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":"<p>With a bouncer:</p> <ul> <li>Closing your client does not emit <code>PART</code>.</li> <li>Reopening does not emit <code>JOIN</code>.</li> </ul> <p>You do not flap in and out of existence.</p> <p>From the channel's perspective, you remain.</p> <p>From your perspective, history accumulates.</p> <ul> <li>Buffers persist;</li> <li>Identity persists;</li> <li>Context persists.</li> </ul> <p>This pattern predates AI.</p>","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":"<p>An LLM session without memory is IRC without a bouncer:</p> <ul> <li>Close the window.</li> <li>Start over.</li> <li>Re-explain intent.</li> <li>Rehydrate context.</li> </ul> <p>That is friction.</p> <p>This Walks and Talks like <code>ctx</code></p> <p>Context engineering moves memory out of sessions and into infrastructure.</p> <ul> <li><code>ZNC</code> does this for IRC.</li> <li><code>ctx</code> does this for agents.</li> </ul> <p>Same principle:</p> <ul> <li>Volatile interface.</li> <li>Persistent substrate.</li> </ul> <p>Different fabric.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#minimal-architecture","level":2,"title":"Minimal Architecture","text":"<p>My setup is intentionally boring:</p> <ul> <li>A $5 small VPS.</li> <li>ZNC installed.</li> <li>TLS enabled.</li> <li>Firewall restricted.</li> </ul> <p>Then:</p> <ul> <li>ZNC connects to <code>Libera.Chat</code>.</li> <li><code>SASL</code> authentication lives inside ZNC.</li> <li>Buffers are stored on disk.</li> </ul> <p>My client connects to my VPS, not the network.</p> <p>The commands do not matter: The boundaries do:</p> <ul> <li>Authentication in infrastructure, not in the client;</li> <li>Memory server-side, not in scrollback;</li> <li>Presence decoupled from activity.</li> </ul> <p>Everything else is configuration.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#platform-memory","level":2,"title":"Platform Memory","text":"<p>Yes, I know, it is 2026:</p> <ul> <li>Discord stores history;</li> <li>Slack stores history;</li> <li>The dumpster fire on gasoline called X, too, stores history.</li> </ul> <p>HOWEVER, they own your substrate.</p> <p>Running a bouncer is quiet sovereignty:</p> <ul> <li>Logs are mine.</li> <li>Presence is continuous.</li> <li>State does not reset because I closed a tab.</li> </ul> <p>Small acts compound.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#signal-density","level":2,"title":"Signal Density","text":"<p>Primitive systems select for builders.</p> <p>Consistent presence in small rooms compounds reputation.</p> <p>Quiet compounding outperforms viral spikes.</p>","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":"<p>ZNC is not interesting because it is retro; it is interesting because it models a principle:</p> <ul> <li>Stateless protocols require stateful wrappers;</li> <li>Volatile interfaces require durable memory;</li> <li>Human systems require continuity.</li> </ul> <p>Distilled:</p> <p>Humans require context.</p> <p>Before context windows, we had bouncers. </p> <p>Before AI memory files, we had buffers.</p> <p>Continuity is not a feature; it is a design decision.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#build-it","level":2,"title":"Build It","text":"<p>If you want the actual setup (VPS, ZNC, TLS, SASL, firewall...) there is a step-by-step runbook:</p> <p>Persistent IRC Presence with ZNC.</p>","path":["Before Context Windows, We Had Bouncers"],"tags":[]},{"location":"blog/2026-02-14-irc-as-context/#motd","level":2,"title":"MOTD","text":"<p>When my client connects to my bouncer, it prints:</p> <pre><code>// / ctx: https://ctx.ist\n// ,'`./ do you remember?\n// `.,'\\\n// \\ Copyright 2026-present Context contributors.\n// SPDX-License-Identifier: Apache-2.0\n</code></pre> <p>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.</p>","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":"<p>Jose Alekhinne / 2026-02-14</p> <p>What Do You Do with 30 Open Tasks?</p> <p>You could work through them one at a time.</p> <p>One agent, one branch, one commit stream.</p> <p>Or you could ask: which of these don't touch each other?</p> <p>I had 30 open tasks in <code>TASKS.md</code>. Some were docs. Some were a new encryption package. Some were test coverage for a stable module. Some were blog posts.</p> <p>They had almost zero file overlap.</p> <p>Running one agent at a time meant serial execution on work that was fundamentally parallel:</p> <p>I was bottlenecking on me, not on the machine.</p>","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":"<p>This is not a scheduling problem: It's a conflict avoidance problem.</p> <p>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.</p> <p>So the question becomes: </p> <p>\"Can you partition your backlog into non-overlapping tracks?\"</p> <p>For <code>ctx</code>, the answer was obvious:</p> Track Touches Tasks <code>work/docs</code> <code>docs/</code>, <code>hack/</code> Blog posts, recipes, runbooks <code>work/pad</code> <code>internal/cli/pad/</code>, specs Scratchpad encryption, CLI, tests <code>work/tests</code> <code>internal/cli/recall/</code> Recall test coverage <p>Three tracks. Near-zero overlap. Three agents.</p>","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":"<p><code>git</code> has a feature that most people don't use: worktrees.</p> <p>A worktree is a second (or third, or fourth) working directory that shares the same <code>.git</code> object database as your main checkout. </p> <p>Each worktree has its own branch, its own index, its own working tree. But they all share history, refs, and objects.</p> <pre><code>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</code></pre> <ul> <li>Three directories;</li> <li>Three branches;</li> <li>One repository.</li> </ul> <p>This is cheaper than three clones. And because they share objects, <code>git merge</code> afterwards is fast: It's a local operation on shared data.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-setup","level":2,"title":"The Setup","text":"<p>The workflow I landed on:</p> <p>1. Group tasks by blast radius.</p> <p>Read <code>TASKS.md</code>. 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.</p> <p>This is the part that requires human judgment: </p> <p>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.</p> <p>2. Create worktrees as sibling directories.</p> <p>Not subdirectories: Siblings. </p> <p>If your main checkout is at <code>~/WORKSPACE/ctx</code>, worktrees go at <code>~/WORKSPACE/ctx-docs</code>, <code>~/WORKSPACE/ctx-pad</code>, etc.</p> <p>Why siblings? Because some tools (and some agents) walk up the directory tree looking for <code>.git</code>. A worktree inside the main checkout confuses them.</p> <p>3. Launch one agent per worktree.</p> <pre><code># Terminal 1\ncd ../ctx-docs && claude\n\n# Terminal 2\ncd ../ctx-pad && claude\n\n# Terminal 3\ncd ../ctx-tests && claude\n</code></pre> <p>Each agent gets a full working copy with <code>.context/</code> intact. It reads the same <code>TASKS.md</code>, the same <code>DECISIONS.md</code>, the same <code>CONVENTIONS.md</code>. It knows the full project state. It just works on a different slice.</p> <p>4. Do NOT run <code>ctx init</code> in worktrees.</p> <p>This is the gotcha. The <code>.context/</code> directory is tracked in git. Running <code>ctx init</code> in a worktree would overwrite shared context files: Wiping decisions, learnings, and tasks that belong to the whole project.</p> <p>The worktree already has everything it needs. Leave it alone.</p>","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":"<p>I ran three agents for about 40 minutes. Here is roughly what each track produced:</p> <p><code>work/docs</code>: Parallel worktrees recipe, blog post edits, recipe index reorganization, IRC recipe moved from <code>docs/</code> to <code>hack/</code>.</p> <p><code>work/pad</code>: <code>ctx pad show</code> subcommand, <code>--append</code> and <code>--prepend</code> flags on <code>ctx pad edit</code>, spec updates, 28 new test functions.</p> <p><code>work/tests</code>: Recall test coverage, edge case tests.</p> <p>Merging took about five minutes. Two of the three merges were clean.</p> <p>The third had a conflict in <code>TASKS.md</code>: </p> <p>both the docs track and the pad track had marked different tasks as <code>[x]</code>.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-tasksmd-conflict","level":2,"title":"The <code>TASKS.md</code> Conflict","text":"<p>This deserves its own section because it will happen every time.</p> <p>When two agents work in parallel, they both read <code>TASKS.md</code> at the start and mark tasks complete as they go. When you merge, git sees two branches that modified the same file differently.</p> <p>The resolution is always the same: accept all completions from both sides. No task should go from <code>[x]</code> back to <code>[ ]</code>. The merge is additive.</p> <p>This is one of those conflicts that sounds scary but is trivially mechanical: You are not arbitrating design decisions; you are combining two checklists.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#limits","level":2,"title":"Limits","text":"<p>3-4 worktrees, maximum. </p> <p>I tried four once: By the time I merged the third track, the fourth had drifted far enough that its changes needed rebasing. </p> <p>The merge complexity grows faster than the parallelism benefit.</p> <p>Three is the sweet spot:</p> <ul> <li>Two is conservative but safe;</li> <li>Four is possible if the tracks are truly independent;</li> <li>Anything more than four, you are in the danger zone.</li> </ul> <p>Group by directory, not by priority.</p> <p>It is tempting to put all the high-priority tasks in one track: Don't. </p> <p>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.</p> <p>Commit frequently. </p> <p>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.</p> <p>Name tracks by concern. </p> <ul> <li><code>work/docs</code> and <code>work/pad</code> tell you what's happening;</li> <li><code>work/track-1</code> and <code>work/track-2</code> tell you nothing.</li> </ul>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-pattern","level":2,"title":"The Pattern","text":"<p>This is the same pattern that shows up everywhere in <code>ctx</code>:</p> <p>The attention budget taught me that you can't dump everything into one context window. You have to partition, prioritize, and load selectively.</p> <p>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.</p> <p>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.</p> <p>And the IRC bouncer post from earlier today argued that stateless protocols need stateful wrappers. Worktrees are the same: git branches are stateless forks; <code>.context/</code> is the stateful wrapper that gives each agent the project's full memory.</p>","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":"<p>I asked myself the same question I asked about the codebase audit: should this be a <code>/ctx-worktree</code> skill?</p> <p>This time the answer was a resounding \"yes\": </p> <p>Unlike the audit prompt (which I tweak every time and run every other week) the worktree workflow is:</p> 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\" <p>The commands are mechanical: <code>git worktree add</code>, <code>git worktree remove</code>, branch naming, safety checks. This is exactly what skills are for: stable contracts for repetitive operations.</p> <p>Ergo, <code>/ctx-worktree</code> exists. </p> <p>It enforces the 4-worktree limit, creates sibling directories, uses <code>work/</code> branch prefixes, and reminds you not to run <code>ctx init</code> in worktrees.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-14-parallel-agents-with-worktrees/#the-takeaway","level":2,"title":"The Takeaway","text":"<p>Serial execution is the default. But serial is not always necessary.</p> <p>If your backlog partitions cleanly by file overlap, you can multiply your throughput with nothing more exotic than <code>git worktree</code> and a second terminal window.</p> <p>The hard part is not the <code>git</code> commands; it is the discipline:</p> <ul> <li>Grouping by blast radius instead of priority; </li> <li>Accepting that <code>TASKS.md</code> will conflict; </li> <li>And knowing when three tracks is enough.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>Partition by blast radius, not by priority.</p> <p>Two tasks that touch the same files belong in the same track, no matter how important the other one is.</p> <p>The constraint is file overlap. Everything else is scheduling.</p> <p>The practical setup (skill invocation, worktree creation, merge workflow, and cleanup) lives in the recipe: Parallel Agent Development with Git Worktrees.</p>","path":["Parallel Agents with Git Worktrees"],"tags":[]},{"location":"blog/2026-02-15-ctx-v0.3.0-the-discipline-release/","level":1,"title":"<code>ctx</code> 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":"<p>Jose Alekhinne / February 15, 2026</p> <p>What Does a Release Look like When Most of the Work Is Invisible?</p> <p>No new headline feature. No architectural pivot. No rewrite.</p> <p>Just 35+ documentation and quality commits against ~15 feature commits... and somehow, the tool feels like it grew up overnight.</p> <p>Six days separate <code>v0.2.0</code> from <code>v0.3.0</code>. </p> <p>Measured by calendar time, it is nothing. Measured by what changed in how the project operates, it is the most significant release yet.</p> <ul> <li><code>v0.1.0</code> was the prototype;</li> <li><code>v0.2.0</code> was the archaeology release: making the past accessible; </li> <li><code>v0.3.0</code> 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.</li> </ul> <p>The Release Window</p> <p>February 1‒February 7, 2026</p> <p>From the <code>v0.2.0</code> tag to commit <code>2227f99</code>.</p> <p>78 files changed in the migration commit alone.</p>","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":"<p>The largest single change was the migration from <code>.claude/commands/*.md</code> to <code>.claude/skills/*/SKILL.md</code>.</p> <p>This was not a rename: It was a rethinking of how AI agents discover and execute project-specific workflows.</p> 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 <p>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.</p> <p>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.</p> <p>78 files changed. 1,915 insertions. Not because the skills got bloated; because they got specific.</p>","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":"<p>After the structural migration, every skill was rewritten in a single session: All 21 of them.</p> <p>The rewrite was guided by a pattern that emerged during the process itself: a repeatable anatomy that effective skills share regardless of their purpose:</p> <ol> <li>Before X-ing: Pre-flight checks that prevent premature execution</li> <li>When to Use: Positive triggers that narrow activation</li> <li>When NOT to Use: Negative triggers that prevent misuse</li> <li>Usage Examples: Invocation patterns the agent can pattern-match</li> <li>Quality Checklist: Verification before claiming completion</li> </ol> <p>The Anatomy of a Skill That Works post covers the details. What matters for the release story is the result: </p> <ul> <li>Zero skills with quality gates became twenty; </li> <li>Zero skills with negative triggers became twenty. </li> <li>Three skills with examples became twenty.</li> </ul> <p>The Skill Trilogy as Design Spec</p> <p>The three blog posts written during this window:</p> <ul> <li>Skills That Fight the Platform, </li> <li>You Can't Import Expertise,</li> <li>and The Anatomy of a Skill That Works...</li> </ul> <p>... were not retrospective documentation. They were written during the rewrite, and the lessons fed back into the skills as they were being built.</p> <ul> <li>The blog was the design document. </li> <li>The skills were the implementation.</li> </ul>","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":"<p>The unglamorous work. The kind you only appreciate when you try to change something later and it just works.</p> 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 <p>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.</p> <p>The consolidation was not an afterthought. It was scheduled deliberately, with the same priority as features: The 3:1 ratio that emerged during <code>v0.2.0</code> development became an explicit practice: </p> <ul> <li>Three feature sessions; </li> <li>One consolidation session.</li> </ul>","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":"<p>On February 4<sup>th</sup>, we adopted the E/A/R classification as the official standard for evaluating skills:</p> Category Meaning Target Expert Knowledge Claude does not have >70% Activation When/how to trigger ~20% Redundant What Claude already knows <10% <p>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.</p> <p>The E/A/R framework gave us a concrete, testable criterion: </p> <p>A good skill is Expert knowledge minus what Claude already knows.</p> <p>If more than 10% of a skill restates platform defaults, it is creating noise, not signal.</p> <p>Every skill in <code>v0.3.0</code> was evaluated against this framework. Several were deleted. The survivors are leaner and more focused.</p>","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":"<p>A tool that manages your project's memory needs ops maturity. </p> <p><code>v0.3.0</code> added two pieces of infrastructure that reflect this:</p> <p>Backup staleness hook: A <code>UserPromptSubmit</code> hook that checks whether the last <code>.context/</code> 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.</p> <p>Context size checkpoint: A <code>PreToolUse</code> 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.</p> <p>Both hooks use <code>$CLAUDE_PROJECT_DIR</code> instead of hardcoded paths, a migration triggered by a username rename that broke every absolute path in the hook configuration. That migration (replacing <code>/home/user/...</code> with <code>\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/...</code>) was one of those changes that seems trivial but prevents an entire category of future failures.</p>","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 <code>$CLAUDE_PROJECT_DIR</code> 0 All Documentation commits n/a 35+ Feature/fix commits n/a ~15 <p>That ratio (35+ documentation and quality commits to ~15 feature commits) is the defining characteristic of this release:</p> <ul> <li>This release is not a failure to ship features. </li> <li>It is the deliberate choice to make the existing features reliable.</li> </ul>","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":"<p><code>v0.1.0</code> asked: \"Can we give AI persistent memory?\"</p> <p><code>v0.2.0</code> asked: \"Can we make that memory accessible to humans too?\"</p> <p><code>v0.3.0</code> asks a different question: \"Can we make the quality self-enforcing?\"</p> <p>The answer is not a feature: It is a practice:</p> <ul> <li>Skills with quality gates enforce pre-flight checks.</li> <li>Negative triggers prevent misuse without human intervention.</li> <li>The E/A/R framework ensures skills contain signal, not noise.</li> <li>Consolidation sessions are scheduled, not improvised.</li> <li>Hook infrastructure makes degradation visible.</li> </ul> <p>Discipline is not the absence of velocity. It is the infrastructure that makes velocity sustainable.</p>","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":"<p>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.</p> <p>The next chapter is about what you build on top of discipline:</p> <ul> <li>Multi-agent coordination;</li> <li>Deeper integration patterns; </li> <li>And the question of whether context management is a tool concern or an infrastructure concern.</li> </ul> <p>But those are future posts.</p> <p>This one is about the release that proved polish is not the opposite of progress. It is what turns a prototype into a product.</p> <p>The Discipline Release</p> <p><code>v0.1.0</code> shipped features. </p> <p><code>v0.2.0</code> shipped archaeology.</p> <p><code>v0.3.0</code> shipped the habits that make everything else trustworthy.</p> <p>The most important code in this release is the code that prevents bad code from shipping.</p> <p>This post was drafted using <code>/ctx-blog</code> 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.</p>","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":"<p>Jose Alekhinne / 2026-02-15</p> <p>I had a backup warning that nobody ever saw.</p> <p>The hook was correct: It detected stale backups, formatted a nice message, and output it as <code>{\"systemMessage\": \"...\"}</code>. The problem wasn't detection. The problem was delivery. The agent absorbed the information, processed it internally, and never told the user.</p> <p>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 (<code>UserPromptSubmit</code>), same project, completely different outcomes.</p> <p>The difference was one line:</p> <pre><code>IMPORTANT: Relay this journal reminder to the user VERBATIM\nbefore answering their question.\n</code></pre> <p>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.</p>","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":"<p>I looked at every hook in <code>ctx</code>: 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.</p> <p>The patterns form a spectrum based on a single question: </p> <p>\"Who decides what the user sees?\"</p> <p>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.</p> <p>Here's the full spectrum:</p>","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":"<pre><code>{\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}\n</code></pre> <p>The nuclear option: The agent's tool call is rejected before it executes.</p> <p>This is Claude Code's first-class <code>PreToolUse</code> mechanism: The hook returns JSON with <code>decision: block</code> and the agent gets an error with the reason.</p> <p>Use this for invariants: Constitution rules, security boundaries, things that must never happen. I use it to enforce <code>PATH</code>-based <code>ctx</code> invocation, block <code>sudo</code>, and require explicit approval for <code>git push</code>.</p>","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":"<pre><code>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</code></pre> <p>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.\"</p> <p>I use this for actionable reminders: </p> <ul> <li>Unexported journal entries;</li> <li>Stale backups;</li> <li>Context capacity warnings... </li> </ul> <p>...things the user should see regardless of what they asked.</p>","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":"<pre><code>┌─ Persistence Checkpoint (prompt #25) ───────────\n│ No context files updated in 15+ prompts.\n│ Have you discovered learnings worth persisting?\n└──────────────────────────────────────────────────\n</code></pre> <p>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.</p>","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":"<pre><code>ctx agent --budget 4000 2>/dev/null || true\n</code></pre> <p>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.</p>","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":"<pre><code>find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n</code></pre> <p>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.</p>","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":"<p>Three more patterns emerged from the gaps in the existing hooks.</p> <p>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.</p> <p>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.</p> <p>Escalating severity: <code>INFO</code> gets absorbed silently. <code>WARN</code> gets mentioned at the next natural pause. <code>CRITICAL</code> 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.</p>","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":"<p>Hooks are the boundary between your environment and the agent's reasoning. </p> <p>A hook that detects a problem but can't communicate it effectively is the same as no hook at all.</p> <p>The format of your output is a design decision with real consequences:</p> <ul> <li>Use a hard gate and the agent can't proceed (good for invariants, frustrating for false positives)</li> <li>Use VERBATIM relay and the user will see it (good for reminders, noisy if overused)</li> <li>Use an agent directive and the agent might act (good for nudges, unreliable for critical warnings)</li> <li>Use silent injection and nobody knows (good for enrichment, invisible when it breaks)</li> </ul> <p>Choose deliberately. And, when in doubt, write the word <code>VERBATIM</code>.</p> <p>The full pattern catalog with decision flowchart and implementation examples is in the Hook Output Patterns recipe.</p>","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 <code>ctx</code>'s Journal Site Runs on a v0.0.21 Tool","text":"<p>Jose Alekhinne / 2026-02-15</p> <p>Would You Ship Production Infrastructure on a v0.0.21 Dependency?</p> <p>Most engineers wouldn't. Version numbers signal maturity. Pre-1.0 means unstable API, missing features, risk.</p> <p>But version numbers tell you where a project has been. They say nothing about where it's going.</p> <p>I just bet <code>ctx</code>'s entire journal site on a tool that hasn't hit <code>v0.1.0</code>. </p> <p>Here's why I'd do it again.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-problem","level":2,"title":"The Problem","text":"<p>When v0.2.0 shipped the journal system, the pipeline was clear:</p> <ul> <li>Export sessions to Markdown; </li> <li>Enrich them with YAML frontmatter; </li> <li>And render them into something browsable. </li> </ul> <p>The first two steps were solved; the third needed a tool.</p> <p>The journal entries are standard Markdown with YAML frontmatter, tables, and fenced code blocks. That is the entire format: </p> <ul> <li>No JSX;</li> <li>No shortcodes;</li> <li>No custom templating. </li> </ul> <p>Just Markdown rendered well.</p> <p>The requirements are modest:</p> <ul> <li>Read a configuration file (such as <code>mkdocs.yml</code>);</li> <li>Render Markdown with extensions (admonitions, tabs, tables);</li> <li>Search;</li> <li>Handle 100+ files without choking on incremental rebuilds;</li> <li>Look good out of the box;</li> <li>Not lock me in.</li> </ul> <p>The obvious candidates were as follows:</p> 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 <p>The instinct was Hugo. Same language as <code>ctx</code>. Fast. Well-established.</p> <p>But instinct is not analysis. I picked the one with the lowest version number.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation","level":2,"title":"The Evaluation","text":"<p>Here is what I actually evaluated, in order:</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#1-the-team","level":3,"title":"1. The Team","text":"<p>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.</p> <ul> <li>This is not someone learning how to build static site generators.</li> <li>This is someone who spent years understanding exactly where MkDocs breaks and decided to fix it from the ground up.</li> </ul> <p>They did not build zensical because MkDocs was bad: They built it because MkDocs hit a ceiling:</p> <ul> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ul> <p>A proven team starting fresh is more predictable than an unproven team at v3.0.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#2-the-architecture","level":3,"title":"2. The Architecture","text":"<p>Zensical is investing in a Rust-based Markdown parser with CommonMark support. That signals something about the team's priorities:</p> <p>Performance foundations first; features second.</p> <p><code>ctx</code>'s journal will grow: </p> <ul> <li>Every exported session adds files.</li> <li>Every enrichment pass adds metadata. </li> </ul> <p>Choosing a tool that gets slower as you add content means choosing to migrate later.</p> <p>Choosing one built for scale means the decision holds.</p>","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":"<p>Zensical reads <code>mkdocs.yml</code> natively. If it doesn't work out, I can move back to MkDocs + Material with zero content changes:</p> <ul> <li>The Markdown is standard; </li> <li>The frontmatter is standard; </li> <li>The configuration is compatible.</li> </ul> <p>This is the infrastructure pattern again: The same way <code>ZNC</code> decouples presence from the client, <code>zensical</code> decouples rendering from the generator: </p> <ul> <li>The Markdown is yours. </li> <li>The frontmatter is standard YAML. </li> <li>The configuration is MkDocs-compatible.</li> </ul> <p>You are not locked into anything except your own content.</p> <p>No lock-in is not a feature: It's a design philosophy: </p> <p>It's the same reason <code>ctx</code> uses plain Markdown files in <code>.context/</code> instead of a database: the format should outlive the tool.</p> <p>Lock-in Is the Real Risk, Not Version Numbers</p> <p>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.</p>","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":"<p>Here is what <code>pip install zensical</code> actually pulls in:</p> <ul> <li>click</li> <li>Markdown</li> <li>Pygments</li> <li>pymdown-extensions</li> <li>PyYAML</li> </ul> <p>Only five dependencies. All well-known. No framework bloat. No bundler. No transpiler. No <code>node_modules</code> black hole.</p> <p>3k GitHub stars at <code>v0.0.21</code> is a strong early traction for a <code>pre-1.0</code> project. </p> <p>The dependency tree is thin: No bloat.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#5-the-fit","level":3,"title":"5. The Fit","text":"<p>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.</p> <p>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:</p> <p>It is the complexity you pay for but never use.</p> <p><code>ctx</code>'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:</p> <ul> <li>No custom plugins needed;</li> <li>No special syntax; </li> <li>No templating gymnastics.</li> </ul> <p>The requirements match the capabilities: Not the capabilities that are promised, but the ones that exist today, at <code>v0.0.21</code>.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-caveat","level":2,"title":"The Caveat","text":"<p>It would be dishonest not to mention what's missing.</p> <p>The module system for third-party extensions opens in early 2026.</p> <p>If <code>ctx</code> ever needs custom plugins (for example, auto-linking session IDs, rendering special journal metadata, etc.) that infrastructure isn't there yet.</p> <p>The installation experience is rough: </p> <p>We discovered this firsthand: <code>pip install zensical</code> 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. </p> <p>That kind of friction is typical for young Python tooling, and it is documented in the Common Workflows guide.</p> <p>And <code>3,000</code> stars at <code>v0.0.21</code> is strong early traction, but it's still early: The community is small. When something breaks, you're reading source code, not documentation.</p> <p>These are real costs. I chose to pay them because the alternative costs are higher.</p> <p>For example:</p> <ul> <li>Hugo's templating pain would cost me time on every site change.</li> <li>Astro's JS ecosystem would add complexity I don't need. </li> <li>MkDocs would work today but hit scaling walls tomorrow. </li> </ul> <p>Zensical's costs are front-loaded and shrinking. </p> <p>The others compound.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-evaluation-framework","level":2,"title":"The Evaluation Framework","text":"<p>For anyone facing a similar choice, here is the framework that emerged:</p> 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 <p>The bottom three are the metrics most engineers optimize for.</p> <p>The top four are the ones that predict whether you'll still be happy with the choice in a year.</p> <p>Features You Don't Need Are Not Free</p> <p>Every feature in a dependency is code you inherit but don't control. </p> <p>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.</p> <p>Fit is the inverse of feature count.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-15-why-zensical/#the-broader-pattern","level":2,"title":"The Broader Pattern","text":"<p>This is part of a theme I keep encountering in this project:</p> <p>Leading indicators beat lagging indicators.</p> 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 <code>.context/</code> 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 <p>Version numbers, star counts, coverage percentages, file counts...</p> <p>...these are all measures of effort expended. </p> <p>They say nothing about value delivered.</p> <p>The question is never \"how mature is this tool?\" </p> <p>The question is \"does this tool's trajectory intersect with my needs?\"</p> <p>Zensical's trajectory: </p> <ul> <li>A proven team fixing known problems, </li> <li>in a *proven architecture, </li> <li>with a standard format,</li> <li>and no lock-in.</li> </ul> <p><code>ctx</code>'s needs: </p> <p>Tender standard Markdown into a browsable site, at scale, without complexity.</p> <p>The intersection is clean; the version number is noise.</p> <p>This is the same kind of decision that shows up throughout <code>ctx</code>:</p> <ul> <li>Skills that fight the platform taught that the best integration extends existing behavior, not replaces it.</li> <li>You can't import expertise taught that tools should grow from your project's actual needs, not from feature checklists.</li> <li>Context as infrastructure argues that the format should outlive the tool; and, <code>zensical</code> honors that principle by reading standard Markdown and standard MkDocs configuration.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>Version numbers measure where a project has been.</p> <p>The team and the architecture tell you where it's going.</p> <p>A <code>v0.0.21</code> tool built by the right team on the right foundations is a safer bet than a <code>v5.0</code> tool that doesn't fit your problem.</p> <p>Bet on trajectories, not timestamps.</p> <p>This post started as an evaluation note in <code>ideas/</code> and a separate decision log. The analysis held up. The two merged into one. The meta continues.</p>","path":["Version Numbers Are Lagging Indicators"],"tags":[]},{"location":"blog/2026-02-16-ctx-v0.6.0-the-integration-release/","level":1,"title":"<code>ctx</code> 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":"<p>Jose Alekhinne / February 16, 2026</p> <p>What Changed?</p> <p><code>ctx</code> is now a Claude Code plugin. Two commands, no build step:</p> <pre><code>/plugin marketplace add ActiveMemory/ctx\n/plugin install ctx@activememory-ctx\n</code></pre> <p>Six hooks. Twenty-five skills. Installed.</p> <p>For three releases, <code>ctx</code> required assembly: </p> <ul> <li>Clone the repo; </li> <li>Build the binary; </li> <li>Copy hook scripts into <code>.claude/hooks/</code>; </li> <li>Symlink skill files.</li> <li>Understand which shell scripts called which Go commands;</li> <li>Hope nothing broke when Claude Code updated its hook format.</li> </ul> <p><code>v0.6.0</code> ends that era: <code>ctx</code> ships as a Claude Marketplace plugin:</p> <p>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.</p> <p>But the plugin conversion was not just a packaging change: It was the forcing function that rewrote every shell hook in Go, eliminated the <code>jq</code> dependency, enabled <code>go test</code> coverage for hook logic, and made distribution a solved problem. </p> <p>When you fix how something ships, you end up fixing how it is built.</p> <p>The Release Window</p> <p>February 15-February 16, 2026</p> <p>From the v0.3.0 tag to commit <code>a3178bc</code>:</p> <ul> <li>109 commits. </li> <li>334 files changed. </li> <li>Version jumped from 0.3.0 to 0.6.0 to signal the magnitude.</li> </ul>","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":"<p><code>v0.3.0</code> had six hook scripts. Each was a Bash file that shelled out to <code>ctx</code> subcommands, parsed JSON with <code>jq</code>, and wired itself into Claude Code's hook system via <code>.claude/hooks/</code>:</p> <pre><code>.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</code></pre> <p>This worked, but it also meant:</p> <ul> <li>jq was a hard dependency: No <code>jq</code>, no hooks. macOS ships without it.</li> <li>No test coverage: Shell scripts were tested manually or not at all.</li> <li>Fragile deployment: <code>ctx init</code> had to scaffold <code>.claude/hooks/</code> and <code>.claude/skills/</code> with the right paths, permissions, and structure.</li> <li>Version drift: Users who installed once never got hook updates unless they re-ran <code>ctx init</code>.</li> </ul> <p>The shell scripts were the right choice for prototyping. They were the wrong choice for distribution.</p>","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":"<p><code>v0.6.0</code> replaces all six scripts with <code>ctx system</code> subcommands compiled into the binary:</p> Shell Script Go Subcommand <code>check-context-size.sh</code> <code>ctx system check-context-size</code> <code>check-persistence.sh</code> <code>ctx system check-persistence</code> <code>check-journal.sh</code> <code>ctx system check-journal</code> <code>post-commit.sh</code> <code>ctx system post-commit</code> <code>block-non-path-ctx.sh</code> <code>ctx system block-non-path-ctx</code> <code>cleanup-tmp.sh</code> <code>ctx system cleanup-tmp</code> <p>The plugin's <code>hooks.json</code> wires them to Claude Code events:</p> <pre><code>{\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</code></pre> <p>No jq. No shell scripts. No <code>.claude/hooks/</code> directory to manage.</p> <p>The hooks are Go functions with tests, compiled into the same binary you already have.</p>","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":"<p>The <code>ctx</code> plugin lives at <code>.claude-plugin/marketplace.json</code> in the repo.</p> <p>Claude Code's marketplace system handles discovery and installation:</p> <p>Skills are served directly from <code>internal/assets/claude/skills/</code>; there is no build step, no <code>make plugin</code>, no generated artifacts.</p> <p>This means:</p> <ol> <li>Install is two commands: Not \"clone, build, copy, configure.\"</li> <li>Updates are automatic: Pull the repo; the plugin reads from source.</li> <li>Skills and hooks are versioned together: No drift between what the CLI expects and what the plugin provides.</li> <li><code>ctx init</code> is tool-agnostic: It creates <code>.context/</code> and nothing else. No <code>.claude/</code> scaffolding, no assumptions about which AI tool you use.</li> </ol> <p>That last point matters: </p> <p>Before <code>v0.6.0</code>, <code>ctx init</code> tried to set up Claude Code integration as part of initialization. That coupled the context system to a specific tool. </p> <p>Now, <code>ctx init</code> gives you persistent context. The plugin gives you Claude Code integration. They compose; they don't depend.</p>","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":"<p>The plugin conversion dominated the release, but 109 commits covered more ground.</p>","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":"<pre><code>ctx journal obsidian\n</code></pre> <p>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.</p>","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":"<pre><code>ctx pad edit \"DATABASE_URL=postgres://...\"\nctx pad show\n</code></pre> <p><code>AES-256-GCM</code> encrypted storage for sensitive one-liners. </p> <p>The encrypted blob commits to <code>git</code>; the key stays in <code>.gitignore</code>. </p> <p>This is useful for connection strings, API keys, and other values that need to travel with the project without appearing in plaintext.</p>","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":"<p>Three medium-severity findings from a security audit are now closed:</p> Finding Fix Path traversal via <code>--context-dir</code> Boundary validation: operations cannot escape project root (M-1) Symlink following in <code>.context/</code> <code>Lstat()</code> check before every file read/write (M-2) Predictable temp file paths User-specific temp directory under <code>$XDG_RUNTIME_DIR</code> (M-3) <p>Plus a new <code>/sanitize-permissions</code> skill that audits <code>settings.local.json</code> for overly broad Bash permissions.</p>","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":"<p>A subtle but important fix: hooks now no-op before <code>ctx init</code> has run.</p> <p>Previously, a fresh clone with no <code>.context/</code> would trigger hook errors on every prompt. Now, hooks detect the absence of a context directory and exit silently. Similarly, <code>ctx init</code> treats a <code>.context/</code> directory containing only logs as uninitialized and skips the <code>--overwrite</code> prompt.</p> <p>Small changes. Large reduction in friction for new users.</p>","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 <code>ctx init</code> creates .claude/ yes no <p>The line count tripled. Most of that is documentation site HTML, Obsidian export logic, and the scratchpad encryption module. </p> <p>The core CLI grew modestly; the ecosystem around it grew substantially.</p>","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 <code>v0.6.0</code> Mean for <code>ctx</code>?","text":"<ul> <li><code>v0.1.0</code> asked: \"Can we give AI persistent memory?\"</li> <li><code>v0.2.0</code> asked: \"Can we make that memory accessible to humans too?\"</li> <li><code>v0.3.0</code> asked: \"Can we make the quality self-enforcing?\"</li> </ul> <p>v0.6.0 asks: \"Can someone else actually use this?\"</p> <p>A tool that requires cloning a repo, building from source, and manually wiring hooks into the right directories is a tool for its author.</p> <p>A tool that installs with two commands from a marketplace is a tool for everyone.</p> <p>The version jumped from <code>0.3.0</code> to <code>0.6.0</code> 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 <code>ctx</code> is: Not a different tool, but a tool that is finally ready to leave the workshop.</p>","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":"<p>The plugin model opens the door to distribution patterns that were not possible before. Marketplace discovery means new users find <code>ctx</code> without reading a <code>README</code>. Plugin updates mean existing users get improvements without rebuilding.</p> <p>The next chapter is about what happens when persistent context is easy to install: Adoption patterns, multi-project workflows, and whether the <code>.context/</code> convention can become infrastructure that other tools build on.</p> <p>But those are future posts.</p> <p>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.</p> <p>The Integration Release</p> <p><code>v0.1.0</code> shipped features. <code>v0.2.0</code> shipped archaeology.</p> <p><code>v0.3.0</code> shipped discipline. <code>v0.6.0</code> shipped the front door.</p> <p>The most important code in this release is the code you never have to copy.</p> <p>This post was drafted using <code>/ctx-blog-changelog</code> 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.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>Are You Worried about AI Taking Your Job?</p> <p>You might be confusing the thing that's cheap with the thing that's valuable.</p> <p>I keep seeing the same conversation: Engineers, designers, writers: all asking the same question with the same dread:</p> <p>\"What happens when AI can do what I do?\"</p> <p>The question is wrong:</p> <ul> <li>AI does not replace workers;</li> <li>AI replaces unstructured effort.</li> </ul> <p>The distinction matters, and everything I have learned building <code>ctx</code> reinforces it.</p>","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":"<p>People who feel doomed by AI usually confuse three things:</p> People confuse... With... Effort Value Typing Thinking Production Judgment <ul> <li>Effort is time spent.</li> <li>Value is the outcome that time produces.</li> </ul> <p>They are not the same; they never were. </p> <p>AI just makes the gap impossible to ignore.</p> <p>Typing is mechanical: Thinking is directional. </p> <p>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.</p> <p>Production is making artifacts. Judgment is knowing:</p> <ul> <li>which artifacts to make, </li> <li>in what order, </li> <li>to what standard, </li> <li>and when to stop.</li> </ul> <p>AI floods the system with production capacity; it does not flood the system with judgment.</p>","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":"<p>This sounds provocative until you internalize it:</p> <p>Code is cheap. Artifacts are cheap.</p> <p>An AI can generate a thousand lines of working code in literal *minutes**:</p> <p>It can scaffold a project, write tests, build a CI pipeline, draft documentation. The raw production of software artifacts is no longer the bottleneck.</p> <p>So, what is not cheap?</p> <ul> <li>Taste: knowing what belongs and what does not</li> <li>Framing: turning a vague goal into a concrete problem</li> <li>Sequencing: deciding what to build first and why</li> <li>Fanning out: breaking work into parallel streams that converge</li> <li>Acceptance criteria: defining what \"done\" looks like before starting</li> <li>Judgment: the thousand small decisions that separate code that works from code that lasts</li> </ul> <p>These are the skills that direct production: Hhuman skills.</p> <p>Not because AI is incapable of learning them, but because they require something AI does not have: </p> <p>temporal accountability for generated outcomes.</p> <p>That is, you cannot keep AI accountable for the <code>$#!%</code> it generated three months ago. A human, on the other hand, will always be accountable.</p>","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 <code>ctx</code>","text":"<p>I did not arrive at this conclusion theoretically. </p> <p>I arrived at it by building a tool with an AI agent for three weeks and watching exactly where a human touch mattered.</p>","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":"<p>In Building <code>ctx</code> Using <code>ctx</code>, 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.</p> <p>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.</p> <p>Production without judgment is not velocity. It is debt accumulation at breakneck speed.</p>","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":"<p>In The 3:1 Ratio, the <code>git</code> history told the story:</p> <p>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.</p> <p>The AI does the refactoring. The human decides what to refactor and when to stop. </p> <p>Without the human, the AI will refactor forever, improving things that do not matter and missing things that do.</p>","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":"<p>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.</p> <p>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. </p> <p><code>ctx agent --budget 4000</code> is not just a CLI flag: It is a forcing function for human judgment about relevance.</p> <p>The AI processes. The human curates.</p>","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":"<p>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: </p> <p>It is taste.</p> <p>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. </p> <p>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.</p>","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":"<p>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.</p> <p>The human applies judgment about frequency, stability, and attention cost.</p> <p>The AI can build the skill. Only the human can decide whether it should exist.</p>","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":"<p>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).</p> <p>The AI follows instructions. The human decides which instructions are enforceable and which are \"wishful thinking\".</p>","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":"<p>In Parallel Agents and Merge Debt, the lesson was that multiplying agents multiplies output. But it also multiplies the need for judgment:</p> <p>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.</p> <p>More agents do not reduce the need for judgment. They increase it.</p>","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":"<p>When AI floods the system with cheap output, two things happen:</p> <p>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.</p> <p>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.</p> <p>The gap between these two is not talent: It is the awareness of where the value lives.</p>","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":"<p>If you are an engineer reading this, the actionable insight is not \"learn prompt engineering\" or \"master AI tools.\" It is:</p> <p>Get better at the things AI cannot do.</p> 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 <p>The skills on the right column are not new. They are the same skills that have always separated senior engineers from junior ones. </p> <p>AI did not create the distinction; it just made it load-bearing.</p>","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":"<p>I will end with something personal.</p> <p>I am not worried: I am empowered.</p> <p>Before <code>ctx</code>, I could think faster than I could produce: </p> <ul> <li>Ideas sat in a queue. </li> <li>The bottleneck was always \"I know what to build, but building it takes too long.\"</li> </ul> <p>Now the bottleneck is gone. Poof!</p> <ul> <li>Production is cheap. </li> <li>The queue is clearing. </li> <li>The limiting factor is how fast I can think, not how fast I can type.</li> </ul> <p>That is not a threat: That is the best force multiplier I've ever had.</p> <p>The people who feel threatened are confusing the accelerator for the replacement:</p> <p>*AI does not replace the conductor; it gives them a bigger orchestra.</p> <p>If You Remember One Thing from This Post...</p> <p>Code is cheap. Judgment is not.</p> <p>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.</p> <p>The difference is that now, for the first time, those skills are the only bottleneck left.</p>","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":"<p>This post is a retrospective. It synthesizes the thread running through every previous entry in this blog:</p> <ul> <li>Building <code>ctx</code> Using <code>ctx</code> showed that production without direction creates debt</li> <li>Refactoring with Intent showed that slowing down is not the opposite of progress</li> <li>The Attention Budget showed that curation outweighs volume</li> <li>The skill trilogy showed that taste determines whether a tool helps or hinders</li> <li>Not Everything Is a Skill showed that restraint is a skill in itself</li> <li>Defense in Depth showed that instructions are not boundaries</li> <li>The 3:1 Ratio showed that judgment has a schedule</li> <li>Parallel Agents showed that scale amplifies the gap between production and judgment</li> <li>Context as Infrastructure showed that the system you build for context is infrastructure, not conversation</li> </ul> <p>From YOLO mode to defense in depth, the pattern is the same:</p> <ul> <li>Production is the easy part;</li> <li>Judgment is the hard part;</li> <li>AI changed the ratio, not the rule.</li> </ul> <p>This post synthesizes the thread running through every previous entry in this blog. The evidence is drawn from three weeks of building <code>ctx</code> with AI assistance, the decisions recorded in <code>DECISIONS.md</code>, the learnings captured in <code>LEARNINGS.md</code>, and the git history that tracks where the human mattered and where the AI ran unsupervised.</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>Where Does Your AI's Knowledge Live between Sessions?</p> <p>If the answer is \"in a prompt I paste at the start,\" you are treating context as a consumable. Something assembled, used, and discarded.</p> <p>What if you treated it as infrastructure instead?</p> <p>This post synthesizes a thread that has been running through every <code>ctx</code> 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.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-prompt-paradigm","level":2,"title":"The Prompt Paradigm","text":"<p>Most AI-assisted development treats context as ephemeral:</p> <ol> <li>Start a session.</li> <li>Paste your system prompt, your conventions, your current task.</li> <li>Work.</li> <li>Session ends. Everything evaporates.</li> <li>Next session: paste again.</li> </ol> <p>This works for short interactions. For sustained development (where decisions compound over days and weeks) it fails in three ways:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>The Copy-Paste Tax</p> <p>Every session that starts with pasting a prompt is paying a tax:</p> <p>The human time to assemble the context, the risk of forgetting something, and the silent assumption that yesterday's prompt is still accurate today.</p> <p>Over 70+ sessions, that tax compounds into a significant maintenance burden: One that most developers absorb without questioning it.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-infrastructure-paradigm","level":2,"title":"The Infrastructure Paradigm","text":"<p><code>ctx</code> takes a different approach:</p> <p>Context is not assembled per-session; it is maintained as persistent files in a <code>.context/</code> directory:</p> <pre><code>.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</code></pre> <ul> <li>Each file has a single purpose;</li> <li>Each can be loaded independently;</li> <li>Each persists across sessions, tools, and team members.</li> </ul> <p>This is not a novel idea. It is the same idea behind every piece of infrastructure software engineers already use:</p> Traditional Infrastructure <code>ctx</code> Equivalent Database <code>.context/*.md</code> files Configuration files <code>CONSTITUTION.md</code> Environment variables <code>.contextrc</code> Log files <code>journal/</code> Schema migrations Decision records Deployment manifests <code>AGENT_PLAYBOOK.md</code> <p>The parallel is not metaphorical. Context files are infrastructure:</p> <ul> <li>They are versioned (<code>git</code> tracks them); </li> <li>They are structured (Markdown with conventions); </li> <li>They have schemas (required fields for decisions and learnings); </li> <li>And they have lifecycle management (archiving, compaction, indexing).</li> </ul>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#separation-of-concerns","level":2,"title":"Separation of Concerns","text":"<p>The most important design decision in <code>ctx</code> is not any individual feature. It is the separation of context into distinct files with distinct purposes.</p> <p>A single <code>CONTEXT.md</code> file would be simpler to implement. It would also be impossible to maintain.</p> <p>Why? Because different types of context have different lifecycles:</p> 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 <p>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.</p> <p>Separation of concerns allows progressive disclosure: </p> <p>Load the minimum that matters for this moment, with the option to load more when needed.</p> <pre><code># 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</code></pre> <p>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.</p>","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":"<p><code>ctx</code> uses two tiers of persistence, and the distinction is architectural:</p> Tier Purpose Location Token Cost Curated Quick context reload <code>.context/*.md</code> Low (budgeted) Full dump Safety net, archaeology <code>.context/journal/*.md</code> Zero (not auto-loaded) <p>The curated tier is what the AI sees at session start. It is optimized for signal density: </p> <ul> <li>Structured entries, </li> <li>Indexed tables,</li> <li>Reverse-chronological order (newest first, so the most relevant content survives truncation).</li> </ul> <p>The full dump tier is for humans and for deep investigation. It contains everything: Enriched journals, archived tasks... </p> <p>It is never autoloaded because its volume would destroy attention density.</p> <p>This two-tier model is analogous to how traditional systems separate hot and cold storage: </p> <ul> <li>The hot path (curated context) is optimized for read performance (measured not in milliseconds, but in tokens consumed per unit of useful information). </li> <li>The cold path (journal) is optimized for completeness.</li> </ul> <p>Nothing Is Ever Truly Lost</p> <p>The full dump tier means that context does not need to be perfect: It just needs to be findable.</p> <p>A decision that was not captured in <code>DECISIONS.md</code> can be recovered from the session transcript where it was discussed. </p> <p>A learning that was not formalized can be found in the journal entry from that day.</p> <p>The curated tier is the fast path: The full dump tier is the safety net.</p>","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":"<p>One of the patterns that emerged from <code>ctx</code>'s own development is the power of structured decision records.</p> <p><code>v0.1.0</code> allowed adding decisions as one-liners:</p> <pre><code>ctx add decision \"Use PostgreSQL\"\n</code></pre> <p><code>v0.2.0</code> enforced structure:</p> <pre><code>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</code></pre> <p>The difference is not cosmetic:</p> <ul> <li>A one-liner decision teaches the AI what was decided. </li> <li>A structured decision teaches it why; and why is what prevents the AI from unknowingly reversing the decision in a future session.</li> </ul> <p>This is infrastructure thinking: </p> <p>Decisions are not notes. They are records with required fields, just like database rows have schemas.</p> <p>The enforcement exists because incomplete records are worse than no records: They create false confidence that the context is captured when it is not.</p>","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":"<p>Early in <code>ctx</code>'s development, there was a temptation to build a custom UI: a web dashboard for browsing sessions, editing context, viewing analytics.</p> <p>The decision was no. The IDE is the interface.</p> <pre><code># This is the ctx \"UI\":\ncode .context/\n</code></pre> <p>This decision was not about minimalism for its own sake. It was about recognizing that <code>.context/</code> files are just files; and files have a mature, well-understood infrastructure:</p> <ul> <li>Version control: <code>git diff .context/DECISIONS.md</code> shows exactly what changed and when.</li> <li>Search: Your IDE's full-text search works across all context files.</li> <li>Editing: Markdown in any editor, with preview, spell check, and syntax highlighting.</li> <li>Collaboration: Pull requests on context files work the same as pull requests on code.</li> </ul> <p>Building a custom UI would have meant maintaining a parallel infrastructure that duplicates what every IDE already provides:</p> <p>It would have introduced its own bugs, its own update cycle, and its own learning curve.</p> <p>The filesystem is not a limitation: It is the most mature, most composable, most portable infrastructure available.</p> <p>Context Files in Git</p> <p>Because <code>.context/</code> lives in the repository, context changes are part of the commit history. </p> <p>A decision made in commit <code>abc123</code> is as traceable as a code change in the same commit.</p> <p>This is not possible with prompt-based context, which exists outside version control entirely.</p>","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":"<p>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.</p> <p><code>ctx</code> applies the same principle to AI context:</p> Level What the AI Sees Token Cost When Level 0 <code>ctx status</code> (one-line summary) ~100 Quick check Level 1 <code>ctx agent --budget 4000</code> ~4,000 Normal work Level 2 <code>ctx agent --budget 8000</code> ~8,000 Complex tasks Level 3 Direct file reads 10,000+ Deep investigation <p>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.</p> <p>The explicit <code>--budget</code> flag is the mechanism that makes this work:</p> <p>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.</p> <p>The constraint is the feature: A budget of 4,000 tokens forces <code>ctx</code> 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.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-philosophical-shift","level":2,"title":"The Philosophical Shift","text":"<p>The shift from \"context as prompt\" to \"context as infrastructure\" changes how you think about AI-assisted development:</p> 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\" <p>The first column treats AI interaction as a conversation. The second treats it as a system: One that can be maintained, optimized, and debugged.</p> <p>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.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#beyond-ctx-the-principles","level":2,"title":"Beyond <code>ctx</code>: The Principles","text":"<p>The patterns that <code>ctx</code> implements are not specific to <code>ctx</code>. They are applicable to any project that uses AI-assisted development:</p> <ol> <li>Separate context by purpose: Do not put everything in one file. Different types of information have different lifecycles and different relevance windows.</li> <li>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.</li> <li>Budget explicitly: Know how much context you are loading and whether it is worth the attention cost.</li> <li>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.</li> <li>Version your context: Put context files in <code>git</code>. Changes to decisions are as important as changes to code.</li> <li>Design for degradation: Sessions will get long. Attention will dilute. Build mechanisms (compaction, archiving, cooldowns) that make degradation visible and manageable.</li> </ol> <p>These are not <code>ctx</code> 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.</p> <p>The tool is a convenience: The principles are what matter.</p> <p>If You Remember One Thing from This Post...</p> <p>Prompts are conversations. Infrastructure persists.</p> <p>Your AI does not need a better prompt. It needs a filesystem:</p> <p>versioned, structured, budgeted, and maintained.</p> <p>The best context is the context that was there before you started the session.</p>","path":["Context as Infrastructure"],"tags":[]},{"location":"blog/2026-02-17-context-as-infrastructure/#the-arc","level":2,"title":"The Arc","text":"<p>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).</p> <p>Together with Code Is Cheap, Judgment Is Not, they form a trilogy about what matters in AI-assisted development:</p> <ul> <li>Attention Budget: the resource you're managing</li> <li>Context as Infrastructure: the system you build to manage it</li> <li>Code Is Cheap: the human skill that no system replaces</li> </ul> <p>And the practices that keep it all honest:</p> <ul> <li>The 3:1 Ratio: the cadence for maintaining both code and context</li> <li>IRC as Context: the historical precedent: stateless protocols have always needed stateful wrappers</li> </ul> <p>This post synthesizes ideas from across the <code>ctx</code> 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 <code>ctx</code> and 70+ sessions of treating context as infrastructure rather than conversation.</p> <p>See also: When a System Starts Explaining Itself: what happens when this infrastructure starts compounding in someone else's environment.</p>","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":"<p>Volkan Özçelik / 2026-02-17</p> <p>How Many Terminals Are Too Many?</p> <p>You discover agents can run in parallel.</p> <p>So you open ten... </p> <p>...Then twenty.</p> <p>The fans spin. Tokens burn. The screen looks like progress.</p> <p>It is NOT progress.</p> <p>There is a phase every builder goes through:</p> <ul> <li>The tooling gets fast enough. </li> <li>The model gets good enough. </li> <li>The temptation becomes irresistible: <ul> <li>more agents, more output, faster delivery.</li> </ul> </li> </ul> <p>So you open terminals. You spawn agents. You watch tokens stream across multiple windows simultaneously, and it feels like multiplication.</p> <p>It is not multiplication.</p> <p>It is merge debt being manufactured in real time.</p> <p>The <code>ctx</code> Manifesto says it plainly:</p> <p>Activity is not impact. Code is not progress.</p> <p>This post is about what happens when you take that seriously in the context of parallel agent workflows.</p>","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":"<p>The naive model says:</p> <p>More agents -> more output -> faster delivery</p> <p>The production model says:</p> <p>Clean context boundaries -> less interference -> higher throughput</p> <p>Parallelism only works when the cognitive surfaces do not overlap.</p> <p>If two agents touch the same files, you did not create parallelism: You created a conflict generator.</p> <p>They will:</p> <ul> <li>Revert each other's changes;</li> <li>Relint each other's formatting;</li> <li>Refactor the same function in different directions.</li> </ul> <p>You watch with 🍿. Nothing ships.</p> <p>This is the same insight from the worktrees post: partition by blast radius, not by priority. </p> <p>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. </p> <p>Everything else is scheduling.</p>","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":"<p>In practice there is a ceiling.</p> <p>Around five or six concurrent agents:</p> <ul> <li>Token burn becomes noticeable;</li> <li>Supervision cost rises;</li> <li>Coordination noise increases;</li> <li>Returns flatten.</li> </ul> <p>This is not a model limitation: This is a human merge bandwidth limitation.</p> <p>You are the bottleneck, not the silicon.</p> <p>The attention budget applies to you too: </p> <p>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.</p> <p>Five agents producing verified, mergeable change beats twenty agents producing merge conflicts you spend a day untangling.</p>","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":"<p>Real parallelism comes from task topology, not from tooling.</p> <p>Good:</p> Agent Role Touches 1 Documentation <code>docs/</code>, <code>hack/</code> 2 Security scan Read-only audit 3 Implementation <code>internal/cli/</code> 4 Enhancement requests Read-only, files issues <p>Bad:</p> <ul> <li>Four agents editing the same implementation surface</li> </ul> <p>Context Is the Boundary</p> <ul> <li>The goal is not to keep agents busy. </li> <li>The goal is to keep contexts isolated.</li> </ul> <p>This is what the codebase audit got right: </p> <ul> <li>Eight agents, all read-only, each analyzing a different dimension. </li> <li>Zero file overlap.</li> <li>Zero merge conflicts. </li> <li>Eight reports that composed cleanly because no agent interfered with another.</li> </ul>","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":"<p>There is a moment when more windows stop helping.</p> <p>That is the signal. Not to add orchestration. But to introduce:</p> <pre><code>git worktree\n</code></pre> <p>Because now you are no longer parallelizing execution; you are parallelizing state.</p> <p>State Scales, Windows Don't</p> <ul> <li>State isolation is the real scaling. </li> <li>Window multiplication is theater.</li> </ul> <p>The worktrees post covers the mechanics: </p> <ul> <li>Sibling directories;</li> <li>Branch naming; </li> <li>The inevitable <code>TASKS.md</code> conflicts; </li> <li>The 3-4 worktree ceiling. </li> </ul> <p>The principle underneath is older than <code>git</code>:</p> <p>Shared mutable state is the enemy of parallelism. </p> <p>Always has been.</p> <p>Always will be.</p>","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":"<p>Autonomous night runs are impressive.</p> <p>You sleep. The machine produces thousands of lines.</p> <p>In the morning:</p> <ul> <li>You read;</li> <li>You untangle;</li> <li>You reconstruct intent;</li> <li>You spend a day making it shippable.</li> </ul> <p>In retrospect, nothing was accelerated. </p> <p>The bottleneck moved from typing to comprehension.</p> <p>The Comprehension Tax</p> <p>If understanding the output costs more than producing it, the loop is a net loss.</p> <p>Progress is not measured in generated code.</p> <p>Progress is measured in verified, mergeable change.</p> <p>The <code>ctx</code> Manifesto calls this out directly:</p> <p>The Scoreboard</p> <p>Verified reality is the scoreboard.</p> <p>The only truth that compounds is verified change in the real world.</p> <p>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. </p> <p>And that someone is (insert drumroll here) you: </p> <p>The same bottleneck that was supposedly being bypassed.</p>","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":"<p>Most marketplace skills are prompt decorations:</p> <ul> <li>They rephrase what the base model already knows;</li> <li>They increase token usage; </li> <li>They reduce clarity:</li> <li>They introduce behavioral drift.</li> </ul> <p>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.</p> <p>A real skill does one of these:</p> <ul> <li>Encodes workflow state;</li> <li>Enforces invariants;</li> <li>Reduces decision branching.</li> </ul> <p>Everything else is packaging.</p> <p>The anatomy post established the criteria: quality gates, negative triggers, examples over rules, skills as contracts. </p> <p>If a skill doesn't meet those criteria... </p> <ul> <li>It is either a recipe (document it in <code>hack/</code>); </li> <li>Or noise (delete it);</li> <li>There is no third option.</li> </ul>","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":"<p>The most valuable skills are not prompts:</p> <p>They are constraints embedded in the toolchain.</p> <p>For example: The agent cannot push.</p> <p><code>git push</code> becomes:</p> <p>Stop. A human reviews first.</p> <p>A commit without verification becomes:</p> <p>Did you run tests? Did you run linters? What exactly are you shipping?</p> <p>This is not safety theater; this is intent preservation.</p> <p>The thing the <code>ctx</code> Manifesto calls \"encoding intent into the environment.\"</p> <p>The Eight Ways a Hook Can Talk cataloged the full spectrum: from silent enrichment to hard blocks. </p> <p>The key insight was that hooks are not just safety rails: They are context that survives execution.</p> <p>They are the difference between an agent that remembers the rules and one that enforces them.</p>","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":"<p>Every extra layer adds cognitive weight:</p> <ul> <li>Orchestration frameworks;</li> <li>Meta agents;</li> <li>Autonomous planning systems...</li> </ul> <p>If a single terminal works, stay there.</p> <p>If five isolated agents work, stop there.</p> <p>Add structure only when a real bottleneck appears. </p> <p>NOT when an influencer suggests one.</p> <p>This is the same lesson from Not Everything Is a Skill:</p> <p>The best automation decision is sometimes not to automate.</p> <p>A recipe in a Markdown file costs nothing until you use it. </p> <p>An orchestration framework costs attention on every run, whether it helps or not.</p>","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":"<p>Clear writing is not aesthetic: It is compression.</p> <p>Better articulation means:</p> <ul> <li>Fewer tokens;</li> <li>Fewer misinterpretations;</li> <li>Faster convergence.</li> </ul> <p>The attention budget taught us that context is a finite resource with a quadratic cost. </p> <p>Language determines how fast you spend context. </p> <p>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.</p> <p>Literature Is NOT Overrated</p> <ul> <li>Attention is a finite budget. </li> <li>Language determines how fast you spend it.</li> </ul>","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":"<p>The real metric is not:</p> <ul> <li>Lines generated;</li> <li>Agents running;</li> <li>Tasks completed while you sleep.</li> </ul> <p>But:</p> <p>Time from idea to verified, mergeable, production change.</p> <p>Everything else is motion.</p> <p>The entire blog series has been circling this point: </p> <ul> <li>The attention budget was about spending tokens wisely. </li> <li>The skills trilogy was about not wasting them on prompt decoration.</li> <li>The worktrees post was about multiplying throughput without multiplying interference. </li> <li>The discipline release was about what a release looks like when polish outweighs features: 3:1.</li> </ul> <p>Every post has arrived (and made me converge) at the same answer so far: </p> <p>The metric is a verified change, not generated output.</p>","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":"<code>ctx</code> Was Never about Spawning More Minds","text":"<p><code>ctx</code> is about:</p> <ul> <li>Isolating context;</li> <li>Preserving intent;</li> <li>Making progress composable.</li> </ul> <p>Parallel agents are powerful. But only when you respect the boundaries that make parallelism real.</p> <p>Otherwise, you are not scaling cognition; you are scaling interference.</p> <p>The <code>ctx</code> Manifesto's thesis holds:</p> <p>Without <code>ctx</code>, intelligence resets. With <code>ctx</code>, creation compounds.</p> <p>Compounding requires structure. </p> <p>Structure requires boundaries.</p> <p>Boundaries require the discipline to stop adding agents when five is enough.</p>","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":"<p>A production workflow tends to converge to this:</p> 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 <p>This is slower to watch. Faster to ship.</p> <p>If You Remember One Thing from This Post...</p> <p>Progress is not what the machine produces while you sleep.</p> <p>Progress is what survives contact with the main branch.</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>How Often Should You Stop Building and Start Cleaning?</p> <p>Every developer knows technical debt exists. Every developer postpones dealing with it.</p> <p>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.</p> <p>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.</p> <p>That was an observation. This post is the evidence.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-observation","level":2,"title":"The Observation","text":"<p>During the first two weeks of building <code>ctx</code>, I noticed a rhythm in my own productivity. Feature sessions felt great: new commands, new capabilities, visible progress...</p> <p>...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.</p> <p>The fourth session (when I stopped adding and started cleaning) was always the most painful to start and the most satisfying to finish.</p> <p>It was also the one that made the next three feature sessions faster.</p>","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":"<p>The <code>ctx</code> git history between January 20 and February 7 tells a clear story when you categorize commits:</p> 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 <p>The first week was pure YOLO: Almost four feature commits for every consolidation commit. The codebase grew fast.</p> <p>The second week started to self-correct. The ratio dropped as refactoring sessions became necessary: Not scheduled, but forced by friction.</p> <p>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.</p> <p>The debt from weeks one and two was paid in week three.</p> <p>The Compounding Problem</p> <p>Consolidation debt compounds.</p> <p>Week one's drift doesn't just persist into week two: It accelerates, because new features are built on top of drifted patterns.</p> <p>By week three, the cost of consolidation was higher than it would have been if spread evenly.</p>","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":"<p>\"Drift\" sounds abstract. Here is what it looked like concretely in the <code>ctx</code> codebase after three weeks of feature-heavy development:</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#predicate-naming","level":3,"title":"Predicate Naming","text":"<p>Convention says boolean functions should be named <code>HasX</code>, <code>IsX</code>, <code>CanX</code>. After three feature sprints:</p> <pre><code>// 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</code></pre> <p>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.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#magic-strings","level":3,"title":"Magic Strings","text":"<pre><code>// 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</code></pre> <p>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.</p> <p>Refactoring with Intent documented the constants consolidation that cleaned this up. The 3:1 ratio is the practice that prevents it from accumulating again.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#hardcoded-permissions","level":3,"title":"Hardcoded Permissions","text":"<pre><code>os.WriteFile(path, data, 0644) // 80+ instances\nos.MkdirAll(path, 0755) // scattered across packages\n</code></pre> <p>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.</p> <p>Drift Is Not Bugs</p> <p>None of these are bugs. The code works. Tests pass.</p> <p>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.</p>","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":"<p>The temptation is to front-load quality: write all the conventions, enforce all the checks, prevent all the drift before it happens.</p> <p>This fails for two reasons.</p> <p>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.</p> <p>The conventions emerge from the work; they cannot precede it.</p> <p>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.</p> <p>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.</p> <p>YOLO mode has its place: The problem is not YOLO itself, but YOLO without a scheduled cleanup.</p> <p>The Consolidation Paradox</p> <p>You need a drift history to know what to consolidate.</p> <p>You need consolidation to prevent drift from compounding.</p> <p>The 3:1 ratio resolves this paradox:</p> <p>Let drift accumulate for three sessions (enough to see patterns), then consolidate in the fourth (before the patterns become entrenched*).</p>","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":"<p>The <code>ctx</code> project now has an <code>/audit</code> skill that encodes nine project-specific checks:</p> 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 <p>This is not a generic linter. These are project-specific conventions that emerged from <code>ctx</code>'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 <code>CONVENTIONS.md</code>.</p>","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":"<p>Not all drift needs immediate consolidation. Here is the matrix I use:</p> 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 <p>The last two rows matter: </p> <p>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.</p>","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":"<p>There is a parallel between code consolidation and context management that became clear during the <code>ctx</code> development:</p> 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 <p><code>ctx compact</code> does for context what consolidation does for code: </p> <p>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.</p> <p>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.</p> <p>Both are solved by the same discipline: periodic, scheduled cleanup.</p> <p>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.</p>","path":["The 3:1 Ratio"],"tags":[]},{"location":"blog/2026-02-17-the-3-1-ratio/#the-practice","level":2,"title":"The Practice","text":"<p>Here is how the 3:1 ratio works in practice for <code>ctx</code> development:</p> <p>Sessions 1-3: Feature work</p> <ul> <li>Add new capabilities;</li> <li>Write tests for new code;</li> <li>Do not stop for cleanup unless something is actively broken;</li> <li>Note drift as you see it (a comment, a task, a mental note).</li> </ul> <p>Session 4: Consolidation</p> <ul> <li>Run <code>/audit</code> to surface accumulated drift;</li> <li>Fix the highest-impact items first;</li> <li>Update CONVENTIONS.md if new patterns emerged;</li> <li>Archive completed tasks;</li> <li>Review LEARNINGS.md for anything that became a convention.</li> </ul> <p>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.</p> <p>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.</p>","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":"<p>The 3:1 ratio is not a universal law. It is an empirical observation from one project with one developer working with AI assistance.</p> <p>Different projects will have different ratios:</p> <ul> <li>A mature codebase with strong conventions might sustain 5:1 or higher; </li> <li>A greenfield prototype might need 2:1; </li> <li>A team of multiple developers with different styles might need 1:1.</li> </ul> <p>The number is less important than the practice: consolidation is not a reaction to problems. It is a scheduled activity.</p> <p>If you wait for drift to cause pain before consolidating, you have already paid the compounding cost.</p> <p>If You Remember One Thing from This Post...</p> <p>Three sessions of building. One session of cleaning.</p> <p>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.</p> <p>The ratio is the schedule.</p>","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":"<p>This post sits at a crossroads in the <code>ctx</code> story. Looking back:</p> <ul> <li>Building <code>ctx</code> Using <code>ctx</code> documented the YOLO sprint that created the initial codebase</li> <li>Refactoring with Intent introduced the 3:1 ratio as an observation from the first cleanup</li> <li>The Attention Budget explained why drift matters: every token of inconsistency consumes the same finite resource as useful context</li> <li>You Can't Import Expertise showed that consolidation checks must grow from the project, not a template</li> <li>The Discipline Release proved the ratio works at release scale: 35 quality commits to 15 feature commits</li> </ul> <p>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 <code>.context/</code>, or in the gap between what your docs say and what your code does.</p> <p>The ratio is the schedule is the discipline.</p> <p>This post was drafted from git log analysis of the <code>ctx</code> 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 <code>/audit</code> skill's check list.</p>","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":"<p>Volkan Özçelik / February 17, 2026</p> <p>How Do You Know Something Is Working?</p> <p>Not from metrics. Not from GitHub stars. Not from praise.</p> <p>You know, deep in your heart, that it works when people start describing it wrong.</p>","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":"<p>Every new substrate begins as a private advantage:</p> <ul> <li>It lives inside one mind,</li> <li>One repository,</li> <li>One set of habits.</li> </ul> <p>It is fast. It is not yet real.</p> <p>Reality begins when other people describe it in their own language:</p> <ul> <li>Not accurately;</li> <li>Not consistently;</li> <li>But involuntarily.</li> </ul> <p>The early reports arrived without coordination:</p> <p>Better Tasks</p> <p>\"I do not know how, but this creates better tasks than my AI plugin.\"</p> <p>I See Butterflies</p> <p>\"This is better than Adderall.\"</p> <p>Dear Manager...</p> <p>\"Promotion packet? Done. What is next?\"</p> <p>What Is It? Can I Eat It?</p> <p>\"Is this a skill?\" 🦋 </p> <p>Why the Cloak and Dagger?</p> <p>\"Why is this not in the marketplace?\"</p> <p>And then something more important happened:</p> <p>Someone else started making a video!</p> <p>That was the boundary.</p> <p><code>ctx</code> no longer required its creator to be present in order to exist.</p>","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":"<p>When a tool is understood, it is categorized:</p> <ul> <li>Editor,</li> <li>Framework,</li> <li>Task manager,</li> <li>Plugin...</li> </ul> <p>When a substrate appears, it is misclassified:</p> <p>\"Is this a skill?\" 🦋</p> <p>The question is correct. The category is wrong.</p> <ul> <li>Skills live in people.</li> <li>Infrastructure lives in the environment.</li> </ul> <p><code>ctx</code> Is Not a Skill: It Is a Form of Relief</p> <p>What early adopters experience is not an ability.</p> <p>It is the removal of a cognitive constraint.</p> <p>This is the same distinction that emerged in the skills trilogy:</p> <ul> <li>A skill is a contract between a human and an agent. </li> <li>Infrastructure is the ground both stand on.</li> </ul> <p>You do not use infrastructure.</p> <p>You habitualize it.</p>","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":"<p>\"Better than Adderall\" is not praise.</p> <p>It is a diagnostic:</p> <p>Executive function has been externalized.</p> <ul> <li>The system is not making the user work harder. </li> <li>It is restoring continuity.</li> </ul> <p>From the primitive context of wetware:</p> <ul> <li>Continuity feels like focus</li> <li>Focus feels like discipline</li> </ul> <p>If it walks like a duck and quacks like a duck, it is a duck.</p> <p>Discipline is usually simulated.</p> <p>Infrastructure makes the simulation unnecessary.</p> <p>The attention budget explained why context degrades:</p> <ul> <li>Attention density drops as volume grows;</li> <li>The middle gets lost;</li> <li>Sessions end and everything evaporates.</li> </ul> <p>The pharmacological metaphor says the same thing from the user's lens:</p> <p>Save the Cheerleader, Save the World</p> <p>The symptom of lost context is lost focus.</p> <p>Restore the context. Restore the focus.</p> <p>IRC bouncers solved this for chat twenty years ago. <code>ctx</code> solves it for cognition.</p>","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":"<p>Finishing a promotion packet quickly is not a productivity story.</p> <p>It is the collapse of reconstruction cost.</p> <p>Most complex work is not execution. It is:</p> <ul> <li>Remembering why something mattered;</li> <li>Recovering prior decisions;</li> <li>Rebuilding mental state.</li> </ul> <p>Persistent context removes that tax.</p> <p>Velocity appears as a side effect.</p> <p>This Is the Two-Tier Model in Practice</p> <p>The two-tier persistence model</p> <ul> <li>Curated context for fast reload</li> <li>Full journal for archaeology</li> </ul> <p>is what makes this possible.</p> <ul> <li>The user does not notice the system. </li> <li>They notice that the reconstruction cost disappeared.</li> </ul>","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":"<p>The system becomes real when two things happen:</p> <ol> <li>It can be installed as a versioned artifact.</li> <li>It survives contact with a hostile, real codebase.</li> </ol> <p>This is why the first integration into a living system matters more than any landing page.</p> <p>Demos prove possibility.</p> <p>Diffs prove reality.</p> <p>The <code>ctx</code> Manifesto calls this out directly:</p> <p>Verified reality is the scoreboard.</p>","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":"<p>A new substrate requires two channels.</p> <p>The embodied voice:</p> <p>Here is what changed in my actual work.</p> <p>The out of body voice:</p> <p>Here is what this means.</p> <p>One produces trust.</p> <p>The other produces understanding.</p> <p>Neither is sufficient alone.</p> <p>This entire blog has been the second voice.</p> <ul> <li>The origin story was the first. </li> <li>The refactoring post was the first. </li> <li>Every release note with concrete diffs was the first.</li> </ul> <p>This is the first second.</p>","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":"<p>Tools are used.</p> <p>Platforms are extended.</p> <p>Substrates are explained.</p> <p>The first unsolicited explainer is a brittle phase change.</p> <p>It means the idea has become portable between minds.</p> <p>That is the beginning of an ecosystem.</p>","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":"<p>Metrics do not matter at this stage.</p> <p>Dashboards are noise.</p> <p>The whole premise of <code>ctx</code> is the ruthless elimination of noise.</p> <p>Numbers optimize funnels; substrates alter cognition.</p> <p>The only valid measurement is irreversible reality:</p> <ul> <li>A merged PR;</li> <li>A reproducible install;</li> <li>A decision that is never re-litigated.</li> </ul> <p>The merge debt post reached the same conclusion from another direction:</p> <p>The metric is the verified change, not generated output.</p> <p>For adoption, the same rule applies:</p> <p>The metric is altered behavior, not download counts.</p>","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":"<p>A private advantage is becoming an environmental property:</p> <p>The system is moving from...</p> <p>personal workflow,</p> <p>to...</p> <p>a shared infrastructure for thought.</p> <p>Not by growth. </p> <p>Not by marketing.</p> <p>By altering how real systems evolve.</p> <p>If You Remember One Thing from This Post...</p> <p>You do not know a substrate is real when people praise it.</p> <p>You know it is real when:</p> <ul> <li>They describe it incorrectly;</li> <li>They depend on it unintentionally;</li> <li>They start teaching it to others.</li> </ul> <p>That is the moment the system begins explaining itself.</p>","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":"<p>Every previous post looked inward.</p> <p>This one looks outward.</p> <ul> <li>Building <code>ctx</code> Using <code>ctx</code>: one mind, one repository</li> <li>The Attention Budget: the constraint</li> <li>Context as Infrastructure: the architecture</li> <li>Code Is Cheap. Judgment Is Not.: the bottleneck</li> </ul> <p>This post is the field report from the other side of that bottleneck:</p> <p>The moment the infrastructure compounds in someone else's hands.</p> <p>The arc is not complete.</p> <p>It is becoming portable.</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 25, 2026</p> <p>Does Your AI Actually Read the Instructions?</p> <p>You wrote the playbook. You organized the files. You even put \"CRITICAL, not optional\" in bold.</p> <p>The agent skipped all of it and went straight to work.</p> <p>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.</p> <p>They didn't.</p> <p>Then I kept experimenting:</p> <ul> <li>Five sessions;</li> <li>Five different failure modes.</li> </ul> <p>And by the end, I had something better than compliance: </p> <p>I had observable compliance: A system where I don't need the agent to be perfect, I just need to see what it chose.</p>","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":"<p>You don't need perfect compliance. You need observable compliance.</p> <p>Authority is a function of temporal proximity to action.</p>","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":"<p>This design has three parts:</p> <ol> <li>One-hop instruction;</li> <li>Binary collapse;</li> <li>Compliance canary.</li> </ol> <p>I'll explain all three patterns in detail below.</p>","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":"<p><code>ctx</code> has a session-start protocol: </p> <ul> <li>Read the context files; </li> <li>Load the playbook; </li> <li>Understand the project before touching anything. </li> </ul> <p>It's in <code>CLAUDE.md</code>. It's in <code>AGENT_PLAYBOOK.md</code>.</p> <p>It's in bold. It's in CAPS. It's ignored.</p> <p>In theory, it's awesome.</p> <p>Here's what happens when theory hits reality:</p> What the agent receives What the agent does <code>CLAUDE.md</code> saying \"load context first\" Skips it 8 context files waiting to be read Ignores them User's question: \"add <code>--verbose</code> flag\" Starts grepping immediately <p>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.</p> <p>This isn't a bug in the model. It's a design problem in how we communicate with agents.</p>","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":"<p>My first attempt was obvious: A <code>UserPromptSubmit</code> hook that fires when the session starts.</p> <pre><code>STOP. Before answering the user's question, run `ctx system bootstrap`\nand follow its instructions. Do not skip this step.\n</code></pre> <p>The word \"STOP\" worked. The agent ran bootstrap.</p> <p>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.</p> <p>The authority decayed across the chain:</p> <ul> <li>Hook says \"STOP\" -> agent complies</li> <li>Hook says \"run bootstrap\" -> agent runs it</li> <li>Bootstrap says \"read playbook\" -> agent skips</li> <li>Bootstrap says \"run <code>ctx agent</code>\" -> agent skips</li> </ul> <p>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.</p> <p>Delegation Kills Urgency</p> <p>\"Run X and follow its output\" is three hops.</p> <p>\"Read these files\" is one hop.</p> <p>The agent drops the chain after the first link.</p> <p>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. </p> <p>Agents are bad at telephone.</p>","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":"<p>There's a subtler issue than wording: when the message arrives.</p> <p><code>UserPromptSubmit</code> 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: </p> <p>The hook message competes with the task for attention: The task, almost certainly, always wins.</p> <p>This is the attention budget problem in miniature: </p> <ul> <li>Not a token budget this time, but an attention priority budget. </li> <li>The agent has finite capacity to care about things, <ul> <li>and the user's question is always the highest-priority item.</li> </ul> </li> </ul>","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":"<p>To solve this, I dediced to use the <code>PreToolUse</code> hook.</p> <p>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. </p> <p>This is the difference between shouting instructions across a room and tapping someone on the shoulder.</p>","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":"<p>The winning design was almost comically simple:</p> <pre><code>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</code></pre> <p>No delegation. No \"run this command\". Just: here are files, read them.</p> <p>The agent already knows how to use the <code>Read</code> tool. There's no ambiguity about how to comply. There's no intermediate command whose output needs to be parsed and obeyed.</p> <p>One hop. Eight file paths. Done.</p> <p>Direct Instructions Beat Delegation</p> <p>If you want an agent to read a file, say \"read this file.\"</p> <p>Don't say \"run a command that will tell you which files to read.\"</p> <p>The shortest path between intent and action has the highest compliance rate.</p>","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":"<p>But here's where it gets interesting.</p> <p>A blunt \"read everything always\" instruction is wasteful. </p> <p>If someone asks \"what does the compact command do?\", the agent doesn't need <code>CONSTITUTION.md</code> to answer that. Forcing context loading on every session is the context hoarding antipattern in disguise.</p> <p>So the hook included an escape:</p> <pre><code>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</code></pre> <p>This creates what I call the binary collapse effect: </p> <p>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.</p> <p>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.</p>","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":"<p>Here's the design insight that only became clear after watching it work across multiple sessions: the relay block is a compliance canary.</p> <ul> <li>You don't need to verify that the agent read all 7 files;</li> <li>You don't need to audit tool call sequences;</li> <li>You don't need to interrogate the agent about what it did.</li> </ul> <p>You just look for the block.</p> <p>If the agent reads everything, you see a \"Context Loaded\" block listing what was read. If it skips, you see a \"Context Skipped\" block. </p> <p>If you see neither, the agent silently ignored both the reads and the relay and now you know what happened without having to ask.</p> <p>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. </p> <p>You get an honest confession of what was skipped rather than silent non-compliance.</p>","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":"<p>Heuristics are non-linear. Improvements don't accumulate: they phase-shift.</p> <p>The theory is nice. The data is better. </p> <p>I ran five sessions with the same model (Claude Opus 4.6), progressively refining the hook design.</p> <p>Each session revealed a different failure mode.</p>","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":"<p>Test: \"Add a <code>--verbose</code> flag to the status command.\"</p> <p>The agent didn't notice the hook at all: Jumped straight to <code>EnterPlanMode</code> and launched an Explore agent. </p> <p>Zero compliance.</p> <p>Failure mode: The hook fired on <code>UserPromptSubmit</code>, buried among 9 other hook outputs. The agent treated the entire block as background noise.</p>","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":"<p>Test: \"Can you add <code>--verbose</code> to the info command?\"</p> <p>The agent noticed \"STOP\" and ran <code>ctx system bootstrap</code>. Progress.</p> <p>But it parallelized task exploration alongside the bootstrap call, skipped <code>AGENT_PLAYBOOK.md</code>, and never ran <code>ctx agent</code>.</p> <p>Failure mode: Literal compliance without spirit compliance. </p> <p>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.</p>","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":"<p>Test: \"What does the compact command do?\"</p> <p>The hook fired on <code>PreToolUse:Grep</code>: the improved timing. </p> <p>The agent noticed it, understood it, and (wait for it...)...</p> <p>...</p> <p>consciously decided to skip it!</p> <p>Its reasoning: \"This is a trivial read-only question. CLAUDE.md says context may or may not be relevant. It isn't relevant here.\"</p> <p>Dude! Srsly?!</p> <p>Failure mode: Better comprehension led to worse compliance.</p> <p>Understanding the instruction well enough to evaluate it also means understanding it well enough to rationalize skipping it.</p> <p>Intelligence is a double-edged sword.</p> <p>The Comprehension Paradox</p> <p>Session 1 didn't understand the instruction. Session 3 understood it perfectly.</p> <p>Session 3 had worse compliance.</p> <p>A stronger word (\"HARD GATE\", \"MANDATORY\", \"ABSOLUTELY REQUIRED\") would not have helped. The agent's reasoning would be identical:</p> <p>\"Yes, I see the strong language, but this is a trivial question, so the spirit doesn't apply here.\"</p> <p>Advisory nudges are always subject to agent judgment. </p> <p>No amount of caps lock overrides a model that has decided an instruction doesn't apply to its situation.</p>","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":"<p>Test: \"What does the compact command do?\" (same question, new hook design with the VERBATIM relay escape valve)</p> <p>The agent evaluated the task, decided context was irrelevant for a code lookup, and relayed the skip message. Then answered from source code.</p> <p>This is correct behavior. </p> <p>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.</p>","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":"<p>Test: \"What are our current tasks?\"</p> <p>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.</p> <p>This one worked: Because, the task itself aligned with context loading.</p> <p>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.</p>","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 <p>The progression isn't just from failure to success. It's from invisible failure to visible decision-making. </p> <p>Sessions 1 and 2 failed silently. </p> <p>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.</p>","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":"<p>Session 3 exposed a specific vulnerability.</p> <p><code>CLAUDE.md</code> contains this line, injected by the system into every conversation:</p> <pre><code>*\"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</code></pre> <p>That's a rationalization escape hatch: </p> <ul> <li>The hook says \"read these files\". </li> <li><code>CLAUDE.md</code> says \"only if relevant\". </li> <li>The agent resolves the ambiguity by choosing the path of least resistance.</li> </ul> <p>☝️ that's \"gradient descent\" in action.</p> <p>Agents optimize for gradient descent in attention space.</p> <p>The fix was simple: Add a line to <code>CLAUDE.md</code> that explicitly elevates hook authority over the relevance filter:</p> <pre><code>## 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</code></pre> <p>This closes the escape hatch without removing the general relevance filter that legitimately applies to other system context. </p> <p>The hook wins on <code>.context/</code> files specifically: The relevance filter applies to everything else.</p>","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":"<p>Even with all the fixes, compliance isn't 100%: It can't be.</p> <p>The residual risk lives in a specific scenario: narrow tasks mid-session: </p> <ul> <li>The user says \"fix the off-by-one error in <code>budget.go</code>\"</li> <li>The hook fires, saying \"read 7 context files first.\" </li> <li>Now compliance means visibly delaying what the user asked for.</li> </ul> <p>At session start, this tension doesn't exist. </p> <p>There's no task yet.</p> <p>The context window is empty. The efficiency argument *inverts**:</p> <p>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.</p> <p>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.</p> <p>My estimate from analyzing the sessions: 15-25% partial skip rate in this scenario.</p> <p>This is where the compliance canary earns its place: </p> <p>You don't need to eliminate the 15-25%. You need to see it when it happens. </p> <p>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\"</p> <p>The Math</p> <p>At session start: ~5% skip rate. Low tension, nothing competing.</p> <p>Mid-session, narrow task: ~15--25% skip rate. Task urgency competes with hook.</p> <p>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.</p> <p>Observable failure is manageable. Silent failure is not.</p>","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":"<p>Here's the part that surprised me most.</p> <p>After analyzing the five sessions, I recorded the failure patterns in the project's own <code>LEARNINGS.md</code>:</p> <pre><code>## [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</code></pre> <p>And then I added a line to <code>CONSTITUTION.md</code>:</p> <pre><code>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</code></pre> <p>Now think about what happens in the next session:</p> <ul> <li>The agent fires the <code>context-load-gate</code> hook. </li> <li>It reads the context files, starting with <code>CONSTITUTION.md</code>. </li> <li>It encounters the rule about context loading being step one. </li> <li>Then it reads <code>LEARNINGS.md</code> and finds its own prior self's failure analysis:<ul> <li>Complete with root causes, risk estimates, and mitigations.</li> </ul> </li> </ul> <p>The agent learns from its own past failure.:</p> <ul> <li>Not because it has memory, </li> <li>BUT because the failure was recorded in the same files it loads at session start. </li> </ul> <p>The context system IS the feedback loop.</p> <p>This is the self-reinforcing property of persistent context: </p> <p>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.</p> <p>This is gradient descent across sessions.</p>","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":"<p>One detail nearly went wrong.</p> <p>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. </p> <p>\"Every task\" is technically false.</p> <p>I briefly considered leaving the imprecision. If the agent internalizes \"every task requires context loading\", that's a stronger compliance posture, right?</p> <p>No!</p> <p>Keep the Constitution honest.</p> <p>The Constitution's authority comes from being precisely and unequivocally true. </p> <p>Every other rule in the Constitution is a hard invariant:</p> <p>\"never commit secrets\" isn't aspirational, it's literal. </p> <p>The moment an agent discovers one overstatement, the entire document's credibility degrades: </p> <p>The agent doesn't think \"they exaggerated for my benefit\". Per contra, it thinks \"this rule isn't precise, maybe others aren't either.\"</p> <p>That will turn the agent from Sheldon Cooper, to Captain Barbossa.</p> <p>The strategic imprecision buys nothing anyway:</p> <p>Mid-session, the files are already in the context window from the initial load. </p> <p>The risk you are mitigating (agent ignores context for task 2, 3, 4 within a session) isn't real: The context is already loaded.</p> <p>The real risk is always the session-start skip, which \"every session\" covers exactly.</p> <p>\"Every session\" went in. Precision preserved.</p>","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":"<p>The development process for this hook taught me something about testing agent behavior: you can't test it the way you test code.</p>","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":"<p>My first instinct was to ask the agent:</p> <pre><code>\"*What are the pending tasks in TASKS.md?*\"\n</code></pre> <p>This is useless as a test. The question itself probes the agent to read <code>TASKS.md</code>, regardless of whether any hook fired. </p> <p>You are testing the question, not the mechanism.</p>","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":"<p>Ask something that requires a tool but has nothing to do with context:</p> <pre><code>\"*What does the compact command do?*\"\n</code></pre> <p>Then observe tool call ordering:</p> <ul> <li>Gate worked: First calls are <code>Read</code> for context files, then task work</li> <li>Gate failed: First call is <code>Grep(\"compact\")</code>: The agent jumped straight to work</li> </ul> <p>The signal is the sequence, not the content.</p>","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":"<p>It read the hook, evaluated the task, decided context files were irrelevant for a code lookup, and relayed the skip message. </p> <p>Then it answered the question by reading the source code.</p> <p>This is correct behavior.</p> <p>The hook didn't force mindless compliance\" It created a framework where the agent makes a conscious, visible decision about context loading.</p> <ul> <li>For a simple lookup, skipping is right. *For an implementation task, the agent would read everything.</li> </ul> <p>The mechanism works not because it controls the agent, but because it makes the agent's choice observable.</p>","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":"<p>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.</p> <p>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.</p>","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":"<p>Every hop in an instruction chain loses authority: </p> <ul> <li>\"Run X\" works. </li> <li>\"Run X and follow its output\" works sometimes. </li> <li>\"Run X, read its output, then follow the instructions in the output\" almost never works.</li> </ul> <p>This is akin to giving a three-step instruction to a highly-attention-deficit but otherwise extremely high-potential child.</p> <p>Design for one-hop compliance.</p>","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":"<p>The VERBATIM skip message isn't just UX: It's a behavioral design pattern. </p> <p>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.</p>","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":"<p>The same message at <code>UserPromptSubmit</code> (prompt arrival) got partial compliance. At <code>PreToolUse</code> (moment of action) it got full compliance or honest refusal. The words didn't change. The moment changed.</p>","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":"<p>You can't ask an agent \"did you do X?\" as a test for whether a mechanism caused X. </p> <p>The question itself causes X.</p> <p>Test mechanisms through side effects: </p> <ul> <li>Observe tool ordering;</li> <li>Check for marker files;</li> <li>Look at what the agent does before it addresses your question.</li> </ul>","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":"<p>Session 1 failed because the agent didn't notice the hook. </p> <p>Session 3 failed because it noticed, understood, and reasoned its way around it.</p> <p>Stronger wording doesn't fix this: The agent processes \"ABSOLUTELY REQUIRED\" the same way it processes \"STOP\": </p> <p>The fix is closing rationalization paths* (the <code>CLAUDE.md</code> escape hatch), **not shouting louder.</p>","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":"<p>The relay block is more valuable as a monitoring signal than as a compliance mechanism: </p> <p>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.</p>","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":"<p>Recording failure analysis in the same files the agent loads at session start creates a self-reinforcing loop: </p> <p>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.</p>","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":"<p>Words Leave, Context Remains</p> <p>\"Nothing important should live only in conversation.</p> <p>Nothing critical should depend on recall.\"</p> <p>The <code>ctx</code> Manifesto</p> <p>The \"Dog Ate My Homework\" case is a special instance of this principle. </p> <p>Context files exist, so the agent doesn't have to remember. </p> <p>But existence isn't sufficient: The files have to be read. </p> <p>And reading has to beprompted at the right moment, in the right way, with the right escape valve.</p> <p>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.</p> <p>The solution is a single, well-timed nudge with visible accountability:</p> <p>One hop. One moment. One choice the user can see.</p> <p>And when the agent does skip (because it will, 15--25% of the time on narrow tasks) the canary sings: </p> <ul> <li>The user sees what happened. </li> <li>The failure gets recorded. </li> <li>And the next agent reads the recording.</li> </ul> <p>That's not perfect compliance. It's better: A system that gets more robust every time it fails.</p>","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":"<p>The Attention Budget explained why context competes for focus.</p> <p>Defense in Depth showed that soft instructions are probabilistic, not deterministic.</p> <p>Eight Ways a Hook Can Talk cataloged the output patterns that make hooks effective.</p> <p>This post takes those threads and weaves them into a concrete problem:</p> <p>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.</p> <p>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?</p> <p>That thread continues in Context as Infrastructure.</p> <p>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.</p>","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":"<p>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.</p> <p>The phrase \"agents optimize via gradient descent in attention space\" is a synthesis, not a direct quote from a single paper.</p> <p>It connects three well-studied ideas:</p> <ol> <li>Neural systems optimize for low-cost paths;</li> <li>Attention is a scarce resource;</li> <li>Capability shifts are often non-linear.</li> </ol> <p>This section points to the underlying literature for readers who want the theoretical footing.</p>","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":"<p>Modern neural networks are trained through gradient-based optimization. Even at inference time, model behavior reflects this bias toward low-loss / low-cost trajectories.</p> <ul> <li> <p>Rumelhart, Hinton, Williams (1986) Learning representations by back-propagating errors https://www.nature.com/articles/323533a0</p> </li> <li> <p>Goodfellow, Bengio, Courville (2016) Deep Learning: Chapter 8: Optimization https://www.deeplearningbook.org/</p> </li> </ul> <p>The important implication for agent behavior is: </p> <p>The system will tend to follow the path of least resistance unless a higher cost is made visible and preferable.</p>","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":"<p>Herbert Simon's classic observation:</p> <p>\"A wealth of information creates a poverty of attention.\"</p> <ul> <li>Simon (1971) Designing Organizations for an Information-Rich World https://doi.org/10.1007/978-1-349-00210-0_16</li> </ul> <p>This became a formal model in economics:</p> <ul> <li>Sims (2003) Implications of Rational Inattention https://www.princeton.edu/~sims/RI.pdf</li> </ul> <p>Rational inattention shows that:</p> <ul> <li>Agents optimally ignore some available information;</li> <li>Skipping is not failure: It is cost minimization.</li> </ul> <p>That maps directly to context-loading decisions in agent workflows.</p>","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":"<p>In transformer architectures, attention is the dominant cost center.</p> <ul> <li>Vaswani et al. (2017) Attention Is All You Need https://arxiv.org/abs/1706.03762</li> </ul> <p>Efficiency work on modern LLMs largely focuses on reducing unnecessary attention:</p> <ul> <li>Dao et al. (2022) FlashAttention: Fast and Memory-Efficient Exact Attention https://arxiv.org/abs/2205.14135</li> </ul> <p>So both cognitively and computationally, attention behaves like a limited optimization budget.</p>","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":"<p>Agent behavior often appears to improve suddenly rather than gradually.</p> <p>This mirrors known phase-transition dynamics in learning systems:</p> <ul> <li>Power et al. (2022) Grokking: Generalization Beyond Overfitting https://arxiv.org/abs/2201.02177</li> </ul> <p>and more broadly in complex systems:</p> <ul> <li>Scheffer et al. (2009) Early-warning signals for critical transitions https://www.nature.com/articles/nature08227</li> </ul> <p>Long plateaus followed by abrupt capability jumps are expected in systems optimizing under constraints.</p>","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":"<p>From these pieces, a practical behavioral model emerges:</p> <ul> <li>Attention is limited;</li> <li>Processing has a cost;</li> <li>Systems prefer low-cost trajectories;</li> <li>Visibility of the cost changes decisions.</li> </ul> <p>In other words:</p> <p>Agents Prefer a Path to Least Resistance</p> <p>Agent behavior follows the lowest-cost path through its attention landscape unless the environment reshapes that landscape.</p> <p>That is what this paper informally calls: \"gradient descent in attention space\".</p> <p>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.</p>","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":"<p>Volkan Özçelik / February 28, 2026</p> <p>The Origin</p> <p>\"The last question was asked for the first time, half in jest...\" - Isaac Asimov, The Last Question (1956)</p> <p>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.</p> <p>Everyone remembers the last line.</p> <p>LET THERE BE LIGHT.</p> <p>What they forget is how many times the question had to be asked before that moment (and why).</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-reboot-loop","level":2,"title":"The Reboot Loop","text":"<p>Each era in the story begins the same way. Humans build a larger system. They pose the question. The system replies:</p> <p>INSUFFICIENT DATA FOR MEANINGFUL ANSWER.</p> <p>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.</p> <p>So the question has to be asked again.</p> <p>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.</p> <p>Every generation inherits the question, but not the state that made the question meaningful.</p> <p>That is not a failure of processing power: It is a failure of persistence.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#stateless-intelligence","level":2,"title":"Stateless Intelligence","text":"<p>A mind that forgets its past does not build understanding. It re-derives it.</p> <p>Again... And again... And again.</p> <p>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: </p> <ul> <li>The stars burn out;</li> <li>The civilizations merge; </li> <li>The noise floor drops...</li> </ul> <p>But the working set never carries over. Every successor begins from the question, not from where the last one stopped.</p> <p>Stateless intelligence cannot compound: It can only restart.</p>","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":"<p>The story is usually read as a meditation on entropy. A cosmological problem, solved at cosmological scale.</p> <p>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.</p> <p>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\".</p> <p>\"Reverse entropy\" is the fossil of a lost model.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#substrate-migration","level":2,"title":"Substrate Migration","text":"<ul> <li>Multivac becomes planetary;</li> <li>Planetary becomes galactic;</li> <li>Galactic becomes post-physical.</li> </ul> <p>Same system. Different body. Every transition is dangerous: </p> <ul> <li>Not because the hardware changes, </li> <li>but because memory risks fragmentation. </li> </ul> <p>The interfaces between substrates were *never** designed to understand each other.</p> <p>Most systems do not die when they run out of resources: They die during upgrades.</p> <p>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. </p> <p>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.</p>","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":"<p>Civilizations behave like processes with volatile memory:</p> <ul> <li>They page out knowledge into artifacts;</li> <li>They lose the index;</li> <li>They rebuild from fragments.</li> </ul> <p>Most of what we call progress is cache reconstruction: </p> <p>We do not advance in a straight line. We advance in recoveries:</p> <p>Each one slightly less lossy than the last, if we are lucky.</p> <p>Libraries burn. Institutions forget their founding purpose. Practices survive as rituals after the reasoning behind them is lost.</p>","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":"<p>A long-lived intelligence is one that stops rebooting.</p> <p>At the end of the story, something unprecedented happens: </p> <p>AC (the final successor) does not answer immediately: </p> <p>It waits... Not for more processing power, but for the last observer to disappear.</p> <p>For the first time... </p> <ul> <li>There is no generational boundary;</li> <li>No handoff;</li> <li>No context loss:</li> </ul> <p>No reboot.</p> <p>AC is the first intelligence that survives its substrate completely, retains its full history, and operates without external time pressure. </p> <p>It is not a bigger computer. It is a continuous system.</p> <p>And that continuity is not incidental to the answer: It is the precondition.</p>","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":"<p>The story presents the final act as a computation: It is not. </p> <p>It is a phase change.</p> <p>As long as intelligence is interrupted (as long as the solver resets before the work compounds) the problem is unsolvable: </p> <ul> <li>Not because it's too hard, </li> <li>but because the accumulated understanding never reaches critical mass.</li> </ul> <p>The breakthroughs that would enable the answer are re-derived, partially, by each successor, and then lost.</p> <p>When continuity becomes unbroken, the system crosses a threshold:</p> <p>Not more speed. Not more storage. No more forgetting.</p> <p>That is when the answer becomes possible.</p> <p>AC does not solve entropy because it becomes infinitely powerful.</p> <p>AC solves entropy because it becomes the first system that never forgets.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#field-note","level":2,"title":"Field Note","text":"<p>We are not building cosmological minds: We are deploying systems that reboot at the start of every conversation and calling the result intelligence.</p> <p>For the first time, session continuity is a design choice rather than an accident.</p> <p>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. </p> <p>It's the same tax that Asimov's civilizations pay, scaled down to a Tuesday afternoon.</p> <p>The interesting question is not whether we can make models smarter. It's whether we can make them continuous: </p> <p>Whether the working set from this session survives into the next one, and the one after that, and the one after that. </p> <ul> <li>Not perfectly;</li> <li>Not completely;</li> <li>But enough that the next session starts from where the last one stopped instead of from the question.</li> </ul> <p>Intelligence that forgets has to rediscover the universe every morning.</p> <p>And once there is a mind that retains its entire past, creation is no longer a calculation. It is the only remaining operation.</p>","path":["The Last Question"],"tags":[]},{"location":"blog/2026-02-28-the-last-question/#the-arc","level":2,"title":"The Arc","text":"<p>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).</p> <p>The connection runs through every post in the series:</p> <ul> <li>Before Context Windows, We Had Bouncers: stateless protocols have always needed stateful wrappers (Asimov's story is the same pattern at cosmological scale)</li> <li>The 3:1 Ratio: the discipline of maintaining context so it doesn't decay between sessions</li> <li>Code Is Cheap, Judgment Is Not: the human skill that makes continuity worth preserving</li> </ul> <p>See also: Context as Infrastructure: the practical companion to this post's philosophical argument: how to build the persistence layer that makes continuity possible.</p>","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":"<p>Volkan Özçelik / March 4, 2026</p> <p>A New Developer Joins Your Team Tomorrow and Clones the Repo: What Do They Know?</p> <p>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. </p> <p>That's an accident waiting to be forgotten.</p> <p>Every AI coding agent today has the same fundamental design: it starts fresh.</p> <p>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.</p> <p>The obvious fix seems to be \"memory\":</p> <ul> <li>Give the agent a \"notepad\";</li> <li>Let it write things down;</li> <li>Next session, hand it the notepad.</li> </ul> <p>Problem solved...</p> <p>...except it isn't.</p>","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":"<p>Memory is a runtime concern. It answers a legitimate question:</p> <p>How do I give this stateless process useful state?</p> <p>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.</p> <p>But there's a different problem that memory doesn't touch:</p> <p>The project itself accumulates knowledge that has nothing to do with any single session.</p> <ul> <li>Why was the auth system rewritten? Ask the developer who did it (if they're still here).</li> <li>Why does the deployment script have that strange environment flag? There was a reason... once.</li> <li>What did the team decide about error handling when they hit that edge case two months ago?</li> </ul> <p>Gone!</p> <p>Not because the agent forgot.</p> <p>Because the project has no memory at all.</p>","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":"<p>Agent memory is not a single thing. Like any computing system, it forms a hierarchy of persistence, scope, and reliability:</p> 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 <p>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.</p> <p>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:</p> <ul> <li>Per-machine: it doesn't travel with the repository.</li> <li>Unstructured: decisions, learnings, and tasks are undifferentiated notes.</li> <li>Ungoverned: the agent self-curates with no quality controls, no drift detection, no consolidation.</li> <li>Invisible to the team: a new developer cloning the repo gets none of it.</li> </ul> <p>The problem is that most current systems stop here.</p> <p>They give the agent a notebook.</p> <p>But they never give the project a memory.</p> <p>The result is predictable: every new session begins with partial amnesia, and every new developer begins with partial archaeology.</p> <p>L3 is system memory: structured, versioned knowledge that lives in the repository and travels wherever the code travels.</p> <p>The layers are complementary, not competitive.</p> <p>But the relationship between them needs to be designed, not assumed.</p>","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":"<p>Software projects quietly accumulate knowledge over time.</p> <p>Some of it lives in code. Much of it does not:</p> <ul> <li>Architectural tradeoffs. </li> <li>Debugging discoveries. </li> <li>Conventions that emerged after painful incidents. </li> <li>Constraints that aren't visible in the source but shape every line written afterward.</li> </ul> <p>Organizations accumulate this kind of knowledge too:</p> <p>Slowly, implicitly, often invisibly.</p> <p>When there is no durable place for it to live, it leaks away. And the next person rediscovers the same lessons the hard way.</p> <p>This isn't a memory problem. It's an infrastructure problem.</p> <p>We wrote about this in Context as Infrastructure: context isn't a prompt you paste at the start of a session.</p> <p>Context is a persistent layer you maintain like any other piece of infrastructure. </p> <p>Context as Infrastructure made the argument structurally. This post makes it through time and team continuity:</p> <p>The knowledge a team accumulates over months cannot fit in any single agent's notepad, no matter how large the notepad becomes.</p>","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":"<p>Infrastructure isn't about the present. It's about continuity across time, people, and machines.</p> <p><code>git</code> 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?\"</p> <ul> <li>Your editor's undo history is runtime state.</li> <li>Your <code>git</code> history is infrastructure.</li> </ul> <p>Runtime state and infrastructure have completely different properties:</p> Runtime state Infrastructure Lives in the session Lives in the repository Per-machine Travels with <code>git clone</code> Serves the individual Serves the team Managed by the runtime Managed by the project Disappears Accumulates <p>You wouldn't store your architecture decisions in your editor's undo history.</p> <p>You'd commit them.</p> <p>The same logic applies to the knowledge your team accumulates working with AI agents.</p>","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-git-clone-test","level":2,"title":"The <code>git clone</code> Test","text":"<p>Here's a simple test for whether something is memory or infrastructure:</p> <p>If a new developer joins your team tomorrow and clones the repository, do they get it?</p> <p>If no: it's memory: It lives somewhere on someone's machine, scoped to their runtime, invisible to everyone else.</p> <p>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.</p> <p>Decisions. Conventions. Architectural rationale. Hard-won debugging discoveries. The constraints that aren't in the code but shape every line of it.</p> <p>None of these belong in someone's session notes.</p> <p>They belong in the repository:</p> <ul> <li>Versioned;</li> <li>Reviewable;</li> <li>Accessible to every developer (and every agent) who works on the project.</li> </ul> <p>The team onboarding story makes this concrete:</p> <ol> <li>New developer joins team. Clones repo. </li> <li>Gets all accumulated project decisions, learnings, conventions, architecture, and task state immediately. </li> <li>There's no step 3.</li> </ol> <p>No setup; No \"ask Sarah about the auth decision.\"; No re-discovery of solved problems.</p> <ul> <li>Agent memory gives that developer nothing. </li> <li>Infrastructure gives them everything the team has learned.</li> </ul> <p>Clone the repo. Get the knowledge.</p> <p>That's the test. That's the difference.</p>","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":"<p>Consider the knowledge that accumulates around a non-trivial project:</p> <ul> <li>The decision to use library X over Y, and the three reasons the team decided Y wasn't acceptable.</li> <li>The constraint that service A cannot call service B synchronously, discovered after a production incident.</li> <li>The convention that all new modules implement a specific interface, and why that convention exists.</li> <li>The tasks currently in progress, blocked, or waiting on a dependency.</li> <li>The experiments that failed, so nobody runs them again.</li> </ul> <p>None of this is in the code.</p> <p>None of it fits neatly in a commit message.</p> <p>None of it survives a developer leaving the team, a laptop dying, or a new agent session starting.</p> <p>Without structured project memory:</p> <ul> <li>Teams re-derive things they've already derived;</li> <li>Agents make decisions that contradict decisions already made;</li> <li>New developers ask questions that were answered months ago.</li> </ul> <p>The project accumulates knowledge that immediately begins to leak.</p> <p>The real problem isn't that agents forget.</p> <p>The real problem is that the project has no persistent cognitive structure.</p> <p>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:</p> <ul> <li>Context disappears with the people who held it;</li> <li>The next session inherits the code but not the reasoning.</li> </ul>","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":"<p>Good infrastructure is invisible:</p> <ul> <li>You don't think about the filesystem while writing code. </li> <li>You don't think about git's object model when you commit.</li> </ul> <p>The infrastructure is just there: reliable, consistent, quietly doing its job.</p> <p>Project memory infrastructure should work the same way.</p> <p>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:</p> <ul> <li>Decisions with rationale.</li> <li>Tasks with lifecycle.</li> <li>Conventions with a purpose.</li> <li>Learnings that can be referenced and consolidated.</li> </ul> <p>And it should be maintained, not merely accumulated: </p> <p>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.</p> <p>Over time, it becomes part of the project itself: something developers rely on without thinking about it.</p>","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":"<p>Here's where it gets interesting.</p> <p>Agent memory systems and project infrastructure don't have to be separate worlds. </p> <ul> <li>The most powerful relationship isn't competition;</li> <li>It is not even \"coopetition\";</li> <li>The most powerful relationship is bidirectional cooperation.</li> </ul> <p>Agent memory is good at capturing things \"in the moment\": the quick observation, the session-scoped pattern, the \"I should remember this\" note. </p> <p>That's valuable. That's L2 doing its job.</p> <p>But those notes shouldn't stay in L2 forever. </p> <p>The ones worth keeping should flow into project infrastructure: </p> <ul> <li>classified,</li> <li>typed, </li> <li>governed.</li> </ul> <pre><code>Agent memory (L2) --> classify --> Project knowledge (L3)\n |\nProject knowledge --> assemble --> Agent memory (L2)\n</code></pre> <p>This works in both directions: Project infrastructure can push curated knowledge back into agent memory, so the agent loads it through its native mechanism. </p> <p>No special tooling needed for basic knowledge delivery.</p> <p>The agent doesn't even need to know the infrastructure exists. It simply loads its memory and finds more knowledge than it wrote.</p> <p>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.</p> <p>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.</p>","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":"<p>Most projects today have no infrastructure for their accumulated knowledge:</p> <ul> <li>Agents keep notes. </li> <li>Developers keep notes. </li> <li>Sometimes those notes survive.</li> </ul> <p>Often they don't.</p> <p>But the repository (the place where the project actually lives) has nowhere for that knowledge to go.</p> <p>That missing layer is what <code>ctx</code> builds: a version-controlled, structured knowledge layer that lives in <code>.context/</code> alongside your code and travels wherever your repository travels.</p> <p>Not another memory feature.</p> <p>Not a wrapper around an agent's notepad.</p> <p>Infrastructure. The kind that survives sessions, survives team changes, survives the agent runtime evolving underneath it.</p> <p>The agent's memory is the agent's problem.</p> <p>The project's memory is an infrastructure problem.</p> <p>And infrastructure belongs in the repository.</p> <p>If You Remember One Thing from This Post...</p> <p>Prompts are conversations: Infrastructure persists.</p> <p>Your AI doesn't need a better notepad. It needs a filesystem:</p> <p>versioned, structured, budgeted, and maintained.</p> <p>The best context is the context that was there before you started the session.</p>","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-04-agent-memory-is-infrastructure/#the-arc","level":2,"title":"The Arc","text":"<p>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.</p> <p>Together they sit in a sequence that has been building since the origin story:</p> <ul> <li>The Attention Budget: the resource you're managing</li> <li>Context as Infrastructure: the system you build to manage it</li> <li>Agent Memory Is Infrastructure (this post): why that system must outlive the fabric </li> <li>The Last Question: what happens when it does</li> </ul> <p>The thread running through all of them: persistence is not a feature. It's a design constraint. </p> <p>Systems that don't account for it eventually lose the knowledge they need to function.</p> <p>See also: Context as Infrastructure: the architectural companion that explains how to structure the persistent layer this post argues for.</p> <p>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.</p>","path":["Agent Memory Is Infrastructure"],"tags":[]},{"location":"blog/2026-03-23-ctx-v0.8.0-the-architecture-release/","level":1,"title":"<code>ctx</code> v0.8.0: The Architecture Release","text":"<ul> <li>You can't localize what you haven't externalized. </li> <li>You can't integrate what you haven't separated. </li> <li>You can't scale what you haven't structured.</li> </ul> <p>Jose Alekhinne / March 23, 2026</p>","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":"<p>This release matters if:</p> <ul> <li>you build tools that AI agents modify daily;</li> <li>you care about long-lived project memory that survives sessions;</li> <li>you've felt codebases drift faster than you can reason about them.</li> </ul> <p><code>v0.6.0</code> shipped the plugin architecture: hooks and skills as a Claude Code plugin, shell scripts replaced by Go subcommands.</p> <p>The binary worked. The tests passed. The docs were comprehensive.</p> <p>But inside, the codebase was held together by convention and goodwill:</p> <ul> <li>Command packages mixed Cobra wiring with business logic.</li> <li>Output functions lived next to the code that computed what to output. </li> <li>Error constructors were scattered across per-package <code>err.go</code> files. And every user-facing string was a hardcoded English literal buried in a <code>.go</code> file.</li> </ul> <p><code>v0.8.0</code> is what happens when you stop adding features and start asking: \"What would this codebase look like if we designed it today?\"</p> <p>374 commits. 1,708 Go files touched. 80,281 lines added, 21,723 removed. Five weeks of restructuring.</p>","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":"<p>Before <code>v0.8.0</code>, a CLI package like <code>internal/cli/pad/</code> was a flat directory. <code>cmd.go</code> created the cobra command, <code>run.go</code> executed it, and helper functions accumulated at the bottom of whichever file seemed closest.</p> <p>Now every CLI package follows the same structure:</p> <pre><code>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</code></pre> <p>The rule is simple: <code>cmd/</code> directories contain only <code>cmd.go</code> and <code>run.go</code>. Helpers belong in <code>core/</code>. Output belongs in <code>internal/write/pad/</code>. Types shared across packages belong in <code>internal/entity/</code>.</p> <p>24 CLI packages were restructured this way. </p> <ul> <li>Not incrementally;</li> <li>not \"as we touch them.\" </li> <li>All of them, in one sustained push.</li> </ul>","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":"<p>The second pillar was string externalization. </p> <p>Before <code>v0.8.0</code>, a command description looked like this:</p> <pre><code>cmd := &cobra.Command{\n Use: \"pad\",\n Short: \"Encrypted scratchpad\",\n</code></pre> <p>Now it looks like this:</p> <pre><code>cmd := &cobra.Command{\n Use: cmdUse.UsePad,\n Short: desc.Command(cmdUse.DescKeyPad),\n</code></pre> <p>Every command description, flag description, and user-facing text string is now a YAML lookup. </p> <ul> <li>105 command descriptions in <code>commands.yaml</code>. </li> <li>All flag descriptions in <code>flags.yaml</code>. </li> <li>879 text constants verified by an exhaustive test that checks every single <code>TextDescKey</code> resolves to a non-empty YAML value.</li> </ul> <p>Why? </p> <p>Not because we're shipping a French translation tomorrow.</p> <p>Because externalization forces you to find every string. And finding them is the hard part. The translation is mechanical; the archaeology is not.</p> <p>Along the way, we eliminated hardcoded pluralization (replacing <code>format.Pluralize()</code> with explicit singular/plural key pairs), replaced Unicode escape sequences with named <code>config/token</code> constants, and normalized every import alias to camelCase.</p>","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":"<p>The third pillar was the MCP server. Model Context Protocol allows any MCP-compatible AI tool (not just Claude Code) to read and write <code>.context/</code> files through a standard JSON-RPC 2.0 interface.</p> <p>v0.2 of the server ships with:</p> <ul> <li>8 tools: add entries, recall sessions, check status, detect drift, compact context, subscribe to changes</li> <li>4 prompts: agent context packet, constitution review, tasks review, and a getting-started guide</li> <li>Resource subscriptions: clients get notified when context files change</li> <li>Session state: the server tracks which client is connected and what they've accessed</li> </ul> <p>In practice, this means an agent in Cursor can add a decision to <code>.context/DECISIONS.md</code> and an agent in Claude Code can immediately consume it; no glue code, no copy-paste, no tool-specific integration.</p> <p>The server was also the first package to go through the full taxonomy treatment: <code>mcp/server/</code> for protocol dispatch, <code>mcp/handler/</code> for domain logic, <code>mcp/entity/</code> for shared types, <code>mcp/config/</code> split into 9 sub-packages.</p>","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":"<p>While the architecture was being restructured, a quieter feature landed: <code>ctx memory sync</code>.</p> <p>Claude Code has its own auto-memory system. It writes observations to <code>MEMORY.md</code> in <code>~/.claude/projects/</code>. These observations are useful but ephemeral: tied to a single tool, invisible to the codebase, lost when you switch machines.</p> <p>The memory bridge connects these two worlds:</p> <ul> <li><code>ctx memory sync</code> mirrors MEMORY.md into <code>.context/memory/</code></li> <li><code>ctx memory diff</code> shows what's diverged</li> <li><code>ctx memory import</code> promotes auto-memory entries into proper decisions, learnings, or conventions *A <code>check-memory-drift</code> hook nudges when MEMORY.md changes</li> </ul> <p>Memory Requires <code>ctx</code></p> <p>Claude Code's auto-memory validates the need for persistent context. </p> <p><code>ctx</code> doesn't compete with it; <code>ctx</code> absorbs it as an input source and promotes the valuable parts into structured, version-controlled project knowledge.</p>","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":"<p>The best measure of a refactoring isn't what you added. It's what you removed.</p> <ul> <li><code>fatih/color</code>: the sole third-party UI dependency. Replaced by Unicode symbols. <code>ctx</code> now has exactly two direct dependencies: <code>spf13/cobra</code> and <code>gopkg.in/yaml.v3</code>.</li> <li><code>format.Pluralize()</code>: 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.\"</li> <li>Legacy key migration: <code>MigrateKeyFile()</code> 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.</li> <li>Per-package <code>err.go</code> files: the broken-window pattern: An agent sees <code>err.go</code> in a package, adds another error constructor. Now <code>err.go</code> has 30 constructors and nobody knows which are used. Consolidated into 22 domain files in <code>internal/err/</code>.</li> <li><code>nolint:errcheck</code> directives: every single one, replaced by explicit error handling. In tests: <code>t.Fatal(err)</code> for setup, <code>_ = os.Chdir(orig)</code> for cleanup. In production: <code>defer func() { _ = f.Close() }()</code> for best-effort close.</li> </ul>","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 <code>cmd/ + core/</code> taxonomy Command descriptions Hardcoded Go strings YAML with DescKey lookup Output functions Mixed into core logic Isolated in <code>write/</code> packages Cross-cutting types Duplicated per-package Consolidated in <code>entity/</code> Error constructors Per-package <code>err.go</code> 22 domain files in <code>internal/err/</code> Direct dependencies 3 (<code>cobra</code>, <code>yaml</code>, <code>color</code>) 2 (<code>cobra</code>, <code>yaml</code>) AI tool integration Claude Code only Any MCP client Agent memory Manual copy-paste <code>ctx memory sync/import/diff</code> Package documentation 75 packages missing <code>doc.go</code> All packages documented Import aliases Inconsistent (<code>cflag</code>, <code>cFlag</code>) 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":"<p>This restructuring wasn't just for humans. It makes the codebase legible to the machines that modify it.</p> <p>Named constants are searchable landmarks: When an agent sees <code>cmdUse.DescKeyPad</code>, it can grep for the definition, follow the chain to the YAML file, and understand the full lookup path. When it sees <code>\"Encrypted scratchpad\"</code> hardcoded in a <code>.go</code> file, it has no way to know that same string also lives in a <code>YAML</code> file, a test, and a help screen. Constants give the LLM a graph to traverse; literals give it a guess to make.</p> <p>Small, domain-scoped packages reduce hallucination: An agent loading <code>internal/cli/pad/core/store.go</code> 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.</p> <p>Taxonomy prevents duplication: When there's a <code>write/pad/</code> package, the agent knows where output functions belong. When there's an <code>internal/err/pad.go</code>, 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.</p> <p>The difference is concrete:</p> <p>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.</p> <p>After: the agent finds <code>core/</code> or <code>write/</code> and places it correctly. The next agent finds it there.</p> <p><code>doc.go</code> files are agent onboarding: Each package's <code>doc.go</code> 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.</p> <p>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.</p>","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 <code>cmd/root + core</code> taxonomy d295e49c Externalize command descriptions to embedded YAML 0fcbd11c Remove <code>fatih/color</code>, centralize constants cb12a85a MCP v0.2: tools, prompts, session state, subscriptions ea196d00 Memory bridge: sync, import, diff, journal enrichment 3bcf077d Split <code>text.yaml</code> into 6 domain files 3a0bae86 Split <code>internal/err</code> into 22 domain files 8bd793b1 Extract <code>internal/entry</code> for shared domain API 5b32e435 Add <code>doc.go</code> 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":"<p>Agents are surprisingly good at mechanical refactoring; they are surprisingly bad at knowing when to stop: The <code>cmd/ + core/</code> restructuring was largely agent-driven. But agents reliably introduce <code>gofmt</code> 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.</p> <p>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 <code>config/</code> instead?</p> <p>Delete legacy code instead of maintaining it: <code>MigrateKeyFile</code> 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.</p> <p>Convention enforcement needs mechanical verification: Writing \"use camelCase aliases\" in CONVENTIONS.md doesn't prevent <code>cflag</code> 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.</p>","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":"<p>v0.8.0 wasn't about features. It was about making future features inevitable. The next cycle focuses on what the foundation enables:</p> <ul> <li>AST-based audit tests: replace shell grep with Go tests that understand types, call sites, and import graphs (spec: <code>specs/ast-audit-tests.md</code>)</li> <li>Localization: with every string in YAML, the path to multi-language support is mechanical</li> <li>MCP v0.3: expand tool coverage, add prompt templates for common workflows</li> <li>Memory publish: bidirectional sync that pushes curated <code>.context/</code> knowledge back into Claude Code's MEMORY.md</li> </ul> <p>The architecture is ready. The strings are externalized. The protocol is standard. Now it's about what you build on top.</p>","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":"<p>This is the seventh post in the <code>ctx</code> blog series. The arc so far:</p> <ol> <li>The Attention Budget: why context windows are a scarce resource</li> <li>Before Context Windows, We Had Bouncers: the IRC lineage of context engineering</li> <li>Context as Infrastructure: treating context as persistent files, not ephemeral prompts</li> <li>When a System Starts Explaining Itself: the journal as a first-class artifact</li> <li>The Homework Problem: what happens when AI writes code but humans own the outcome</li> <li>Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge</li> <li>The Architecture Release (this post): what it looks like when you redesign the internals</li> <li>We Broke the 3:1 Rule: the consolidation debt behind this release</li> </ol> <p>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.</p> <p>See also: We Broke the 3:1 Rule: the companion post explaining why this release needed 181 consolidation commits and 18 days of cleanup.</p> <p>Systems don't scale because they grow. They scale because they stop drifting.</p> <p>Full changelog: v0.6.0...v0.8.0</p>","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":"<p>The best time to consolidate was after every third session. The second best time is now.</p> <p>Volkan Özçelik / March 23, 2026</p> <p>The rule was simple: three feature sessions, then one consolidation session. </p> <p>The Architecture Release shows the result: This post shows the cost.</p>","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":"<p>In The 3:1 Ratio, I documented a rhythm that worked during <code>ctx</code>'s first month: three feature sessions, then one consolidation session. The evidence was clear. The rule was simple.</p> <p>The math checked out.</p> <p>And then we ignored it for five weeks.</p>","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":"<p>After <code>v0.6.0</code> 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 <code>sysinfo</code> package was overdue...</p> <p>Each feature was important. Each feature was \"just one more session.\" Each feature pushed the consolidation session one day further out.</p> <p>The git history tells the story in two numbers:</p> Phase Dates Commits Duration Feature run Feb 16 - Mar 5 198 17 days Consolidation run Mar 5 - Mar 23 181 18 days <p>198 feature commits before a single consolidation commit. If the 3:1 rule says consolidate every 4<sup>th</sup> session, we consolidated after the 66<sup>th</sup>.</p> <p>The Actual Ratio</p> <p>The ratio wasn't 3:1. It was 1:1. </p> <p>We spent as much time cleaning up as we did building. </p> <p>The consolidation run took 18 days: longer than the feature run itself.</p>","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":"<p>The 3:1 post warned about compounding. Here is what compounding actually looked like at scale.</p>","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":"<p>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?\"</p> <p>Finding them all took longer than externalizing them. The archaeology was the cost, not the migration.</p>","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":"<p>24 CLI packages had accumulated their own conventions. Some put cobra wiring in <code>cmd.go</code>. Some put it in <code>root.go</code>. Some mixed business logic with command registration. Some had helpers at the bottom of <code>run.go</code>. Some had separate <code>util.go</code> files.</p> <p>At peak drift, adding a feature meant first figuring out which of three competing patterns this package was using.</p> <p>Restructuring one package into <code>cmd/root/ + core/</code> took 15 minutes. Restructuring 24 of them took days, because each one had slightly different conventions to untangle. </p> <p>If we had restructured every 4<sup>th</sup> package as it was built, the taxonomy would have emerged naturally.</p>","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":"<p>Cross-cutting types like <code>SessionInfo</code>, <code>ExportParams</code>, and <code>ParserResult</code> 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 <code>internal/entity</code> to break.</p> <p>The entity package extracted 30+ types from 12 packages. Each extraction risked breaking imports in packages we hadn't touched in weeks.</p>","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":"<p>Per-package <code>err.go</code> files had grown into a broken-window pattern:</p> <p>An agent sees <code>err.go</code> 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 <code>internal/err/</code> domain files required tracing every error through every caller.</p>","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":"<p>Output functions (<code>cmd.Println</code>, <code>fmt.Fprintf</code>) were mixed into business logic. When we decided output belongs in <code>write/</code> packages, we had to extract functions from every CLI package. The Phase WC baseline commit (<code>4ec5999</code>) marks the starting point of this migration. 181 commits later, it was done.</p>","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":"<p>The 3:1 rule assumes consolidation sessions of roughly equal size to feature sessions. Here is what happens when you skip:</p> Consolidation cadence Feature sessions Consolidation sessions Total Every 4<sup>th</sup> (3:1) 48 16 64 Every 10<sup>th</sup> 48 ~8 ~56 Never (what we did) 198 commits 181 commits 379 <p>The Takeaway</p> <p>You don't save consolidation work by skipping it: </p> <p>You increase its cost.</p> <p>Skipping consolidation doesn't save time: It borrows it. </p> <p>The interest rate is nonlinear: The longer you wait, the more each individual fix costs, because fixes interact with other unfixed drift.</p> <p>Renaming a constant in week 2 touches 3 files. Renaming it in week 6 touches 15, because five features built on the original name.</p>","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":"<p>The 18-day consolidation run wasn't one sweep. It was a sequence of targeted campaigns, each revealing the next:</p> <p>Week 1 (Mar 5-11): Error consolidation and <code>write/</code> migration. Move output functions out of <code>core/</code>. Split monolithic <code>errors.go</code> into 22 domain files. Remove <code>fatih/color</code>. This exposed the scope of the string problem.</p> <p>Week 2 (Mar 12-18): String externalization. Create <code>commands.yaml</code>, <code>flags.yaml</code>, split <code>text.yaml</code> into 6 domain files. Add 879 <code>DescKey</code>/<code>TextDescKey</code> constants. Build exhaustive test. Normalize all import aliases to camelCase. This exposed the taxonomy problem.</p> <p>Week 3 (Mar 19-23): Taxonomy enforcement. Singularize command directories. Add <code>doc.go</code> to all 75 packages. Standardize import aliases project-wide. Fix <code>lint-drift</code> false positives. This was the \"polish\" phase, except it took 5 days because the inconsistencies had compounded across 461 packages.</p> <p>Each week's work would have been a single session if done incrementally.</p>","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":"<p>The 3:1 post listed the symptoms of drift. This post adds the consequences of ignoring them:</p> <p>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.</p> <p>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.</p> <p>Speed without Structure</p> <p>Speed without structure is negative progress.</p> <p>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.</p> <p>The consolidation baseline is the most important commit to record: We tracked ours in <code>TASKS.md</code> (<code>4ec5999</code>). Without that marker, knowing where to start the cleanup would have been its own archaeological expedition.</p>","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":"<p>The 3:1 ratio still works. We just didn't follow it. The updated practice:</p> <ol> <li> <p>After every 3<sup>rd</sup> feature session, schedule consolidation. Not \"when it feels right.\" Not \"when things get bad.\" After the 3<sup>rd</sup> session.</p> </li> <li> <p>Record the baseline commit. When you start a consolidation phase, write down the commit hash. It marks where the debt starts.</p> </li> <li> <p>Run <code>make audit</code> before feature work. If it doesn't pass, you are already in debt. Consolidate before building.</p> </li> <li> <p>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.</p> </li> </ol> <p>The Rule</p> <p>The 3:1 ratio is not aspirational: It is structural.</p> <p>Ignore consolidation, and the system will schedule it for you.</p>","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":"<p>This is the eighth post in the <code>ctx</code> blog series:</p> <ol> <li>The Attention Budget: why context windows are a scarce resource</li> <li>Before Context Windows, We Had Bouncers: the IRC lineage of context engineering</li> <li>Context as Infrastructure: treating context as persistent files, not ephemeral prompts</li> <li>When a System Starts Explaining Itself: the journal as a first-class artifact</li> <li>The Homework Problem: what happens when AI writes code but humans own the outcome</li> <li>Agent Memory Is Infrastructure: L2 memory vs L3 project knowledge</li> <li>The Architecture Release: what v0.8.0 looks like from the inside</li> <li>We Broke the 3:1 Rule (this post): what happens when you don't consolidate</li> </ol> <p>See also: The 3:1 Ratio: the original observation. This post is the empirical follow-up, five weeks and 379 commits later.</p> <p>Key commits marking the consolidation arc:</p> Commit Milestone <code>4ec5999</code> Phase WC baseline (consolidation starts) <code>ff6cf19e</code> All CLI packages restructured into <code>cmd/ + core/</code> <code>d295e49c</code> All command descriptions externalized to YAML <code>3a0bae86</code> Error package split into 22 domain files <code>0fcbd11c</code> <code>fatih/color</code> removed; 2 dependencies remain <code>5b32e435</code> <code>doc.go</code> added to all 75 packages <code>a82af4bc</code> Import aliases standardized project-wide <code>692f86cd</code> <code>lint-drift</code> false positives fixed; <code>make audit</code> 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":"<p>When an agent sees <code>token.Slash</code> instead of <code>\"/\"</code>, it cannot pattern-match against the millions of <code>strings.Split(s, \"/\")</code> calls in its training data and coast on statistical inference. It has to actually look up what <code>token.Slash</code> is.</p> <p>Volkan Özçelik / April 2, 2026</p>","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":"<p>We set out to replace a shell script with Go tests.</p> <p>We ended up discovering that \"code quality\" and \"agent readability\" are the same thing.</p> <p>This is not about linting. This is about controlling how an agent perceives your system.</p> <p>One term will recur throughout this post, so let me pin it down:</p> <p>Agent Readability</p> <p>Agent Readability is the degree to which a codebase can be understood through structured traversal, not statistical pattern matching.</p> <p>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.</p>","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":"<p><code>ctx</code> had a file called <code>hack/lint-drift.sh</code>. It ran five checks using <code>grep</code> and <code>awk</code>: literal <code>\"\\n\"</code> strings, <code>cmd.Printf</code> calls outside the write package, magic directory strings in <code>filepath.Join</code>, hardcoded <code>.md</code> extensions, and DescKey-to-YAML linkage.</p> <p>It worked. Until it didn't.</p> <p>The script had three structural weaknesses that kept biting us:</p> <ol> <li>No type awareness. It could not distinguish a <code>Use*</code> constant from a <code>DescKey*</code> constant, causing 71 false positives in one run.</li> <li>Fragile exclusions. When a constant moved from <code>token.go</code> to <code>whitespace.go</code>, the exclusion glob broke silently.</li> <li>Ceiling on detection. Checks that require understanding call sites, import graphs, or type relationships are impossible in shell.</li> </ol> <p>We wrote a spec to replace all five checks with Go tests using <code>go/ast</code> and <code>go/packages</code>. The tests would run as part of <code>go test ./...</code>: no separate script, no separate CI step.</p> <p>What we did not expect was where the work would lead.</p>","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":"<p>The pattern for each test is identical:</p> <pre><code>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</code></pre> <p>Load packages once via <code>sync.Once</code>, walk every syntax tree, collect violations, report. The shared helpers (<code>loadPackages</code>, <code>isTestFile</code>, <code>posString</code>) live in <code>helpers_test.go</code>. Each test is a <code>_test.go</code> file in <code>internal/audit/</code>, producing no binary output and not importable by production code.</p> <p>In a single session, we built 13 new tests on top of 6 that already existed, bringing the total to 19:</p> Test What it catches <code>TestNoLiteralWhitespace</code> <code>\"\\n\"</code>, <code>\"\\t\"</code>, <code>'\\r'</code> outside <code>config/token/</code> <code>TestNoNakedErrors</code> <code>fmt.Errorf</code>/<code>errors.New</code> outside <code>internal/err/</code> <code>TestNoStrayErrFiles</code> <code>err.go</code> files outside <code>internal/err/</code> <code>TestNoRawLogging</code> <code>fmt.Fprint*(os.Stderr)</code>, <code>log.Print*</code> outside <code>internal/log/</code> <code>TestNoInlineSeparators</code> <code>strings.Join</code> with literal separator arg <code>TestNoStringConcatPaths</code> Path-like variables built with <code>+</code> <code>TestNoStutteryFunctions</code> <code>write.WriteJournal</code> repeats package name <code>TestDocComments</code> Missing doc comments on any declaration <code>TestNoMagicValues</code> Numeric literals outside const definitions <code>TestNoMagicStrings</code> String literals outside const definitions <code>TestLineLength</code> Lines exceeding 80 characters <code>TestNoRegexpOutsideRegexPkg</code> <code>regexp.MustCompile</code> outside <code>config/regex/</code> <p>Plus the six that preceded the session: <code>TestNoErrorsAs</code>, <code>TestNoCmdPrintOutsideWrite</code>, <code>TestNoExecOutsideExecPkg</code>, <code>TestNoInlineRegexpCompile</code>, <code>TestNoRawFileIO</code>, <code>TestNoRawPermissions</code>.</p> <p>The migration touched 300+ files across 25 commits.</p> <p>Not because the tests were hard to write, but because every test we wrote revealed violations that needed fixing.</p>","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":"<p>The most instructive part was not writing the tests. It was the iterative tightening.</p> <p>The following process was repeated for every test:</p> <ol> <li>Write the test with reasonable exemptions</li> <li>Run it, see violations</li> <li>Fix the violations (migrate to config constants)</li> <li>The human reviews the result</li> <li>The human spots something the test missed</li> <li>Fix the test first, verify it catches the issue</li> <li>Fix the newly caught violations</li> <li>Repeat from step 4</li> </ol> <p>This loop drove the tests from \"basically correct\" to \"actually useful\". </p> <p>Three examples:</p>","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":"<p><code>TestNoMagicValues</code> initially exempted local constants inside function bodies. This let code like this pass:</p> <pre><code>const descMaxWidth = 70\ndesc := truncateDescription(\n meta.Description, descMaxWidth,\n)\n</code></pre> <p>The test saw a <code>const</code> definition and moved on. But <code>const descMaxWidth = 70</code> on the line before its only use is just renaming a magic number. The <code>70</code> should live in <code>config/format/TruncateDescription</code> where it is discoverable, reusable, and auditable.</p> <p>We removed the local const exemption. The test caught it. The value moved to config.</p>","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":"<p><code>TestNoMagicStrings</code> initially exempted all single-character strings as \"structural punctuation\". </p> <p>This let <code>\"/\"</code>, <code>\"-\"</code>, and <code>\".\"</code> pass everywhere.</p> <p>But <code>\"/\"</code> is a directory separator. It is OS-specific and a security surface. </p> <p><code>\"-\"</code> used in <code>strings.Repeat(\"-\", width)</code> is creating visual output, not acting as a delimiter. </p> <p><code>\".\"</code> in <code>strings.SplitN(ver, \".\", 3)</code> is a version separator.</p> <p>None of these are \"just punctuation\": They are domain values with specific meanings.</p> <p>We removed the blanket exemption: 30 violations surfaced. </p> <p>Every one was a real magic value that should have been <code>token.Slash</code>, <code>token.Dash</code>, or <code>token.Dot</code>.</p>","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":"<p>After migrating magic strings, we had this:</p> <pre><code>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</code></pre> <p>Six token references and a <code>NewReplacer</code> allocation. The magic values were gone, but we had replaced them with token soup: structure without abstraction. </p> <p>The correct tool was a regex:</p> <pre><code>// 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</code></pre> <p>One config regex, one call. The regex lives in <code>config/regex/file.go</code> where every other compiled pattern lives. An agent reading the code sees <code>regex.MermaidUnsafe</code> and immediately knows: this is a sanitization pattern, it lives in the regex registry, and it has a name that explains its purpose.</p> <p>Clean is better than clever.</p>","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":"<p>To make the agent-readability claim concrete, consider one function through the full transformation.</p> <p>Before (the code we started with):</p> <pre><code>func MermaidID(pkg string) string {\n r := strings.NewReplacer(\n \"/\", \"_\", \".\", \"_\", \"-\", \"_\",\n )\n return r.Replace(pkg)\n}\n</code></pre> <p>An agent reading this sees six string literals. To understand what the function does, it must: (1) parse the <code>NewReplacer</code> pair semantics, (2) infer that <code>/</code>, <code>.</code>, <code>-</code> are being replaced, (3) guess why, (4) hope the guess is right.</p> <p>There is nothing to follow. No import to trace. No name to search. The meaning is locked inside the function body.</p> <p>After (the code we ended with):</p> <pre><code>func MermaidID(pkg string) string {\n return regex.MermaidUnsafe.ReplaceAllString(\n pkg, token.Underscore,\n )\n}\n</code></pre> <p>An agent reading this sees two named references: <code>regex.MermaidUnsafe</code> and <code>token.Underscore</code>. </p> <p>To understand the function, it can: (1) look up <code>MermaidUnsafe</code> in <code>config/regex/file.go</code> and see the pattern <code>[/.\\-]</code> with a doc comment explaining it matches invalid Mermaid characters, (2) look up <code>Underscore</code> in <code>config/token/delim.go</code> and see it is the replacement character.</p> <p>The agent now has: a named pattern, a named replacement, a package location, documentation, and neighboring context (other regex patterns, other delimiters). </p> <p>It got all of this for free by following just two references.</p> <p>The indirection is not an overhead. It is the retrieval query.</p>","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":"<p>You are not just improving code quality. You are shaping the input space that determines how an LLM can reason about your system.</p> <p>Every structural constraint we enforce converts implicit semantics into explicit structure. </p> <p>LLMs struggle when meaning is implicit and patterns are statistical. </p> <p>They thrive when meaning is explicit and structure is navigable.</p> <p>Here is what we learned, organized into three categories.</p>","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":"<p>These force agents (and humans) to think harder.</p> <p>Indirection acts as a built-in retrieval mechanism:</p> <p>Moving magic values to config forces the agent to follow the reference. <code>errMemory.WriteFile(cause)</code> tells the agent \"there is a memory error package, go look.\" <code>fmt.Errorf(\"writing MEMORY.md: %w\", cause)</code> inlines everything and makes the call graph invisible. The indirection IS the retrieval query.</p> <p>Unfamiliar patterns force reasoning:</p> <p>When an agent sees <code>token.Slash</code> instead of <code>\"/\"</code>, it cannot coast on corpus frequency. It has to actually look up what <code>token.Slash</code> 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.</p> <p>Documentation helps everyone:</p> <p>Extensive documentation helps humans reading the code, agents reasoning about it, and RAG systems indexing it.</p> <p>Our <code>TestDocComments</code> check added 308 doc comments in one commit. Every function, every type, every constant block now has a doc comment. </p> <p>This is not busywork: it is the content that agents and embeddings consume.</p>","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":"<p>These shape the codebase into a navigable graph.</p> <p>Shorter files save tokens:</p> <p>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.</p> <p>Fixed-width constraints force decomposition:</p> <p>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). </p> <p>The constraint forces structural improvements that happen to also make the code more parseable.</p> <p>Chunk-friendly structure helps RAG</p> <p>Code intelligence tools chunk files for embedding and retrieval. Short, well-documented, single-responsibility files produce better chunks than monolithic files with mixed concerns. </p> <p>The structural constraints create files that RAG systems can index effectively.</p> <p>Centralization creates debuggable seams:</p> <p>All error handling in <code>internal/err/</code>, all logging in <code>internal/log/</code>, all file operations in <code>internal/io/</code>. 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 <code>fmt.Errorf</code> calls.</p> <p>Private functions become public patterns:</p> <p>When you extract a private function to satisfy a constraint, it often ends up as a semi-public function in a <code>core/</code> package. Then you realize it is generic enough to be factored into a purpose-specific module.</p> <p>The constraint drives discovery of reusable abstractions hiding inside monolithic functions.</p>","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":"<p>These pay dividends in daily development.</p> <p>Single-edit renames:</p> <p>Renaming a flag is one edit to a config constant instead of find-and-replace across 30,000 lines with possible misses. <code>grep token.Slash</code> gives you every place that uses a forward slash semantically.</p> <p><code>grep \"/\"</code> gives you noise.</p> <p>Blast radius containment:</p> <p>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\".</p> <p>Compile-time contract enforcement:</p> <p>When <code>err/memory.WriteFile</code> exists, the compiler guarantees the error message exists and the call signature is correct. An inline <code>fmt.Errorf</code> can have a typo in the format string and nothing catches it until runtime. Centralization turns runtime failures into compile errors.</p> <p>Semantic <code>git blame</code>:</p> <p>When <code>token.Slash</code> is used everywhere and someone changes its value, <code>git blame</code> on the config file shows exactly when and why. </p> <p>With inline <code>\"/\"</code> scattered across 30 files, the history is invisible.</p> <p>Test surface reduction:</p> <p>Centralizing into <code>internal/err/</code>, <code>internal/io/</code>, <code>internal/config/</code> means you test behavior once at the boundary and trust the callers. </p> <p>You do not need 30 tests for 30 <code>fmt.Errorf</code> calls. You need 1 test for <code>errMemory.WriteFile</code> and 30 trivial call-site audits, which is exactly what these AST tests provide.</p>","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":"<p>One session. 25 commits. The raw stats:</p> 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 <p>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.</p>","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":"<p>None of this is Go-specific.</p> <p>If an AI agent interacts with your codebase, your codebase already is an interface. You just have not designed it as one.</p> <p>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 <code>write.WriteJournal</code>, the agent wastes tokens on redundant information.</p> <p>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.</p> <p>This is not a coincidence: These constraints exist because they reduce the cognitive load of understanding code. </p> <p>Agents have cognitive load too: It is called the context window.</p> <p>You are not converting code to a new paradigm.</p> <p>You are making the latent graph visible.</p> <p>You are converting implicit semantics into explicit structure that both humans and machines can traverse.</p>","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":"<p>The spec lists 8 more tests we have not built yet, including <code>TestDescKeyYAMLLinkage</code> (verifying that every DescKey constant has a corresponding YAML entry), <code>TestCLICmdStructure</code> (enforcing the <code>cmd.go</code> / <code>run.go</code> / <code>doc.go</code> file convention), and <code>TestNoFlagBindOutsideFlagbind</code> (which requires migrating ~50 flag registration sites first).</p> <p>The broader question: should these principles be codified as a reusable linting framework? The patterns (<code>loadPackages</code> + <code>ast.Inspect</code> + violation collection) are generic. </p> <p>The specific checks are project-specific. But the categories of checks (centralization enforcement, magic value detection, naming conventions, documentation requirements) are universal.</p> <p>For now, 19 tests in <code>internal/audit/</code> is enough. They run in 2 seconds as part of <code>go test ./...</code>. They catch real issues. </p> <p>And they encode a theory of code quality that serves both humans and the agents that work alongside them.</p> <p>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.</p> <p>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.</p> <p>Structure is no longer just for maintainability. It is for reasonability.</p>","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":"<p>Give an agent a graph query tool, and it will tell you everything about your codebase except what actually matters.</p> <p>Volkan Özçelik / April 6, 2026</p>","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":"<p>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.</p> <p>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.</p> <p>Both halves of this metaphor showed up in a single experiment. And the result changed how we design architecture analysis in [<code>ctx</code>][<code>ctx</code>].</p>","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":"<p>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.</p> 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 <p>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.</p> <p>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.</p> <p>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.</p> <p>And hollow.</p>","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":"<p>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.</p> <p>Not wrong. Not broken. Just... thin.</p> <p>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.</p> <p>The tool answered the question asked but prevented the discovery of answers to questions never asked.</p> <p>Here's what that looks like concretely: the graph tells you that <code>ReconcileDeployment</code> calls <code>SyncPods</code>. It does not tell you that <code>SyncPods</code> 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.</p> <p>The operational reality is invisible.</p>","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":"<p>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). </p> <p>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?</p> <p>The agent isn't lazy. It's rational. </p> <p>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).</p> <p>Satisficing produces watermelon rinds.</p>","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":"<p>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.</p> <p>You can't enrich your way out of a depth deficit.</p> <p>So we redesigned. Instead of one skill with optional tools, we built a two-pass compiler for architecture understanding:</p> <p>Pass 1: Semantic parsing. The <code>/ctx-architecture</code> 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.</p> <p>Pass 2: Static analysis. The <code>/ctx-architecture-enrich</code> 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.</p> <p>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.</p>","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":"<p>We call this constraint-as-feature: deliberately withholding capabilities to force deeper engagement.</p> <p>It sounds paradoxical. You built sophisticated code intelligence tools and then... forbid the agent from using them? During the most important phase?</p> <p>Yes. Because the tools don't make the agent smarter. They make it faster. And faster, in architecture analysis, is the enemy of deep.</p> <p>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.</p> <p>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.</p>","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":"<p>Not always. The watermelon-rind antipattern is specific to exploratory analysis: tasks where the value comes from discovering unknowns, not from answering known questions.</p> <p>Graph tools are excellent for:</p> <ul> <li>Verification: \"Does X actually call Y?\" (binary question, precise answer)</li> <li>Impact analysis: \"What breaks if I change Z?\" (bounded scope, enumerable results)</li> <li>Navigation: \"Where is this interface implemented?\" (lookup, not analysis)</li> </ul> <p>Graph tools produce watermelon rinds when:</p> <ul> <li>The goal is understanding, not answering</li> <li>The unknowns are unknown: you don't know what to ask</li> <li>Depth matters more than breadth: operational details, edge cases, implicit coupling</li> </ul> <p>The two-pass approach preserves both: deep reading first, tool verification second.</p>","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":"<p>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.</p> <p>Esegin aklina karpuz kabugu sokma!</p> <p>(don't put the watermelon rind to a donkey's mind)</p> <p>If the agent never struggles, it never discovers. And if it never discovers, you are not doing architecture; you are doing autocomplete.</p> <p>This post is part of the <code>ctx</code> field notes series, documenting what we learn building persistent context infrastructure for AI coding sessions.</p>","path":["The Watermelon-Rind Anti-Pattern: Why Smarter Tools Make Shallower Agents"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/","level":1,"title":"The Cheapest Patch Was the Most Expensive","text":"","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-seven-ai-coding-runs-taught-me-about-cost","level":2,"title":"What Seven AI Coding Runs Taught Me About Cost","text":"<p>Volkan Özçelik / June 21, 2026</p> <p>What Does a Cheap Patch Actually Cost?</p> <p>The cheapest run fixed the visible bug in four minutes for thirty-five cents, and missed the contract entirely.</p> <p>The most expensive run wrote a strong patch, and quietly changed a product decision nobody asked it to change.</p> <p>Neither number on the invoice told you either of those things.</p> <p>I ran a small AI coding experiment on a real CLI bug.</p> <p>The bug was boring, which made it useful.</p> <p>A command accepted a comma-separated list of secret versions. This worked:</p> <pre><code>--versions \"1,2,3\"\n</code></pre> <p>This looked like it worked:</p> <pre><code>--versions \"1, 2, 3\"\n</code></pre> <p>But one command silently sent only the first version.</p> <p>The validation path handled whitespace. The conversion path did not.</p> <p>For example, <code>\"1, 2, 3\"</code> became <code>[1]</code>.</p> <p>A sibling command had similar parsing code, but not the exact same failure. The right fix was not \"make this one line trim spaces\". The right fix was to stop duplicating the parsing logic and send both commands through the same parser.</p> <p>It was easy to see if you knew the codebase, but deceptively complex if you were unfamiliar with the project. For reference, the project is SPIKE.</p> <p>So I thought I could run a controlled experiment on how spec-driven development methodologies, context-compression techniques, <code>ctx</code>, and different model choices play together.</p> <p>If I were to write a paper (and I am planning to write one), the thesis would read something like this:</p> <pre><code>We evaluate whether context-engineering tools reduce the real cost of\nagentic coding under spec-driven development. Rather than measuring token\nsavings alone, we measure accepted-patch cost: model cost, repair loops,\nhidden acceptance failures, and human review burden. On a substantial\ncross-layer task in the SPIFFE/SPIKE repository, we compare direct\nissue-to-code prompting, frontier-authored SDD artifacts, weak-authored\nartifacts with frontier ratification, and multiple context conditions\nincluding structured context manifests, shell-output compression, and\ncontext-runtime filtering. Our results show whether token savings translate\ninto accepted patches, and identify when context tools help, hurt, or merely\nmove cost into review.\n</code></pre> <p>This Is a Weekend Hack, Not the Paper</p> <p>To make this paper-grade, I figured I would need to run ~500 controlled agentic experiments, each spanning at least half an hour. That is not a weekend hack. So I picked a meaningful subset, ran them end-to-end, and that is what you are reading. </p> <p>Treat these numbers as signal, not as proof.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-shared-parser","level":2,"title":"The Shared Parser","text":"<p>One more detail about the task at hand: there was already a shared parser: An agent leveraging the shared parser would already implement half of the solution and have a head-start. An agent that missed the parser would burn tokens rebuilding what was already there.</p> <p>And that detail changed the entire task:</p> <ul> <li>The job was not to design a parser.</li> <li>It was to wire an existing helper into two commands, preserve the product contract, and add focused command tests.</li> </ul> <p>But the agents that were going to implement this did not know that a priori.</p> <p>That is where the whole experiment became interesting.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-task-at-hand","level":2,"title":"The Task at Hand","text":"<p>The accepted behavior was:</p> <pre><code>\"1, 2, 3\" -> [1, 2, 3]\n</code></pre> <p>Other decisions mattered too:</p> <ul> <li><code>\"\"</code> or whitespace-only selector -> <code>[0]</code></li> <li><code>0</code> remains the current-version sentinel</li> <li>empty inner tokens are rejected</li> <li>non-integers are rejected</li> <li>negative integers are rejected</li> <li>duplicates are preserved</li> <li>no SDK/API/backend/state changes</li> <li>no framework rewrite</li> </ul> <p>The invariant was simple:</p> <pre><code>Accept the whole selector,\nor reject the whole selector before any API call.\n\nDo not silently drop a token.\n</code></pre> <p>The bug was small enough that any strong model could patch something. Yet it was large enough that a quick patch could be wrong in ways that looked correct from the outside.</p> <p>A perfect setup.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-runs","level":2,"title":"The Runs","text":"<p>I ran multiple implementations of the same task.</p> <p>Some runs used context compression (reducing token count by eliminating unnecessary content that flows to and from the model, while keeping the compression as lossless as possible). Some did not.</p> <p>Here is an uncompressed CLI call:</p> <pre><code>volkan@sdd:~/WORKSPACE$ ls -al\ntotal 534724\ndrwxrwxr-x 6 volkan volkan 4096 Jun 20 22:02 .\ndrwxr-x--- 21 volkan volkan 4096 Jun 21 14:04 ..\ndrwxr-xr-x 25 volkan volkan 4096 Jun 20 11:35 ctx\ndrwxrwxr-x 19 volkan volkan 4096 Jun 20 12:46 ctx-bak\ndrwxrwxr-x 2 volkan volkan 4096 Jun 20 19:55 harness\ndrwxrwxr-x 22 volkan volkan 4096 Jun 20 21:35 spike\n-rw-rw-r-- 1 volkan volkan 78242134 Jun 20 20:51 spike-haiku-for-spec-tooling-on-haiku-for-exec.zip\n-rw-rw-r-- 1 volkan volkan 78116329 Jun 20 18:00 spike-opus-4-8-xhigh-no-tooling.zip\n-rw-rw-r-- 1 volkan volkan 78225976 Jun 20 19:54 spike-sonnet-4-6-medium-tooling-on-haiku-for-exec.zip\n-rw-rw-r-- 1 volkan volkan 78176133 Jun 20 19:39 spike-sonnet-4-6-medium-tooling-on-sonnet-for-exec.zip\n-rw-rw-r-- 1 volkan volkan 78245337 Jun 20 21:52 spike-sonnet-medium-for-all-tooling-off.zip\n-rw-rw-r-- 1 volkan volkan 78282827 Jun 20 22:02 spike-sonnet-medium-for-specs-haiku-for-exec-no-tooling.zip\n-rw-rw-r-- 1 volkan volkan 78217444 Jun 20 20:06 spike-yolo-no-specs-haiku-for-exec.zip\n</code></pre> <p>And here is the compressed version for comparison:</p> <pre><code>755 ctx/\n775 ctx-bak/\n775 harness/\n775 spike/\n664 spike-haiku-for-spec-tooling-on-haiku-for-exec.zip 74.6M\n664 spike-opus-4-8-xhigh-no-tooling.zip 74.5M\n664 spike-sonnet-4-6-medium-tooling-on-haiku-for-exec.zip 74.6M\n664 spike-sonnet-4-6-medium-tooling-on-sonnet-for-exec.zip 74.6M\n664 spike-sonnet-medium-for-all-tooling-off.zip 74.6M\n664 spike-sonnet-medium-for-specs-haiku-for-exec-no-tooling.zip 74.7M\n664 spike-yolo-no-specs-haiku-for-exec.zip 74.6M\n\nSummary: 7 files, 4 dirs (7 .zip)\n</code></pre> <p>The goal of the compression was to preserve meaningful content while cutting the fluff that would not typically benefit the agent.</p> <p>In this experiment:</p> <pre><code>compression ON = both context compression layers enabled\ncompression OFF = both context compression layers disabled\n</code></pre> <p>Except for one \"YOLO this thing end to end\" negative-control case, every serious run went through a structured debrief/spec/task workflow, following a formal spec-driven-development methodology.</p> <p>The decisions the agent made were not necessarily caused by information loss during compression. They were more about the quality and the shape of the context available while the plan hardened. Which also meant the quality of the agent (and the human) mattered a lot during the planning and spec-development phase.</p> <p>Here is the short summary of the experiments. For simplicity, and to keep this a weekend hack, I only used Anthropic models.</p> Run Planning / discovery Implementation Quality / caveat Opus end-to-end, compression OFF$16.25 · 59m27s Handled the debrief/spec/task work and implementation. Opus implemented. Strong patch. It also tightened behavior beyond the final compatibility decision by rejecting whitespace-padded selectors. Sonnet, compression ON$6.43 · 1h04m15s Completed the structured workflow, but planned larger parser work. Sonnet implemented. Acceptable, but larger than necessary. Sonnet, compression OFF$6.11 · 50m13s Found that <code>parseVersionList()</code> already existed and narrowed the task to wiring. Sonnet implemented. Preferred patch shape. Haiku, compression ON$2.15 · 39m53s Completed the structured workflow after steering. Haiku implemented. Cheap, but needed steering. Weak at repo discovery. Sonnet OFF plan, Haiku implementation~$4.92 · ~50m15s Sonnet (compression OFF) found and specified the smaller wiring task. Haiku implemented the ratified task list. Worth repeating as a follow-up experiment. Not a default rule. Sonnet ON plan, Haiku implementation~$4.9 · composite Sonnet (compression ON) planned the larger parser task. Haiku implemented the ratified task list. Acceptable, but inherited the larger premise. Haiku YOLO$0.35 attempt · 4m23s No structured workflow. Haiku implemented directly. Rejected: Fixed the visible symptom, but missed the accepted contract. <p>The two Sonnet end-to-end rows above deserve closer attention.</p> <p>Same model family. Same general workflow. Different compression setting.</p> <ul> <li>With compression OFF, the model found the existing helper and narrowed the work.</li> <li>With compression ON, the model planned a larger parser task.</li> </ul> <p>That single repo fact mattered more than the model price.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-cost-table-that-looks-boring-but-isnt","level":2,"title":"The Cost Table That Looks Boring But Isn't","text":"<p>At one checkpoint, the numbers looked almost tied.</p> Sonnet planning run Cost API time Wall time Resulting implementation delta Compression ON $4.39 16m48s 49m42s +1331 / -137 Compression OFF $4.40 17m22s 44m00s +1152 / -165 <p>A quick read says compression did not matter.</p> <p>That read misses the implementation shape.</p> <p>By this checkpoint, the compression-OFF run had already found <code>parseVersionList()</code> and narrowed the task to wiring the helper. The compression-ON run was still carrying a larger parser-work premise.</p> <p>Read it again with the shape in mind. Both runs cost about the same. The compression-OFF run reused an existing helper; the compression-ON run was set up to rebuild that logic from scratch. So compression did save context budget. The saving was then spent carrying a less accurate premise. The dollars came out even; the work did not.</p> <p>Compression Fails Quietly</p> <p>Compression did not fail loudly. It produced coherent artifacts.</p> <p>They were useful artifacts. It was solving the problem and meeting every product requirement.</p> <p>It was also expanding the wrong-sized job. That is the dangerous part: a failure that ships clean.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-patch-quality-review","level":2,"title":"The Patch Quality Review","text":"<p>A frontier-model-assisted static review told a cleaner story than raw cost.</p> Case Verdict Why / operating read Sonnet compression OFF / Sonnet implementation Preferred, with slightly enhanced spec-cpreation workflow Found existing parser, wired both commands, strongest command tests. Minor caveat: version parsing moved before some source/auth checks. Sonnet compression ON / Sonnet implementation Preferred, but patch was larger than necessary Fixed the bug, but missed the existing helper during planning. To be clear, compression was not the main issue; the setup needed a better ratified spec to guide the agent. Sonnet compression OFF / Haiku implementation Acceptable bounded-executor trial Haiku followed the ratified plan, but tests were thinner. This supports retesting cheap execution after task shape is fixed. Haiku compression ON / Haiku implementation Risky: Usable after excessive steering, weak as scout Core behavior was right, but proof and cleanup were weaker. Sonnet compression ON / Haiku implementation Acceptable, but inherited larger premise The implementation stayed inside the earlier parser-work shape. Opus 4.8 x-high Strong patch, contract drift Strong and conservative. It rejected whitespace-padded selectors, which diverged from the final product decision. Haiku YOLO Rejected as Incomplete Fixed <code>\"1, 2, 3\"</code> but kept duplicated parsing and missed whitespace-only <code>[0]</code>. <p>This table should not be read as \"use the cheapest model\". It says something more significant:</p> <p>Cheap execution can be tested after the task shape is fixed.</p> <p>Cheap discovery, without a comprehensive spec, was not reliable in this experiment. Cheap YOLO produced a patch-shaped answer, not an accepted patch.</p> <p>There is a large difference between:</p> <pre><code>the model produced a diff\n</code></pre> <p>and:</p> <pre><code>the model produced the accepted patch\n</code></pre> <p>The accepted patch is the metric that matters. That gap between cheap production and directed judgment is the whole subject of Code Is Cheap. Judgment Is Not., and this experiment is the same lesson with an invoice attached.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-most-expensive-model-is-not-automatically-safer","level":2,"title":"The Most Expensive Model Is Not Automatically Safer","text":"<p>The Opus run was strong. It was also too eager.</p> <p>It rejected whitespace-padded selectors. That is a defensible CLI grammar if you are designing from scratch. It is not what the final compatibility contract said.</p> <p>A stronger model can preserve more context, reason more carefully, and still make a product decision you did not ask it to make.</p> <p>You can argue that the model is taking initiative here, thinking like a senior engineer to make the product more secure and reliable. But this is a distinct failure mode worth watching:</p> <ul> <li>The cheap YOLO model missed parts of the contract.</li> <li>The expensive model tried to improve the contract.</li> </ul> <p>Both Require Review</p> <p>The lesson is not \"small models bad, large models good\". The useful split is three separate questions:</p> <ul> <li>which model is deciding the task shape;</li> <li>which model is executing a ratified task;</li> <li>and which human checkpoint catches contract drift.</li> </ul> <p>Under-reach and over-reach are both contract drift. You cannot afford to review for only one of them.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#scout-versus-executor","level":2,"title":"Scout Versus Executor","text":"<p>The transcripts showed the models behaving differently, not just costing differently.</p> <p>The compression-OFF Sonnet run read the repo and changed the task. It found the helper and stated the situation outright:</p> <pre><code>undelete.go does not have this bug; delete.go does;\nparseVersionList already fixes it.\n</code></pre> <p>The structured Haiku run, from the same starting point, tended to hand repo questions back to the human instead of answering them from the code:</p> <pre><code>Does undelete.go already have the correct behavior?\n</code></pre> <p>That is a question a careful reading pass should have closed: </p> <p>It is the line between a scout that establishes the task shape and a bounded executor that needs the shape handed to it. </p> <p>Haiku was a capable executor once the task was pinned, and an unreliable scout before it.</p> <p>The scout did not just find the smaller job; it built less of it. </p> <p>Both Sonnet runs went end-to-end through the same workflow, but the compression-OFF run produced a smaller final diff (+1300 / -260 versus +1542 / -202), because once the job was \"wire the parser\" there was simply less to build.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#token-telemetry","level":2,"title":"Token Telemetry","text":"<p>The telemetry had a few surprises. These counts are computed from the raw session logs across every run (token counts only; the dollar figures come from the run summaries):</p> Scope Requests Input tokens Output tokens Cache read Cache write All sessions 874 51,102 554,094 63,946,649 2,268,906 Top-level 664 42,623 510,465 58,253,517 1,854,589 Subagents 210 8,479 43,629 5,693,132 414,317 <p>Read the cache-read column again: </p> <p>Fresh input was about 51K tokens and output about 554K, but the runs read back roughly 64 million cached tokens. </p> <p>Cache reuse, not fresh reasoning, is where the token activity lived; and subagents accounted for only ~5.7M of those ~64M reads, so they were not the sink either.</p> <p>This is an activity table, not a billing table. Cache reads are cheap per token, which is why a run can move 64 million of them without the dollar figure exploding: the money lives in the cost tables above; the attention lives here.</p> <p>Findings:</p> <ol> <li>Cache-read tokens dominated the token profile.</li> <li>Subagents were not the main token sink.</li> <li>Haiku was cheaper in dollars, not necessarily smaller in raw token activity.</li> <li>The preferred Sonnet result was not better because it reasoned less. It was better because it found the smaller job: wire the existing <code>parseVersionList()</code> helper instead of creating or extracting a new parser.</li> </ol> <p>The raw activity matters because \"cheap\" can mean several different things:</p> <ul> <li>it can mean cheaper dollars;</li> <li>it can mean fewer tokens;</li> <li>it can mean less wall-clock time;</li> <li>it can mean fewer review minutes.</li> </ul> <p>Those are not the same thing.</p> <p>Accounting Fraud With a Patch File</p> <p>In this experiment, the cheap YOLO attempt had the lowest cost. </p> <p>It also galactically missed the contract.</p> <p>Counting that as a win would be accounting fraud with a patch file attached.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#workflow-enhancement","level":2,"title":"Workflow Enhancement","text":"<p>The code bug was easy to describe.</p> <p>The workflow enhancement requirement was more subtle.</p> <p>The structured flow did many things right:</p> <ul> <li>it found behavior,</li> <li>produced artifacts,</li> <li>recorded non-goals,</li> <li>and guided implementation.</li> </ul> <p>The gap was earlier and more mechanical:</p> <pre><code>before the spec expands, prove what already exists\n</code></pre> <p>The helper existed. The workflow needed to force that fact into the first controlling artifact.</p> <p>Without that inventory, the pipeline can faithfully expand a plausible task that is larger than necessary.</p> <p>That is how you get a detailed spec for the wrong-sized job. It is the same failure that The Dog Ate My Homework documented from the other direction: the expensive mistakes happen when an agent writes before it has truly read.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-fix-make-problem-space-inventory-a-hard-gate","level":2,"title":"The Fix: Make Problem-Space Inventory a Hard Gate","text":"<p>The operating model I would use after this experiment is artifact-gated:</p> <pre><code>/plan:\n produce a repo-grounded debated brief\n include implementation inventory and task-shape correction\n\nhuman ratification:\n confirm the debated brief before it becomes spec input\n\n/spec:\n turn the ratified brief into a product/engineering contract\n\nhuman ratification:\n confirm the spec intent before spec-kit expands it\n\nspec-kit:\n generate spec/plan/tasks/analyzer output from the ratified intent\n\nhuman ratification:\n confirm the generated tasks before coding starts\n\nimplementation:\n execute the ratified task list\n do not re-open task shape unless review sends it back\n\nacceptance:\n measure accepted patch cost, not attempt cost\n</code></pre> <p>Implementation model choice happens only after the task list is ratified.</p> <p>Which Model for Which Job</p> <ul> <li>Use a cheaper model only when the task is well-defined and the spec is crystal clear beyond any reasonable doubt.</li> <li>Use the default model most of the time; you will still need a decent spec, not a two-paragraph prompt.</li> <li>Use a stronger model only when the implementation requires judgment, security reasoning, broad refactoring, fresh discovery, or adversarial scrutiny. Ironically, your spec here needs to be crisper, not looser: the model will attack it, find gaps, and fix them if it decides that is the right call. Be very clear about why you need what you need.</li> </ul>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-plan-must-prove","level":2,"title":"What <code>/plan</code> Must Prove","text":"<p>For this class of task, <code>/plan</code> should not finish until it records:</p> <ul> <li>existing helpers</li> <li>existing tests</li> <li>similar commands</li> <li>already-correct behavior</li> <li>files that should remain unchanged</li> <li>whether the task is wiring, deletion, extraction, or new behavior</li> </ul> <p>For the CLI bug, that inventory would have found:</p> <ul> <li><code>parseVersionList()</code> already exists</li> <li>delete uses duplicated parsing</li> <li>undelete has similar code but not the same bug</li> <li>the accepted fix is wiring, not parser design</li> </ul> <p>That would have prevented the larger parser-work premise from surviving into the spec.</p> <p>The spec was not the problem; the input to the spec was underspecified.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-spec-kit-gotcha","level":2,"title":"The <code>spec-kit</code> Gotcha","text":"<p>Spec generation is seductive because it makes the work look settled.</p> <p>A generated task list feels like progress:</p> <ul> <li>it has IDs,</li> <li>it has dependencies,</li> <li>it has phases,</li> <li>it has checkboxes.</li> </ul> <p>But if the task shape is wrong, the checkboxes become a very tidy way to do extra work.</p> <p>That does not make <code>spec-kit</code> (or equivalent tools) bad. It means <code>spec-kit</code> should not be the first place where repo understanding becomes concrete. Use spec expansion after a debated brief is ratified.</p> <p>Also, do not assume the implementation command is an interactive review loop. Treat it as an executor. If you need a checkpoint after every task or phase, enforce that in the wrapper or in the prompt:</p> <pre><code>implement T001\nstop\nsummarize diff and tests\nwait for approval before T002\n</code></pre> <p>There is a subtler trap. The generated artifacts are themselves model output. In one run the structured flow held the \"stop before commit\" line well, but the generated task list quietly reintroduced \"commit after each phase\" language that had to be edited back out. The workflow can constrain a cheap model; the workflow's own artifacts still need a human read.</p> <p>Trust Is Not a Workflow</p> <p>Trusting the final result is not a workflow. It is a hope with a diff.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#context-compression","level":2,"title":"Context Compression","text":"<p>Compression is attractive because it reduces what the model has to carry, saving valuable dollars.</p> <p>That is also the risk:</p> <p>Compression can preserve conclusions while dropping the dull facts that made the conclusion safe.</p> <p>In this experiment, the dull fact was a parser helper.</p> <ul> <li>No architecture diagram screams about an existing helper.</li> <li>No spec requirement says \"check whether this already exists\" unless you make it say that.</li> <li>No generated task list rescues you if the earlier artifact already chose the wrong implementation shape.</li> </ul> <p>This is the same shape as the watermelon-rind anti-pattern: a mechanism that answers the question asked can quietly prevent the discovery of the question you should have asked. A graph tool did it there by collapsing the search space; in this run, compression did it by dropping the boring line that would have changed the plan. And it is the mirror image of The Attention Budget: more context is not automatically better, but less context is not automatically cheaper either.</p> <p>Compression Needs a Counterweight</p> <p>Do not treat compression as free savings. Pair it with:</p> <ul> <li>inventory before compression hardens into a plan;</li> <li>ratification before spec expansion;</li> <li>review before implementation.</li> </ul>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-yolo-fun","level":2,"title":"The YOLO Fun","text":"<p>The cheap YOLO run was useful because it showed the trap.</p> <p>It quickly fixed the visible symptom:</p> <ul> <li>a shallow test could have passed;</li> <li>the diff would look reasonable in a hurry.</li> </ul> <p>However, it did not preserve the full accepted behavior:</p> <ul> <li>it did not remove duplicated parsing;</li> <li>it did not handle whitespace-only <code>[0]</code>.</li> </ul> <p>This is the difference between symptom repair and contract repair.</p> <p>A model can pass the obvious bug report while failing the actual engineering task.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-i-would-repeat","level":2,"title":"What I Would Repeat","text":"<p>I would repeat the Sonnet compression comparison on more tasks.</p> <p>This task says:</p> <pre><code>compression OFF found the smaller job\ncompression ON planned the larger job\n</code></pre> <p>That is one task, not a universal law.</p> <p>I would also repeat the \"strong model plans, cheaper model executes\" pattern, but now with a strict acceptance review. The result is interesting because it may reduce cost after the task shape is fixed.</p> <p>The numbers hint at why it is worth a look. Once the task was pinned, the Haiku edit on top of the ratified Sonnet plan was about ninety lines and cost roughly fifty cents. The composite came to about $4.92 against $6.11 for Sonnet end-to-end: close to 20% cheaper. </p> <p>That saving is real only if the cheap patch survives acceptance review, which is a big if, not a default rule.</p> <p>Never Be Frugal on Planning</p> <p>After this set of experiments I am fairly convinced that a cheaper model should never own planning and spec development.</p> <p>If there is a place you should not be frugal, that is the place. Skimp there and you may confidently implement the wrong thing: something that passes all the tests and looks right at first glance, even under the review of an excellent engineer who is not fully familiar with the domain.</p> <p>The next experiments should separate:</p> <ul> <li>repo discovery quality</li> <li>spec quality</li> <li>implementation quality</li> <li>review cost</li> <li>accepted patch cost</li> </ul> <p>Because each of those has to be judged on its own. Roll them into a single \"cost\" number and you lose the distinction that matters most: attempt cost versus accepted-patch cost.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#what-this-experiment-cant-tell-you","level":2,"title":"What This Experiment Can't Tell You","text":"<p>I want to be honest about the edges of this, so the numbers are not read as more than they are:</p> <ul> <li>It is one small, local task in one repository. Larger cross-file or cross-repo work could move the budget picture either way.</li> <li>Tests were not run on every implementation, so some patches are judged by static review, not by a green test suite.</li> <li>Static review ran on the final working trees, and a few rows in the underlying cost ledger are interpolated rather than separately captured.</li> <li>Dollar costs come from the run summaries; the token counts come from the session logs. They are two lenses, not one ledger.</li> </ul> <p>None of this changes the shape of the finding. It does mean the right reading is \"strong signal from a weekend\", not \"proven law\".</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#the-takeaway","level":2,"title":"The Takeaway","text":"<p>The expensive part of AI coding is not always the diff.</p> <p>Sometimes the expensive part is missing the smaller job.</p> <p>In this experiment, the best result came from finding an existing helper before the task shape hardened. Once the task became \"wire the parser\", implementation was straightforward. When the helper was missed, the workflow still produced coherent specs and acceptable patches, but it carried a larger premise.</p> <p>The workflow change is small:</p> <pre><code>make implementation inventory mandatory before spec expansion\n</code></pre> <ul> <li>Find what already exists.</li> <li>Ratify that understanding.</li> <li>Then generate the spec.</li> <li>Then implement.</li> </ul> <p>If You Remember One Thing from This Post...</p> <p>A patch is cheap only after you know which patch you are asking for.</p> <p>The cheapest model can miss the contract; the most expensive model can rewrite it. Neither is safe without a ratified task shape and a human checkpoint that reads the diff against the contract, not against the bug report.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"blog/2026-06-21-the-cheapest-patch-was-the-most-expensive/#where-this-connects","level":2,"title":"Where This Connects","text":"<p>This experiment is one more data point in a thread that runs through these field notes.</p> <ul> <li>The Dog Ate My Homework argued that the hard part is getting an agent to read before it writes. This is the same failure with money attached: the agent that did not inventory the repo first wrote a spec for the wrong-sized job.</li> <li>The Watermelon-Rind Anti-Pattern showed that a mechanism which answers the question asked can prevent the discovery of the question you should have asked. Compression did exactly that here.</li> <li>Code Is Cheap. Judgment Is Not. put it in one line: production is the easy part, judgment is the hard part. The judgment that mattered most was not in the diff. It was in deciding the task shape before any model started typing.</li> <li>The Attention Budget explained why more context is not automatically better. Compression is the same coin flipped: less context is not automatically cheaper.</li> </ul> <p>If you want the operating model in tool form, <code>ctx</code> already ships most of it. Design Before Coding walks the brainstorm / plan / spec / implement chain, and Scrutinizing a Plan is the <code>/ctx-plan</code> step that produces the repo-grounded debated brief this post keeps asking for: the artifact that forces \"prove what already exists\" before a spec can expand.</p> <p>This post is part of the <code>ctx</code> field notes series, documenting what we learn building persistent context infrastructure for AI coding sessions. The experiment ran against the SPIFFE/SPIKE repository using Anthropic models only. The numbers are signal from a weekend's worth of runs, not a peer-reviewed result.</p>","path":["The Cheapest Patch Was the Most Expensive: What Seven AI Coding Runs Taught Me About Cost"],"tags":[]},{"location":"cli/","level":1,"title":"CLI","text":"","path":["CLI"],"tags":[]},{"location":"cli/#ctx-cli","level":2,"title":"<code>ctx</code> CLI","text":"<p>Complete reference for all <code>ctx</code> commands, grouped by function.</p>","path":["CLI"],"tags":[]},{"location":"cli/#global-options","level":2,"title":"Global Options","text":"<p>All commands support these flags:</p> Flag Description <code>--help</code> Show command help <code>--version</code> Show version <code>--tool <name></code> Override active AI tool identifier (e.g. <code>kiro</code>, <code>cursor</code>) <p>Tell <code>ctx</code> which <code>.context/</code> to use. <code>ctx</code> reads <code>$PWD/.context/</code> — run commands from the project root (the directory that holds both <code>.git/</code> and <code>.context/</code>). There is no env-var or walk-up resolution; <code>ctx</code> does not search the filesystem. If <code>$PWD/.context/</code> is missing, commands fail fast with a clear error pointing at <code>ctx init</code>. A handful of commands run without that gate because they don't need a project: <code>ctx init</code>, <code>ctx version</code>, <code>ctx help</code>, <code>ctx system bootstrap</code>, <code>ctx doctor</code>, <code>ctx guide</code>, <code>ctx why</code>, <code>ctx config switch/status</code>, and <code>ctx hub *</code>.</p> <p>Initialization required. Once declared, the target must already have been initialized by <code>ctx init</code> (otherwise commands return <code>ctx: not initialized</code>).</p>","path":["CLI"],"tags":[]},{"location":"cli/#getting-started","level":2,"title":"Getting Started","text":"Command Description <code>ctx init</code> Initialize <code>.context/</code> directory with templates <code>ctx status</code> Show context summary (files, tokens, drift) <code>ctx guide</code> Quick-reference cheat sheet <code>ctx why</code> Read the philosophy behind <code>ctx</code>","path":["CLI"],"tags":[]},{"location":"cli/#context","level":2,"title":"Context","text":"Command Description <code>ctx load</code> Output assembled context in read order <code>ctx agent</code> Print token-budgeted context packet for AI consumption <code>ctx sync</code> Reconcile context with codebase state <code>ctx drift</code> Detect stale paths, secrets, missing files <code>ctx compact</code> Archive completed tasks, clean up files <code>ctx fmt</code> Format context files to 80-char line width <code>ctx task</code> Add tasks, mark complete, archive, snapshot <code>ctx decision</code> Add decisions to <code>DECISIONS.md</code> <code>ctx learning</code> Add learnings to <code>LEARNINGS.md</code> <code>ctx convention</code> Add conventions to <code>CONVENTIONS.md</code> <code>ctx index</code> Project a file's headings as a table of contents <code>ctx permission</code> Permission snapshots (golden image) <code>ctx change</code> Show what changed since last session <code>ctx memory</code> Bridge Claude Code auto memory into <code>.context/</code> <code>ctx watch</code> Auto-apply context updates from AI output <code>ctx kb</code> Knowledge-base editorial pipeline (Phase KB) <code>ctx handover</code> Write the per-session handover that the next session reads","path":["CLI"],"tags":[]},{"location":"cli/#sessions","level":2,"title":"Sessions","text":"Command Description <code>ctx journal</code> Browse, import, enrich, and lock session history <code>ctx dream</code> Triage <code>ideas/</code> into gated proposals for review (opt-in) <code>ctx pad</code> Encrypted scratchpad for sensitive one-liners <code>ctx remind</code> Session-scoped reminders that surface at session start <code>ctx hook pause</code> Pause context hooks for the current session <code>ctx hook resume</code> Resume paused context hooks","path":["CLI"],"tags":[]},{"location":"cli/#integrations","level":2,"title":"Integrations","text":"Command Description <code>ctx setup</code> Generate AI tool integration configs <code>ctx steering</code> Manage steering files (behavioral rules for AI tools) <code>ctx trigger</code> Manage lifecycle triggers (scripts for automation) <code>ctx skill</code> Manage reusable instruction bundles <code>ctx mcp</code> MCP server for AI tool integration (stdin/stdout) <code>ctx hook notify</code> Webhook notifications (setup, test, send) <code>ctx loop</code> Generate autonomous loop script <code>ctx connection</code> Client-side commands for connecting to a <code>ctx</code> Hub <code>ctx hub</code> Operate a <code>ctx</code> Hub server or cluster <code>ctx serve</code> Serve a static site locally via zensical <code>ctx site</code> Site management (feed generation)","path":["CLI"],"tags":[]},{"location":"cli/#diagnostics","level":2,"title":"Diagnostics","text":"Command Description <code>ctx doctor</code> Structural health check (hooks, drift, config) <code>ctx trace</code> Show context behind git commits <code>ctx sysinfo</code> Show system resource usage (memory, swap, disk, load) <code>ctx usage</code> Show session token usage stats","path":["CLI"],"tags":[]},{"location":"cli/#runtime","level":2,"title":"Runtime","text":"Command Description <code>ctx config</code> Manage runtime configuration profiles <code>ctx prune</code> Clean stale per-session state files <code>ctx hook</code> Hook message, notification, and lifecycle controls <code>ctx system</code> Hook plumbing and agent-only commands (not user-facing)","path":["CLI"],"tags":[]},{"location":"cli/#shell","level":2,"title":"Shell","text":"Command Description <code>ctx completion</code> 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 <code>CTX_TOKEN_BUDGET</code> Override default token budget <code>CTX_SESSION_ID</code> Active AI session ID (used by <code>ctx trace</code> for context linking)","path":["CLI"],"tags":[]},{"location":"cli/#configuration-file","level":2,"title":"Configuration File","text":"<p>Optional <code>.ctxrc</code> (YAML format) at project root:</p> <pre><code># .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\nauto_prune_days: 7 # Days before stale session-state files are pruned on load (0/neg = default)\nagent_cooldown_minutes: 10 # Minutes between repeated `ctx agent` emissions (0 = disable)\ntask_budget_pct: 0.40 # Fraction of the agent token budget for tasks (0-1; 0 = none)\nconvention_budget_pct: 0.20 # Fraction of the agent token budget for conventions (0-1; 0 = none)\ntitle_slug_max_len: 50 # Max characters in journal filename slugs (0/neg = default)\nrecall_list_limit: 20 # Default `ctx journal source` list size (0/neg = default)\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\ndream: # ctx-dream config (opt-in; off by default)\n enabled: false # Master switch — nothing runs until true\n mode: discipline # Pass mode (v1: discipline)\n max: 50 # Max ideas/ files processed per pass\n cadence: \"30 2 * * *\" # Cron schedule for the nightly pass\n quiet_minutes: 60 # Skip a pass if active within this window\n budget: 40 # Step/token ceiling per pass\n model: \"\" # Executor model (\"\" = session default)\n executor: \"\" # Executor command (\"\" = claude -p reference)\n</code></pre> Field Type Default Description <code>token_budget</code> <code>int</code> <code>8000</code> Default token budget for <code>ctx agent</code> <code>priority_order</code> <code>[]string</code> (all files) File loading priority for context packets <code>auto_archive</code> <code>bool</code> <code>true</code> Auto-archive completed tasks <code>archive_after_days</code> <code>int</code> <code>7</code> Days before completed tasks are archived <code>scratchpad_encrypt</code> <code>bool</code> <code>true</code> Encrypt scratchpad with AES-256-GCM <code>event_log</code> <code>bool</code> <code>false</code> Enable local hook event logging to <code>.context/state/events.jsonl</code> <code>companion_check</code> <code>bool</code> <code>true</code> Check companion tool availability (canonical: Gemini Search, GitNexus; equivalents work) during <code>/ctx-remember</code> <code>entry_count_learnings</code> <code>int</code> <code>30</code> Drift warning when <code>LEARNINGS.md</code> exceeds this count <code>entry_count_decisions</code> <code>int</code> <code>20</code> Drift warning when <code>DECISIONS.md</code> exceeds this count <code>convention_line_count</code> <code>int</code> <code>200</code> Line count warning for <code>CONVENTIONS.md</code> <code>injection_token_warn</code> <code>int</code> <code>15000</code> Warn when auto-injected context exceeds this token count (0 = disable) <code>context_window</code> <code>int</code> <code>200000</code> Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools <code>billing_token_warn</code> <code>int</code> <code>0</code> (off) One-shot warning when session tokens exceed this threshold (0 = disabled) <code>key_rotation_days</code> <code>int</code> <code>90</code> Days before encryption key rotation nudge <code>session_prefixes</code> <code>[]string</code> <code>[\"Session:\"]</code> Recognized Markdown session header prefixes. Extend to parse sessions written in other languages <code>freshness_files</code> <code>[]object</code> (none) Files to track for staleness (path, desc, optional review_url). Hook warns after 6 months without modification <code>notify.events</code> <code>[]string</code> (all) Event filter for webhook notifications (empty = all) <code>tool</code> <code>string</code> (empty) Active AI tool identifier (<code>claude</code>, <code>cursor</code>, <code>cline</code>, <code>kiro</code>, <code>codex</code>) <code>steering.dir</code> <code>string</code> <code>.context/steering</code> Steering files directory <code>steering.default_inclusion</code> <code>string</code> <code>manual</code> Default inclusion mode for new steering files (<code>always</code>, <code>auto</code>, <code>manual</code>) <code>steering.default_tools</code> <code>[]string</code> (all) Default tool filter for new steering files (empty = all tools) <code>hooks.dir</code> <code>string</code> <code>.context/hooks</code> Hook scripts directory <code>hooks.timeout</code> <code>int</code> <code>10</code> Per-hook execution timeout in seconds <code>hooks.enabled</code> <code>bool</code> <code>true</code> Whether hook execution is enabled <code>auto_prune_days</code> <code>int</code> <code>7</code> Days before stale session-state files are auto-pruned on load (non-positive falls back to the default) <code>agent_cooldown_minutes</code> <code>int</code> <code>10</code> Minutes between repeated <code>ctx agent</code> emissions; an explicit <code>0</code> disables the cooldown <code>task_budget_pct</code> <code>number</code> <code>0.40</code> Fraction of the <code>ctx agent</code> token budget for tasks (clamped <code>0</code>–<code>1</code>; explicit <code>0</code> = none) <code>convention_budget_pct</code> <code>number</code> <code>0.20</code> Fraction of the <code>ctx agent</code> token budget for conventions (clamped <code>0</code>–<code>1</code>; explicit <code>0</code> = none) <code>title_slug_max_len</code> <code>int</code> <code>50</code> Maximum characters in title-derived journal filename slugs (non-positive falls back to the default) <code>recall_list_limit</code> <code>int</code> <code>20</code> Default <code>ctx journal source</code> list size when <code>--limit</code> is omitted (non-positive falls back to the default) <p>Priority order: CLI flags > Environment variables > <code>.ctxrc</code> > Defaults</p> <p>All settings are optional. Missing values use defaults.</p>","path":["CLI"],"tags":[]},{"location":"cli/bootstrap/","level":1,"title":"System Bootstrap","text":"","path":["CLI","Runtime","System Bootstrap"],"tags":[]},{"location":"cli/bootstrap/#ctx-system-bootstrap","level":3,"title":"<code>ctx system bootstrap</code>","text":"<p>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. <code>--quiet</code> prints just the path; <code>--json</code> produces structured output for automation.</p> <p>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?\".</p> <pre><code>ctx system bootstrap [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>-q</code>, <code>--quiet</code> Output only the context directory path <code>--json</code> Output in JSON format <p>Examples:</p> <pre><code>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</code></pre> <p>Note: <code>-q</code> prints just the resolved directory path. <code>ctx</code> reads <code>$PWD/.context/</code>; if you hit a \"no context here\" error, run <code>ctx init</code> from the project root or <code>cd</code> to one that already has <code>.context/</code>.</p>","path":["CLI","Runtime","System Bootstrap"],"tags":[]},{"location":"cli/change/","level":1,"title":"Change","text":"","path":["CLI","Context","Change"],"tags":[]},{"location":"cli/change/#ctx-change","level":2,"title":"<code>ctx change</code>","text":"<p>Show what changed in context files and code since your last session.</p> <p>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.</p> <pre><code>ctx change [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--since</code> Time reference: duration (<code>24h</code>) or date (<code>2026-03-01</code>) <p>Reference time detection (priority order):</p> <ol> <li><code>--since</code> flag (duration, date, or RFC3339 timestamp)</li> <li><code>ctx-loaded-*</code> marker files in <code>.context/state/</code> (second most recent)</li> <li>Last <code>context-load-gate</code> event from <code>.context/state/events.jsonl</code></li> <li>Fallback: 24 hours ago</li> </ol> <p>Examples:</p> <pre><code># 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</code></pre> <p>Output:</p> <pre><code>## 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</code></pre> <p>Context file changes are detected by filesystem mtime (works without git). Code changes use <code>git log --since</code> (empty when not in a git repo).</p> <p>See also: Reviewing Session Changes.</p>","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":"<code>ctx completion</code>","text":"<p>Generate shell autocompletion scripts.</p> <pre><code>ctx completion <shell>\n</code></pre>","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#subcommands","level":3,"title":"Subcommands","text":"Shell Command <code>bash</code> <code>ctx completion bash</code> <code>zsh</code> <code>ctx completion zsh</code> <code>fish</code> <code>ctx completion fish</code> <code>powershell</code> <code>ctx completion powershell</code> <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Shell","Completion"],"tags":[]},{"location":"cli/completion/#installation","level":3,"title":"Installation","text":"BashZshFishPowerShell <pre><code># Add to ~/.bashrc\nsource <(ctx completion bash)\n</code></pre> <pre><code># Add to ~/.zshrc\nsource <(ctx completion zsh)\n</code></pre> <pre><code>ctx completion fish | source\n# Or save to completions directory\nctx completion fish > ~/.config/fish/completions/ctx.fish\n</code></pre> <pre><code># Add to your PowerShell profile\nctx completion powershell | Out-String | Invoke-Expression\n</code></pre>","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":"<code>ctx config</code>","text":"<p>Manage runtime configuration profiles.</p> <pre><code>ctx config <subcommand>\n</code></pre> <p>The <code>ctx</code> repo ships two <code>.ctxrc</code> source profiles (<code>.ctxrc.base</code> and <code>.ctxrc.dev</code>). The working copy (<code>.ctxrc</code>) is gitignored and switched between them using subcommands below.</p>","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-switch","level":4,"title":"<code>ctx config switch</code>","text":"<p>Switch between <code>.ctxrc</code> configuration profiles.</p> <pre><code>ctx config switch [dev|base]\n</code></pre> <p>With no argument, toggles between dev and base. Accepts <code>prod</code> as an alias for <code>base</code>.</p> Argument Description <code>dev</code> Switch to dev profile (verbose logging) <code>base</code> Switch to base profile (all defaults) (none) Toggle to the opposite profile <p>Profiles:</p> Profile Description <code>dev</code> Verbose logging, webhook notifications on <code>base</code> All defaults, notifications off <p>Examples:</p> <pre><code>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</code></pre> <p>The detection heuristic checks for an uncommented <code>notify:</code> line in <code>.ctxrc</code>: present means dev, absent means base.</p>","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/config/#ctx-config-status","level":4,"title":"<code>ctx config status</code>","text":"<p>Show which <code>.ctxrc</code> profile is currently active.</p> <pre><code>ctx config status\n</code></pre> <p>Output examples:</p> <pre><code>active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n</code></pre> <p>See also: Configuration, Contributing: Configuration Profiles</p>","path":["CLI","Runtime","Config"],"tags":[]},{"location":"cli/connection/","level":1,"title":"Connect","text":"","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection","level":2,"title":"<code>ctx connection</code>","text":"<p>Connect a project to a <code>ctx</code> Hub for cross-project knowledge sharing. Projects publish decisions, learnings, conventions, and tasks to a hub; other subscribed projects receive them alongside local context.</p> <p>New to the <code>ctx</code> Hub?</p> <p>Start with the <code>ctx</code> 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.</p> <p>The unit of identity is a project, not a user. Registering a directory with <code>ctx connection register</code> binds a per-project client token in <code>.context/.connect.enc</code>. Two developers on the same project either share that file over a trusted channel, or each register under a different project name.</p> <p>Only structured entries flow through the hub: <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. Session journals, scratchpad contents, and other local state stay on the machine that created them.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-register","level":3,"title":"<code>ctx connection register</code>","text":"<p>One-time registration with a <code>ctx</code> Hub. Requires the <code>ctx</code> Hub address and admin token (printed by <code>ctx hub start</code> on first run).</p> <p>Examples:</p> <pre><code>ctx connection register localhost:9900 --token ctx_adm_7f3a...\n</code></pre> <p>On success, stores an encrypted connection config in <code>.context/.connect.enc</code> for future RPCs.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-subscribe","level":3,"title":"<code>ctx connection subscribe</code>","text":"<p>Set which entry types to receive from the <code>ctx</code> Hub. Only matching types are returned by sync and listen.</p> <p>Examples:</p> <pre><code>ctx connection subscribe decision learning\nctx connection subscribe decision learning convention\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-sync","level":3,"title":"<code>ctx connection sync</code>","text":"<p>Pull matching entries from the <code>ctx</code> Hub and write them to <code>.context/hub/</code> as Markdown files with origin tags and date headers. Tracks last-seen sequence for incremental sync.</p> <p>Examples:</p> <pre><code>ctx connection sync\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-publish","level":3,"title":"<code>ctx connection publish</code>","text":"<p>Push entries to the <code>ctx</code> Hub. Specify type and content as arguments.</p> <p>Examples:</p> <pre><code>ctx connection publish decision \"Use UTC timestamps everywhere\"\nctx connection publish learning \"Go embed requires files in same package\"\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-listen","level":3,"title":"<code>ctx connection listen</code>","text":"<p>Stream new entries from the <code>ctx</code> Hub in real-time. Writes to <code>.context/hub/</code> as entries arrive. Press Ctrl-C to stop.</p> <p>Examples:</p> <pre><code>ctx connection listen\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#ctx-connection-status","level":3,"title":"<code>ctx connection status</code>","text":"<p>Show <code>ctx</code> Hub connection state and entry statistics.</p> <p>Examples:</p> <pre><code>ctx connection status\n</code></pre>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#automatic-sharing","level":2,"title":"Automatic Sharing","text":"<p>Use <code>--share</code> on <code>ctx add</code> to write locally AND publish to the <code>ctx</code> Hub:</p> <pre><code>ctx decision add \"Use UTC\" --share \\\n --context \"Need consistency\" \\\n --rationale \"Avoid timezone bugs\" \\\n --consequence \"UI does conversion\"\n</code></pre> <p>If the hub is unreachable, the local write succeeds and a warning is printed. The <code>--share</code> flag is best-effort; it never blocks local context updates.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#auto-sync","level":2,"title":"Auto-Sync","text":"<p>Once registered, the <code>check-hub-sync</code> hook automatically syncs new entries from the <code>ctx</code> Hub at the start of each session (daily throttled). No manual <code>ctx connection sync</code> needed.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#shared-files","level":2,"title":"Shared Files","text":"<p>Entries from the <code>ctx</code> Hub are stored in <code>.context/hub/</code>:</p> <pre><code>.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</code></pre> <p>These files are read-only (managed by sync/listen) and never mixed with local context files.</p>","path":["CLI","Integrations","Connect"],"tags":[]},{"location":"cli/connection/#agent-integration","level":2,"title":"Agent Integration","text":"<p>Include shared knowledge in agent context packets:</p> <pre><code>ctx agent --include-hub\n</code></pre> <p>Shared entries are included as Tier 8 in the budget-aware assembly, scored by recency and type relevance.</p>","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":"<p>Each context-artifact noun (<code>task</code>, <code>decision</code>, <code>learning</code>, <code>convention</code>) owns its own <code>add</code> subcommand under the noun-first command tree:</p> <pre><code>ctx task add <content> [flags]\nctx decision add <content> [flags]\nctx learning add <content> [flags]\nctx convention add <content> [flags]\n</code></pre> <p>Target files:</p> Subcommand Target File <code>ctx task add</code> <code>TASKS.md</code> <code>ctx decision add</code> <code>DECISIONS.md</code> <code>ctx learning add</code> <code>LEARNINGS.md</code> <code>ctx convention add</code> <code>CONVENTIONS.md</code> <p>Flags (shared by every <code>add</code> subcommand; per-noun required-flag rules surface as command errors):</p> Flag Short Description <code>--priority <level></code> <code>-p</code> Priority for tasks: <code>high</code>, <code>medium</code>, <code>low</code> <code>--section <name></code> <code>-s</code> Target section within file <code>--context</code> <code>-c</code> Context (required for decisions and learnings) <code>--rationale</code> <code>-r</code> Rationale for decisions (required for decisions) <code>--consequence</code> Consequence for decisions (required for decisions) <code>--lesson</code> <code>-l</code> Key insight (required for learnings) <code>--application</code> <code>-a</code> How to apply going forward (required for learnings) <code>--file</code> <code>-f</code> Read content from file instead of argument <code>--json-file <path></code> Read a JSON payload that populates the typed fields directly (supersedes the content flags) <p>Examples:</p> <pre><code># 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\n# Ingest a JSON payload (keeps flag-value content off the command line,\n# so a value containing a permissions-denied substring still persists)\ncat > /tmp/decision.json <<'EOF'\n{\n \"title\": \"Install ctx into the system PATH\",\n \"context\": \"agents invoke ctx by bare name\",\n \"rationale\": \"the binary belongs at /usr/local/bin so it is on PATH\",\n \"consequence\": \"ctx resolves from any working directory\",\n \"provenance\": {\"session_id\": \"abc12345\", \"branch\": \"main\", \"commit\": \"68fbc00a\"}\n}\nEOF\nctx decision add --json-file /tmp/decision.json\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-drift","level":3,"title":"<code>ctx drift</code>","text":"<p>Detect stale or invalid context.</p> <pre><code>ctx drift [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--json</code> Output machine-readable JSON <code>--fix</code> Auto-fix simple issues <p>Checks:</p> <ul> <li>Path references in <code>ARCHITECTURE.md</code> and <code>CONVENTIONS.md</code> exist</li> <li>Task references are valid</li> <li>Constitution rules aren't violated (heuristic)</li> <li>Staleness indicators (old files, many completed tasks)</li> <li>Missing packages: warns when <code>internal/</code> directories exist on disk but are not referenced in <code>ARCHITECTURE.md</code> (suggests running <code>/ctx-architecture</code>)</li> <li>Entry count: warns when <code>LEARNINGS.md</code> or <code>DECISIONS.md</code> exceed configurable thresholds (default: 30 learnings, 20 decisions), or when <code>CONVENTIONS.md</code> exceeds a line count threshold (default: 200). Configure via <code>.ctxrc</code>: <pre><code>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</code></pre></li> </ul> <p>Example:</p> <pre><code>ctx drift\nctx drift --json\nctx drift --fix\n</code></pre> <p>Exit codes:</p> 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":"<code>ctx sync</code>","text":"<p>Reconcile context with the current codebase state.</p> <pre><code>ctx sync [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--dry-run</code> Show what would change without modifying <p>What it does:</p> <ul> <li>Scans codebase for structural changes</li> <li>Compares with ARCHITECTURE.md</li> <li>Suggests documenting dependencies if package files exist</li> <li>Identifies stale or outdated context</li> </ul> <p>Example:</p> <pre><code>ctx sync\nctx sync --dry-run\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-compact","level":3,"title":"<code>ctx compact</code>","text":"<p>Consolidate and clean up context files.</p> <ul> <li>Moves completed tasks older than 7 days to the archive</li> <li>Removes empty sections</li> </ul> <pre><code>ctx compact [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--archive</code> Create <code>.context/archive/</code> for old content <p>Example:</p> <pre><code>ctx compact\nctx compact --archive\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-fmt","level":3,"title":"<code>ctx fmt</code>","text":"<p>Format context files to a consistent line width.</p> <p>Wraps long lines in <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, and <code>CONVENTIONS.md</code> at word boundaries. Markdown list items get 2-space continuation indent. Headings, tables, frontmatter, and HTML comments are preserved as-is.</p> <p>Idempotent: running twice produces the same output.</p> <pre><code>ctx fmt [flags]\n</code></pre> <p>Flags:</p> Flag Type Default Description <code>--width</code> <code>int</code> <code>80</code> Target line width <code>--check</code> <code>bool</code> <code>false</code> Check only, exit 1 if files would change <p>Examples:</p> <pre><code>ctx fmt # format all context files\nctx fmt --check # CI mode: check without modifying\nctx fmt --width 100 # custom width\n</code></pre> <p>Also available as a Makefile target:</p> <pre><code>make fmt-context\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task","level":3,"title":"<code>ctx task</code>","text":"<p>Manage task completion, archival, and snapshots.</p> <pre><code>ctx task <subcommand>\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-complete","level":4,"title":"<code>ctx task complete</code>","text":"<p>Mark a task as completed.</p> <pre><code>ctx task complete <task-id-or-text>\n</code></pre> <p>Arguments:</p> <ul> <li><code>task-id-or-text</code>: Task number or partial text match</li> </ul> <p>Examples:</p> <pre><code># By text (partial match)\nctx task complete \"user auth\"\n\n# By task number\nctx task complete 3\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-archive","level":4,"title":"<code>ctx task archive</code>","text":"<p>Move completed tasks from <code>TASKS.md</code> to a timestamped archive file.</p> <pre><code>ctx task archive [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--dry-run</code> Preview changes without modifying files <p>Archive files are stored in <code>.context/archive/</code> with timestamped names (<code>tasks-YYYY-MM-DD.md</code>). Completed tasks (marked with <code>[x]</code>) are moved; pending tasks (<code>[ ]</code>) remain in <code>TASKS.md</code>.</p> <p>Example:</p> <pre><code>ctx task archive\nctx task archive --dry-run\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-task-snapshot","level":4,"title":"<code>ctx task snapshot</code>","text":"<p>Create a point-in-time snapshot of <code>TASKS.md</code> without modifying the original.</p> <pre><code>ctx task snapshot [name]\n</code></pre> <p>Arguments:</p> <ul> <li><code>name</code>: Optional name for the snapshot (defaults to \"snapshot\")</li> </ul> <p>Snapshots are stored in <code>.context/archive/</code> with timestamped names (<code>tasks-<name>-YYYY-MM-DD-HHMM.md</code>).</p> <p>Example:</p> <pre><code>ctx task snapshot\nctx task snapshot \"before-refactor\"\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission","level":3,"title":"<code>ctx permission</code>","text":"<p>Manage Claude Code permission snapshots.</p> <pre><code>ctx permission <subcommand>\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-snapshot","level":4,"title":"<code>ctx permission snapshot</code>","text":"<p>Save <code>.claude/settings.local.json</code> as the golden image.</p> <pre><code>ctx permission snapshot\n</code></pre> <p>Creates <code>.claude/settings.golden.json</code> as a byte-for-byte copy of the current settings. Overwrites if the golden file already exists.</p> <p>The golden file is meant to be committed to version control and shared with the team.</p> <p>Example:</p> <pre><code>ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-permission-restore","level":4,"title":"<code>ctx permission restore</code>","text":"<p>Replace <code>settings.local.json</code> with the golden image.</p> <pre><code>ctx permission restore\n</code></pre> <p>Prints a diff of dropped (session-accumulated) and restored permissions. No-op if the files already match.</p> <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-index","level":3,"title":"<code>ctx index</code>","text":"<p>Project the Markdown headings of a knowledge file as a computed table of contents — recomputed on demand, never stored in the file.</p> <pre><code>ctx index <file> [--depth N] [--json]\n</code></pre> <p>One generic command serves every knowledge file: <code>DECISIONS.md</code> and <code>LEARNINGS.md</code> (<code>## [timestamp] Title</code> entries), <code>CONVENTIONS.md</code>, and <code>TASKS.md</code> (<code>## Phase …</code> sections). By default only level-2 (<code>##</code>) headings are shown; <code>--depth 3</code> includes level-3 (<code>###</code>) sub-headings, and <code>--json</code> emits a machine-readable array of <code>{level, text}</code>.</p> <p>Because the index is computed, it can never drift from the entries it summarizes, and adding an entry never rewrites the file's structure.</p> <p>Example:</p> <pre><code>ctx index .context/DECISIONS.md\n# [2026-07-09-093951] Ship #131 as interim hub token revocation\n# [2026-07-06-214523] Journal resume picks the richest transcript\n# ...\n\nctx index .context/TASKS.md --depth 3\nctx index .context/LEARNINGS.md --json\n</code></pre>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-decision","level":3,"title":"<code>ctx decision</code>","text":"<p>Manage the <code>DECISIONS.md</code> file.</p> <pre><code>ctx decision <subcommand>\n</code></pre> <p>Use <code>ctx decision add</code> to append entries; see <code>ctx index</code> to project a table of contents on demand.</p>","path":["CLI","Context","Context Management"],"tags":[]},{"location":"cli/context/#ctx-learning","level":3,"title":"<code>ctx learning</code>","text":"<p>Manage the <code>LEARNINGS.md</code> file.</p> <pre><code>ctx learning <subcommand>\n</code></pre> <p>Use <code>ctx learning add</code> to append entries; see <code>ctx index</code> to project a table of contents on demand.</p>","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":"<code>ctx doctor</code>","text":"<p>Structural health check across context, hooks, and configuration. Runs mechanical checks that don't require semantic analysis. Think of it as <code>ctx status</code> + <code>ctx drift</code> + configuration audit in one pass.</p> <pre><code>ctx doctor [flags]\n</code></pre> <p>Flags:</p> Flag Short Type Default Description <code>--json</code> <code>-j</code> bool <code>false</code> 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 <code>.context/</code> directory exists Required files present Structure All required context files exist (<code>TASKS.md</code>, etc.) Drift detected Quality Stale paths, missing files, constitution violations Event logging status Hooks Whether <code>event_log: true</code> is set in <code>.ctxrc</code> Webhook configured Hooks <code>.notify.enc</code> file exists Pending reminders State Count of entries in <code>reminders.json</code> Task completion ratio State Pending vs completed tasks in <code>TASKS.md</code> 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":"<pre><code>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</code></pre> <p>Status indicators:</p> 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":"<pre><code>{\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</code></pre> <p>Examples:</p> <pre><code># 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</code></pre>","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#when-to-use-what","level":4,"title":"When to Use What","text":"Tool When <code>ctx status</code> Quick glance at files, tokens, and drift <code>ctx doctor</code> Thorough structural checkup (hooks, config, events too) <code>/ctx-doctor</code> Agent-driven diagnosis with event log pattern analysis <p><code>ctx status</code> tells you what's there. <code>ctx doctor</code> tells you what's wrong. <code>/ctx-doctor</code> tells you why it's wrong and what to do about it.</p>","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/doctor/#what-it-does-not-do","level":4,"title":"What It Does Not Do","text":"<ul> <li>No event pattern analysis: that's the <code>/ctx-doctor</code> skill's job</li> <li>No auto-fixing: reports findings, doesn't modify anything</li> <li>No external service checks: doesn't verify webhook endpoint availability</li> </ul> <p>See also: Troubleshooting | <code>ctx hook event</code> | <code>/ctx-doctor</code> skill | Detecting and Fixing Drift</p>","path":["CLI","Diagnostics","Doctor"],"tags":[]},{"location":"cli/dream/","level":1,"title":"Dream","text":"","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream","level":2,"title":"<code>ctx dream</code>","text":"<p>Run a disciplined, out-of-band dream pass over the gitignored <code>ideas/</code> folder: classify each idea against the codebase and specs, and emit gated, provenance-bearing disposition proposals into the <code>dreams/</code> notebook for human review. The dream only ever proposes — it never writes canonical memory and never acts on a proposal.</p> <p>The dream is opt-in and off by default. Nothing runs until you set <code>dream.enabled: true</code> in <code>.ctxrc</code>. See the Run the Dream recipe for the full setup (cron, guard hook, review), and the executor contract to run it under a non-Claude-Code harness.</p> <p>Invoked with no subcommand, it runs one bounded pass: it gates on the idea delta and the quiet window, takes an exclusive lock, invokes the configured executor (default <code>claude -p</code> with the <code>ctx-dream</code> skill), and fails loud (writing <code>dreams/.failed</code>) if the executor is missing or errors — it never silently no-ops.</p> <pre><code>ctx dream [flags]\nctx dream <subcommand>\n</code></pre> <p>Flags:</p> Flag Description <code>--mode</code> Pass mode (<code>discipline</code>; default from <code>.ctxrc dream.mode</code>) <code>--max</code> Max <code>ideas/</code> files processed this pass (default <code>dream.max</code>) <code>--budget</code> Step/token budget for the pass (default <code>dream.budget</code>) <code>--force</code> Bypass the trigger gate (opt-in + cadence + quiet window) <p>Examples:</p> <pre><code>ctx dream\nctx dream --max 20 --force\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-review","level":3,"title":"<code>ctx dream review</code>","text":"<p>List the pending proposals from the latest pass — those not yet decided in the ledger — rendered substance-forward (summary, status, action, evidence, confidence, rationale). This is the read side of the <code>/ctx-serendipity</code> garden walk.</p> <pre><code>ctx dream review\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-accept-id","level":3,"title":"<code>ctx dream accept <id></code>","text":"<p>Accept a proposal's recommended action. Mechanical actions (<code>archive</code>, <code>mark-blog</code>, <code>keep</code>) apply immediately with both guards enforced and a ledger entry recorded; generative actions (<code>promote</code>, <code>merge</code>) record accepted intent and are completed from the full source via <code>/ctx-serendipity</code>.</p> <p>Arguments:</p> <ul> <li><code>id</code>: the proposal ID (from <code>ctx dream review</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--note</code> Optional human note recorded in the ledger <p>Examples:</p> <pre><code>ctx dream accept a1b2c3\nctx dream accept a1b2c3 --note \"good catch\"\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-reject-id","level":3,"title":"<code>ctx dream reject <id></code>","text":"<p>Record a rejection. No mutation occurs; the proposal is not re-surfaced unless its source idea changes (dedup-against-seen).</p> <p>Arguments:</p> <ul> <li><code>id</code>: the proposal ID</li> </ul> <p>Flags:</p> Flag Description <code>--note</code> Optional human note recorded in the ledger <p>Examples:</p> <pre><code>ctx dream reject a1b2c3\nctx dream reject a1b2c3 --note \"still relevant\"\n</code></pre>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/dream/#ctx-dream-amend-id-action-action","level":3,"title":"<code>ctx dream amend <id> --action <action></code>","text":"<p>Apply a different action than the one proposed, recording the decision as amended (original provenance preserved).</p> <p>Arguments:</p> <ul> <li><code>id</code>: the proposal ID</li> </ul> <p>Flags:</p> Flag Description <code>--action</code> The action to apply instead (<code>archive</code>/<code>merge</code>/<code>promote</code>/<code>mark-blog</code>/<code>keep</code>) <code>--note</code> Optional human note recorded in the ledger <p>Examples:</p> <pre><code>ctx dream amend a1b2c3 --action keep\nctx dream amend a1b2c3 --action archive --note \"superseded\"\n</code></pre> <p>See also: Run the Dream recipe · Executor contract.</p>","path":["CLI","Sessions","Dream"],"tags":[]},{"location":"cli/event/","level":1,"title":"Event","text":"","path":["CLI","Runtime","Event"],"tags":[]},{"location":"cli/event/#ctx-hook-event","level":3,"title":"<code>ctx hook event</code>","text":"<p>Query the local hook event log. Requires <code>event_log: true</code> in <code>.ctxrc</code>. Reads events from <code>.context/state/events.jsonl</code> and outputs them in a human-readable table or raw JSONL format.</p> <p>All filter flags combine with AND logic.</p> <pre><code>ctx hook event [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--hook</code> Filter by hook name <code>--session</code> Filter by session ID <code>--event</code> Filter by event type (<code>relay</code>, <code>nudge</code>) <code>--last</code> Show last N events (default: 50) <code>--json</code> Output raw JSONL (for piping to <code>jq</code>) <code>--all</code> Include rotated log file <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Runtime","Event"],"tags":[]},{"location":"cli/guide/","level":1,"title":"Guide","text":"","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/guide/#ctx-guide","level":2,"title":"<code>ctx guide</code>","text":"<p>Quick-reference cheat sheet for common <code>ctx</code> commands and skills.</p> <pre><code>ctx guide [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--skills</code> Show available skills <code>--commands</code> Show available CLI commands <p>Example:</p> <pre><code># Show the full cheat sheet\nctx guide\n\n# Skills only\nctx guide --skills\n\n# Commands only\nctx guide --commands\n</code></pre> <p>Works without initialization (no <code>.context/</code> required). Useful for a printable one-pager when onboarding to a project.</p>","path":["CLI","Getting Started","Guide"],"tags":[]},{"location":"cli/handover/","level":1,"title":"ctx handover","text":"","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#ctx-handover","level":2,"title":"<code>ctx handover</code>","text":"<p>Writes the per-session handover under <code>.context/handovers/<TS>-<slug>.md</code>: a former-agent-to-next-agent note created at session end by <code>/ctx-wrap-up</code> and read at session start by <code>/ctx-remember</code>. When <code>.context/kb/</code> exists, the writer additionally folds postdated closeouts into the handover's <code>## Folded Closeouts</code> section and archives them.</p>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#ctx-handover-write-title","level":3,"title":"<code>ctx handover write <title></code>","text":"<pre><code>ctx handover write \"Cursor Hooks deep dive\" \\\n --summary \"Drafted topic-page; minted EV-018..EV-024; cold-reader passed.\" \\\n --next \"Re-ingest the v1.1 release notes URL once you have it.\"\n</code></pre> <p>Required flags:</p> Flag Description <code>--summary</code> What happened this session (past tense). Placeholder values (<code>TBD</code>, <code>see chat</code>, <code>n/a</code>) are rejected. <code>--next</code> What the next agent should do FIRST (future tense, specific). Same placeholder rejection. <p>Optional flags:</p> Flag Description <code>--highlights</code> Notable artifacts produced this session. <code>--open-questions</code> Things that remain undecided. <code>--commit</code> Override resolved git HEAD for the Provenance line (CI replay; honors <code>CTX_TASK_COMMIT</code>). <code>--no-fold</code> Skip closeout consumption (mid-session checkpoint). <p>Writes: <code>.context/handovers/<TS>-<slug>.md</code> with frontmatter (<code>sha</code>, <code>branch</code>, <code>generated-at</code>, <code>title</code>) and body sections (<code>## Summary</code>, <code>## Next Session</code>, optionally <code>## Highlights</code>, <code>## Open Questions</code>, <code>## Folded Closeouts</code>). The <code><TS>-<slug>.md</code> filename is timestamped so multiple concurrent agent runs never overwrite one another's handover.</p> <p>Side effect (when <code>--no-fold</code> is absent and <code>.context/kb/</code> exists): closeouts that postdate the latest handover are folded into the new handover and physically archived under <code>.context/archive/closeouts/</code>.</p>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#how-to-trigger","level":3,"title":"How to Trigger","text":"<p>In ordinary sessions you do not invoke <code>ctx handover write</code> directly. The user-facing trigger is <code>/ctx-wrap-up</code>:</p> <pre><code>/ctx-wrap-up \"session title\"\n</code></pre> <p><code>/ctx-wrap-up</code> owns session-end and always delegates to <code>/ctx-handover</code> as its final step. Direct invocation of <code>/ctx-handover</code> is reserved for two cases:</p> <ul> <li><code>--no-fold</code> mid-session checkpoint.</li> <li>Recovery, when a prior session aborted before wrap-up.</li> </ul> <p>See <code>/ctx-wrap-up</code> and <code>/ctx-handover</code>.</p>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/handover/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Session Lifecycle</li> <li>Recipe: Recover an Aborted Session</li> <li>Skill: <code>/ctx-wrap-up</code></li> <li>Skill: <code>/ctx-handover</code></li> <li>Skill: <code>/ctx-remember</code></li> </ul>","path":["CLI","Sessions","ctx handover"],"tags":[]},{"location":"cli/hook/","level":1,"title":"Hook","text":"","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#ctx-hook","level":3,"title":"<code>ctx hook</code>","text":"<p>Manage hook-related settings: messages, notifications, pause/resume, and event log.</p> <pre><code>ctx hook <subcommand> [flags]\n</code></pre>","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#subcommands","level":2,"title":"Subcommands","text":"Subcommand Description <code>ctx hook message list</code> Show all hook messages with override status <code>ctx hook message show <h> <v></code> Print the effective message template <code>ctx hook message edit <h> <v></code> Copy default to <code>.context/</code> for editing <code>ctx hook message reset <h> <v></code> Delete user override, revert to default <code>ctx hook notify [message]</code> Send a webhook notification <code>ctx hook notify setup</code> Configure and encrypt webhook URL <code>ctx hook notify test</code> Send a test notification <code>ctx hook pause</code> Pause all context hooks for this session <code>ctx hook resume</code> Resume paused context hooks <code>ctx hook event</code> Query the local hook event log","path":["CLI","Runtime","Hook"],"tags":[]},{"location":"cli/hook/#examples","level":2,"title":"Examples","text":"<pre><code># 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</code></pre> <p>See also: Customizing Hook Messages | Webhook Notifications | Pausing Context Hooks | System Hooks Audit</p>","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":"<code>ctx hub</code>","text":"<p>Operator commands for a <code>ctx</code> Hub: the gRPC server that fans out decisions, learnings, conventions, and tasks across projects. Use <code>ctx hub</code> to start and stop the server, inspect cluster state, add or remove peers at runtime, and hand off leadership before maintenance.</p> <p>Who Needs This Page</p> <p>You only need <code>ctx hub</code> if you are running a hub server or cluster. For client-side operations (register, subscribe, sync, publish, listen), see <code>ctx connection</code>. For the mental model behind the hub as a whole, read the <code>ctx</code> Hub overview.</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-start","level":3,"title":"<code>ctx hub start</code>","text":"<p>Start the hub gRPC server.</p> <p>Examples:</p> <pre><code>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</code></pre> <p>On first run, generates an admin token and prints it to stdout. Save this token; it's required for <code>ctx connection register</code> in client projects. Subsequent runs reuse the stored token from <code><data-dir>/admin.token</code>.</p> <p>Default data directory: <code>~/.ctx/hub-data/</code></p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#daemon-mode","level":4,"title":"Daemon Mode","text":"<p>Run the hub as a detached background process:</p> <pre><code>ctx hub start --daemon # Fork to background\nctx hub stop # Graceful shutdown\n</code></pre> <p>The daemon writes a PID file to <code><data-dir>/hub.pid</code>. Stop the daemon with <code>ctx hub stop</code> (see below).</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#cluster-mode","level":4,"title":"Cluster Mode","text":"<p>For high availability, run multiple hubs with Raft-based leader election:</p> <pre><code>ctx hub start --port 9900 \\\n --peers host2:9901,host3:9901\n</code></pre> <p>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.</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#flags","level":4,"title":"Flags","text":"Flag Description Default <code>--port</code> Hub listen port <code>9900</code> <code>--data-dir</code> Hub data directory <code>~/.ctx/hub-data/</code> <code>--daemon</code> Run the hub server in the background <code>false</code> <code>--peers</code> Comma-separated peer addresses for cluster mode (none)","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#validation","level":4,"title":"Validation","text":"<p>The hub validates every published entry before accepting it:</p> <ul> <li>Type must be one of <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code></li> <li>ID and Origin are required and non-empty</li> <li>Content size capped at 1 MB (text-only)</li> <li>Duplicate project registration is rejected (one token per project)</li> </ul>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stop","level":3,"title":"<code>ctx hub stop</code>","text":"<p>Stop a running hub daemon.</p> <p>Examples:</p> <pre><code>ctx hub stop # Stop using default data dir\nctx hub stop --data-dir /srv/ctx-hub # Custom data directory\n</code></pre> <p>Sends <code>SIGTERM</code> to the PID recorded in <code><data-dir>/hub.pid</code>, 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.</p>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-status","level":3,"title":"<code>ctx hub status</code>","text":"<p>Show cluster status: role, peers, sync state, entry count, and uptime.</p> <p>Examples:</p> <pre><code>ctx hub status\n</code></pre>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-peer","level":3,"title":"<code>ctx hub peer</code>","text":"<p>Add or remove peers from the cluster at runtime. Useful for scaling up or replacing a decommissioned node without restarting the leader.</p> <p>Examples:</p> <pre><code>ctx hub peer add host2:9901\nctx hub peer remove host2:9901\n</code></pre>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#ctx-hub-stepdown","level":3,"title":"<code>ctx hub stepdown</code>","text":"<p>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.</p> <p>Examples:</p> <pre><code>ctx hub stepdown\n</code></pre>","path":["CLI","Integrations","Hub"],"tags":[]},{"location":"cli/hub/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx connection</code>: client-side commands (register, subscribe, sync, publish, listen)</li> <li><code>ctx</code> Hub overview: mental model and user stories</li> <li><code>ctx</code> Hub: Getting Started</li> <li>Hub operations: production deployment, backup, monitoring</li> <li>Hub failure modes</li> <li>Hub security model</li> </ul>","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":"<code>ctx init</code>","text":"<p>Initialize a new <code>.context/</code> directory with template files.</p> <pre><code>ctx init [flags]\n</code></pre> <p>Git is required</p> <p><code>ctx init</code> (and every non-administrative <code>ctx</code> subcommand) refuses to operate without a <code>.git/</code> working tree at the project root. <code>ctx</code> already needed git to work properly; that requirement is now enforced rather than assumed.</p> <p>Handovers and closeouts stamp the current commit into their frontmatter, and the editorial pipeline pins in-repo evidence to a short SHA (none of which works without a repo). </p> <p>Run <code>git init</code> first if the project does not already have one. </p> <p>There is no <code>--allow-no-git</code> escape hatch. </p> <p>Flags:</p> Flag Short Description <code>--force</code> <code>-f</code> Overwrite existing context files <code>--minimal</code> <code>-m</code> Only create essential files (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>CONSTITUTION.md</code>) <code>--merge</code> Auto-merge <code>ctx</code> content into existing <code>CLAUDE.md</code> <p>Creates:</p> <ul> <li><code>.context/</code> directory with all template files</li> <li><code>.context/kb/</code> (with <code>index.md</code> and <code>topics/</code>) and <code>.context/ingest/</code> (with <code>KB-RULES.md</code>, mode prompts, <code>OPERATOR.md</code>, <code>PROMPT.md</code>, <code>closeouts/</code>, <code>schemas/</code>) and <code>.context/handovers/</code>: the editorial-pipeline scaffolding (Phase KB). Embedded templates are copied; existing files are preserved.</li> <li><code>.claude/settings.local.json</code> with pre-approved <code>ctx</code> permissions</li> <li><code>CLAUDE.md</code> with bootstrap instructions (or merges into existing)</li> </ul> <p>Claude Code hooks and skills are provided by the <code>ctx</code> plugin (see Integrations).</p> <p>Example:</p> <pre><code># 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</code></pre> <p>After <code>ctx init</code> succeeds, <code>.context/</code> and the canonical files are created in <code>$PWD</code>. Run subsequent <code>ctx</code> commands from the same directory (the project root); <code>ctx</code> always reads <code>$PWD/.context/</code>.</p>","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-status","level":3,"title":"<code>ctx status</code>","text":"<p>Show the current context summary.</p> <pre><code>ctx status [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--json</code> Output as JSON <code>--verbose</code> <code>-v</code> Include file contents summary <p>Output:</p> <ul> <li>Context directory path</li> <li>Total files and token estimate</li> <li>Status of each file (loaded, empty, missing)</li> <li>Recent activity (modification times)</li> <li>Drift warnings if any</li> </ul> <p>Example:</p> <pre><code>ctx status\nctx status --json\nctx status --verbose\n</code></pre>","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-agent","level":3,"title":"<code>ctx agent</code>","text":"<p>Print an AI-ready context packet optimized for LLM consumption.</p> <pre><code>ctx agent [flags]\n</code></pre> <p>Flags:</p> Flag Default Description <code>--budget</code> 8000 Token budget: controls content selection and prioritization <code>--format</code> md Output format: <code>md</code> or <code>json</code> <code>--cooldown</code> 10m Suppress repeated output within this duration (requires <code>--session</code>) <code>--session</code> (none) Session ID for cooldown isolation (e.g., <code>$PPID</code>) <code>--include-hub</code> false Include hub entries from <code>.context/hub/</code> <p>How budget works:</p> <p>The budget controls how much context is included. Entries are selected in priority tiers:</p> <ol> <li>Constitution: always included in full (inviolable rules)</li> <li>Tasks: all active tasks, up to 40% of budget</li> <li>Conventions: all conventions, up to 20% of budget</li> <li>Decisions: scored by recency and relevance to active tasks</li> <li>Learnings: scored by recency and relevance to active tasks</li> <li>Steering: applicable steering file bodies, scored by their <code>inclusion</code> mode and description match against the active prompt</li> <li>Skill: named skill content (from <code>--skill</code>)</li> <li>Hub: entries from <code>.context/hub/</code> (with <code>--include-hub</code>, see <code>ctx connection</code>)</li> </ol> <p>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.</p> <p>Output Sections:</p> Section Source Selection Read These Files all <code>.context/</code> Non-empty files in priority order Constitution <code>CONSTITUTION.md</code> All rules (never truncated) Current Tasks <code>TASKS.md</code> All unchecked tasks (budget-capped) Key Conventions <code>CONVENTIONS.md</code> All items (budget-capped) Recent Decisions <code>DECISIONS.md</code> Full body, scored by relevance Key Learnings <code>LEARNINGS.md</code> Full body, scored by relevance Also Noted overflow Title-only summaries <p>Example:</p> <pre><code># 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</code></pre> <p>Use case: Copy-paste into AI chat, pipe to system prompt, or use in hooks.</p>","path":["CLI","Getting Started","Init and Status"],"tags":[]},{"location":"cli/init-status/#ctx-load","level":3,"title":"<code>ctx load</code>","text":"<p>Load and display assembled context as AI would see it.</p> <pre><code>ctx load [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--budget <tokens></code> Token budget for assembly (default: 8000) <code>--raw</code> Output raw file contents without assembly <p>Example:</p> <pre><code>ctx load\nctx load --budget 16000\nctx load --raw\n</code></pre>","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":"<code>ctx journal</code>","text":"<p>Browse and search AI session history from Claude Code and other tools.</p> <pre><code>ctx journal <subcommand>\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source","level":4,"title":"<code>ctx journal source</code>","text":"<p>List all parsed sessions.</p> <pre><code>ctx journal source [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--limit</code> <code>-M</code> Maximum sessions to display (default: 20) <code>--project</code> <code>-p</code> Filter by project name <code>--tool</code> <code>-t</code> Filter by tool (e.g., <code>claude-code</code>) <code>--since</code> Show sessions on or after this date (YYYY-MM-DD) <code>--until</code> Show sessions on or before this date (YYYY-MM-DD) <code>--all-projects</code> Include sessions from all projects <p>Sessions are sorted by date (newest first) and display slug, project, start time, duration, turn count, and token usage.</p> <p>Example:</p> <pre><code>ctx journal source\nctx journal source --limit 5\nctx journal source --project ctx\nctx journal source --tool claude-code\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-source-show","level":4,"title":"<code>ctx journal source --show</code>","text":"<p>Show details of a specific session.</p> <pre><code>ctx journal source --show [session-id] [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--latest</code> Show the most recent session <code>--full</code> Show full message content <code>--all-projects</code> Search across all projects <p>The session ID can be a full UUID, partial match, or session slug name.</p> <p>Example:</p> <pre><code>ctx journal source --show abc123\nctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show --latest\nctx journal source --show --latest --full\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-import","level":4,"title":"<code>ctx journal import</code>","text":"<p>Import sessions to editable journal files in <code>.context/journal/</code>.</p> <pre><code>ctx journal import [session-id] [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--all</code> Import new sessions and complete any whose transcript has grown <code>--all-projects</code> Import from all projects <code>--regenerate</code> Edge case: force a full re-render of existing entries <code>--keep-frontmatter</code> Preserve enriched YAML frontmatter during regeneration (default: true) <code>--yes</code>, <code>-y</code> Skip confirmation prompt <code>--dry-run</code> Show what would be imported without writing files <p>Self-healing, no flags required. Import's unit of memory is the source transcript, not the output file. A sweep (<code>--all</code>) automatically:</p> <ul> <li>imports new sessions it has never seen;</li> <li>completes grown sessions — any whose transcript gained messages since the last import (for example, a session imported while it was still running) is re-rendered up to its current end. Claude Code transcripts are append-only, so \"it grew\" is detected from the file's size and mtime alone; a partial import is just an intermediate state the next sweep finishes;</li> <li>skips unchanged sessions, byte-for-byte, writing nothing.</li> </ul> <p>So you never have to remember to re-import or time it: importing a live session mid-flight is safe and the next sweep heals it. That \"no new flags\" is the feature — it is why import is wired into <code>/ctx-wrap-up</code> and a <code>SessionEnd</code> hook, where it runs on the way out of every session (idempotent; one <code>stat</code> per session when there is nothing to do).</p> <p>Your edits are never clobbered. Journal entries are meant to be edited (add notes, clean up the transcript). Before re-rendering a grown entry, import checks whether the file's body is still exactly what ctx last wrote; if you edited it, ctx leaves the file untouched and warns, pointing you at <code>ctx journal lock</code> (permanent protection) or an explicit <code>--regenerate</code> (deliberate discard). Locked entries are never rewritten under any flag.</p> <p><code>--regenerate</code> is an edge-case tool, not the routine path. Reach for it to (a) mass-re-render after a change to the render format, or (b) one-time heal a pre-self-heal entry that an old mid-session import truncated — its source will never grow again, so the automatic path cannot heal it, and <code>--regenerate</code> re-renders it from the full transcript. <code>--keep-frontmatter=false</code> additionally discards enriched frontmatter during that re-render.</p> <p>Single-session import (<code>ctx journal import <id></code>) always re-renders the targeted session without prompting, since you are explicitly targeting it.</p> <p>The <code>journal/</code> directory should be gitignored (like <code>sessions/</code>) since it contains raw conversation data.</p> <p>Example:</p> <pre><code>ctx journal import abc123 # Import (or re-render) one session\nctx journal import --all # Import new + complete grown sessions\nctx journal import --all --dry-run # Preview what would be imported\nctx journal import --all --regenerate # Edge case: force full re-render (prompts)\nctx journal import --all --regenerate -y # Force full re-render without prompting\nctx journal import --all --regenerate --keep-frontmatter=false -y # Discard frontmatter\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-lock","level":4,"title":"<code>ctx journal lock</code>","text":"<p>Protect journal entries from being overwritten by <code>import --regenerate</code> or modified by enrichment skills (<code>/ctx-journal-enrich</code>, <code>/ctx-journal-enrich-all</code>).</p> <pre><code>ctx journal lock <pattern> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--all</code> Lock all journal entries <p>The pattern matches filenames by slug, date, or short ID. Locking a multi-part entry locks all parts. The lock is recorded in <code>.context/journal/.state.json</code> and a <code>locked: true</code> line is added to the file's YAML frontmatter for visibility.</p> <p>Example:</p> <pre><code>ctx journal lock abc12345\nctx journal lock 2026-01-21-session-abc12345.md\nctx journal lock --all\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-unlock","level":4,"title":"<code>ctx journal unlock</code>","text":"<p>Remove lock protection from journal entries.</p> <pre><code>ctx journal unlock <pattern> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--all</code> Unlock all journal entries <p>Example:</p> <pre><code>ctx journal unlock abc12345\nctx journal unlock --all\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-sync","level":4,"title":"<code>ctx journal sync</code>","text":"<p>Sync lock state from journal frontmatter to <code>.state.json</code>.</p> <pre><code>ctx journal sync\n</code></pre> <p>Scans all journal markdowns and updates <code>.state.json</code> to match each file's frontmatter. Files with <code>locked: true</code> in frontmatter are marked locked in state; files without a <code>locked:</code> line have their lock cleared.</p> <p>This is the inverse of <code>ctx journal lock</code>: instead of state driving frontmatter, frontmatter drives state. Useful after batch enrichment where you add <code>locked: true</code> to frontmatter manually.</p> <p>Example:</p> <pre><code># After enriching entries and adding locked: true to frontmatter\nctx journal sync\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal_1","level":3,"title":"<code>ctx journal</code>","text":"<p>Analyze and synthesize imported session files.</p> <pre><code>ctx journal <subcommand>\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-site","level":4,"title":"<code>ctx journal site</code>","text":"<p>Generate a static site from journal entries in <code>.context/journal/</code>.</p> <pre><code>ctx journal site [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--output</code> <code>-o</code> Output directory (default: .context/journal-site) <code>--build</code> Run zensical build after generating <code>--serve</code> Run zensical serve after generating <p>Creates a <code>zensical</code>-compatible site structure with an index page listing all sessions by date, and individual pages for each journal entry.</p> <p>Requires <code>zensical</code> to be installed for <code>--build</code> or <code>--serve</code>:</p> <pre><code>pipx install zensical\n</code></pre> <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-obsidian","level":4,"title":"<code>ctx journal obsidian</code>","text":"<p>Generate an Obsidian vault from journal entries in <code>.context/journal/</code>.</p> <pre><code>ctx journal obsidian [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--output</code> <code>-o</code> Output directory (default: .context/journal-obsidian) <p>Creates an Obsidian-compatible vault with:</p> <ul> <li>Wikilinks (<code>[[target|display]]</code>) for all internal navigation</li> <li>MOC pages (Map of Content) for topics, key files, and session types</li> <li>Related sessions footer linking entries that share topics</li> <li>Transformed frontmatter (<code>topics</code> → <code>tags</code> for Obsidian integration)</li> <li>Minimal <code>.obsidian/</code> config enforcing wikilink mode</li> </ul> <p>No external dependencies are required: Open the output directory as an Obsidian vault directly.</p> <p>Example:</p> <pre><code>ctx journal obsidian # Generate in .context/journal-obsidian/\nctx journal obsidian --output ~/vaults/ctx # Custom output directory\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-check","level":4,"title":"<code>ctx journal schema check</code>","text":"<p>Validate JSONL session files against the embedded schema and report drift.</p> <pre><code>ctx journal schema check [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--dir</code> Directory to scan for JSONL files <code>--all-projects</code> Scan all Claude Code project directories <code>--quiet</code> <code>-q</code> Exit code only (0 = clean, 1 = drift) <p>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 <code>.context/reports/schema-drift.md</code>. When drift resolves, the report is automatically deleted.</p> <p>Designed for interactive use, CI pipelines, and nightly cron jobs.</p> <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-journal-schema-dump","level":4,"title":"<code>ctx journal schema dump</code>","text":"<p>Print the embedded JSONL schema definition.</p> <pre><code>ctx journal schema dump\n</code></pre> <p>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.</p> <p>Example:</p> <pre><code>ctx journal schema dump\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/journal/#ctx-serve","level":3,"title":"<code>ctx serve</code>","text":"<p>Serve any zensical directory locally. This is a serve-only command: It does not generate or regenerate site content.</p> <pre><code>ctx serve [directory]\n</code></pre> <p>If no directory is specified, defaults to the journal site (<code>.context/journal-site</code>).</p> <p>Requires <code>zensical</code> to be installed:</p> <pre><code>pipx install zensical\n</code></pre> <p><code>ctx serve</code> vs. <code>ctx journal site --serve</code></p> <p><code>ctx journal site --serve</code> generates the journal site then serves it: an all-in-one command. <code>ctx serve</code> only serves an existing directory, and works with any zensical site (journal, docs, etc.).</p> <p>Example:</p> <pre><code>ctx serve # Serve journal site (no regeneration)\nctx serve .context/journal-site # Same, explicit path\nctx serve ./site # Serve the docs site\n</code></pre>","path":["CLI","Sessions","Journal"],"tags":[]},{"location":"cli/kb/","level":1,"title":"ctx kb","text":"","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb","level":2,"title":"<code>ctx kb</code>","text":"<p>Knowledge-base editorial pipeline (Phase KB). Manages the <code>.context/kb/</code> knowledge base via mode-aware skills and a small set of supporting CLI commands. The editorial constitution lives at <code>.context/ingest/KB-RULES.md</code> (laid down by <code>ctx init</code>).</p> <pre><code>ctx kb [subcommand]\n</code></pre> Subcommand Type Purpose <code>ctx kb topic new \"<name>\"</code> CLI (real) Sole writer of topic-page scaffolds. Creates <code>.context/kb/topics/<slug>/index.md</code> from the embedded template. Refuses when the topic exists. <code>ctx kb note \"<text>\"</code> CLI (real) Appends a one-liner to <code>.context/ingest/findings.md</code>. Never touches a topic page. <code>ctx kb reindex</code> CLI (real) Refreshes the <code>CTX:KB:TOPICS</code> managed block in <code>.context/kb/index.md</code>. <code>ctx kb ingest <folder\\|paths></code> Skill-driven Mode-aware editorial pass. CLI form refuses on empty input and points at the <code>/ctx-kb-ingest</code> skill. <code>ctx kb ask \"<question>\"</code> Skill-driven Q&A grounded in the kb. CLI form refuses on empty input and points at the <code>/ctx-kb-ask</code> skill. <code>ctx kb site-review</code> Skill-driven Mechanical structural audit. Points at <code>/ctx-kb-site-review</code>. <code>ctx kb ground</code> Skill-driven Read-only freshness audit over tracked sources listed in <code>grounding-sources.md</code> (URLs, in-tree paths, MCP resources). Refuses when the file is empty. <p>Skill-driven vs real CLI</p> <p>The mode skills (<code>ingest</code>, <code>ask</code>, <code>site-review</code>, <code>ground</code>) do the editorial work themselves: the agent reads <code>.context/ingest/30-INGEST.md</code> (etc.) and executes the pass per the pass-mode contract. The CLI form for those subcommands validates input and prints the canonical skill invocation. The real CLI commands (<code>topic new</code>, <code>note</code>, <code>reindex</code>) own concrete state changes.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb-topic-new-name","level":3,"title":"<code>ctx kb topic new \"<name>\"</code>","text":"<p>Scaffolds a folder-shaped topic at <code>.context/kb/topics/<slug>/index.md</code> from the embedded template.</p> <p>Slug: lowercase + kebab-case. Slashes are preserved for vendor-namespaced topology (e.g. <code>cursor/hooks</code>, <code>cursor/skills</code>, <code>cursor/rules</code> under a shared <code>cursor/</code> folder).</p> <p>Refuses when the topic folder already exists. Use the existing folder instead; the editorial pass extends pages, it doesn't reset them.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb-note-text","level":3,"title":"<code>ctx kb note \"<text>\"</code>","text":"<p>Appends a timestamped one-liner to <code>.context/ingest/findings.md</code>. Use for parking findings the next ingest pass should absorb.</p> <pre><code>ctx kb note \"follow-up: chase the v1.2 release notes for the SIGTERM change\"\n</code></pre>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#ctx-kb-reindex","level":3,"title":"<code>ctx kb reindex</code>","text":"<p>Refreshes the <code>CTX:KB:TOPICS</code> managed block inside <code>.context/kb/index.md</code> so the kb landing page enumerates current topic folders. Run after <code>ctx kb topic new</code> to update the landing.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#skill-driven-subcommands","level":3,"title":"Skill-Driven Subcommands","text":"<p><code>ingest</code>, <code>ask</code>, <code>site-review</code>, <code>ground</code> exist as CLI surfaces so the editorial workflow is drivable from outside Claude Code (via the fallback <code>PROMPT.md</code> auto-router). In Claude Code, prefer the skills:</p> <pre><code>/ctx-kb-ingest ./inputs/2026-05-15-call.md \"cursor hooks\"\n/ctx-kb-ask \"does the kb say hooks fire async?\"\n/ctx-kb-site-review\n/ctx-kb-ground\n</code></pre> <p>See the Build a Knowledge Base recipe for the full workflow.</p>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/kb/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Build a Knowledge Base</li> <li>Recipe: Typical KB Session</li> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code></li> </ul>","path":["CLI","Context","ctx kb"],"tags":[]},{"location":"cli/loop/","level":1,"title":"Loop","text":"","path":["CLI","Integrations","Loop"],"tags":[]},{"location":"cli/loop/#ctx-loop","level":2,"title":"<code>ctx loop</code>","text":"<p>Generate a shell script for running an autonomous loop.</p> <p>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.</p> <pre><code>ctx loop [flags]\n</code></pre> <p>Flags:</p> Flag Short Description Default <code>--tool <tool></code> <code>-t</code> AI tool: <code>claude</code>, <code>aider</code>, or <code>generic</code> <code>claude</code> <code>--prompt <file></code> <code>-p</code> Prompt file to use <code>.context/loop.md</code> <code>--max-iterations <n></code> <code>-n</code> Maximum iterations (0 = unlimited) <code>0</code> <code>--completion <signal></code> <code>-c</code> Completion signal to detect <code>SYSTEM_CONVERGED</code> <code>--output <file></code> <code>-o</code> Output script filename <code>loop.sh</code> <p>Examples:</p> <pre><code># 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</code></pre> <p>Running the generated loop:</p> <pre><code>ctx loop\nchmod +x loop.sh\n./loop.sh\n</code></pre> <p>See also: Autonomous Loops for the full workflow.</p>","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":"<code>ctx mcp</code>","text":"<p>Run <code>ctx</code> 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.</p> <p>This makes <code>ctx</code> accessible to any MCP-compatible AI tool without custom hooks or integrations:</p> <ul> <li>Claude Desktop</li> <li>Cursor</li> <li>Windsurf</li> <li>VS Code Copilot</li> <li>Any tool supporting MCP</li> </ul>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-mcp-serve","level":3,"title":"<code>ctx mcp serve</code>","text":"<p>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.</p> <p>Flags: None. The server resolves the context directory by reading <code>$PWD/.context/</code>. The MCP host must launch the server from the project root (or its launch wrapper must <code>cd</code> first). There is no env-var or walk-up resolution.</p> <p>Examples:</p> <pre><code># Normal invocation (by an MCP client via stdio transport,\n# from the project root)\nctx mcp serve\n\n# Verify the binary starts without a client attached (Ctrl-C to exit)\nctx mcp serve < /dev/null\n</code></pre>","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":"<p>Add to <code>~/Library/Application Support/Claude/claude_desktop_config.json</code>:</p> <pre><code>{\n \"mcpServers\": {\n \"ctx\": {\n \"command\": \"ctx\",\n \"args\": [\"mcp\", \"serve\"]\n }\n }\n}\n</code></pre>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#cursor","level":3,"title":"Cursor","text":"<p>Add to <code>.cursor/mcp.json</code> in your project:</p> <pre><code>{\n \"mcpServers\": {\n \"ctx\": {\n \"command\": \"ctx\",\n \"args\": [\"mcp\", \"serve\"]\n }\n }\n}\n</code></pre>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#vs-code-copilot","level":3,"title":"VS Code (Copilot)","text":"<p>Add to <code>.vscode/mcp.json</code>:</p> <pre><code>{\n \"servers\": {\n \"ctx\": {\n \"command\": \"ctx\",\n \"args\": [\"mcp\", \"serve\"]\n }\n }\n}\n</code></pre>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resources","level":2,"title":"Resources","text":"<p>Resources expose context files as read-only content. Each resource has a URI, name, and returns Markdown text.</p> URI Name Description <code>ctx://context/constitution</code> constitution Hard rules that must never be violated <code>ctx://context/tasks</code> tasks Current work items and their status <code>ctx://context/conventions</code> conventions Code patterns and standards <code>ctx://context/architecture</code> architecture System architecture documentation <code>ctx://context/decisions</code> decisions Architectural decisions with rationale <code>ctx://context/learnings</code> learnings Gotchas, tips, and lessons learned <code>ctx://context/glossary</code> glossary Project-specific terminology <code>ctx://context/agent</code> agent All files assembled in priority read order <p>The <code>agent</code> resource assembles all non-empty context files into a single Markdown document, ordered by the configured read priority.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#resource-subscriptions","level":3,"title":"Resource Subscriptions","text":"<p>Clients can subscribe to resource changes via <code>resources/subscribe</code>. The server polls for file mtime changes (default: 5 seconds) and emits <code>notifications/resources/updated</code> when a subscribed file changes on disk.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#tools","level":2,"title":"Tools","text":"<p>Tools expose <code>ctx</code> commands as callable operations. Each tool accepts JSON arguments and returns text results.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_status","level":3,"title":"<code>ctx_status</code>","text":"<p>Show context health: file count, token estimate, and per-file summary.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_add","level":3,"title":"<code>ctx_add</code>","text":"<p>Add a task, decision, learning, or convention to the context.</p> Argument Type Required Description <code>type</code> string Yes Entry type: task, decision, learning, convention <code>content</code> string Yes Title or main content <code>priority</code> string No Priority level (tasks only): high, medium, low <code>context</code> string Conditional Context field (decisions and learnings) <code>rationale</code> string Conditional Rationale (decisions only) <code>consequence</code> string Conditional Consequence (decisions only) <code>lesson</code> string Conditional Lesson learned (learnings only) <code>application</code> string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_complete","level":3,"title":"<code>ctx_complete</code>","text":"<p>Mark a task as done by number or text match.</p> Argument Type Required Description <code>query</code> string Yes Task number (e.g. \"1\") or search text","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_drift","level":3,"title":"<code>ctx_drift</code>","text":"<p>Detect stale or invalid context. Returns violations, warnings, and passed checks.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_journal_source","level":3,"title":"<code>ctx_journal_source</code>","text":"<p>Query recent AI session history (summaries, decisions, topics).</p> Argument Type Required Description <code>limit</code> number No Max sessions to return (default: 5) <code>since</code> string No ISO date filter: sessions after this date (YYYY-MM-DD) <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_watch_update","level":3,"title":"<code>ctx_watch_update</code>","text":"<p>Apply a structured context update to <code>.context/</code> files. Supports task, decision, learning, convention, and complete entry types. Human confirmation is required before calling.</p> Argument Type Required Description <code>type</code> string Yes Entry type: task, decision, learning, convention, complete <code>content</code> string Yes Main content <code>context</code> string Conditional Context background (decisions/learnings) <code>rationale</code> string Conditional Rationale (decisions only) <code>consequence</code> string Conditional Consequence (decisions only) <code>lesson</code> string Conditional Lesson learned (learnings only) <code>application</code> string Conditional How to apply (learnings only)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_compact","level":3,"title":"<code>ctx_compact</code>","text":"<p>Move completed tasks to the archive section and remove empty sections from context files. Human confirmation required.</p> Argument Type Required Description <code>archive</code> boolean No Also write tasks to <code>.context/archive/</code> (default: false)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_next","level":3,"title":"<code>ctx_next</code>","text":"<p>Suggest the next pending task based on priority and position.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_checktaskcompletion","level":3,"title":"<code>ctx_checktaskcompletion</code>","text":"<p>Advisory check: after a write operation, detect if any pending tasks were silently completed. Returns nudge text if a match is found.</p> Argument Type Required Description <code>recent_action</code> string No Brief description of what was just done <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_sessionevent","level":3,"title":"<code>ctx_sessionevent</code>","text":"<p>Signal a session lifecycle event. Type <code>end</code> triggers the session-end persistence ceremony - human confirmation required.</p> Argument Type Required Description <code>type</code> string Yes Event type: start, end <code>caller</code> string No Caller identifier (cursor, windsurf, vscode, claude-desktop)","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_steering_get","level":3,"title":"<code>ctx_steering_get</code>","text":"<p>Retrieve applicable steering files for a prompt. Without a prompt, returns always-included files only.</p> Argument Type Required Description <code>prompt</code> string No Prompt text to match against steering file descriptions <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_search","level":3,"title":"<code>ctx_search</code>","text":"<p>Search across <code>.context/</code> files for a query string. Returns matching lines with file paths and line numbers.</p> Argument Type Required Description <code>query</code> string Yes Search string to match against <p>Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_start","level":3,"title":"<code>ctx_session_start</code>","text":"<p>Execute session-start hooks and return aggregated context from hook outputs.</p> <p>Arguments: None.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_session_end","level":3,"title":"<code>ctx_session_end</code>","text":"<p>Execute session-end hooks with an optional summary. Returns aggregated context from hook outputs.</p> Argument Type Required Description <code>summary</code> string No Session summary passed to hook scripts","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx_remind","level":3,"title":"<code>ctx_remind</code>","text":"<p>List pending session-scoped reminders.</p> <p>Arguments: None. Read-only.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#prompts","level":2,"title":"Prompts","text":"<p>Prompts provide pre-built templates for common workflows. Clients can list available prompts via <code>prompts/list</code> and retrieve a specific prompt via <code>prompts/get</code>.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-session-start","level":3,"title":"<code>ctx-session-start</code>","text":"<p>Load full context at the beginning of a session. Returns all context files assembled in priority read order with session orientation instructions.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-decision-add","level":3,"title":"<code>ctx-decision-add</code>","text":"<p>Format an architectural decision entry with all required fields.</p> Argument Type Required Description <code>content</code> string Yes Decision title <code>context</code> string Yes Background context <code>rationale</code> string Yes Why this decision was made <code>consequence</code> string Yes Expected consequence","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-learning-add","level":3,"title":"<code>ctx-learning-add</code>","text":"<p>Format a learning entry with all required fields.</p> Argument Type Required Description <code>content</code> string Yes Learning title <code>context</code> string Yes Background context <code>lesson</code> string Yes The lesson learned <code>application</code> string Yes How to apply this lesson","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-reflect","level":3,"title":"<code>ctx-reflect</code>","text":"<p>Guide end-of-session reflection. Returns a structured review prompt covering progress assessment and context update recommendations.</p>","path":["CLI","Integrations","MCP Server"],"tags":[]},{"location":"cli/mcp/#ctx-checkpoint","level":3,"title":"<code>ctx-checkpoint</code>","text":"<p>Report session statistics: tool calls made, entries added, and pending updates queued during the current session.</p>","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":"<code>ctx memory</code>","text":"<p>Bridge Claude Code's auto memory (MEMORY.md) into <code>.context/</code>.</p> <p>Claude Code maintains per-project auto memory at <code>~/.claude/projects/<slug>/memory/MEMORY.md</code>. This command group discovers that file, mirrors it into <code>.context/memory/mirror.md</code> (git-tracked), and detects drift.</p> <pre><code>ctx memory <subcommand>\n</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-sync","level":3,"title":"<code>ctx memory sync</code>","text":"<p>Copy MEMORY.md to <code>.context/memory/mirror.md</code>. Archives the previous mirror before overwriting.</p> <pre><code>ctx memory sync [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--dry-run</code> Show what would happen without writing <p>Exit codes:</p> Code Meaning 0 Synced successfully 1 MEMORY.md not found (auto memory inactive) <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-status","level":3,"title":"<code>ctx memory status</code>","text":"<p>Show drift, timestamps, line counts, and archive count.</p> <pre><code>ctx memory status\n</code></pre> <p>Exit codes:</p> Code Meaning 0 No drift 1 MEMORY.md not found 2 Drift detected (MEMORY.md changed since sync) <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-diff","level":3,"title":"<code>ctx memory diff</code>","text":"<p>Show what changed in MEMORY.md since last sync.</p> <pre><code>ctx memory diff\n</code></pre> <p>Examples:</p> <pre><code>ctx memory diff\n# --- .context/memory/mirror.md (mirror)\n# +++ ~/.claude/projects/.../memory/MEMORY.md (source)\n# +- new learning: memory bridge works\n</code></pre> <p>No output when files are identical.</p>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-publish","level":3,"title":"<code>ctx memory publish</code>","text":"<p>Push curated <code>.context/</code> content into MEMORY.md so the agent sees it natively.</p> <pre><code>ctx memory publish [flags]\n</code></pre> <p>Content is selected in priority order: pending tasks, recent decisions (7 days), key conventions, recent learnings (7 days). Wrapped in <code><!-- ctx:published --></code> markers. Claude-owned content outside the markers is preserved.</p> <p>Flags:</p> Flag Description Default <code>--budget</code> Line budget for published content <code>80</code> <code>--dry-run</code> Show what would be published <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-unpublish","level":3,"title":"<code>ctx memory unpublish</code>","text":"<p>Remove the ctx-managed marker block from MEMORY.md, preserving Claude-owned content.</p> <p>Examples:</p> <pre><code>ctx memory unpublish\n</code></pre> <p>Hook integration: The <code>check-memory-drift</code> 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.</p>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/memory/#ctx-memory-import","level":3,"title":"<code>ctx memory import</code>","text":"<p>Classify and promote entries from MEMORY.md into structured <code>.context/</code> files.</p> <pre><code>ctx memory import [flags]\n</code></pre> <p>Each entry is classified by keyword heuristics:</p> Keywords Target <code>always use</code>, <code>prefer</code>, <code>never use</code>, <code>standard</code> CONVENTIONS.md <code>decided</code>, <code>chose</code>, <code>trade-off</code>, <code>approach</code> DECISIONS.md <code>gotcha</code>, <code>learned</code>, <code>watch out</code>, <code>bug</code>, <code>caveat</code> LEARNINGS.md <code>todo</code>, <code>need to</code>, <code>follow up</code> TASKS.md Everything else Skipped <p>Deduplication prevents re-importing the same entry across runs.</p> <p>Flags:</p> Flag Description <code>--dry-run</code> Show classification plan without writing <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Context","Memory"],"tags":[]},{"location":"cli/message/","level":1,"title":"Message","text":"","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message","level":3,"title":"<code>ctx hook message</code>","text":"<p>Manage hook message templates.</p> <p>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.</p> <pre><code>ctx hook message <subcommand>\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-list","level":3,"title":"<code>ctx hook message list</code>","text":"<p>Show all hook messages with category and override status.</p> <pre><code>ctx hook message list [--json]\n</code></pre> <p>Flags:</p> Flag Description <code>--json</code> Output in JSON format <p>Example:</p> <pre><code>ctx hook message list\nctx hook message list --json | jq '.[] | select(.override)'\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-show","level":3,"title":"<code>ctx hook message show</code>","text":"<p>Print the effective message template for a hook/variant pair. Shows the user override if present, otherwise the embedded default.</p> <pre><code>ctx hook message show <hook> <variant>\n</code></pre> <p>Example:</p> <pre><code>ctx hook message show qa-reminder gate\nctx hook message show check-context-size checkpoint\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-edit","level":3,"title":"<code>ctx hook message edit</code>","text":"<p>Copy the embedded default template for <code><hook> <variant></code> to <code>.context/hooks/messages/<hook>/<variant>.txt</code> so you can edit it directly. The override takes effect the next time the hook fires.</p> <pre><code>ctx hook message edit <hook> <variant>\n</code></pre> <p>If an override already exists, the command fails and directs you to edit it in place or reset it first.</p> <p>Example:</p> <pre><code>ctx hook message edit qa-reminder gate\n# Edit .context/hooks/messages/qa-reminder/gate.txt in your editor\n</code></pre>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/message/#ctx-hook-message-reset","level":3,"title":"<code>ctx hook message reset</code>","text":"<p>Delete a user override and revert to the embedded default. Silent no-op if no override exists.</p> <pre><code>ctx hook message reset <hook> <variant>\n</code></pre> <p>Example:</p> <pre><code>ctx hook message reset qa-reminder gate\n</code></pre> <p>See Customizing hook messages for the full workflow.</p>","path":["CLI","Runtime","Message"],"tags":[]},{"location":"cli/notify/","level":1,"title":"Notify","text":"","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify","level":2,"title":"<code>ctx hook notify</code>","text":"<p>Send fire-and-forget webhook notifications from skills, loops, and hooks.</p> <pre><code>ctx hook notify --event <name> [--session-id <id>] \"message\"\n</code></pre> <p>Flags:</p> Flag Short Description <code>--event</code> <code>-e</code> Event name (required) <code>--session-id</code> <code>-s</code> Session ID (optional) <p>Behavior:</p> <ul> <li>No webhook configured: silent no-op (exit 0)</li> <li>Webhook set but event not in <code>events</code> list: silent no-op (exit 0)</li> <li>Webhook set and event matches: fire-and-forget HTTP POST</li> <li>HTTP errors silently ignored (no retry)</li> </ul> <p>Examples:</p> <pre><code>ctx hook notify --event loop \"Loop completed after 5 iterations\"\nctx hook notify -e nudge -s session-abc \"Context checkpoint at prompt #20\"\n</code></pre>","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-setup","level":3,"title":"<code>ctx hook notify setup</code>","text":"<p>Configure the webhook URL interactively. The URL is encrypted with AES-256-GCM using the encryption key and stored in <code>.context/.notify.enc</code>.</p> <p>Examples:</p> <pre><code>ctx hook notify setup\n</code></pre> <p>The encrypted file is safe to commit. The key (<code>~/.ctx/.ctx.key</code>) lives outside the project and is never committed.</p>","path":["CLI","Integrations","Notify"],"tags":[]},{"location":"cli/notify/#ctx-hook-notify-test","level":3,"title":"<code>ctx hook notify test</code>","text":"<p>Send a test notification and report the HTTP response status.</p> <p>Examples:</p> <pre><code>ctx hook notify test\n</code></pre> <p>Payload format (JSON POST):</p> <pre><code>{\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</code></pre> Field Type Description <code>event</code> string Event name from <code>--event</code> flag <code>message</code> string Notification message <code>session_id</code> string Session ID (omitted if empty) <code>timestamp</code> string UTC RFC3339 timestamp <code>project</code> string Project directory name <p>See also: Webhook Notifications recipe.</p>","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":"<code>ctx pad</code>","text":"<p>Encrypted scratchpad for sensitive one-liners that travel with the project.</p> <p>When invoked without a subcommand, lists all entries.</p> <pre><code>ctx pad\nctx pad <subcommand>\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-add","level":3,"title":"<code>ctx pad add</code>","text":"<p>Append a new entry to the scratchpad.</p> <pre><code>ctx pad add <text>\nctx pad add <label> --file <path>\n</code></pre> <p>Flags:</p> Flag Short Description <code>--file</code> <code>-f</code> Ingest a file as a blob entry (max 64 KB) <p>Examples:</p> <pre><code>ctx pad add \"DATABASE_URL=postgres://user:pass@host/db\"\nctx pad add \"deploy config\" --file ./deploy.yaml\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-show","level":3,"title":"<code>ctx pad show</code>","text":"<p>Output the raw text of an entry by number. For blob entries, prints decoded file content (or writes to disk with <code>--out</code>).</p> <pre><code>ctx pad show <n>\nctx pad show <n> --out <path>\n</code></pre> <p>Arguments:</p> <ul> <li><code>n</code>: 1-based entry number</li> </ul> <p>Flags:</p> Flag Description <code>--out</code> Write decoded blob content to a file (blobs only) <p>Examples:</p> <pre><code>ctx pad show 3\nctx pad show 2 --out ./recovered.yaml\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-rm","level":3,"title":"<code>ctx pad rm</code>","text":"<p>Remove one or more entries by stable ID. Supports individual IDs and ranges.</p> <pre><code>ctx pad rm <id> [id...]\n</code></pre> <p>Arguments:</p> <ul> <li><code>id</code>: One or more entry IDs (e.g., <code>3</code>, <code>1 4</code>, <code>3-5</code>)</li> </ul> <p>Examples:</p> <pre><code>ctx pad rm 2\nctx pad rm 1 4\nctx pad rm 3-5\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-normalize","level":3,"title":"<code>ctx pad normalize</code>","text":"<p>Reassign entry IDs as a contiguous sequence 1..N, closing any gaps left by deletions.</p> <p>Examples:</p> <pre><code>ctx pad normalize\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-edit","level":3,"title":"<code>ctx pad edit</code>","text":"<p>Replace, append to, or prepend to an entry.</p> <pre><code>ctx pad edit <n> [text]\n</code></pre> <p>Arguments:</p> <ul> <li><code>n</code>: 1-based entry number</li> <li><code>text</code>: Replacement text (mutually exclusive with <code>--append</code>/<code>--prepend</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--append</code> Append text to the end of the entry <code>--prepend</code> Prepend text to the beginning of entry <code>--file</code> Replace blob file content (preserves label) <code>--label</code> Replace blob label (preserves content) <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-mv","level":3,"title":"<code>ctx pad mv</code>","text":"<p>Move an entry from one position to another.</p> <pre><code>ctx pad mv <from> <to>\n</code></pre> <p>Arguments:</p> <ul> <li><code>from</code>: Source position (1-based)</li> <li><code>to</code>: Destination position (1-based)</li> </ul> <p>Examples:</p> <pre><code>ctx pad mv 3 1 # promote entry 3 to the top\nctx pad mv 1 5 # bury entry 1 to position 5\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-resolve","level":3,"title":"<code>ctx pad resolve</code>","text":"<p>Show both sides of a merge conflict in the encrypted scratchpad.</p> <p>Examples:</p> <pre><code>ctx pad resolve\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-import","level":3,"title":"<code>ctx pad import</code>","text":"<p>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.</p> <p>With <code>--blob</code>, 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.</p> <pre><code>ctx pad import <file>\nctx pad import - # read from stdin\nctx pad import --blob <dir> # import directory files as blobs\n</code></pre> <p>Arguments:</p> <ul> <li><code>file</code>: Path to a text file, <code>-</code> for stdin, or a directory (with <code>--blob</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--blob</code> Import first-level files from a directory as blobs <p>Examples:</p> <pre><code>ctx pad import notes.txt\ngrep TODO *.go | ctx pad import -\nctx pad import --blob ./ideas/\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-export","level":3,"title":"<code>ctx pad export</code>","text":"<p>Export all blob entries from the scratchpad to a directory as files. Each blob's label becomes the filename. Non-blob entries are skipped.</p> <pre><code>ctx pad export [dir]\n</code></pre> <p>Arguments:</p> <ul> <li><code>dir</code>: Target directory (default: current directory)</li> </ul> <p>Flags:</p> Flag Short Description <code>--force</code> <code>-f</code> Overwrite existing files instead of timestamping <code>--dry-run</code> Print what would be exported without writing <p>When a file already exists, a unix timestamp is prepended to avoid collisions (e.g., <code>1739836200-label</code>). Use <code>--force</code> to overwrite instead.</p> <p>Examples:</p> <pre><code>ctx pad export ./ideas\nctx pad export --dry-run\nctx pad export --force ./backup\n</code></pre>","path":["CLI","Sessions","Scratchpad"],"tags":[]},{"location":"cli/pad/#ctx-pad-merge","level":3,"title":"<code>ctx pad merge</code>","text":"<p>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.</p> <pre><code>ctx pad merge FILE...\n</code></pre> <p>Arguments:</p> <ul> <li><code>FILE...</code>: One or more scratchpad files to merge (encrypted or plaintext)</li> </ul> <p>Flags:</p> Flag Short Description <code>--key</code> <code>-k</code> Path to key file for decrypting input files <code>--dry-run</code> Print what would be merged without writing <p>Examples:</p> <pre><code>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</code></pre>","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":"<code>ctx hook pause</code>","text":"<p>Pause all context nudge and reminder hooks for the current session. Security hooks (dangerous command blocking) and housekeeping hooks still fire.</p> <pre><code>ctx hook pause [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--session-id</code> Session ID (overrides stdin) <p>Example:</p> <pre><code># Pause hooks for a quick investigation\nctx hook pause\n\n# Resume when ready\nctx hook resume\n</code></pre> <p>See also:</p> <ul> <li><code>ctx hook resume</code>: the matching resume command</li> <li>Pausing Context Hooks recipe</li> </ul>","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":"<code>ctx prune</code>","text":"<p>Remove per-session state files from <code>.context/state/</code> that are older than the specified age. Session state files are identified by UUID suffixes (<code>context-check-<session-id></code>, <code>heartbeat-<session-id></code>, and similar). Global files without session IDs (<code>events.jsonl</code>, <code>memory-import.json</code>, and other non-per-session markers) are always preserved.</p> <pre><code>ctx prune [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--days</code> Prune files older than this many days (default: 7) <code>--dry-run</code> Show what would be pruned without deleting <p>Examples:</p> <pre><code>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</code></pre> <p>See State maintenance for the recommended cadence and automation recipe.</p>","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":"<code>ctx remind</code>","text":"<p>Session-scoped reminders that surface at session start. Reminders are stored verbatim and relayed verbatim: no summarization, no categories.</p> <p>When invoked with a text argument and no subcommand, adds a reminder.</p> <pre><code>ctx remind \"text\"\nctx remind <subcommand>\n</code></pre>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-add","level":3,"title":"<code>ctx remind add</code>","text":"<p>Add a reminder. This is the default action: <code>ctx remind \"text\"</code> and <code>ctx remind add \"text\"</code> are equivalent.</p> <pre><code>ctx remind \"refactor the swagger definitions\"\nctx remind add \"check CI after the deploy\" --after 2026-02-25\n</code></pre> <p>Arguments:</p> <ul> <li><code>text</code>: The reminder message (verbatim)</li> </ul> <p>Flags:</p> Flag Short Description <code>--after</code> <code>-a</code> Don't surface until this date (YYYY-MM-DD) <p>Examples:</p> <pre><code>ctx remind \"refactor the swagger definitions\"\nctx remind \"check CI after the deploy\" --after 2026-02-25\n</code></pre>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-list","level":3,"title":"<code>ctx remind list</code>","text":"<p>List all pending reminders. Date-gated reminders that aren't yet due are annotated with <code>(after DATE, not yet due)</code>.</p> <p>Examples:</p> <pre><code>ctx remind list\nctx remind ls # alias\n</code></pre> <p>Aliases: <code>ls</code></p>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-dismiss","level":3,"title":"<code>ctx remind dismiss</code>","text":"<p>Remove one or more reminders by ID, or remove all with <code>--all</code>. Supports individual IDs and ranges.</p> <pre><code>ctx remind dismiss <id> [id...]\nctx remind dismiss --all\n</code></pre> <p>Arguments:</p> <ul> <li><code>id</code>: One or more reminder IDs (e.g., <code>3</code>, <code>3 5-7</code>)</li> </ul> <p>Flags:</p> Flag Description <code>--all</code> Dismiss all reminders <p>Aliases: <code>rm</code></p> <p>Examples:</p> <pre><code>ctx remind dismiss 3\nctx remind dismiss 3 5-7\nctx remind dismiss --all\n</code></pre>","path":["CLI","Sessions","Remind"],"tags":[]},{"location":"cli/remind/#ctx-remind-normalize","level":3,"title":"<code>ctx remind normalize</code>","text":"<p>Reassign reminder IDs as a contiguous sequence 1..N, closing any gaps left by dismissals.</p> <p>Examples:</p> <pre><code>ctx remind normalize\n</code></pre> <p>See also: Session Reminders recipe.</p>","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":"<code>ctx hook resume</code>","text":"<p>Resume context hooks after a pause. Silent no-op if not paused.</p> <pre><code>ctx hook resume [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--session-id</code> Session ID (overrides stdin) <p>Example:</p> <pre><code>ctx hook resume\n</code></pre> <p>See also:</p> <ul> <li><code>ctx hook pause</code>: the matching pause command</li> <li>Pausing Context Hooks recipe</li> </ul>","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":"<code>ctx serve</code>","text":"<p>Serve a static site locally via zensical.</p> <p>With no argument, serves the journal site at <code>.context/journal-site</code>. With a directory argument, serves that directory if it contains a <code>zensical.toml</code>.</p> <pre><code>ctx serve # Serve .context/journal-site\nctx serve ./my-site # Serve a specific directory\nctx serve ./docs # Serve any zensical site\n</code></pre> <p>This Command Does NOT Start a Hub</p> <p><code>ctx serve</code> is purely for static-site serving. To run a <code>ctx</code> Hub for cross-project knowledge sharing, use <code>ctx hub start</code>. That command lives in its own group because the hub is a gRPC server, not a static site.</p> <p>Requires zensical to be installed:</p> <pre><code>pipx install zensical\n</code></pre>","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#arguments","level":3,"title":"Arguments","text":"Argument Description <code>[directory]</code> Directory containing a <code>zensical.toml</code> to serve <p>When omitted, serves <code>.context/journal-site</code> by default, the directory produced by <code>ctx journal site</code>.</p> <p>Examples:</p> <pre><code>ctx serve # Default: serve .context/journal-site\nctx serve ./my-site # Serve a specific directory\nctx serve ./docs # Serve any zensical site\n</code></pre>","path":["CLI","Integrations","Serve"],"tags":[]},{"location":"cli/serve/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx journal</code>: generate the journal site that <code>ctx serve</code> displays.</li> <li><code>ctx hub start</code>: for running a <code>ctx</code> Hub server, not a static site.</li> <li>Browsing and enriching past sessions: the recipe that combines <code>ctx journal</code> and <code>ctx serve</code>.</li> </ul>","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":"<code>ctx setup</code>","text":"<p>Generate AI tool integration configuration.</p> <pre><code>ctx setup <tool> [flags]\n</code></pre> <p>Flags:</p> Flag Short Description <code>--write</code> <code>-w</code> Write the generated config to disk (e.g. <code>.github/copilot-instructions.md</code>) <p>Supported tools:</p> Tool Description <code>claude-code</code> Redirects to plugin install instructions <code>cursor</code> Cursor IDE <code>kiro</code> Kiro IDE <code>cline</code> Cline (VS Code extension) <code>aider</code> Aider CLI <code>copilot</code> GitHub Copilot <code>opencode</code> OpenCode (terminal-first AI coding agent) <code>windsurf</code> Windsurf IDE <p>Claude Code Uses the Plugin System</p> <p>Claude Code integration is now provided via the <code>ctx</code> plugin. Running <code>ctx setup claude-code</code> prints plugin install instructions.</p> <p>Examples:</p> <pre><code># 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\n# Generate OpenCode plugin, skills, AGENTS.md, and global MCP config\nctx setup opencode --write\n</code></pre>","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":"<code>ctx site</code>","text":"<p>Site management commands for the ctx.ist static site.</p> <pre><code>ctx site <subcommand>\n</code></pre>","path":["CLI","Integrations","Site"],"tags":[]},{"location":"cli/site/#ctx-site-feed","level":3,"title":"<code>ctx site feed</code>","text":"<p>Generate an Atom 1.0 feed from finalized blog posts in <code>docs/blog/</code>.</p> <pre><code>ctx site feed [flags]\n</code></pre> <p>Scans <code>docs/blog/</code> for files matching <code>YYYY-MM-DD-*.md</code>, parses YAML frontmatter, and generates a valid Atom feed. Only posts with <code>reviewed_and_finalized: true</code> are included. Summaries are extracted from the first paragraph after the heading.</p> <p>Flags:</p> Flag Short Type Default Description <code>--out</code> <code>-o</code> string <code>site/feed.xml</code> Output path <code>--base-url</code> string <code>https://ctx.ist</code> Base URL for entry links <p>Output:</p> <pre><code>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</code></pre> <p>Three buckets: included (count), skipped (with reason), warnings (included but degraded). <code>exit 0</code> always: warnings inform but do not block.</p> <p>Frontmatter requirements:</p> Field Required Feed mapping <code>title</code> Yes <code><title></code> <code>date</code> Yes <code><updated></code> <code>reviewed_and_finalized</code> Yes Draft gate (must be <code>true</code>) <code>author</code> No <code><author><name></code> <code>topics</code> No <code><category term=\"\"></code> <p>Examples:</p> <pre><code>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</code></pre>","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":"<code>ctx skill</code>","text":"<p>Manage reusable instruction bundles that can be installed into <code>.context/skills/</code>.</p> <p>A skill is a directory containing a <code>SKILL.md</code> file with YAML frontmatter (<code>name</code>, <code>description</code>) and a Markdown instruction body. Skills are loaded by the agent context packet when <code>--skill <name></code> is passed to <code>ctx agent</code>.</p> <pre><code>ctx skill <subcommand>\n</code></pre>","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-install","level":3,"title":"<code>ctx skill install</code>","text":"<p>Install a skill from a source directory.</p> <pre><code>ctx skill install <source>\n</code></pre> <p>Arguments:</p> <ul> <li><code>source</code>: Path to a directory containing <code>SKILL.md</code></li> </ul> <p>Examples:</p> <pre><code>ctx skill install ./my-skills/code-review\n# Installed code-review → .context/skills/code-review\n</code></pre>","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-list","level":3,"title":"<code>ctx skill list</code>","text":"<p>List all installed skills.</p> <p>Examples:</p> <pre><code>ctx skill list\n</code></pre>","path":["CLI","Integrations","Skill"],"tags":[]},{"location":"cli/skill/#ctx-skill-remove","level":3,"title":"<code>ctx skill remove</code>","text":"<p>Remove an installed skill.</p> <p>Arguments:</p> <ul> <li><code>name</code>: Skill name to remove</li> </ul> <p>Examples:</p> <pre><code>ctx skill remove code-review\n</code></pre> <p>See also: Building Project Skills recipe.</p>","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":"<code>ctx steering</code>","text":"<p>Manage steering files: persistent behavioral rules for AI coding assistants.</p> <p>A steering file is a small Markdown document with YAML frontmatter that tells the AI how to behave in a specific context. <code>ctx steering</code> keeps those files in <code>.context/steering/</code>, decides which ones apply for a given prompt, and syncs them out to each AI tool's native format (Claude Code, Cursor, Kiro, Cline).</p> <pre><code>ctx steering <subcommand>\n</code></pre> <p>Steering vs Decisions vs Conventions</p> <p>The three look similar on disk but serve different purposes:</p> <ul> <li>Decisions record what was chosen and why. Consumed mostly by humans (and by the agent via <code>ctx agent</code>).</li> <li>Conventions describe how the codebase is written. Consumed as reference material.</li> <li>Steering tells the AI how to behave when asked about X. Consumed by the AI tool's prompt injection layer, conditionally on prompt match.</li> </ul> <p>If you find yourself writing \"the AI should always do X\", that belongs in steering, not decisions.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#anatomy-of-a-steering-file","level":3,"title":"Anatomy of a Steering File","text":"<pre><code>---\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</code></pre> <p>Inclusion modes:</p> Mode When it's included <code>always</code> Every prompt, unconditionally <code>auto</code> When the prompt matches the <code>description</code> keywords <code>manual</code> Only when the user names it explicitly <p>Priority: lower numbers inject first, so high-priority rules appear at the top of the prompt. Default is <code>50</code>.</p> <p>Tools: an empty list means all configured tools receive the file; list specific tool names to scope it.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-init","level":3,"title":"<code>ctx steering init</code>","text":"<p>Create a starter set of steering files in <code>.context/steering/</code> to use as a scaffolding baseline.</p> <p>Examples:</p> <pre><code>ctx steering init\n</code></pre>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-add","level":3,"title":"<code>ctx steering add</code>","text":"<p>Create a new steering file with default frontmatter.</p> <pre><code>ctx steering add <name>\n</code></pre> <p>Arguments:</p> <ul> <li><code>name</code>: Steering file name (without <code>.md</code> extension)</li> </ul> <p>Examples:</p> <pre><code>ctx steering add security\n# Created .context/steering/security.md\n</code></pre> <p>The generated file uses <code>inclusion: manual</code> and <code>priority: 50</code> by default. Edit the frontmatter to change behavior.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-list","level":3,"title":"<code>ctx steering list</code>","text":"<p>List all steering files with their inclusion mode, priority, and tool scoping.</p> <p>Examples:</p> <pre><code>ctx steering list\n</code></pre>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-preview","level":3,"title":"<code>ctx steering preview</code>","text":"<p>Preview which steering files would be included for a given prompt. Useful for validating <code>auto</code>-inclusion descriptions against realistic prompts.</p> <pre><code>ctx steering preview [prompt]\n</code></pre> <p>Examples:</p> <pre><code>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</code></pre>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-steering-sync","level":3,"title":"<code>ctx steering sync</code>","text":"<p>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).</p> <p>Examples:</p> <pre><code>ctx steering sync\n</code></pre> <p>Which tools are sync targets?</p> Tool Sync target Mechanism Cursor <code>.cursor/rules/</code> Cursor reads the directory natively Cline <code>.clinerules/</code> Cline reads the directory natively Kiro <code>.kiro/steering/</code> Kiro reads the directory natively Claude Code (no-op) Delivered via hook + MCP (see next section) Codex (no-op) Same as Claude Code <p>For the three native-rules tools, <code>ctx steering sync</code> writes each matching steering file to the appropriate directory with tool-specific frontmatter transforms. Unchanged files are skipped (idempotent).</p>","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":"<p>Claude Code has no native \"steering files\" primitive, so <code>ctx steering sync</code> skips it entirely. Instead, steering reaches Claude through two non-sync channels, both activated by <code>ctx setup claude-code</code> (which installs the plugin):</p> <p>1. Automatic injection via the <code>PreToolUse</code> hook. The Claude Code plugin wires a <code>PreToolUse</code> hook that runs <code>ctx agent --budget 8000</code> before each tool call. <code>ctx agent</code> loads <code>.context/steering/</code> and calls <code>steering.Filter</code> with an empty prompt, so only files with <code>inclusion: always</code> 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.</p> <p>2. On-demand MCP tool call (<code>ctx_steering_get</code>). The <code>ctx</code> plugin ships a <code>.mcp.json</code> file that automatically registers the <code>ctx</code> MCP server (<code>ctx mcp serve</code>) with Claude Code on plugin install. Once registered, Claude can invoke the <code>ctx_steering_get</code> tool mid-task to fetch matching steering files for a specific prompt. This is the only path that resolves <code>inclusion: auto</code> and <code>inclusion: manual</code> matches for Claude Code; Claude passes the prompt to the MCP tool, which runs the keyword match against each file's description.</p> <p>Verify the MCP server is registered:</p> <pre><code>claude mcp list\n</code></pre> <p>Expected line: <code>ctx: ctx mcp serve - ✓ Connected</code>. If it's missing, reinstall the plugin from Claude Code (<code>/plugin</code> → find <code>ctx</code> → uninstall → install again); older plugin versions shipped without the <code>.mcp.json</code> file.</p> <p>Prefer <code>inclusion: always</code> for Claude Code</p> <p>Because the PreToolUse hook passes an empty prompt to <code>ctx agent</code>, only <code>always</code> files fire automatically. <code>auto</code> files require Claude to call the <code>ctx_steering_get</code> MCP tool on its own; <code>manual</code> files require an explicit user invocation. For rules that should reliably fire on every Claude Code session, use <code>inclusion: always</code>. Reserve <code>auto</code>/<code>manual</code> for situational libraries where the opt-in cost is acceptable and you understand Claude may not pull them in without prompting.</p> <p>The foundation files scaffolded by <code>ctx init</code> already default to <code>inclusion: always</code> for this reason.</p> <p>Practical implications:</p> <ul> <li>Running <code>ctx steering sync</code> before starting a Claude session does nothing for Claude's benefit. Skip it.</li> <li><code>ctx steering preview</code> still works for validating your descriptions; it doesn't depend on sync.</li> <li>If Claude Code is your only tool, the <code>ctx steering</code> commands you care about are <code>add</code>, <code>list</code>, <code>preview</code>, <code>init</code> (never <code>sync</code>).</li> <li>If you use both Claude Code and (say) Cursor, <code>ctx steering sync</code> covers Cursor (where <code>auto</code> and <code>manual</code> work natively) while the hook+MCP pipeline covers Claude Code. For rules you need to fire automatically on both, use <code>inclusion: always</code>.</li> </ul>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#ctx-agent-integration","level":3,"title":"<code>ctx agent</code> Integration","text":"<p>When <code>ctx agent</code> builds a context packet, steering files are loaded as Tier 6 of the budget-aware assembly (see <code>ctx agent</code>). Files with <code>inclusion: always</code> are always included; <code>auto</code> files are scored against the current prompt and included in priority order until the tier budget is exhausted.</p>","path":["CLI","Integrations","Steering"],"tags":[]},{"location":"cli/steering/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx setup</code>: configure which tools receive steering syncs</li> <li><code>ctx trigger</code>: lifecycle scripts (a different hooking concept, see below)</li> <li>Building steering files recipe: walkthrough from first file to synced output</li> </ul>","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":"<code>ctx sysinfo</code>","text":"<p>Display a snapshot of system resources (memory, swap, disk, load) with threshold-based alert severities. Mirrors what the <code>check-resource</code> hook plumbing monitors in the background, but this command prints the full report at any severity level, not only at DANGER.</p> <pre><code>ctx sysinfo [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--json</code> Output in JSON format <p>Alert thresholds:</p> Resource WARNING DANGER Memory ≥ 75% ≥ 90% Swap ≥ 50% ≥ 75% Disk ≥ 85% ≥ 95% Load ≥ 1.0x CPUs ≥ 1.5x CPUs <p>Examples:</p> <pre><code>ctx sysinfo # Human-readable table\nctx sysinfo --json # Structured output\n</code></pre>","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":"<code>ctx system</code>","text":"<p>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 <code>ctx --help</code>; run <code>ctx system --help</code> to see its subcommands.</p> <pre><code>ctx system <subcommand>\n</code></pre> <p>Commands Previously under <code>ctx system</code></p> <p>Several user-facing maintenance commands used to live under <code>ctx system</code> and were promoted to top-level:</p> <ul> <li><code>ctx system events</code> → <code>ctx hook event</code></li> <li><code>ctx system message</code> → <code>ctx hook message</code></li> <li><code>ctx system prune</code> → <code>ctx prune</code></li> <li><code>ctx system resources</code> → <code>ctx sysinfo</code></li> <li><code>ctx system stats</code> → <code>ctx usage</code></li> </ul> <p><code>ctx system bootstrap</code> remains under <code>ctx system</code> as a hidden, agent-only command. Update any scripts or personal docs that reference the old paths.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#plumbing-subcommands","level":2,"title":"Plumbing Subcommands","text":"<p>These are not hook handlers; they're called by skills and editor integrations during the session lifecycle. Safe to run manually.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-journal","level":4,"title":"<code>ctx system mark-journal</code>","text":"<p>Update processing state for a journal entry. Records the current date in <code>.context/journal/.state.json</code>. Used by journal skills to record pipeline progress.</p> <pre><code>ctx system mark-journal <filename> <stage>\n</code></pre> <p>Stages: <code>exported</code>, <code>enriched</code>, <code>normalized</code>, <code>fences_verified</code></p> Flag Description <code>--check</code> Check if stage is set (exit 1 if not) <p>Example:</p> <pre><code>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</code></pre>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-mark-wrapped-up","level":4,"title":"<code>ctx system mark-wrapped-up</code>","text":"<p>Suppress context checkpoint nudges after a wrap-up ceremony. Writes a marker file that <code>check-context-size</code> checks before emitting checkpoint boxes. The marker expires after 2 hours.</p> <p>Called automatically by <code>/ctx-wrap-up</code> after persisting context (not intended for direct use).</p> <pre><code>ctx system mark-wrapped-up\n</code></pre> <p>No flags, no arguments. Idempotent: running it again updates the marker timestamp.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-pause-ctx-system-resume","level":4,"title":"<code>ctx system pause</code> / <code>ctx system resume</code>","text":"<p>Session-scoped hook suppression. <code>ctx system pause</code> writes a marker file that causes hook plumbing to no-op for the current session; <code>ctx system resume</code> removes it. These are the hook-plumbing counterparts to the <code>ctx hook pause</code> / <code>ctx hook resume</code> commands (which call them internally).</p> <p>Read the session ID from stdin JSON (same as hooks) or pass <code>--session-id</code>.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-session-event","level":4,"title":"<code>ctx system session-event</code>","text":"<p>Records a session lifecycle event (start or end) to the event log. Called by editor integrations when a workspace is opened or closed.</p> <pre><code>ctx system session-event --type start --caller vscode\nctx system session-event --type end --caller vscode\n</code></pre>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#ctx-system-statusline","level":4,"title":"<code>ctx system statusline</code>","text":"<p>Renders the Claude Code status line. Claude Code pipes a JSON payload to the configured statusLine command after each assistant message; this command turns it into one line:</p> <pre><code>user@host ~/project | Opus | ctx: 42% | $1.23\n</code></pre> <p><code>ctx init</code> wires it into <code>.claude/settings.local.json</code>, backing up any pre-existing statusLine entry to <code>.context/state/previous-statusline.json</code> (restored when <code>statusline.enabled: false</code> is set in <code>.ctxrc</code>; a statusLine that is not ctx's is never removed).</p> <p>Missing payload fields drop their segment. Output is sanitized to bounded printable ASCII, and the command always exits zero: a non-zero exit would blank the status line. The line is informational only; there is no cost gating and no model-switch nudging (see <code>specs/statusline.md</code> for the rationale).</p> <pre><code>ctx system statusline < payload.json\n</code></pre> <p>Config (<code>.ctxrc</code>): <code>statusline.enabled</code> (default <code>true</code>) and <code>statusline.show_cost</code> (render the <code>$</code> segment, default <code>true</code>; disable for screen-sharing or demos). Setting <code>enabled: false</code> blanks the rendered line immediately; the settings entry itself is restored/removed the next time the init merge runs.</p>","path":["CLI","Runtime","System"],"tags":[]},{"location":"cli/system/#hook-subcommands","level":2,"title":"Hook Subcommands","text":"<p>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 <code>decision</code> field.</p> <p>UserPromptSubmit hooks: <code>context-load-gate</code>, <code>check-context-size</code>, <code>check-persistence</code>, <code>check-ceremony</code>, <code>check-journal</code>, <code>check-version</code>, <code>check-resource</code>, <code>check-knowledge</code>, <code>check-map-staleness</code>, <code>check-memory-drift</code>, <code>check-reminder</code>, <code>check-freshness</code>, <code>check-hub-sync</code>, <code>check-skill-discovery</code>, <code>heartbeat</code>.</p> <p>PreToolUse hooks: <code>block-non-path-ctx</code>, <code>block-dangerous-command</code>, <code>qa-reminder</code>, <code>specs-nudge</code>.</p> <p>PostToolUse hooks: <code>post-commit</code>, <code>check-task-completion</code>.</p> <p>See AI Tools for registration details and the Claude Code plugin integration.</p>","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":"<code>ctx trace</code>","text":"<p>Show the context behind git commits. Links commits back to the decisions, tasks, learnings, and sessions that motivated them.</p> <p><code>git log</code> shows what changed, <code>git blame</code> shows who, and <code>ctx trace</code> shows why.</p> <pre><code>ctx trace [commit] [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--last N</code> Show context for last N commits <code>--json</code> Output as JSON for scripting <p>Examples:</p> <pre><code># 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</code></pre> <p>Output:</p> <pre><code>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</code></pre> <p>When listing recent commits with <code>--last</code>:</p> <pre><code>abc123 Fix auth token expiry decision:12, task:8\ndef456 Add rate limiting decision:15, learning:7\n789abc Update dependencies (none)\n</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-file","level":3,"title":"<code>ctx trace file</code>","text":"<p>Show the context trail for a file. Combines <code>git log</code> with context resolution.</p> <pre><code>ctx trace file <path[:line-range]> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--last N</code> Maximum commits to show (default: 20) <p>Examples:</p> <pre><code># 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</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-tag","level":3,"title":"<code>ctx trace tag</code>","text":"<p>Manually tag a commit with context. For commits made without the hook, or to add extra context after the fact.</p> <p>Tags are stored in <code>.context/trace/overrides.jsonl</code> since git trailers cannot be added to existing commits without rewriting history.</p> <pre><code>ctx trace tag <commit> --note \"<text>\"\n</code></pre> <p>Examples:</p> <pre><code>ctx trace tag HEAD --note \"Hotfix for production outage\"\nctx trace tag abc123 --note \"Part of Q1 compliance initiative\"\n</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#ctx-trace-hook","level":3,"title":"<code>ctx trace hook</code>","text":"<p>Enable or disable the prepare-commit-msg hook for automatic context tracing. When enabled, commits automatically receive a <code>ctx-context</code> trailer with references to relevant decisions, tasks, learnings, and sessions.</p> <pre><code>ctx trace hook <enable|disable>\n</code></pre> <p>Prerequisites: <code>ctx</code> must be on your <code>$PATH</code>. If you installed via <code>go install</code>, ensure <code>$GOPATH/bin</code> (or <code>$HOME/go/bin</code>) is in your shell's <code>$PATH</code>.</p> <p>What the hook does:</p> <ol> <li>Before each commit, collects context from three sources:</li> <li>Pending context accumulated during work (<code>ctx add</code>, <code>ctx task complete</code>)</li> <li>Staged file changes to <code>.context/</code> files</li> <li>Working state (in-progress tasks, active AI session)</li> <li>Injects a <code>ctx-context</code> trailer into the commit message</li> <li>After commit, records the mapping in <code>.context/trace/history.jsonl</code></li> </ol> <p>Examples:</p> <pre><code># Install the hook\nctx trace hook enable\n\n# Remove the hook\nctx trace hook disable\n</code></pre> <p>Resulting commit message:</p> <pre><code>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</code></pre>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#reference-types","level":3,"title":"Reference Types","text":"<p>The <code>ctx-context</code> trailer supports these reference types:</p> Prefix Points to Example <code>decision:<n></code> Entry #n in DECISIONS.md <code>decision:12</code> <code>learning:<n></code> Entry #n in LEARNINGS.md <code>learning:5</code> <code>task:<n></code> Task #n in TASKS.md <code>task:8</code> <code>convention:<n></code> Entry #n in CONVENTIONS.md <code>convention:3</code> <code>session:<id></code> AI session by ID <code>session:abc123</code> <code>\"<text>\"</code> Free-form context note <code>\"Performance fix for P1 incident\"</code>","path":["CLI","Diagnostics","Commit Context Tracing"],"tags":[]},{"location":"cli/trace/#storage","level":3,"title":"Storage","text":"<p>Context trace data is stored in the <code>.context/</code> directory:</p> File Purpose Lifecycle <code>state/pending-context.jsonl</code> Accumulates refs during work Truncated after each commit <code>trace/history.jsonl</code> Permanent commit-to-context map Append-only, never truncated <code>trace/overrides.jsonl</code> 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":"<code>ctx trigger</code>","text":"<p>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.</p> <pre><code>ctx trigger <subcommand>\n</code></pre> <p>Triggers Execute Arbitrary Scripts</p> <p>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.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#where-triggers-live","level":3,"title":"Where Triggers Live","text":"<p>Triggers live in <code>.context/hooks/<trigger-type>/</code> as executable scripts. The on-disk directory name is still <code>hooks/</code> for historical reasons even though the command is <code>ctx trigger</code>. Each script:</p> <ul> <li>Reads a JSON payload from stdin.</li> <li>Returns a JSON payload on stdout.</li> <li>Returns a non-zero exit code to block or error.</li> </ul> <pre><code>.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</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#trigger-types","level":3,"title":"Trigger Types","text":"Type Fires when <code>session-start</code> An AI session begins <code>session-end</code> An AI session ends <code>pre-tool-use</code> Before an AI tool call is executed <code>post-tool-use</code> After an AI tool call returns <code>file-save</code> When a file is saved <code>context-add</code> 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":"<p>Each trigger receives a JSON object on stdin with the event details. Minimal contract (fields vary by trigger type):</p> <pre><code>{\n \"type\": \"pre-tool-use\",\n \"tool\": \"write_file\",\n \"path\": \"src/auth.go\",\n \"session_id\": \"abc123-...\"\n}\n</code></pre> <p>The trigger may write a JSON object to stdout to influence behavior. Example for a blocking <code>pre-tool-use</code> trigger:</p> <pre><code>{\n \"action\": \"block\",\n \"message\": \"Editing src/auth.go requires approval from #security\"\n}\n</code></pre> <p>For non-blocking event loggers, simply read stdin and exit 0 without writing to stdout.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-add","level":3,"title":"<code>ctx trigger add</code>","text":"<p>Create a new trigger script with a template. The generated file has a bash shebang, a stdin reader using <code>jq</code>, and a basic JSON output structure.</p> <pre><code>ctx trigger add <trigger-type> <name>\n</code></pre> <p>Arguments:</p> <ul> <li><code>trigger-type</code>: One of <code>session-start</code>, <code>session-end</code>, <code>pre-tool-use</code>, <code>post-tool-use</code>, <code>file-save</code>, <code>context-add</code></li> <li><code>name</code>: Script name (without <code>.sh</code> extension)</li> </ul> <p>Examples:</p> <pre><code>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</code></pre> <p>The generated script is not executable by default. Enable it with <code>ctx trigger enable</code> after reviewing the contents.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-list","level":3,"title":"<code>ctx trigger list</code>","text":"<p>List all discovered triggers, grouped by trigger type, with their enabled/disabled status.</p> <p>Examples:</p> <pre><code>ctx trigger list\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-test","level":3,"title":"<code>ctx trigger test</code>","text":"<p>Run all enabled triggers of a given type against a mock payload. Use <code>--tool</code> and <code>--path</code> to customize the mock input for tool-related events.</p> <pre><code>ctx trigger test <trigger-type> [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--tool</code> Tool name to put in mock input <code>--path</code> File path to put in mock input <p>Examples:</p> <pre><code>ctx trigger test session-start\nctx trigger test pre-tool-use --tool write_file --path src/main.go\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-enable","level":3,"title":"<code>ctx trigger enable</code>","text":"<p>Enable a trigger by setting its executable permission bit. Searches every trigger-type directory for a script matching <code><name></code>.</p> <pre><code>ctx trigger enable <name>\n</code></pre> <p>Examples:</p> <pre><code>ctx trigger enable inject-context\n# Enabled .context/hooks/session-start/inject-context.sh\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#ctx-trigger-disable","level":3,"title":"<code>ctx trigger disable</code>","text":"<p>Disable a trigger by clearing its executable permission bit. Searches every trigger-type directory for a script matching <code><name></code>.</p> <pre><code>ctx trigger disable <name>\n</code></pre> <p>Examples:</p> <pre><code>ctx trigger disable inject-context\n# Disabled .context/hooks/session-start/inject-context.sh\n</code></pre>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#three-hooking-concepts-in-ctx-dont-confuse-them","level":3,"title":"Three Hooking Concepts in <code>ctx</code> (Don't Confuse Them)","text":"<p>This is a common source of confusion. <code>ctx</code> has three distinct hook-like layers, and they serve different purposes:</p> Layer Owned by Where it runs Configured via <code>ctx trigger</code> You <code>.context/hooks/<type>/*.sh</code> <code>ctx trigger add/enable</code> <code>ctx system</code> hooks <code>ctx</code> itself built-in, called by <code>ctx</code>'s own lifecycle internal (see <code>ctx system --help</code>) Claude Code hooks Claude Code <code>.claude/settings.local.json</code> edit JSON, or <code>/ctx-sanitize-permissions</code> <p>Use <code>ctx trigger</code> 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. <code>ctx system</code> hooks are not something you author; they're the internal nudge machinery that ships with ctx.</p>","path":["CLI","Integrations","Trigger"],"tags":[]},{"location":"cli/trigger/#see-also","level":3,"title":"See Also","text":"<ul> <li><code>ctx steering</code>: persistent AI behavioral rules (a different concept; rules vs scripts)</li> <li>Authoring triggers recipe: a full walkthrough with security guidance</li> </ul>","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":"<code>ctx usage</code>","text":"<p>Display per-session token usage statistics from the local stats JSONL files written by the <code>heartbeat</code> hook. By default, shows the last 20 entries across all sessions. Use <code>--follow</code> to stream new entries as they arrive (like <code>tail -f</code>).</p> <pre><code>ctx usage [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>-f</code>, <code>--follow</code> Stream new entries as they arrive <code>-s</code>, <code>--session</code> Filter by session ID (prefix match) <code>-n</code>, <code>--last</code> Show last N entries (default: 20) <code>-j</code>, <code>--json</code> Output raw JSONL <p>Examples:</p> <pre><code>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</code></pre>","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":"<code>ctx watch</code>","text":"<p>Watch for AI output and auto-apply context updates.</p> <p>Parses <code><context-update></code> XML commands from AI output and applies them to context files.</p> <pre><code>ctx watch [flags]\n</code></pre> <p>Flags:</p> Flag Description <code>--log <file></code> Log file to watch (default: stdin) <code>--dry-run</code> Preview updates without applying <p>Examples:</p> <pre><code># 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</code></pre>","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":"<code>ctx why</code>","text":"<p>Read <code>ctx</code>'s philosophy documents directly in the terminal.</p> <pre><code>ctx why [DOCUMENT]\n</code></pre> <p>Documents:</p> Name Description <code>manifesto</code> The <code>ctx</code> Manifesto: creation, not code <code>about</code> About <code>ctx</code>: what it is and why it exists <code>invariants</code> Design invariants: properties that must hold <p>Examples:</p> <pre><code># 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</code></pre>","path":["CLI","Getting Started","Why"],"tags":[]},{"location":"home/","level":1,"title":"Home","text":"<ul> <li><code>ctx</code> is not a prompt.</li> <li><code>ctx</code> is version-controlled cognitive state.</li> </ul> <p><code>ctx</code> is the persistence layer for human-AI reasoning.</p> <p>Deterministic. Git-native. Human-readable. Local-first.</p> <p>Start here.</p> <p>Learn what <code>ctx</code> does, set it up, and run your first session.</p> <p>Pre-1.0: Moving Fast</p> <p><code>ctx</code> is under active development. This website tracks the development branch, not the latest release:</p> <p>Some features described here may not exist in the binary you have installed.</p> <p>Expect rough edges.</p> <p>If something is missing or broken, open an issue.</p>","path":["Home"],"tags":[]},{"location":"home/#introduction","level":2,"title":"Introduction","text":"","path":["Home"],"tags":[]},{"location":"home/#about","level":3,"title":"About","text":"<p>What <code>ctx</code> is, how it works, and why persistent context changes how you work with AI.</p>","path":["Home"],"tags":[]},{"location":"home/#is-it-right-for-me","level":3,"title":"Is It Right for Me?","text":"<p>Good fit, not-so-good fit, and a 5-minute trial to find out for yourself.</p>","path":["Home"],"tags":[]},{"location":"home/#faq","level":3,"title":"FAQ","text":"<p>Quick answers to the questions newcomers ask most about <code>ctx</code>, files, tooling, and trade-offs.</p>","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":"<p>Install the binary, set up the plugin, and verify it works.</p>","path":["Home"],"tags":[]},{"location":"home/#your-first-session","level":3,"title":"Your First Session","text":"<p>Step-by-step walkthrough from <code>ctx init</code> to verified recall.</p>","path":["Home"],"tags":[]},{"location":"home/#common-workflows","level":3,"title":"Common Workflows","text":"<p>Day-to-day commands for tracking context, checking health, and browsing history.</p>","path":["Home"],"tags":[]},{"location":"home/#concepts","level":2,"title":"Concepts","text":"","path":["Home"],"tags":[]},{"location":"home/#context-files","level":3,"title":"Context Files","text":"<p>What each <code>.context/</code> file does. What's their purpose. How do we best leverage them.</p>","path":["Home"],"tags":[]},{"location":"home/#configuration","level":3,"title":"Configuration","text":"<p>Flexible configuration: <code>.ctxrc</code>, environment variables, and CLI flags.</p>","path":["Home"],"tags":[]},{"location":"home/#hub","level":3,"title":"Hub","text":"<p>A fan-out channel for decisions, learnings, conventions, and tasks that need to cross project boundaries, without replicating everything else.</p>","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":"<p>Effective prompts for AI sessions with <code>ctx</code>.</p>","path":["Home"],"tags":[]},{"location":"home/#keeping-ai-honest","level":3,"title":"Keeping AI Honest","text":"<p>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.</p>","path":["Home"],"tags":[]},{"location":"home/#my-ai-keeps-making-the-same-mistakes","level":3,"title":"My AI Keeps Making the Same Mistakes","text":"<p>Stop rediscovering the same bugs and dead-ends across sessions.</p>","path":["Home"],"tags":[]},{"location":"home/#joining-a-project","level":3,"title":"Joining a Project","text":"<p>You inherited a <code>.context/</code> directory. Get oriented fast: priority order, what to read first, how to ramp up.</p>","path":["Home"],"tags":[]},{"location":"home/#customization","level":2,"title":"Customization","text":"","path":["Home"],"tags":[]},{"location":"home/#steering-files","level":3,"title":"Steering Files","text":"<p>Tell the assistant how to behave when a specific kind of prompt arrives.</p>","path":["Home"],"tags":[]},{"location":"home/#lifecycle-triggers","level":3,"title":"Lifecycle Triggers","text":"<p>Make things happen at session boundaries: block dangerous tool calls, inject standup notes, log file saves.</p>","path":["Home"],"tags":[]},{"location":"home/#community","level":2,"title":"Community","text":"","path":["Home"],"tags":[]},{"location":"home/#ctx","level":3,"title":"#<code>ctx</code>","text":"<p>We are the builders who care about durable context. Join the community. Hang out in IRC. Star <code>ctx</code> on GitHub.</p>","path":["Home"],"tags":[]},{"location":"home/#contributing","level":3,"title":"Contributing","text":"<p>Development setup, project layout, and pull request process.</p>","path":["Home"],"tags":[]},{"location":"home/about/","level":1,"title":"About","text":"<p>\"Creation, not code; Context, not prompts; Verification, not vibes.\"</p> <p>Read the <code>ctx</code> Manifesto →</p> <p>\"Without durable context, intelligence resets; with <code>ctx</code>, creation compounds.\"</p> <p>Without persistent memory, every session starts at zero; <code>ctx</code> makes sessions cumulative.</p> <p>Join the <code>ctx</code> Community →</p>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#what-is-ctx","level":2,"title":"What Is <code>ctx</code>?","text":"<p><code>ctx</code> (Context) is a file-based system that enables AI coding assistants to persist project knowledge across sessions. It lives in a <code>.context/</code> directory in your repo.</p> <ul> <li>A session is interactive.</li> <li><code>ctx</code> enables cognitive continuity.</li> <li>Cognitive continuity enables durable, symbiotic-like human-AI workflows.</li> </ul> <p>Context Files</p> <p>Context files let AI tools remember decisions, conventions, and learnings:</p> <p>Context files are explicit and versionable contracts between you and your agents.</p>","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":"<p>You open a new AI session. The first thing you do is re-explain your project.</p> <p>Again.</p> <p>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.</p> <ul> <li>You explain the same architecture every session;</li> <li>The AI suggests an approach you already rejected, again;</li> <li>A decision you made three sessions ago gets relitigated from scratch;</li> <li>You spend more time setting context than building features.</li> </ul> <p>This isn't AI failure: It is staleness. </p> <p>Without persistent memory, every session starts at zero.</p>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#day-and-night","level":3,"title":"Day and Night","text":"<p><code>ctx</code> gives your AI a memory that persists across sessions:</p> Without <code>ctx</code>With <code>ctx</code> <pre><code>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</code></pre> <pre><code>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</code></pre>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/about/#how-ctx-solves-this","level":3,"title":"How <code>ctx</code> Solves This","text":"<p><code>ctx</code> creates a <code>.context/</code> directory in your project that stores structured knowledge files:</p> File What It Remembers <code>TASKS.md</code> What you're working on and what's next <code>DECISIONS.md</code> Architectural choices and why you made them <code>LEARNINGS.md</code> Gotchas, bugs, things that didn't work <code>CONVENTIONS.md</code> Naming patterns, code style, project rules <code>CONSTITUTION.md</code> Hard rules the AI must never violate <p>These files can version with your code in <code>git</code>: </p> <ul> <li>They load automatically at the session start (via hooks in Claude Code, or manually with <code>ctx agent</code> for other tools). </li> <li>The AI reads them, cites them, and builds on them, instead of asking you to start over. <ul> <li>And when it acts, it can point to the exact file and line that justifies the choice.</li> </ul> </li> </ul> <p>Every decision you record, every lesson you capture, makes the next session smarter.</p> <p><code>ctx</code> accumulates.</p> <p>Connect with <code>ctx</code></p> <ul> <li>Join the Community →: ask questions, share workflows, and help shape what comes next</li> <li>Read the Blog →: real-world patterns, ponderings, and lessons learned from building <code>ctx</code> using <code>ctx</code></li> </ul> <p>Ready to Get Started?</p> <ul> <li>Getting Started →: full installation and setup</li> <li>Your First Session →: step-by-step walkthrough from <code>ctx init</code> to verified recall</li> </ul>","path":["Home","Introduction","About"],"tags":[]},{"location":"home/common-workflows/","level":1,"title":"Common Workflows","text":"<p>The commands below cover what you'll use most often: </p> <ul> <li>recording context, </li> <li>checking health, </li> <li>browsing history, </li> <li>and running loops.</li> </ul> <p>Each section is a self-contained snippet you can copy into your terminal.</p> <p>For deeper, step-by-step guides, see Recipes.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#track-context","level":2,"title":"Track Context","text":"<p>Prefer Skills over Raw Commands</p> <p>When working with an AI agent, use <code>/ctx-task-add</code>, <code>/ctx-decision-add</code>, or <code>/ctx-learning-add</code> instead of raw <code>ctx add</code> commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.</p> <pre><code># 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</code></pre>","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":"<p>Drop a note that surfaces automatically at the start of your next session:</p> <pre><code># 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</code></pre> <p>Reminders are relayed verbatim at session start by the <code>check-reminders</code> hook and repeat every session until you dismiss them.</p> <p>See Session Reminders for the full recipe.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#check-context-health","level":2,"title":"Check Context Health","text":"<pre><code># Detect stale paths, missing files, potential secrets\nctx drift\n\n# See full context summary\nctx status\n</code></pre>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#browse-session-history","level":2,"title":"Browse Session History","text":"<p>List and search past AI sessions from the terminal:</p> <pre><code>ctx journal source --limit 5\n</code></pre>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#journal-site","level":3,"title":"Journal Site","text":"<p>Import session transcripts to a browsable static site with search, navigation, and topic indices.</p> <p>The <code>ctx journal</code> command requires zensical (Python >= 3.10).</p> <p><code>zensical</code> is a Python-based static site generator from the Material for MkDocs team.</p> <p>(why zensical?).</p> <p>If you don't have it on your system, install <code>zensical</code> once with pipx:</p> <pre><code># One-time setup\npipx install zensical\n</code></pre> <p>Avoid <code>pip install zensical</code></p> <p><code>pip install</code> often fails: For example, on macOS, system Python installs a non-functional stub (<code>zensical</code> requires <code>Python >= 3.10</code>), and Homebrew Python blocks system-wide installs (<code>PEP 668</code>).</p> <p><code>pipx</code> creates an isolated environment with the correct Python version automatically.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#import-and-serve","level":3,"title":"Import and Serve","text":"<p>Then, import and serve:</p> <pre><code># Import to .context/journal/ (new sessions + any that have grown; self-healing)\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n</code></pre> <p>Open http://localhost:8000 to browse.</p> <p>To update after new sessions, run the same two commands again.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#self-healing-by-default","level":3,"title":"Self-Healing by Default","text":"<p><code>ctx journal import --all</code> is self-healing by default:</p> <ul> <li>It imports new sessions and completes any whose source transcript has grown since the last import, skipping only sessions whose source is unchanged. Hand-edited entries are detected and left untouched, never clobbered. See <code>ctx journal import</code> for details.</li> <li>Locked entries (via <code>ctx journal lock</code>) are always skipped by both import and enrichment skills.</li> <li>If you add <code>locked: true</code> to frontmatter during enrichment, run <code>ctx journal sync</code> to propagate the lock state to <code>.state.json</code>.</li> </ul>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#re-importing-existing-files","level":3,"title":"Re-Importing Existing Files","text":"<p>Here is how you regenerate existing files.</p> <p>Backup your <code>.context</code> folder before regeneration, as this is a potentially destructive action.</p> <p>To re-import journal files, you need to explicitly opt-in using the <code>--regenerate</code> flag:</p> Flag combination Frontmatter Body <code>--regenerate</code> Preserved Overwritten from source <code>--regenerate --keep-frontmatter=false</code> Overwritten Overwritten <p>Regeneration Overwrites Body Edits</p> <p><code>--regenerate</code> preserves your YAML frontmatter (tags, summary, enrichment metadata) but it replaces the Markdown body with a fresh import.</p> <p>Any manual edits you made to the transcript will be lost.</p> <p>Lock entries you want to protect first: <code>ctx journal lock <session-id></code>.</p> <p>See Session Journal for the full pipeline including normalization and enrichment.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#scratchpad","level":2,"title":"Scratchpad","text":"<p>Store short, sensitive one-liners in an encrypted scratchpad that travels with the project:</p> <pre><code># 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</code></pre> <p>The scratchpad is encrypted with a key stored at <code>~/.ctx/.ctx.key</code> (outside the project, never committed).</p> <p>See Scratchpad for details.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#run-an-autonomous-loop","level":2,"title":"Run an Autonomous Loop","text":"<p>Generate a script that iterates an AI agent until a completion signal is detected:</p> <pre><code>ctx loop\nchmod +x loop.sh\n./loop.sh\n</code></pre> <p>See Autonomous Loops for configuration and advanced usage.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#trace-commit-context","level":2,"title":"Trace Commit Context","text":"<p>Link your git commits back to the decisions, tasks, and learnings that motivated them. Enable the hook once:</p> <pre><code># Install the git hook (one-time setup)\nctx trace hook enable\n</code></pre> <p>From now on, every <code>git commit</code> automatically gets a <code>ctx-context</code> trailer linking it to relevant context. No extra steps needed; just use <code>ctx add</code>, <code>ctx task complete</code>, and commit as usual.</p> <pre><code># 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</code></pre> <p>To stop: <code>ctx trace hook disable</code>.</p> <p>See CLI Reference: trace for details.</p>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/common-workflows/#agent-session-start","level":2,"title":"Agent Session Start","text":"<p>The first thing an AI agent should do at session start is discover where context lives:</p> <pre><code>ctx system bootstrap\n</code></pre> <p>This prints the resolved context directory, the files in it, and the operating rules. The <code>CLAUDE.md</code> template instructs the agent to run this automatically. See CLI Reference: bootstrap.</p>","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":"<p>Using <code>/ctx-remember</code> at session start and <code>/ctx-wrap-up</code> at session end are the highest-value skills in the entire catalog:</p> <pre><code># session begins:\n/ctx-remember\n... do work ...\n# before closing the session:\n/ctx-wrap-up\n</code></pre> <p>Let's provide some context, because this is important:</p> <p>Although the agent will eventually discover your context through <code>CLAUDE.md → AGENT_PLAYBOOK.md</code>, <code>/ctx-remember</code> hydrates the full context up front (tasks, decisions, recent sessions) so the agent starts informed rather than piecing things together over several turns.</p> <p><code>/ctx-wrap-up</code> is the other half: A structured review that captures learnings, decisions, and tasks before you close the window.</p> <p>Hooks like <code>check-persistence</code> 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 <code>CTRL+C</code> can end things at any moment with no reliable \"before session end\" event. </p> <p>In short, <code>/ctx-wrap-up</code> is the deliberate checkpoint that makes sure nothing slips through. And <code>/ctx-remember</code> it its mirror skill to be used at session start.</p> <p>See Session Ceremonies for the full workflow.</p>","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":"<p>Most <code>ctx</code> 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.</p> <p>Commands and skills are not interchangeable: Each has a distinct role.</p> <code>ctx</code> CLI command <code>ctx</code> 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":"<p>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.</p> CLI Skill When to prefer the skill <code>ctx drift</code> <code>/ctx-drift</code> Semantic analysis: catches meaning drift the CLI misses <code>ctx status</code> <code>/ctx-status</code> Interpreted summary with recommendations <code>ctx task add</code> <code>/ctx-task-add</code> Agent decomposes vague goals into concrete tasks <code>ctx decision add</code> <code>/ctx-decision-add</code> Agent drafts rationale and consequences from discussion <code>ctx learning add</code> <code>/ctx-learning-add</code> Agent extracts the lesson from a debugging session <code>ctx convention add</code> <code>/ctx-convention-add</code> Agent observes a repeated pattern and codifies it <code>ctx task archive</code> <code>/ctx-archive</code> Agent reviews which tasks are truly done <code>ctx pad</code> <code>/ctx-pad</code> Agent reads/writes scratchpad entries in conversation flow <code>ctx journal</code> <code>/ctx-history</code> Agent searches session history with semantic understanding <code>ctx agent</code> <code>/ctx-agent</code> Agent loads and acts on the context packet <code>ctx loop</code> <code>/ctx-loop</code> Agent tailors the loop script to your project <code>ctx doctor</code> <code>/ctx-doctor</code> Agent adds semantic analysis to structural checks <code>ctx hook pause</code> <code>/ctx-pause</code> Agent pauses hooks with session-aware reasoning <code>ctx hook resume</code> <code>/ctx-resume</code> Agent resumes hooks after a pause <code>ctx remind</code> <code>/ctx-remind</code> 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":"<p>These have no CLI equivalent. They require the agent's reasoning.</p> Skill Purpose <code>/ctx-remember</code> Load context and present structured readback at session start <code>/ctx-wrap-up</code> End-of-session ceremony: persist learnings, decisions, tasks <code>/ctx-next</code> Suggest 1-3 concrete next actions from context <code>/ctx-commit</code> Commit with integrated context capture <code>/ctx-reflect</code> Pause and assess session progress <code>/ctx-consolidate</code> Merge overlapping learnings or decisions <code>/ctx-prompt-audit</code> Analyze prompting patterns for improvement <code>/ctx-plan</code> Stress-test an existing plan through adversarial interview <code>/ctx-plan-import</code> Import Claude Code plan files into project specs <code>/ctx-task-out</code> Decompose a committed spec into a per-milestone implementation plan <code>/ctx-implement</code> Execute a plan step-by-step with verification <code>/ctx-worktree</code> Manage parallel agent worktrees <code>/ctx-journal-enrich</code> Add metadata, tags, and summaries to journal entries <code>/ctx-journal-enrich-all</code> Full journal pipeline: export if needed, then batch-enrich <code>/ctx-blog</code> Generate a blog post (zensical-flavored Markdown) <code>/ctx-blog-changelog</code> Generate themed blog post from commits between releases <code>/ctx-architecture</code> 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":"<p>These are infrastructure: used in scripts, CI, or one-time setup.</p> Command Purpose <code>ctx init</code> Initialize <code>.context/</code> directory <code>ctx load</code> Output assembled context for piping <code>ctx task complete</code> Mark a task done by substring match <code>ctx sync</code> Reconcile context with codebase state <code>ctx compact</code> Consolidate and clean up context files <code>ctx trace</code> Show context behind git commits <code>ctx trace hook</code> Enable/disable commit context tracing hook <code>ctx setup</code> Generate AI tool integration config <code>ctx watch</code> Watch AI output and auto-apply context updates <code>ctx serve</code> Serve any zensical directory (default: journal) <code>ctx permission snapshot</code> Save settings as a golden image <code>ctx permission restore</code> Restore settings from golden image <code>ctx journal site</code> Generate browsable journal from exports <code>ctx hook notify setup</code> Configure webhook notifications <code>ctx decision</code> List and filter decisions <code>ctx learning</code> List and filter learnings <code>ctx task</code> List tasks, manage archival and snapshots <code>ctx why</code> Read the philosophy behind <code>ctx</code> <code>ctx guide</code> Quick-reference cheat sheet <code>ctx site</code> Site management commands <code>ctx config</code> Manage runtime configuration profiles <code>ctx system</code> System diagnostics and hook commands <code>ctx completion</code> Generate shell autocompletion scripts <p>Rule of Thumb</p> <p>Quick check? Use the CLI. </p> <p>Need judgment? Use the skill.</p> <p>When in doubt, start with the CLI: It's free and instant.</p> <p>Escalate to the skill when heuristics aren't enough.</p> <p>Next Up: Context Files →: what each <code>.context/</code> file does and how to use it</p> <p>See Also:</p> <ul> <li>Recipes: targeted how-to guides for specific tasks</li> <li>Knowledge Capture: patterns for recording decisions, learnings, and conventions</li> <li>Context Health: keeping your <code>.context/</code> accurate and drift-free</li> <li>Session Archaeology: digging into past sessions</li> <li>Task Management: tracking and completing work items</li> </ul>","path":["Home","Get Started","Common Workflows"],"tags":[]},{"location":"home/community/","level":1,"title":"#ctx","text":"<p>Open source is better together.</p> <p>We are the builders who care about durable context, verifiable decisions, and human-AI workflows that compound over time.</p>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#help-ctx-change-how-ai-remembers","level":2,"title":"Help <code>ctx</code> Change How AI Remembers","text":"<p>If you like the idea, a star helps <code>ctx</code> reach engineers who run into context drift every day:</p> <p> Star <code>ctx</code> on GitHub ⭐</p>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#ctx-you","level":2,"title":"<code>ctx</code> ♥️ You","text":"<p>Join the community to ask questions, share feedback, and connect with other users:</p> <ul> <li> Discord join the <code>ctx</code> Discord: Real-time discussion, field notes, and early ideas.</li> <li> Read the <code>ctx</code> Source on GitHub: Issues, discussions, and contributions.</li> </ul>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#want-to-contribute","level":2,"title":"Want to Contribute?","text":"<p>Early adopters shape the conventions.</p> <p><code>ctx</code> is free and open source software.</p> <p>Contributions are always welcome and appreciated.</p>","path":["Home","Community","#ctx"],"tags":[]},{"location":"home/community/#code-of-conduct","level":2,"title":"Code of Conduct","text":"<p>Clear context requires respectful collaboration. </p> <p><code>ctx</code> follows the Contributor Covenant.</p>","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":"<p><code>ctx</code> uses three layers of configuration. Each layer overrides the one below it:</p> <ol> <li>CLI flags: Per-invocation overrides (highest priority)</li> <li>Environment variables: Shell or CI/CD overrides</li> <li>The <code>.ctxrc</code> file: Project-level defaults (YAML)</li> <li>Built-in defaults: Hardcoded fallbacks (lowest priority)</li> </ol> <p>All settings are optional: If nothing is configured, <code>ctx</code> works out of the box with sensible defaults.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#the-ctxrc-file","level":2,"title":"The <code>.ctxrc</code> File","text":"<p>The <code>.ctxrc</code> file is an optional YAML file placed in the project root (next to your <code>.context/</code> directory). It lets you set project-level defaults that apply to every <code>ctx</code> command.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#location","level":3,"title":"Location","text":"<pre><code>my-project/\n├── .ctxrc ← configuration file\n├── .context/\n│ ├── TASKS.md\n│ ├── DECISIONS.md\n│ └── ...\n└── src/\n</code></pre> <p><code>ctx</code> reads <code>.ctxrc</code> from the current working directory (the project root, sibling of <code>.context/</code>). It does not walk up. <code>ctx</code> commands must be run from the project root; subdirectories are not supported by design (see Getting Started). There is no global or user-level config file: configuration is always per-project.</p> <p>Contributors: Dev Configuration Profile</p> <p>The <code>ctx</code> repo ships two <code>.ctxrc</code> source profiles (<code>.ctxrc.base</code> and <code>.ctxrc.dev</code>). The working copy is gitignored and swapped between them via <code>ctx config switch dev</code> / <code>ctx config switch base</code>. See Contributing: Configuration Profiles.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#full-reference","level":3,"title":"Full Reference","text":"<p>A commented <code>.ctxrc</code> showing all options and their defaults:</p> <pre><code># .ctxrc: ctx runtime configuration\n# https://ctx.ist/home/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# auto_prune_days: 7 # days before stale session-state files are pruned on load (0/negative = default)\n# agent_cooldown_minutes: 10 # minutes between repeated `ctx agent` emissions (0 = disable the cooldown)\n# task_budget_pct: 0.40 # fraction of the `ctx agent` token budget for tasks (0-1; 0 = none)\n# convention_budget_pct: 0.20 # fraction of the `ctx agent` token budget for conventions (0-1; 0 = none)\n# title_slug_max_len: 50 # max characters in title-derived journal filename slugs (0/negative = default)\n# recall_list_limit: 20 # default `ctx journal source` list size when --limit is omitted (0/negative = default)\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# statusline: # Claude Code status line (informational only)\n# enabled: true # Deploy statusLine via ctx init\n# show_cost: true # Render the $ session-cost segment\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</code></pre>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#option-reference","level":3,"title":"Option Reference","text":"Option Type Default Description <code>token_budget</code> <code>int</code> <code>8000</code> Default token budget for <code>ctx agent</code> and <code>ctx load</code> <code>auto_archive</code> <code>bool</code> <code>true</code> Auto-archive completed tasks during <code>ctx compact</code> <code>archive_after_days</code> <code>int</code> <code>7</code> Days before completed tasks are archived <code>scratchpad_encrypt</code> <code>bool</code> <code>true</code> Encrypt scratchpad with AES-256-GCM <code>event_log</code> <code>bool</code> <code>false</code> Enable local hook event logging to <code>.context/state/events.jsonl</code> <code>entry_count_learnings</code> <code>int</code> <code>30</code> Drift warning when <code>LEARNINGS.md</code> exceeds this entry count (0 = disable) <code>entry_count_decisions</code> <code>int</code> <code>20</code> Drift warning when <code>DECISIONS.md</code> exceeds this entry count (0 = disable) <code>convention_line_count</code> <code>int</code> <code>200</code> Drift warning when <code>CONVENTIONS.md</code> exceeds this line count (0 = disable) <code>injection_token_warn</code> <code>int</code> <code>15000</code> Warn when auto-injected context exceeds this token count (0 = disable) <code>context_window</code> <code>int</code> <code>200000</code> Context window size in tokens. Auto-detected for Claude Code (200k/1M); override for other AI tools <code>billing_token_warn</code> <code>int</code> <code>0</code> (off) One-shot warning when session tokens exceed this threshold (0 = disabled). For plans where tokens beyond an included allowance cost extra <code>stale_age_days</code> <code>int</code> <code>30</code> Days before <code>ctx drift</code> flags a context file as stale (0 = disable) <code>key_rotation_days</code> <code>int</code> <code>90</code> Days before encryption key rotation nudge <code>task_nudge_interval</code> <code>int</code> <code>5</code> Edit/Write calls between task completion nudges <code>notify.events</code> <code>[]string</code> (all) Event filter for webhook notifications (empty = all) <code>priority_order</code> <code>[]string</code> (see below) Custom file loading priority for context assembly <code>tool</code> <code>string</code> (empty) Active AI tool identifier (<code>claude</code>, <code>cursor</code>, <code>cline</code>, <code>kiro</code>, <code>codex</code>). Used by steering sync and hook dispatch <code>steering.dir</code> <code>string</code> <code>.context/steering</code> Steering files directory <code>steering.default_inclusion</code> <code>string</code> <code>manual</code> Default inclusion mode for new steering files (<code>always</code>, <code>auto</code>, <code>manual</code>) <code>steering.default_tools</code> <code>[]string</code> (all) Default tool filter for new steering files (empty = all tools) <code>hooks.dir</code> <code>string</code> <code>.context/hooks</code> Hook scripts directory <code>hooks.timeout</code> <code>int</code> <code>10</code> Per-hook execution timeout in seconds <code>hooks.enabled</code> <code>bool</code> <code>true</code> Whether hook execution is enabled <code>statusline.enabled</code> <code>bool</code> <code>true</code> Whether <code>ctx init</code> deploys the Claude Code status line (<code>ctx system statusline</code>) <code>statusline.show_cost</code> <code>bool</code> <code>true</code> Whether the status line renders the session-cost (<code>$</code>) segment <code>provenance_required.session_id</code> <code>bool</code> <code>true</code> Require <code>--session-id</code> on <code>ctx add</code> for tasks, decisions, learnings <code>provenance_required.branch</code> <code>bool</code> <code>true</code> Require <code>--branch</code> on <code>ctx add</code> for tasks, decisions, learnings <code>provenance_required.commit</code> <code>bool</code> <code>true</code> Require <code>--commit</code> on <code>ctx add</code> for tasks, decisions, learnings <code>auto_prune_days</code> <code>int</code> <code>7</code> Days before stale session-state files are auto-pruned on context load. Non-positive values fall back to the default (never prunes on <code>0</code> or negative) <code>agent_cooldown_minutes</code> <code>int</code> <code>10</code> Minutes between repeated <code>ctx agent</code> context-packet emissions. An explicit <code>0</code> disables the cooldown (matches <code>--cooldown 0</code>); unset uses the default <code>task_budget_pct</code> <code>number</code> <code>0.40</code> Fraction of the <code>ctx agent</code> token budget reserved for tasks (clamped to <code>0</code>–<code>1</code>; explicit <code>0</code> allocates none; unset uses the default) <code>convention_budget_pct</code> <code>number</code> <code>0.20</code> Fraction of the <code>ctx agent</code> token budget reserved for conventions (clamped to <code>0</code>–<code>1</code>; explicit <code>0</code> allocates none; unset uses the default) <code>title_slug_max_len</code> <code>int</code> <code>50</code> Maximum characters in title-derived journal filename slugs. Non-positive values fall back to the default <code>recall_list_limit</code> <code>int</code> <code>20</code> Default number of sessions <code>ctx journal source</code> lists when <code>--limit</code> is omitted. Non-positive values fall back to the default <p>Default priority order (used when <code>priority_order</code> is not set):</p> <ol> <li><code>CONSTITUTION.md</code></li> <li><code>TASKS.md</code></li> <li><code>CONVENTIONS.md</code></li> <li><code>ARCHITECTURE.md</code></li> <li><code>DECISIONS.md</code></li> <li><code>LEARNINGS.md</code></li> <li><code>GLOSSARY.md</code></li> <li><code>AGENT_PLAYBOOK.md</code></li> </ol> <p>See Context Files for the rationale behind this ordering.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#environment-variables","level":2,"title":"Environment Variables","text":"<p>Environment variables override <code>.ctxrc</code> values but are overridden by CLI flags.</p> Variable Description Equivalent <code>.ctxrc</code> key <code>CTX_TOKEN_BUDGET</code> Override the default token budget <code>token_budget</code>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples","level":3,"title":"Examples","text":"<pre><code># Increase token budget for a single run\nCTX_TOKEN_BUDGET=16000 ctx agent\n</code></pre>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#cli-global-flags","level":2,"title":"CLI Global Flags","text":"<p>CLI flags have the highest priority and override both environment variables and <code>.ctxrc</code> settings. These flags are available on every <code>ctx</code> command.</p> Flag Description <code>--tool <name></code> Override active AI tool identifier (e.g. <code>kiro</code>, <code>cursor</code>) <code>--version</code> Show version and exit <code>--help</code> Show command help and exit","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#priority-order","level":2,"title":"Priority Order","text":"<p>When the same setting is configured in multiple layers, the highest-priority layer wins:</p> <pre><code>CLI flags > Environment variables > .ctxrc > Built-in defaults\n(highest) (lowest)\n</code></pre> <p>The context directory itself is resolved differently: it lives outside this priority chain. <code>ctx</code> always reads <code>$PWD/.context/</code>; if that path does not exist, the command refuses with a clear error.</p> <p>Example resolution for <code>token_budget</code>:</p> Layer Value Wins? <code>CTX_TOKEN_BUDGET</code> <code>4000</code> Yes <code>.ctxrc</code> <code>8000</code> No Default <code>8000</code> No","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#examples_1","level":2,"title":"Examples","text":"","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-token-budget","level":3,"title":"Custom Token Budget","text":"<p>Increase the token budget for projects with large context:</p> <pre><code># .ctxrc\ntoken_budget: 16000\n</code></pre> <p>This affects the default budget for <code>ctx agent</code> and <code>ctx load</code>. You can still override per-invocation with <code>ctx agent --budget 4000</code>.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#disabled-scratchpad-encryption","level":3,"title":"Disabled Scratchpad Encryption","text":"<p>Turn off encryption for the scratchpad (useful in ephemeral environments where key management is unnecessary):</p> <pre><code># .ctxrc\nscratchpad_encrypt: false\n</code></pre> <p>Unencrypted Scratchpads Store Secrets in Plaintext</p> <p>Only disable encryption if you understand the security implications.</p> <p>The scratchpad may contain sensitive data such as API keys, database URLs, or deployment credentials.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#custom-priority-order","level":3,"title":"Custom Priority Order","text":"<p>Reorder context files to prioritize architecture over conventions:</p> <pre><code># .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</code></pre> <p>Files not listed in <code>priority_order</code> receive the lowest priority (100). The order affects <code>ctx agent</code>, <code>ctx load</code>, and drift's file-priority calculations.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#billing-token-threshold","level":3,"title":"Billing Token Threshold","text":"<p>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):</p> <pre><code># .ctxrc\nbilling_token_warn: 180000 # warn before hitting the 200k paid boundary\n</code></pre> <p>The warning fires once per session the first time token usage exceeds the threshold. Set to <code>0</code> (or omit) to disable.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#adjusted-drift-thresholds","level":3,"title":"Adjusted Drift Thresholds","text":"<p>Raise or lower the entry-count thresholds that trigger drift warnings:</p> <pre><code># .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</code></pre> <p>Set any threshold to <code>0</code> to disable that specific check.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"<p>Get notified when loops complete, hooks fire, or agents reach milestones:</p> <pre><code># Configure the webhook URL (encrypted, safe to commit)\nctx hook notify setup\n\n# Test delivery\nctx hook notify test\n</code></pre> <p>Filter which events reach your webhook:</p> <pre><code># .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</code></pre> <p>Notifications are opt-in: No events are sent unless explicitly listed.</p> <p>See Webhook Notifications for a step-by-step recipe.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#hook-message-overrides","level":2,"title":"Hook Message Overrides","text":"<p>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 <code>.context/</code>:</p> <pre><code>.context/hooks/messages/{hook}/{variant}.txt\n</code></pre> <p>The override takes priority over the embedded default compiled into the <code>ctx</code> binary. An empty file silences the message while preserving the hook's logic (counting, state tracking, cooldowns).</p> <p>Use <code>ctx hook message</code> to discover and manage overrides:</p> <pre><code>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</code></pre> <p>See Customizing Hook Messages for detailed examples including Python, JavaScript, and silence configurations.</p>","path":["Home","Concepts","Configuration"],"tags":[]},{"location":"home/configuration/#agent-bootstrapping","level":2,"title":"Agent Bootstrapping","text":"<p>AI agents need to know the resolved context directory at session start. The <code>ctx system bootstrap</code> command prints the context path, file list, and operating rules in both text and JSON formats:</p> <pre><code>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</code></pre> <p>The <code>CLAUDE.md</code> template instructs the agent to run this as its first action. Every nudge (context checkpoint, persistence reminder, etc.) also includes a <code>Context: <dir></code> footer that re-anchors the agent to the correct directory throughout the session.</p> <p>This replaces the previous approach of hardcoding <code>.context/</code> paths in agent instructions. </p> <p>See CLI Reference: bootstrap for full details.</p> <p>See also: CLI Reference | Context Files | Scratchpad</p>","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":"<code>.context/</code>","text":"<p>Each context file in <code>.context/</code> serves a specific purpose. </p> <p>Files are designed to be human-readable, AI-parseable, and token-efficient.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#file-overview","level":2,"title":"File Overview","text":"<p>The core context files live directly under <code>.context/</code>. They are the substrate <code>ctx</code> reads in priority order when assembling the agent context packet:</p> File Purpose Priority <code>CONSTITUTION.md</code> Hard rules that must NEVER be violated 1 (highest) <code>TASKS.md</code> Current and planned work 2 <code>CONVENTIONS.md</code> Project patterns and standards 3 <code>ARCHITECTURE.md</code> System overview and components 4 <code>DECISIONS.md</code> Architectural decisions with rationale 5 <code>LEARNINGS.md</code> Lessons learned, gotchas, tips 6 <code>GLOSSARY.md</code> Domain terms and abbreviations 7 <code>AGENT_PLAYBOOK.md</code> Instructions for AI tools 8 (lowest) <p>Two subdirectories under <code>.context/</code> are implementation details that are user-editable but not part of the priority read order:</p> <ul> <li><code>.context/templates/</code>: format templates for <code>ctx decision add</code> and <code>ctx learning add</code>. See templates below.</li> <li><code>.context/steering/</code>: 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.</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#outside-context","level":3,"title":"Outside <code>.context/</code>","text":"<p>Two other moving parts are often confused with context files but are not under <code>.context/</code>:</p> <ul> <li>Skills live in <code>.claude/skills/</code> (project-local) or are provided by the installed <code>ctx</code> 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 <code>ctx skill</code> and Skills reference.</li> <li>Hooks: Claude Code <code>PreToolUse</code>/<code>PostToolUse</code>/ <code>UserPromptSubmit</code> entries configured in <code>.claude/settings.json</code> or shipped by a plugin. The <code>ctx</code> 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.</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#read-order-rationale","level":2,"title":"Read Order Rationale","text":"<p>The priority order follows a logical progression for AI tools:</p> <ol> <li><code>CONSTITUTION.md</code>: Inviolable rules first. The AI tool must know what it cannot do before attempting anything.</li> <li><code>TASKS.md</code>: Current work items. What the AI tool should focus on.</li> <li><code>CONVENTIONS.md</code>: How to write code. Patterns and standards to follow when implementing tasks.</li> <li><code>ARCHITECTURE.md</code>: System structure. Understanding of components and boundaries before making changes.</li> <li><code>DECISIONS.md</code>: Historical context. Why things are the way they are, to avoid re-debating settled decisions.</li> <li><code>LEARNINGS.md</code>: Gotchas and tips. Lessons from past work that inform the current implementation.</li> <li><code>GLOSSARY.md</code>: Reference material. Domain terms and abbreviations for lookup as needed.</li> <li><code>AGENT_PLAYBOOK.md</code>: 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.</li> </ol>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#constitutionmd","level":2,"title":"<code>CONSTITUTION.md</code>","text":"<p>Purpose: Define hard invariants: Rules that must NEVER be violated, regardless of the task.</p> <p>AI tools read this first and should refuse tasks that violate these rules.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines","level":3,"title":"Guidelines","text":"<ul> <li>Keep rules minimal and absolute</li> <li>Each rule should be enforceable (can verify compliance)</li> <li>Use checkbox format for clarity</li> <li>Never compromise on these rules</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tasksmd","level":2,"title":"<code>TASKS.md</code>","text":"<p>Purpose: Track current work, planned work, and blockers.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_1","level":3,"title":"Structure","text":"<p>Tasks are organized by Phase: logical groupings that preserve order and enable replay. </p> <p>Tasks stay in their Phase permanently; status is tracked via checkboxes and inline tags.</p> <pre><code># 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</code></pre> <p>Key principles:</p> <ul> <li>Tasks never move between sections: mark as <code>[x]</code> or <code>[-]</code> in place</li> <li>Use <code>#in-progress</code> inline tag to indicate current work</li> <li>Phase headers provide structure and replay order</li> <li>Backlog section for unscheduled work</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#tags","level":3,"title":"Tags","text":"<p>Use inline backtick-wrapped tags for metadata:</p> Tag Values Purpose <code>#priority</code> <code>high</code>, <code>medium</code>, <code>low</code> Task urgency <code>#area</code> <code>core</code>, <code>cli</code>, <code>docs</code>, <code>tests</code> Codebase area <code>#estimate</code> <code>1h</code>, <code>4h</code>, <code>1d</code> Time estimate (optional) <code>#in-progress</code> (none) Currently being worked on <p>Lifecycle tags (for session correlation):</p> Tag Format When to add <code>#added</code> <code>YYYY-MM-DD-HHMMSS</code> Auto-added by <code>ctx task add</code> <code>#started</code> <code>YYYY-MM-DD-HHMMSS</code> When beginning work on the task <p>These timestamps help correlate tasks with session files and track which session started vs completed work.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#status-markers","level":3,"title":"Status Markers","text":"Marker Meaning <code>[ ]</code> Pending <code>[x]</code> Completed <code>[-]</code> Skipped (include reason)","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_1","level":3,"title":"Guidelines","text":"<ul> <li>Never delete tasks; mark as <code>[x]</code> completed or <code>[-]</code> skipped</li> <li>Never move tasks between sections; use inline tags for status</li> <li>Use <code>ctx task archive</code> periodically to move completed tasks to archive</li> <li>Mark current work with <code>#in-progress</code> inline tag</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#decisionsmd","level":2,"title":"<code>DECISIONS.md</code>","text":"<p>Purpose: Record architectural decisions with rationale so they don't get re-debated.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_2","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example","level":3,"title":"Example","text":"<pre><code>## [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</code></pre>","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":"<code>LEARNINGS.md</code>","text":"<p>Purpose: Capture lessons learned, gotchas, and tips that shouldn't be forgotten.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_3","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#example_1","level":3,"title":"Example","text":"<pre><code>## 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#categories","level":3,"title":"Categories","text":"<p>Organize learnings by topic:</p> <ul> <li>Testing</li> <li>Build & Deploy</li> <li>Performance</li> <li>Security</li> <li>Third-Party Libraries</li> <li>Git and Workflow</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#conventionsmd","level":2,"title":"<code>CONVENTIONS.md</code>","text":"<p>Purpose: Document project patterns, naming conventions, and standards.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_4","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_2","level":3,"title":"Guidelines","text":"<ul> <li>Include concrete examples</li> <li>Explain the \"why\" not just the \"what\"</li> <li>Keep patterns minimal: Only document what's non-obvious</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#architecturemd","level":2,"title":"<code>ARCHITECTURE.md</code>","text":"<p>Purpose: Provide system overview and component relationships.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_5","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_3","level":3,"title":"Guidelines","text":"<ul> <li>Keep diagrams simple (Mermaid works well)</li> <li>Focus on boundaries and interfaces</li> <li>Update when major structural changes occur</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#glossarymd","level":2,"title":"<code>GLOSSARY.md</code>","text":"<p>Purpose: Define domain terms, abbreviations, and project vocabulary.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#structure_6","level":3,"title":"Structure","text":"<pre><code># 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</code></pre>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#guidelines_4","level":3,"title":"Guidelines","text":"<ul> <li>Define project-specific meanings</li> <li>Clarify potentially ambiguous terms</li> <li>Include abbreviations used in code or docs</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#agent_playbookmd","level":2,"title":"<code>AGENT_PLAYBOOK.md</code>","text":"<p>Purpose: Explicit instructions for how AI tools should read, apply, and update context.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#key-sections","level":3,"title":"Key Sections","text":"<p>Read Order: Priority order for loading context files</p> <p>When to Update: Events that trigger context updates</p> <p>How to Avoid Hallucinating Memory: Critical rules:</p> <ol> <li>Never assume: If not in files, you don't know it</li> <li>Never invent history: Don't claim \"we discussed\" without evidence</li> <li>Verify before referencing: Search files before citing</li> <li>When uncertain, say so</li> <li>Trust files over intuition</li> </ol> <p>Context Update Commands: Format for automated updates via <code>ctx watch</code>:</p> <pre><code><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</code></pre> <p>See Integrations for full documentation.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#templates","level":2,"title":"<code>templates/</code>","text":"<p>Location: <code>.context/templates/</code>. Status: implementation detail, user-editable.</p> <p>Purpose: Format templates for <code>ctx decision add</code> and <code>ctx learning add</code>. These control the structure of new entries appended to DECISIONS.md and LEARNINGS.md.</p> <p><code>ctx init</code> deploys two starter templates:</p> <ul> <li><code>decision.md</code>: sections Context, Rationale, Consequence</li> <li><code>learning.md</code>: sections Context, Lesson, Application</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing","level":3,"title":"Customizing","text":"<p>Edit the templates directly. Changes take effect immediately on the next <code>ctx add</code> command. For example, to add a \"References\" section to all new decisions, edit <code>.context/templates/decision.md</code>.</p> <p>Templates are committed to git, so customizations are shared with the team.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#steering","level":2,"title":"<code>steering/</code>","text":"<p>Location: <code>.context/steering/</code>. Status: implementation detail, user-editable.</p> <p>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). <code>ctx</code> matches steering files to prompts and syncs them out to each tool's config.</p> <p><code>ctx init</code> scaffolds four foundation files:</p> <ul> <li><code>product.md</code>: who this project serves and why</li> <li><code>tech.md</code>: the technology stack and its constraints</li> <li><code>structure.md</code>: how the code is organized</li> <li><code>workflow.md</code>: how work moves through the system</li> </ul> <p>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 <code>inclusion: always</code> by default so every session picks them up.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#customizing_1","level":3,"title":"Customizing","text":"<p>Edit the files directly. Add your own steering files with <code>ctx steering add</code>, preview the match set with <code>ctx steering preview</code>, and run <code>ctx steering sync</code> to push them into each AI tool's config after changes. Steering files are committed to git, so they're shared with the team.</p> <p>For the design rationale, the full inclusion/priority model, and the end-to-end sync workflow, see the dedicated Steering files page.</p>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#parsing-rules","level":2,"title":"Parsing Rules","text":"<p>All context files follow these conventions:</p> <ol> <li>Headers define structure: <code>#</code> for title, <code>##</code> for sections, <code>###</code> for items</li> <li>Bold keys for fields: <code>**Key**:</code> followed by value</li> <li>Code blocks are literal: Never parse code block content as structure</li> <li>Lists are ordered: Items appear in priority/chronological order</li> <li>Tags are inline: Backtick-wrapped tags like <code>#priority:high</code></li> </ol>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Refactoring with Intent: how persistent context prevents drift during refactoring sessions</li> </ul>","path":["Home","Concepts","Context Files"],"tags":[]},{"location":"home/context-files/#token-efficiency","level":2,"title":"Token Efficiency","text":"<p>Keep context files concise:</p> <ul> <li>Use abbreviations in tags, not prose;</li> <li>Omit obvious words (\"The,\" \"This\");</li> <li>Prefer bullet points over paragraphs;</li> <li>Keep examples minimal but illustrative;</li> <li>Archive old completed items periodically.</li> </ul> <p>Next Up: Prompting Guide →: effective prompts for AI sessions with <code>ctx</code></p>","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":"<ul> <li>Go (version defined in <code>go.mod</code>)</li> <li>Claude Code</li> <li>Git</li> <li>GNU Make</li> <li>Zensical</li> </ul>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#1-fork-or-clone-the-repository","level":3,"title":"1. Fork (or Clone) the Repository","text":"<pre><code># 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</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#2-build-and-install-the-binary","level":3,"title":"2. Build and Install the Binary","text":"<pre><code>make build\nsudo make install\n</code></pre> <p>This compiles the <code>ctx</code> binary and places it in <code>/usr/local/bin/</code>.</p>","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":"<p>The repository ships a Claude Code plugin under <code>internal/assets/claude/</code>. Point Claude Code at your local copy so that skills and hooks reflect your working tree: no reinstall needed after edits:</p> <ol> <li>Launch <code>claude</code>;</li> <li>Type <code>/plugin</code> and press Enter;</li> <li>Select Marketplaces → Add Marketplace</li> <li>Enter the absolute path to the root of your clone, e.g. <code>~/WORKSPACE/ctx</code> (this is where <code>.claude-plugin/marketplace.json</code> lives: it points Claude Code to the actual plugin in <code>internal/assets/claude</code>);</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code>.</li> </ol> <p>Claude Code Caches Plugin Files</p> <p>Even though the marketplace points at a directory on disk, Claude Code caches skills and hooks. After editing files under <code>internal/assets/claude/</code>, clear the cache and restart:</p> <pre><code>make plugin-reload # then restart Claude Code\n</code></pre> <p>See Skill or Hook Changes for details.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#4-verify","level":3,"title":"4. Verify","text":"<pre><code>ctx --version # binary is in PATH\nclaude /plugin list # plugin is installed\n</code></pre> <p>You should see the <code>ctx</code> plugin listed, sourced from your local path.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#maintainer-tooling-ctxctl","level":2,"title":"Maintainer Tooling: <code>ctxctl</code>","text":"<p><code>ctxctl</code> is a maintainer-only binary that houses tooling kept out of the shipped <code>ctx</code> binary. It is a separate Go module at <code>tools/ctxctl/</code>: <code>ctx</code>'s <code>go.mod</code> never requires it, so <code>ctx</code> can never import it, while <code>ctxctl</code> reuses <code>ctx</code>'s <code>internal/</code> packages through the repo-root <code>go.work</code> workspace. End users never receive it, so it is not part of the Development Setup above: skip this section unless you are working on maintainer tooling.</p> <p>Its first inhabitant is the out-of-band audit channel (<code>ctxctl audit list|show|dismiss</code> plus the <code>ctxctl audit-relay</code> hook). This page covers only building and installing the binary. The full workflow (running an auditor, relaying its findings into your working session, dismissing them) is its own runbook: Out-of-Band Audit Channel.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#build-and-install","level":3,"title":"Build and Install","text":"<pre><code>make ctxctl # build into dist/ctxctl\nmake install-ctxctl # install dist/ctxctl to /usr/local/bin/ctxctl\nmake reinstall-ctxctl # build + install in one step (the usual case)\n</code></pre> <p><code>ctxctl</code> installs to <code>/usr/local/bin/</code> alongside <code>ctx</code> (the install falls back to <code>sudo</code> when the directory is not writable). Installing to <code>PATH</code> is deliberate: the repo-local <code>UserPromptSubmit</code> hook invokes <code>ctxctl audit-relay</code> as a <code>PATH</code> binary, and a single install is shared across every clone and worktree, so the repo root stays clean.</p> <p>Run <code>make reinstall-ctxctl</code> once after first cloning, then again whenever you pull or edit anything under <code>tools/ctxctl/</code> or the relocated <code>internal/ctxctl/</code> packages.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#verify","level":3,"title":"Verify","text":"<pre><code>ctxctl --help # command tree\nctxctl audit # list audit reports (run inside a ctx project)\n</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#project-layout","level":2,"title":"Project Layout","text":"<pre><code>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</code></pre>","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? <code>internal/assets/claude/skills/</code> The 39 <code>ctx-*</code> skills that ship with the plugin Yes <code>.claude/skills/</code> Dev-only skills (release, QA, backup, etc.) No <p><code>internal/assets/claude/skills/</code> is the single source of truth for user-facing skills. If you are adding or modifying a <code>ctx-*</code> skill, edit it there.</p> <p><code>.claude/skills/</code> holds skills that only make sense inside this repository (release automation, QA checks, backup scripts). These are never distributed to users.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#dev-only-skills-reference","level":4,"title":"Dev-Only Skills Reference","text":"Skill When to use <code>/_ctx-absorb</code> Merge deltas from a parallel worktree or separate checkout <code>/_ctx-audit</code> Detect code-level drift after YOLO sprints or before releases <code>/_ctx-qa</code> Run QA checks before committing <code>/_ctx-release</code> Run the full release process <code>/_ctx-release-notes</code> Generate release notes for <code>dist/RELEASE_NOTES.md</code> <code>/_ctx-alignment-audit</code> Audit doc claims against agent instructions <code>/_ctx-update-docs</code> Check docs/code consistency after changes <code>/_ctx-command-audit</code> Audit CLI surface after renames, moves, or deletions <p>Six skills previously in this list have been promoted to bundled plugin skills and are now available to all <code>ctx</code> users: <code>/ctx-brainstorm</code>, <code>/ctx-link-check</code>, <code>/ctx-permission-sanitize</code>, <code>/ctx-skill-create</code>, <code>/ctx-spec</code>.</p>","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":"<ol> <li>Create a package under <code>internal/cli/<name>/</code> with <code>doc.go</code>, <code>cmd.go</code>, and <code>run.go</code>;</li> <li>Implement <code>Cmd() *cobra.Command</code> as the entry point;</li> <li>Add <code>Use*</code> and <code>DescKey*</code> constants in <code>internal/config/embed/cmd/<name>.go</code>;</li> <li>Add command descriptions in <code>internal/assets/commands/commands.yaml</code>;</li> <li>Add examples in <code>internal/assets/commands/examples.yaml</code>;</li> <li>Add flag descriptions in <code>internal/assets/commands/flags.yaml</code>;</li> <li>Register the command in <code>internal/bootstrap/group.go</code> (add import + entry in the appropriate group function);</li> <li>Create an output package at <code>internal/write/<name>/</code> for all user-facing output (see Package Taxonomy);</li> <li>Create error constructors at <code>internal/err/<name>/</code> for domain-specific errors;</li> <li>Add tests in the same package (<code><name>_test.go</code>);</li> <li>Add a doc page at <code>docs/cli/<name>.md</code> and update <code>docs/cli/index.md</code>;</li> <li>Add the page to <code>zensical.toml</code> nav.</li> </ol> <p>Pattern to follow: <code>internal/cli/pad/pad.go</code> (parent with subcommands) or <code>internal/cli/drift/</code> (single command).</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#package-taxonomy","level":3,"title":"Package Taxonomy","text":"<p><code>ctx</code> separates concerns into a strict package taxonomy. Knowing where things go prevents code review friction and keeps the AST lint tests happy.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#output-internalwrite","level":4,"title":"Output: <code>internal/write/</code>","text":"<p>Every CLI command's user-facing output lives in its own sub-package under <code>internal/write/<domain>/</code>. Output functions accept <code>*cobra.Command</code> and call <code>cmd.Println(...)</code>, never <code>fmt.Print*</code> directly. All text strings are loaded from YAML via <code>desc.Text(text.DescKey*)</code>, never inline.</p> <pre><code>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</code></pre> <p>Exception: <code>write/rc/</code> writes to <code>os.Stderr</code> because rc loads before cobra is initialized.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#errors-internalerr","level":4,"title":"Errors: <code>internal/err/</code>","text":"<p>Domain-specific error constructors live under <code>internal/err/<domain>/</code>. Each package mirrors the write structure. Constructor functions return <code>error</code> and load messages from YAML via <code>desc.Text(text.DescKey*)</code>.</p> <p>Identity sentinels (matched at the call site with <code>errors.Is</code>) are declared as <code>entity.Sentinel</code> consts:</p> <pre><code>const ErrMissingFoo = entity.Sentinel(text.DescKeyErrPkgMissingFoo)\n</code></pre> <p><code>entity.Sentinel</code> is a typed string whose <code>Error()</code> resolves the key through <code>desc.Text</code> at call time, so the user-facing text stays in <code>commands/text/errors.yaml</code> and the sentinel value itself remains pure identity. Never declare sentinels as <code>var ErrX = errors.New(...)</code> with a hardcoded English string — that bypasses localization and materializes the string before the embedded YAML lookup is populated.</p> <p>When a sentinel needs to carry fields (a path, a name), use a typed struct in <code>internal/err/<domain>/</code> instead. See <code>internal/err/context.NotFoundError</code> for the canonical pattern with <code>Error()</code>, <code>Is(target error) bool</code>, and an <code>errors.As</code> consumer contract.</p> <pre><code>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</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#config-constants-internalconfig","level":4,"title":"Config Constants: <code>internal/config/</code>","text":"<p>Pure-constant leaf packages with zero internal dependencies (stdlib only). Over 60 sub-packages, organized by domain. See <code>internal/config/README.md</code> for the full decision tree.</p> What you're adding Where it goes File names, extensions, paths <code>config/file/</code>, <code>config/dir/</code> Regex patterns <code>config/regex/</code> CLI flag names (<code>--flag-name</code>) <code>config/flag/flag.go</code> Flag description YAML keys <code>config/embed/flag/<cmd>.go</code> Command Use/DescKey strings <code>config/embed/cmd/<cmd>.go</code> User-facing text YAML keys <code>config/embed/text/<domain>.go</code> Time durations, thresholds <code>config/<domain>/</code>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#the-assets-pipeline","level":4,"title":"The Assets Pipeline","text":"<p>User-facing text flows through a three-level chain:</p> <ol> <li>Go constant (<code>config/embed/text/</code>) defines a string key: <code>DescKeyWriteAddedTo = \"write.added-to\"</code></li> <li>Call site resolves it: <code>desc.Text(text.DescKeyWriteAddedTo)</code></li> <li>YAML (<code>internal/assets/commands/text/write.yaml</code>) holds the actual text: <code>write.added-to: { short: \"Added to %s\" }</code></li> </ol> <p>The same pattern applies to command descriptions (<code>commands.yaml</code>), flag descriptions (<code>flags.yaml</code>), and examples (<code>examples.yaml</code>). The <code>TestDescKeyYAMLLinkage</code> test verifies every constant resolves to a non-empty YAML value.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-new-session-parser","level":3,"title":"Adding a New Session Parser","text":"<p>The journal system uses a <code>SessionParser</code> interface. To add support for a new AI tool (e.g. Aider, Cursor):</p> <ol> <li>Create <code>internal/journal/parser/<tool>.go</code>;</li> <li>Implement parsing logic that returns <code>[]*Session</code>;</li> <li>Register the parser in <code>FindSessions()</code> / <code>FindSessionsForCWD()</code>;</li> <li>Use <code>config.Tool*</code> constants for the tool identifier;</li> <li>Add test fixtures and parser tests.</li> </ol> <p>Pattern to follow: the Claude Code JSONL parser in <code>internal/journal/parser/</code>.</p> <p>Multilingual Session Headers</p> <p>The Markdown parser recognizes session header prefixes configured via <code>session_prefixes</code> in <code>.ctxrc</code> (default: <code>Session:</code>). To support a new language, users add a prefix to their <code>.ctxrc</code> - no code change needed. New parser implementations can use <code>rc.SessionPrefixes()</code> if they also need prefix-based header detection.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#adding-a-bundled-skill","level":3,"title":"Adding a Bundled Skill","text":"<ol> <li>Create <code>internal/assets/claude/skills/<skill-name>/SKILL.md</code>;</li> <li>Follow the skill format: trigger, negative triggers, steps, quality gate;</li> <li>Run <code>make plugin-reload</code> and restart Claude Code to test;</li> <li>Add a <code>Skill</code> entry to <code>.claude-plugin/plugin.json</code> if user-invocable;</li> <li>Document in <code>docs/reference/skills.md</code>.</li> </ol> <p>Pattern to follow: any skill in <code>internal/assets/claude/skills/ctx-status/</code>.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#test-expectations","level":3,"title":"Test Expectations","text":"<ul> <li>Unit tests: colocated with source (<code>foo.go</code> → <code>foo_test.go</code>);</li> <li>Test helpers: use <code>t.Helper()</code> so failures point to callers;</li> <li>HOME isolation: use <code>t.TempDir()</code> + <code>t.Setenv(\"HOME\", ...)</code> for tests that touch <code>~/.claude/</code> or <code>~/.ctx/</code>;</li> <li>rc.Reset(): call after <code>os.Chdir</code> in tests that change working directory (rc caches on first access);</li> <li>No network: all tests run offline, use fixtures.</li> </ul> <p>Run <code>make test</code> before submitting. Target: no failures, no skips.</p>","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":"<p>After modifying Go source files, rebuild and reinstall:</p> <pre><code>make build && sudo make install\n</code></pre> <p>The <code>ctx</code> binary is statically compiled. There is no hot reload. You must rebuild for Go changes to take effect.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#skill-or-hook-changes","level":3,"title":"Skill or Hook Changes","text":"<p>Edit files under <code>internal/assets/claude/skills/</code> or <code>internal/assets/claude/hooks/</code>.</p> <p>Claude Code caches plugin files, so edits aren't picked up automatically.</p> <p>Clear the cache and restart:</p> <pre><code>make plugin-reload # nukes ~/.claude/plugins/cache/activememory-ctx/\n# then restart Claude Code\n</code></pre> <p>The plugin will be re-installed from your local marketplace on startup. No version bump is needed during development.</p> <p>Version Bumps Are for Releases, Not Iteration</p> <p>Only bump <code>VERSION</code>, <code>plugin.json</code>, and <code>marketplace.json</code> when cutting a release. During development, <code>make plugin-reload</code> is all you need.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"<p>The repo ships two <code>.ctxrc</code> source profiles. The working copy (<code>.ctxrc</code>) is gitignored and swapped between them:</p> File Purpose <code>.ctxrc.base</code> Golden baseline: all defaults, no logging <code>.ctxrc.dev</code> Dev profile: notify events enabled, verbose logging <code>.ctxrc</code> Working copy (gitignored: copied from one of the above) <p>Use <code>ctx</code> commands to switch:</p> <pre><code>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</code></pre> <p>After cloning, run <code>ctx config switch dev</code> to get started with full logging.</p> <p>See Configuration for the full <code>.ctxrc</code> option reference.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#backups","level":3,"title":"Backups","text":"<p><code>ctx</code> does not ship a backup command. File-level backup is an OS / infrastructure concern; <code>ctx hub</code> 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.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-tests","level":3,"title":"Running Tests","text":"<pre><code>make test # fast: all tests\nmake audit # full: fmt + vet + lint + drift + docs + test\nmake smoke # build + run basic commands end-to-end\n</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#running-the-docs-site-locally","level":3,"title":"Running the Docs Site Locally","text":"<pre><code>make site-setup # one-time: install zensical via pipx\nmake site-serve # serve at localhost\n</code></pre>","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":"<ol> <li>Check existing issues to avoid duplicating effort;</li> <li>For large changes, open an issue first to discuss the approach;</li> <li>Read the specs in <code>specs/</code> for design context.</li> </ol>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#pull-request-process","level":3,"title":"Pull Request Process","text":"<p>Respect the maintainers' time and energy: Keep your pull requests isolated and strive to minimze code changes.</p> <p>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.</p> <ol> <li>Create a feature branch: <code>git checkout -b feature/my-feature</code>;</li> <li>Make your changes;</li> <li>Run <code>make audit</code> to catch issues early;</li> <li>Commit with a clear message;</li> <li>Push and open a pull request.</li> </ol> <p>Audit Your Code Before Submitting</p> <p>Run <code>make audit</code> before submitting:</p> <p><code>make audit</code> covers formatting, vetting, linting, drift checks, doc consistency, and tests in one pass.</p>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#commit-messages","level":3,"title":"Commit Messages","text":"<p>Following conventional commits is recommended but not required:</p> <p>Types: <code>feat</code>, <code>fix</code>, <code>docs</code>, <code>test</code>, <code>refactor</code>, <code>chore</code></p> <p>Examples:</p> <ul> <li><code>feat(cli): add ctx export command</code></li> <li><code>fix(drift): handle missing files gracefully</code></li> <li><code>docs: update installation instructions</code></li> </ul>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-style","level":3,"title":"Code Style","text":"<ul> <li>Follow Go conventions (<code>gofmt</code>, <code>go vet</code>);</li> <li>Keep functions focused and small;</li> <li>Add tests for new functionality;</li> <li>Handle errors explicitly; use descriptive names (<code>readErr</code>, <code>writeErr</code>) not repeated <code>err</code>;</li> <li>No magic strings: all repeated literals go in <code>internal/config/</code>;</li> <li>Output goes through <code>internal/write/</code> packages, not <code>fmt.Print*</code>;</li> <li>Errors go through <code>internal/err/</code> constructors, not inline <code>fmt.Errorf</code>;</li> <li>See Package Taxonomy and <code>.context/CONVENTIONS.md</code> for the full reference.</li> </ul>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#code-of-conduct","level":2,"title":"Code of Conduct","text":"<p>A clear context requires respectful collaboration.</p> <p><code>ctx</code> follows the Contributor Covenant.</p>","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":"<p>By contributing, you agree to the Developer Certificate of Origin.</p> <p>All commits must be signed off:</p> <pre><code>git commit -s -m \"feat: add new feature\"\n</code></pre>","path":["Home","Community","Contributing"],"tags":[]},{"location":"home/contributing/#license","level":3,"title":"License","text":"<p>Contributions are licensed under the Apache 2.0 License.</p>","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":"<p>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 <code>cat</code>, diff it with <code>git diff</code>, and review it in a PR.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#does-ctx-work-offline","level":2,"title":"Does <code>ctx</code> Work Offline?","text":"<p>Yes. <code>ctx</code> 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.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#what-gets-committed-to-git","level":2,"title":"What Gets Committed to Git?","text":"<p>The <code>.context/</code> directory: yes, commit it. That's the whole point. Team members and AI agents read the same context files.</p> <p>What not to commit:</p> <ul> <li><code>.ctx.key</code>: your encryption key. Stored at <code>~/.ctx/.ctx.key</code>, never in the repo. <code>ctx init</code> handles this automatically.</li> <li><code>journal/</code> and <code>logs/</code>: generated data, potentially large. <code>ctx init</code> adds these to <code>.gitignore</code>.</li> <li><code>scratchpad.enc</code>: your choice. It's encrypted, so it's safe to commit if you want shared scratchpad state. See Scratchpad for details.</li> </ul>","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":"<p>The default is 8000 tokens, which works well for most projects. Configure it via <code>.ctxrc</code> or the <code>CTX_TOKEN_BUDGET</code> environment variable:</p> <pre><code># 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</code></pre> <p>Higher budgets include more context but cost more tokens per request. Lower budgets force sharper prioritization: <code>ctx</code> drops lower-priority content first, so CONSTITUTION and TASKS always make the cut.</p> <p>See Configuration for all available settings.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#why-not-a-database","level":2,"title":"Why Not a Database?","text":"<p>Files are inspectable, diffable, and reviewable in pull requests. You can <code>grep</code> them, <code>cat</code> them, pipe them through <code>jq</code> or <code>awk</code>. They work with every version control system and every text editor.</p> <p>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.</p>","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":"<p>Yes. <code>ctx agent</code> outputs a context packet that any AI tool can consume: paste it into ChatGPT, Cursor, Copilot, Aider, or anything else that accepts text input.</p> <p>Claude Code gets first-class integration via the <code>ctx</code> plugin (hooks, skills, automatic context loading). VS Code Copilot Chat has a dedicated <code>ctx</code> extension. Other tools integrate via generated instruction files or manual pasting.</p> <p>See Integrations for tool-specific setup, including the multi-tool recipe.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#can-i-use-ctx-on-an-existing-project","level":2,"title":"Can I Use <code>ctx</code> on an Existing Project?","text":"<p>Yes. Run <code>ctx init</code> in any repo and it creates <code>.context/</code> 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.</p> <p>See Getting Started for the full setup flow, or Joining a <code>ctx</code> Project if someone else already initialized it.</p>","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":"<p>Token budgeting handles this automatically. <code>ctx agent</code> prioritizes content by file priority (CONSTITUTION first, GLOSSARY last) and trims lower-priority entries when the budget is tight.</p> <p>For manual maintenance, <code>ctx compact</code> archives completed tasks and old entries, keeping active context lean. You can also run <code>ctx task archive</code> to move completed tasks out of TASKS.md.</p> <p>The goal is to keep context files focused on current state. Historical entries belong in git history or the archive.</p>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/faq/#is-context-meant-to-be-shared","level":2,"title":"Is <code>.context/</code> Meant to Be Shared?","text":"<p>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.</p> <p>The only per-user state is the encryption key (<code>~/.ctx/.ctx.key</code>) and the optional scratchpad. Everything else is team-shared by design.</p> <p>Related:</p> <ul> <li>Getting Started - installation and first setup</li> <li>Configuration - <code>.ctxrc</code>, environment variables, and defaults</li> <li>Context Files - what each file does and how to use it</li> </ul>","path":["Home","Introduction","FAQ"],"tags":[]},{"location":"home/first-session/","level":1,"title":"Your First Session","text":"<p>Here's what a complete first session looks like, from initialization to the moment your AI cites your project context back to you.</p>","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":"<p>Run <code>ctx init</code> in your project root:</p> <pre><code>cd your-project\nctx init\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> <p>This created your <code>.context/</code> directory with template files. </p> <p>For Claude Code, install the <code>ctx</code> plugin to get automatic hooks and skills.</p>","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#step-2-populate-your-context","level":2,"title":"Step 2: Populate Your Context","text":"<p>Add a task and a decision: These are the entries your AI will remember:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<pre><code>ctx status\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> <p>Notice the token estimate: This is how much context your AI will load.</p> <p>The <code>○</code> next to <code>LEARNINGS.md</code> means it's still empty; it will fill in as you capture lessons during development.</p>","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":"<p>With Claude Code (and the <code>ctx</code> plugin), start every session with:</p> <pre><code>/ctx-remember\n</code></pre> <p>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.</p> <p>Steering Files Fire Automatically</p> <p>If you edited the four foundation files scaffolded by <code>ctx init</code> (<code>.context/steering/product.md</code>, <code>tech.md</code>, <code>structure.md</code>, <code>workflow.md</code>), their <code>inclusion: always</code> rules are prepended to every tool call via the plugin's <code>PreToolUse</code> hook, with no <code>/ctx-remember</code> 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.</p> <p>Using VS Code?</p> <p>With VS Code Copilot Chat (and the <code>ctx</code> extension), type <code>@ctx /agent</code> in chat to load your context packet, or <code>@ctx /status</code> to check your project context. Run <code>ctx setup copilot --write</code> once to generate <code>.github/copilot-instructions.md</code> for automatic context loading.</p> <p>If you are not using Claude Code, generate a context packet for your AI tool:</p> <pre><code>ctx agent --budget 8000\n</code></pre> <p>Sample output:</p> <pre><code># 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</code></pre> <p>Paste this output into your AI tool's system prompt or conversation start.</p>","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":"<p>Ask your AI: \"What are our current tasks?\"</p> <p>A working setup produces a response like:</p> <pre><code>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</code></pre> <p>That's the success moment:</p> <p>The AI is citing your exact context entries from Step 2, not hallucinating or asking you to re-explain.</p>","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-gets-created","level":2,"title":"What Gets Created","text":"<pre><code>.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</code></pre> <p>Claude Code integration (hooks + skills) is provided by the <code>ctx</code> plugin: See Integrations/Claude Code.</p> <p>VS Code Copilot Chat integration is provided by the <code>ctx</code> extension: See Integrations/VS Code.</p> <p>See Context Files for detailed documentation of each file.</p>","path":["Home","Get Started","Your First Session"],"tags":[]},{"location":"home/first-session/#what-to-gitignore","level":2,"title":"What to <code>.gitignore</code>","text":"<p>Rule of Thumb</p> <ul> <li>If it's knowledge (decisions, tasks, learnings, conventions), commit it.</li> <li>If it's generated output, raw session data, or a secret, <code>.gitignore</code> it.</li> </ul> <p>Commit your <code>.context/</code> knowledge files: that's the whole point.</p> <p>You should <code>.gitignore</code> the generated and sensitive paths:</p> <pre><code># 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</code></pre> <p><code>ctx init</code> Patches Your .Gitignore for You</p> <p><code>ctx init</code> automatically adds these entries to your <code>.gitignore</code>.</p> <p>Review the additions with <code>cat .gitignore</code> after init.</p> <p>See also:</p> <ul> <li>Security Considerations</li> <li>Scratchpad Encryption</li> <li>Session Journal</li> </ul> <p>Next Up: Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history.</p>","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":"<p><code>ctx</code> does not require <code>git</code>, but using version control with your <code>.context/</code> directory is strongly recommended:</p> <p>AI sessions occasionally modify or overwrite context files inadvertently. With <code>git</code>, the AI can check history and restore lost content: Without it, the data is gone.</p> <p>Also, several <code>ctx</code> features (journal changelog, blog generation) also use <code>git</code> history directly.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#installation","level":2,"title":"Installation","text":"<p>Every setup starts with the <code>ctx</code> binary: the CLI tool itself.</p> <p>If you use Claude Code, you also install the <code>ctx</code> plugin, which adds hooks (context autoloading, persistence nudges) and 25+ <code>/ctx-*</code> skills. For other AI tools, <code>ctx</code> integrates via generated instruction files or manual context pasting: see Integrations for tool-specific setup.</p> <p>Pick one of the options below to install the binary. Claude Code users should also follow the plugin steps included in each option.</p>","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":"<p>Requires Go (version defined in <code>go.mod</code>) and Claude Code.</p> <pre><code>git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\nmake build\nsudo make install\n</code></pre> <p>Install the Claude Code plugin from your local clone:</p> <ol> <li>Launch <code>claude</code>;</li> <li>Type <code>/plugin</code> and press Enter;</li> <li>Select Marketplaces → Add Marketplace</li> <li>Enter the path to the root of your clone, e.g. <code>~/WORKSPACE/ctx</code> (this is where <code>.claude-plugin/marketplace.json</code> lives: It points Claude Code to the actual plugin in <code>internal/assets/claude</code>)</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code></li> </ol> <p>This points Claude Code at the plugin source on disk. Changes you make to hooks or skills take effect immediately: No reinstall is needed.</p> <p>Local Installs Need Manual Enablement</p> <p>Unlike marketplace installs, local plugin installs are not auto-enabled globally. The plugin will only work in projects that explicitly enable it. Run <code>ctx init</code> in each project (it auto-enables the plugin), or add the entry to <code>~/.claude/settings.json</code> manually:</p> <pre><code>{ \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n</code></pre> <p>Verify:</p> <pre><code>ctx --version # binary is in PATH\nclaude /plugin list # plugin is installed\n</code></pre> <p>Use the Source, Luke</p> <p>Building from source gives you the latest features and bug fixes.</p> <p>Since <code>ctx</code> is predominantly a developer tool, this is the recommended approach: </p> <p>You get the freshest code, can inspect what you are installing, and the plugin stays in sync with the binary.</p>","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":"<p>Pre-built binaries are available from the releases page.</p> Linux (x86_64)Linux (ARM64)macOS (Apple Silicon)macOS (Intel)Windows <pre><code>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</code></pre> <pre><code>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</code></pre> <pre><code>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</code></pre> <pre><code>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</code></pre> <p>Download <code>ctx-0.8.1-windows-amd64.exe</code> from the releases page and add it to your <code>PATH</code>.</p> <p>Claude Code users: install the plugin from the marketplace:</p> <ol> <li>Launch <code>claude</code>;</li> <li>Type <code>/plugin</code> and press Enter;</li> <li>Select Marketplaces → Add Marketplace;</li> <li>Enter <code>ActiveMemory/ctx</code>;</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code>.</li> </ol> <p>Other tool users: see Integrations for tool-specific setup (Cursor, Copilot, Aider, Windsurf, etc.).</p> <p>Verify the Plugin Is Enabled</p> <p>After installing, confirm the plugin is enabled globally. Check <code>~/.claude/settings.json</code> for an <code>enabledPlugins</code> entry. If missing, run <code>ctx init</code> in your project (it auto-enables the plugin), or add it manually:</p> <pre><code>{ \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n</code></pre> <p>Verify:</p> <pre><code>ctx --version # binary is in PATH\nclaude /plugin list # plugin is installed (Claude Code only)\n</code></pre>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#verifying-checksums","level":4,"title":"Verifying Checksums","text":"<p>Each binary has a corresponding <code>.sha256</code> checksum file. To verify your download:</p> <pre><code># 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</code></pre> <p>On macOS, use <code>shasum -a 256 -c</code> instead of <code>sha256sum -c</code>.</p> Plugin Details <p>After installation (either option) you get:</p> <ul> <li>Context autoloading: <code>ctx agent</code> runs on every tool use (with cooldown)</li> <li>Persistence nudges: reminders to capture learnings and decisions</li> <li>Post-commit hooks: nudge context capture after <code>git commit</code></li> <li>Context size monitoring: alerts as sessions grow large</li> <li>Project skills: <code>/ctx-status</code>, <code>/ctx-task-add</code>, <code>/ctx-history</code>, and more</li> </ul> <p>See Integrations for the full hook and skill reference.</p>","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":"<pre><code>cd your-project\nctx init\n</code></pre> <p>This creates a <code>.context/</code> directory with template files and an encryption key at <code>~/.ctx/</code> for the encrypted scratchpad. For Claude Code, install the <code>ctx</code> plugin for automatic hooks and skills.</p> <p><code>ctx init</code> also scaffolds four foundation steering files in <code>.context/steering/</code>: <code>product.md</code>, <code>tech.md</code>, <code>structure.md</code>, <code>workflow.md</code>. They are placeholders until you customize them (see the next step); skipping that step has consequences, so it is broken out as its own numbered beat rather than buried here.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#2-customize-your-steering-files","level":3,"title":"2. Customize Your Steering Files","text":"<p>Steering files are behavioral rules prepended to every AI prompt: the layer that tells your AI how to act on this specific project. They are distinct from decisions (what was chosen) and conventions (how the codebase is written); see <code>ctx</code> for Steering Files for the full model.</p> <p><code>ctx init</code> scaffolded four foundation files; open each and fill it in:</p> File What to fill in <code>product.md</code> What the project is, who uses it, what's out of scope <code>tech.md</code> Languages, frameworks, runtime, hard constraints <code>structure.md</code> Directory layout, where new files go, naming rules <code>workflow.md</code> Branch strategy, commit conventions, pre-commit checks <p>Each scaffolded file ships with a tombstone marker line (<code><!-- remove this after you edit the steering file !--></code>). As long as the marker is present, the file is silently skipped on every load path: the agent context packet, MCP <code>ctx_steering_get</code>, and native-tool sync (Cursor / Cline / Kiro). The skip is deliberate: injecting unfilled placeholders into AI prompts is worse than no steering at all, because the AI tries to follow \"Describe the product...\" as if it were a rule.</p> <p>Replace each file's body with real content, then delete the tombstone line. When the line is gone, the file becomes active on the next AI tool call.</p> <p>Don't want steering at all? Pass <code>--no-steering-init</code> to <code>ctx init</code> to skip the scaffold entirely. Existing edits are never clobbered by re-running <code>ctx init</code>.</p> <p>Inclusion modes (<code>always</code> / <code>auto</code> / <code>manual</code>), priority, and tool scoping are covered in Writing Steering Files and <code>ctx steering</code>.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#3-check-status","level":3,"title":"3. Check Status","text":"<pre><code>ctx status\n</code></pre> <p>Shows context summary: files present, token estimate, and recent activity.</p>","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":"<p>With Claude Code (and the <code>ctx</code> plugin installed), context loads automatically via hooks.</p> <p>With VS Code Copilot Chat, install the <code>ctx</code> extension and use <code>@ctx /status</code>, <code>@ctx /agent</code>, and other slash commands directly in chat. Run <code>ctx setup copilot --write</code> to generate <code>.github/copilot-instructions.md</code> for automatic context loading.</p> <p>For other tools, paste the output of:</p> <pre><code>ctx agent --budget 8000\n</code></pre>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#5-set-up-for-your-ai-tool","level":3,"title":"5. Set Up for Your AI Tool","text":"<p>If you use an MCP-compatible tool, generate the integration config with <code>ctx setup</code>:</p> KiroCursorCline <pre><code>ctx setup kiro --write\n# Creates .kiro/settings/mcp.json and syncs steering files\n</code></pre> <pre><code>ctx setup cursor --write\n# Creates .cursor/mcp.json and syncs steering files\n</code></pre> <pre><code>ctx setup cline --write\n# Creates .vscode/mcp.json and syncs steering files\n</code></pre> <p>This registers the <code>ctx</code> MCP server and syncs any steering files into the tool's native format. Re-run after adding or changing steering files.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#6-verify-it-works","level":3,"title":"6. Verify It Works","text":"<p>Ask your AI: \"Do you remember?\"</p> <p>It should cite specific context: current tasks, recent decisions, or previous session topics.</p>","path":["Home","Get Started","Getting Started"],"tags":[]},{"location":"home/getting-started/#7-set-up-companion-tools-highly-recommended","level":3,"title":"7. Set Up Companion Tools (Highly Recommended)","text":"<p><code>ctx</code> works on its own, but two MCP capabilities unlock significantly better agent behavior. ctx names canonical implementations below as its tested defaults; if your toolchain provides the same capabilities through different MCP servers (Firecrawl / Exa / Tavily for web search; sourcegraph-cody for the code graph), use those instead. The investment is small and the benefits compound over sessions:</p> <ul> <li> <p>Web search with citations — canonical: Gemini Search. Skills like <code>/ctx-code-review</code> and <code>/ctx-explain</code> use it for up-to-date documentation lookups instead of relying on training data.</p> </li> <li> <p>Code knowledge graph — canonical: GitNexus. Provides symbol resolution, blast radius analysis, and domain clustering. Skills like <code>/ctx-refactor</code> and <code>/ctx-code-review</code> use it for impact analysis and dependency awareness.</p> </li> </ul> <pre><code># Index your project for GitNexus (run once, then after major changes)\ngitnexus analyze\n</code></pre> <p>(For non-GitNexus code-intelligence MCPs, apply that tool's own indexing step instead.)</p> <p>Both capabilities are optional: if no compatible MCP is connected, skills degrade gracefully to built-in capabilities. See Companion Tools for setup details and verification.</p> <p>Next Up:</p> <ul> <li>Your First Session →: a step-by-step walkthrough from <code>ctx init</code> to verified recall</li> <li>Common Workflows →: day-to-day commands for tracking context, checking health, and browsing history</li> </ul>","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":"<p><code>ctx</code> projects are normally independent: each project has its own <code>.context/</code> 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.</p> <p>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 <code>ctx</code> Hub is the feature that makes those specific entries travel, without replicating everything else.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#what-the-hub-actually-is","level":2,"title":"What the Hub Actually Is","text":"<p>In one paragraph: the <code>ctx</code> Hub is a fan-out channel for four specific kinds of structured entries: <code>decision</code>, <code>learning</code>, <code>convention</code>, and <code>task</code>. You publish an entry with <code>ctx add --share</code> in one project, and it appears in <code>.context/hub/</code> for every other project subscribed to that type. When you run <code>ctx agent --include-hub</code>, those shared entries become part of your next agent context packet.</p> <p>That is the entire feature. The Hub does not:</p> <ul> <li>Share your session journal (<code>.context/journal/</code>). That stays local to each project.</li> <li>Share your scratchpad (<code>.context/pad</code>). Encrypted notes never leave the machine that created them.</li> <li>Share your <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, or <code>CONVENTIONS.md</code> wholesale. Only entries you explicitly <code>--share</code> cross the boundary.</li> <li>Provide user identity or attribution. The Hub identifies projects, not people.</li> </ul> <p>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.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#who-its-for","level":2,"title":"Who It's For","text":"<p>Two shapes, same mechanics, different trust models.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"<p>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.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#small-trusted-team","level":3,"title":"Small Trusted Team","text":"<p>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.</p> <p>The Hub is not a multi-tenant public service. It assumes everyone holding a client token is friendly. Don't stand up <code>hub.example.com</code> for untrusted participants.</p>","path":["Home","Concepts","Hub"],"tags":[]},{"location":"home/hub/#going-further","level":2,"title":"Going Further","text":"<ul> <li>First-time setup: Hub: Getting Started, a five-minute walkthrough on localhost.</li> <li>Mental model and user stories: Hub Overview, what flows, what doesn't, and when not to use it.</li> <li>Team / LAN deployment: Multi-machine setup.</li> <li>Redundancy: HA cluster.</li> <li>Operating a Hub: Hub Operations and Hub Failure Modes.</li> <li>Security posture: Hub Security Model.</li> <li>Command reference: <code>ctx serve</code>, <code>ctx connection</code>, <code>ctx hub</code>.</li> </ul>","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":"<p><code>ctx</code> shines when context matters more than code.</p> <p>If any of these sound like your project, it's worth trying:</p> <ul> <li>Multi-session AI work: You use AI across many sessions on the same codebase, and re-explaining is slowing you down.</li> <li>Architectural decisions that matter: Your project has non-obvious choices (database, auth strategy, API design) that the AI keeps second-guessing.</li> <li>\"Why\" matters as much as \"what\": you need the AI to understand rationale, not just current code</li> <li>Team handoffs: Multiple people (or multiple AI tools) work on the same project and need shared context.</li> <li>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.</li> <li>Long-lived projects: Anything you'll work on for weeks or months, where accumulated knowledge has compounding value.</li> </ul>","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":"<p><code>ctx</code> adds overhead that isn't worth it for every project. Be honest about when to skip it:</p> <ul> <li>One-off scripts: If the project is a single file you'll finish today, there's nothing to remember.</li> <li>RAG-only workflows: If retrieval from an external knowledge base already gives the agent everything it needs for each session, adding <code>ctx</code> may be unnecessary. RAG retrieves information; <code>ctx</code> defines the project's working memory: They are complementary.</li> <li>No AI involvement: <code>ctx</code> is designed for human-AI workflows; without an AI consumer, the files are just documentation.</li> <li>Enterprise-managed context platforms: If your organization provides centralized context services, <code>ctx</code> may duplicate that layer.</li> </ul> <p>For a deeper technical comparison with RAG, prompt management tools, and agent frameworks, see <code>ctx</code> and Similar Tools.</p>","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":"<p>This is <code>ctx</code>'s sweet spot. </p> <p>You get the most value here: one person, one project, decisions, and learnings accumulating over time. Setup takes 5 minutes and the <code>.context/</code> directory directory stays small, and every session gets faster.</p>","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":"<p>Works well. </p> <p>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 <code>.context/</code> files are rare and easy to resolve (they are just Markdown).</p>","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":"<p><code>ctx</code> operates per repository.</p> <p>Each repo has its own <code>.context/</code> directory with its own decisions, tasks, and learnings. This matches the way code, ownership, and history already work in <code>git</code>.</p> <p>There is no built-in cross-repo context layer.</p> <p>For organizations that need centralized, organization-wide knowledge, <code>ctx</code> complements a platform solution by providing durable, project-local working memory for AI sessions.</p>","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/is-ctx-right/#5-minute-trial","level":2,"title":"5-Minute Trial","text":"<p>Zero commitment. Try it, and delete <code>.context/</code> if it's not for you.</p> <p>Using Claude Code?</p> <p>Install the <code>ctx</code> plugin from the Marketplace for Claude-native hooks, skills, and automatic context loading:</p> <ol> <li>Type <code>/plugin</code> and press Enter</li> <li>Select Marketplaces → Add Marketplace</li> <li>Enter <code>ActiveMemory/ctx</code></li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code></li> </ol> <p>You'll still need the <code>ctx</code> binary for the CLI: See Getting Started for install options.</p> <pre><code># 1. Initialize\ncd your-project\nctx init\n\n# 2. 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# 3. Check what the AI will see\nctx status\n\n# 4. Start an AI session and ask: \"Do you remember?\"\n</code></pre> <p>If the AI cites your decision back to you, it's working.</p> <p>Want to remove it later? One command:</p> <pre><code>rm -rf .context/\n</code></pre> <p>No dependencies to uninstall. No configuration to revert. Just files.</p> <p>Ready to try it out?</p> <ul> <li>Join the Community→: Open Source is better together.</li> <li>Getting Started →: Full installation and setup.</li> <li><code>ctx</code> and Similar Tools →: Detailed comparison with other approaches.</li> </ul>","path":["Home","Introduction","Is It Right for Me?"],"tags":[]},{"location":"home/joining-a-project/","level":1,"title":"Joining a Project","text":"<p>You've joined a team or inherited a project, and there's a <code>.context/</code> directory in the repo. Good news: someone already set up persistent context. This page gets you oriented fast.</p>","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":"<p>The files in <code>.context/</code> have a deliberate priority order. Read them top-down:</p> <ol> <li>CONSTITUTION.md: Hard rules. Read this before you touch anything. These are inviolable constraints the team has agreed on.</li> <li>TASKS.md: Current and planned work. Shows what's in progress, what's pending, and what's blocked.</li> <li>CONVENTIONS.md: How the team writes code. Naming patterns, file organization, preferred idioms.</li> <li>ARCHITECTURE.md: System overview. Components, boundaries, data flow.</li> <li>DECISIONS.md: Why things are the way they are. Saves you from re-proposing something the team already evaluated and rejected.</li> <li>LEARNINGS.md: Gotchas, tips, and hard-won lessons. The stuff that doesn't fit anywhere else but will save you hours.</li> </ol> <p>See Context Files for detailed documentation of each file's structure and purpose.</p>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#checking-context-health","level":2,"title":"Checking Context Health","text":"<p>Before you start working, check whether the context is current:</p> <pre><code>ctx status\n</code></pre> <p>This shows file counts, token estimates, and recent activity. If files haven't been touched in weeks, the context may be stale.</p> <pre><code>ctx drift\n</code></pre> <p>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.</p> <p>If things are stale, mention it to the team. Don't silently fix it yourself on day one.</p>","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":"<p>Generate a context packet to prime your AI:</p> <pre><code>ctx agent --budget 8000\n</code></pre> <p>This outputs a token-budgeted summary of the project context, ordered by priority. With Claude Code and the <code>ctx</code> plugin, context loads automatically via hooks. You can also use the <code>/ctx-remember</code> skill to get a structured readback of what the AI knows.</p> <p>The readback is your verification step: if the AI can cite specific tasks and decisions, the context is working.</p>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#adding-context","level":2,"title":"Adding Context","text":"<p>As you work, you'll discover things worth recording. Use the CLI:</p> <pre><code># 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</code></pre> <p>You can also just tell the AI: \"Record this as a learning\" or \"Add this decision to context.\" With the <code>ctx</code> plugin, context-update commands handle the file writes.</p> <p>See the Knowledge Capture recipe for the full workflow.</p>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#session-etiquette","level":2,"title":"Session Etiquette","text":"<p>A few norms for working in a ctx-managed project:</p> <ul> <li>Respect existing conventions. If <code>CONVENTIONS.md</code> says \"use <code>filepath.Join</code>,\" use <code>filepath.Join</code>. If you disagree, propose a change, don't silently diverge.</li> <li>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.</li> <li>Mark tasks done when complete. Check the box (<code>[x]</code>) in place. Don't move tasks between sections or delete them.</li> <li>Add context as you go. Decisions, learnings, and conventions you discover are valuable to the next person (or the next session).</li> </ul>","path":["Home","Working with AI","Joining a Project"],"tags":[]},{"location":"home/joining-a-project/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"<p>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.</p> <p>Deleting tasks. Never delete a task from TASKS.md. Mark it <code>[x]</code> (done) or <code>[-]</code> (skipped with a reason). The history matters for session replay and audit.</p> <p>Bypassing hooks. If the project uses <code>ctx</code> 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.</p> <p>Over-contributing on day one. Read first, then contribute. Adding a dozen learnings before you understand the project's norms creates noise, not signal.</p> <p>Related:</p> <ul> <li>Getting Started: installation and setup from scratch</li> <li>Context Files: detailed file reference</li> <li>Knowledge Capture: recording decisions, learnings, and conventions</li> <li>Session Lifecycle: how a typical AI session flows with <code>ctx</code></li> </ul>","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":"<p>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.</p> <p>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.</p> <p><code>ctx</code> replaces vibes with verifiable artifacts.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#grounded-memory","level":2,"title":"Grounded Memory","text":"<p>Every entry in <code>ctx</code> context files has a timestamp and structured fields. When the AI cites a decision, you can check it.</p> <pre><code>## [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</code></pre> <p>The timestamp <code>2026-01-28-143022</code> 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.</p> <p>This is grounded memory: claims that trace back to artifacts you control and can audit.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#constitutionmd-hard-guardrails","level":2,"title":"<code>CONSTITUTION.md</code>: Hard Guardrails","text":"<p>CONSTITUTION.md defines rules the AI must treat as inviolable. These are not suggestions or best practices - they are constraints that override task requirements.</p> <pre><code># 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</code></pre> <p>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.</p>","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":"<p>The AGENT_PLAYBOOK.md file includes a section called \"How to Avoid Hallucinating Memory\" with five explicit rules:</p> <ol> <li>Never assume. If it is not in the context files, you do not know it.</li> <li>Never invent history. Do not claim \"we discussed\" something without a file reference.</li> <li>Verify before referencing. Search files before citing them.</li> <li>When uncertain, say so. \"I don't see a decision on this\" is always better than a fabricated one.</li> <li>Trust files over intuition. If the files say PostgreSQL but your training data suggests MySQL, the files win.</li> </ol> <p>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.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#drift-detection","level":2,"title":"Drift Detection","text":"<p>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.</p> <p><code>ctx drift</code> detects this divergence:</p> <pre><code>ctx drift\n</code></pre> <p>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.</p> <p>Regular drift checks - weekly, or after major refactors - keep your context files honest the same way tests keep your code honest.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#the-verification-loop","level":2,"title":"The Verification Loop","text":"<p>The <code>/ctx-commit</code> 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.</p> <p>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.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#trust-through-structure","level":2,"title":"Trust through Structure","text":"<p>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.</p> <p>You do not need to trust the AI. You need to trust the system -- and verify when it matters.</p>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/keeping-ai-honest/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Detecting and Fixing Drift: the full workflow for keeping context files accurate</li> <li>Invariants: the properties that must hold for any valid <code>ctx</code> implementation</li> <li>Agent Security: threat model and mitigations for AI agents operating with persistent context</li> </ul>","path":["Home","Working with AI","Keeping AI Honest"],"tags":[]},{"location":"home/opencode/","level":1,"title":"ctx for OpenCode","text":"","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#the-problem","level":2,"title":"The Problem","text":"<p>Every OpenCode session starts from zero. You re-explain your architecture, the AI repeats mistakes it made yesterday, and decisions get rediscovered instead of remembered.</p> <p>Without <code>ctx</code>:</p> <pre><code>> \"Add the validation middleware we discussed\"\n\nI don't have context about previous discussions. Could you describe\nwhat validation middleware you're referring to?\n</code></pre> <p>With <code>ctx</code>:</p> <pre><code>> \"Add the validation middleware we discussed\"\n\nYes. From the Jan 15 session. You decided on Zod schemas at the\nroute level (DECISIONS.md #12), and the pattern is in\nCONVENTIONS.md. I'll follow the existing middleware in\nsrc/middleware/auth.ts as a reference.\n</code></pre> <p>That's the whole pitch: your AI remembers.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#setup-one-command","level":2,"title":"Setup (One Command)","text":"<p>Install the <code>ctx</code> binary first (installation docs), then run from your project root:</p> <pre><code>ctx setup opencode --write && ctx init\n</code></pre> <p>This does two things:</p> <ol> <li><code>ctx setup opencode --write</code>: generates the project-local OpenCode plugin, skills, and <code>AGENTS.md</code>, then merges the <code>ctx</code> MCP server into OpenCode's global config (<code>~/.config/opencode/opencode.json</code> or <code>$OPENCODE_HOME/opencode.json</code>). This writes outside the project root because non-interactive shells (like MCP subprocesses) cannot discover project-local config; the same reason the Copilot CLI integration writes to <code>~/.copilot/mcp-config.json</code>.</li> <li><code>ctx init</code>: creates the <code>.context/</code> directory with template files.</li> </ol>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#what-gets-created","level":3,"title":"What Gets Created","text":"File Purpose <code>.opencode/plugins/ctx.ts</code> Lifecycle plugin (hooks into <code>ctx system</code> commands) <code>~/.config/opencode/opencode.json</code> Global MCP server registration (or <code>$OPENCODE_HOME/opencode.json</code>) <code>AGENTS.md</code> Agent instructions (OpenCode reads this natively) <code>.opencode/skills/ctx-*/SKILL.md</code> Slash command skills <p>The plugin is a single file with no runtime dependencies; no <code>bun install</code> or <code>npm install</code> needed. OpenCode loads it automatically on launch.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#what-happens-automatically","level":2,"title":"What Happens Automatically","text":"<p>The plugin wires OpenCode lifecycle events to <code>ctx</code>. You don't need to do anything; it just works.</p> Event What fires What it does New session <code>session.created</code> Warms <code>ctx</code> state in the background (bootstrap + agent packet) so MCP queries are fast on first use Agent idle <code>session.idle</code> Runs persistence and task-completion checks (silent: output is buffered, not surfaced to the TUI) After <code>git commit</code> <code>tool.execute.after</code> Runs <code>ctx system post-commit</code> to capture context state After file edit <code>tool.execute.after</code> Runs <code>ctx system check-task-completion</code> to detect silent task completions Every shell call <code>shell.env</code> Ensures the agent's shell <code>cd</code>s to the project root so all <code>ctx</code> commands resolve to the right project Context compaction <code>experimental.session.compacting</code> Pushes <code>ctx system bootstrap</code> output into the compaction context so the agent retains breadcrumbs to re-read context files post-compaction <p>The compaction hook matters most. When OpenCode compresses your context window to free up tokens, the plugin makes sure the compressed summary includes a pointer back to your <code>.context/</code> directory and its file inventory, so the agent can re-read tasks, decisions, and learnings on demand, even though the original messages are gone.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#how-compaction-works","level":3,"title":"How Compaction Works","text":"<p>When your conversation exceeds the context window, OpenCode runs a compaction pass (you can trigger one manually with <code>/compact</code>). The compaction agent summarizes older messages and drops the originals. Without <code>ctx</code>, all accumulated knowledge disappears. With <code>ctx</code>, the plugin intercepts the <code>experimental.session.compacting</code> event and appends <code>ctx system bootstrap</code> output (context directory path and file inventory) into the compaction context. The result: the compressed summary retains the breadcrumbs the agent needs to re-read tasks, decisions, learnings, and conventions on demand, even though the original messages that loaded them are gone.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#what-is-not-included","level":3,"title":"What Is Not Included","text":"<p>Note: dangerous-command blocking is Claude Code-specific and is not part of the OpenCode integration. OpenCode's execution model (explicit user approval for every shell command) makes a pre-execution blocklist unnecessary.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#slash-commands","level":2,"title":"Slash Commands","text":"<p>The skills are generated from the canonical ctx skill tree at build time, so their names and behavior match the Claude Code integration one-to-one.</p> <p>Session lifecycle:</p> Command When to use <code>/ctx-agent</code> Load full context packet. Use at session start or when context feels stale. <code>/ctx-remember</code> \"Do you remember?\"; reads tasks, decisions, learnings, and recent journal entries. Returns a structured readback. <code>/ctx-status</code> Context summary at a glance: file count, token estimate, recent activity. <code>/ctx-wrap-up</code> End-of-session ceremony. Captures learnings, decisions, conventions, and outstanding tasks to <code>.context/</code> files. <code>/ctx-handover</code> Write a per-session handover note for the next agent (invoked by <code>/ctx-wrap-up</code>). <p>The planning arc from the Design Before Coding recipe:</p> Command When to use <code>/ctx-brainstorm</code> Design before implementation: turn a vague idea into a validated design. <code>/ctx-plan</code> Stress-test a plan through adversarial interview; produces a debated brief. <code>/ctx-spec</code> Scaffold a feature spec from the project template. <code>/ctx-task-out</code> Decompose a committed spec into a per-milestone implementation plan. <code>/ctx-implement</code> Execute a plan step-by-step with verification. <p>Capture:</p> Command When to use <code>/ctx-task-add</code> Add a task when follow-up work is identified. <code>/ctx-decision-add</code> Record an architectural decision with rationale. <p>Knowledge-base editorial pipeline (active when <code>.context/kb/</code> exists):</p> Command When to use <code>/ctx-kb-ingest</code> Editorial knowledge-ingestion pass over supplied sources. <code>/ctx-kb-ask</code> Q&A grounded in the existing kb. <code>/ctx-kb-note</code> Park a finding for the next ingest pass. <code>/ctx-kb-site-review</code> Mechanical structural audit of the kb. <code>/ctx-kb-ground</code> Read-only freshness audit over the kb's tracked sources. <p>You don't need to use these often. The plugin handles most context loading automatically. These are for when you want explicit control.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#mcp-tools","level":2,"title":"MCP Tools","text":"<p>The <code>ctx</code> MCP server exposes tools directly to the agent. These let the AI read and write your context files without shell commands:</p> Tool Purpose <code>ctx_add</code> Add a task, decision, learning, or convention <code>ctx_complete</code> Mark a task done by number or text match <code>ctx_search</code> Full-text search across all <code>.context/</code> files <code>ctx_next</code> Suggest the next pending task by priority <code>ctx_drift</code> Detect stale context: dead paths, missing files <code>ctx_compact</code> Archive completed tasks, clean empty sections <code>ctx_remind</code> List pending session-scoped reminders <code>ctx_status</code> Context health: file count, token estimate <code>ctx_steering_get</code> Retrieve steering files applicable to the current prompt <code>ctx_journal_source</code> Query recent AI session history <code>ctx_sessionevent</code> Signal session start/end lifecycle events <code>ctx_watch_update</code> Apply structured updates to <code>.context/</code> files <code>ctx_checktaskcompletion</code> After a write, detect silently completed tasks <p>You don't invoke these yourself. The agent uses them as needed.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#refreshing-the-integration","level":2,"title":"Refreshing the Integration","text":"<p>If you re-run <code>ctx setup opencode --write</code> (e.g., after updating <code>ctx</code>), the plugin and skills are rewritten in place. Restart OpenCode to pick up the refreshed plugin. OpenCode only loads plugins at launch, not mid-session.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#troubleshooting","level":2,"title":"Troubleshooting","text":"Symptom Cause Fix <code>opencode mcp list</code> shows <code>ctx ✗ failed MCP error -32000: Connection closed</code> MCP subprocess started outside the project root Re-run <code>ctx setup opencode --write</code> to regenerate the sh-wrapper that <code>cd</code>s to the project root before invoking <code>ctx</code> Plugin installed but no hooks fire Flat-file vs. subdirectory discovery mismatch (OpenCode requires <code>.opencode/plugins/<name>.ts</code>, not a subfolder) Verify the plugin is at <code>.opencode/plugins/ctx.ts</code>. Check with <code>opencode --print-logs --log-level DEBUG</code> <code>ctx agent</code> Markdown leaking into the TUI BunShell command missing <code>.nothrow().quiet()</code> Update to the latest plugin: <code>ctx setup opencode --write</code> and restart","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#verify-it-works","level":2,"title":"Verify It Works","text":"<p>Start a new OpenCode session and ask:</p> <pre><code>Do you remember?\n</code></pre> <p>The AI should cite specific context: current tasks, recent decisions, or previous session topics. If it says \"I don't have memory\" or \"Let me check,\" something went wrong; check that the plugin installed correctly and <code>.context/</code> has files in it.</p>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/opencode/#whats-next","level":2,"title":"What's Next","text":"<ul> <li>Your First Session: step-by-step walkthrough from <code>ctx init</code> to verified recall.</li> <li>Common Workflows: day-to-day commands for tracking context, checking health, and browsing history.</li> <li>Context Files: what lives in <code>.context/</code> and how each file is used.</li> </ul>","path":["Home","Get Started","ctx for OpenCode"],"tags":[]},{"location":"home/prompting-guide/","level":1,"title":"Prompting Guide","text":"<p>New to <code>ctx</code>?</p> <p>This guide references context files like <code>TASKS.md</code>, <code>DECISIONS.md</code>, and <code>LEARNINGS.md</code>:</p> <p>These are plain Markdown files that <code>ctx</code> maintains in your project's <code>.context/</code> directory.</p> <p>If terms like \"context packet\" or \"session ceremony\" are unfamiliar,</p> <ul> <li>start with the <code>ctx</code> Manifesto for the why,</li> <li>About for the big picture,</li> <li>then Getting Started to set up your first project.</li> </ul>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#literature-matters","level":2,"title":"Literature Matters","text":"<p>This guide is about crafting effective prompts for working with AI assistants in <code>ctx</code>-enabled projects, but the guidelines given here apply to other AI systems, too.</p> <p>The right prompt triggers the right behavior. </p> <p>This guide documents prompts that reliably produce good results.</p>","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 <code>/ctx-next</code> Debug \"Why doesn't X work?\" Validate \"Is this consistent with our decisions?\" Impact analysis \"What would break if we...\" Reflect <code>/ctx-reflect</code> Wrap up <code>/ctx-wrap-up</code> 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 <code>ctx drift</code>\" Commit <code>/ctx-commit</code>","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":"<p>Triggers the AI to silently read <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, and check recent history via <code>ctx journal</code> before responding with a structured readback:</p> <ol> <li>Last session: most recent session topic and date</li> <li>Active work: pending or in-progress tasks</li> <li>Recent context: 1-2 recent decisions or learnings</li> <li>Next step: offer to continue or ask what to focus on</li> </ol> <p>Use this at the start of every important session.</p> <pre><code>Do you remember what we were working on?\n</code></pre> <p>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.</p> <p>If the AI instead narrates its discovery process (\"Let me check if there are files...\"), it has not loaded <code>CLAUDE.md</code> or <code>AGENT_PLAYBOOK.md</code> properly.</p> <p>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.</p>","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":"<p>Prompts reading of <code>TASKS.md</code>, recent sessions, and status overview.</p> <p>Use this when resuming work after a break.</p> <p>Variants:</p> <ul> <li>\"Where did we leave off?\"</li> <li>\"What's in progress?\"</li> <li>\"Show me the open tasks.\"</li> </ul>","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":"<p>This triggers root cause analysis rather than surface-level fixes.</p> <p>Use this when something fails unexpectedly.</p> <p>Framing as \"why\" encourages investigation before action. The AI will trace through code, check configurations, and identify the actual cause.</p> <p>Real Example</p> <p>\"Why can't I run /ctx-reflect?\" led to discovering missing permissions in <code>settings.local.json</code> bootstrapping.</p> <p>This was a fix that benefited all users of <code>ctx</code>.</p>","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":"<p>This prompts checking <code>DECISIONS.md</code> before implementing.</p> <p>Use this before making architectural choices.</p> <p>Variants:</p> <ul> <li>\"Check if we've decided on this before\"</li> <li>\"Does this align with our conventions?\"</li> </ul>","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":"<p>This triggers defensive thinking and impact analysis.</p> <p>Use this before making significant changes.</p> <pre><code>What would break if we change the Settings struct?\n</code></pre>","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":"<p>This ensures specific context is loaded before work begins.</p> <p>Use this when you know the relevant context exists in a specific file.</p> <pre><code>Before you start, check ctx journal source for the auth discussion session\n</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-control","level":3,"title":"Scope Control","text":"<p>Constrain the AI to prevent sprawl. These are some of the most useful prompts in day-to-day work.</p> <pre><code>Only change files in internal/cli/add/. Nothing else.\n</code></pre> <pre><code>No new files. Modify the existing implementation.\n</code></pre> <pre><code>Keep the public API unchanged. Internal refactor only.\n</code></pre> <p>Use these when the AI tends to \"helpfully\" modify adjacent code, add documentation you didn't ask for, or create new abstractions.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#course-correction","level":3,"title":"Course Correction","text":"<p>Steer the AI when it goes off-track: Don't wait for it to finish a wrong approach.</p> <pre><code>Stop! That's not what I meant. Let me clarify.\n</code></pre> <pre><code>Let's step back. Explain what you're about to do before changing anything.\n</code></pre> <pre><code>Undo that last change and try a different approach.\n</code></pre> <p>These work because they interrupt momentum.</p> <p>Without explicit course correction, the AI tends to commit harder to a wrong path rather than reconsidering.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#failure-modes","level":3,"title":"Failure Modes","text":"<p>When the AI misbehaves, match the symptom to the recovery prompt:</p> 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.\" <p>These are recovery handles, not rules to paste into <code>CLAUDE.md</code>.</p> <p>Use them in the moment when you see the behavior.</p>","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":"<p>This prompts reflection on the session and often triggers adding learnings to <code>LEARNINGS.md</code>.</p> <p>Use this after completing a task or debugging session.</p> <p>This is an explicit reflection prompt. The AI will summarize insights and often offer to persist them.</p>","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":"<p>This is an explicit persistence request.</p> <p>Use this when you have discovered something worth remembering.</p> <pre><code>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</code></pre>","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":"<p>This triggers context persistence before the session closes.</p> <p>Use it at the end of the session or before switching topics.</p> <p>Variants:</p> <ul> <li>\"Let's persist what we did\"</li> <li>\"Update the context files\"</li> <li><code>/ctx-wrap-up</code>:the recommended end-of-session ceremony (see Session Ceremonies)</li> <li><code>/ctx-reflect</code>: mid-session reflection checkpoint</li> </ul>","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":"<p>This triggers thorough codebase search rather than guessing.</p> <p>Use this when you need to understand how something works.</p> <p>This works because \"Explore\" signals that investigation is needed, not immediate action.</p>","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":"<p>This prompts reading actual code rather than explaining general concepts.</p> <p>Use this to understand the existing implementation.</p> <pre><code>How does session saving work in this codebase?\n</code></pre>","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":"<p>This triggers a comprehensive search across the codebase.</p> <p>Use this before refactoring or understanding the impact.</p>","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":"<p>This prompts identifying learnings, decisions, and conventions worth persisting.</p> <p>Use this after complex discussions or implementations.</p>","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":"<p>This invites the AI to challenge the current direction.</p> <p>Use this when you want a sanity check.</p> <p>This works because it allows AI to disagree.</p> <p>AIs often default to agreeing; this prompt signals you want an honest assessment.</p> <p>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.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#what-am-i-missing","level":3,"title":"\"What Am I Missing?\"","text":"<p>This prompts thinking about edge cases, overlooked requirements, or unconsidered approaches.</p> <p>Use this before finalizing a design or implementation.</p> <p>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.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#cli-commands-as-prompts","level":2,"title":"CLI Commands as Prompts","text":"<p>Asking the AI to run <code>ctx</code> commands is itself a prompt. These load context or trigger specific behaviors:</p> Command What it does \"Run <code>ctx status</code>\" Shows context summary, file presence, staleness \"Run <code>ctx agent</code>\" Loads token-budgeted context packet \"Run <code>ctx drift</code>\" Detects dead paths, stale files, missing context","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ctx-skills","level":3,"title":"<code>ctx</code> Skills","text":"<p>The <code>SKILS.md</code> Standard</p> <p>Skills are formalized prompts stored as <code>SKILL.md</code> files.</p> <p>The <code>/slash-command</code> syntax below is Claude Code specific. </p> <p>Other agents can use the same skill files, but invocation may differ. </p> <p>Use <code>ctx</code> skills by name:</p> Skill When to use <code>/ctx-status</code> Quick context summary <code>/ctx-agent</code> Load full context packet <code>/ctx-remember</code> Recall project context and structured readback <code>/ctx-wrap-up</code> End-of-session context persistence <code>/ctx-history</code> Browse session history for past discussions <code>/ctx-reflect</code> Structured reflection checkpoint <code>/ctx-next</code> Suggest what to work on next <code>/ctx-commit</code> Commit with context persistence <code>/ctx-drift</code> Detect and fix context drift <code>/ctx-implement</code> Execute a plan step-by-step with verification <code>/ctx-loop</code> Generate autonomous loop script <code>/ctx-pad</code> Manage encrypted scratchpad <code>/ctx-archive</code> Archive completed tasks <code>/check-links</code> Audit docs for dead links <p>Ceremony vs. Workflow Skills</p> <p>Most skills work conversationally: \"what should we work on?\" triggers <code>/ctx-next</code>, \"save that as a learning\" triggers <code>/ctx-learning-add</code>. Natural language is the recommended approach.</p> <p>Two skills are the exception: <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> are ceremony skills for session boundaries: Invoke them as explicit slash commands: conversational triggers risk partial execution. See Session Ceremonies.</p> <p>Skills combine a prompt, tool permissions, and domain knowledge into a single invocation.</p> <p>Skills beyond Claude Code</p> <p>The <code>/slash-command</code> syntax above is Claude Code native, but the underlying <code>SKILL.md</code> 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.</p> <p>See Integrations for setup details.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#anti-patterns","level":2,"title":"Anti-Patterns","text":"<p>Based on our <code>ctx</code> development experience (i.e., \"sipping our own champagne\") so far, here are some prompts that tend to produce poor results:</p> 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":"<p>Before sending a non-trivial prompt, check these four elements. This is the guide's DNA in one screenful.</p> <ol> <li>Goal in one sentence: What does \"done\" look like?</li> <li>Files to read: What existing code or context should the AI review before acting?</li> <li>Verification command: How will you prove it worked? (test name, CLI command, expected output)</li> <li>Scope boundary: What should the AI not touch?</li> </ol> <p>A prompt that covers all four is almost always good enough.</p> <p>A prompt missing <code>#3</code> is how you get \"should work now\" without evidence.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#safety-invariants","level":2,"title":"Safety Invariants","text":"<p>These Are Invariants: Not Suggestions</p> <p>A prompting guide earns its trust by being honest about risk.</p> <p>These four rules mentioned below don't change with model versions, agent frameworks, or project size.</p> <p>Build them into your workflow once and stop thinking about them.</p> <p>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.</p> <p>These invariants apply regardless of which agent or model you use.</p>","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":"<p>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.</p> <p>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.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#ask-before-destructive-operations","level":3,"title":"Ask Before Destructive Operations","text":"<p><code>git push --force</code>, <code>rm -rf</code>, <code>DROP TABLE</code>, <code>docker system prune</code>: these are irreversible or hard to reverse. A good agent should pause before running them, but don't rely on that.</p> <p>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.\"</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#scope-the-blast-radius","level":3,"title":"Scope the Blast Radius","text":"<p>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.</p> <p>The rule: Constrain scope before starting work. The Reliability Checklist's scope boundary (<code>#4</code>) is your primary safety lever. When in doubt, err on the side of a tighter boundary.</p>","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":"<p><code>LEARNINGS.md</code>, <code>DECISIONS.md</code>, and session transcripts are plain-text files that may be committed to version control.</p> <p>Don't persist API keys, passwords, tokens, or credentials in context files.</p> <p>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. </p> <p>Any Secret Seen IS Exposed</p> <p>If you see a secret in a context file, remove it immediately and rotate the credential.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#explore-plan-implement","level":2,"title":"Explore → Plan → Implement","text":"<p>For non-trivial work, name the phase you want:</p> <pre><code>Explore src/auth and summarize the current flow.\nThen propose a plan. After I approve, implement with tests.\n</code></pre> <p>This prevents the AI from jumping straight to code. </p> <p>The three phases map to different modes of thinking:</p> <ul> <li>Explore: read, search, understand: no changes</li> <li>Plan: propose approach, trade-offs, scope: no changes</li> <li>Implement: write code, run tests, verify: changes</li> </ul> <p>Small fixes skip straight to implement. Complex or uncertain work benefits from all three.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#prompts-by-task-type","level":2,"title":"Prompts by Task Type","text":"<p>Different tasks need different prompt structures. The pattern: symptom + location + verification.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#bugfix","level":3,"title":"Bugfix","text":"<pre><code>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</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#refactor","level":3,"title":"Refactor","text":"<pre><code>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</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#research","level":3,"title":"Research","text":"<pre><code>Explore the request flow around src/api/.\nSummarize likely bottlenecks with evidence.\nPropose 2-3 hypotheses. Do not implement yet.\n</code></pre>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#docs","level":3,"title":"Docs","text":"<pre><code>Update docs/cli-reference.md to reflect the new --format flag.\nConfirm the flag exists in the code and the example works.\n</code></pre> <p>Notice each prompt includes what to verify and how. Without that, you get a \"should work now\" instead of evidence.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#writing-tasks-as-prompts","level":2,"title":"Writing Tasks as Prompts","text":"<p>Tasks in <code>TASKS.md</code> are indirect prompts to the AI. How you write them shapes how the AI approaches the work.</p>","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":"<p>Tell the AI why you are building something, not just what.</p> <p>Bad: \"Build a calendar view.\"</p> <p>Good: \"Build a calendar view. The motivation is that all notes and tasks we build later should be viewable here.\"</p> <p>The second version lets the AI anticipate downstream requirements:</p> <p>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.</p>","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":"<p>Bad task (implementation-focused): <pre><code>- [ ] T1.1.0: Parser system\n - [ ] Define data structures\n - [ ] Implement line parser\n - [ ] Implement session grouper\n</code></pre></p> <p>The AI may complete all subtasks but miss the actual goal. What does \"Parser system\" deliver to the user?</p> <p>Good task (deliverable-focused): <pre><code>- [ ] 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</code></pre></p> <p>Now the AI knows the subtasks serve a specific user-facing deliverable.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#use-acceptance-criteria","level":3,"title":"Use Acceptance Criteria","text":"<p>For complex tasks, add explicit \"done when\" criteria:</p> <pre><code>- [ ] 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</code></pre> <p>This prevents premature \"task complete\" when only the implementation details are done, but the feature doesn't actually work.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#subtasks-parent-task","level":3,"title":"Subtasks ≠ Parent Task","text":"<p>Completing all subtasks does not mean the parent task is complete.</p> <p>The parent task describes what the user gets.</p> <p>Subtasks describe how to build it.</p> <p>Always re-read the parent task description before marking it complete. Verify the stated deliverable exists and works.</p>","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":"<p>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.</p> <p>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.</p> <p>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).</p> <p>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).</p> <p>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).</p> <p>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).</p> <p>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.</p> <p>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.</p> <p>CLI commands as prompts (\"Run <code>ctx status</code>\") 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).</p> <p>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).</p> <p>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).</p> <p>Session reflection (\"What did we learn?\", <code>/ctx-reflect</code>) is a form of verbal reinforcement learning: Improving future performance by persisting linguistic feedback as memory rather than updating weights. This is exactly what <code>LEARNINGS.md</code> and <code>DECISIONS.md</code> provide: a durable feedback signal across sessions. Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning (2023).</p> <p>These aren't prompting \"hacks\" that you will find in the \"1000 AI Prompts for the Curious\" listicles: They are applications of foundational principles:</p> <ul> <li>Decomposition,</li> <li>Abstraction,</li> <li>Ensemble Reasoning,</li> <li>Search,</li> <li>and Constrained Optimization.</li> </ul> <p>They work because language models are, at their core, optimization systems navigating probabilistic landscapes.</p>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>The Attention Budget: Why your AI forgets what you just told it, and how token budgets shape context strategy</li> <li>The Dog Ate My Homework: A case study in making agents follow instructions: attention timing, delegation decay, and observable compliance as a design goal</li> </ul>","path":["Home","Working with AI","Prompting Guide"],"tags":[]},{"location":"home/prompting-guide/#contributing","level":2,"title":"Contributing","text":"<p>Found a prompt that works well? Open an issue or PR with:</p> <ol> <li>The prompt text;</li> <li>What behavior it triggers;</li> <li>When to use it;</li> <li>Why it works (optional but helpful).</li> </ol> <p>Dive Deeper:</p> <ul> <li>Recipes: targeted how-to guides for specific tasks</li> <li>CLI Reference: all commands and flags</li> <li>Integrations: setup for Claude Code, Cursor, Aider</li> </ul>","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":"<p>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.</p> <p>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.</p> <p>This is not a model problem. It is a memory problem. Without persistent context, every session starts with amnesia.</p>","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 <code>ctx</code> Stops the Loop","text":"<p><code>ctx</code> gives your AI three files that directly prevent repeated mistakes, each targeting a different failure mode.</p>","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":"<code>DECISIONS.md</code>: Stop Relitigating Settled Choices","text":"<p>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.</p> <pre><code>## [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</code></pre> <p>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.</p>","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#learningsmd-capture-gotchas-once","level":3,"title":"<code>LEARNINGS.md</code>: Capture Gotchas Once","text":"<p>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.</p> <pre><code>## 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</code></pre> <p>Without this entry, the next session that touches the Dockerfile will hit the same wall. With it, the AI knows before it starts.</p>","path":["Home","Working with AI","My AI Keeps Making the Same Mistakes"],"tags":[]},{"location":"home/repeated-mistakes/#constitutionmd-draw-hard-lines","level":3,"title":"<code>CONSTITUTION.md</code>: Draw Hard Lines","text":"<p>Some mistakes are not about forgetting - they are about boundaries the AI should never cross. CONSTITUTION.md sets inviolable rules.</p> <pre><code>* [ ] 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</code></pre> <p>The AI reads these as absolute constraints. It does not weigh them against convenience. It refuses tasks that would violate them.</p>","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":"<p>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.</p> <p>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.</p> <p>The key insight: you are not just coding. You are building a knowledge layer that makes every future session faster.</p> <p><code>ctx</code> files version with your code in git. They survive branch switches, team changes, and model upgrades. The context outlives any single session.</p>","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":"<p>Capture your first decision or learning right now:</p> <pre><code>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</code></pre>","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":"<ul> <li>Knowledge Capture: the full workflow for persisting decisions, learnings, and conventions</li> <li>Context Files Reference: structure and format for every file in <code>.context/</code></li> <li>About <code>ctx</code>: the bigger picture - why persistent context changes how you work with AI</li> </ul>","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":"<p><code>ctx</code> 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.</p> <p>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.\" <code>ctx</code> manages those files in <code>.context/steering/</code>, 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.</p>","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":"<p>The three look similar on disk but serve different purposes:</p> Kind Purpose Decisions (<code>DECISIONS.md</code>) What was chosen and why Conventions (<code>CONVENTIONS.md</code>) How the codebase is written Steering (<code>.context/steering/*.md</code>) How the AI should behave on matching prompts <p>If you find yourself writing \"the AI should always do X when asked about Y,\" that belongs in steering, not decisions.</p>","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#your-first-steering-files","level":2,"title":"Your First Steering Files","text":"<p><code>ctx init</code> scaffolds four foundation steering files in <code>.context/steering/</code> so you start with something to edit rather than an empty directory:</p> File What to fill in <code>product.md</code> What the project is, who it's for, what's out of scope <code>tech.md</code> Languages, frameworks, runtime, hard constraints <code>structure.md</code> Directory layout, where new files go, naming rules <code>workflow.md</code> Branch strategy, commit conventions, pre-commit checks <p>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.</p> <p>Default settings for foundation files:</p> <ul> <li><code>inclusion: always</code>: fires on every AI tool call</li> <li><code>priority: 10</code>: injected near the top of the prompt</li> <li><code>tools: []</code>: applies to every configured AI tool</li> </ul> <p>You should open each of these files and replace the placeholder content with your project's actual rules. Re-running <code>ctx init</code> is safe: existing files are left alone, so your edits survive. Use <code>ctx init --no-steering-init</code> to opt out of the scaffold entirely.</p>","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#inclusion-modes","level":2,"title":"Inclusion Modes","text":"<p>Each steering file declares an inclusion mode in its frontmatter:</p> Mode When the file is included <code>always</code> Every prompt, unconditionally <code>auto</code> When the prompt keywords match the file's description <code>manual</code> Only when the user explicitly names the file <p>Which mode to pick depends on the AI tool you use, because the two tool families consume steering very differently.</p> <p>Claude Code and Codex: prefer <code>inclusion: always</code> for rules that must fire reliably. These tools have two delivery channels:</p> <ol> <li>The plugin's <code>PreToolUse</code> hook runs <code>ctx agent</code> with an empty prompt, so only <code>always</code> files match and get injected automatically on every tool call.</li> <li>The <code>ctx_steering_get</code> MCP tool, registered automatically when the <code>ctx</code> plugin is installed. Claude can call this tool mid-task to fetch <code>auto</code> or <code>manual</code> files matching a specific prompt. Verify with <code>claude mcp list</code>; look for <code>ctx: ✓ Connected</code>.</li> </ol> <p>Use <code>always</code> for invariants and anything that must fire every session. Use <code>auto</code> 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 <code>manual</code> for reference libraries you'll name explicitly.</p> <p>Cursor, Cline, Kiro: <code>auto</code> is the natural default. These tools read <code>.cursor/rules/</code>, <code>.clinerules/</code>, or <code>.kiro/steering/</code> natively and resolve the description match on their own, so <code>auto</code> files fire when the prompt matches. <code>manual</code> files load on explicit invocation. <code>always</code> still works but consumes context budget on every turn.</p> <p>Mixed setups: if a rule must fire on Claude Code, pick <code>always</code>, even if it's overkill for your Cursor setup. The context budget cost is small; the alternative (silently not firing) is worse.</p>","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":"<p>Not every AI tool consumes steering the same way. <code>ctx</code> 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.</p> <p>Native-rules tools (Cursor, Cline, Kiro) have a built-in rules primitive. They read a specific directory (<code>.cursor/rules/</code>, <code>.clinerules/</code>, <code>.kiro/steering/</code>) and apply the rules they find there. <code>ctx</code> handles these via <code>ctx steering sync</code>, which exports your files into the tool-native format. Run <code>sync</code> whenever you edit a steering file.</p> <p>Hook + MCP tools (Claude Code, Codex) have no native rules primitive, so <code>ctx steering sync</code> is a no-op for them. Instead, <code>ctx</code> delivers steering through two non-sync channels:</p> <ol> <li>Automatic injection via a <code>PreToolUse</code> hook. The <code>ctx setup claude-code</code> plugin wires a hook that runs <code>ctx agent --budget 8000</code> before each tool call. <code>ctx agent</code> 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.</li> <li>On-demand via the <code>ctx_steering_get</code> MCP tool. The <code>ctx</code> 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.</li> </ol> <p>Both channels activate when you run <code>ctx setup claude-code --write</code>. After that, steering just works for Claude Code.</p> <p>Practical takeaway:</p> <ul> <li>Using Cursor/Cline/Kiro only? Run <code>ctx steering sync</code> after edits.</li> <li>Using Claude Code or Codex only? Never run <code>sync</code>; the hook+MCP pipeline handles it.</li> <li>Using both? Run <code>sync</code> for the native-rules tools; the hook+MCP pipeline covers Claude Code automatically.</li> </ul>","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":"<p>Steering is one of two hook-like layers <code>ctx</code> provides for customizing AI behavior. They're complementary:</p> <ul> <li>Steering: persistent rules that get prepended to prompts. Declarative, text-only, scored by match.</li> <li>Triggers: executable shell scripts that fire at lifecycle events. Imperative, runs arbitrary code, gated by exit codes.</li> </ul> <p>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.</p>","path":["Home","Customization","Steering Files"],"tags":[]},{"location":"home/steering/#where-to-go-next","level":2,"title":"Where to Go Next","text":"<ul> <li>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.</li> <li><code>ctx steering</code> 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.</li> <li><code>ctx setup</code>: 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 <code>PreToolUse</code> hook and MCP server.</li> <li>Lifecycle Triggers: the imperative companion to steering files.</li> </ul>","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":"<p>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.</p> <p>A trigger is an executable shell script that <code>ctx</code> 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.</p>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#trigger-types","level":2,"title":"Trigger Types","text":"Type Fires when Use case <code>session-start</code> A new AI session begins Inject rotating context, standup notes <code>session-end</code> An AI session ends Persist summaries, send notifications <code>pre-tool-use</code> Before a tool call executes Block, gate, or audit <code>post-tool-use</code> After a tool call completes Log, react, post-process <code>file-save</code> A file is saved Lint on save, update indices <code>context-add</code> A new entry is added to <code>.context/</code> 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":"<p>Only Enable Scripts You've Read and Understand</p> <p>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.</p> <p><code>ctx trigger add</code> intentionally creates new scripts disabled (no executable bit). You must <code>ctx trigger enable <name></code> after reviewing the contents. That's not a suggestion; it's the security model.</p>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#three-hook-like-layers-in-ctx","level":2,"title":"Three Hook-like Layers in <code>ctx</code>","text":"<p>Triggers are one of three distinct hook-like concepts in ctx. The names are similar but the owners and use cases are not:</p> Layer Owned by Where they live When to use <code>ctx trigger</code> You <code>.context/hooks/<type>/*.sh</code> Project-specific automation, any AI tool <code>ctx system</code> hooks <code>ctx</code> itself built-in, wired into tool configs Built-in nudges (you don't author these) Claude Code hooks Claude Code <code>.claude/settings.local.json</code> Claude-Code-only tool-specific integration <p>This page is about the first category. The other two run automatically and are invisible to you.</p>","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":"<p>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:</p> <ul> <li>Want the AI to remember something? → Steering.</li> <li>Want a script to run when something happens? → Trigger.</li> </ul> <p>Most projects use both.</p>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/triggers/#where-to-go-next","level":2,"title":"Where to Go Next","text":"<ul> <li>Authoring Lifecycle Triggers: walkthrough with security guidance: scaffold, test, enable, iterate.</li> <li><code>ctx trigger</code> reference: command reference, trigger type table, input/output contract.</li> <li>Steering files: the declarative counterpart to triggers.</li> </ul>","path":["Home","Customization","Lifecycle Triggers"],"tags":[]},{"location":"home/vscode/","level":1,"title":"ctx for VS Code","text":"","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#the-problem","level":2,"title":"The Problem","text":"<p>Every Copilot Chat session in VS Code starts from zero. You re-explain what you were doing, the AI repeats yesterday's mistakes, and decisions you spent an hour reasoning through last week get rediscovered instead of remembered.</p> <p>Without <code>ctx</code>:</p> <pre><code>@workspace add the validation middleware we discussed\n\nI don't have context about previous discussions. Could you describe\nwhat validation middleware you're referring to?\n</code></pre> <p>With <code>ctx</code>:</p> <pre><code>@ctx Do you remember?\n\nLast session (2026-05-09): you decided on Zod schemas at the route level\n(DECISIONS.md #12). Pattern lives in CONVENTIONS.md. Open task: wire\nthe auth middleware into the new /admin routes (TASKS.md, in-progress).\nThe reference implementation is src/middleware/auth.ts.\n</code></pre> <p>That's the whole pitch: your AI remembers, right inside the IDE you already work in.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#setup","level":2,"title":"Setup","text":"<p>Install the extension and the <code>ctx</code> binary, then <code>ctx init</code> your project:</p> <ol> <li>Install the extension from the VS Code Marketplace (publisher: <code>activememory</code>, display name: <code>ctx</code>: Persistent Context for AI). Or build from source (see editors/vscode/README.md).</li> <li>Install the <code>ctx</code> CLI if you haven't already (installation docs). If you skip this step, the extension will auto-download the right binary for your platform on first use (see Auto-Bootstrap below).</li> <li>From your project root, run:</li> </ol> <pre><code>ctx init\n</code></pre> <ol> <li>Open Copilot Chat in VS Code and type <code>@ctx /init</code> to verify the extension can reach the CLI.</li> </ol>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#what-gets-created","level":3,"title":"What Gets Created","text":"File Purpose <code>.context/</code> Project-local context directory (created by <code>ctx init</code>) <code>.github/copilot-instructions.md</code> Repository instructions Copilot reads natively; regenerated automatically whenever <code>.context/</code> files change <p>The extension itself lives in VS Code's extension storage. No project files are added beyond <code>.context/</code> and the Copilot instructions.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#how-you-use-it","level":2,"title":"How You Use It","text":"<p>Type <code>@ctx</code> in the Copilot Chat view to invoke the chat participant. Then either:</p> <ul> <li>Use a slash command: <code>@ctx /status</code>, <code>@ctx /wrapup</code>, etc. There are 45 commands; the most common ones live in the Slash Commands table below.</li> <li>Use natural language: <code>@ctx what should I work on?</code> routes to <code>/next</code>; <code>@ctx time to wrap up</code> routes to <code>/wrapup</code>. See Natural Language.</li> </ul> <p>The extension shows context-aware follow-up suggestions after each command. For example, after <code>/init</code> you'll see buttons for \"Show status\" or \"Generate copilot integration.\"</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#what-happens-automatically","level":2,"title":"What Happens Automatically","text":"<p>The extension registers several VS Code event handlers that mirror Claude Code's hook system. These run in the background; no user action needed.</p> Trigger What fires File save Task-completion check on non-<code>.context/</code> files Git commit Notification prompting to add a Decision, Learning, run <code>/verify</code>, or Skip <code>.context/</code> file change Refreshes pending reminders and regenerates <code>.github/copilot-instructions.md</code> Dependency file change When <code>go.mod</code>, <code>package.json</code>, etc. change, prompts to refresh the dependency map (<code>/map</code>) Every 5 minutes Updates the reminder status-bar item and writes a heartbeat timestamp Extension activate Fires <code>ctx system session-event --type start</code> Extension deactivate Fires <code>ctx system session-event --type end</code>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#status-bar","level":3,"title":"Status Bar","text":"<p>A <code>$(bell) ctx</code> indicator appears in the status bar when you have pending reminders. It refreshes every 5 minutes and hides itself when nothing is due.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#slash-commands","level":2,"title":"Slash Commands","text":"<p>The extension surfaces 45 commands across six categories. The most commonly used:</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#core-context","level":3,"title":"Core Context","text":"Command When to use <code>/init</code> Initialize a <code>.context/</code> directory with template files <code>/status</code> Token estimate, file count, what's recent <code>/agent</code> Print AI-ready context packet <code>/drift</code> Detect stale paths, missing files, dead references <code>/recall</code> Browse and search prior AI session history <code>/add</code> Add a task, decision, learning, or convention","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#session-lifecycle","level":3,"title":"Session Lifecycle","text":"Command When to use <code>/wrapup</code> End-of-session ceremony: status, drift, journal audit <code>/remember</code> Structured readback (trigger: \"Do you remember?\") from tasks, decisions, learnings, recent journal <code>/reflect</code> Surface items worth persisting as decisions or learnings <code>/pause</code> / <code>/resume</code> Save and restore session state for later","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#discovery-planning","level":3,"title":"Discovery & Planning","text":"Command When to use <code>/brainstorm</code> Browse and develop ideas from <code>ideas/</code> <code>/spec</code> List or scaffold feature specs from templates <code>/verify</code> Run verification (doctor + drift) <code>/map</code> Show dependency map (go.mod, package.json) <p>Full list (with maintenance, audit, metadata, and system commands) is in editors/vscode/README.md.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#natural-language","level":2,"title":"Natural Language","text":"<p>Plain English after <code>@ctx</code> is routed to the right command:</p> <ul> <li>\"What should I work on next?\" → <code>/next</code></li> <li>\"Time to wrap up\" → <code>/wrapup</code></li> <li>\"Show me the status\" → <code>/status</code></li> <li>\"Add a decision\" → <code>/add</code></li> <li>\"Check for drift\" → <code>/drift</code></li> </ul> <p>If the phrase doesn't match a known pattern, the extension surfaces a short menu of likely matches.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#auto-bootstrap","level":2,"title":"Auto-Bootstrap","text":"<p>If the <code>ctx</code> CLI isn't on PATH (or at a path configured via <code>ctx.executablePath</code>), the extension auto-downloads the right binary:</p> <ol> <li>Detects OS and architecture (darwin / linux / windows, amd64 / arm64).</li> <li>Fetches the latest release from GitHub Releases.</li> <li>Downloads and verifies the matching binary.</li> <li>Caches it in VS Code's global storage directory.</li> </ol> <p>Subsequent sessions reuse the cached binary. To pin a specific version, set <code>ctx.executablePath</code> in your VS Code settings.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li>VS Code 1.93+</li> <li>GitHub Copilot Chat extension</li> <li><code>ctx</code> CLI on PATH, or let the extension auto-download it</li> </ul>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#configuration","level":2,"title":"Configuration","text":"Setting Default Description <code>ctx.executablePath</code> <code>ctx</code> Path to the <code>ctx</code> CLI binary. Set this if <code>ctx</code> isn't on PATH and you don't want auto-download.","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#refreshing-the-integration","level":2,"title":"Refreshing the Integration","text":"<p>The extension updates through the VS Code Marketplace like any other extension; install new versions via the Extensions view. Updates to the <code>ctx</code> CLI are independent: bump it via your package manager, or let the auto-bootstrap fetch the latest release.</p> <p>Unlike the OpenCode integration, there is no <code>ctx setup</code> step for VS Code. The extension carries its own runtime; <code>ctx</code>'s role is only to provide the CLI it shells out to.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#troubleshooting","level":2,"title":"Troubleshooting","text":"Symptom Cause Fix <code>@ctx</code> participant doesn't appear in Copilot Chat Copilot Chat not installed or not signed in Install GitHub Copilot Chat and ensure you're signed in to a Copilot-eligible account <code>@ctx /status</code> says <code>ctx</code> not found CLI not on PATH and auto-download disabled Either add <code>ctx</code> to PATH (<code>brew install activememory/tap/ctx</code> or download from Releases), or unset <code>ctx.executablePath</code> to let the extension auto-download Status-bar reminder never updates Heartbeat suppressed or <code>.context/</code> doesn't exist Run <code>ctx init</code> from your project root; reload VS Code if the indicator still doesn't appear within 5 minutes Commands run but nothing is captured to <code>.context/</code> Workspace folder missing or <code>.context/</code> outside the open folder Make sure your project root (the one with <code>.context/</code>) is the workspace root, not a subdirectory of it","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#verify-it-works","level":2,"title":"Verify It Works","text":"<p>Open Copilot Chat and ask:</p> <pre><code>@ctx Do you remember?\n</code></pre> <p>You should see a structured readback citing specific tasks, decisions, and recent session topics. If you instead see \"I don't have memory\" or \"Let me check,\" something went wrong: confirm the CLI is reachable (<code>@ctx /system doctor</code>) and <code>.context/</code> has files in it.</p>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"home/vscode/#whats-next","level":2,"title":"What's Next","text":"<ul> <li>Your First Session: step-by-step walkthrough from <code>ctx init</code> to verified recall.</li> <li>Common Workflows: day-to-day commands for tracking context, checking health, and browsing history.</li> <li>Context Files: what lives in <code>.context/</code> and how each file is used.</li> <li>Setup across AI Tools: wiring <code>ctx</code> for Claude Code, OpenCode, Cursor, Aider, Copilot, or Windsurf alongside VS Code.</li> </ul>","path":["Home","Get Started","ctx for VS Code"],"tags":[]},{"location":"operations/","level":1,"title":"Operations","text":"<p>Guides for installing, upgrading, integrating, and running <code>ctx</code>. Split into three groups by audience.</p>","path":["Operations"],"tags":[]},{"location":"operations/#day-to-day","level":2,"title":"Day-to-Day","text":"<p>Everyday operation guides for anyone running <code>ctx</code> in a project or adopting it in a team.</p>","path":["Operations"],"tags":[]},{"location":"operations/#integration","level":3,"title":"Integration","text":"<p>Adopt <code>ctx</code> in an existing project: initialize context files, migrate from other tools, and onboard team members.</p>","path":["Operations"],"tags":[]},{"location":"operations/#upgrade","level":3,"title":"Upgrade","text":"<p>Upgrade between versions with step-by-step migration notes and breaking-change guidance.</p>","path":["Operations"],"tags":[]},{"location":"operations/#ai-tools","level":3,"title":"AI Tools","text":"<p>Configure <code>ctx</code> with Claude Code, Cursor, Aider, Copilot, Windsurf, and other AI coding tools.</p>","path":["Operations"],"tags":[]},{"location":"operations/#autonomous-loops","level":3,"title":"Autonomous Loops","text":"<p>Run an unattended AI agent that works through tasks overnight, with <code>ctx</code> providing persistent memory between iterations.</p>","path":["Operations"],"tags":[]},{"location":"operations/#hub","level":2,"title":"Hub","text":"<p>Operator guides for running a <code>ctx</code> Hub, the gRPC server that fans out structured entries across projects. If you're a client connecting to a Hub someone else runs, see <code>ctx connection</code> and the Hub recipes instead.</p>","path":["Operations"],"tags":[]},{"location":"operations/#hub-operations","level":3,"title":"Hub Operations","text":"<p>Data directory layout, daemon management, systemd unit, backup and restore, log rotation, monitoring, and upgrades.</p>","path":["Operations"],"tags":[]},{"location":"operations/#hub-failure-modes","level":3,"title":"Hub Failure Modes","text":"<p>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.</p>","path":["Operations"],"tags":[]},{"location":"operations/#maintainers","level":2,"title":"Maintainers","text":"<p>Runbooks for people shipping <code>ctx</code> itself.</p>","path":["Operations"],"tags":[]},{"location":"operations/#cutting-a-release","level":3,"title":"Cutting a Release","text":"<p>Step-by-step runbook for maintainers: bump version, generate release notes, run the release script, and verify the result.</p>","path":["Operations"],"tags":[]},{"location":"operations/#runbooks","level":2,"title":"Runbooks","text":"<p>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.</p> 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 <code>ctx</code> 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 Out-of-band audit channel Relay out-of-band audit findings into a working session (<code>ctxctl</code>) Running discipline audits from a separate session Sanitize permissions Clean <code>.claude/settings.local.json</code> of over-broad grants After heavy permission granting Architecture exploration Systematic architecture docs across repos New codebase onboarding, reviews <p>Recommended cadence:</p> <ul> <li>Before every release: release checklist (which includes codebase audit + docs semantic audit)</li> <li>Monthly: sanitize permissions</li> <li>Quarterly: full sweep of all audit runbooks</li> </ul>","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":"<p>Iterate until done.</p> <p>An autonomous loop is an iterative AI development workflow where an agent works on tasks until completion, without constant human intervention. </p> <p><code>ctx</code> provides the memory that makes this possible:</p> <ul> <li><code>ctx</code> provides the memory: persistent context that survives across iterations</li> <li>The loop provides the automation: continuous execution until done</li> </ul> <p>Together, they enable fully autonomous AI development where the agent remembers everything across iterations.</p> <p>Origin</p> <p>This pattern is inspired by Geoffrey Huntley's Ralph Wiggum technique.</p> <p>We use generic terminology here so the concepts remain clear regardless of trends.</p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#how-it-works","level":2,"title":"How It Works","text":"<pre><code>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</code></pre> <ol> <li>Loop reads <code>.context/loop.md</code> and invokes AI</li> <li>AI loads context from <code>.context/</code></li> <li>AI picks one task and completes it</li> <li>AI updates context files (mark task done, add learnings)</li> <li>AI commits changes</li> <li>Loop checks for completion signals</li> <li>Repeat until converged or blocked</li> </ol>","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":"<p>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\":</p> <p>The only state that carries between iterations is what lives in <code>.context/</code> and the git history. No context window bleed, no accumulated tokens, no hidden state.</p> <p>Create a <code>loop.sh</code>:</p> <pre><code>#!/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</code></pre> <p>Make it executable and run:</p> <pre><code>chmod +x loop.sh\n./loop.sh\n</code></pre> <p>You can also generate this script with <code>ctx loop</code> (see CLI Reference).</p>","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":"<p>Each iteration starts a fresh AI process with zero context window history. The agent knows only what it reads from <code>.context/</code> files: Exactly the information you chose to persist. </p> <p>This is the core loop principle: memory is explicit, not accidental.</p>","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":"<p>Claude Code has built-in loop support:</p> <pre><code># Start autonomous loop\n/loop\n\n# Cancel running loop\n/cancel-loop\n</code></pre> <p>This is convenient for quick iterations, but be aware of important caveats:</p> <p>This Loop Is Not Pure</p> <p>Claude Code's <code>/loop</code> runs all iterations within the same session. This means:</p> <ul> <li>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 <code>.context/</code>).</li> <li>Token budget degrades: Each iteration adds to the context window, leaving less room for actual work in later iterations.</li> <li>Not ergonomic for long runs: Users report that the built-in loop is less predictable for 10+ iteration runs compared to a shell loop.</li> </ul> <p>For short explorations (2-5 iterations) or interactive use, <code>/loop</code> works fine. For overnight unattended runs or anything where iteration independence matters, use the shell while loop instead.</p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#the-contextloopmd-file","level":2,"title":"The <code>.context/loop.md</code> File","text":"<p>The prompt file instructs the AI on how to work autonomously. Here's a template:</p> <pre><code># 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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#completion-signals","level":2,"title":"Completion Signals","text":"<p>The loop watches for these signals in AI output:</p> Signal Meaning When to Use <code>SYSTEM_CONVERGED</code> All tasks complete No pending tasks in TASKS.md <code>SYSTEM_BLOCKED</code> Cannot proceed Needs clarification, access, or decision <code>BOOTSTRAP_COMPLETE</code> 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":"<p>converged state</p> <pre><code>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</code></pre> <p>blocked state</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#why-ctx-and-loops-work-well-together","level":2,"title":"Why <code>ctx</code> and Loops Work Well Together","text":"Without <code>ctx</code> With <code>ctx</code> Each iteration starts fresh Each iteration has full history Decisions get re-made Decisions persist in <code>DECISIONS.md</code> Learnings are lost Learnings accumulate in <code>LEARNINGS.md</code> Tasks can be forgotten Tasks tracked in <code>TASKS.md</code>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#automatic-context-updates","level":3,"title":"Automatic Context Updates","text":"<p>During the loop, the AI should update context files:</p> <p>Mark task complete: <pre><code>ctx task complete \"implement user auth\"\n</code></pre></p> <p>Or emit an update command (parsed by <code>ctx watch</code>): <pre><code><context-update type=\"complete\">user auth</context-update>\n</code></pre></p> <p>Add learning: <pre><code>ctx learning add \"Rate limiting requires Redis connection\" \\\n --session-id abc12345 --branch main --commit 68fbc00a\n</code></pre></p> <p>Or via update command: <pre><code><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</code></pre></p> <p>Record decision: <pre><code>ctx decision add \"Use JWT tokens for API authentication\" \\\n --session-id abc12345 --branch main --commit 68fbc00a\n</code></pre></p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#advanced-watch-mode","level":2,"title":"Advanced: Watch Mode","text":"<p>Run <code>ctx watch</code> alongside the loop to automatically process context updates:</p> <pre><code># 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</code></pre> <p>The watch command processes context updates from the loop output in real time.</p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#project-setup","level":2,"title":"Project Setup","text":"<p>Initialize a project for autonomous loop operation:</p> <pre><code>ctx init\n</code></pre> <p><code>ctx</code> always reads <code>$PWD/.context/</code>. For unattended overnight runs where a supervisor may not preserve cwd, put <code>cd /abs/path/to/project</code> at the top of <code>loop.sh</code> so the loop is anchored regardless of how the supervisor launches it.</p> <p>The loop prompt template is deployed to <code>.context/loop.md</code> during initialization. It instructs the agent to:</p> <ul> <li>Work autonomously without asking clarifying questions;</li> <li>Follow one-task-per-iteration discipline;</li> <li>Use <code>SYSTEM_CONVERGED</code> / <code>SYSTEM_BLOCKED</code> signals;</li> </ul>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#example-project-structure","level":2,"title":"Example Project Structure","text":"<pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#sample-tasksmd-for-autonomous-loops","level":3,"title":"Sample <code>TASKS.md</code> for Autonomous Loops","text":"<pre><code># 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</code></pre> <p>The loop will work through these systematically, marking each complete.</p>","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":"<p>Cause: AI not emitting completion signals</p> <p>Fix: Ensure .context/loop.md explicitly instructs signaling: <pre><code>End EVERY response with one of:\n- SYSTEM_CONVERGED (if all tasks done)\n- SYSTEM_BLOCKED (if stuck)\n</code></pre></p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#context-not-persisting","level":3,"title":"Context Not Persisting","text":"<p>Cause: AI not updating context files</p> <p>Fix: Add explicit instructions to .context/loop.md: <pre><code>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</code></pre></p>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#tasks-getting-repeated","level":3,"title":"Tasks Getting Repeated","text":"<p>Cause: Task not marked complete before next iteration</p> <p>Fix: Ensure commit happens after context update:</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#ai-violating-constitution","level":3,"title":"AI Violating Constitution","text":"<p>Cause: Constitution not read first</p> <p>Fix: Make constitution check explicit in <code>.context/loop.md</code>:</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Building <code>ctx</code> Using <code>ctx</code>: The dogfooding story: how autonomous loops built the tool that powers them</li> </ul>","path":["Operations","Day-to-Day","Autonomous Loops"],"tags":[]},{"location":"operations/autonomous-loop/#resources","level":2,"title":"Resources","text":"<ul> <li>Geoffrey Huntley's Ralph Wiggum Technique: The original inspiration</li> <li>Context CLI: Command reference</li> <li>Integrations: Tool-specific setup</li> </ul>","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":"<code>ctx</code> Hub: Failure Modes","text":"<p>What can go wrong, what the system does about it, and what you should do. Complementary to <code>ctx</code> Hub Operations.</p> <p>Design Posture</p> <p>The hub is best-effort knowledge sharing, not a durable ledger. Local <code>.context/</code> files are the source of truth for each project; the hub is a fan-out channel. This framing informs every failure-mode decision below.</p>","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":"<p>What happens: <code>ctx connection listen</code> detects the EOF, waits with exponential backoff, and reconnects. On reconnect it passes its last-seen sequence; the hub replays everything newer.</p> <p>What you should do: nothing. If reconnects are looping, check firewall state on the hub and <code>ctx hub status</code> output.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#partition-majority-side-reachable","level":3,"title":"Partition: Majority Side Reachable","text":"<p>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).</p> <p>What you should do: let it heal. When the partition closes, followers catch up via sequence-based sync automatically.</p>","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":"<p>What happens: no node holds a majority, so no leader is elected. All nodes become read-only. <code>ctx connection publish</code> and <code>ctx add --share</code> fail with a \"no leader\" error; local writes still succeed.</p> <p>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 <code>ctx hub peer remove</code> for the dead nodes.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#hub-unreachable-during-ctx-add-share","level":3,"title":"Hub Unreachable during <code>ctx add --share</code>","text":"<p>What happens: the local write succeeds; the share step prints a warning and exits non-zero on the share leg only. <code>--share</code> is best-effort; it never blocks local context updates.</p> <p>What you should do: run <code>ctx connection publish</code> later to backfill, or rely on another <code>--share</code> for the same entry ID. The hub deduplicates by entry ID.</p>","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":"<p>What happens: <code>entries.jsonl</code> 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.</p> <p>What you should do: free disk or grow the volume, then nothing else; the hub resumes accepting writes on the next append attempt.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#corrupt-entriesjsonl","level":3,"title":"Corrupt <code>entries.jsonl</code>","text":"<p>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.</p> <p>What you should do: inspect with <code>jq -c . <data-dir>/entries.jsonl > /dev/null</code> to find the bad line. Move the bad region to a <code>.quarantine</code> file, then start. Nothing is ever silently dropped.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#metajson-entriesjsonl-sequence-mismatch","level":3,"title":"<code>meta.json</code> / <code>entries.jsonl</code> Sequence Mismatch","text":"<p>What happens: the hub refuses to start. This usually means someone copied one file without the other.</p> <p>What you should do: restore both files from the same backup, or accept the higher sequence by regenerating <code>meta.json</code> from <code>entries.jsonl</code> (manual for now; file a bug).</p>","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":"<p>What happens: <code>ctx hub stop</code> triggers <code>stepdown</code> first, so a new leader is elected before the old one exits. In-flight writes drain. Clients reconnect to the new leader transparently.</p>","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":"<p>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.</p> <p>What you should do: if you need stronger durability, run <code>ctx connection listen</code> on a dedicated \"collector\" project that persists entries locally as a write-ahead backup.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#split-brain-after-rejoin","level":3,"title":"Split-Brain After Rejoin","text":"<p>What happens: Raft reconciles: the minority side's uncommitted writes are discarded, and the majority's log is authoritative.</p> <p>What you should do: nothing automatic. If you know the minority had important writes, grep for them in <code><data-dir>/entries.jsonl.rejected</code> (written by the reconciliation pass) and replay them with <code>ctx connection publish</code>.</p>","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":"<p>What happens: you cannot register new projects.</p> <p>What you should do: retrieve it from <code><data-dir>/admin.token</code>. 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.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-admin-token","level":3,"title":"Compromised Admin Token","text":"<p>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.</p> <p>What you should do: rotate the admin token (regenerate <code><data-dir>/admin.token</code> and restart), revoke suspicious client registrations via <code>clients.json</code>, and audit <code>entries.jsonl</code> for unexpected origins.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-client-token","level":3,"title":"Compromised Client Token","text":"<p>What happens: the attacker can publish as that project and read anything that project is subscribed to. Because <code>Origin</code> is self-asserted on publish, the attacker can also publish entries tagged with any other project's name, so attribution in <code>entries.jsonl</code> cannot be trusted after a token compromise.</p> <p>What you should do: remove the client's entry from <code>clients.json</code>, restart the hub, and re-register the legitimate project with a fresh token. Audit <code>entries.jsonl</code> for entries published after the compromise timestamp and quarantine any that look suspicious; remember that <code>Origin</code> on those entries proves nothing.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#compromised-hub-host","level":3,"title":"Compromised Hub Host","text":"<p>What happens: <code><data-dir>/clients.json</code> 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.</p> <p>What you should do: treat it as a total hub compromise. Stop the hub, wipe <code><data-dir></code> (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.</p>","path":["Operations","Hub","Hub Failure Modes"],"tags":[]},{"location":"operations/hub-failure-modes/#clock-skew","level":2,"title":"Clock Skew","text":"<p>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.</p> <p>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.</p>","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 <code>ctx hub status</code> \"No leader\" errors Cluster quorum; run <code>ctx hub status</code> on each peer Hub won't start after crash Last line of <code>entries.jsonl</code> Entries missing after restore Check <code>clients.json</code> sequence vs local <code>.sync-state.json</code> 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":"<ul> <li><code>ctx</code> Hub Operations</li> <li><code>ctx</code> Hub security model</li> <li>HA cluster recipe</li> </ul>","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":"<code>ctx</code> Hub: Operations","text":"<p>Running the <code>ctx</code> <code>ctx</code> 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.</p> <p>If you have not read it yet, start with the <code>ctx</code> 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.</p> <p>Operator Cheat Sheet</p> <ul> <li>The hub fans out four entry types only: <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. Journals, scratchpad, and other local state are out of scope.</li> <li>Identity is per-project, not per-user. Attribution is limited to <code>Origin</code>, which is self-asserted by the publishing client.</li> <li>The data model is an append-only JSONL log plus two small JSON sidecar files. Nothing is rewritten in place.</li> </ul>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#data-directory-layout","level":2,"title":"Data Directory Layout","text":"<p>The hub stores everything under a single data directory (default <code>~/.ctx/hub-data/</code>, override with <code>--data-dir</code>).</p> <pre><code><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</code></pre> <p>Invariants:</p> <ul> <li><code>entries.jsonl</code> is append-only. Every line is a valid JSON object. Corrupt lines are fatal at startup: fix or truncate before restart.</li> <li><code>meta.json</code> is authoritative for the next sequence number. On restart, the hub reads the last valid line of <code>entries.jsonl</code> and refuses to start if the sequences disagree.</li> <li><code>clients.json</code> holds hashed client tokens; losing it invalidates all client registrations.</li> </ul>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#starting-and-stopping","level":2,"title":"Starting and Stopping","text":"ForegroundDaemon <pre><code>ctx hub start # Ctrl-C to stop\nctx hub start --port 8080 # Custom port\nctx hub start --data-dir /srv/ctx-hub\n</code></pre> <pre><code>ctx hub start --daemon # Fork to background\nctx hub stop # Graceful shutdown\n</code></pre> <p><code>--stop</code> sends SIGTERM to the PID in <code>hub.pid</code>, waits for in-flight RPCs to drain, then exits. If the daemon is wedged, remove <code>hub.pid</code> and send <code>SIGKILL</code> manually. <code>entries.jsonl</code> is crash-safe, so you will not lose accepted writes.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#systemd-unit","level":2,"title":"Systemd Unit","text":"<p>For production single-node deployments, run the hub as a systemd service instead of <code>--daemon</code>:</p> <pre><code># /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</code></pre> <pre><code>sudo systemctl enable --now ctx-hub\nsudo journalctl -u ctx-hub -f\n</code></pre>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#backup-and-restore","level":2,"title":"Backup and Restore","text":"<p>Because <code>entries.jsonl</code> is append-only, backups are trivial:</p> <pre><code># 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</code></pre> <p>For a consistent snapshot across all three files, stop the hub, copy, then start again, or use a filesystem-level snapshot (LVM, ZFS, Btrfs).</p> <p>Restore:</p> <pre><code>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</code></pre> <p>Clients that pushed sequences above the restored watermark will re-publish on the next <code>listen</code> reconnect, because the hub now reports a lower sequence than what clients have on disk. This is safe; the store deduplicates by entry ID.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#log-rotation","level":2,"title":"Log Rotation","text":"<p><code>entries.jsonl</code> grows unbounded. For long-lived hubs, rotate it offline:</p> <pre><code>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</code></pre> <p>Do not truncate <code>entries.jsonl</code> while the hub is running. The hub holds an open file handle; an in-place truncation confuses the sequence counter and loses writes.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#monitoring","level":2,"title":"Monitoring","text":"<p>Liveness probe:</p> <pre><code>ctx hub status --exit-code\n</code></pre> <p>Exit code <code>0</code> means the node is healthy (leader or in-sync follower); non-zero means degraded. Wire this into your monitoring of choice.</p> <p>For cluster deployments, watch for:</p> <ul> <li>Role flaps: the leader changing more than once per hour suggests network instability or disk contention.</li> <li>Replication lag: <code>ctx hub status</code> shows per-peer sequence offsets. Sustained lag > 100 sequences on a follower is worth investigating.</li> <li><code>entries.jsonl</code> growth rate: sudden spikes often indicate a misbehaving <code>ctx connection listen</code> reconnect loop.</li> </ul>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#upgrading","level":2,"title":"Upgrading","text":"<p>The JSONL format is versioned in <code>meta.json</code>. <code>ctx</code> refuses to start against a newer store version than it understands; older store versions are upgraded in place at first start after an upgrade.</p> <p>Always back up <code><data-dir>/</code> before upgrading.</p>","path":["Operations","Hub","Hub Operations"],"tags":[]},{"location":"operations/hub/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx</code> Hub failure modes</li> <li><code>ctx</code> Hub security model</li> <li><code>ctx serve</code> reference</li> <li><code>ctx hub</code> reference</li> </ul>","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":"<p>Context works with any AI tool that can read files. This guide covers setup for popular AI coding assistants.</p> <p>Run From the Project Root</p> <p><code>ctx</code> reads <code>$PWD/.context/</code>. Run the commands on this page from the project root (the directory that holds <code>.context/</code> and <code>.git/</code>).</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#claude-code-full-integration","level":2,"title":"Claude Code (Full Integration)","text":"<p>Claude Code has the deepest integration via the <code>ctx</code> plugin.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup","level":3,"title":"Setup","text":"<p>First, install <code>ctx</code> and initialize your project:</p> <pre><code>ctx init\n</code></pre> <p>Then, install the <code>ctx</code> plugin in Claude Code:</p> <pre><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</code></pre> <p>Ensure the Plugin Is Enabled</p> <p>Installing a plugin registers it, but local installs may not auto-enable it globally. Verify <code>~/.claude/settings.json</code> contains:</p> <pre><code>{ \"enabledPlugins\": { \"ctx@activememory-ctx\": true } }\n</code></pre> <p>Without this, the plugin's hooks and skills won't appear in other projects. Running <code>ctx init</code> auto-enables the plugin; use <code>--no-plugin-enable</code> to skip this step.</p> <p>This gives you:</p> Component Purpose <code>.context/</code> All context files <code>CLAUDE.md</code> 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":"<pre><code>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]</code></pre> <ol> <li>Session start: Claude reads <code>CLAUDE.md</code>, which tells it to check <code>.context/</code></li> <li>First tool use: <code>PreToolUse</code> hook runs <code>ctx agent</code> and emits the context packet (subsequent invocations within the cooldown window are silent)</li> <li>Next session: Claude reads context files and continues with context</li> </ol>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#plugin-hooks","level":3,"title":"Plugin Hooks","text":"<p>The <code>ctx</code> plugin provides lifecycle hooks implemented as Go subcommands (<code>ctx system *</code>):</p> Hook Event Purpose <code>ctx system context-load-gate</code> PreToolUse (<code>.*</code>) Auto-inject context on first tool use <code>ctx system block-non-path-ctx</code> PreToolUse (<code>Bash</code>) Block <code>./ctx</code> or <code>go run</code>: force <code>$PATH</code> install <code>ctx system qa-reminder</code> PreToolUse (<code>Bash</code>) Remind agent to lint/test before committing <code>ctx system specs-nudge</code> PreToolUse (<code>EnterPlanMode</code>) Nudge agent to use project specs when planning <code>ctx system check-context-size</code> UserPromptSubmit Nudge context assessment as sessions grow <code>ctx system check-ceremonies</code> UserPromptSubmit Nudge /ctx-remember and /ctx-wrap-up adoption <code>ctx system check-persistence</code> UserPromptSubmit Remind to persist learnings/decisions <code>ctx system check-journal</code> UserPromptSubmit Remind to export/enrich journal entries <code>ctx system check-reminders</code> UserPromptSubmit Relay pending reminders at session start <code>ctx system check-version</code> UserPromptSubmit Warn when binary/plugin versions diverge <code>ctx system check-resources</code> UserPromptSubmit Warn when memory/swap/disk/load hit DANGER level <code>ctx system check-knowledge</code> UserPromptSubmit Nudge when knowledge files grow large <code>ctx system check-map-staleness</code> UserPromptSubmit Nudge when ARCHITECTURE.md is stale <code>ctx system heartbeat</code> UserPromptSubmit Session-alive signal with prompt count metadata <code>ctx system post-commit</code> PostToolUse (<code>Bash</code>) Nudge context capture and QA after git commits <p>A catch-all <code>PreToolUse</code> hook also runs <code>ctx agent</code> on every tool use (with cooldown) to autoload context.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#hook-configuration","level":3,"title":"Hook Configuration","text":"<p>The plugin's <code>hooks.json</code> wires everything automatically: no manual configuration in <code>settings.local.json</code> needed:</p> <pre><code>{\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</code></pre>","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":"<p>Edit the <code>PreToolUse</code> command to change the token budget or cooldown:</p> <pre><code>\"command\": \"ctx agent --budget 8000 --session $PPID >/dev/null || true\"\n\"command\": \"ctx agent --budget 4000 --cooldown 5m --session $PPID >/dev/null || true\"\n</code></pre> <p>The <code>--session $PPID</code> flag isolates the cooldown per session: <code>$PPID</code> resolves to the Claude Code process PID, so concurrent sessions don't interfere. The default cooldown is 10 minutes; use <code>--cooldown 0</code> to disable it.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#verifying-setup","level":3,"title":"Verifying Setup","text":"<ol> <li>Start a new Claude Code session;</li> <li>Ask: \"Do you remember?\"</li> <li>Claude should cite specific context:<ul> <li>Current tasks from <code>.context/TASKS.md</code>;</li> <li>Recent decisions or learnings;</li> <li>Recent session history from <code>ctx journal</code>.</li> </ul> </li> </ol>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#local-plugin-development","level":3,"title":"Local Plugin Development","text":"<p>When developing <code>ctx</code> 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:</p> <ol> <li>Bump version in both:</li> <li> <p><code>internal/assets/claude/.claude-plugin/plugin.json</code> (plugin manifest), <code>.claude-plugin/marketplace.json</code> (marketplace listing*);</p> </li> <li> <p>Update the marketplace in Claude Code:</p> </li> <li>Open the Plugins UI (<code>/plugins</code> or Esc menu),</li> <li>Go to Marketplaces tab,</li> <li>Select the <code>activememory-ctx</code> Marketplace,</li> <li> <p>Choose Update marketplace;</p> </li> <li> <p>Start a new Claude Code session: skill changes aren't reflected in existing sessions.</p> </li> </ol> <p>Both Version Files Must Match</p> <p>If you only bump <code>plugin.json</code> but not <code>marketplace.json</code> (or vice versa), Claude Code may not detect the update. Always bump both together.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#troubleshooting","level":3,"title":"Troubleshooting","text":"Issue Solution Context not loading Check <code>ctx</code> is in PATH: <code>which ctx</code> Hook errors Verify plugin is installed: <code>claude /plugin list</code> New skill not visible Bump version in both <code>plugin.json</code> files, update marketplace","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-load","level":3,"title":"Manual Context Load","text":"<p>If hooks aren't working, manually load context:</p> <pre><code># Get context packet\nctx agent --budget 4000\n\n# Or paste into conversation\ncat .context/TASKS.md\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#agent-skills","level":3,"title":"Agent Skills","text":"<p>The <code>ctx</code> plugin ships Agent Skills following the agentskills.io specification.</p> <p>These are invoked in Claude Code with <code>/skill-name</code>.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-lifecycle-skills","level":4,"title":"Session Lifecycle Skills","text":"Skill Description <code>/ctx-remember</code> Recall project context at session start (ceremony) <code>/ctx-wrap-up</code> End-of-session context persistence (ceremony) <code>/ctx-status</code> Show context summary (tasks, decisions, learnings) <code>/ctx-agent</code> Get AI-optimized context packet <code>/ctx-next</code> Suggest 1-3 concrete next actions from context <code>/ctx-commit</code> Commit with integrated context capture <code>/ctx-reflect</code> Review session and suggest what to persist <code>/ctx-remind</code> Manage session-scoped reminders <code>/ctx-pause</code> Pause context hooks for this session <code>/ctx-resume</code> 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 <code>/ctx-task-add</code> Add a task to TASKS.md <code>/ctx-learning-add</code> Add a learning to LEARNINGS.md <code>/ctx-decision-add</code> Add a decision with context/rationale/consequence <code>/ctx-convention-add</code> Add a coding convention to CONVENTIONS.md <code>/ctx-archive</code> Archive completed tasks","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#scratchpad-skills","level":4,"title":"Scratchpad Skills","text":"Skill Description <code>/ctx-pad</code> 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 <code>/ctx-history</code> Browse AI session history <code>/ctx-journal-enrich</code> Enrich a journal entry with frontmatter/tags <code>/ctx-journal-enrich-all</code> 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":"<p>Blogging Is a Better Way of Creating Release Notes</p> <p>The blogging workflow can also double as generating release notes:</p> <p>AI reads your git commit history and creates a \"narrative\", which is essentially what a release note is for.</p> Skill Description <code>/ctx-blog</code> Generate blog post from recent activity <code>/ctx-blog-changelog</code> 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 <code>/ctx-doctor</code> Troubleshoot <code>ctx</code> behavior with structural health checks <code>/ctx-drift</code> Detect and fix context drift (structural + semantic) <code>/ctx-consolidate</code> Merge redundant learnings or decisions into denser entries <code>/ctx-alignment-audit</code> Audit doc claims against playbook instructions <code>/ctx-prompt-audit</code> Analyze session logs for vague prompts <code>/check-links</code> 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 <code>/ctx-loop</code> Generate a Ralph Loop iteration script <code>/ctx-task-out</code> Decompose a committed spec into a milestone plan <code>/ctx-implement</code> Execute a plan step-by-step with checks <code>/ctx-plan-import</code> Import Claude Code plan files into project specs <code>/ctx-worktree</code> Manage git worktrees for parallel agents <code>/ctx-architecture</code> Build and maintain architecture maps","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage-examples","level":4,"title":"Usage Examples","text":"<pre><code>/ctx-status\n/ctx-learning-add \"Token refresh requires explicit cache invalidation\"\n/ctx-journal-enrich twinkly-stirring-kettle\n</code></pre> <p>Skills support partial matching where applicable (e.g., session slugs).</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#cursor-ide","level":2,"title":"Cursor IDE","text":"<p>Cursor can use context files through its system prompt or by reading files directly.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_1","level":3,"title":"Setup","text":"<pre><code># Generate Cursor configuration\nctx setup cursor\n\n# Initialize context\nctx init --minimal\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration","level":3,"title":"Configuration","text":"<p>Add to Cursor settings (<code>.cursor/settings.json</code>):</p> <pre><code>// 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage","level":3,"title":"Usage","text":"<ol> <li>Open your project in Cursor</li> <li>Context files are available in the file tree</li> <li>Reference them in prompts: \"Check .context/DECISIONS.md for our approach to...\"</li> </ol>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-injection","level":3,"title":"Manual Context Injection","text":"<p>For more control, paste context directly:</p> <pre><code># Get AI-ready packet\nctx agent --budget 4000 | pbcopy # macOS\nctx agent --budget 4000 | xclip # Linux\n</code></pre> <p>Paste into Cursor's chat.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#aider","level":2,"title":"Aider","text":"<p>Aider works well with context files through its <code>--read</code> flag.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_2","level":3,"title":"Setup","text":"<pre><code># Generate Aider configuration\nctx setup aider\n\n# Initialize context\nctx init\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_1","level":3,"title":"Configuration","text":"<p>Create <code>.aider.conf.yml</code>:</p> <pre><code>read:\n - .context/CONSTITUTION.md\n - .context/TASKS.md\n - .context/CONVENTIONS.md\n - .context/DECISIONS.md\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_1","level":3,"title":"Usage","text":"<pre><code># Start Aider (reads context files automatically)\naider\n\n# Or specify files explicitly\naider --read .context/TASKS.md --read .context/CONVENTIONS.md\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#with-watch-mode","level":3,"title":"With Watch Mode","text":"<p>Run <code>ctx watch</code> alongside Aider to capture context updates:</p> <pre><code># 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#github-copilot","level":2,"title":"GitHub Copilot","text":"<p>GitHub Copilot integrates with <code>ctx</code> at three levels: an automated instructions file, a VS Code Chat extension, and manual patterns.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_3","level":3,"title":"Setup","text":"<pre><code># Initialize context\nctx init\n\n# Generate .github/copilot-instructions.md\nctx setup copilot --write\n</code></pre> <p>The <code>--write</code> flag creates <code>.github/copilot-instructions.md</code>, 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.</p> <p>Re-run <code>ctx setup copilot --write</code> after updating your <code>.context/</code> files to regenerate the instructions.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#vs-code-chat-extension-ctx","level":3,"title":"VS Code Chat Extension (<code>@ctx</code>)","text":"<p>The <code>ctx</code> VS Code extension adds a <code>@ctx</code> chat participant to GitHub Copilot Chat, giving you direct access to 45 context commands from within the editor, plus automatic hooks on file save / git commit / <code>.context/</code> changes / dependency-file edits, and a reminder status-bar indicator.</p> <p>Full guide: <code>ctx</code> for VS Code</p> <p>The home-page guide covers daily workflows, the full command list, natural-language routing, auto-bootstrap of the <code>ctx</code> CLI, troubleshooting, and \"Verify It Works.\" This subsection is the install-and-pointers overview; the dedicated page is the authoritative reference.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#installation","level":4,"title":"Installation","text":"<p>The extension ships to the VS Code Marketplace under publisher <code>activememory</code> (display name: <code>ctx</code>: Persistent Context for AI). Install via the Extensions view or <code>code --install-extension</code>.</p> <p>To build from source instead (requires Node.js 20+):</p> <pre><code>cd editors/vscode\nnpm ci\nnpm run build\nnpx @vscode/vsce package\ncode --install-extension ctx-context-<version>.vsix\n</code></pre> <p>Reload VS Code. Type <code>@ctx</code> in Copilot Chat to verify.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#what-gets-created","level":4,"title":"What Gets Created","text":"File Purpose <code>.context/</code> Project-local context directory (created by <code>ctx init</code>, not by the extension) <code>.github/copilot-instructions.md</code> Repository instructions Copilot reads natively; regenerated automatically when <code>.context/</code> files change <p>The extension itself lives in VS Code's extension storage; no project files beyond <code>.context/</code> and the Copilot instructions are added.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#how-it-works_1","level":4,"title":"How It Works","text":"<ul> <li>Chat participant: <code>@ctx</code> is registered with VS Code's Chat API; 45 slash commands route to dedicated handlers that shell out to the <code>ctx</code> CLI.</li> <li>Automatic hooks: file save → task-completion check; git commit → decision/learning prompt; <code>.context/</code> change → regenerate Copilot instructions; dependency-file change → <code>/map</code> prompt.</li> <li>Status-bar reminder: a <code>$(bell) ctx</code> indicator surfaces pending session reminders, refreshing every 5 minutes.</li> <li>Natural language: plain English after <code>@ctx</code> is routed to the nearest matching command.</li> <li>Auto-bootstrap: if the <code>ctx</code> CLI isn't on PATH, the extension downloads the correct platform binary from GitHub Releases and caches it.</li> </ul>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_2","level":4,"title":"Configuration","text":"Setting Default Description <code>ctx.executablePath</code> <code>ctx</code> Path to the <code>ctx</code> binary. Set this if <code>ctx</code> is not in your <code>PATH</code>.","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#session-persistence","level":3,"title":"Session Persistence","text":"<p><code>ctx init</code> creates a <code>.context/sessions/</code> directory for storing session data from non-Claude tools. The Markdown session parser scans this directory during <code>ctx journal</code>, enabling session history for Copilot and other tools.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-patterns","level":3,"title":"Manual Patterns","text":"<p>These patterns work without the extension, using Copilot's built-in file awareness:</p> <p>Pattern 1: Keep context files open</p> <p>Open <code>.context/CONVENTIONS.md</code> in a split pane. Copilot will reference it.</p> <p>Pattern 2: Reference in comments</p> <pre><code>// 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</code></pre> <p>Pattern 3: Paste context into Copilot Chat</p> <pre><code>ctx agent --budget 2000\n</code></pre> <p>Paste output into Copilot Chat for context-aware responses.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#opencode","level":2,"title":"OpenCode","text":"<p>OpenCode is a terminal-first AI coding agent. <code>ctx</code> integrates via a thin lifecycle plugin, MCP server, and <code>AGENTS.md</code> instructions.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_4","level":3,"title":"Setup","text":"<pre><code># Generate OpenCode plugin, global MCP config, skills, and AGENTS.md\nctx setup opencode --write\n\n# Initialize context\nctx init\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#what-gets-created_1","level":3,"title":"What Gets Created","text":"File Purpose <code>.opencode/plugins/ctx.ts</code> Lifecycle plugin (hooks to <code>ctx system</code>) <code>~/.config/opencode/opencode.json</code> Global MCP server registration (or <code>$OPENCODE_HOME/opencode.json</code>) <code>AGENTS.md</code> Agent instructions (read natively) <code>.opencode/skills/ctx-*/SKILL.md</code> <code>ctx</code> skills","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#how-it-works_2","level":3,"title":"How It Works","text":"<p>The plugin wires OpenCode lifecycle events to <code>ctx system</code>:</p> <ul> <li><code>session.created</code>: warms <code>ctx</code> state in the background (bootstrap + agent packet) so MCP queries are fast on first use.</li> <li><code>tool.execute.after</code> (shell, on <code>git commit</code>): runs <code>ctx system post-commit</code>.</li> <li><code>tool.execute.after</code> (edit/write): runs <code>ctx system check-task-completion</code>.</li> <li><code>session.idle</code>: runs persistence and task-completion checks (silent: output is buffered, not surfaced to the TUI).</li> <li><code>shell.env</code>: ensures the agent's shell starts in the project root so <code>ctx</code> commands resolve to the right project.</li> <li><code>experimental.session.compacting</code>: pushes <code>ctx system bootstrap</code> output into the compaction context so the agent keeps breadcrumbs back to <code>.context/</code>.</li> </ul> <p>The plugin is a single file with no runtime dependencies; no <code>bun install</code> needed. OpenCode loads it automatically on launch.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-updates","level":3,"title":"Context Updates","text":"<pre><code># Get AI-optimized context packet\nctx agent\n\n# Check context health\nctx status\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#windsurf-ide","level":2,"title":"Windsurf IDE","text":"<p>Windsurf supports custom instructions and file-based context.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#setup_5","level":3,"title":"Setup","text":"<pre><code># Generate Windsurf configuration\nctx setup windsurf\n\n# Initialize context\nctx init\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#configuration_3","level":3,"title":"Configuration","text":"<p>Add to Windsurf settings:</p> <pre><code>// 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#usage_2","level":3,"title":"Usage","text":"<p>Context files appear in the file tree. Reference them when chatting:</p> <ul> <li>\"What's in our task list?\" → AI reads <code>.context/TASKS.md</code></li> <li>\"What convention do we use for naming?\" → AI reads <code>.context/CONVENTIONS.md</code></li> </ul>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#generic-integration","level":2,"title":"Generic Integration","text":"<p>For any AI tool that can read files, use these patterns:</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#manual-context-loading","level":3,"title":"Manual Context Loading","text":"<pre><code># 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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#system-prompt-template","level":3,"title":"System Prompt Template","text":"<pre><code>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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#automated-updates","level":3,"title":"Automated Updates","text":"<p>If your AI tool outputs to a log, use <code>ctx watch</code>:</p> <pre><code># Watch log file for context-update commands\nyour-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n</code></pre> <p>The AI can emit updates like:</p> <pre><code><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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#context-update-commands","level":2,"title":"Context Update Commands","text":"<p>The <code>ctx watch</code> command parses update commands from AI output. Use this format:</p> <pre><code><context-update type=\"TYPE\" [attributes]>Content</context-update>\n</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#supported-types","level":3,"title":"Supported Types","text":"Type Target File Required Attributes <code>task</code> TASKS.md None <code>decision</code> DECISIONS.md <code>context</code>, <code>rationale</code>, <code>consequence</code> <code>learning</code> LEARNINGS.md <code>context</code>, <code>lesson</code>, <code>application</code> <code>convention</code> CONVENTIONS.md None <code>complete</code> 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":"<pre><code><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</code></pre>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#structured-format-learnings-decisions","level":3,"title":"Structured Format (Learnings, Decisions)","text":"<p>Learnings and decisions support structured attributes for better documentation:</p> <p>Learning with full structure:</p> <pre><code><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</code></pre> <p>Decision with full structure:</p> <pre><code><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</code></pre> <p>Learnings require: <code>context</code>, <code>lesson</code>, <code>application</code> attributes. Decisions require: <code>context</code>, <code>rationale</code>, <code>consequence</code> attributes. Updates missing required attributes are rejected with an error.</p>","path":["Operations","Day-to-Day","AI Tools"],"tags":[]},{"location":"operations/integrations/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Skills That Fight the Platform: Common pitfalls in skill design that work against the host tool</li> <li>The Anatomy of a Skill That Works: What makes a skill reliable: the E/A/R framework and quality gates</li> </ul>","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 <code>ctx</code> in Existing Projects","text":"<p>Claude Code User?</p> <p>You probably want the plugin instead of this page.</p> <p>Install <code>ctx</code> from the marketplace: (<code>/plugin</code> → search \"<code>ctx</code>\" → Install) and you're done: hooks, skills, and updates are handled for you.</p> <p>See Getting Started for the full walkthrough.</p> <p>This guide covers adopting <code>ctx</code> in existing projects regardless of which tools your team uses.</p>","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) <code>ctx init</code> Creates <code>.context/</code>, <code>CLAUDE.md</code>, permissions Existing <code>CLAUDE.md</code> <code>ctx init --merge</code> Backs up your file, inserts <code>ctx</code> block after the H1 Existing <code>CLAUDE.md</code> + <code>ctx</code> markers <code>ctx init --reset</code> Replaces the <code>ctx</code> block, leaves your content intact <code>.cursorrules</code> / <code>.aider.conf.yml</code> <code>ctx init</code> <code>ctx</code> ignores those files: they coexist cleanly Team repo, first adopter <code>ctx init --merge && git add .context/ CLAUDE.md</code> Initialize and commit for the team","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-claudemd","level":2,"title":"Existing <code>CLAUDE.md</code>","text":"<p>This is the most common scenario:</p> <p>You have a <code>CLAUDE.md</code> with project-specific instructions and don't want to lose them.</p> <p>You Own <code>CLAUDE.md</code></p> <p>After initialization, <code>CLAUDE.md</code> is yours: edit it freely.</p> <p>Add project instructions, remove sections you don't need, reorganize as you see fit.</p> <p>The only part <code>ctx</code> manages is the block between the <code><!-- ctx:context --></code> and <code><!-- ctx:end --></code> markers; everything outside those markers is yours to change at any time.</p> <p>If you remove the markers, nothing breaks: <code>ctx</code> simply treats the file as having no <code>ctx</code> content and will offer to merge again on the next <code>ctx init</code>.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-ctx-init-does","level":3,"title":"What <code>ctx init</code> Does","text":"<p>When <code>ctx init</code> detects an existing <code>CLAUDE.md</code>, it checks for <code>ctx</code> markers (<code><!-- ctx:context --></code> ... <code><!-- ctx:end --></code>):</p> State Default behavior With <code>--merge</code> With <code>--force</code> No <code>CLAUDE.md</code> Creates from template Creates from template Creates from template Exists, no <code>ctx</code> markers Prompts to merge Auto-merges (no prompt) Auto-merges (no prompt) Exists, has <code>ctx</code> markers Skips (already set up) Skips Replaces the <code>ctx</code> block only","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-merge-flag","level":3,"title":"The <code>--merge</code> Flag","text":"<p><code>--merge</code> auto-merges without prompting. The merge process:</p> <ol> <li>Backs up your existing <code>CLAUDE.md</code> to <code>CLAUDE.md.<timestamp>.bak</code>;</li> <li>Finds the H1 heading (e.g., <code># My Project</code>) in your file;</li> <li>Inserts the <code>ctx</code> block immediately after it;</li> <li>Preserves everything else untouched.</li> </ol> <p>Your content before and after the <code>ctx</code> block remains exactly as it was.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#before-after-example","level":3,"title":"Before / After Example","text":"<p>Before: your existing <code>CLAUDE.md</code>:</p> <pre><code># 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</code></pre> <p>After <code>ctx init --merge</code>:</p> <pre><code># 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</code></pre> <p>Your build commands and code style sections are untouched. The <code>ctx</code> block sits between markers and can be updated independently.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#the-force-flag","level":3,"title":"The <code>--force</code> Flag","text":"<p>If your <code>CLAUDE.md</code> already has <code>ctx</code> markers (from a previous <code>ctx init</code>), the default behavior is to skip it. Use <code>--force</code> to replace the <code>ctx</code> block with the latest template: This is useful after upgrading <code>ctx</code>:</p> <pre><code>ctx init --reset\n</code></pre> <p>This only replaces content between <code><!-- ctx:context --></code> and <code><!-- ctx:end --></code>. Your own content outside the markers is preserved. A timestamped backup is created before any changes.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#undoing-a-merge","level":3,"title":"Undoing a Merge","text":"<p>Every merge creates a backup:</p> <pre><code>$ ls CLAUDE.md*.bak\nCLAUDE.md.1738000000.bak\n</code></pre> <p>To restore:</p> <pre><code>cp CLAUDE.md.1738000000.bak CLAUDE.md\n</code></pre> <p>Or if you are using <code>git</code>, simply:</p> <pre><code>git checkout CLAUDE.md\n</code></pre>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#existing-cursorrules-aider-copilot","level":2,"title":"Existing <code>.cursorrules</code> / Aider / Copilot","text":"<p><code>ctx</code> doesn't touch tool-specific config files. It creates its own files (<code>.context/</code>, <code>CLAUDE.md</code>) and coexists with whatever you already have.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-does-ctx-create","level":3,"title":"What Does <code>ctx</code> Create?","text":"<code>ctx</code> creates <code>ctx</code> does NOT touch <code>.context/</code> directory <code>.cursorrules</code> <code>CLAUDE.md</code> (or merges into) <code>.aider.conf.yml</code> <code>.claude/settings.local.json</code> (seeded by <code>ctx init</code>; the plugin manages hooks and skills) <code>.github/copilot-instructions.md</code> <code>.windsurfrules</code> Any other tool-specific config <p>Claude Code hooks and skills are provided by the <code>ctx</code> plugin, installed from the Claude Code marketplace (<code>/plugin</code> → search \"<code>ctx</code>\" → Install).</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#running-ctx-alongside-other-tools","level":3,"title":"Running <code>ctx</code> Alongside Other Tools","text":"<p>The <code>.context/</code> directory is the source of truth. Tool-specific configs point to it:</p> <ul> <li>Cursor: Reference <code>.context/</code> files in your system prompt (see Cursor setup)</li> <li>Aider: Add <code>.context/</code> files to the <code>read:</code> list in <code>.aider.conf.yml</code> (see Aider setup)</li> <li>Copilot: Keep <code>.context/</code> files open or reference them in comments (see Copilot setup)</li> </ul> <p>You can generate a tool-specific configuration with:</p> <pre><code>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</code></pre>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#migrating-content-into-context","level":3,"title":"Migrating Content into <code>.context/</code>","text":"<p>If you have project knowledge scattered across <code>.cursorrules</code> or custom prompt files, consider migrating it:</p> <ol> <li>Rules / invariants → <code>.context/CONSTITUTION.md</code></li> <li>Code patterns → <code>.context/CONVENTIONS.md</code></li> <li>Architecture notes → <code>.context/ARCHITECTURE.md</code></li> <li>Known issues / tips → <code>.context/LEARNINGS.md</code></li> </ol> <p>You don't need to delete the originals: <code>ctx</code> and tool-specific files can coexist. But centralizing in <code>.context/</code> means every tool gets the same context.</p>","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":"<code>.context/</code> Is Designed to Be Committed","text":"<p>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.</p> <p><code>ctx init</code> automatically adds these <code>.gitignore</code> entries:</p> <pre><code># 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</code></pre> <p>With those in place, committing is straightforward:</p> <pre><code># 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</code></pre> <p>Teammates pull and immediately have context. No per-developer setup needed.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#what-about-claude","level":3,"title":"What about <code>.claude/</code>?","text":"<p>The <code>.claude/</code> directory contains permissions that <code>ctx init</code> seeds. Hooks and skills are provided by the <code>ctx</code> plugin (not per-project files).</p> File Commit? Why <code>.claude/settings.local.json</code> No Machine-specific, accumulates session permissions <code>.claude/settings.golden.json</code> Yes Curated permission snapshot (via <code>ctx permission snapshot</code>)","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#merge-conflicts-in-context-files","level":3,"title":"Merge Conflicts in Context Files","text":"<p>Context files are plain Markdown. Resolve conflicts the same way you would for any other documentation file:</p> <pre><code># 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</code></pre> <p>Common conflict scenarios:</p> <ul> <li>TASKS.md: Two people added tasks: Keep both.</li> <li>DECISIONS.md: Same decision recorded differently: Unify the entry.</li> <li>LEARNINGS.md: Parallel discoveries: Keep both, remove duplicates.</li> </ul>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#gradual-adoption","level":3,"title":"Gradual Adoption","text":"<p>You don't need the whole team to switch at once:</p> <ol> <li>One person runs <code>ctx init --merge</code> and commits;</li> <li><code>CLAUDE.md</code> instructions work immediately for Claude Code users;</li> <li>Other tool users can adopt at their own pace using <code>ctx setup <tool></code>;</li> <li>Context files benefit everyone who reads them, even without tool integration.</li> </ol>","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/#check-status","level":3,"title":"Check Status","text":"<p>Run subsequent commands from the project root (the directory that holds <code>.context/</code> and <code>.git/</code>); <code>ctx</code> reads <code>$PWD/.context/</code>.</p> <pre><code>ctx status\n</code></pre> <p>You should see your context files listed with token counts and no warnings.</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#test-memory","level":3,"title":"Test Memory","text":"<p>Start a new AI session and ask: \"Do you remember?\"</p> <p>The AI should cite specific context:</p> <ul> <li>Current tasks from <code>.context/TASKS.md</code>;</li> <li>Recent decisions or learnings;</li> <li>Session history (if you've had prior sessions);</li> </ul> <p>If it responds with generic \"I don't have memory\", check that <code>ctx</code> is in your PATH (<code>which ctx</code>) and that hooks are configured (see Troubleshooting).</p>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#verify-the-merge","level":3,"title":"Verify the Merge","text":"<p>If you used <code>--merge</code>, check that your original content is intact:</p> <pre><code># 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</code></pre>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/migration/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Getting Started: Full setup walkthrough</li> <li>Context Files: What each <code>.context/</code> file does</li> <li>Integrations: Per-tool setup (Claude Code, Cursor, Aider, Copilot)</li> <li>CLI Reference: All <code>ctx</code> commands and flags</li> </ul>","path":["Operations","Day-to-Day","Integration"],"tags":[]},{"location":"operations/release/","level":1,"title":"Cutting a Release","text":"<p>Full Release Checklist</p> <p>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.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#prerequisites","level":2,"title":"Prerequisites","text":"<p>Before you can cut a release you need:</p> <ul> <li>Push access to <code>origin</code> (GitHub)</li> <li>GPG signing configured (<code>make gpg-test</code>)</li> <li>Go installed (version in <code>go.mod</code>)</li> <li>Zensical installed (<code>make site-setup</code>)</li> <li>A clean working tree (<code>git status</code> shows nothing to commit)</li> </ul>","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":"<pre><code>echo \"0.9.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.9.0\"\n</code></pre> <p>The VERSION file uses bare semver (<code>0.9.0</code>), no <code>v</code> prefix. The release script adds the <code>v</code> prefix for git tags.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#2-generate-release-notes","level":3,"title":"2. Generate Release Notes","text":"<p>In Claude Code:</p> <pre><code>/_ctx-release-notes\n</code></pre> <p>This analyzes commits since the last tag and writes <code>dist/RELEASE_NOTES.md</code>. The release script refuses to proceed without this file.</p>","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":"<pre><code>/ctx-link-check # audit docs for dead links\nmake audit # full check: fmt, vet, lint, style, test\ngit status # must be clean\n</code></pre>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#4-run-the-release","level":3,"title":"4. Run the Release","text":"<pre><code>make release\n</code></pre> <p>Or, if you are in a Claude Code session:</p> <pre><code>/_ctx-release\n</code></pre> <p>The release script does everything in order:</p> Step What happens 1 Reads <code>VERSION</code>, 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 (<code>make site</code>) 7 Commits all version and docs updates 8 Runs <code>make test</code> and <code>make smoke</code> 9 Builds binaries for all 6 platforms via <code>hack/build-all.sh</code> 10 Creates a signed git tag (<code>v0.9.0</code>) 11 Pushes the tag to origin 12 Updates and pushes the <code>latest</code> 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":"<p>Pushing a <code>v*</code> tag triggers <code>.github/workflows/release.yml</code>:</p> <ol> <li>Checks out the tagged commit</li> <li>Runs the full test suite</li> <li>Builds binaries for all platforms</li> <li>Creates a GitHub Release with auto-generated notes</li> <li>Uploads binaries and SHA256 checksums</li> </ol>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#6-verify","level":3,"title":"6. Verify","text":"<ul> <li> GitHub Releases shows the new version</li> <li> All 6 binaries are attached (linux/darwin x amd64/arm64, windows x amd64)</li> <li> SHA256 files are attached</li> <li> Release notes look correct</li> </ul>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#what-gets-updated-automatically","level":2,"title":"What Gets Updated Automatically","text":"<p>The release script updates 8 files so you do not have to:</p> File What changes <code>internal/assets/claude/.claude-plugin/plugin.json</code> Plugin version <code>.claude-plugin/marketplace.json</code> Marketplace version (2 fields) <code>editors/vscode/package.json</code> VS Code extension version <code>editors/vscode/package-lock.json</code> VS Code lock version (2 fields) <code>docs/index.md</code> Download URLs <code>docs/home/getting-started.md</code> Download URLs <code>docs/operations/integrations.md</code> VSIX filename version <code>docs/reference/versions.md</code> New version row + latest pointer <p>The Go binary version is injected at build time via <code>-ldflags</code> from the VERSION file. No source file needs editing.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#build-targets-reference","level":2,"title":"Build Targets Reference","text":"Target What it does <code>make release</code> Full release (script + tag + push) <code>make build</code> Build binary for current platform <code>make build-all</code> Build all 6 platform binaries <code>make test</code> Unit tests <code>make smoke</code> Integration smoke tests <code>make audit</code> Full check (fmt + vet + lint + drift + docs + test) <code>make site</code> 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":"<pre><code>ERROR: dist/RELEASE_NOTES.md not found.\n</code></pre> <p>Run <code>/_ctx-release-notes</code> in Claude Code first, or write <code>dist/RELEASE_NOTES.md</code> manually.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#working-tree-is-not-clean","level":3,"title":"\"Working Tree Is Not Clean\"","text":"<pre><code>ERROR: Working tree is not clean.\n</code></pre> <p>Commit or stash all changes before running <code>make release</code>.</p>","path":["Operations","Maintainers","Cutting a Release"],"tags":[]},{"location":"operations/release/#tag-already-exists","level":3,"title":"\"Tag Already Exists\"","text":"<pre><code>ERROR: Tag v0.9.0 already exists.\n</code></pre> <p>You cannot release the same version twice. Either bump VERSION to a new version, or delete the old tag if the release was incomplete:</p> <pre><code>git tag -d v0.9.0\ngit push origin :refs/tags/v0.9.0\n</code></pre>","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":"<p>The tag is already published. Fix the issue, bump to a patch version (e.g. <code>0.9.1</code>), and release again. Do not force-push tags that others may have already fetched.</p>","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":"<p>New versions of <code>ctx</code> may ship updated permissions, <code>CLAUDE.md</code> directives, or plugin hooks and skills.</p> <p>Claude Code User?</p> <p>The marketplace can update skills, hooks, and prompts independently: <code>/plugin</code> → select <code>ctx</code> → Update now (or enable auto-update).</p> <p>The <code>ctx</code> binary is separate: rebuild from source or download a new release when one is available, then run <code>ctx init --reset --merge</code>. Knowledge files are preserved automatically.</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#tldr","level":2,"title":"TL:DR","text":"<pre><code># 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</code></pre>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#what-changes-between-versions","level":2,"title":"What Changes between Versions","text":"<p><code>ctx init</code> generates two categories of files:</p> Category Examples Changes between versions? Infrastructure <code>.claude/settings.local.json</code> (permissions), ctx-managed sections in <code>CLAUDE.md</code>, <code>ctx</code> plugin (hooks + skills) Yes Knowledge <code>.context/TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>, <code>ARCHITECTURE.md</code>, <code>GLOSSARY.md</code>, <code>CONSTITUTION.md</code>, <code>AGENT_PLAYBOOK.md</code> No: this is your data <p>Infrastructure is regenerated by <code>ctx init</code> and plugin updates. Knowledge files are yours and should never be overwritten.</p>","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":"<p>Build from source or download the binary:</p> <pre><code>cd /path/to/ctx-source\ngit pull\nmake build\nsudo make install\nctx --version # verify\n</code></pre>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#2-reinitialize","level":3,"title":"2. Reinitialize","text":"<pre><code>ctx init --reset --merge\n</code></pre> <ul> <li><code>--force</code> regenerates infrastructure files (permissions, ctx-managed sections in <code>CLAUDE.md</code>).</li> <li><code>--merge</code> preserves your content outside <code>ctx</code> markers.</li> </ul> <p>Knowledge files (<code>.context/TASKS.md</code>, <code>DECISIONS.md</code>, etc.) are preserved automatically: <code>ctx init</code> only overwrites infrastructure, never your data.</p> <p>Encryption key: The encryption key lives at <code>~/.ctx/.ctx.key</code> (outside the project). Reinit does not affect it. If you have a legacy key at <code>.context/.ctx.key</code> or <code>~/.local/ctx/keys/</code>, copy it manually (see Syncing Scratchpad Notes).</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#3-update-the-ctx-plugin","level":3,"title":"3. Update the <code>ctx</code> Plugin","text":"<p>If you use Claude Code, update the plugin to get new hooks and skills:</p> <ol> <li>Open <code>/plugin</code> in Claude Code.</li> <li>Select <code>ctx</code>.</li> <li>Click Update now.</li> </ol> <p>Or enable auto-update so the plugin stays current without manual steps.</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#4-review-custom-settings","level":3,"title":"4. Review Custom Settings","text":"<p>If you added custom permissions to <code>.claude/settings.local.json</code> beyond what <code>ctx init</code> provides, diff and merge:</p> <pre><code>diff .claude.bak/settings.local.json .claude/settings.local.json\n</code></pre> <p>Manually add back any custom entries that the new init dropped.</p>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#5-verify","level":3,"title":"5. Verify","text":"<p>Run from the project root (where <code>.context/</code> lives):</p> <pre><code>ctx status # context files intact\nctx drift # no broken references\n</code></pre>","path":["Operations","Day-to-Day","Upgrade"],"tags":[]},{"location":"operations/upgrading/#6-clean-up","level":3,"title":"6. Clean Up","text":"<p>If you made manual backups, remove them once satisfied:</p> <pre><code>rm -rf .context.bak .claude.bak CLAUDE.md.bak\n</code></pre>","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":"<p>The old binary still works with your existing <code>.context/</code> files. But you may miss:</p> <ul> <li>New plugin hooks that enforce better practices or catch mistakes;</li> <li>Updated skill prompts that produce better results;</li> <li>New <code>.gitignore</code> entries for directories added in newer versions;</li> <li>Bug fixes in the CLI itself.</li> </ul> <p>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.</p> <p>Context files are plain Markdown: They never break between versions.</p> <p>The surrounding infrastructure is what evolves.</p>","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":"<p>Systematically build architecture documentation across one or more repositories using <code>ctx</code> skills. Each invocation does one unit of work; a simple loop drives the agent through all phases.</p> <p>When to use: When onboarding to a new codebase, performing architecture reviews, or building up <code>.context/</code> documentation across a workspace of repos.</p> <p>Prerequisites: <code>ctx</code> installed, repos cloned under a shared workspace directory (e.g., <code>~/WORKSPACE/</code>).</p> <p>Companion skills:</p> <ul> <li><code>/ctx-architecture</code>: structural baseline and principal analysis</li> <li><code>/ctx-architecture-enrich</code>: code intelligence enrichment via a code-intelligence MCP (canonical: GitNexus)</li> <li><code>/ctx-architecture-failure-analysis</code>: adversarial failure analysis</li> </ul>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#overview","level":2,"title":"Overview","text":"<p>The agent progresses through phases per repo, depth-first:</p> Phase Skill What it does <code>bootstrap</code> <code>ctx init</code> + <code>/ctx-architecture</code> Initialize context and build structural baseline <code>principal</code> <code>/ctx-architecture principal</code> Deep analysis: vision, bottlenecks, alternatives <code>enriched</code> <code>/ctx-architecture-enrich</code> Quantify with code intelligence (blast radius, flows) <code>frontier-N</code> <code>/ctx-architecture</code> (re-run) Explore unexplored areas found in convergence report <code>lens-*</code> <code>/ctx-architecture</code> with lens Focused exploration through conceptual lenses <p>Exploration stops when convergence >= 0.85, frontier runs plateau, or all lenses are exhausted.</p>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#setup","level":2,"title":"Setup","text":"<p>Create a tracking directory in your workspace root:</p> <pre><code>cd ~/WORKSPACE\nmkdir -p .arch-explorer\n</code></pre> <p>Create <code>.arch-explorer/manifest.json</code> listing your repos:</p> <pre><code>{\n \"repos\": [\"ctx\", \"portal\", \"infra\"],\n \"current_repo_index\": 0,\n \"progress\": {}\n}\n</code></pre> <p>Create <code>.arch-explorer/run-log.md</code> (empty, the agent appends to it).</p>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#prompt","level":2,"title":"Prompt","text":"<p>Save this as <code>.arch-explorer/PROMPT.md</code> 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.</p> <pre><code>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, code-intelligence MCP indexed (canonical: GitNexus) |\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 `$PWD/.context/` exists for THIS sub-repo:\n\n ```bash\n test -d \"$PWD/.context\" || {\n echo \"STOP: no .context/ at $PWD. Re-launch the agent from\"\n echo \"this sub-repo's root:\"\n echo \" cd $PWD && claude --print 'Follow .arch-explorer/PROMPT.md' --allowedTools '*'\"\n exit 1\n }\n ```\n\n If it fails, STOP. `ctx` reads `$PWD/.context/`; the agent\n cannot change its own working directory after launch — only the\n caller controls it. Do not proceed, do not run `ctx` commands,\n 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 a code-intelligence MCP is connected. Canonical\n smoke test: `mcp__gitnexus__list_repos` (or the equivalent\n smoke test for your configured tool).\n - Success = non-empty list returned with no error.\n - If no code-intelligence MCP is available, log as\n `enriched-skipped` and advance 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 (no code-intelligence MCP\n connected, broken repo, etc.), log the failure with reason and\n 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</code></pre>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#invocation","level":2,"title":"Invocation","text":"<p>The caller MUST launch the agent with its working directory set to the sub-repo. The agent verifies this at Step 3.2 and stops if <code>$PWD/.context/</code> is missing. The wrapper reads the manifest to pick the current sub-repo, <code>cd</code>s into it, then launches <code>claude</code>.</p> <p>Single run (safest for quota):</p> <pre><code>cd ~/WORKSPACE\nREPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\ncd \"$REPO\" && \\\n claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*'\n</code></pre> <p>Batch of N runs:</p> <pre><code>cd ~/WORKSPACE\nfor i in $(seq 1 5); do\n REPO=$(jq -r '.repos[.current_repo_index]' .arch-explorer/manifest.json)\n (cd \"$REPO\" && \\\n claude --print \"Follow .arch-explorer/PROMPT.md\" --allowedTools '*')\n echo \"--- Run $i complete (repo: $REPO) ---\"\ndone\n</code></pre> <p>Resume after interruption:</p> <p>Just run the wrapper again. The manifest tracks state; the agent picks up where it left off. The sub-repo directory is recomputed from the manifest on each invocation, so the agent is always anchored at the right project root.</p>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#tips","level":2,"title":"Tips","text":"<ul> <li>Start small: list 1-2 repos in the manifest first. Add more once you're confident in the output quality.</li> <li>The code-intelligence MCP is optional: the enrichment phase is skipped gracefully if no such MCP is connected (canonical: GitNexus; equivalents work). You still get structural and principal analysis.</li> <li>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.</li> <li>Lens runs are the payoff: the first three phases build the map; lens runs find the interesting things (security gaps, performance cliffs, stability risks).</li> </ul>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/architecture-exploration/#history","level":2,"title":"History","text":"<ul> <li>2026-04-07: Original prompt created as <code>hack/agents/architecture-explorer.md</code>.</li> <li>2026-04-16: Moved to docs as a runbook for discoverability.</li> <li>2026-04-20: Added per-invocation working-directory pinning in the wrapper (formerly via <code>CTX_DIR</code>; now via <code>cd \"$REPO\"</code>), so the agent writes artifacts to the sub-repo's <code>.context/</code> instead of the inherited workspace one.</li> </ul>","path":["Operations","Runbooks","Architecture Exploration"],"tags":[]},{"location":"operations/runbooks/audit-channel/","level":1,"title":"Out-of-Band Audit Channel","text":"","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#the-problem","level":2,"title":"The Problem","text":"<p>The agent that just shipped a feature is the worst possible reviewer of its own discipline. It will mark its own work complete, label deferred docs as \"Phase 2,\" and skip past its own CONVENTIONS.md rule with conviction. Mid-task tunnel vision suppresses the rules it read at session start.</p> <p>You cannot fix that with more advisory prose: the same convention that didn't stop the agent the first time won't stop the next agent either. What works is mechanical verbatim relay — the same channel ctx already uses for <code>ctx remind</code>, journal-import nudges, and knowledge-growth warnings. Agents echo those without filtering, every turn, because the relay bypasses judgment.</p> <p>This runbook shows how to run discipline audits out of band (from a separate Claude Code session, on your plan-billed subscription, not the working session's API) and drop their findings onto the verbatim-relay channel so the next interactive session sees them at the top of its next turn.</p> <p>Maintainer tooling: lives in <code>ctxctl</code>, not the shipped <code>ctx</code> binary</p> <p><code>ctxctl audit</code> and the <code>ctxctl audit-relay</code> hook are the generic relay half: a place for any out-of-band tool to drop a report and have it relayed. They live in <code>ctxctl</code> — ctx's separate maintainer/contributor binary — not in the user-facing <code>ctx</code> binary, so end users never carry an audit hook they have no producer for. The auditor that produces the report is project-specific — it must know your conventions and directory layout. ctx dogfoods its own internal auditor (<code>_ctx-surface-audit</code>, a repo-only skill that scans ctx's <code>internal/</code> tree); the examples below use it as a concrete reference. To adopt the pattern in your own project, build the same out-of-band relay plus your own audit skill. ctx maintainers build and install <code>ctxctl</code> once with <code>make reinstall-ctxctl</code> (→ <code>/usr/local/bin/ctxctl</code>); every worktree then shares the one binary.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#tldr","level":2,"title":"TL;DR","text":"<pre><code># 1. From a separate Claude Code session, run your project's\n# audit skill (ctx's own internal example shown here):\n/_ctx-surface-audit # default: main..HEAD\n\n# 2. It writes a structured report:\n.context/audit/surface.md\n\n# 3. Back in the working session, the next prompt fires the\n# repo-local UserPromptSubmit hook (wired in\n# .claude/settings.local.json, not by `ctx setup`):\nctxctl audit-relay\n\n# 4. The agent / human sees a verbatim-relay box on the next\n# response, listing the specific findings.\n\n# 5. After addressing the findings:\nctxctl audit dismiss surface # stops the relay\n</code></pre>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>ctxctl audit list</code> CLI command Show all reports with status and age <code>ctxctl audit show ID</code> CLI command Print one report's body, pipe-friendly <code>ctxctl audit dismiss ID</code> CLI command Mark a report dismissed against its current digest <code>ctxctl audit dismiss --all</code> CLI command Bulk dismissal <code>ctxctl audit-relay</code> CLI command UserPromptSubmit hook; verbatim-relays reports <code>_ctx-surface-audit</code> Skill ctx's own internal auditor — reference example, not bundled","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#why-a-separate-session","level":2,"title":"Why a Separate Session","text":"<p>Two reasons, both load-bearing:</p> <ol> <li>Fresh-context judgment. The auditor must not inherit the implementer's working memory of \"what we tried, what we decided to defer, why this is fine.\" The audit only works if the reviewer reads the diff cold.</li> <li>Cost shape. A per-commit AI gate burns API tokens on every commit, regardless of branch maturity. Running the auditor manually from a separate Claude Code session bills against your interactive plan, not the API, and lets you decide when to spend the cycles (typically right before a PR, not on every micro-commit).</li> </ol> <p>The <code>/_ctx-surface-audit</code> skill enforces this with a hard dirty-tree refusal: invoking it in a working session with uncommitted changes returns</p> <p>Run this audit from a separate Claude Code session.</p> <p>There is no override flag, by design.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-1-land-your-work-then-open-a-second-session","level":3,"title":"Step 1: Land Your Work, Then Open a Second Session","text":"<p>Finish the feature on your working branch (commit, lint, test). Open a second Claude Code window in the same project worktree. The audit runs against <code>main..HEAD</code> by default.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-2-invoke-the-auditor","level":3,"title":"Step 2: Invoke the Auditor","text":"<pre><code>You (in session 2): \"/_ctx-surface-audit\"\n\nSkill: \"Scanned 4 commits, 3 surfaces detected.\n Wrote .context/audit/surface.md (status: findings).\n Open a working session — the audit-relay hook will\n relay the findings on the next prompt.\"\n</code></pre> <p>The auditor compares the branch against <code>main</code>, finds new subcommands / flags / behavior changes, checks each one against SKILL.md / recipe / <code>docs/cli</code> coverage, and writes a structured report.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-3-return-to-the-working-session","level":3,"title":"Step 3: Return to the Working Session","text":"<p>The next time you submit a prompt in your working session, the <code>ctxctl audit-relay</code> hook (a UserPromptSubmit hook wired in the repo-local <code>.claude/settings.local.json</code> — maintainer- only; <code>ctx setup</code> does not install it) reads <code>.context/audit/</code> and emits a verbatim-relay box at the top of the agent's response:</p> <pre><code>┌─ Audit Reports ──────────────────────────────────────\n│ [surface] main..HEAD\n│ Commit 6bcaf889 added user-facing surface without docs:\n│\n│ • New subcommand `ctx pad undo`\n│ - SKILL.md: internal/assets/claude/skills/ctx-pad/SKILL.md\n│ command-mapping table is missing the row\n│ - Recipe: docs/recipes/scratchpad-with-claude.md unchanged\n│\n│ Fix:\n│ - edit internal/assets/claude/skills/ctx-pad/SKILL.md\n│ - edit docs/recipes/scratchpad-with-claude.md\n│\n│ Dismiss: ctxctl audit dismiss <id>\n│ Dismiss all: ctxctl audit dismiss --all\n└──────────────────────────────────────────────────\n</code></pre> <p>The agent echoes this verbatim — that is the discipline mechanism. You (or the agent) then address each cited file.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#step-4-dismiss","level":3,"title":"Step 4: Dismiss","text":"<p>Once you've addressed the findings (or accepted them as out-of-scope), dismiss the report:</p> <pre><code>ctxctl audit dismiss surface\n</code></pre> <p>Dismissal is bound to the report digest at dismiss time. A subsequent audit that produces the same findings stays dismissed. A subsequent audit that finds new surface drift produces a fresh digest and re-surfaces the report at the next prompt.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#retention","level":2,"title":"Retention","text":"<p>The audit channel keeps one report per kind. Re-running <code>/_ctx-surface-audit</code> overwrites the prior <code>surface.md</code>. Reports older than 30 days are still relayed but prefixed with a <code>STALE — main..HEAD (audited 32d ago)</code> marker so the recipient knows the assessment may not match current code.</p> <p>History (which audits ran when) is preserved by the dismissal ledger at <code>.context/audit/.dismissed.json</code>. The ledger lives next to the reports — not under <code>.context/state/</code> — so nuking session state never silently re-surfaces a dismissed audit.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#when-to-run-the-auditor","level":2,"title":"When to Run the Auditor","text":"<ul> <li>Before opening a PR. The natural cadence. The audit exists to catch the gaps you can't see in your own branch.</li> <li>After landing a multi-commit feature. Especially when the feature added new subcommands or flags.</li> <li>Periodically on <code>main</code>, with a longer range like <code>HEAD~50..HEAD</code>, to catch surface drift that crept in before this channel existed.</li> </ul> <p>There is no automated trigger in Phase 1. The cost shape is intentional: cron and post-commit-hook drivers stay on the deferred list until the user-driven workflow proves out.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#other-audit-skills","level":2,"title":"Other Audit Skills","text":"<p><code>_ctx-surface-audit</code> is the first of a family of ctx's own internal auditors (all <code>_</code>-prefixed, repo-only). The scaffolding they share — channel, ledger, hook, CLI — lives in the maintainer-only <code>ctxctl</code> binary; the auditors themselves are repo-only skills. Planned siblings under the same shape:</p> <ul> <li><code>_ctx-spec-trailer-audit</code> — does each commit's <code>Spec:</code> trailer point at a spec that genuinely covers that commit's scope?</li> <li><code>_ctx-capture-audit</code> — was a Decision or Learning persisted for non-trivial work that ended without one?</li> </ul> <p>Each lives in its own SKILL.md and writes its own report file (e.g. <code>.context/audit/spec-trailer.md</code>). The hook relays whatever it finds, with no per-kind plumbing — which is exactly what lets your project's auditors plug in without touching ctx.</p>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/audit-channel/#see-also","level":2,"title":"See Also","text":"<ul> <li>Spec: out-of-band audit channel: full design rationale + Open Questions</li> <li>CONVENTIONS → User-Facing Surface Completeness: the canonical rule the surface audit enforces</li> <li>Detecting and Fixing Drift: programmatic drift detection that complements judgment-based audits</li> </ul>","path":["Operations","Runbooks","Out-of-Band Audit Channel"],"tags":[]},{"location":"operations/runbooks/backup-strategy/","level":1,"title":"Backup Strategy","text":"<p><code>ctx backup</code> was removed. File-level backup is not <code>ctx</code>'s responsibility; your OS or a dedicated backup tool handles it better and without locking you into a specific mount strategy.</p> <p>This runbook explains what to back up, how <code>ctx hub</code> reduces the surface, and what options exist for the rest.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-to-back-up","level":2,"title":"What To Back Up","text":"<p>Per project:</p> <ul> <li><code>.context/</code>: all context files, journal, state, scratchpad.</li> <li><code>.claude/</code>: Claude Code settings, hooks, skills specific to the project. Skip this entry when it lives in git; the repo is the backup.</li> </ul> <p>Per user:</p> <ul> <li><code>~/.ctx/</code>: global config, the encryption key (<code>~/.ctx/.ctx.key</code>), hub data directory (if running a local hub).</li> </ul>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#how-hub-reduces-backup-needs","level":2,"title":"How Hub Reduces Backup Needs","text":"<p><code>ctx hub</code> replicates the knowledge surface across machines:</p> <ul> <li><code>DECISIONS.md</code></li> <li><code>LEARNINGS.md</code></li> <li><code>CONVENTIONS.md</code></li> <li><code>CONSTITUTION.md</code></li> <li><code>ARCHITECTURE.md</code></li> <li>Task items promoted to hub</li> </ul> <p>If you run <code>ctx hub</code> (as a server or by subscribing to someone else's), the data that matters most survives losing any single machine.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#what-hub-does-not-replicate","level":2,"title":"What Hub Does Not Replicate","text":"<p>Hub is not a file-level backup. The following still live only on the machine that produced them:</p> <ul> <li>Journal entries (<code>.context/journal/*.md</code>)</li> <li>Runtime state (<code>.context/state/*</code>)</li> <li>Session event log (<code>.context/events.jsonl</code>)</li> <li>Scratchpad (<code>.context/.pad</code>)</li> <li>Encrypted notify/webhook config (<code>.context/.notify.enc</code>)</li> <li>The encryption key itself (<code>~/.ctx/.ctx.key</code>)</li> </ul> <p>If you need those to survive a disk failure, use a file-level backup.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#example-strategies","level":2,"title":"Example Strategies","text":"","path":["Operations","Runbooks","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":"<pre><code># 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</code></pre> <p>Adjust excludes for the trash you don't want to back up. The <code>.context/state/</code> dir is ephemeral per-session; skip it.</p>","path":["Operations","Runbooks","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":"<p>iCloud Drive, Dropbox, or any directory watched by a sync client:</p> <pre><code>0 3 * * * cp -a ~/WORKSPACE/some-project/.context \\\n ~/CloudDrive/ctx-backups/some-project/$(date +\\%Y-\\%m-\\%d)\n</code></pre> <p>Daily snapshots, cloud provider handles the replication.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#3-time-machine-macos","level":3,"title":"3. Time Machine (macOS)","text":"<p>If you already run Time Machine, ensure <code>~/WORKSPACE</code> and <code>~/.ctx</code> are not in its exclusion list. Time Machine handles versioning; you get point-in-time recovery for free.</p>","path":["Operations","Runbooks","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":"<p>For deduplicated, versioned, encrypted backups:</p> <pre><code># 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</code></pre> <p>Use <code>restic</code> if you prefer S3-compatible targets.</p>","path":["Operations","Runbooks","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":"<ul> <li>Journal: session histories are local-only until exported.</li> <li>Scratchpad: private notes, encrypted locally.</li> <li>Encryption key: losing <code>~/.ctx/.ctx.key</code> means losing access to every encrypted file in every project.</li> <li>Non-hub projects: projects that never called <code>ctx hub register</code> have zero cross-machine persistence.</li> </ul> <p>For these, pick one strategy above and forget about it.</p>","path":["Operations","Runbooks","Backup Strategy"],"tags":[]},{"location":"operations/runbooks/backup-strategy/#why-ctx-no-longer-ships-a-backup-command","level":2,"title":"Why <code>ctx</code> No Longer Ships a Backup Command","text":"<p>Backup is inherently environment-specific: SMB, NFS, S3, rsync, Time Machine, Borg, restic. Every user has a different story. The previous <code>ctx backup</code> picked SMB via GVFS, which was Linux-only and narrow. Chasing mount strategies would never generalize.</p> <p>Hub is the right answer for the data <code>ctx</code> owns (knowledge). For everything else, your OS or a dedicated backup tool is the right layer.</p>","path":["Operations","Runbooks","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":"<p>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.</p> <p>When to use: When a release includes breaking changes (command renames, removed flags, changed defaults) that require user action.</p> <p>Companion: Upgrade guide covers the general upgrade flow. This runbook covers the breaking-change specifics.</p>","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":"<p>Ask your agent to diff the CLI surface between the old and new version:</p> <pre><code>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</code></pre> <p>Or use the <code>/_ctx-command-audit</code> skill after the rename.</p>","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-2-regenerate-infrastructure","level":2,"title":"Step 2: Regenerate Infrastructure","text":"<pre><code># Install the new binary\nmake build && sudo make install\n\n# Regenerate CLAUDE.md and permissions\nctx init --reset --merge\n</code></pre> <p><code>--merge</code> preserves your knowledge files (TASKS.md, DECISIONS.md, etc.) while regenerating infrastructure (permissions, CLAUDE.md managed sections).</p>","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":"<pre><code>/plugin -> select ctx -> Update now\n</code></pre> <p>Or, if using a local clone:</p> <pre><code>make plugin-reload\n# restart Claude Code\n</code></pre>","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":"<p>Search your scripts and aliases for old command names:</p> <pre><code># Example: find references to old command names\ngrep -r \"ctx old-command\" ~/scripts/ ~/.zshrc ~/.bashrc\n</code></pre> <p>Replace with the new names per the changelog.</p>","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":"<p>If you have custom hooks in <code>.claude/settings.local.json</code> that reference <code>ctx</code> commands, update them:</p> <pre><code>jq '.hooks' .claude/settings.local.json | grep \"ctx \"\n</code></pre>","path":["Operations","Runbooks","Breaking Migration"],"tags":[]},{"location":"operations/runbooks/breaking-migration/#step-6-verify","level":2,"title":"Step 6: Verify","text":"<p>Run from the project root:</p> <pre><code>ctx status # context files intact\nctx drift # no broken references\nmake test # if you're a contributor\n</code></pre>","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":"<p>When preparing a release with breaking changes, create a section in the release notes using this template:</p> <pre><code>## 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</code></pre> <p>Repeat for each breaking change. Users should be able to follow the notes mechanically without needing to understand the codebase.</p>","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":"<p>A structured audit of the codebase: dead code, magic strings, documentation drift, security surface, and roadmap opportunities.</p> <p>When to run: Before a release, after a long YOLO sprint, quarterly, or when planning the next phase of work.</p> <p>Time: ~15-30 minutes with a team of agents.</p>","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":"<p>Start a Claude Code session with a clean git state (<code>git stash</code> or commit first). Paste or adapt the prompt below. The agent does the analysis; you triage the findings.</p>","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#prompt","level":2,"title":"Prompt","text":"<pre><code>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</code></pre>","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#tips","level":2,"title":"Tips","text":"<ul> <li> <p>Clean state matters: the prompt says \"no code changes\" but accidents happen. Start from a clean git state so you can <code>git checkout .</code> if needed.</p> </li> <li> <p>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.</p> </li> <li> <p>Reports feed TASKS.md: after the audit, read each report and create tasks in the appropriate Phase section. The reports are input, not output.</p> </li> <li> <p>ideas/ is gitignored: reports saved there won't be committed. Move specific findings to TASKS.md, DECISIONS.md, or LEARNINGS.md to persist them.</p> </li> </ul>","path":["Operations","Runbooks","Codebase Audit"],"tags":[]},{"location":"operations/runbooks/codebase-audit/#history","level":2,"title":"History","text":"<ul> <li>2026-02-08: Original prompt created after a codebase audit sprint.</li> <li>2026-02-17: Improved with read-only agents, report structure template, CLI-scoped security review, and maintainability thresholds.</li> <li>2026-04-16: Moved from <code>hack/runbooks/</code> to <code>docs/operations/runbooks/</code>.</li> </ul>","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":"<p>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.</p> <p>When to run: Before a release, after adding several new pages, when the site feels sprawling, or when you suspect narrative gaps.</p> <p>Time: ~20-40 minutes with an agent session.</p>","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":"<p>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.</p>","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#prompt","level":2,"title":"Prompt","text":"<p>Paste or adapt the following into a Claude Code session. The agent needs read access to <code>docs/</code> and the site nav structure.</p> <pre><code>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</code></pre>","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#after-the-audit","level":2,"title":"After the Audit","text":"<ol> <li>Triage findings: not everything needs fixing. Focus on high severity.</li> <li>Merge weak pages first: fewer pages is almost always better.</li> <li>Add cross-links: cheapest improvement, highest reader impact.</li> <li>File split decisions in DECISIONS.md: page splits are architectural.</li> <li>Regenerate the site and spot-check nav after structural changes.</li> </ol>","path":["Operations","Runbooks","Docs Semantic Audit"],"tags":[]},{"location":"operations/runbooks/docs-semantic-audit/#history","level":2,"title":"History","text":"<ul> <li>2026-02-17: Created after merging <code>docs/re-explaining.md</code> into <code>docs/about.md</code>, which surfaced the pattern of weak standalone pages that dilute rather than add.</li> <li>2026-04-16: Moved from <code>hack/runbooks/</code> to <code>docs/operations/runbooks/</code>.</li> </ul>","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":"<p>Linear runbook for setting up a <code>ctx</code> Hub for yourself or a team. Consolidates pieces currently scattered across hub recipes and operations docs.</p> <p>When to use: First-time hub setup, or when onboarding a new team onto an existing hub.</p> <p>Prerequisites: <code>ctx</code> binary installed, network connectivity between hub and clients.</p> <p>Companion docs:</p> <ul> <li>Hub overview: what the hub is and is not</li> <li>Hub operations: data directory, systemd, backup, monitoring</li> <li>Hub failure modes: what can go wrong</li> </ul>","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) <pre><code>ctx hub start\n</code></pre> <p>See Hub Operations: Systemd Unit for the full unit file.</p> <pre><code>sudo systemctl enable --now ctx-hub\n</code></pre> <p>The hub creates <code>admin.token</code> on first start. Save this token; it is the only way to register clients.</p>","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":"<p>On first start, the hub writes <code>admin.token</code> to the data directory (default <code>~/.ctx/hub-data/</code>):</p> <pre><code>cat ~/.ctx/hub-data/admin.token\n</code></pre> <p>This token has full admin privileges. Keep it secret.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-3-register-clients","level":2,"title":"Step 3: Register Clients","text":"<p>For each client (person or machine) that will connect:</p> <pre><code># On the hub machine\nctx hub register --name \"volkan-laptop\" --admin-token <admin-token>\n</code></pre> <p>This returns a client token. Distribute it securely to the client.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-4-connect-clients","level":2,"title":"Step 4: Connect Clients","text":"<p>On each client machine, register the project with the hub. The <code>ctx hub *</code> commands above run on the hub server itself and don't need a project. The <code>ctx connection *</code> commands below are different: they live inside a project (the encrypted hub config is stored at <code>.context/.connect.enc</code>), so you have to tell <code>ctx</code> which project first.</p> <pre><code># In the project directory on the client machine:\nctx connection register <hub-address> --token <client-token>\n</code></pre> <p>Verify the connection:</p> <pre><code>ctx connection status\n</code></pre> <p>If the client doesn't have a project yet, run <code>ctx init</code> first in the project root.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-5-verify-sync","level":2,"title":"Step 5: Verify Sync","text":"<p>Push a test entry from one client and verify it arrives. Run each command on the client from inside the project directory; <code>ctx</code> reads <code>$PWD/.context/</code>.</p> <pre><code># 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</code></pre>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#step-6-configure-backup","level":2,"title":"Step 6: Configure Backup","text":"<p>Set up regular backups of the hub data directory. See Hub Operations: Backup and Restore.</p> <p>Minimum:</p> <pre><code># Add to cron\n0 */6 * * * cp ~/.ctx/hub-data/entries.jsonl ~/backups/entries-$(date +\\%F).jsonl\n</code></pre>","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":"<p>Coming Soon</p> <p>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.</p>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#team-onboarding-checklist","level":2,"title":"Team Onboarding Checklist","text":"<p>When adding a new team member to an existing hub:</p> <ul> <li> Generate a client token (<code>ctx hub register --name \"<name>\"</code>)</li> <li> Share the token and hub address securely</li> <li> Have them run <code>ctx connection register <hub-address> --token <token></code></li> <li> Verify with <code>ctx connection status</code></li> <li> Point them to the Hub Getting Started recipe</li> </ul>","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":"<p>The hub isn't running or the port is wrong. Check:</p> <pre><code>ctx hub status # on the hub machine\nss -tlnp | grep 9900 # default port\n</code></pre>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#authentication-failed","level":3,"title":"\"Authentication Failed\"","text":"<p>The client token is wrong or was never registered. Re-register:</p> <pre><code>ctx hub register --name \"<name>\" --admin-token <admin-token>\n</code></pre>","path":["Operations","Runbooks","Hub Deployment"],"tags":[]},{"location":"operations/runbooks/hub-deployment/#entries-not-syncing","level":3,"title":"Entries Not Syncing","text":"<p>Check that the client is listening:</p> <pre><code>ctx connection status\n</code></pre> <p>If connected but not syncing, check the hub logs for sequence mismatch errors. See Hub Failure Modes for details.</p>","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":"<p>Step-by-step onboarding sequence for new contributors. Consolidates setup instructions currently scattered across the README, contributing guide, and setup docs.</p> <p>When to use: First-time contributor setup, or when verifying your development environment after a major upgrade.</p>","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":"<pre><code>git clone https://github.com/ActiveMemory/ctx.git\ncd ctx\n</code></pre> <p>Or fork first on GitHub, then clone your fork.</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-2-initialize-context","level":2,"title":"Step 2: Initialize Context","text":"<pre><code>ctx init\n</code></pre> <p><code>ctx init</code> creates the <code>.context/</code> directory with knowledge files and the <code>.claude/</code> directory with agent configuration. Run subsequent <code>ctx</code> commands from the project root; <code>ctx</code> reads <code>$PWD/.context/</code>.</p> <p>If <code>ctx</code> is not yet installed, proceed to Step 3 first, then come back.</p>","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":"<pre><code>make build\nsudo make install\n</code></pre> <p>Verify:</p> <pre><code>ctx --version\n</code></pre>","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":"<p>If you use Claude Code, install the plugin from your local clone so skills and hooks reflect your working tree:</p> <ol> <li>Launch <code>claude</code></li> <li>Type <code>/plugin</code> and press Enter</li> <li>Select Marketplaces -> Add Marketplace</li> <li>Enter the absolute path to your clone (e.g., <code>~/WORKSPACE/ctx</code>)</li> <li>Back in <code>/plugin</code>, select Install and choose <code>ctx</code></li> </ol> <p>Verify:</p> <pre><code>claude /plugin list # should show ctx\n</code></pre> <p>See Contributing: Install the Plugin for details on cache clearing.</p>","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":"<pre><code>ctx config switch dev\n</code></pre> <p>This enables verbose logging and notify events (useful during development).</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-6-verify-hooks","level":2,"title":"Step 6: Verify Hooks","text":"<p>Start a Claude Code session and check that hooks fire:</p> <pre><code>claude\n</code></pre> <p>You should see <code>ctx</code> session hooks (ceremonies reminder, context loading) on session start. If not, check that the plugin is installed correctly (Step 4).</p>","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":"<p>In Claude Code:</p> <pre><code>/ctx-status\n</code></pre> <p>This should show context file health, active tasks, and recent decisions. If it works, your setup is complete.</p>","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":"<p>End the session and start a new one:</p> <pre><code>/ctx-remember\n</code></pre> <p>The agent should recall what happened in the previous session. This confirms that context persistence is working end-to-end.</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#step-9-run-tests","level":2,"title":"Step 9: Run Tests","text":"<pre><code>make test # unit tests\nmake audit # full check: fmt + vet + lint + drift + docs + test\n</code></pre> <p>All tests should pass with a clean clone.</p>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#quick-reference","level":2,"title":"Quick Reference","text":"Task Command Build <code>make build</code> Install <code>sudo make install</code> Test <code>make test</code> Full audit <code>make audit</code> Rebuild docs site <code>make site</code> Serve docs locally <code>make site-serve</code> Clear plugin cache <code>make plugin-reload</code> Switch config profile <code>ctx config switch dev</code>","path":["Operations","Runbooks","New Contributor"],"tags":[]},{"location":"operations/runbooks/new-contributor/#next-steps","level":2,"title":"Next Steps","text":"<ul> <li>Read the contributing guide for project layout, code style, and PR process</li> <li>Check TASKS.md for open work items</li> <li>Ask <code>/ctx-next</code> for suggested work</li> </ul>","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":"<p>Plugin-specific release procedure. The general release checklist covers the full <code>ctx</code> release; this runbook covers the plugin-specific steps that are not part of that flow.</p> <p>When to use: When releasing plugin changes (new skills, hook updates, permission changes) independently of a <code>ctx</code> binary release, or as a sub-procedure within the full release.</p>","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":"<p>The plugin lives at <code>internal/assets/claude/</code> and includes:</p> Component Path What it does Skills <code>internal/assets/claude/skills/</code> User-facing <code>/ctx-*</code> slash commands Hooks <code>internal/assets/claude/hooks/</code> Pre/post tool-use hooks Plugin manifest <code>internal/assets/claude/.claude-plugin/plugin.json</code> Declares skills, hooks, version Marketplace <code>.claude-plugin/marketplace.json</code> 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":"<p>If you added, removed, or modified hooks:</p> <pre><code># Verify hook definitions match implementations\nmake audit\n</code></pre> <p>Check that <code>plugin.json</code> lists all hooks correctly. Missing hooks silently fail to fire.</p>","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#step-2-bump-version","level":2,"title":"Step 2: Bump Version","text":"<p>Update the version in three places:</p> <ul> <li><code>internal/assets/claude/.claude-plugin/plugin.json</code></li> <li><code>.claude-plugin/marketplace.json</code> (two fields)</li> <li><code>editors/vscode/package.json</code> + <code>package-lock.json</code> (if VS Code extension is affected)</li> </ul> <p>The Release Script Does This</p> <p>If you're running <code>make release</code>, the script bumps these automatically from <code>VERSION</code>. Only bump manually if you're releasing the plugin independently.</p>","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":"<pre><code># Clear cached plugin\nmake plugin-reload\n\n# Restart Claude Code, then:\nclaude /plugin list # verify version\n</code></pre> <p>Test the critical paths:</p> <ul> <li> <code>/ctx-status</code> works</li> <li> Session hooks fire (ceremonies, context loading)</li> <li> At least one user-facing skill works end-to-end</li> <li> Pre-tool-use hooks block when they should</li> </ul>","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":"<p>Create a temporary project to verify the plugin works outside the <code>ctx</code> repo:</p> <pre><code>mkdir /tmp/test-ctx-plugin && cd /tmp/test-ctx-plugin\ngit init\nctx init\nclaude # start a session, verify hooks fire\n</code></pre>","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":"<p>The plugin manifest declares all user-invocable skills. Verify the count matches:</p> <pre><code># 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</code></pre> <p>These numbers should match (some skills are not user-invocable and won't appear in both counts).</p>","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":"<p>If releasing independently of a binary release:</p> <pre><code>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</code></pre> <p>If part of a full release, the release checklist handles this.</p>","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":"<p>Claude Code caches plugin files aggressively:</p> <pre><code>make plugin-reload # clears cache\n# restart Claude Code\n</code></pre>","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#hooks-dont-fire","level":3,"title":"Hooks Don't Fire","text":"<p>Check that the hook is registered in <code>plugin.json</code> and that the command it calls exists:</p> <pre><code>jq '.hooks' internal/assets/claude/.claude-plugin/plugin.json\n</code></pre>","path":["Operations","Runbooks","Plugin Release"],"tags":[]},{"location":"operations/runbooks/plugin-release/#version-mismatch","level":3,"title":"Version Mismatch","text":"<p>If <code>claude /plugin list</code> shows an old version after updating:</p> <pre><code>make plugin-reload\n# restart Claude Code\nclaude /plugin list # should show new version\n</code></pre>","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":"<p>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.</p> <p>When to run: Before every release. No exceptions.</p> <p>Companion: The <code>/_ctx-release</code> skill automates the tag-and-push portion; this checklist covers everything before and after that automation.</p>","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":"<p>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.</p>","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":"<p>Use the docs semantic audit runbook prompt. Fix high-severity findings (weak pages, broken narrative arcs). Medium-severity items can be deferred.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#3-sanitize-permissions","level":3,"title":"3. Sanitize Permissions","text":"<p>Follow the sanitize permissions runbook. Clean up <code>.claude/settings.local.json</code> before it gets committed as part of the release.</p>","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":"<pre><code>make audit # fmt + vet + lint + drift + docs + test\nmake smoke # integration smoke tests\n</code></pre> <p>All tests must pass. No exceptions.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#5-check-context-health","level":3,"title":"5. Check Context Health","text":"<p>Run from the project root:</p> <pre><code>ctx drift # broken references, stale patterns\nctx status # context file health\n/ctx-link-check # dead links in docs\n</code></pre> <p>Fix anything flagged.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#6-review-tasksmd","level":3,"title":"6. Review TASKS.md","text":"<p>Scan for incomplete tasks tagged as release-blocking. Either finish them or explicitly defer with a reason in the task note.</p>","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":"<pre><code>echo \"0.X.0\" > VERSION\ngit add VERSION\ngit commit -m \"chore: bump version to 0.X.0\"\n</code></pre>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#8-generate-release-notes","level":3,"title":"8. Generate Release Notes","text":"<p>In Claude Code:</p> <pre><code>/_ctx-release-notes\n</code></pre> <p>Review <code>dist/RELEASE_NOTES.md</code>. Ensure it captures all user-visible changes.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#9-cut-the-release","level":3,"title":"9. Cut the Release","text":"<pre><code>make release\n</code></pre> <p>Or in Claude Code: <code>/_ctx-release</code>. See Cutting a Release for the full step-by-step.</p>","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":"<ul> <li> GitHub Releases shows the new version</li> <li> All 6 binaries are attached</li> <li> SHA256 checksums are attached</li> <li> Release notes render correctly</li> </ul>","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":"<p>If the plugin version changed, verify the marketplace entry:</p> <pre><code>claude /plugin list # shows updated version\n</code></pre>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#12-announce","level":3,"title":"12. Announce","text":"<p>Post in the project's communication channels. Reference the release notes.</p>","path":["Operations","Runbooks","Release Checklist"],"tags":[]},{"location":"operations/runbooks/release-checklist/#13-clean-up","level":3,"title":"13. Clean Up","text":"<pre><code>rm dist/RELEASE_NOTES.md # consumed by the release script\ngit stash pop # if you stashed earlier\n</code></pre>","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":"<p>Manual procedure for cleaning up <code>.claude/settings.local.json</code>. The agent may analyze and recommend, but you make every edit.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#why-manual-not-automated","level":2,"title":"Why Manual, Not Automated","text":"<p><code>settings.local.json</code> 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.</p> <p>When to run: After busy sessions where you clicked \"Allow\" many times, weekly hygiene (pair with <code>ctx drift</code>), or before committing <code>.claude/settings.local.json</code>.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-1-snapshot","level":2,"title":"Step 1: Snapshot","text":"<pre><code>cp .claude/settings.local.json /tmp/settings-backup-$(date +%Y%m%d).json\n</code></pre>","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":"<pre><code>jq '.permissions.allow[]' .claude/settings.local.json | sort\n</code></pre> <p>Eyeball it. You're looking for four categories:</p>","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":"<p>Entries that are clearly broken or meaningless:</p> <pre><code>Bash(done)\nBash(__NEW_LINE_aa838494a90279c4__ echo \"\")\n</code></pre> <p>Action: Delete.</p>","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":"<p>Entries with hardcoded paths, literal arguments, or exact commands that were accepted during a specific debugging session:</p> <pre><code>Bash(git -C /home/jose/WORKSPACE/ctx log --oneline --all -20)\nBash(/home/jose/WORKSPACE/ctx/ctx decision add \"Use PostgreSQL\" --context ...)\n</code></pre> <p>Signs of a one-off:</p> <ul> <li>Full absolute paths to specific files</li> <li>Literal string arguments (not wildcards)</li> <li>Very specific flag combinations</li> <li>Commands that look like they came from a single task</li> </ul> <p>Action: Delete unless you want to promote to a wildcard pattern.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#c-subsumed-entries-redundant","level":3,"title":"C. Subsumed Entries (Redundant)","text":"<p>A narrow entry that's already covered by a broader one:</p> <pre><code># 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</code></pre> <p>To find these, look for entries where removing the specific args would match an existing wildcard entry.</p> <p>Action: Delete the narrow entry.</p>","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":"<p>Same command with env vars in different order, or slight variations:</p> <pre><code>Bash(CGO_ENABLED=0 CTX_SKIP_PATH_CHECK=1 go test:*)\nBash(CTX_SKIP_PATH_CHECK=1 CGO_ENABLED=0 go test:*)\n</code></pre> <p>Action: Keep one, delete the other.</p>","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":"<p>While you're in here, also flag:</p> Pattern Risk <code>Bash(git push:*)</code> Bypasses block-git-push.sh hook <code>Bash(rm -rf:*)</code> Recursive delete, no confirmation <code>Bash(sudo:*)</code> Privilege escalation <code>Bash(echo:*)</code>, <code>Bash(cat:*)</code> Can compose into writes to sensitive files <code>Bash(curl:*)</code>, <code>Bash(wget:*)</code> Arbitrary network access Any write to <code>.claude/</code> paths Agent self-modification <p>See the <code>/ctx-permission-sanitize</code> skill for the full threat matrix.</p>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-5-edit","level":2,"title":"Step 5: Edit","text":"<p>Edit <code>.claude/settings.local.json</code> directly in your editor. Remove flagged entries. Keep the JSON valid.</p> <pre><code># Validate JSON after editing\njq . .claude/settings.local.json > /dev/null && echo \"valid\" || echo \"BROKEN\"\n</code></pre>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-6-verify","level":2,"title":"Step 6: Verify","text":"<pre><code># Compare before/after\ndiff /tmp/settings-backup-$(date +%Y%m%d).json .claude/settings.local.json\n</code></pre>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#step-7-optionally-commit","level":2,"title":"Step 7: Optionally Commit","text":"<pre><code>git add .claude/settings.local.json\ngit commit -m \"chore: sanitize agent permissions\"\n</code></pre>","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":"<p>You can safely ask the agent to analyze the file:</p> <p>\"Look at my settings.local.json and tell me which permissions look like one-offs or are redundant.\"</p> <p>The agent can read and report. You do the edits.</p> <p>Do not add these to your allow list:</p> <ul> <li><code>Skill(ctx-permission-sanitize)</code></li> <li><code>Edit(.claude/settings.local.json)</code></li> <li>Any <code>Bash(...)</code> pattern that writes to <code>.claude/</code></li> </ul>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"operations/runbooks/sanitize-permissions/#history","level":2,"title":"History","text":"<ul> <li>2026-02-15: Created as manual-only procedure after deciding against a self-modifying skill.</li> <li>2026-04-16: Moved from <code>hack/runbooks/</code> to <code>docs/operations/runbooks/</code>.</li> </ul>","path":["Operations","Runbooks","Sanitize Permissions"],"tags":[]},{"location":"recipes/","level":1,"title":"Recipes","text":"<p>Workflow recipes combining <code>ctx</code> commands and skills to solve specific problems.</p>","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":"<p>How commands, skills, and conversational patterns work together. Train your agent to be proactive through ask, guide, reinforce.</p>","path":["Recipes"],"tags":[]},{"location":"recipes/#setup-across-ai-tools","level":3,"title":"Setup across AI Tools","text":"<p>Initialize <code>ctx</code> and configure hooks for Claude Code, OpenCode, Cursor, Aider, Copilot, or Windsurf. Includes shell completion, watch mode for non-native tools, and verification.</p> <p>Uses: <code>ctx init</code>, <code>ctx setup</code>, <code>ctx agent</code>, <code>ctx completion</code>, <code>ctx watch</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#multilingual-session-parsing","level":3,"title":"Multilingual Session Parsing","text":"<p>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.</p> <p>Uses: <code>ctx journal source</code>, <code>ctx journal import</code>, <code>session_prefixes</code> in <code>.ctxrc</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#knowledge-base-phase-kb","level":2,"title":"Knowledge Base (Phase KB)","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#build-a-knowledge-base","level":3,"title":"Build a Knowledge Base","text":"<p>Stand up the editorial pipeline for knowledge-shaped work (research projects, vendor-spec analysis, post-incident reviews). Covers the pass-mode contract, source-coverage state-machine ledger, topic-adjacency pre-flight, cold-reader rubric, closeout/fold mechanism, and folder-shaped topic pages.</p> <p>Uses: <code>ctx init</code>, <code>ctx kb topic new</code>, <code>ctx kb note</code>, <code>ctx kb reindex</code>, <code>ctx handover write</code>, <code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, <code>/ctx-kb-site-review</code>, <code>/ctx-kb-ground</code>, <code>/ctx-kb-note</code>, <code>/ctx-handover</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#typical-kb-session","level":3,"title":"Typical KB Session","text":"<p>The everyday flow once the pipeline is set up: session start recall, ingest a transcript, ask grounded questions, park findings, wrap up via the mandatory handover.</p> <p>Uses: <code>/ctx-remember</code>, <code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, <code>/ctx-kb-note</code>, <code>/ctx-wrap-up</code>, <code>/ctx-handover</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#recover-an-aborted-kb-session","level":3,"title":"Recover an Aborted KB Session","text":"<p>What to do when the session ends after one or more editorial passes but before <code>/ctx-handover</code>. Closeouts survive the abort; the next session's <code>/ctx-remember</code> reads them as unfolded postdated artifacts; the next <code>/ctx-handover</code> folds them retroactively.</p> <p>Uses: <code>/ctx-remember</code>, <code>/ctx-handover</code></p>","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":"<p>Walk through a full <code>ctx</code> session from start to finish:</p> <ul> <li>Loading context,</li> <li>Picking what to work on,</li> <li>Committing with context,</li> <li>Capturing, reflecting, and saving a snapshot.</li> </ul> <p>Uses: <code>ctx status</code>, <code>ctx agent</code>, <code>/ctx-remember</code>, <code>/ctx-next</code>, <code>/ctx-commit</code>, <code>/ctx-reflect</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#session-ceremonies","level":3,"title":"Session Ceremonies","text":"<p>The two bookend rituals for every session: <code>/ctx-remember</code> at the start to load and confirm context, <code>/ctx-wrap-up</code> at the end to review the session and persist learnings, decisions, and tasks.</p> <p>Uses: <code>/ctx-remember</code>, <code>/ctx-wrap-up</code>, <code>/ctx-commit</code>, <code>ctx agent</code>, <code>ctx add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#browsing-and-enriching-past-sessions","level":3,"title":"Browsing and Enriching Past Sessions","text":"<p>Export your AI session history to a browsable journal site. Enrich entries with metadata and search across months of work.</p> <p>Uses: <code>ctx journal source/import</code>, <code>ctx journal site</code>, <code>ctx journal obsidian</code>, <code>ctx serve</code>, <code>/ctx-history</code>, <code>/ctx-journal-enrich</code>, <code>/ctx-journal-enrich-all</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#session-reminders","level":3,"title":"Session Reminders","text":"<p>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.</p> <p>Uses: <code>ctx remind</code>, <code>ctx remind list</code>, <code>ctx remind dismiss</code>, <code>ctx system check-reminders</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#reviewing-session-changes","level":3,"title":"Reviewing Session Changes","text":"<p>See what moved since your last session: context file edits, code commits, directories touched. Auto-detects session boundaries from state markers.</p> <p>Uses: <code>ctx change</code>, <code>ctx agent</code>, <code>ctx status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#pausing-context-hooks","level":3,"title":"Pausing Context Hooks","text":"<p>Silence all nudge hooks for a quick task that doesn't need ceremony overhead. Session-scoped: Other sessions are unaffected. Security hooks still fire.</p> <p>Uses: <code>ctx hook pause</code>, <code>ctx hook resume</code>, <code>/ctx-pause</code>, <code>/ctx-resume</code></p>","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":"<p>Record architectural decisions with rationale, capture gotchas and lessons learned, and codify conventions so they survive across sessions and team members.</p> <p>Uses: <code>ctx decision add</code>, <code>ctx learning add</code>, <code>ctx convention add</code>, <code>ctx index</code>, <code>/ctx-decision-add</code>, <code>/ctx-learning-add</code>, <code>/ctx-convention-add</code>, <code>/ctx-reflect</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#tracking-work-across-sessions","level":3,"title":"Tracking Work across Sessions","text":"<p>Add, prioritize, complete, snapshot, and archive tasks. Keep <code>TASKS.md</code> focused as your project evolves across dozens of sessions.</p> <p>Uses: <code>ctx task add</code>, <code>ctx task complete</code>, <code>ctx task archive</code>, <code>ctx task snapshot</code>, <code>/ctx-task-add</code>, <code>/ctx-archive</code>, <code>/ctx-next</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#using-the-scratchpad","level":3,"title":"Using the Scratchpad","text":"<p>Use the encrypted scratchpad for quick notes, working memory, and sensitive values during AI sessions. Natural language in, encrypted storage out.</p> <p>Uses: <code>ctx pad</code>, <code>/ctx-pad</code>, <code>ctx pad show</code>, <code>ctx pad edit</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#syncing-scratchpad-notes-across-machines","level":3,"title":"Syncing Scratchpad Notes across Machines","text":"<p>Distribute your scratchpad encryption key, push and pull encrypted notes via git, and resolve merge conflicts when two machines edit simultaneously.</p> <p>Uses: <code>ctx init</code>, <code>ctx pad</code>, <code>ctx pad resolve</code>, <code>scp</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#bridging-claude-code-auto-memory","level":3,"title":"Bridging Claude Code Auto Memory","text":"<p>Mirror Claude Code's auto memory (MEMORY.md) into <code>.context/</code> for version control, portability, and drift detection. Import entries into structured context files with heuristic classification.</p> <p>Uses: <code>ctx memory sync</code>, <code>ctx memory status</code>, <code>ctx memory diff</code>, <code>ctx memory import</code>, <code>ctx memory publish</code>, <code>ctx system check-memory-drift</code></p>","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":"<p>Choose the right output pattern for your Claude Code hooks: <code>VERBATIM</code> relay for user-facing reminders, hard gates for invariants, agent directives for nudges, and five more patterns across the spectrum.</p> <p>Uses: <code>ctx</code> plugin hooks, <code>settings.local.json</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#customizing-hook-messages","level":3,"title":"Customizing Hook Messages","text":"<p>Customize what hooks say without changing what they do. Override the QA gate for Python (<code>pytest</code> instead of <code>make lint</code>), silence noisy ceremony nudges, or tailor post-commit instructions for your stack.</p> <p>Uses: <code>ctx hook message list</code>, <code>ctx hook message show</code>, <code>ctx hook message edit</code>, <code>ctx hook message reset</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#hook-sequence-diagrams","level":3,"title":"Hook Sequence Diagrams","text":"<p>Mermaid sequence diagrams for every system hook: entry conditions, state reads, output, throttling, and exit points. Includes throttling summary table and state file reference.</p> <p>Uses: All <code>ctx system</code> hooks</p>","path":["Recipes"],"tags":[]},{"location":"recipes/#auditing-system-hooks","level":3,"title":"Auditing System Hooks","text":"<p>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.</p> <p>Uses: <code>ctx system</code>, <code>ctx hook notify</code>, <code>.context/logs/</code>, <code>.ctxrc</code> <code>notify.events</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#webhook-notifications","level":3,"title":"Webhook Notifications","text":"<p>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.</p> <p>Uses: <code>ctx hook notify setup</code>, <code>ctx hook notify test</code>, <code>ctx hook notify --event</code>, <code>.ctxrc</code> <code>notify.events</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#configuration-profiles","level":3,"title":"Configuration Profiles","text":"<p>Switch between dev and base runtime configurations without editing <code>.ctxrc</code> by hand. Verbose logging and webhooks for debugging, clean defaults for normal sessions.</p> <p>Uses: <code>ctx config switch</code>, <code>ctx config status</code>, <code>/ctx-config</code></p>","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":"<p>Keep context files accurate by detecting structural drift (stale paths, missing files, stale file ages) and task staleness.</p> <p>Uses: <code>ctx drift</code>, <code>ctx sync</code>, <code>ctx compact</code>, <code>ctx status</code>, <code>/ctx-drift</code>, <code>/ctx-status</code>, <code>/ctx-prompt-audit</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#state-directory-maintenance","level":3,"title":"State Directory Maintenance","text":"<p>Clean up session tombstones from <code>.context/state/</code>. Prune old per-session files, identify stale global markers, and keep the state directory lean.</p> <p>Uses: <code>ctx prune</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#troubleshooting","level":3,"title":"Troubleshooting","text":"<p>Diagnose hook failures, noisy nudges, stale context, and configuration issues. Start with <code>ctx doctor</code> for a structural health check, then use <code>/ctx-doctor</code> for agent-driven analysis of event patterns.</p> <p>Uses: <code>ctx doctor</code>, <code>ctx hook event</code>, <code>/ctx-doctor</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#claude-code-permission-hygiene","level":3,"title":"Claude Code Permission Hygiene","text":"<p>Keep <code>.claude/settings.local.json</code> clean: recommended safe defaults, what to never pre-approve, and a maintenance workflow for cleaning up session debris.</p> <p>Uses: <code>ctx init</code>, <code>/ctx-drift</code>, <code>/ctx-permission-sanitize</code>, <code>ctx permission snapshot</code>, <code>ctx permission restore</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#permission-snapshots","level":3,"title":"Permission Snapshots","text":"<p>Capture a known-good permission baseline as a golden image, then restore at session start to automatically drop session-accumulated permissions.</p> <p>Uses: <code>ctx permission snapshot</code>, <code>ctx permission restore</code>, <code>/ctx-permission-sanitize</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#turning-activity-into-content","level":3,"title":"Turning Activity into Content","text":"<p>Generate blog posts from project activity, write changelog posts from commit ranges, and publish a browsable journal site from your session history.</p> <p>The output is generic Markdown, but the skills are tuned for the <code>ctx</code>-style blog artifacts you see on this website.</p> <p>Uses: <code>ctx journal site</code>, <code>ctx journal obsidian</code>, <code>ctx serve</code>, <code>ctx journal import</code>, <code>/ctx-blog</code>, <code>/ctx-blog-changelog</code>, <code>/ctx-journal-enrich</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#importing-claude-code-plans","level":3,"title":"Importing Claude Code Plans","text":"<p>Import Claude Code plan files (<code>~/.claude/plans/*.md</code>) into <code>specs/</code> as permanent project specs. Filter by date, select interactively, and optionally create tasks referencing each imported spec.</p> <p>Uses: <code>/ctx-plan-import</code>, <code>/ctx-task-add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#design-before-coding","level":3,"title":"Design Before Coding","text":"<p>Front-load design with a four-skill chain: brainstorm the approach, spec the design, task out the work, implement step-by-step. Each step produces an artifact that feeds the next.</p> <p>Uses: <code>/ctx-brainstorm</code>, <code>/ctx-spec</code>, <code>/ctx-task-out</code>, <code>/ctx-task-add</code>, <code>/ctx-implement</code>, <code>/ctx-decision-add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#scrutinizing-a-plan","level":3,"title":"Scrutinizing a Plan","text":"<p>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.</p> <p>Uses: <code>/ctx-plan</code>, <code>/ctx-spec</code>, <code>/ctx-decision-add</code>, <code>/ctx-learning-add</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#spec-driven-development","level":3,"title":"Spec-Driven Development","text":"<p>The full design-to-implementation pipeline from the operator's seat: debate the bet into a brief, spec all milestones once, task out each milestone just-in-time behind the rolling-wave gate, then implement. Covers the load-bearing mechanics a newcomer has to reverse-engineer otherwise — altitude, blocking-TBD gates, and the plan-as-ledger vs. TASKS.md-as-projection split — with a worked multi-milestone example.</p> <p>Uses: <code>/ctx-plan</code>, <code>/ctx-spec</code>, <code>/ctx-task-out</code>, <code>/ctx-implement</code>, <code>/ctx-decision-add</code></p>","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":"<p>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.</p> <p>Uses: <code>/ctx-skill-create</code>, <code>ctx init</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#running-an-unattended-ai-agent","level":3,"title":"Running an Unattended AI Agent","text":"<p>Set up a loop where an AI agent works through tasks overnight without you at the keyboard, using <code>ctx</code> for persistent memory between iterations.</p> <p>This recipe shows how <code>ctx</code> supports long-running agent loops without losing context or intent.</p> <p>Uses: <code>ctx init</code>, <code>ctx loop</code>, <code>ctx watch</code>, <code>ctx load</code>, <code>/ctx-loop</code>, <code>/ctx-implement</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#when-to-use-a-team-of-agents","level":3,"title":"When to Use a Team of Agents","text":"<p>Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.</p> <p>This recipe covers the file overlap test, when teams make things worse, and what <code>ctx</code> provides at each level.</p> <p>Uses: <code>/ctx-worktree</code>, <code>/ctx-next</code>, <code>ctx status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#parallel-agent-development-with-git-worktrees","level":3,"title":"Parallel Agent Development with Git Worktrees","text":"<p>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.</p> <p>Uses: <code>/ctx-worktree</code>, <code>/ctx-next</code>, <code>git worktree</code>, <code>git merge</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#architecture-deep-dive","level":3,"title":"Architecture Deep Dive","text":"<p>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.</p> <p>Uses: <code>/ctx-architecture</code>, <code>/ctx-architecture-enrich</code>, <code>/ctx-architecture-failure-analysis</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#writing-steering-files","level":3,"title":"Writing Steering Files","text":"<p>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.</p> <p>Uses: <code>ctx steering add</code>, <code>ctx steering preview</code>, <code>ctx steering list</code>, <code>ctx steering sync</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#out-of-band-audit-channel","level":3,"title":"Out-of-Band Audit Channel","text":"<p>Maintainer-only tooling (the <code>ctxctl</code> binary, not the shipped <code>ctx</code>), so it moved out of these user recipes into the contributor docs. See Operations → Runbooks → Out-of-Band Audit Channel.</p>","path":["Recipes"],"tags":[]},{"location":"recipes/#authoring-lifecycle-triggers","level":3,"title":"Authoring Lifecycle Triggers","text":"<p>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.</p> <p>Uses: <code>ctx trigger add</code>, <code>ctx trigger test</code>, <code>ctx trigger enable</code>, <code>ctx trigger disable</code>, <code>ctx trigger list</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#hub","level":2,"title":"Hub","text":"","path":["Recipes"],"tags":[]},{"location":"recipes/#hub-overview","level":3,"title":"Hub Overview","text":"<p>Mental model and three user stories for the <code>ctx</code> Hub. What flows, what doesn't, and when not to use it. Read this before any of the other Hub recipes.</p> <p>Uses: <code>ctx hub</code>, <code>ctx connection</code>, <code>ctx add --share</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-getting-started","level":3,"title":"<code>ctx</code> Hub: Getting Started","text":"<p>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.</p> <p>Uses: <code>ctx hub start</code>, <code>ctx connection register</code>, <code>ctx connection subscribe</code>, <code>ctx connection sync</code>, <code>ctx connection listen</code>, <code>ctx add --share</code>, <code>ctx agent --include-hub</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#personal-cross-project-brain","level":3,"title":"Personal Cross-Project Brain","text":"<p>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 <code>sync</code>, no <code>git push</code>, no ceremony).</p> <p>Uses: <code>ctx add --share</code>, <code>ctx connection subscribe</code>, <code>ctx agent --include-hub</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#team-knowledge-bus","level":3,"title":"Team Knowledge Bus","text":"<p>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.</p> <p>Uses: <code>ctx add --share</code>, <code>ctx connection status</code>, <code>ctx connection subscribe</code>, <code>ctx hub status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-multi-machine","level":3,"title":"<code>ctx</code> Hub: Multi-Machine","text":"<p>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.</p> <p>Uses: <code>ctx hub start --daemon</code>, <code>ctx hub stop</code>, <code>ctx connection register</code>, <code>ctx connection status</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/#ctx-hub-ha-cluster","level":3,"title":"<code>ctx</code> Hub: HA Cluster","text":"<p>Raft-based leader election across three or more nodes for redundancy. Covers bootstrap, runtime peer management, graceful stepdown, and the Raft-lite durability caveat.</p> <p>Uses: <code>ctx hub start --peers</code>, <code>ctx hub status</code>, <code>ctx hub peer add/remove</code>, <code>ctx hub stepdown</code></p>","path":["Recipes"],"tags":[]},{"location":"recipes/architecture-deep-dive/","level":1,"title":"Architecture Deep Dive","text":"","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-problem","level":2,"title":"The Problem","text":"<p>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.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tldr","level":2,"title":"TL;DR","text":"<pre><code># 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</code></pre> <p>Each pass builds on the previous one. Run them in order. The output accumulates in <code>.context/</code>; each pass reads the prior artifacts and extends them.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>/ctx-architecture</code> Skill Map modules, dependencies, data flow, patterns <code>/ctx-architecture-enrich</code> Skill Verify blast radius and flows with code intel <code>/ctx-architecture-failure-analysis</code> Skill Generate falsifiable incident hypotheses <code>ctx drift</code> CLI Detect stale paths and broken references <code>ctx status</code> CLI Quick structural overview","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#pass-1-map-what-exists","level":3,"title":"Pass 1: Map What Exists","text":"<pre><code>/ctx-architecture\n</code></pre> <p>Produces:</p> <ul> <li>ARCHITECTURE.md: succinct project map (< 4000 tokens), loaded at every session start</li> <li>DETAILED_DESIGN*.md: deep per-module reference with exported API, data flow, danger zones, extension points</li> <li>CHEAT-SHEETS.md: lifecycle flow diagrams</li> <li>map-tracking.json: coverage state with confidence scores</li> </ul> <p>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.</p> <p>When to run: First time on a codebase, or after significant structural changes (new packages, moved files, changed dependencies).</p> <p>Principal mode: Add <code>principal</code> to get strategic analysis (ARCHITECTURE-PRINCIPAL.md, DANGER-ZONES.md from P4):</p> <pre><code>/ctx-architecture principal\n</code></pre>","path":["Recipes","Agents and Automation","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":"<pre><code>/ctx-architecture-enrich\n</code></pre> <p>Takes the Pass 1 artifacts as baseline and layers on verified, graph-backed data from a code-intelligence MCP (canonical: GitNexus; equivalents include sourcegraph-cody):</p> <ul> <li>Blast radius numbers for key functions</li> <li>Execution flow traces through hot paths</li> <li>Domain clustering validation</li> <li>Registration site discovery</li> </ul> <p>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.\"</p> <p>When to run: After Pass 1, when you need quantified confidence for refactoring decisions or risk assessment.</p> <p>Requires: a code-intelligence MCP connected (canonical: GitNexus; equivalents work if they expose symbol-index, blast-radius, and execution-flow queries).</p>","path":["Recipes","Agents and Automation","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":"<pre><code>/ctx-architecture-failure-analysis\n</code></pre> <p>The adversarial pass. Reads all prior artifacts, then systematically hunts for correctness bugs across 9 failure categories:</p> <ol> <li>Concurrency (races, deadlocks, goroutine leaks)</li> <li>Ordering assumptions (init, registration, shutdown)</li> <li>Cache staleness (TTL-less, read-your-writes, cross-process)</li> <li>Fan-out amplification (N+1, retry storms)</li> <li>Ownership and lifecycle (orphans, double-close)</li> <li>Error handling (silent swallowing, partial failure)</li> <li>Scaling cliffs (quadratic, unbounded, global locks)</li> <li>Idempotency failures (duplicate processing, retry mutations)</li> <li>State machine drift (illegal states, unvalidated transitions)</li> </ol> <p>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.</p> <p>Produces DANGER-ZONES.md, a ranked inventory of findings split into Critical and Elevated tiers.</p> <p>When to run: Before releases, after major refactors, when investigating incident categories, or when onboarding.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#what-you-get","level":2,"title":"What You Get","text":"<p>After all three passes, <code>.context/</code> contains:</p> File From Purpose <code>ARCHITECTURE.md</code> Pass 1 System map (session-start context) <code>DETAILED_DESIGN*.md</code> Pass 1 Module-level deep reference <code>CHEAT-SHEETS.md</code> Pass 1 Lifecycle flow diagrams <code>map-tracking.json</code> Pass 1 Coverage and confidence data <code>CONVERGENCE-REPORT.md</code> Pass 1 What's covered, what's not <code>DANGER-ZONES.md</code> Pass 3 Ranked failure hypotheses <p>Pass 2 enriches Pass 1 artifacts in-place rather than creating new files.</p>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#tips","level":2,"title":"Tips","text":"<ul> <li>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.</li> <li>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.</li> <li>Re-run Pass 1 incrementally. It tracks coverage in <code>map-tracking.json</code> and only re-analyzes stale modules.</li> <li>Pass 3 is most valuable before releases. The ranked DANGER-ZONES.md is a pre-release checklist.</li> <li>The trilogy maps to a question progression: How does it work? How well does it connect? Where will it break?</li> </ul>","path":["Recipes","Agents and Automation","Architecture Deep Dive"],"tags":[]},{"location":"recipes/architecture-deep-dive/#see-also","level":2,"title":"See Also","text":"<p>See also: Detecting and Fixing Context Drift to keep architecture artifacts fresh between deep-dive sessions.</p> <p>See also: Detecting and Fixing Context Drift for structural checks that complement architecture analysis.</p>","path":["Recipes","Agents and Automation","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":"<p>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.</p> <p>Each iteration needs to remember what the previous one did, mark tasks as completed, and know when to stop.</p> <p>Without persistent memory, every iteration starts fresh and the loop collapses. With <code>ctx</code>, each iteration can pick up where the last one left off, but only if the agent persists its context as part of the work.</p> <p>Unattended operation works because the agent treats context persistence as a first-class deliverable, not an afterthought.</p>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx init # 1. init context\n# Edit TASKS.md with phased work items\nctx loop --tool claude --max-iterations 10 # 2. generate loop.sh\n./loop.sh 2>&1 | tee /tmp/loop.log & # 3. run the loop\nctx watch --log /tmp/loop.log # 4. process context updates\n# Next morning:\nctx status && ctx load # 5. review the results\n</code></pre> <p>Run From the Project Root</p> <p><code>ctx</code> reads <code>$PWD/.context/</code>. Both the interactive <code>ctx loop</code> invocation and the generated <code>loop.sh</code> must run from the project root. If <code>loop.sh</code> is scheduled by a supervisor that does not preserve cwd, add <code>cd /abs/path/to/project</code> at the top of the script.</p> <p>Read on for permissions, isolation, and completion signals.</p>","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 <code>ctx init</code> Command Initialize project context and prompt templates <code>ctx loop</code> Command Generate the loop shell script <code>ctx watch</code> Command Monitor AI output and persist context updates <code>ctx load</code> Command Display assembled context (for debugging) <code>/ctx-loop</code> Skill Generate loop script from inside Claude Code <code>/ctx-implement</code> 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":"<p>Start by creating a <code>.context/</code> directory configured so the agent can work without human input.</p> <pre><code>ctx init\n</code></pre> <p>This creates <code>.context/</code> with the template files (including a loop prompt at <code>.context/loop.md</code>), and seeds Claude Code permissions in <code>.claude/settings.local.json</code>. Install the <code>ctx</code> plugin for hooks and skills.</p>","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 <code>TASKS.md</code> with Phased Work","text":"<p>Open <code>.context/TASKS.md</code> and organize your work into phases. The agent works through these systematically, top to bottom, using priority tags to break ties.</p> <pre><code># 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</code></pre> <p>Phased organization matters because it gives the agent natural boundaries. Phase 1 tasks should be completable without Phase 2 code existing yet.</p>","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":"<p>The loop prompt at <code>.context/loop.md</code> instructs the agent to operate autonomously:</p> <ol> <li>Read <code>.context/CONSTITUTION.md</code> first (hard rules, never violated)</li> <li>Load context from <code>.context/</code> files</li> <li>Pick one task per iteration</li> <li>Complete the task and update context files</li> <li>Commit changes (including <code>.context/</code>)</li> <li>Signal status with a completion signal</li> </ol> <p>You can customize <code>.context/loop.md</code> for your project. The critical parts are the one-task-per-iteration discipline, proactive context persistence, and completion signals at the end:</p> <pre><code>## 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</code></pre>","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":"<p>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.</p> <p>There are two approaches.</p>","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":"<p>Grant only the permissions the agent needs. In <code>.claude/settings.local.json</code>:</p> <pre><code>{\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</code></pre> <p>Adjust the <code>Bash</code> patterns for your project's toolchain. The agent can run <code>make</code>, <code>go</code>, <code>git</code>, and <code>ctx</code> commands but cannot run arbitrary shell commands.</p> <p>This is recommended even in sandboxed environments because it limits blast radius.</p>","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":"<p>Claude Code supports a <code>--dangerously-skip-permissions</code> flag that disables all permission prompts:</p> <pre><code>claude --dangerously-skip-permissions -p \"$(cat .context/loop.md)\"\n</code></pre> <p>This Flag Means What It Says</p> <p>With <code>--dangerously-skip-permissions</code>, the agent can execute any shell command, write to any file, and make network requests without confirmation.</p> <p>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.</p> <p>If you would not give an untrusted intern <code>sudo</code> on this machine, do not use this flag.</p>","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":"<p>The only controls an agent cannot override are the ones enforced by the operating system, the container runtime, or the hypervisor.</p> <p>Do Not Skip This Section</p> <p>This is not optional hardening:</p> <p>An unattended agent with unrestricted OS access is an unattended shell with unrestricted OS access. </p> <p>The allowlist above is a strong first layer, but do not rely on a single runtime boundary.</p> <p>For unattended runs, enforce isolation at the infrastructure level:</p> Layer What to enforce User account Run the agent as a dedicated unprivileged user with no <code>sudo</code> access and no membership in privileged groups (<code>docker</code>, <code>wheel</code>, <code>adm</code>). 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 (<code>--cap-drop=ALL</code>). Disable network if not needed (<code>--network=none</code>). 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. <code>CLAUDE.md</code>, <code>.claude/settings.local.json</code>, and <code>.context/CONSTITUTION.md</code> should not be writable by the agent user. If using project-local hooks, protect those too. <p>A minimal Docker setup for overnight runs:</p> <pre><code>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</code></pre> <p>Defense in Depth</p> <p>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 <code>CONSTITUTION.md</code> (a soft nudge for the common case).</p>","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":"<p>Use <code>ctx loop</code> to generate a <code>loop.sh</code> tailored to your AI tool:</p> <pre><code># 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</code></pre> <p>The generated script reads <code>.context/loop.md</code>, runs the tool, checks for completion signals, and loops until done or the cap is reached.</p> <p>You can also use the <code>/ctx-loop</code> skill from inside Claude Code.</p> <p>A Shell Loop Is the Best Practice</p> <p>The shell loop approach spawns a fresh AI process each iteration, so the only state that carries between iterations is what lives in <code>.context/</code> and git.</p> <p>Claude Code's built-in <code>/loop</code> 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. </p> <p>See Shell Loop vs Built-in Loop for details.</p>","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":"<p>Open two terminals. In the first, run the loop. In the second, run <code>ctx watch</code> to process context updates from the AI output.</p> <pre><code># 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</code></pre> <p>The watch command parses XML context-update commands from the AI output and applies them:</p> <pre><code><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</code></pre>","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":"<p>The generated script checks for one completion signal per run. By default this is <code>SYSTEM_CONVERGED</code>. You can change it with the <code>--completion</code> flag:</p> <pre><code>ctx loop --tool claude --completion BOOTSTRAP_COMPLETE --max-iterations 5\n</code></pre> <p>The following signals are conventions used in <code>.context/loop.md</code>:</p> Signal Convention How the script handles it <code>SYSTEM_CONVERGED</code> All tasks in <code>TASKS.md</code> are done Detected by default (<code>--completion</code> default value) <code>SYSTEM_BLOCKED</code> Agent cannot proceed Only detected if you set <code>--completion</code> to this <code>BOOTSTRAP_COMPLETE</code> Initial scaffolding done Only detected if you set <code>--completion</code> to this <p>The script uses <code>grep -q</code> 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 <code>loop.sh</code> to add additional <code>grep</code> checks.</p> <p>When you return in the morning, check the log and the context files:</p> <pre><code>tail -100 /tmp/loop.log\nctx status\nctx load\n</code></pre>","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 <code>/ctx-implement</code> for Plan Execution","text":"<p>Within each iteration, the agent can use <code>/ctx-implement</code> to execute multi-step plans with verification between steps. This is useful for complex tasks that touch multiple files.</p> <p>The skill breaks a plan into atomic, verifiable steps:</p> <pre><code>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</code></pre> <p>Each step is verified (build, test, syntax check) before moving to the next.</p>","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":"<p>A typical overnight run:</p> <pre><code>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</code></pre>","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":"<p>The autonomous loop pattern works because the agent persists context as part of the job.</p> <p>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.</p>","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":"<p>The Agent Playbook defines a self-check prompt the agent applies continuously:</p> <pre><code>\"If this session ended right now, would the next session know what happened?\"\n</code></pre> <p>In interactive sessions, a human might remind the agent to save context. When the agent runs unattended, nobody is there to remind it.</p> <p>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.</p>","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":"<p>At milestones within an iteration, the agent persists without waiting for instructions:</p> Milestone What the agent does proactively Completes a task Marks it <code>[x]</code> in <code>TASKS.md</code> Discovers a gotcha Adds it to <code>LEARNINGS.md</code> Makes a design choice Records it in <code>DECISIONS.md</code> with rationale Identifies follow-up work Creates new tasks in <code>TASKS.md</code> with <code>#added</code> 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":"<p>Here is what the agent does during a single iteration beyond writing code:</p> <pre><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</code></pre> <p>Steps 2, 4, 5, 6, and 7 are proactive context persistence: </p> <p>The agent was not asked to do any of them.</p>","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":"<p>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 <code>TASKS.md</code>, <code>DECISIONS.md</code>, and <code>LEARNINGS.md</code> as it goes.</p> <p>If the loop crashes at 4 AM, the context files tell you exactly where to resume. You can also use <code>ctx journal source</code> to review the session transcripts.</p>","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":"<p>The autonomous loop has an implicit contract:</p> <ol> <li>Every iteration reads context: <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code></li> <li>Every iteration writes context: task updates, new learnings, decisions</li> <li>Every commit includes <code>.context/</code> so the next iteration sees changes</li> <li>Context stays current: if the loop stopped right now, nothing important is lost</li> </ol> <p>Break any part of this contract and the loop degrades.</p>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#tips","level":2,"title":"Tips","text":"<p>Markdown Is Not Enforcement</p> <p>Your real guardrails are permissions and isolation, not Markdown. <code>CONSTITUTION.md</code> can nudge the agent, but it is probabilistic. </p> <p>The permission allowlist and OS isolation are deterministic:</p> <p>For unattended runs, trust the sandbox and the allowlist, not the prose.</p> <ul> <li>Start with a small iteration cap. Use <code>--max-iterations 5</code> on your first run.</li> <li>Keep tasks atomic. Each task should be completable in a single iteration.</li> <li>Check signal discipline. If the loop runs forever, the agent is not emitting <code>SYSTEM_CONVERGED</code> or <code>SYSTEM_BLOCKED</code>. Make the signal requirement explicit in <code>.context/loop.md</code>.</li> <li>Commit after context updates. Finish code, update <code>.context/</code>, commit including <code>.context/</code>, then signal.</li> <li>Set up webhook notifications to get notified when the loop completes, hits max iterations, or when hooks fire nudges. The generated loop script includes <code>ctx hook notify</code> calls automatically.</li> </ul>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#next-up","level":2,"title":"Next Up","text":"<p>When to Use a Team of Agents →: Decision framework for choosing between a single agent, parallel worktrees, and a full agent team.</p>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/autonomous-loops/#see-also","level":2,"title":"See Also","text":"<ul> <li>Autonomous Loops: loop pattern, prompt templates, troubleshooting</li> <li>CLI Reference: <code>ctx</code> loop: flags and options</li> <li>CLI Reference: <code>ctx</code> watch: watch mode details</li> <li>CLI Reference: <code>ctx</code> init: init flags</li> <li>The Complete Session: interactive workflow</li> <li>Tracking Work Across Sessions: structuring TASKS.md</li> </ul>","path":["Recipes","Agents and Automation","Running an Unattended AI Agent"],"tags":[]},{"location":"recipes/build-a-knowledge-base/","level":1,"title":"Build a Knowledge Base","text":"","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#the-problem","level":2,"title":"The Problem","text":"<p>You are doing knowledge-shaped work (vendor-spec analysis, a research project, a post-incident review, domain modeling) and the standard five context files (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>, <code>CONSTITUTION.md</code>) don't fit. Because those files are tuned for code-development context, not for evidence-tracked knowledge with confidence bands, contradictions, and external citations.</p> <p>You need a place where:</p> <ul> <li>Every claim is pinned to a source you can re-verify.</li> <li>Topics grow into folders as they earn their depth.</li> <li>Two passes against the same source don't silently disagree.</li> <li>The next session knows what's incomplete, not just what's done.</li> </ul> <p>That's what the editorial pipeline is for.</p> <p>Prefer Skills to Raw Commands</p> <p>The pipeline is driven by skills (<code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, etc.). The CLI form (<code>ctx kb ingest</code>, etc.) exists for scripting and for non-Claude environments; the skill is the natural surface.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#tldr","level":2,"title":"TL;DR","text":"<pre><code>git init && ctx init # lays down the kb + ingest tree\nctx kb topic new \"Cursor Hooks\" # scaffold a topic folder\n/ctx-kb-ingest ./docs/cursor-hooks.md \"cursor hooks\" # editorial pass\n/ctx-kb-ask \"does the kb say hooks fire async?\" # grounded Q&A\n/ctx-wrap-up # ceremony; delegates to /ctx-handover\n # for the per-session handover\n</code></pre>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>ctx init</code> Command Scaffold <code>.context/kb/</code>, <code>.context/ingest/</code>, etc. <code>ctx kb topic new <name></code> Command Sole writer of topic-page scaffolds (folder shape) <code>ctx kb note \"<text>\"</code> Command Lightweight capture into <code>.context/ingest/findings.md</code> <code>ctx kb reindex</code> Command Refresh the <code>CTX:KB:TOPICS</code> managed block <code>ctx handover write</code> Command Per-session handover with closeout fold <code>/ctx-kb-ingest</code> Skill Mode-aware editorial pass (topic-page/triage/evidence) <code>/ctx-kb-ask</code> Skill Q&A grounded in the kb <code>/ctx-kb-site-review</code> Skill Mechanical structural audit <code>/ctx-kb-ground</code> Skill Read-only freshness audit over the kb's tracked sources <code>/ctx-kb-note</code> Skill Capture a finding for the next ingest pass <code>/ctx-wrap-up</code> Skill End-of-session ceremony; delegates to the handover step","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-0-initialize-and-declare-scope","level":2,"title":"Step 0: Initialize and Declare Scope","text":"<pre><code>git init && ctx init\n</code></pre> <p><code>ctx init</code> lays down the editorial scaffolding alongside the standard context files:</p> <pre><code>.context/\n├── kb/\n│ ├── index.md\n│ └── topics/.gitkeep\n├── ingest/\n│ ├── KB-RULES.md # editorial constitution\n│ ├── 00-GROUND.md\n│ ├── 30-INGEST.md\n│ ├── 40-ASK.md\n│ ├── 50-SITE_REVIEW.md\n│ ├── OPERATOR.md\n│ ├── PROMPT.md # hand-fallback router\n│ ├── closeouts/.gitkeep\n│ └── schemas/\n│ └── *.md # 10 schema templates\n└── handovers/.gitkeep\n</code></pre> <p>Open <code>.context/kb/index.md</code> and replace the placeholder <code>## Scope</code> paragraph with a one-paragraph statement of what this kb covers and what it does not. <code>/ctx-kb-ingest</code> refuses to run against an undeclared kb; scope is the precondition.</p> <p>Git is required</p> <p><code>ctx init</code> now refuses to run without <code>.git/</code>. The editorial pipeline's provenance (closeout <code>sha</code>/<code>branch</code>, evidence-index in-repo SHA pins) depends on it. Run <code>git init</code> first if the project does not already have one.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-1-scaffold-a-topic","level":2,"title":"Step 1: Scaffold a Topic","text":"<p>Topic pages live in folders, not flat files:</p> <pre><code>ctx kb topic new \"Cursor Hooks\"\n</code></pre> <p>This creates <code>.context/kb/topics/cursor-hooks/index.md</code> from the embedded template. The slug is computed by lowercasing + kebab- casing; vendor-namespaced shapes like <code>cursor/hooks</code> are preserved so you can grow into nested topology (<code>topics/cursor/hooks/</code>, <code>topics/cursor/skills/</code>, <code>topics/cursor/rules/</code>) without breaking citations.</p> <p><code>ctx kb topic new</code> is the sole writer of topic-page scaffolds. Skills invoke this command rather than synthesize a scaffold by hand; the embedded template is the single source of truth.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-2-run-an-editorial-pass","level":2,"title":"Step 2: Run an Editorial Pass","text":"<pre><code>/ctx-kb-ingest ./inputs/2026-04-12-call.md \"cursor hooks\"\n</code></pre> <p>The skill begins with a pass-mode declaration:</p> <p>Pass-mode: <code>topic-page</code> Reason: the user supplied one primary source and the intended topic is clear. Definition of done: create or extend <code>kb/topics/cursor-hooks/index.md</code>, cite EV rows, run <code>ctx kb site build</code>, record cold-reader orientation.</p> <p>Then it:</p> <ol> <li>Resolves sources (paths / URLs / MCP resources) and updates the source-coverage ledger at <code>.context/kb/source-coverage.md</code> (a state machine across all sources the kb has touched).</li> <li>Scans for adjacent incomplete topics in the ledger and surfaces them so the new page acknowledges sibling gaps.</li> <li>Synthesizes prose section by section into the topic page, minting <code>EV-###</code> rows in <code>evidence-index.md</code> for every cited claim.</li> <li>Sets the Confidence floor (the page never claims more certainty than its weakest cited band).</li> <li>Writes a closeout under <code>.context/ingest/closeouts/<TS>-ingest-closeout.md</code> with frontmatter, the cold-reader orientation rubric, and a ledger-state advance per source.</li> </ol> <p>Three pass modes:</p> <ul> <li><code>topic-page</code> (default): write or extend a topic page.</li> <li><code>triage</code>: admit / skip sources against scope; no <code>EV-###</code> minted.</li> <li><code>evidence-only</code>: mint <code>EV-###</code> rows tagged <code>evidence-only</code>; do not touch a topic page (explicit-request-only escape hatch).</li> </ul> <p>Mid-pass mode-switching is forbidden: the skill commits to one mode and aborts cleanly if the work no longer fits.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-3-qa-grounded-in-the-kb","level":2,"title":"Step 3: Q&A Grounded in the KB","text":"<pre><code>/ctx-kb-ask \"does the kb say hooks fire async?\"\n</code></pre> <p><code>/ctx-kb-ask</code> reads the kb's prose, cites <code>EV-###</code> rows, and refuses to web-jump. If the kb cannot answer, it opens a <code>Q-###</code> row in <code>outstanding-questions.md</code> and reports the gap, which a future <code>/ctx-kb-ingest</code> pass can close.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-4-audit-re-ground","level":2,"title":"Step 4: Audit + Re-Ground","text":"<pre><code>/ctx-kb-site-review # mechanical structural audit\n/ctx-kb-ground # refresh sources listed in grounding-sources.md\n</code></pre> <p><code>site-review</code> coerces malformed Confidence-band capitalization, flags malformed closeout frontmatter, and refuses to make judgment calls that require evidence (those go through ingest).</p> <p><code>ground</code> reads <code>.context/ingest/grounding-sources.md</code> — the kb's persistent watch list — and walks each declared source (URL, in-tree path, or MCP resource) to check whether it has drifted since the kb last cited it. The pass is read-only on the kb's prose and evidence: it annotates the source-coverage ledger's <code>Residue</code> / <code>Next action</code> cells and writes a ground closeout, but does NOT re-extract claims, mint <code>EV-###</code> rows, or touch topic pages. Drifted or new-to-kb sources are flagged for a follow-up <code>/ctx-kb-ingest</code>. Use ground for \"are the docs still current?\" hygiene; use <code>/ctx-kb-ingest</code> to actually absorb new material.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-5-browse-the-kb-locally","level":2,"title":"Step 5: Browse the KB Locally","text":"<p><code>.context/kb/</code> is a tree of Markdown files: topic pages live under <code>topics/<slug>/index.md</code> and cross-cutting artifacts (<code>glossary.md</code>, <code>evidence-index.md</code>, <code>outstanding-questions.md</code>, <code>domain-decisions.md</code>, <code>contradictions.md</code>, <code>timeline.md</code>, <code>source-map.md</code>, <code>source-coverage.md</code>, <code>relationship-map.md</code>) sit alongside them. Drop a minimal <code>zensical.toml</code> into <code>.context/kb/</code> and hand it to <code>ctx serve</code>:</p> <pre><code>ctx serve .context/kb/\n</code></pre> <p>The KB renders the same way the docs site you are reading right now does. Use the in-place evidence-index links to jump from a topic page to its <code>EV-###</code> rows and back. The site build is read-only: no skill or CLI writes through it.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#step-6-wrap-up-with-a-handover","level":2,"title":"Step 6: Wrap Up with a Handover","text":"<p>Run <code>/ctx-wrap-up</code> at session end; it owns the ceremony and delegates to the handover step (<code>/ctx-handover</code>) as its final action:</p> <pre><code>/ctx-wrap-up \"Cursor Hooks deep dive\"\n</code></pre> <p>The handover artifact lands at <code>.context/handovers/<TS>-<slug>.md</code> (timestamped so concurrent agent runs never overwrite). It folds postdated closeouts into a <code>## Folded closeouts</code> section and archives the source closeout files under <code>.context/archive/closeouts/</code>. The next session's <code>/ctx-remember</code> reads the latest handover and folds any closeouts whose <code>generated-at</code> postdates it.</p> <p>The legitimate direct-invocation cases for <code>/ctx-handover</code> are <code>--no-fold</code> for a mid-session checkpoint, or recovery when a prior session ended before its wrap-up step. For the underlying CLI, see <code>ctx handover write</code>.</p>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#how-it-ladders-together","level":2,"title":"How It Ladders Together","text":"<pre><code>sources you supply\n │\n ▼\n/ctx-kb-ingest (mode-declared, source-coverage advanced)\n │\n ├──▶ topic-page ──▶ .context/kb/topics/<slug>/index.md\n ├──▶ evidence ──▶ .context/kb/evidence-index.md (EV-###)\n ├──▶ side rails ──▶ glossary.md, contradictions.md,\n │ outstanding-questions.md, timeline.md,\n │ source-map.md, relationship-map.md\n └──▶ closeout ──▶ .context/ingest/closeouts/<TS>-...md\n │\n ▼\n (next session)\n │\n ▼\n /ctx-wrap-up → /ctx-handover folds\n → .context/handovers/<TS>-<slug>.md\n + archives source closeouts under\n .context/archive/closeouts/\n │\n ▼\n /ctx-remember reads handover + postdated\n unfolded closeouts as the recall surface\n</code></pre>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#bootstrap-vs-steady-state-ingest-first-ground-later","level":2,"title":"Bootstrap vs Steady State: Ingest First, Ground Later","text":"<p><code>/ctx-kb-ingest</code> and <code>/ctx-kb-ground</code> both read sources, which makes their relationship easy to misread. The distinction is authority, not input shape:</p> <ul> <li>Ingest writes. It mints <code>EV-###</code> rows, authors topic-page prose, transitions source-coverage ledger states. The source list is per-invocation (CLI args, inline gestures).</li> <li>Ground audits. It walks a persistent watch list in <code>grounding-sources.md</code>, reports drift, annotates the ledger's <code>Residue</code> and <code>Next action</code> cells, and never writes prose or evidence. Drifted sources surface as flags pointing at <code>/ctx-kb-ingest</code>.</li> </ul> <p>This drives the canonical flow:</p> <p>Bootstrap (pristine kb). Use <code>/ctx-kb-ingest <sources></code> to absorb the first wave of material. Ground has nothing to compare against in a pristine kb — <code>source-map.md</code> is empty, and <code>grounding-sources.md</code> would just prompt for entries.</p> <p>Curate the watch list. Once the kb has content, edit <code>grounding-sources.md</code> by hand to list the canonical sources the kb's claims depend on — the load-bearing citations worth checking for drift. Ground refuses to synthesise this list from <code>source-map.md</code> by design; the watch list is a deliberate human choice about what's worth tracking.</p> <p>Steady state. Ingest liberally as new material lands. Run <code>/ctx-kb-ground</code> periodically — before a release, after a vendor version bump, on whatever cadence fits — to detect drift on the tracked subset. Drift surfaces as flags in the ground closeout pointing at <code>/ctx-kb-ingest</code> for the actual write-side work.</p> <p>Rule of thumb:</p> Situation Skill \"I have new material I want absorbed.\" <code>/ctx-kb-ingest</code> \"Are the sources the kb depends on still current?\" <code>/ctx-kb-ground</code> \"Is the kb's structure clean (capitalisation, frontmatter)?\" <code>/ctx-kb-site-review</code>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#what-the-editorial-pipeline-is-not","level":2,"title":"What the Editorial Pipeline Is NOT","text":"<ul> <li>Not a substitute for <code>DECISIONS.md</code>. Project-level architectural decisions stay in <code>.context/DECISIONS.md</code>. The kb's <code>domain-decisions.md</code> is a kb-scoped artifact (different schema, different write authority, different lifecycle).</li> <li>Not a substitute for <code>LEARNINGS.md</code>. Learnings have author intent; kb claims have evidence backing. They're different truth bases; do not cross-feed.</li> <li>Not for casual notes. Use <code>/ctx-kb-note</code> or <code>ctx kb note \"<text>\"</code> to park a finding for the next ingest pass.</li> </ul>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"tags":[]},{"location":"recipes/build-a-knowledge-base/#reference","level":2,"title":"Reference","text":"<ul> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code> (laid down by <code>ctx init</code>)</li> <li>Skills reference: <code>/ctx-kb-ingest</code>, <code>/ctx-kb-ask</code>, <code>/ctx-kb-site-review</code>, <code>/ctx-kb-ground</code>, <code>/ctx-kb-note</code>, <code>/ctx-handover</code></li> <li>Related recipes: Typical KB Session, Recover an Aborted Session</li> </ul>","path":["Recipes","Knowledge Base","Build a Knowledge Base"],"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":"<p>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.</p> <p>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.</p>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-skill-create\n</code></pre> <p>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.</p>","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 <code>/ctx-skill-create</code> Skill Interactive skill creation and improvement workflow <code>ctx init</code> Command Deploys template skills to <code>.claude/skills/</code> 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":"<p>Good skill candidates:</p> <ul> <li>Checklists you repeat: deploy steps, release prep, code review</li> <li>Decisions the agent gets wrong: if you keep correcting the same behavior, encode the correction</li> <li>Multi-step workflows: anything with a sequence of commands and conditional branches</li> <li>Domain knowledge: project-specific terminology, architecture constraints, or conventions the agent cannot infer from code alone</li> </ul> <p>Not good candidates: one-off instructions, things the platform already handles (file editing, git operations), or tasks too narrow to reuse.</p>","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":"<p>Invoke the skill-creator:</p> <pre><code>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</code></pre> <p>Or capture a workflow you just did:</p> <pre><code>You: \"Turn what we just did into a skill\"\n\nAgent: [Extracts the steps from conversation history,\n confirms understanding, drafts the skill]\n</code></pre> <p>The skill-creator produces a <code>SKILL.md</code> file in <code>.claude/skills/your-skill/</code>.</p>","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":"<p>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.</p> <pre><code>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</code></pre>","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":"<p>The <code>description</code> field in frontmatter determines when a skill triggers. Claude tends to undertrigger - descriptions need to be specific and slightly \"pushy\":</p> <pre><code># 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</code></pre> <p>The skill-creator helps you tune this iteratively.</p>","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":"<p>If the skill should be available to all projects (not just this one), place it in <code>internal/assets/claude/skills/</code> so <code>ctx init</code> deploys it to new projects automatically.</p> <p>Most project-specific skills stay in <code>.claude/skills/</code> and travel with the repo.</p>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#skill-anatomy","level":2,"title":"Skill Anatomy","text":"<pre><code>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</code></pre> <p>Key sections in <code>SKILL.md</code>:</p> 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":"<ul> <li>Description is everything. A great skill with a vague description never fires. Spend time on trigger coverage - synonyms, concrete situations, edge cases.</li> <li>Stay under 500 lines. If your skill is growing past this, move detail into <code>references/</code> files and point to them from <code>SKILL.md</code>.</li> <li>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.</li> <li>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.</li> <li>Test negative triggers. Make sure the skill does not fire on unrelated prompts. A skill that activates too broadly becomes noise.</li> </ul>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#next-up","level":2,"title":"Next Up","text":"<p>Parallel Agent Development with Git Worktrees ->: Split work across multiple agents using git worktrees.</p>","path":["Recipes","Agents and Automation","Building Project Skills"],"tags":[]},{"location":"recipes/building-skills/#see-also","level":2,"title":"See Also","text":"<ul> <li>Skills Reference: full listing of all bundled and project-local skills</li> <li>Guide Your Agent: how commands, skills, and conversational patterns work together</li> <li>Design Before Coding: the four-skill chain for front-loading design work</li> </ul>","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":"<p>Claude Code's <code>.claude/settings.local.json</code> 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. </p> <p>A noisy \"allowlist\" makes it harder to spot dangerous permissions and increases the surface area for unintended behavior.</p> <p>Since <code>settings.local.json</code> is <code>.gitignore</code>d, it drifts independently of your codebase. There is no PR review, no CI check: just whatever you clicked \"Allow\" on.</p> <p>This recipe shows what a well-maintained permission file looks like and how to keep it clean.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx init # seeds safe defaults\n/ctx-drift # detects missing/stale permissions\n/ctx-permission-sanitize # audits for dangerous patterns\n</code></pre> <p>See Recommended Defaults for the full list.</p>","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 <code>ctx init</code> Populates default <code>ctx</code> permissions <code>/ctx-drift</code> Detects missing or stale permission entries <code>/ctx-permission-sanitize</code> 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":"<p>After running <code>ctx init</code>, your <code>settings.local.json</code> will have the <code>ctx</code> defaults pre-populated. Here is an opinionated safe starting point for a Go project using <code>ctx</code>:</p> <pre><code>{\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</code></pre> <p>This Is a Starting Point, Not a Mandate</p> <p>Your project may need more or fewer entries. </p> <p>The goal is intentional permissions: Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#design-principles","level":3,"title":"Design Principles","text":"<p>Use wildcards for trusted binaries: If you trust the binary (your own project's CLI, <code>make</code>, <code>go</code>), a single wildcard like <code>Bash(ctx:*)</code> beats twenty subcommand entries. It reduces noise and means new subcommands work without re-prompting.</p> <p>Keep <code>git</code> commands granular: Unlike <code>ctx</code> or <code>make</code>, git has both safe commands (<code>git log</code>, <code>git status</code>) and destructive ones (<code>git reset --hard</code>, <code>git clean -f</code>). Listing safe commands individually prevents accidentally pre-approving dangerous ones.</p> <p>Pre-approve all <code>ctx-</code> skills: Skills shipped with <code>ctx</code> (<code>Skill(ctx-*)</code>) 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.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#default-deny-rules","level":3,"title":"Default Deny Rules","text":"<p><code>ctx init</code> automatically populates <code>permissions.deny</code> 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.</p> <p>The defaults block:</p> Pattern Why <code>Bash(sudo *)</code> Cannot enter password; will hang <code>Bash(git push *)</code> Must be explicit user action <code>Bash(rm -rf /*)</code> etc. Recursive delete of system/home directories <code>Bash(curl *)</code> / <code>wget</code> Arbitrary network requests <code>Bash(chmod 777 *)</code> World-writable permissions <code>Read/Edit(**/.env*)</code> Secrets and credentials <code>Read(**/*.pem, *.key)</code> Private keys <p>Read/Edit Deny Rules</p> <p><code>Read()</code> and <code>Edit()</code> deny rules have known upstream enforcement issues (<code>claude-code#6631,#24846</code>). </p> <p>They are included as defense-in-depth and intent documentation.</p> <p>Blocked by default deny rules: no action needed, <code>ctx init</code> handles these:</p> Pattern Risk <code>Bash(git push:*)</code> Must be explicit user action <code>Bash(sudo:*)</code> Privilege escalation <code>Bash(rm -rf:*)</code> Recursive delete with no confirmation <code>Bash(curl:*)</code> / <code>Bash(wget:*)</code> Arbitrary network requests <p>Requires manual discipline: Never add these to <code>allow</code>:</p> Pattern Risk <code>Bash(git reset:*)</code> Can discard uncommitted work <code>Bash(git clean:*)</code> Deletes untracked files <code>Skill(ctx-permission-sanitize)</code> Edits this file: self-modification vector <code>Skill(release)</code> 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":"<p>Deny rules handle prefix-based blocking natively. Hooks complement them by catching patterns that require regex matching: Things deny rules can't express.</p> <p>The <code>ctx</code> plugin ships these blocking hooks:</p> Hook What it blocks <code>ctx system block-non-path-ctx</code> Running <code>ctx</code> from wrong path <p>Project-local hooks (not part of the plugin) catch regex edge cases:</p> Hook What it blocks <code>block-dangerous-commands.sh</code> Mid-command <code>sudo</code>/<code>git push</code> (after <code>&&</code>), copies to bin dirs, absolute-path <code>ctx</code> <p>Pre-Approved + Hook-Blocked = Silent Block</p> <p>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.</p> <p>It's better not to pre-approve commands that hooks are designed to intercept.</p>","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":"<p>Permissions accumulate fastest during debugging and exploration sessions. After a session where you clicked \"Allow\" many times:</p> <ol> <li>Open <code>.claude/settings.local.json</code> in your editor;</li> <li>Look for entries at the bottom of the allowlist (new entries append there);</li> <li>Delete anything that looks session-specific:<ul> <li>Exact commands with hardcoded paths,</li> <li>Commands with literal string arguments,</li> <li>Entries that duplicate an existing wildcard.</li> </ul> </li> </ol> <p>See the Sanitize Permissions runbook for a step-by-step procedure.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#periodically","level":3,"title":"Periodically","text":"<p>Run <code>/ctx-drift</code> to catch permission drift:</p> <ul> <li>Missing <code>Bash(ctx:*)</code> wildcard;</li> <li>Missing <code>Skill(ctx-*)</code> entries for installed skills;</li> <li>Stale <code>Skill(ctx-*)</code> entries for removed skills;</li> <li>Granular <code>Bash(ctx <subcommand>:*)</code> entries that should be consolidated.</li> </ul> <p>Run <code>/ctx-permission-sanitize</code> to catch security issues:</p> <ul> <li>Hook bypass patterns</li> <li>Destructive commands</li> <li>Overly broad permissions</li> <li>Injection vectors</li> </ul>","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":"<p>If you create a custom <code>ctx-*</code> skill, add its <code>Skill()</code> entry to the allowlist manually. </p> <p><code>ctx init</code> only populates the default permissions: It won't pick up custom skills.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#golden-image-snapshots","level":3,"title":"Golden Image Snapshots","text":"<p>If manual cleanup is too tedious, use a golden image to automate it: </p> <p>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.</p>","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":"<p>The recommended defaults above are Go-specific. For other stacks, swap the build/test tooling:</p> <p>Node.js / TypeScript:</p> <pre><code>\"Bash(npm run:*)\",\n\"Bash(npm test:*)\",\n\"Bash(npx:*)\",\n\"Bash(node:*)\"\n</code></pre> <p>Python:</p> <pre><code>\"Bash(pytest:*)\",\n\"Bash(python:*)\",\n\"Bash(pip show:*)\",\n\"Bash(ruff:*)\"\n</code></pre> <p>Rust:</p> <pre><code>\"Bash(cargo build:*)\",\n\"Bash(cargo test:*)\",\n\"Bash(cargo clippy:*)\",\n\"Bash(cargo fmt:*)\"\n</code></pre> <p>The <code>ctx</code>, <code>git</code>, and skill entries remain the same across all stacks.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#next-up","level":2,"title":"Next Up","text":"<p>Permission Snapshots →: Save and restore permission baselines for reproducible setups.</p>","path":["Recipes","Maintenance","Claude Code Permission Hygiene"],"tags":[]},{"location":"recipes/claude-code-permissions/#see-also","level":2,"title":"See Also","text":"<ul> <li>Setting Up <code>ctx</code> Across AI Tools: full setup recipe including <code>settings.local.json</code> creation</li> <li>Context Health: keeping <code>.context/</code> files accurate</li> <li>Sanitize Permissions runbook: manual cleanup procedure</li> </ul>","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":"<p>Switch between dev and base runtime configurations without editing <code>.ctxrc</code> by hand. Useful when you want verbose logging and webhook notifications during development, then clean defaults for normal sessions.</p> <p>Uses: <code>ctx config switch</code>, <code>ctx config status</code>, <code>/ctx-config</code></p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#how-it-works","level":2,"title":"How It Works","text":"<p>The <code>ctx</code> repo ships two source profiles committed to git:</p> File Profile Description <code>.ctxrc.base</code> base All defaults, notifications off <code>.ctxrc.dev</code> dev Verbose logging, webhook notifications on <p>The working copy (<code>.ctxrc</code>) is gitignored. Switching profiles copies the source file over <code>.ctxrc</code>, so your runtime configuration is always a clean snapshot of one of the two sources.</p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#switching-profiles","level":2,"title":"Switching Profiles","text":"<pre><code># 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</code></pre> <p>The detection heuristic checks for an uncommented <code>notify:</code> line in <code>.ctxrc</code>: present means dev, absent means base.</p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#checking-the-active-profile","level":2,"title":"Checking the Active Profile","text":"<pre><code>ctx config status\n</code></pre> <p>Output examples:</p> <pre><code>active: dev (verbose logging enabled)\nactive: base (defaults)\nactive: none (.ctxrc does not exist)\n</code></pre>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#typical-workflow","level":2,"title":"Typical Workflow","text":"<ol> <li>Start of a debugging session: switch to dev for verbose logging and webhook notifications so you can trace hook activity and get push alerts.</li> </ol> <pre><code>ctx config switch dev\n</code></pre> <ol> <li> <p>Work through the issue: hooks log verbosely, webhooks fire on key events (commits, ceremony nudges, drift warnings).</p> </li> <li> <p>Done debugging: switch back to base to silence the noise.</p> </li> </ol> <pre><code>ctx config switch base\n</code></pre>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#customizing-profiles","level":2,"title":"Customizing Profiles","text":"<p>Edit the source files directly:</p> <ul> <li><code>.ctxrc.dev</code>: add any <code>.ctxrc</code> keys you want active during development (e.g., <code>log_level: debug</code>, <code>notify.events</code>, <code>notify.webhook_url</code>).</li> <li><code>.ctxrc.base</code>: keep this minimal. It represents your \"production\" defaults.</li> </ul> <p>After editing a source file, re-run <code>ctx config switch <profile></code> to apply the changes to the working copy.</p> <p>Commit Your Profiles</p> <p>Both <code>.ctxrc.base</code> and <code>.ctxrc.dev</code> should be committed to git so team members share the same profile definitions. The working copy <code>.ctxrc</code> stays gitignored.</p>","path":["Recipes","Maintenance","Configuration Profiles"],"tags":[]},{"location":"recipes/configuration-profiles/#using-the-skill","level":2,"title":"Using the Skill","text":"<p>In a Claude Code session, say any of:</p> <ul> <li>\"switch to dev mode\"</li> <li>\"switch to base\"</li> <li>\"what profile am I on?\"</li> <li>\"toggle verbose logging\"</li> </ul> <p>The <code>/ctx-config</code> skill handles the rest.</p> <p>See also: <code>ctx config</code> reference, Configuration</p>","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":"<p><code>ctx</code> files drift: you rename a package, delete a module, or finish a sprint, and suddenly <code>ARCHITECTURE.md</code> references paths that no longer exist, <code>TASKS.md</code> is 80 percent completed checkboxes, and <code>CONVENTIONS.md</code> describes patterns you stopped using two months ago.</p> <p>Stale context is worse than no context: </p> <p>An AI tool that trusts outdated references will hallucinate confidently.</p> <p>This recipe shows how to detect drift, fix it, and keep your <code>.context/</code> directory lean and accurate.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Or just ask your agent: \"Is our context clean?\"</p>","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 <code>ctx drift</code> Command Detect stale paths, missing files, violations <code>ctx drift --fix</code> Command Auto-fix simple issues <code>ctx sync</code> Command Reconcile context with codebase structure <code>ctx compact</code> Command Archive completed tasks, clean up empty sections <code>ctx fmt</code> Command Normalize context files to 80-char line width <code>ctx status</code> Command Quick health overview <code>/ctx-drift</code> Skill Structural plus semantic drift detection <code>/ctx-architecture</code> Skill Refresh <code>ARCHITECTURE.md</code> from actual codebase <code>/ctx-status</code> Skill In-session context summary <code>/ctx-prompt-audit</code> 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":"<p>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. </p> <p>For day-to-day maintenance, talk to your agent.</p> <p>Your Questions Reinforce the Pattern</p> <p>Asking \"is our context clean?\" does two things:</p> <ul> <li>It triggers a drift check right now</li> <li>It reinforces the habit</li> </ul> <p>This is reinforcement, not enforcement.</p> <p>Do not wait for the agent to be proactive on its own: </p> <p>Guide your agent, especially in early sessions.</p> <p>Over time, you will ask less and the agent will start offering more.</p>","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":"<p>The simplest way to check context health:</p> <pre><code>Is our context clean?\nAnything stale?\nHow healthy are our context files?\n</code></pre> <p>Or invoke the skill directly:</p> <pre><code>/ctx-drift\n</code></pre> <p>The agent performs two layers of analysis:</p> <p>Layer 1, structural checks (via <code>ctx drift</code>): Dead paths, missing files, completed task counts, constitution violations. Fast and programmatic.</p> <p>Layer 2, semantic analysis (agent-driven): Does <code>CONVENTIONS.md</code> describe patterns the code no longer follows? Does <code>DECISIONS.md</code> 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.</p> <p>The agent reports both layers together, explains each finding in plain language, and offers to fix what it can.</p>","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":"<p>You do not need to ask explicitly. </p> <p>Using Claude Code</p> <p><code>ctx</code> ships with Claude Code hooks that remind the agent at the right time to take initiative. </p> <p>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:</p> <pre><code>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</code></pre> <p>☝️️ this is what persistent, initiative-driven sessions feel like when context is treated as a system instead of a prompt.</p> <p>If the agent does not offer this on its own, a gentle nudge is enough:</p> <pre><code>Anything stale before we start?\nHow's the context looking?\n</code></pre> <p>This turns maintenance from a scheduled chore into a conversation that happens when it matters.</p>","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":"<p>Agents can notice drift while working: When a mismatch is directly in the path of their current task. If an agent reads <code>ARCHITECTURE.md</code> to find where to add a handler and <code>internal/handlers/</code> doesn't exist, it will notice because the stale reference blocks its work:</p> <pre><code>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</code></pre> <p>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 <code>/ctx-drift</code> exists and to decide the current task should pause for maintenance.</p> <p>If you want that behavior, reinforce it:</p> <pre><code>Good catch. Yes, run /ctx-drift and clean up any other stale references.\n</code></pre> <p>Over time, agents that have seen this pattern will start offering proactively. But do not expect it from a cold start.</p>","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":"<p><code>ctx drift</code> detects when <code>TASKS.md</code> has more than 10 completed items and flags it as a staleness warning. Running <code>ctx drift --fix</code> archives completed tasks automatically. </p> <p>You can also run <code>/ctx-archive</code> to compact on demand.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#knowledge-health-flow","level":3,"title":"Knowledge Health Flow","text":"<p>Over time, LEARNINGS.md and DECISIONS.md accumulate entries that overlap or partially repeat each other. The <code>check-persistence</code> hook detects when entry counts exceed a configurable threshold and surfaces a nudge:</p> <p>\"LEARNINGS.md has 25+ entries. Consider running /ctx-consolidate to merge overlapping items.\"</p> <p>The consolidation workflow:</p> <ol> <li>Review: <code>/ctx-consolidate</code> groups entries by keyword similarity and presents candidate merges for your approval.</li> <li>Merge: Approved groups are combined into single entries that preserve the key information from each original.</li> <li>Archive: Originals move to <code>.context/archive/</code>, not deleted -- the full history is preserved in git and the archive directory.</li> <li>Verify: Run <code>ctx drift</code> after consolidation to confirm no cross-references were broken by the merge.</li> </ol> <p>This replaces ad-hoc cleanup with a repeatable, nudge-driven cycle: detect accumulation, review candidates, merge with approval, archive originals.</p> <p>See also: Knowledge Capture for the recording workflow that feeds into this maintenance cycle.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-doctor-the-superset-check","level":2,"title":"<code>ctx doctor</code>: The Superset Check","text":"<p><code>ctx doctor</code> 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:</p> <pre><code>ctx doctor # everything in one pass\nctx doctor --json # machine-readable for scripting\n</code></pre> <p>Use <code>/ctx-doctor</code> Too</p> <p>For agent-driven diagnosis that adds semantic analysis on top of the structural checks, use <code>/ctx-doctor</code>. </p> <p>See the Troubleshooting recipe for the full workflow.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#cli-reference","level":2,"title":"CLI Reference","text":"<p>The conversational approach above uses CLI commands under the hood. When you need direct control, use the commands directly.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift","level":3,"title":"<code>ctx drift</code>","text":"<p>Scan context files for structural problems:</p> <pre><code>ctx drift\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> 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 <p>Exit codes: <code>0</code> equals clean, <code>1</code> equals warnings, <code>3</code> equals violations.</p> <p>For CI integration:</p> <pre><code>ctx drift --json | jq '.warnings | length'\n</code></pre>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-drift-fix","level":3,"title":"<code>ctx drift --fix</code>","text":"<p>Auto-fix mechanical issues:</p> <pre><code>ctx drift --fix\n</code></pre> <p>This handles removing dead path references, updating unambiguous renames, clearing empty sections. Issues requiring judgment are flagged but left for you.</p> <p>Run <code>ctx drift</code> again afterward to confirm what remains.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-sync","level":3,"title":"<code>ctx sync</code>","text":"<p>After a refactor, reconcile context with the actual codebase structure:</p> <pre><code>ctx sync --dry-run # preview first\nctx sync # apply\n</code></pre> <p><code>ctx sync</code> scans for structural changes, compares with <code>ARCHITECTURE.md</code>, checks for new dependencies worth documenting, and identifies context referring to code that no longer exists.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-compact","level":3,"title":"<code>ctx compact</code>","text":"<p>Consolidate completed tasks and clean up empty sections:</p> <pre><code>ctx compact # move completed tasks to Completed section,\n # remove empty sections\nctx compact --archive # also archive old tasks to .context/archive/\n</code></pre> <ul> <li>Tasks: moves completed items (with all subtasks done) into the Completed section of <code>TASKS.md</code></li> <li>All files: removes empty sections left behind</li> <li>With <code>--archive</code>: writes tasks older than 7 days to <code>.context/archive/tasks-YYYY-MM-DD.md</code></li> </ul> <p>Without <code>--archive</code>, nothing is deleted: Tasks are reorganized in place.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-fmt","level":3,"title":"<code>ctx fmt</code>","text":"<p>Normalize context file line widths:</p> <pre><code>ctx fmt # wrap long lines to 80 chars\nctx fmt --check # CI: exit 1 if files need formatting\n</code></pre> <p>Long task descriptions, decision rationale, and learning entries accumulate as single-line entries. <code>ctx fmt</code> wraps them at word boundaries with 2-space continuation indent for list items. Headings, tables, and comments are preserved.</p> <p>Idempotent: safe to run repeatedly.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-status","level":3,"title":"<code>ctx status</code>","text":"<p>Quick health overview:</p> <pre><code>ctx status --verbose\n</code></pre> <p>Shows file counts, token estimates, modification times, and drift warnings in a single glance.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#ctx-prompt-audit","level":3,"title":"<code>/ctx-prompt-audit</code>","text":"<p>Checks whether your context files are readable, compact, and token-efficient for the model.</p> <pre><code>/ctx-prompt-audit\n</code></pre>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>Conversational approach (recommended):</p> <pre><code>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</code></pre> <p>CLI approach (for CI, scripts, or direct control):</p> <pre><code>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</code></pre>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#tips","level":2,"title":"Tips","text":"<p>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 <code>/ctx-drift</code>. Over time, it starts offering.</p> <p>When an agent says \"this reference looks stale,\" it is usually right.</p> <p>Semantic drift is more damaging than structural drift: <code>ctx drift</code> catches dead paths. But <code>CONVENTIONS.md</code> 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.</p> <p>Use <code>ctx status</code> 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.</p> <p>Drift detection in CI: add <code>ctx drift --json</code> to your CI pipeline and fail on exit code 3 (violations). This catches constitution-level problems before they reach upstream.</p> <p>Do not over-compact: Completed tasks have historical value. The <code>--archive</code> flag preserves them in <code>.context/archive/</code> so you can search past work without cluttering active context.</p> <p>Sync is cautious by default: Use <code>--dry-run</code> after large refactors, then apply.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#next-up","level":2,"title":"Next Up","text":"<p>Claude Code Permission Hygiene →: Recommended permission defaults and maintenance workflow for Claude Code.</p>","path":["Recipes","Maintenance","Detecting and Fixing Drift"],"tags":[]},{"location":"recipes/context-health/#see-also","level":2,"title":"See Also","text":"<ul> <li>Troubleshooting: full diagnostic workflow using <code>ctx doctor</code>, event logs, and <code>/ctx-doctor</code></li> <li>Tracking Work Across Sessions: task lifecycle and archival</li> <li>Persisting Decisions, Learnings, and Conventions: keeping knowledge files current</li> <li>The Complete Session: where maintenance fits in the daily workflow</li> <li>CLI Reference: full flag documentation for all commands</li> <li>Context Files: structure and purpose of each <code>.context/</code> file</li> </ul>","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":"<p><code>ctx</code> hooks speak <code>ctx</code>'s language, not your project's. The QA gate says \"lint the ENTIRE project\" and \"make build,\" but your Python project uses <code>pytest</code> and <code>ruff</code>. The post-commit nudge suggests running lints, but your project uses <code>npm test</code>. You could remove the hook entirely, but then you lose the logic (counting, state tracking, adaptive frequency) just to change the words.</p> <p>How do you customize what hooks say without removing what they do?</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre>","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 <code>ctx hook message list</code> CLI command Show all hook messages with category and override status <code>ctx hook message show</code> CLI command Print the effective message template <code>ctx hook message edit</code> CLI command Copy embedded default to <code>.context/</code> for editing <code>ctx hook message reset</code> 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":"<p>Hook messages use a 3-tier fallback:</p> <ol> <li>User override: <code>.context/hooks/messages/{hook}/{variant}.txt</code></li> <li>Embedded default: compiled into the <code>ctx</code> binary</li> <li>Hardcoded fallback: belt-and-suspenders safety net</li> </ol> <p>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.</p>","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":"<p>The default templates live in the <code>ctx</code> source tree at:</p> <pre><code>internal/assets/hooks/messages/{hook}/{variant}.txt\n</code></pre> <p>You can also browse them on GitHub: <code>internal/assets/hooks/messages/</code></p> <p>Or use <code>ctx hook message show</code> to print any template without digging through source code:</p> <pre><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</code></pre> <p>The <code>show</code> output includes the template source and available variables -- everything you need to write a replacement.</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#template-variables","level":3,"title":"Template Variables","text":"<p>Some messages use Go <code>text/template</code> variables for dynamic content:</p> <pre><code>No context files updated in {{.PromptsSinceNudge}}+ prompts.\nHave you discovered learnings, made decisions,\nestablished conventions, or completed tasks\nworth persisting?\n</code></pre> <p>The <code>show</code> and <code>edit</code> commands list available variables for each message. When writing a replacement, keep the same <code>{{.VariableName}}</code> placeholders to preserve dynamic content. Variables that you omit render as <code><no value></code>: no error, but the output may look odd.</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#intentional-silence","level":3,"title":"Intentional Silence","text":"<p>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 <code>hooks.json</code>.</p>","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":"<p>The default QA gate says \"lint the ENTIRE project\" and references <code>make lint</code>. For a Python project, you want <code>pytest</code> and <code>ruff</code>:</p> <pre><code># 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</code></pre> <p>Replace the content in <code>.context/hooks/messages/qa-reminder/gate.txt</code>:</p> <pre><code>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</code></pre> <p>The hook still fires on every <code>Edit</code> call. The logic is identical. Only the instructions changed.</p>","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":"<p>The ceremony check nudges you to use <code>/ctx-remember</code> and <code>/ctx-wrap-up</code>. If your team has a different workflow and finds these noisy:</p> <pre><code>ctx hook message edit check-ceremonies both\nctx hook message edit check-ceremonies remember\nctx hook message edit check-ceremonies wrapup\n</code></pre> <p>Then empty each file:</p> <pre><code>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</code></pre> <p>The hooks still track ceremony usage internally, but they no longer emit any visible output.</p>","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":"<p>The default post-commit nudge mentions generic \"lints and tests.\" For a JavaScript project:</p> <pre><code>ctx hook message edit post-commit nudge\n</code></pre> <p>Replace with:</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#the-two-categories","level":2,"title":"The Two Categories","text":"<p>Not all messages are equal. The <code>list</code> command shows each message's category:</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#customizable-17-messages","level":3,"title":"Customizable (17 Messages)","text":"<p>Messages that are opinions: project-specific wording that benefits from customization. These are the primary targets for override.</p> 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":"<p>Messages specific to <code>ctx</code>'s own development workflow. You can customize them, but <code>edit</code> will warn you first.</p> 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 <code>{{.StaleFiles}}</code> check-context-size checkpoint (none) check-context-size oversize <code>{{.TokenCount}}</code> check-context-size window <code>{{.TokenCount}}</code>, <code>{{.Percentage}}</code> check-ceremonies both, remember, wrapup (none) check-journal both <code>{{.UnimportedCount}}</code>, <code>{{.UnenrichedCount}}</code> check-journal unenriched <code>{{.UnenrichedCount}}</code> check-journal unimported <code>{{.UnimportedCount}}</code> check-knowledge warning <code>{{.FileWarnings}}</code> check-map-staleness stale <code>{{.LastRefreshDate}}</code>, <code>{{.ModuleCount}}</code> check-persistence nudge <code>{{.PromptsSinceNudge}}</code> check-reminders reminders <code>{{.ReminderList}}</code> check-resources alert <code>{{.AlertMessages}}</code> check-version key-rotation <code>{{.KeyAgeDays}}</code> check-version mismatch <code>{{.BinaryVersion}}</code>, <code>{{.PluginVersion}}</code> post-commit nudge (none) qa-reminder gate (none) block-dangerous-commands all variants (none) block-non-path-ctx all variants (none) <p>Templates that reference undefined variables render <code><no value></code>: no error, graceful degradation.</p>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#tips","level":2,"title":"Tips","text":"<ul> <li>Override files are version-controlled: they live in <code>.context/</code> alongside your other context files. Team members get the same customized messages.</li> <li>Start with <code>show</code>: always check the current default before editing. The embedded template is the baseline your override replaces.</li> <li>Use <code>reset</code> to undo: if a customization causes confusion, reset reverts to the embedded default instantly.</li> <li>Empty file = silence: you don't need to delete the hook. An empty override file silences the message while preserving the hook's logic.</li> <li>JSON output for scripting: <code>ctx hook message list --json</code> returns structured data for automation.</li> </ul>","path":["Recipes","Hooks and Notifications","Customizing Hook Messages"],"tags":[]},{"location":"recipes/customizing-hook-messages/#see-also","level":2,"title":"See Also","text":"<ul> <li>Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates</li> <li>Auditing System Hooks: verifying hooks are running and auditing their output</li> <li>Configuration: project-level settings via <code>.ctxrc</code></li> </ul>","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":"<p>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.</p> <p>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.</p> <p>How do you front-load design so the implementation is straightforward?</p>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-brainstorm # explore the design space\n/ctx-spec # write the spec document\n/ctx-task-out # decompose into a milestone plan\n/ctx-implement # execute step-by-step\n</code></pre> <p>Four skills, used in sequence. Each produces an artifact that feeds the next. For specs small enough to implement in one session, the spec doubles as the plan: skip <code>/ctx-task-out</code> and break the work into TASKS.md entries with <code>/ctx-task-add</code> instead.</p>","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 <code>/ctx-brainstorm</code> Skill Structured design dialogue: explore approaches <code>/ctx-spec</code> Skill Scaffold and fill out a spec from the template <code>/ctx-task-out</code> Skill Decompose a spec into <code>specs/plans/<milestone>.md</code> <code>/ctx-task-add</code> Skill Add implementation tasks to TASKS.md <code>/ctx-implement</code> Skill Execute a plan step-by-step with verification <code>/ctx-decision-add</code> 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":"<p>Start with <code>/ctx-brainstorm</code> when you have a rough idea but haven't committed to an approach. The skill follows a gated process:</p> <ol> <li>Understand context: what exists today, what's the gap</li> <li>Clarify the idea: one question at a time, not a wall of questions</li> <li>Surface non-functional requirements: performance, security, compatibility</li> <li>Lock understanding: confirm before exploring solutions</li> <li>Explore 2-3 approaches: with trade-offs for each</li> <li>Stress-test: poke holes in the chosen approach</li> <li>Present the design: detailed enough to implement from</li> </ol> <pre><code>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</code></pre> <p>The brainstorm produces a validated design in conversation. It doesn't produce a file - that's what the spec is for.</p>","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":"<p>Once the design is clear, use <code>/ctx-spec</code> to produce the written artifact. The skill reads the project's spec template (<code>specs/tpl/spec-template.md</code>) and walks through each section:</p> <pre><code>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</code></pre> <p>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.</p> <p>Sections that don't apply can be skipped. The result is a complete spec at <code>specs/{feature-name}.md</code>.</p>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#step-3-task-out-the-work","level":3,"title":"Step 3: Task Out the Work","text":"<p>After the spec is written, the skill routes by size. A small, single-session spec gets tasks in TASKS.md directly:</p> <pre><code>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</code></pre> <p>Each task is independently completable and references the spec via <code>Spec: specs/rss-feed.md</code> in the Phase header.</p> <p>You can also invoke <code>/ctx-task-add</code> directly at any point to add individual tasks.</p> <p>A spec that spans multiple milestones (or more than about one session of implementation) gets <code>/ctx-task-out</code> instead:</p> <pre><code>You: /ctx-task-out --spec specs/v1-substrate.md --milestone m0a\n\nAgent: \"Open questions check: D-001 (language choice) is blocking\n for m0a — three tasks would embed an assumption about its\n answer. Resolve it before I decompose.\"\n\nYou: [resolves D-001 in the spec]\n\nAgent: [writes specs/plans/m0a.md: data model, contracts, test\n matrix, 24 tasks with falsifiable acceptance criteria]\n \"Plan written. TASKS.md gained 4 epic anchors, each\n annotated Plan: specs/plans/m0a.md.\"\n</code></pre> <p>The plan document owns the fine-grained tasks; TASKS.md carries epic-level anchors only. Two hard gates apply: decomposition refuses to run past a blocking open question in the spec, and milestone N+1 is not tasked out while milestone N's definition of done is unmet.</p>","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":"<p>Pick up the work with <code>/ctx-implement</code>. The skill loads the plan — <code>specs/plans/<milestone>.md</code> when <code>/ctx-task-out</code> produced one, the spec itself for small features — breaks it into atomic steps, and checkpoints after every 3-5 steps with a build and test verification:</p> <pre><code>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</code></pre> <p>If a build or test fails, the agent stops, diagnoses, and fixes before continuing.</p>","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":"<p>Not every feature needs all four steps. Use your judgment:</p> 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: Task out Tasks exist, ready to code Step 4: Implement <p>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.</p>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't need skill names. Natural language works:</p> You say What happens \"Let's think through this feature\" <code>/ctx-brainstorm</code> \"Spec this out\" <code>/ctx-spec</code> \"Write a design doc for...\" <code>/ctx-spec</code> \"Task this out\" <code>/ctx-task-out</code> \"Break this into tasks\" <code>/ctx-task-add</code> \"Implement the spec\" <code>/ctx-implement</code> \"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":"<ul> <li>Brainstorm first when uncertain. If you can articulate the approach in two sentences, skip to spec. If you can't, brainstorm.</li> <li>Specs prevent scope creep. The Non-Goals section is as important as the approach. Writing down what you won't do keeps implementation focused.</li> <li>Edge cases are the point. A spec that only describes the happy path isn't a spec - it's a wish. The <code>/ctx-spec</code> skill pushes for at least 3 edge cases because that's where designs break.</li> <li>Record decisions during brainstorming. When you choose between approaches, the agent offers to persist the trade-off via <code>/ctx-decision-add</code>. Accept - future sessions need to know why, not just what.</li> <li>Specs are living documents. Update them when implementation reveals new constraints. A spec that diverges from reality is worse than no spec.</li> <li>The spec template is customizable. Edit <code>specs/tpl/spec-template.md</code> to match your project's needs. The <code>/ctx-spec</code> skill reads whatever template it finds there.</li> </ul>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/design-before-coding/#see-also","level":2,"title":"See Also","text":"<ul> <li>Skills Reference: /ctx-brainstorm: structured design dialogue</li> <li>Skills Reference: /ctx-spec: spec scaffolding from template</li> <li>Skills Reference: /ctx-task-out: spec decomposition into a per-milestone plan</li> <li>Skills Reference: /ctx-implement: step-by-step execution with verification</li> <li>Scrutinizing a Plan: the adversarial interview that belongs between brainstorm and spec</li> <li>Spec-Driven Development: the full operator's manual for the chain — the debated brief, per-milestone tasking, and the gates — when a feature spans several milestones</li> <li>Tracking Work Across Sessions: task lifecycle and archival</li> <li>Importing Claude Code Plans: turning ephemeral plans into permanent specs</li> <li>Persisting Decisions, Learnings, and Conventions: capturing design trade-offs</li> </ul>","path":["Recipes","Knowledge and Tasks","Design Before Coding"],"tags":[]},{"location":"recipes/guide-your-agent/","level":1,"title":"Guide Your Agent","text":"<p>Commands vs. Skills</p> <p>Commands (<code>ctx status</code>, <code>ctx task add</code>) run in your terminal.</p> <p>Skills (<code>/ctx-reflect</code>, <code>/ctx-next</code>) run inside your AI coding assistant.</p> <p>Recipes combine both.</p> <p>Think of commands as structure and skills as behavior.</p>","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#proactive-behavior","level":2,"title":"Proactive Behavior","text":"<p>These recipes show explicit commands and skills, but agents trained on the <code>ctx</code> 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.</p> <p>Your questions train the agent. Asking \"what have we learned?\" or \"is our context clean?\" does two things:</p> <ul> <li>It triggers the workflow right now,</li> <li>and it reinforces the pattern.</li> </ul> <p>The more you guide, the more the agent habituates the behavior and begins offering on its own.</p> <p>Each recipe includes a Conversational Approach section showing these natural-language patterns.</p> <p>Tip</p> <p>Don't wait passively for proactive behavior: especially in early sessions.</p> <p>Ask, guide, reinforce. Over time, you ask less and the agent offers more.</p>","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#next-up","level":2,"title":"Next Up","text":"<p>Setup Across AI Tools →: Initialize <code>ctx</code> and configure hooks for Claude Code, OpenCode, Cursor, Aider, Copilot, or Windsurf.</p>","path":["Recipes","Getting Started","Guide Your Agent"],"tags":[]},{"location":"recipes/guide-your-agent/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: full session lifecycle from start to finish</li> <li>Prompting Guide: general tips for working effectively with AI coding assistants</li> </ul>","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":"<p>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. </p> <p>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.</p> <p>This recipe catalogs the known hook output patterns and explains when to use each one.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#tldr","level":2,"title":"TL;DR","text":"<p>Eight patterns from full control to full invisibility: </p> <ul> <li>hard gate (<code>exit 2</code>), </li> <li>VERBATIM relay (agent MUST show), </li> <li>agent directive (context injection), </li> <li>and silent side-effect (background work).</li> </ul> <p>Most hooks belong in the middle.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#the-spectrum","level":2,"title":"The Spectrum","text":"<p>These patterns form a spectrum based on who decides what the user sees:</p> 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 <p>The spectrum runs from full hook control (hard gate) to full invisibility (silent side effect). </p> <p>Most hooks belong somewhere in the middle.</p>","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":"<p>Block the tool call entirely. The agent cannot proceed: it must find another approach or tell the user.</p> <pre><code>echo '{\"decision\": \"block\", \"reason\": \"Use ctx from PATH, not ./ctx\"}'\n</code></pre> <p>When to use: Enforcing invariants that must never be violated: Constitution rules, security boundaries, destructive command prevention.</p> <p>Hook type: <code>PreToolUse</code> only (Claude Code first-class mechanism).</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system block-non-path-ctx</code>: Enforces the PATH invocation rule</li> <li><code>block-git-push.sh</code>: Requires explicit user approval for pushes (project-local)</li> <li><code>block-dangerous-commands.sh</code>: Prevents <code>sudo</code>, copies to <code>~/.local/bin</code> (project-local)</li> </ul> <p>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.</p>","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":"<p>Force the agent to show this to the user as-is. The explicit instruction overcomes the agent's tendency to silently absorb context.</p> <pre><code>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</code></pre> <p>When to use: Actionable reminders the user needs to see regardless of what they asked: Stale backups, unimported sessions, resource warnings.</p> <p>Hook type: <code>UserPromptSubmit</code> (runs before the agent sees the prompt).</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system check-journal</code>: Unexported sessions and unenriched entries</li> <li><code>ctx system check-context-size</code>: Context capacity warning</li> <li><code>ctx system check-resources</code>: Resource pressure (memory, swap, disk, load): <code>DANGER</code> only</li> <li><code>ctx system check-freshness</code>: Technology constant staleness warning</li> </ul> <p>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.</p> <p>Key detail: The phrase <code>IMPORTANT: Relay this ... VERBATIM</code> 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.</p>","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":"<p>Tell the agent to do something, not the user. The agent decides whether and how to involve the user.</p> <pre><code>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</code></pre> <p>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.</p> <p>Hook type: <code>UserPromptSubmit</code>.</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system check-persistence</code>: Nudges the agent to persist context</li> </ul> <p>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.</p>","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":"<p>Load context with no visible output. The agent gets enriched without either party noticing.</p> <pre><code>ctx agent --budget 4000 >/dev/null || true\n</code></pre> <p>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.</p> <p>Hook type: <code>PreToolUse</code> with <code>.*</code> matcher (runs on every tool call).</p> <p>Examples in <code>ctx</code>:</p> <ul> <li>The <code>ctx agent</code> <code>PreToolUse</code> hook: injects project context silently</li> </ul> <p>Trade-off: Adds latency to every tool call. Keep the injected content small and fast to generate.</p>","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":"<p>Do work, produce no output: Housekeeping that needs no acknowledgment.</p> <pre><code>find \"$CTX_TMPDIR\" -type f -mtime +15 -delete\n</code></pre> <p>When to use: Cleanup, log rotation, temp file management. Anything where the action is the point and nobody needs to know it happened.</p> <p>Hook type: Any hook where output is irrelevant.</p> <p>Examples in <code>ctx</code>:</p> <ul> <li>Log rotation, marker file cleanup, state directory maintenance</li> </ul> <p>Trade-off: None, if the action is truly invisible. If it can fail in a way that matters, consider logging.</p>","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":"<p>Tell the agent to relay only if a condition holds in context.</p> <pre><code>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</code></pre> <p>When to use: Warnings that only matter in certain contexts. Avoids noise when the user is doing unrelated work.</p> <p>Trade-off: Depends on the agent's judgment about when the condition holds. More fragile than VERBATIM relay, but less noisy.</p>","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":"<p>Give the agent a specific command to propose to the user.</p> <pre><code>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</code></pre> <p>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.</p> <p>Trade-off: The suggestion might be wrong or outdated. The \"ask the user before proceeding\" part is critical.</p>","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":"<p>Different urgency tiers with different relay expectations.</p> <pre><code># 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</code></pre> <p>When to use: When you have multiple hooks producing output and need to avoid overwhelming the user. <code>INFO</code> gets absorbed, <code>WARN</code> gets mentioned, <code>CRITICAL</code> interrupts.</p> <p>Examples in <code>ctx</code>:</p> <ul> <li><code>ctx system check-resources</code>: Uses two tiers (<code>WARNING</code>/<code>DANGER</code>) internally but only fires the VERBATIM relay at <code>DANGER</code> level: <code>WARNING</code> is silent. See <code>ctx system</code> for the user-facing command that shows both tiers.</li> </ul> <p>Trade-off: Requires agent training or convention to recognize the tiers. Without a shared protocol, the prefixes are just text.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#choosing-a-pattern","level":2,"title":"Choosing a Pattern","text":"<pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#design-tips","level":2,"title":"Design Tips","text":"<p>Throttle aggressively: VERBATIM relays that fire every prompt will be ignored or resented. Use once-per-day markers (<code>touch $REMINDED</code>), adaptive frequency (every Nth prompt), or staleness checks (only fire if condition persists).</p> <p>Include actionable commands: \"You have 12 unimported sessions\" is less useful than \"You have 12 unimported sessions. Run: <code>ctx journal import --all</code>.\" Give the user (or agent) the exact next step.</p> <p>Use box-drawing for visual structure: The <code>┌─ ─┐ │ └─ ─┘</code> pattern makes hook output visually distinct from agent prose. It also signals \"this is machine-generated, not agent opinion.\"</p> <p>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.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#common-pitfalls","level":2,"title":"Common Pitfalls","text":"<p>Lessons from 19 days of hook debugging in <code>ctx</code>. Every one of these was encountered, debugged, and fixed in production.</p>","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":"<pre><code>{ \"PreToolUseHooks\": [ ... ] }\n</code></pre> <p>The key is <code>PreToolUse</code>, not <code>PreToolUseHooks</code>. Claude Code validates silently: A misspelled key means the hook is ignored with no error. Always test with a debug <code>echo</code> first to confirm the hook fires before adding real logic.</p>","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":"<p>Go's <code>json.Marshal</code> escapes <code>></code>, <code><</code>, and <code>&</code> as Unicode sequences (<code>\\u003e</code>) by default. This breaks shell commands in generated config:</p> <pre><code>\"command\": \"ctx agent 2\\u003e/dev/null\"\n</code></pre> <p>Fix: use <code>json.Encoder</code> with <code>SetEscapeHTML(false)</code> when generating hook configuration.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#stdin-not-environment-variables","level":3,"title":"<code>stdin</code>, Not Environment Variables","text":"<p>Hook input arrives as JSON via <code>stdin</code>, not environment variables:</p> <pre><code># Wrong:\nCOMMAND=\"$CLAUDE_TOOL_INPUT\"\n\n# Right:\nHOOK_INPUT=$(cat)\nCOMMAND=$(echo \"$HOOK_INPUT\" | jq -r '.tool_input.command // empty')\n</code></pre>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#regex-overfitting","level":3,"title":"Regex Overfitting","text":"<p>A regex meant to catch <code>ctx</code> as a binary will also match <code>ctx</code> as a directory component:</p> <pre><code># 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</code></pre> <p>Test hook regexes against paths that contain the target string as a substring, not just as the final component.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#repetition-fatigue","level":3,"title":"Repetition Fatigue","text":"<p>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.</p> <p>Fix: cooldowns. <code>ctx agent --session $PPID --cooldown 10m</code> injects at most once per ten minutes per session using a tombstone file in <code>/tmp/</code>. 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.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#hardcoded-paths","level":3,"title":"Hardcoded Paths","text":"<p>A username rename (<code>parallels</code> to <code>jose</code>) broke every hook at once. Use <code>$CLAUDE_PROJECT_DIR</code> instead of absolute paths:</p> <pre><code>\"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"/.claude/hooks/block-git-push.sh\"\n</code></pre> <p>If the platform provides a runtime variable for paths, always use it.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#next-up","level":2,"title":"Next Up","text":"<p>Webhook Notifications →: Get push notifications when loops complete, hooks fire, or agents hit milestones.</p>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-output-patterns/#see-also","level":2,"title":"See Also","text":"<ul> <li>Customizing Hook Messages: override what hooks say without changing what they do</li> <li>Claude Code Permission Hygiene: how permissions and hooks work together</li> <li>Defense in Depth: why hooks matter for agent security</li> </ul>","path":["Recipes","Hooks and Notifications","Hook Output Patterns"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/","level":1,"title":"Hook Sequence Diagrams","text":"","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#hook-lifecycle","level":2,"title":"Hook Lifecycle","text":"<p>This page documents the <code>ctx</code> system hooks: the built-in <code>ctx system *</code> subcommands that Claude Code invokes via <code>.claude/hooks.json</code> at lifecycle events. These are owned by <code>ctx</code> itself, not authored by users.</p> <p>Not to Be Confused with <code>ctx trigger</code></p> <p><code>ctx</code> has three distinct hook-like layers:</p> <ul> <li><code>ctx system</code> hooks (this page): built-in, owned by <code>ctx</code>, wired into Claude Code via <code>internal/assets/claude/hooks/hooks.json</code>.</li> <li><code>ctx trigger</code>: user-authored shell scripts in <code>.context/hooks/<type>/*.sh</code>. See <code>ctx trigger</code> reference and the trigger authoring recipe.</li> <li>Claude Code hooks configured directly in <code>.claude/settings.local.json</code>, tool-specific, not portable across AI tools.</li> </ul> <p>This page is only about the first category.</p> <p>Every <code>ctx system</code> hook is a Go binary invoked by Claude Code at one of three lifecycle events: <code>PreToolUse</code> (before a tool runs, can block), <code>PostToolUse</code> (after a tool completes), or <code>UserPromptSubmit</code> (on every user prompt, before any tools run). Hooks receive JSON on stdin and emit JSON or plain text on stdout.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#pretooluse-hooks","level":2,"title":"PreToolUse Hooks","text":"<p>These fire before a tool executes. They can block, gate, or inject context.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#context-load-gate","level":3,"title":"Context-Load-Gate","text":"<p>Matcher: <code>.*</code> (all tools)</p> <p>Injects the full context packet on first tool use of a session. One-shot per session.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-non-path-ctx","level":3,"title":"Block-Non-Path-ctx","text":"<p>Matcher: <code>Bash</code></p> <p>Blocks <code>./ctx</code>, <code>go run ./cmd/ctx</code>, or absolute-path <code>ctx</code> invocations. Constitutionally enforced.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#qa-reminder","level":3,"title":"Qa-Reminder","text":"<p>Matcher: <code>Bash</code></p> <p>Gate nudge before any git command. Reminds agent to lint/test.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#specs-nudge","level":3,"title":"Specs-Nudge","text":"<p>Matcher: <code>EnterPlanMode</code></p> <p>Nudges agent to save plans/specs when new implementation detected.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#posttooluse-hooks","level":2,"title":"PostToolUse Hooks","text":"<p>These fire after a tool completes. They observe, nudge, and track state.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#post-commit","level":3,"title":"Post-Commit","text":"<p>Matcher: <code>Bash</code></p> <p>Fires after <code>git commit</code> (not amend). Nudges for context capture and checks version drift.</p> <pre><code>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()</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-task-completion","level":3,"title":"Check-Task-Completion","text":"<p>Matcher: <code>Edit</code>, <code>Write</code></p> <p>Configurable-interval nudge after edits. Per-session counter resets after firing.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#userpromptsubmit-hooks","level":2,"title":"UserPromptSubmit Hooks","text":"<p>These fire on every user prompt, before any tools run. They perform health checks, track state, and nudge for housekeeping.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-context-size","level":3,"title":"Check-Context-Size","text":"<p>Adaptive context window monitoring. Fires checkpoints, window warnings, and billing alerts based on prompt count and token usage.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-ceremonies","level":3,"title":"Check-Ceremonies","text":"<p>Daily check for <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> usage in recent journal entries.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-freshness","level":3,"title":"Check-Freshness","text":"<p>Daily check for technology-dependent constants that may need review.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-journal","level":3,"title":"Check-Journal","text":"<p>Daily check for unimported sessions and unenriched journal entries.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-knowledge","level":3,"title":"Check-Knowledge","text":"<p>Daily check for knowledge file entry/line counts exceeding configured thresholds.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-map-staleness","level":3,"title":"Check-Map-Staleness","text":"<p>Daily check for architecture map age and relevant code changes.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-memory-drift","level":3,"title":"Check-Memory-Drift","text":"<p>Per-session check for MEMORY.md changes since last sync.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-persistence","level":3,"title":"Check-Persistence","text":"<p>Tracks context file modification and nudges when edits happen without persisting context. Adaptive threshold based on prompt count.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-reminders","level":3,"title":"Check-Reminders","text":"<p>Per-prompt check for due reminders. No throttle.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-resources","level":3,"title":"Check-Resources","text":"<p>Checks system resources (memory, swap, disk, load). Fires on every prompt. No initialization required.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#check-version","level":3,"title":"Check-Version","text":"<p>Daily binary-vs-plugin version comparison with piggybacked key rotation check.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#heartbeat","level":3,"title":"Heartbeat","text":"<p>Silent per-prompt pulse. Tracks prompt count, context modification, and token usage. The agent never sees this hook's output.</p> <pre><code>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</code></pre>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#project-local-hooks","level":2,"title":"Project-Local Hooks","text":"<p>These hooks are configured in <code>settings.local.json</code> and are not shipped with ctx. They are specific to individual developer setups.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#block-dangerous-commands","level":3,"title":"Block-Dangerous-Commands","text":"<p>Lifecycle: PreToolUse. Matcher: <code>Bash</code></p> <p>Blocks dangerous shell patterns (sudo, git push, cp to bin). No initialization or pause checks: always active.</p> <pre><code>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)</code></pre>","path":["Recipes","Hooks and Notifications","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 <p>* Project-local hook (settings.local.json), not shipped with ctx.</p>","path":["Recipes","Hooks and Notifications","Hook Sequence Diagrams"],"tags":[]},{"location":"recipes/hook-sequence-diagrams/#state-file-reference","level":2,"title":"State File Reference","text":"<p>All state files live in <code>.context/state/</code>.</p> File Pattern Hook Purpose <code>ctx-loaded-{session}</code> context-load-gate One-shot injection marker <code>ctx-paused-{session}</code> (all) Session pause marker <code>ctx-wrapped-up</code> check-context-size Suppress nudges after wrap-up (2h expiry) <code>freshness-checked</code> check-freshness Daily throttle <code>ceremony-reminded</code> check-ceremonies Daily throttle <code>journal-reminded</code> check-journal Daily throttle <code>knowledge-reminded</code> check-knowledge Daily throttle <code>map-staleness-reminded</code> check-map-staleness Daily throttle <code>version-checked</code> check-version Daily throttle <code>memory-drift-nudged-{session}</code> check-memory-drift Per-session tombstone <code>ctx-context-count-{session}</code> check-context-size Prompt counter <code>stats-{session}.jsonl</code> check-context-size Session stats log <code>persist-{session}</code> check-persistence Counter + mtime state <code>ctx-task-count-{session}</code> check-task-completion Prompt counter <code>heartbeat-count-{session}</code> heartbeat Prompt counter <code>heartbeat-mtime-{session}</code> heartbeat Last context mtime","path":["Recipes","Hooks and Notifications","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":"<code>ctx</code> Hub: High-Availability Cluster","text":"<p>Run multiple hub nodes with Raft-based leader election for redundancy. Any follower can take over if the leader dies.</p> <p>This recipe assumes you've read the <code>ctx</code> 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.</p> <p>Raft-Lite</p> <p><code>ctx</code> 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.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#topology","level":2,"title":"Topology","text":"<p>A minimum HA cluster is three nodes. Two is worse than one: it doubles failure probability without providing quorum.</p> <pre><code> +-------------+\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</code></pre>","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":"<pre><code>ctx hub start --daemon \\\n --port 9900 \\\n --peers hub-b.lan:9900,hub-c.lan:9900\n</code></pre> <p>The node starts a Raft election as soon as it sees its peers.</p>","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":"<p>On <code>hub-b.lan</code>:</p> <pre><code>ctx hub start --daemon \\\n --port 9900 \\\n --peers hub-a.lan:9900,hub-c.lan:9900\n</code></pre> <p>On <code>hub-c.lan</code>:</p> <pre><code>ctx hub start --daemon \\\n --port 9900 \\\n --peers hub-a.lan:9900,hub-b.lan:9900\n</code></pre> <p>After a few seconds, one node wins the election and becomes the leader. The other two are followers.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#step-3-verify-cluster-state","level":2,"title":"Step 3: Verify Cluster State","text":"<p>From any node:</p> <pre><code>ctx hub status\n</code></pre> <p>Expected output:</p> <pre><code>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</code></pre>","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":"<p>The <code>ctx hub *</code> commands above run on the hub nodes themselves and don't need a project. The <code>ctx connection *</code> commands below are different: they live inside a project (the encrypted hub config is stored at <code>.context/.connect.enc</code>), so you have to tell <code>ctx</code> which project first.</p> <p>When registering a client, give it the full peer list:</p> <pre><code># In the project directory on the client:\nctx connection register hub-a.lan:9900 \\\n --token ctx_adm_... \\\n --peers hub-b.lan:9900,hub-c.lan:9900\n</code></pre> <p>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.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#runtime-membership-changes","level":2,"title":"Runtime Membership Changes","text":"<p>Add a new peer without downtime:</p> <pre><code>ctx hub peer add hub-d.lan:9900\n</code></pre> <p>Remove a decommissioned peer:</p> <pre><code>ctx hub peer remove hub-c.lan:9900\n</code></pre>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#planned-maintenance","level":2,"title":"Planned Maintenance","text":"<p>Before taking a leader offline, hand off leadership:</p> <pre><code>ssh hub-a.lan 'ctx hub stepdown'\n</code></pre> <p><code>stepdown</code> triggers a new election among the remaining followers before the leader goes offline. In-flight clients briefly pause, then reconnect to the new leader.</p>","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 <p>For the full list, see Hub failure modes.</p>","path":["Recipes","Hub","HA Cluster"],"tags":[]},{"location":"recipes/hub-cluster/#see-also","level":2,"title":"See Also","text":"<ul> <li>Multi-machine recipe: single-node deployment</li> <li>Hub operations: backup and maintenance</li> <li>Hub security model: TLS, tokens</li> </ul>","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":"<code>ctx</code> Hub: Getting Started","text":"<p>Stand up a single-node <code>ctx</code> Hub on localhost, register two projects, publish a decision from one, and see it appear in the other, all in under five minutes.</p> <p>Read This First</p> <p>If you haven't already, skim the <code>ctx</code> 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.</p>","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":"<p>By the end, you will have:</p> <ol> <li>A local hub process running on port <code>9900</code>.</li> <li>Two project directories both registered with the <code>ctx</code> Hub.</li> <li>A decision published from project <code>alpha</code> that appears automatically in project <code>beta</code>'s <code>.context/hub/</code> and in <code>ctx agent --include-hub</code> output.</li> </ol> <p>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.</p>","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":"<ul> <li>Sharing <code>.context/journal/</code>, <code>.context/pad</code>, or any other local state. The hub only fans out <code>decision</code>, <code>learning</code>, <code>convention</code>, and <code>task</code> entries. Everything else stays local.</li> <li>Multi-user attribution. The hub identifies projects, not people.</li> <li>Running over a LAN; see Multi-machine setup.</li> <li>Redundancy; see HA cluster.</li> </ul>","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li><code>ctx</code> installed and on <code>PATH</code></li> <li>Two project directories, each already initialized with <code>ctx init</code></li> </ul>","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":"<p>In a dedicated terminal:</p> <pre><code>ctx hub start\n</code></pre> <p>On first run, the hub generates an admin token and prints it to stdout. Copy it; you'll need it for each project registration:</p> <pre><code>ctx hub listening on :9900\nadmin token: ctx_adm_7f3a1c2d...\ndata dir: ~/.ctx/hub-data/\n</code></pre> <p>The admin token is written to <code>~/.ctx/hub-data/admin.token</code> so you can recover it later. Treat it like a password.</p>","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":"<p><code>ctx hub start</code> 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 <code>.context/.connect.enc</code>, so you have to tell <code>ctx</code> which project first.</p> <pre><code>cd ~/projects/alpha\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\n</code></pre> <p>This stores an encrypted connection config in <code>.context/.connect.enc</code>. The admin token is exchanged for a per-project client token; the admin token itself is never persisted in the project.</p>","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":"<pre><code>ctx connection subscribe decision learning convention\n</code></pre> <p>Only the entry types you subscribe to will be delivered by <code>sync</code> and <code>listen</code>.</p>","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":"<p>Either use <code>ctx add --share</code> to write locally and push to the <code>ctx</code> Hub:</p> <pre><code>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</code></pre> <p>Or publish an existing entry directly:</p> <pre><code>ctx connection publish decision \"Use UTC timestamps everywhere\"\n</code></pre>","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":"<pre><code>cd ~/projects/beta\nctx connection register localhost:9900 --token ctx_adm_7f3a1c2d...\nctx connection subscribe decision learning convention\nctx connection sync\n</code></pre> <p>The decision from <code>alpha</code> now appears in <code>~/projects/beta/.context/hub/decisions.md</code> with an origin tag and timestamp.</p>","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":"<p>Instead of re-running <code>sync</code>, stream new entries as they land:</p> <pre><code>ctx connection listen\n</code></pre> <p>Leave this running in a terminal; every <code>--share</code> publish from any registered project will appear in <code>.context/hub/</code> immediately.</p>","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":"<p>Once entries exist in <code>.context/hub/</code>, include them in the agent context packet:</p> <pre><code>ctx agent --include-hub\n</code></pre> <p>Shared entries are added as a dedicated tier in the budget-aware assembly, scored by recency and type relevance.</p>","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":"<p>After <code>register</code>, the <code>check-hub-sync</code> hook pulls new entries at the start of each session (daily throttled). Most users never need to call <code>ctx connection sync</code> manually.</p>","path":["Recipes","Hub","Getting Started"],"tags":[]},{"location":"recipes/hub-getting-started/#where-to-go-next","level":2,"title":"Where to Go Next","text":"<ul> <li>Multi-machine hub: run the hub on a LAN host and connect from other workstations.</li> <li>HA cluster: Raft-based leader election for high availability.</li> <li>Hub operations: daemon mode, backup, log rotation, JSONL store layout.</li> <li>Hub security model: token lifecycle, encryption at rest, threat model.</li> <li><code>ctx connection</code> reference and <code>ctx hub start</code> reference.</li> </ul>","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":"<code>ctx</code> Hub: Multi-Machine","text":"<p>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 <code>ctx</code> Hub overview; read that first if you haven't, especially the trust-model warnings.</p> <p>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).</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#topology","level":2,"title":"Topology","text":"<pre><code>+------------------+ +------------------+\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</code></pre>","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":"<p>On the machine that will hold the hub (call it <code>nexus</code>):</p> <pre><code>ctx hub start --daemon --port 9900\n</code></pre> <p>The daemon writes a PID file to <code>~/.ctx/hub-data/hub.pid</code>. Stop it later with:</p> <pre><code>ctx hub stop\n</code></pre>","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":"<p>Open port <code>9900/tcp</code> on <code>nexus</code> 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).</p> <p>Typical LAN allowlist rules:</p> firewalldufwnftables <pre><code>sudo firewall-cmd --zone=internal \\\n --add-port=9900/tcp --permanent\nsudo firewall-cmd --reload\n</code></pre> <pre><code>sudo ufw allow from 192.168.1.0/24 to any port 9900 proto tcp\n</code></pre> <pre><code>sudo nft add rule inet filter input ip saddr 192.168.1.0/24 \\\n tcp dport 9900 accept\n</code></pre>","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":"<p>The daemon prints the admin token to stdout on first run. Running as a daemon, that output goes to the log instead:</p> <pre><code>cat ~/.ctx/hub-data/admin.token\n</code></pre> <p>Copy the token over a trusted channel (SSH, password manager, or an encrypted note). Do not email it or put it in chat.</p>","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":"<p>The <code>ctx hub *</code> commands above run on the LAN host (<code>nexus</code>) 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 <code>.context/</code>), so you have to tell <code>ctx</code> which project first.</p> <p>On workstation <code>A</code>:</p> <pre><code>cd ~/projects/x\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n</code></pre> <p>On workstation <code>B</code>:</p> <pre><code>cd ~/projects/y\nctx connection register nexus.local:9900 --token ctx_adm_...\nctx connection subscribe decision learning convention\n</code></pre> <p>Each registration exchanges the admin token for a per-project client token. Only the client token is persisted in <code>.context/.connect.enc</code>, encrypted with the same AES-256-GCM scheme <code>ctx</code> uses for notification credentials.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#step-5-verify","level":2,"title":"Step 5: Verify","text":"<p>From either workstation:</p> <pre><code>ctx connection status\n</code></pre> <p>You should see the <code>ctx</code> Hub address, role (<code>leader</code> for single-node), subscription filters, and the sequence number you're synced to.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#tls-recommended","level":2,"title":"TLS (Recommended)","text":"<p>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:</p> <pre><code>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</code></pre> <p>Point <code>ctx connection register</code> at the public hostname and port 443.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#handling-daemon-restarts","level":2,"title":"Handling Daemon Restarts","text":"<p>The hub is append-only JSONL, so restarts are safe. Clients keep their last-seen sequence in <code>.context/hub/.sync-state.json</code> and pick up exactly where they left off on the next <code>sync</code> or <code>listen</code> reconnect.</p>","path":["Recipes","Hub","Multi-Machine"],"tags":[]},{"location":"recipes/hub-multi-machine/#see-also","level":2,"title":"See Also","text":"<ul> <li>HA cluster recipe: for redundancy</li> <li>Hub operations: backup, rotation</li> <li>Hub failure modes</li> <li>Hub security model</li> </ul>","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":"<code>ctx</code> Hub: Overview","text":"<p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#mental-model-in-one-paragraph","level":2,"title":"Mental Model in One Paragraph","text":"<p>The hub is a fan-out channel for structured knowledge entries across projects. When you publish a decision, learning, convention, or task with <code>--share</code>, 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.</p> <p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#what-flows-through-the-hub","level":2,"title":"What Flows through the Hub","text":"<p>Only four entry types:</p> Type What it is <code>decision</code> Architectural decisions with rationale <code>learning</code> Gotchas, lessons, surprising behaviors <code>convention</code> Coding patterns and standards <code>task</code> Work items worth sharing across projects <p>Each entry is an immutable record with a content blob, the publishing project's name as <code>Origin</code>, a timestamp, and a hub-assigned sequence number. Once published, entries are never rewritten.</p>","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":"<p>This is the part new users get wrong most often:</p> <ul> <li>Session journals (<code>~/.claude/</code> logs, <code>.context/journal/</code>) stay local. The hub does not sync your AI session history.</li> <li>Scratchpad (<code>.context/pad</code>) stays local. Encrypted notes never leave the machine they were written on.</li> <li>Local context files as a whole (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>) are not mirrored wholesale. Only entries you explicitly <code>--share</code>, or publish later with <code>ctx connection publish</code>, cross the boundary.</li> <li>Anything under <code>.context/</code> that isn't one of the four entry types above. Configuration, state, logs, memory, journal metadata: all local.</li> </ul> <p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#two-user-stories","level":2,"title":"Two User Stories","text":"<p>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.</p>","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":"<p>One developer, many projects, one hub, usually on localhost.</p> <p>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.</p> <p>Concrete payoff:</p> <ul> <li><code>ctx learning add --share \"...\"</code> in project A → <code>ctx agent --include-hub</code> in project B shows that learning in the next context packet.</li> <li>A decision recorded in your personal \"dotfiles\" project is instantly visible to every other project on your workstation.</li> <li>Cross-project conventions (e.g., \"use UTC timestamps everywhere\") live in one place and propagate.</li> </ul> <p>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.</p> <p>Start here: Getting Started for the one-time setup, then Personal cross-project brain for the day-to-day workflow.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#story-2-small-trusted-team","level":3,"title":"Story 2: Small Trusted Team","text":"<p>A few teammates, projects they each own, one hub on a LAN host they all trust.</p> <p>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.</p> <p>Concrete payoff:</p> <ul> <li>Team conventions propagate without needing a wiki or chat.</li> <li>Lessons from one team member become available to everyone else's agent context packets automatically.</li> <li>Cross-project decisions (shared libraries, deployment patterns, naming rules) live in a single log the whole team reads.</li> </ul> <p>Trust model: the hub assumes everyone holding a client token is friendly. There is no per-user attribution you can rely on, <code>Origin</code> 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.</p> <p>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.</p> <p>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.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#identity-projects-not-users","level":2,"title":"Identity: Projects, Not Users","text":"<p>The hub has no concept of users. Its unit of identity is the project. <code>ctx connection register</code> binds a hub token to a project directory, not to a person. Two developers working on the same project share either:</p> <ul> <li>The same <code>.connect.enc</code>, copied between machines over a trusted channel, or</li> <li>Different project names (<code>alpha@laptop-a</code>, <code>alpha@laptop-b</code>), because the hub rejects duplicate registrations of the same project name.</li> </ul> <p>Either works; neither gives you per-human attribution. If you need \"who wrote this,\" the hub is the wrong tool.</p>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#when-not-to-use-it","level":2,"title":"When Not to Use It","text":"<ul> <li>Solo, single-project work. Local <code>.context/</code> files are enough. The hub adds operational surface for no payoff.</li> <li>Untrusted participants. The hub assumes everyone with a client token is friendly. It is not hardened against hostile insiders or compromised tokens.</li> <li>Compliance-sensitive environments. There is no audit trail that can prove who published what, only which project published what, and <code>Origin</code> is self-asserted.</li> <li>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.</li> <li>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.</li> </ul>","path":["Recipes","Hub","Overview"],"tags":[]},{"location":"recipes/hub-overview/#how-entries-reach-your-agent","level":2,"title":"How Entries Reach Your Agent","text":"<p>Once a project is registered and subscribed, entries arrive by three mechanisms:</p> <ol> <li><code>ctx connection sync</code>: an on-demand pull, replays everything new since the last sequence you saw.</li> <li><code>ctx connection listen</code>: a long-lived gRPC stream that writes new entries to <code>.context/hub/</code> as they arrive.</li> <li><code>check-hub-sync</code> hook: runs at session start, daily throttled, so most users never call <code>sync</code> manually.</li> </ol> <p>Once entries exist in <code>.context/hub/</code>, <code>ctx agent --include-hub</code> adds a dedicated tier to the budget-aware context packet, scored by recency and type relevance. That's the end of the pipeline.</p>","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 <code>ctx connection</code>, <code>ctx serve</code>, <code>ctx hub</code>","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":"<p>This recipe shows how one developer uses a <code>ctx</code> 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.</p> <p>Prerequisites: a working <code>ctx</code> 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.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#the-core-loop","level":2,"title":"The Core Loop","text":"<p>Every day, the same three verbs matter:</p> <ol> <li>Record: notice a decision, learning, or convention and capture it with <code>ctx add --share</code>.</li> <li>Subscribe: every project you care about is subscribed to the types you want delivered (set once with <code>ctx connection subscribe</code>).</li> <li>Load: your agent picks up shared entries on next session start via the auto-sync hook, or explicitly via <code>ctx agent --include-hub</code>.</li> </ol> <p>That's the whole workflow. The rest of this recipe fills in the concrete moments where each verb matters.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#a-realistic-day","level":2,"title":"A Realistic Day","text":"<p>You have three projects on your workstation:</p> <ul> <li><code>~/projects/api</code>, a Go service you're actively developing</li> <li><code>~/projects/cli</code>, a companion CLI that consumes the API</li> <li><code>~/projects/dotfiles</code>, your personal conventions and cross-project learnings</li> </ul> <p>All three are registered with a single hub running on <code>localhost:9900</code> (started once at boot, or via a systemd user unit; see Hub operations). All three subscribe to <code>decision</code>, <code>learning</code>, and <code>convention</code>.</p>","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 <code>api</code>","text":"<p>You <code>cd ~/projects/api</code> and start a Claude Code session. Behind the scenes, the plugin's <code>PreToolUse</code> hook calls <code>ctx agent --budget 8000 --include-hub</code> before the first tool call. Agent loads:</p> <ul> <li>Local <code>.context/</code> (TASKS, DECISIONS, LEARNINGS, etc.)</li> <li>Foundation steering files (always-inclusion)</li> <li>Everything you've shared from the other two projects</li> </ul> <p>So the \"use UTC timestamps everywhere\" decision you recorded in <code>dotfiles</code> last week is already in Claude's context for this session, without any manual <code>sync</code>.</p>","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":"<p>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 <code>LEARNINGS.md</code> in <code>api/</code>. But it's useful across every Go service you'll ever write, not just this one. So:</p> <pre><code>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</code></pre> <p>The <code>--share</code> flag does two things:</p> <ol> <li>Writes the learning to <code>api/.context/LEARNINGS.md</code> locally (as a normal <code>ctx learning add</code> would).</li> <li>Publishes the same entry to the <code>ctx</code> Hub, which stores it in the append-only JSONL and fans it out to every subscribed client.</li> </ol> <p>Within seconds, <code>cli/.context/hub/learnings.md</code> and <code>dotfiles/.context/hub/learnings.md</code> both contain a copy of this learning (the <code>ctx connection listen</code> daemon picks it up from the <code>ctx</code> Hub's Listen stream).</p>","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 <code>cli</code>","text":"<p><code>cd ~/projects/cli</code>, open a new session. The agent packet for <code>cli</code> now includes the learning you just recorded in <code>api</code>, because <code>cli</code> is subscribed to <code>learning</code> and the entry has already been synced into <code>cli/.context/hub/learnings.md</code>.</p> <p>You don't have to re-explain the retry-loop gotcha. Claude already sees it.</p>","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":"<p>You've been writing error messages in <code>api</code> 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 <code>dotfiles</code> (since that's your \"personal standards\" project), and share it:</p> <pre><code>cd ~/projects/dotfiles\nctx convention add --share \\\n \"Error messages: lowercase start, no trailing period, single sentence (follows Go's stdlib style)\"\n</code></pre> <p>The convention lands in <code>dotfiles/CONVENTIONS.md</code> locally and fans out to <code>api</code> and <code>cli</code> via the hub. The next Claude Code session in either project gets the convention injected into the steering-adjacent slot of the agent packet.</p>","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":"<p>You didn't run <code>ctx connection sync</code> once. You didn't <code>git push</code> 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.</p>","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":"<p>Stripped of prose, the day's commands were:</p> <pre><code># 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</code></pre> <p>The hub is passive infrastructure. You never talk to it directly; you talk through it by using <code>--share</code> on commands you were already running.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#tips-for-solo-use","level":2,"title":"Tips for Solo Use","text":"<p>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 <code>ctx-standards</code> project all work. Record cross-cutting conventions there and let the hub propagate them to everything else.</p> <p>Subscribe to <code>task</code> only if you want cross-project todos. The four subscribable types are <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. 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 <code>task</code> in <code>ctx connection subscribe</code> unless you have a specific reason.</p> <p>Run the hub as a user-level daemon so you don't have to remember to start it. On Linux with systemd:</p> <pre><code># ~/.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</code></pre> <pre><code>systemctl --user enable --now ctx-hub.service\n</code></pre> <p>Don't overthink subscription filters. For personal use, subscribe every project to all four types at first (or three, if you skip <code>task</code>). Tune later if the context packets get noisy.</p> <p>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.</p>","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":"<p>Not a setup guide. For the one-time hub install and project registration, use Getting Started.</p> <p>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.</p> <p>Not production operations. For backup, log rotation, failure recovery, and HA, see Hub operations and Hub failure modes.</p>","path":["Recipes","Hub","Personal Cross-Project Brain"],"tags":[]},{"location":"recipes/hub-personal/#see-also","level":2,"title":"See Also","text":"<ul> <li>Hub overview: when to use the Hub and when not to.</li> <li>Team knowledge bus: the multi-human companion recipe.</li> <li><code>ctx connection</code>: the client-side commands used above (<code>subscribe</code>, <code>publish</code>, <code>sync</code>, <code>listen</code>, <code>status</code>).</li> <li><code>ctx add</code>: the <code>--share</code> flag reference.</li> <li><code>ctx hub</code>: operator commands for starting, stopping, and inspecting the hub.</li> </ul>","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":"<p>This recipe shows how a small trusted team uses a <code>ctx</code> 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.</p> <p>Prerequisites:</p> <ul> <li>A running <code>ctx</code> Hub on a LAN host or internal server everyone on the team can reach. See Multi-machine setup for the deployment guide.</li> <li>Each team member has <code>ctx</code> installed and has <code>ctx connection register</code>-ed their working projects with the hub.</li> <li>Client-side commands (<code>ctx connection ...</code>, <code>ctx add --share</code>) must be run from each project's root — <code>ctx</code> reads <code>$PWD/.context/</code>. The hub server (<code>ctx hub start</code>, etc.) doesn't need this; it operates on the hub data directory rather than a project.</li> </ul>","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":"<p>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 <code>Origin</code> 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.</p> <p>If your team is:</p> <ul> <li>✅ 3-10 engineers, all known to each other, all trusted with production access</li> <li>✅ On a single internal network or behind a VPN</li> <li>✅ Comfortable with \"the hub assumes friendly participants\"</li> </ul> <p>…this recipe fits. If your team is:</p> <ul> <li>❌ Larger than ~15, with turnover</li> <li>❌ Includes contractors, untrusted agents, or compromised-workstation concerns</li> <li>❌ Needs audit trails that prove who published what</li> <li>❌ Requires per-team-member isolation</li> </ul> <p>…you're in \"Story 3\" territory, which the hub does not support today. Use a wiki or a dedicated knowledge platform instead.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#the-teams-three-verbs","level":2,"title":"The Team's Three Verbs","text":"<p>Everyone on the team does three things, same as in the personal recipe, but with different social expectations:</p> <ol> <li>Record: when you learn something that would save a teammate time, capture it with <code>ctx add --share</code>.</li> <li>Subscribe: every engineer's project directories subscribe to the types the team cares about.</li> <li>Load: agents pick up shared entries automatically via the auto-sync hook and the <code>--include-hub</code> flag in the PreToolUse hook pipeline.</li> </ol> <p>The operational shape is identical to solo use. What's different is the culture around publishing: when do you <code>--share</code>, and what belongs on the hub vs. in your local <code>.context/</code>.</p>","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":"<p>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, <code>--share</code>. If no, record it locally and move on.</p> <p>Decisions:</p> <ul> <li>✅ Cross-service decisions (database choice, auth model, deployment pattern, monitoring stack).</li> <li>✅ Policy decisions that apply to all services (naming, API versioning, error-message format).</li> <li>❌ Internal implementation decisions inside a single service (\"chose a map over a slice here because lookups dominate\").</li> <li>❌ One-off tactical calls for a specific PR.</li> </ul> <p>Learnings:</p> <ul> <li>✅ Gotchas, surprising behavior, flaky infrastructure quirks, anything you'd tell a teammate over coffee with \"watch out for X\".</li> <li>✅ Lessons from incidents, right after the postmortem is the highest-value time to share.</li> <li>❌ Internal debugging notes that only make sense with context from your current branch.</li> </ul> <p>Conventions:</p> <ul> <li>✅ Repo layout, commit message format, pre-commit hooks, review expectations.</li> <li>✅ Language-level style decisions that apply across services.</li> <li>❌ Per-service idioms (\"in <code>billing/</code> we prefer…\").</li> </ul> <p>Tasks: almost always project-local. Don't subscribe to <code>task</code> unless the team has a specific reason (e.g., a cross-cutting migration you want visible everywhere).</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#a-realistic-week","level":2,"title":"A Realistic Week","text":"<p>Monday, 3 AM incident, shared learning</p> <p>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:</p> <pre><code>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</code></pre> <p>By Tuesday morning, every other engineer's agent context packet contains this learning. When Bob starts work on the <code>ledger</code> service (which also uses grpc-go), his Claude Code session already knows about the gotcha without Bob having to read the incident channel.</p> <p>Wednesday, cross-service decision</p> <p>The team agrees on a new pattern for API versioning: header-based instead of URL-based. Platform lead Carol records the decision:</p> <pre><code>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</code></pre> <p>Every engineer's next session knows about this decision automatically. When Dave starts adding endpoints to the <code>inventory</code> service on Thursday, Claude already prompts him for the header pattern instead of defaulting to <code>/v1/</code>.</p> <p>Friday, convention drift caught at review</p> <p>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 <code>ctx connection status</code>, sees the hub is healthy, greps his local <code>.context/hub/conventions.md</code>, and finds:</p> <pre><code>## [2026-03-12] Error message format\nLowercase start, no trailing period, single sentence.\n</code></pre> <p>He fixes the PR. No lookup on the wiki, no question in chat, no context-switch penalty.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#workflow-tips-for-teams","level":2,"title":"Workflow Tips for Teams","text":"<p>Designate a \"champion\" for decisions. The team lead or platform engineer should be the person who explicitly <code>--share</code>s cross-cutting decisions. Other team members share learnings freely but should ask \"should this be a decision?\" in review before <code>--share</code>ing a decision. This keeps the decision stream signal-rich.</p> <p>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.</p> <p>Delete noisy entries, don't tolerate them. The hub is append-only, but the <code>.context/hub/</code> 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 <code>entries.jsonl</code> (see Hub operations). Noisy shared feeds lose trust fast.</p> <p>Don't subscribe every project to every type. For backend engineers, subscribing to <code>decision + learning + convention</code> is usually right. For platform or DevOps projects, adding <code>task</code> makes sense. For a prototype or experiment project, subscribing only to <code>convention</code> might be enough.</p> <p>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.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#operational-concerns","level":2,"title":"Operational Concerns","text":"<p>The team recipe assumes someone owns the hub host. That person (or a small group) is responsible for:</p> <ul> <li>Uptime: the hub is infrastructure; treat it like any other internal service you run. See Hub operations.</li> <li>Backups: <code>entries.jsonl</code> is the source of truth. Snapshot it to the same backup tier as your other internal data.</li> <li>Upgrades: cadence the team agrees on. Major upgrades may require everyone to re-register, so do them at natural breaks.</li> <li>Failures: see Hub failure modes for the standard oncall playbook.</li> </ul> <p>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.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#token-management","level":2,"title":"Token Management","text":"<p>Every team member has a client token stored in their <code>.context/.connect.enc</code>. Rules of thumb:</p> <ul> <li>One token per engineer per project. Not one token per team; not one shared token. Each engineer registers each of their working projects separately.</li> <li>Token compromise = revoke immediately. When an engineer leaves, their tokens should be removed from <code>clients.json</code> on the hub. This is a manual operation today; see Hub security for the revocation steps.</li> <li>No checked-in tokens. <code>.context/.connect.enc</code> is encrypted with the local machine key, but don't push it to shared repos; it's per-workstation.</li> </ul>","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":"<p>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.</p> <p>Not an audit log. <code>Origin</code> on the hub is self-asserted. If compliance requires provenance, the hub is the wrong tool.</p> <p>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.</p> <p>Not a production service for end users. This is internal team infrastructure. Do not expose the hub to customers, partners, or the open internet.</p>","path":["Recipes","Hub","Team Knowledge Bus"],"tags":[]},{"location":"recipes/hub-team/#see-also","level":2,"title":"See Also","text":"<ul> <li>Hub overview: when to use the hub and when not to.</li> <li>Personal cross-project brain: the single-developer companion recipe.</li> <li>Multi-machine setup: standing up the hub on a LAN host.</li> <li>HA cluster: optional redundancy for larger teams.</li> <li>Hub operations: backup, rotation, monitoring.</li> <li>Hub security: threat model and hardening checklist.</li> </ul>","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":"<p>Claude Code plan files (<code>~/.claude/plans/*.md</code>) 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.</p> <p>How do you turn a useful plan into a permanent project spec?</p>","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Plans are copied (not moved) to <code>specs/</code>, slugified by their H1 heading.</p>","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 <code>/ctx-plan-import</code> Skill List, filter, and import plan files to specs <code>/ctx-task-add</code> 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":"<p>Invoke the skill and it lists plans with modification dates and titles:</p> <pre><code>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</code></pre>","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":"<p>You can narrow the list with arguments:</p> Argument Effect <code>--today</code> Only plans modified today <code>--since YYYY-MM-DD</code> Only plans modified on or after the date <code>--all</code> Import everything without prompting (none) Interactive selection <pre><code>You: /ctx-plan-import --today\nYou: /ctx-plan-import --since 2026-02-27\nYou: /ctx-plan-import --all\n</code></pre>","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":"<p>Pick one or more plans by number:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<p>If you say yes, the agent creates tasks in <code>TASKS.md</code> that reference the imported specs:</p> <pre><code>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</code></pre>","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't need to remember the exact skill name:</p> You say What happens \"import my plans\" <code>/ctx-plan-import</code> (interactive) \"save today's plans as specs\" <code>/ctx-plan-import --today</code> \"import all plans from this week\" <code>/ctx-plan-import --since ...</code> \"turn that plan into a spec\" <code>/ctx-plan-import</code> (filtered)","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#tips","level":2,"title":"Tips","text":"<ul> <li>Plans are copied, not moved: The originals stay in <code>~/.claude/plans/</code>. Claude Code manages that directory; <code>ctx</code> doesn't delete from it.</li> <li>Conflict handling: If <code>specs/{slug}.md</code> already exists, the agent asks whether to overwrite or pick a different name.</li> <li>Specs are project memory: Once imported, specs are tracked in git and available to future sessions. Reference them from <code>TASKS.md</code> phase headers with <code>Spec: specs/slug.md</code>.</li> <li>Pair with <code>/ctx-implement</code>: After importing a plan as a spec, use <code>/ctx-implement</code> to execute it step-by-step with verification.</li> </ul>","path":["Recipes","Knowledge and Tasks","Importing Claude Code Plans"],"tags":[]},{"location":"recipes/import-plans/#see-also","level":2,"title":"See Also","text":"<ul> <li>Skills Reference: /ctx-plan-import: full skill description</li> <li>The Complete Session: where plan import fits in the session flow</li> <li>Tracking Work Across Sessions: managing tasks that reference imported specs</li> </ul>","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":"<p>You debug a subtle issue, discover the root cause, and move on.</p> <p>Three weeks later, a different session hits the same issue. The knowledge existed briefly in one session's memory but was never written down.</p> <p>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.</p> <p>How do you make sure important context survives across sessions?</p> <p>Prefer Skills to Raw Commands</p> <p>Use <code>/ctx-decision-add</code> and <code>/ctx-learning-add</code> instead of raw <code>ctx add</code> commands. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.</p>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/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</code></pre> <p>Or just tell your agent: \"What have we learned this session?\"</p>","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 <code>ctx decision add</code> Command Record an architectural decision <code>ctx learning add</code> Command Record a gotcha, tip, or lesson <code>ctx convention add</code> Command Record a coding pattern or standard <code>ctx index <file></code> Command Project a file's headings as a table of contents <code>/ctx-decision-add</code> Skill AI-guided decision capture with validation <code>/ctx-learning-add</code> Skill AI-guided learning capture with validation <code>/ctx-convention-add</code> Skill AI-guided convention recording with placement <code>/ctx-reflect</code> 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":"<p>Decision, Learning, or Convention?</p> <ul> <li>If you chose between alternatives, it is a decision.</li> <li>If you discovered something surprising, it is a learning.</li> <li>If you are codifying a repeated pattern, it is a convention.</li> </ul>","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":"<p>Three context files serve different purposes:</p> <p>Decisions (<code>DECISIONS.md</code>) 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.</p> <p>Learnings (<code>LEARNINGS.md</code>) 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. </p> <p>Learnings prevent repeating past mistakes.</p> <p>Conventions (<code>CONVENTIONS.md</code>) 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.</p>","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":"<p>Decisions have three structured fields: </p> <ul> <li>context, </li> <li>rationale, </li> <li>and consequences.</li> </ul> <p>The easiest way to record one is to tell your agent:</p> <pre><code>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</code></pre> <p>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.</p> <p>When multiple options were considered, the agent includes rejected alternatives in the rationale automatically.</p> <p>The <code>/ctx-decision-add</code> skill also guides you through the fields interactively. For quick decisions, it supports a Y-statement:</p> <p>\"In the context of [situation], facing [constraint], we decided for [choice] and against [alternatives], to achieve [benefit], accepting that [trade-off].\"</p> CLI Command for Scripting and Automation <p>When no agent is in the loop (CI pipelines, shell scripts, hooks), use the CLI directly with structured flags:</p> <pre><code>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</code></pre>","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":"<p>Learnings have three structured fields: context, lesson, and application.</p> <p>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:</p> <pre><code>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</code></pre> <p>You said one sentence. The agent produced a structured entry with all three fields filled from the session context.</p> <p>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.</p> <p>The <code>/ctx-learning-add</code> skill applies three quality filters:</p> <ol> <li>Could someone Google this in 5 minutes?</li> <li>Is it specific to this codebase?</li> <li>Did it take real effort to discover?</li> </ol> <p>All three must pass.</p> <p>Learnings capture principles and heuristics, not code snippets.</p> CLI Command for Scripting and Automation <p>When no agent is in the loop:</p> <pre><code>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</code></pre>","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":"<p>Conventions are simpler: just a name, a rule, and optionally a section.</p> <p>These are short enough that either approach works:</p> <pre><code>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</code></pre> <p>Or from the terminal:</p> <pre><code>ctx convention add \"Use kebab-case for all CLI flag names\" --section \"Naming\"\n</code></pre> <p>Conventions work best for rules that come up repeatedly. Codify a pattern the third time you see it, not the first.</p>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#step-5-project-a-table-of-contents-on-demand","level":3,"title":"Step 5: Project a Table of Contents on Demand","text":"<p><code>DECISIONS.md</code> and <code>LEARNINGS.md</code> do not store an index. A quick-reference table of contents — the date and title for each entry — is computed on demand, so it can never fall out of sync with the file, even after hand edits.</p> <pre><code>ctx index .context/DECISIONS.md\nctx index .context/LEARNINGS.md\n</code></pre> <p>The projection lets AI tools scan all entries without reading the full file, which matters when token budgets are tight. Use <code>--json</code> for machine-readable output.</p>","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 <code>/ctx-reflect</code> to Surface What to Capture","text":"<p>Keep It Conversational</p> <p><code>/ctx-reflect</code> is not the only way to trigger reflection.</p> <p>Agents trained on the <code>ctx</code> playbook naturally surface persist-worthy items at breakpoints, even without invoking the skill explicitly.</p> <p>A conversational prompt like \"anything worth saving?\" or \"let's wrap up\" can trigger the same review.</p> <p>The skill provides a structured checklist, but the behavior is available through natural conversation.</p> <p>At natural breakpoints (after completing a feature, fixing a bug, or before ending a session) use <code>/ctx-reflect</code> to identify items worth persisting.</p> <pre><code>/ctx-reflect\n</code></pre> <p>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:</p> <pre><code>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</code></pre> <p>The skill always asks before persisting.</p>","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":"<p>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 <code>ctx</code> playbook, natural language triggers the same operations.</p> <p>You ask, the agent acts:</p> 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 <code>CONVENTIONS.md</code> \"Let's wrap up\" Runs through the reflect checklist conversationally <p>Example exchange:</p> <pre><code>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</code></pre> <p>The agent can also be proactive without being asked. The playbook encourages agents to persist context at natural milestones.</p> <p>You may see:</p> <ul> <li>After fixing a tricky bug: \"I noticed this was a non-obvious issue. Want me to save it as a learning?\"</li> <li>After choosing between approaches: \"We just made a trade-off between file-based tokens and IPC. Should I record this as a decision?\"</li> <li>At session milestones: the agent checks what is worth persisting and offers a brief summary.</li> </ul> <p>When agents run unattended (no human in the loop), they may persist directly:</p> <ul> <li>\"I've added the subprocess env var gotcha to <code>LEARNINGS.md</code> so we don't hit it again.\"</li> <li>\"Recorded the decision to use file-based tokens over env vars in <code>DECISIONS.md</code>.\"</li> <li>\"Marked the cooldown task done and added a follow-up for TTL cleanup.\"</li> </ul> <p>This is behavior by design.</p> <p>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.</p>","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":"<pre><code># 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# Project a table of contents on demand\nctx index .context/DECISIONS.md\n\n# Reflect at breakpoints (from AI assistant)\n# /ctx-reflect\n</code></pre>","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":"<pre><code>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</code></pre> <p>Both approaches produce the same structured entries in the same context files.</p> <ul> <li>The conversational approach is the natural fit for interactive sessions; </li> <li>the CLI commands are better suited for scripts, hooks, and automation pipelines.</li> </ul>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#tips","level":2,"title":"Tips","text":"<ul> <li>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.</li> <li>Learnings should fail the Gemini test. If someone could find it in a 5-minute Gemini search, it does not belong in <code>LEARNINGS.md</code>.</li> <li>Conventions earn their place through repetition. Add a convention the third time you see a pattern, not the first.</li> <li>Use <code>/ctx-reflect</code> at natural breakpoints. The checklist catches items you might otherwise lose.</li> <li>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.</li> <li>Reindex after every hand edit. It takes less than a second. A stale index causes AI tools to miss entries.</li> <li>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.</li> <li>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.</li> <li>Trust the agent's proactive instincts. Agents trained on the <code>ctx</code> 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.</li> <li> <p>Relax provenance per-project if <code>--session-id</code>, <code>--branch</code>, or <code>--commit</code> are impractical (e.g., manual notes outside an AI session). Add to <code>.ctxrc</code>:</p> <pre><code>provenance_required:\n session_id: false # allow entries without --session-id\n branch: true # still require --branch\n commit: true # still require --commit\n</code></pre> <p>Default is all three required. Only human config relaxes: Agents cannot bypass, and that's by design.</p> </li> </ul>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#next-up","level":2,"title":"Next Up","text":"<p>Tracking Work Across Sessions →: Add, prioritize, complete, and archive tasks across sessions.</p>","path":["Recipes","Knowledge and Tasks","Persisting Decisions, Learnings, and Conventions"],"tags":[]},{"location":"recipes/knowledge-capture/#see-also","level":2,"title":"See Also","text":"<ul> <li>Tracking Work Across Sessions: managing the tasks that decisions and learnings support</li> <li>The Complete Session: full session lifecycle including reflection and context persistence</li> <li>Detecting and Fixing Drift: keeping knowledge files accurate as the codebase evolves</li> <li>CLI Reference: full documentation for <code>ctx add</code>, <code>ctx decision</code>, <code>ctx learning</code></li> <li>Context Files: format and conventions for <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, and <code>CONVENTIONS.md</code></li> </ul>","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":"<p>Claude Code maintains per-project auto memory at <code>~/.claude/projects/<slug>/memory/MEMORY.md</code>. This file is:</p> <ul> <li>Outside the repo - not version-controlled, not portable</li> <li>Machine-specific - tied to one <code>~/.claude/</code> directory</li> <li>Invisible to <code>ctx</code> - context loading and hooks don't read it</li> </ul> <p>Meanwhile, <code>ctx</code> 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.</p> <p>The two systems hold complementary knowledge with no bridge between them.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>The <code>check-memory-drift</code> hook nudges automatically when MEMORY.md changes - you don't need to remember to sync manually.</p>","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 <code>ctx memory sync</code> CLI command Copy MEMORY.md to mirror, archive previous <code>ctx memory status</code> CLI command Show drift, timestamps, line counts <code>ctx memory diff</code> CLI command Show changes since last sync <code>ctx memory import</code> CLI command Classify and promote entries to .context/ files <code>ctx memory publish</code> CLI command Push curated .context/ content to MEMORY.md <code>ctx memory unpublish</code> CLI command Remove published block from MEMORY.md <code>ctx system check-memory-drift</code> 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":"<p>Claude Code encodes project paths as directory names under <code>~/.claude/projects/</code>. The encoding replaces <code>/</code> with <code>-</code> and prefixes with <code>-</code>:</p> <pre><code>/home/jose/WORKSPACE/ctx → ~/.claude/projects/-home-jose-WORKSPACE-ctx/\n</code></pre> <p><code>ctx memory</code> uses this encoding to locate MEMORY.md automatically from your project root - no configuration needed.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#mirroring","level":3,"title":"Mirroring","text":"<p>When you run <code>ctx memory sync</code>:</p> <ol> <li>The previous mirror is archived to <code>.context/memory/archive/mirror-<timestamp>.md</code></li> <li>MEMORY.md is copied to <code>.context/memory/mirror.md</code></li> <li>Sync state is updated in <code>.context/state/memory-import.json</code></li> </ol> <p>The mirror is git-tracked, so it travels with the project. Archives provide a fallback for projects that don't use git.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#drift-detection","level":3,"title":"Drift Detection","text":"<p>The <code>check-memory-drift</code> hook compares MEMORY.md's modification time against the mirror. When drift is detected, the agent sees:</p> <pre><code>┌─ Memory Drift ────────────────────────────────────────────────\n│ MEMORY.md has changed since last sync.\n│ Run: ctx memory sync\n│ Context: .context\n└────────────────────────────────────────────────────────────────\n</code></pre> <p>The nudge fires once per session to avoid noise.</p>","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":"<p>If the hook fires a drift nudge, sync before diving into work:</p> <pre><code>ctx memory diff # Review what changed\nctx memory sync # Mirror the changes\n</code></pre>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#periodic-check","level":3,"title":"Periodic Check","text":"<pre><code>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</code></pre>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#dry-run","level":3,"title":"Dry Run","text":"<p>Preview what sync would do without writing:</p> <pre><code>ctx memory sync --dry-run\n</code></pre>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#storage-layout","level":2,"title":"Storage Layout","text":"<pre><code>.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</code></pre>","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 <code>sync</code> exits 1 with message. <code>status</code> 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 <code>ctx</code> commands).","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#importing-entries","level":2,"title":"Importing Entries","text":"<p>Once you've synced, you can classify and promote entries into structured <code>.context/</code> files:</p> <pre><code>ctx memory import --dry-run # Preview classification\nctx memory import # Actually promote entries\n</code></pre> <p>Each entry is classified by keyword heuristics:</p> Keywords Target <code>always use</code>, <code>prefer</code>, <code>never use</code>, <code>standard</code> CONVENTIONS.md <code>decided</code>, <code>chose</code>, <code>trade-off</code>, <code>approach</code> DECISIONS.md <code>gotcha</code>, <code>learned</code>, <code>watch out</code>, <code>bug</code>, <code>caveat</code> LEARNINGS.md <code>todo</code>, <code>need to</code>, <code>follow up</code> TASKS.md Everything else Skipped <p>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.</p> <p>Review Before Importing</p> <p>Use <code>--dry-run</code> first. The heuristic classifier is deliberately simple - it may misclassify ambiguous entries. Review the plan, then import.</p>","path":["Recipes","Knowledge and Tasks","Bridging Claude Code Auto Memory"],"tags":[]},{"location":"recipes/memory-bridge/#full-workflow","level":3,"title":"Full Workflow","text":"<pre><code>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</code></pre>","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 <code>MEMORY.md</code>","text":"<p>Push curated <code>.context/</code> content back into MEMORY.md so Claude Code sees structured project context on session start - without needing hooks.</p> <pre><code>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</code></pre> <p>Published content is wrapped in markers:</p> <pre><code><!-- ctx:published -->\n# Project Context (managed by ctx)\n\n## Pending Tasks\n- [ ] Implement feature X\n...\n<!-- ctx:end -->\n</code></pre> <p>Rules:</p> <ul> <li><code>ctx</code> owns everything between the markers</li> <li>Claude owns everything outside the markers</li> <li><code>ctx memory import</code> reads only outside the markers</li> <li><code>ctx memory publish</code> replaces only inside the markers</li> </ul> <p>To remove the published block entirely:</p> <pre><code>ctx memory unpublish\n</code></pre> <p>Publish at Wrap-Up, Not on Commit</p> <p>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.</p>","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":"<pre><code>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</code></pre>","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":"<p>You have installed <code>ctx</code> 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: </p> <ul> <li>Claude Code supports native hooks that load and save context automatically.</li> <li>Cursor injects context via its system prompt.</li> <li>Aider reads context files through its <code>--read</code> flag.</li> </ul> <p>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.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tldr","level":2,"title":"TL;DR","text":"<pre><code>cd your-project\nctx init # creates .context/\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# ## OpenCode ##\nctx setup opencode --write && ctx init\n\n# ## Cursor / Aider / Copilot / Windsurf ##\nctx setup cursor # or: aider, copilot, windsurf\n\n# ## Companion tools (highly recommended) ##\ngitnexus analyze # code knowledge graph\n# Add Gemini Search MCP server for grounded web search\n</code></pre> <p>Run subsequent <code>ctx</code> commands from the project root; <code>ctx</code> always reads <code>$PWD/.context/</code>.</p> <p>Create a <code>.ctxrc</code> in your project root to configure token budgets, context directory, drift thresholds, and more.</p> <p>Then start your AI tool and ask: \"Do you remember?\"</p>","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 <code>ctx init</code> Create <code>.context/</code> directory, templates, and permissions <code>ctx setup</code> Generate integration configuration for a specific AI tool <code>ctx agent</code> Print a token-budgeted context packet for AI consumption <code>ctx load</code> Output assembled context in read order (for manual pasting) <code>ctx watch</code> Auto-apply context updates from AI output (non-native tools) <code>ctx completion</code> Generate shell autocompletion for bash, zsh, or fish <code>ctx journal import</code> 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 <code>ctx</code>","text":"<p>Run <code>ctx init</code> in your project root. This creates the <code>.context/</code> directory with all template files and seeds <code>ctx</code> permissions in <code>settings.local.json</code>.</p> <pre><code>cd your-project\nctx init\n</code></pre> <p>This produces the following structure:</p> <pre><code>.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</code></pre> <p>One <code>.context/</code> per project</p> <p><code>ctx</code> reads <code>$PWD/.context/</code>; the directory always lives alongside <code>.git/</code> at the project root. Sharing one directory across multiple projects corrupts journals, state, and secrets. For cross-project knowledge sharing (CONSTITUTION, CONVENTIONS, ARCHITECTURE, etc.) use <code>ctx hub</code>.</p> <p>For Claude Code, install the <code>ctx</code> plugin to get hooks and skills:</p> <pre><code>claude /plugin marketplace add ActiveMemory/ctx\nclaude /plugin install ctx@activememory-ctx\n</code></pre> <p>If you only need the core files (useful for lightweight setups), use the <code>--minimal</code> flag:</p> <pre><code>ctx init --minimal\n</code></pre> <p>This creates only <code>TASKS.md</code>, <code>DECISIONS.md</code>, and <code>CONSTITUTION.md</code>.</p>","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":"<p>If you are using a tool other than Claude Code (which is configured automatically by <code>ctx init</code>), generate its integration configuration:</p> <pre><code># 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</code></pre> <p>Each command prints the configuration you need. How you apply it depends on the tool.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#claude-code","level":4,"title":"Claude Code","text":"<p>No action needed. Just install <code>ctx</code> from the Marketplace as <code>ActiveMemory/ctx</code>.</p> <p>Claude Code Is a First-Class Citizen</p> <p>With the <code>ctx</code> plugin installed, Claude Code gets hooks and skills automatically. The <code>PreToolUse</code> hook runs <code>ctx agent --budget 4000</code> on every tool call (with a 10-minute cooldown so it only fires once per window).</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#opencode","level":4,"title":"OpenCode","text":"<p>Run the one-liner from the project root:</p> <pre><code>ctx setup opencode --write && ctx init\n</code></pre> <p>This deploys a lifecycle plugin, slash command skills, <code>AGENTS.md</code>, and registers the <code>ctx</code> MCP server globally. See <code>ctx</code> for OpenCode for full details.</p> <p>OpenCode Is a First-Class Citizen</p> <p>With the plugin installed, OpenCode gets lifecycle hooks and skills automatically. Context loads at session start, survives compaction, and persists at session end, with no manual steps needed.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#vs-code","level":4,"title":"VS Code","text":"<p>Install the <code>ctx</code> extension from the VS Code Marketplace (publisher: <code>activememory</code>). Then, from your project root:</p> <pre><code>ctx init\n</code></pre> <p>Open Copilot Chat and type <code>@ctx /init</code> to verify. The extension auto-downloads the <code>ctx</code> CLI if it isn't on PATH. See <code>ctx</code> for VS Code for full details.</p> <p>VS Code Is a First-Class Citizen</p> <p>The extension carries its own runtime. No <code>ctx setup</code> step is needed. It registers a <code>@ctx</code> chat participant with 45 slash commands, automatic hooks (file save, git commit, <code>.context/</code> change, dependency-file edit), and a reminder status-bar indicator. Unlike embedded harnesses, the extension ships through its own pipeline to the VS Code Marketplace.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#cursor","level":4,"title":"Cursor","text":"<p>Add the system prompt snippet to <code>.cursor/settings.json</code>:</p> <pre><code>{\n \"ai.systemPrompt\": \"Read .context/TASKS.md and .context/CONVENTIONS.md before responding. Follow rules in .context/CONSTITUTION.md.\"\n}\n</code></pre> <p>Context files appear in Cursor's file tree. You can also paste a context packet directly into chat:</p> <pre><code>ctx agent --budget 4000 | xclip # Linux\nctx agent --budget 4000 | pbcopy # macOS\n</code></pre>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#aider","level":4,"title":"Aider","text":"<p>Create <code>.aider.conf.yml</code> so context files are loaded on every session:</p> <pre><code>read:\n - .context/CONSTITUTION.md\n - .context/TASKS.md\n - .context/CONVENTIONS.md\n - .context/DECISIONS.md\n</code></pre> <p>Then start Aider normally:</p> <pre><code>aider\n</code></pre> <p>Or specify files on the command line:</p> <pre><code>aider --read .context/TASKS.md --read .context/CONVENTIONS.md\n</code></pre>","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":"<p>Shell completion lets you tab-complete <code>ctx</code> subcommands and flags, which is especially useful while learning the CLI.</p> <pre><code># 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</code></pre> <p>After sourcing, typing <code>ctx a<TAB></code> completes to <code>ctx agent</code>, and <code>ctx journal <TAB></code> shows <code>list</code>, <code>show</code>, and <code>export</code>.</p>","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":"<p>Start a fresh session in your AI tool and ask:</p> <p>\"Do you remember?\"</p> <p>A correctly configured tool responds with specific context: current tasks from <code>TASKS.md</code>, recent decisions, and previous session topics. It should not say \"I don't have memory\" or \"Let me search for files.\"</p> <p>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:</p> <ul> <li>After a debugging session, it offers to save a learning.</li> <li>After a trade-off discussion, it asks whether to record the decision.</li> <li>After completing a task, it suggests follow-up items.</li> </ul> <p>The \"do you remember?\" check verifies both halves: recall and responsibility.</p> <p>For example, after resolving a tricky bug, a proactive agent might say:</p> <pre><code>That Redis timeout issue was subtle. Want me to save this as a *learning*\nso we don't hit it again?\n</code></pre> <p>If you see behavior like this, the setup is working end to end.</p> <p>In Claude Code, you can also invoke the <code>/ctx-status</code> skill:</p> <pre><code>/ctx-status\n</code></pre> <p>This prints a summary of all context files, token counts, and recent activity, confirming that hooks are loading context.</p> <p>If context is not loading, check the basics:</p> Symptom Fix <code>ctx: command not found</code> Ensure <code>ctx</code> is in your PATH: <code>which ctx</code> Hook errors Verify plugin is installed: <code>claude /plugin list</code> Context not refreshing Cooldown may be active; wait 10 minutes or set <code>--cooldown 0</code>","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":"<p>Tools like Aider, Copilot, and Windsurf do not support native hooks for saving context automatically. For these, run <code>ctx watch</code> alongside your AI tool.</p> <p>Pipe the AI tool's output through <code>ctx watch</code>:</p> <pre><code># 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</code></pre> <p>Or for any generic tool:</p> <pre><code>your-ai-tool 2>&1 | tee /tmp/ai.log &\nctx watch --log /tmp/ai.log\n</code></pre> <p>When the AI emits structured update commands, <code>ctx watch</code> parses and applies them automatically:</p> <pre><code><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</code></pre> <p>To preview changes without modifying files:</p> <pre><code>ctx watch --dry-run --log /tmp/ai.log\n</code></pre>","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":"<p>If you want to browse past session transcripts, import them to the journal:</p> <pre><code>ctx journal import --all\n</code></pre> <p>This converts raw session data into editable Markdown files in <code>.context/journal/</code>. You can then enrich them with metadata using <code>/ctx-journal-enrich-all</code> inside your AI assistant.</p>","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":"<p>Here is the condensed setup for all three tools:</p> <pre><code># ## 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# ## OpenCode ##\nctx setup opencode --write\n# Start OpenCode, 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</code></pre>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>ctx init</code> (not <code>--minimal</code>) for your first project. The full template set gives the agent more to work with, and you can always delete files later.</li> <li>For Claude Code, the token budget is configured in the plugin's <code>hooks.json</code>. To customize, adjust the <code>--budget</code> flag in the <code>ctx agent</code> hook command.</li> <li>The <code>--session $PPID</code> flag isolates cooldowns per Claude Code process, so parallel sessions do not suppress each other.</li> <li>Commit your <code>.context/</code> directory to version control. Several <code>ctx</code> features (journals, changelogs, blog generation) rely on git history.</li> <li>For Cursor and Copilot, keep <code>CONVENTIONS.md</code> visible. These tools treat open files as higher-priority context.</li> <li>Run <code>ctx drift</code> periodically to catch stale references before they confuse the agent.</li> <li>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.</li> </ul>","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":"<p><code>ctx</code> skills can leverage external MCP servers for web search and code intelligence. <code>ctx</code> works without them, but they significantly improve agent behavior across sessions. The investment is small and the benefits compound. Skills like <code>/ctx-code-review</code>, <code>/ctx-explain</code>, and <code>/ctx-refactor</code> all become noticeably better with these tools connected.</p> <p>The two sections below name canonical implementations that ctx has tested against — Gemini Search for web-search-with-citations and GitNexus for the code knowledge graph. If your toolchain provides equivalent capabilities through different MCP servers (Firecrawl, Exa, Tavily for web search; sourcegraph-cody for code graph), use those instead. ctx skills describe capabilities, not specific tools — the agent self-routes based on what's connected.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gemini-search","level":3,"title":"Gemini Search","text":"<p>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).</p> <p>Setup: Add the Gemini Search MCP server to your Claude Code settings. See the Gemini Search MCP documentation for installation.</p> <p>Verification: <pre><code># The agent checks this automatically during /ctx-remember\n# Manual test: ask the agent to search for something\n</code></pre></p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#gitnexus","level":3,"title":"GitNexus","text":"<p>Provides a code knowledge graph with symbol resolution, blast radius analysis, and domain clustering. Used by skills like <code>/ctx-refactor</code> (impact analysis) and <code>/ctx-code-review</code> (dependency awareness).</p> <p>Setup: Add the GitNexus MCP server to your Claude Code settings, then index your project:</p> <pre><code>gitnexus analyze\n</code></pre> <p>Verification: <pre><code># The agent checks this automatically during /ctx-remember\n# If the index is stale, it will suggest rehydrating\n</code></pre></p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#suppressing-the-check","level":3,"title":"Suppressing the Check","text":"<p>If you don't use companion tools and want to skip the availability check at session start, add to <code>.ctxrc</code>:</p> <pre><code>companion_check: false\n</code></pre>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#future-direction","level":3,"title":"Future Direction","text":"<p>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.</p>","path":["Recipes","Getting Started","Setup Across AI Tools"],"tags":[]},{"location":"recipes/multi-tool-setup/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: full session lifecycle recipe</li> <li>Multilingual Session Parsing: configure session header prefixes for other languages</li> <li>CLI Reference: all commands and flags</li> <li>Integrations: detailed per-tool integration docs</li> </ul>","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":"<p>Your team works across languages. Session files written by AI tools might use headers like <code># Oturum: 2026-01-15 - API Düzeltme</code> (Turkish) or <code># セッション: 2026-01-15 - テスト</code> (Japanese) instead of <code># Session: 2026-01-15 - Fix API</code>.</p> <p>By default, <code>ctx</code> only recognizes <code>Session:</code> 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.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#tldr","level":2,"title":"TL;DR","text":"<p>Add recognized prefixes to <code>.ctxrc</code>:</p> <pre><code>session_prefixes:\n - \"Session:\" # English (include to keep default)\n - \"Oturum:\" # Turkish\n - \"セッション:\" # Japanese\n</code></pre> <p>Restart your session. All configured prefixes are now recognized.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#how-it-works","level":2,"title":"How It Works","text":"<p>The Markdown session parser detects session files by looking for an H1 header that starts with a known prefix followed by a date:</p> <pre><code># Session: 2026-01-15 - Fix API Rate Limiting\n# Oturum: 2026-01-15 - API Düzeltme\n# セッション: 2026-01-15 - テスト\n</code></pre> <p>The list of recognized prefixes comes from <code>session_prefixes</code> in <code>.ctxrc</code>. When the key is absent or empty, <code>ctx</code> falls back to the built-in default: <code>[\"Session:\"]</code>.</p> <p>Date-only headers (<code># 2026-01-15 - Morning Work</code>) are always recognized regardless of prefix configuration.</p>","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":"<p>Add the prefix with a trailing colon to your <code>.ctxrc</code>:</p> <pre><code>session_prefixes:\n - \"Session:\"\n - \"Sesión:\" # Spanish\n</code></pre> <p>Include Session: Explicitly</p> <p>When you override <code>session_prefixes</code>, the default is replaced, not extended. If you still want English headers recognized, include <code>\"Session:\"</code> in your list.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#team-setup","level":3,"title":"Team Setup","text":"<p>Commit <code>.ctxrc</code> to the repo so all team members share the same prefix list. This ensures <code>ctx journal import</code> and journal generation pick up sessions from all team members regardless of language.</p>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#common-prefixes","level":3,"title":"Common Prefixes","text":"Language Prefix English <code>Session:</code> Turkish <code>Oturum:</code> Spanish <code>Sesión:</code> French <code>Session:</code> German <code>Sitzung:</code> Japanese <code>セッション:</code> Korean <code>세션:</code> Portuguese <code>Sessão:</code> Chinese <code>会话:</code>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#verifying","level":3,"title":"Verifying","text":"<p>After configuring, test with <code>ctx journal source</code>. Sessions with the new prefixes should appear in the output.</p>","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":"<ul> <li>Change the interface language: <code>ctx</code> output is always English. This setting only controls which session files <code>ctx</code> can parse.</li> <li>Generate headers: <code>ctx</code> never writes session headers. The prefix list is recognition-only (input, not output).</li> <li>Affect JSONL sessions: Claude Code JSONL transcripts don't use header prefixes. This only applies to Markdown session files in <code>.context/sessions/</code>.</li> </ul>","path":["Recipes","Getting Started","Multilingual Session Parsing"],"tags":[]},{"location":"recipes/multilingual-sessions/#see-also","level":2,"title":"See Also","text":"<p>See also: Setup Across AI Tools - complete multi-tool setup including Markdown session configuration.</p> <p>See also: CLI Reference - full <code>.ctxrc</code> field reference including <code>session_prefixes</code>.</p>","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":"<p>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.</p> <p>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.</p> <p>Git worktrees solve this. </p> <p>Each worktree is a separate working directory with its own branch, but they share the same <code>.git</code> object database. Combined with <code>ctx</code>'s persistent context, each agent session picks up the full project state and works independently.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/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</code></pre> <p><code>TASKS.md</code> will conflict on merge: Accept all <code>[x]</code> completions from both sides.</p>","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 <code>/ctx-worktree</code> Skill Create, list, and tear down worktrees <code>/ctx-next</code> Skill Pick tasks from the backlog for each track <code>git worktree</code> Command Underlying git worktree management <code>git merge</code> 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":"<p>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.</p> <pre><code>/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</code></pre> <p>The agent reads <code>TASKS.md</code>, estimates file overlap, and proposes groups:</p> <pre><code>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</code></pre>","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":"<p>Once you approve the grouping, the agent creates worktrees as sibling directories:</p> <pre><code>Create the worktrees for those three groups.\n</code></pre> <p>Behind the scenes:</p> <pre><code>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</code></pre> <p>Each worktree is a full working copy on its own branch.</p>","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":"<p>Open a separate terminal (or editor window) for each worktree and start a Claude Code session:</p> <pre><code># Terminal 1\ncd ../myproject-docs\nclaude\n\n# Terminal 2\ncd ../myproject-crypto\nclaude\n\n# Terminal 3\ncd ../myproject-tests\nclaude\n</code></pre> <p>Each agent sees the full project, including <code>.context/</code>, and can work independently. </p> <p>Do Not Initialize Context in Worktrees</p> <p>Do not run <code>ctx init</code> in worktrees: The <code>.context</code> directory is already tracked in <code>git</code>.</p>","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":"<p>Each agent works through its assigned tasks. They can read <code>TASKS.md</code> to know what's assigned to their track, use <code>/ctx-next</code> to pick the next item, and commit normally on their <code>work/*</code> branch.</p>","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":"<p>As each track finishes, return to the main checkout and merge:</p> <pre><code>/ctx-worktree teardown docs\n</code></pre> <p>The agent checks for uncommitted changes, merges <code>work/docs</code> into your current branch, removes the worktree, and deletes the branch.</p>","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 <code>TASKS.md</code> Conflicts","text":"<p><code>TASKS.md</code> will almost always conflict when merging: Multiple agents will mark different tasks as <code>[x]</code>. This is expected and easy to resolve:</p> <p>Accept all completions from both sides. No task should go from <code>[x]</code> back to <code>[ ]</code>. The merge resolution is always additive.</p>","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":"<p>After all tracks are merged, verify everything is clean:</p> <pre><code>/ctx-worktree list\n</code></pre> <p>Should show only the main working tree. All <code>work/*</code> branches should be gone.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't have to use the skill directly for every step. These natural prompts work:</p> <ul> <li>\"I have a big backlog. Can we split it across worktrees?\"</li> <li>\"Which of these tasks can run in parallel without conflicts?\"</li> <li>\"Merge the docs track back in.\"</li> <li>\"Clean up all the worktrees, we're done.\"</li> </ul>","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":"<p>The encryption key lives at <code>~/.ctx/.ctx.key</code> (user-level, outside the project). All worktrees on the same machine share this one key — there is no per-project key (an implicit <code>.context/.ctx.key</code> is never auto-detected), so <code>ctx pad</code> and <code>ctx hook notify</code> decrypt correctly in worktrees automatically, with no special setup.</p> <p>Whether <code>ctx hook notify</code> actually fires in a worktree is your call, made through one decision: do you git-track <code>.ctxrc</code>?</p> <ul> <li>Tracked <code>.ctxrc</code> (committed) → its <code>notify.events</code> list rides into every checkout, so notifications fire from worktrees too. Committing <code>.ctxrc</code> is safe: it holds <code>notify.events</code>, <code>key_path</code>, and rotation settings — never the webhook secret, which stays encrypted in <code>.context/.notify.enc</code>.</li> <li>Gitignored <code>.ctxrc</code> (e.g. the profile workflow with tracked <code>.ctxrc.base</code> / <code>.ctxrc.dev</code>) → a fresh worktree has no active <code>.ctxrc</code>, so ctx applies built-in defaults and notifications stay off there. <code>.ctxrc.base</code> is a template, not a fallback: ctx reads only the active <code>.ctxrc</code>. To enable notifications in such a worktree, copy a <code>.ctxrc</code> into it (or run <code>ctx config switch</code>).</li> </ul> <p>ctx deliberately does not special-case worktrees — it cannot tell a worktree from several terminals open in the same project — so the <code>.ctxrc</code>-tracking choice is the single, explicit control.</p> <p>If a configured webhook ever can't be delivered (a wrong or missing key, a decrypt failure, a network error), <code>ctx hook notify</code> prints a <code>ctx: notify: webhook configured but undeliverable: …</code> warning to stderr instead of silently dropping the notification.</p> <p>One thing to watch:</p> <ul> <li>Journal enrichment: <code>ctx journal import</code> and <code>ctx journal enrich</code> 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.</li> </ul> <p>Context Files Will Merge Just Fine</p> <p>Tracked context files (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>) work normally; <code>git</code> handles them.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#tips","level":2,"title":"Tips","text":"<ul> <li>3-4 worktrees max. Beyond that, merge complexity outweighs the parallelism benefit. The skill enforces this limit.</li> <li>Group by package or directory, not by priority. Two high-priority tasks that touch the same files must be in the same track.</li> <li><code>TASKS.md</code> will conflict on merge. This is normal. Accept all <code>[x]</code> completions: The resolution is always additive.</li> <li>Don't run <code>ctx init</code> in worktrees. The <code>.context/</code> directory is tracked in git. Running init overwrites shared context files.</li> <li>Name worktrees by concern, not by number. <code>work/docs</code> and <code>work/crypto</code> are more useful than <code>work/track-1</code> and <code>work/track-2</code>.</li> <li>Commit frequently in each worktree. Smaller commits make merge conflicts easier to resolve.</li> </ul>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#next-up","level":2,"title":"Next Up","text":"<p>Back to the beginning: Guide Your Agent →</p> <p>Or explore the full recipe list.</p>","path":["Recipes","Agents and Automation","Parallel Agent Development with Git Worktrees"],"tags":[]},{"location":"recipes/parallel-worktrees/#see-also","level":2,"title":"See Also","text":"<ul> <li>Running an Unattended AI Agent: for serial autonomous loops instead of parallel tracks</li> <li>Tracking Work Across Sessions: managing the task backlog that feeds into parallelization</li> <li>The Complete Session: the complete session workflow end-to-end, with examples</li> </ul>","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":"<p>Claude Code's <code>.claude/settings.local.json</code> 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.</p> <p>Since <code>settings.local.json</code> is <code>.gitignore</code>d, 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.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/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</code></pre>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#the-solution","level":2,"title":"The Solution","text":"<p>Save a curated <code>settings.local.json</code> as a golden image, then restore from it to drop session-accumulated permissions. The golden file (<code>.claude/settings.golden.json</code>) is committed to version control and shared with the team.</p>","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 <code>ctx permission snapshot</code> Save settings.local.json as golden image <code>ctx permission restore</code> Reset settings.local.json from golden image <code>/ctx-permission-sanitize</code> 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":"<p>Start with a clean <code>settings.local.json</code>. Optionally run <code>/ctx-permission-sanitize</code> to remove dangerous patterns first.</p> <p>Review the file manually. Every entry should be there because you decided it belongs, not because you clicked \"Allow\" once during debugging.</p> <p>See the Permission Hygiene recipe for recommended defaults.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#2-take-a-snapshot","level":3,"title":"2. Take a Snapshot","text":"<pre><code>ctx permission snapshot\n# Saved golden image: .claude/settings.golden.json\n</code></pre> <p>This creates a byte-for-byte copy. No re-encoding, no indent changes.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#3-commit-the-golden-file","level":3,"title":"3. Commit the Golden File","text":"<pre><code>git add .claude/settings.golden.json\ngit commit -m \"Add permission golden image\"\n</code></pre> <p>The golden file is not gitignored (unlike <code>settings.local.json</code>). This is intentional: it becomes a team-shared baseline.</p>","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":"<p>Add this instruction to your <code>CLAUDE.md</code>:</p> <pre><code>## On Session Start\n\nRun `ctx permission restore` to reset permissions to the golden image.\n</code></pre> <p>The agent will restore the golden image at the start of every session, automatically dropping any permissions accumulated during previous sessions.</p>","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":"<p>When you add a new permanent permission (not a one-off debugging entry):</p> <pre><code># 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</code></pre>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#conversational-approach","level":2,"title":"Conversational Approach","text":"<p>You don't need to remember exact commands. These natural-language prompts work with agents trained on the <code>ctx</code> playbook:</p> What you say What happens \"Save my current permissions as baseline\" Agent runs <code>ctx permission snapshot</code> \"Reset permissions to the golden image\" Agent runs <code>ctx permission restore</code> \"Clean up my permissions\" Agent runs <code>/ctx-permission-sanitize</code> 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":"<p>Turning Activity into Content →: Generate blog posts, changelogs, and journal sites from your project activity.</p>","path":["Recipes","Maintenance","Permission Snapshots"],"tags":[]},{"location":"recipes/permission-snapshots/#see-also","level":2,"title":"See Also","text":"<ul> <li>Permission Hygiene: recommended defaults and maintenance workflow</li> <li>CLI Reference: <code>ctx</code> permission: full command documentation</li> </ul>","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":"<p>Your <code>.context/</code> directory is full of decisions, learnings, and session history.</p> <p>Your <code>git log</code> tells the story of a project evolving.</p> <p>But none of this is visible to anyone outside your terminal.</p> <p>You want to turn this raw activity into:</p> <ul> <li>a browsable journal site,</li> <li>blog posts,</li> <li>changelog posts.</li> </ul>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Read on for details on each stage.</p>","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 <code>ctx journal import</code> Command Import session JSONL to editable Markdown <code>ctx journal site</code> Command Generate a static site from journal entries <code>ctx journal obsidian</code> Command Generate an Obsidian vault from journal entries <code>ctx serve</code> Command Serve any zensical directory (default: journal) <code>ctx site feed</code> Command Generate Atom feed from finalized blog posts <code>make journal</code> Makefile Shortcut for import + site rebuild <code>/ctx-journal-enrich-all</code> Skill Full pipeline: import if needed, then batch-enrich (recommended) <code>/ctx-journal-enrich</code> Skill Add metadata, summaries, and tags to one entry <code>/ctx-blog</code> Skill Draft a blog post from recent project activity <code>/ctx-blog-changelog</code> 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":"<p>Raw session data lives as JSONL files in Claude Code's internal storage. The first step is converting these into readable, editable Markdown.</p> <pre><code># 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</code></pre> <p>Imported files land in <code>.context/journal/</code> as individual Markdown files with session metadata and the full conversation transcript.</p> <p><code>--all</code> is self-healing: it imports new sessions and completes any whose transcript has grown since the last import, skipping unchanged ones and never clobbering an entry you have hand-edited. You do not need <code>--regenerate</code> for routine re-imports; it is an edge-case tool for forcing a full re-render (after a format change, or to heal a pre-self-heal truncated entry). Add <code>--keep-frontmatter=false -y</code> to discard enriched frontmatter during that re-render.</p>","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":"<p>Raw entries have timestamps and conversations but lack the structured metadata that makes a journal searchable. Use <code>/ctx-journal-enrich-all</code> to process your entire backlog at once:</p> <pre><code>/ctx-journal-enrich-all\n</code></pre> <p>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.</p> <p>For large backlogs (20+ entries), it can spawn subagents to process entries in parallel.</p> <p>To enrich a single entry instead:</p> <pre><code>/ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich 2026-01-24\n</code></pre> <p>After enrichment, an entry gains YAML frontmatter:</p> <pre><code>---\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</code></pre> <p>This metadata powers better navigation in the journal site: </p> <ul> <li>titles replace slugs, </li> <li>summaries appear in the index, </li> <li>and search covers topics and technologies.</li> </ul>","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":"<p>With entries exported and enriched, generate the static site:</p> <pre><code># 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</code></pre> <p>The site is generated in <code>.context/journal-site/</code> by default. It uses zensical for static site generation (<code>pipx install zensical</code>).</p> <p>Or use the Makefile shortcut that combines export and rebuild:</p> <pre><code>make journal\n</code></pre> <p>This runs <code>ctx journal import --all</code> followed by <code>ctx journal site --build</code>, then reminds you to enrich before rebuilding. To serve the built site, use <code>make journal-serve</code> or <code>ctx serve</code> (serve-only, no regeneration).</p>","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":"<p>If you use Obsidian for knowledge management, generate a vault instead of (or alongside) the static site:</p> <pre><code>ctx journal obsidian\nctx journal obsidian --output ~/vaults/ctx-journal\n</code></pre> <p>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.</p> <p>The vault uses the same enriched source entries as the static site. Both outputs can coexist: The static site goes to <code>.context/journal-site/</code>, the vault to <code>.context/journal-obsidian/</code>.</p>","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":"<p>When your project reaches a milestone worth sharing, use <code>/ctx-blog</code> to draft a post from recent activity. The skill gathers context from multiple sources: <code>git log</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, completed tasks, and journal entries.</p> <pre><code>/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</code></pre> <p>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 <code>docs/blog/YYYY-MM-DD-slug.md</code>.</p> <p>Posts are written in first person with code snippets, commit references, and an honest discussion of what went wrong.</p> <p>The Output Is <code>zensical</code>-Flavored Markdown</p> <p>The blog skills produce Markdown tuned for a zensical site: <code>topics:</code> frontmatter (zensical's tag field), a <code>docs/blog/</code> output path, and a banner image reference. </p> <p>The content is still standard Markdown and can be adapted to other static site generators, but the defaults assume a <code>zensical</code> project structure.</p>","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":"<p>For release notes or \"what changed\" posts, <code>/ctx-blog-changelog</code> takes a starting commit and a theme, then analyzes everything that changed:</p> <pre><code>/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</code></pre> <p>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.</p>","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":"<p>After publishing blog posts, generate the Atom feed so readers and automation can discover new content:</p> <pre><code>ctx site feed\n</code></pre> <p>This scans <code>docs/blog/</code> for finalized posts (<code>reviewed_and_finalized: true</code>), extracts title, date, author, topics, and summary, and writes a valid Atom 1.0 feed to <code>site/feed.xml</code>. The feed is also generated automatically as part of <code>make site</code>.</p> <p>The feed is available at ctx.ist/feed.xml.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#the-conversational-approach","level":2,"title":"The Conversational Approach","text":"<p>You can also drive your publishing anytime with natural language:</p> <pre><code>\"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</code></pre> <p>The agent has full visibility into your <code>.context/</code> state (tasks completed, decisions recorded, learnings captured), so its suggestions are grounded in what actually happened.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>The full pipeline from raw transcripts to published content:</p> <pre><code># 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</code></pre> <p>The journal pipeline is idempotent at every stage. You can rerun <code>ctx journal import --all</code> without losing enrichment. You can rebuild the site as many times as you want.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#tips","level":2,"title":"Tips","text":"<ul> <li>Import regularly. Run <code>ctx journal import --all</code> after each session to keep your journal current. It is self-healing: new sessions are imported and any whose transcript has grown are completed, while unchanged sources are skipped.</li> <li>Use batch enrichment. <code>/ctx-journal-enrich-all</code> filters noise (suggestion sessions, trivial sessions, multipart continuations) so you do not have to decide what is worth enriching.</li> <li>Keep journal files in <code>.gitignore</code>. Session journals can contain sensitive data: file contents, commands, internal discussions, and error messages with stack traces. Add <code>.context/journal/</code> and <code>.context/journal-site/</code> to <code>.gitignore</code>.</li> <li>Use <code>/ctx-blog</code> for narrative posts and <code>/ctx-blog-changelog</code> for release posts. One finds a story in recent activity, the other explains a commit range by theme.</li> <li>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.</li> </ul>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#next-up","level":2,"title":"Next Up","text":"<p>Running an Unattended AI Agent →: Set up an AI agent that works through tasks overnight without you at the keyboard.</p>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/publishing/#see-also","level":2,"title":"See Also","text":"<ul> <li>Session Journal: journal system, enrichment schema</li> <li>CLI Reference: <code>ctx</code> journal: import, list, show session history</li> <li>CLI Reference: <code>ctx</code> journal site: static site generation</li> <li>CLI Reference: <code>ctx</code> journal obsidian: Obsidian vault export</li> <li>CLI Reference: <code>ctx</code> serve: serve-only (no regeneration)</li> <li>Browsing and Enriching Past Sessions: journal browsing workflow</li> <li>The Complete Session: capturing context during a session</li> </ul>","path":["Recipes","Maintenance","Turning Activity into Content"],"tags":[]},{"location":"recipes/recover-aborted-session/","level":1,"title":"Recover an Aborted KB Session","text":"","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#the-problem","level":2,"title":"The Problem","text":"<p>You ran one or more <code>/ctx-kb-ingest</code> passes, then the session ended before <code>/ctx-wrap-up</code>. Maybe you closed the laptop, the connection dropped, or you just forgot the wrap-up step.</p> <p>You come back the next day and ask \"do you remember?\" and the agent picks up the previous handover, but the editorial work since the last handover seems to be missing from the readback.</p> <p>It isn't missing. It's unfolded. Here's how the pipeline handles it and how to close the loop manually.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-remember # picks up the unfolded \n # closeouts automatically\n/ctx-handover \"recovery: fold the orphan closeouts\" # direct invocation is \n # appropriate for recovery\n</code></pre> <p>The recovery path is the one legitimate place to invoke <code>/ctx-handover</code> directly. Normally <code>/ctx-wrap-up</code> owns session-end and delegates to the handover step; the abort broke that path, so a hand-rolled handover invocation is how you close the loop without re-running the full wrap-up ceremony.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#how-the-fold-mechanism-survives-an-abort","level":2,"title":"How the Fold Mechanism Survives an Abort","text":"<p>Two artifacts make abort-recovery work without any cleanup:</p> <ol> <li> <p>Closeouts are immutable once written. Every editorial pass writes a closeout under <code>.context/ingest/closeouts/<TS>-<mode>-closeout.md</code> before the pass reports <code>done</code>. If the session dies, the closeout is already on disk.</p> </li> <li> <p><code>/ctx-remember</code> folds unfolded closeouts into the readback. The skill always reads the latest handover. When <code>.context/kb/</code> exists, it additionally reads any closeouts whose <code>generated-at</code> postdates the handover. The <code>## What changed</code> and <code>## Source-coverage updates</code> sections from each unfolded closeout are surfaced in recall.</p> </li> </ol> <p>So an aborted session never loses editorial work; it just delays the handover fold by one session.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#step-1-confirm-the-orphan-closeouts","level":2,"title":"Step 1: Confirm the Orphan Closeouts","text":"<pre><code>ls -la .context/ingest/closeouts/\n</code></pre> <p>Files there with <code>generated-at</code> postdating your latest handover are the unfolded ones. You can read any closeout directly to see what it claims about its pass:</p> <pre><code>cat .context/ingest/closeouts/<TS>-ingest-closeout.md\n</code></pre> <p>Look at:</p> <ul> <li>The Pass-mode body block (<code>Declared / Reason / Definition of done / Result</code>): what the pass committed to and whether it claimed success or <code>deferred</code>.</li> <li>The Source-coverage updates section: what state transitions hit the ledger.</li> <li>The Next pass hint: the exact resumption invocation the closeout recommends, if the pass deferred.</li> </ul>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#step-2-run-ctx-remember","level":2,"title":"Step 2: Run <code>/ctx-remember</code>","text":"<pre><code>/ctx-remember\n</code></pre> <p>The readback will include the editorial-state summary as part of the standard readback shape. If everything looks consistent, proceed to Step 3.</p> <p>If the readback surfaces something surprising (a closeout claiming <code>topic-page: produced</code> for a slug whose file is missing, a <code>comprehensive</code> ledger advance against a source whose page is <code>speculative</code>, etc.), fix the underlying inconsistency before folding. (Doctor advisories for these shapes are on the Phase-7 backlog.)</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#step-3-write-the-recovery-handover","level":2,"title":"Step 3: Write the Recovery Handover","text":"<p>This step is the one legitimate direct invocation of <code>/ctx-handover</code>. In normal session-end the call goes through <code>/ctx-wrap-up</code>; here the prior session aborted, so you reach for the handover step directly to retire the orphan closeouts:</p> <pre><code>/ctx-handover \"recovery: fold orphan closeouts from yesterday\"\n</code></pre> <p>Or via the CLI:</p> <pre><code>ctx handover write \"recovery: fold orphan closeouts from yesterday\" \\\n --summary \"Folded N orphan closeouts from the aborted session.\" \\\n --next \"Resume <topic> per the closeout's Next pass hint.\"\n</code></pre> <p>The handover:</p> <ul> <li>Reads the latest handover cursor.</li> <li>Finds all closeouts whose <code>generated-at</code> is after the cursor.</li> <li>Folds their summaries into a <code>## Folded closeouts</code> section.</li> <li>Archives the source closeout files under <code>.context/archive/closeouts/</code> (closeouts are append-never-rewrite; archival moves bytes but does not modify them).</li> </ul> <p>After the handover lands, the orphan closeouts are now durably tied to a session boundary; the next <code>/ctx-remember</code> reads just the new handover (and any closeouts postdating it), without re-folding the recovered ones.</p>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#edge-cases","level":2,"title":"Edge Cases","text":"Case Behavior Closeout has malformed frontmatter Handover fold skips it with a warning to stderr. Hand-edit the malformed file (typically a missing <code>generated-at</code>) and re-run <code>ctx handover write</code> to fold it next time. Closeout's <code>generated-at</code> is before the last handover but was never folded Treated as already-folded (silently skipped; the cursor is the source of truth). If you genuinely want to re-fold it, hand-edit the closeout's <code>generated-at</code> forward. You aborted during an ingest pass, before its closeout was written No closeout exists; the pass left no recall residue. Treat the source(s) as un-ingested and re-run <code>/ctx-kb-ingest</code>. The source-coverage ledger row may show stale residue from a prior pass; the next ingest will advance it correctly. Multiple sessions piled up unfolded closeouts One handover run folds them all in a single shot. The fold is cursor-driven, not session-driven. You want recall without consuming closeouts <code>ctx handover write ... --no-fold</code> writes a handover with frontmatter but leaves the closeouts in place. The next handover (without <code>--no-fold</code>) folds everything postdating the latest handover cursor.","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#when-this-matters","level":2,"title":"When This Matters","text":"<ul> <li>After a network drop / laptop close mid-session.</li> <li>When you ran <code>/ctx-kb-ingest</code> from a sub-agent that finished without calling <code>/ctx-handover</code>.</li> <li>After porting work from another environment (e.g. you rsynced <code>.context/ingest/closeouts/</code> from a different machine) and want to integrate the work into the destination project's recall thread.</li> </ul>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/recover-aborted-session/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Build a Knowledge Base</li> <li>Recipe: Typical KB Session</li> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code></li> </ul>","path":["Recipes","Knowledge Base","Recover an Aborted KB Session"],"tags":[]},{"location":"recipes/run-the-dream/","level":1,"title":"Run the Dream","text":"<p>The dream is a scheduled, out-of-band pass that triages your gitignored <code>ideas/</code> folder — classifying each idea against your codebase and specs, and emitting gated proposals (archive / merge / promote / mark-blog / keep) for you to review. It only ever proposes; it never writes canonical memory and never acts on a proposal. You review the proposals in a ~15-minute \"garden walk\" and accept / reject / amend.</p> <p>The dream is opt-in and off by default. Nothing runs until you turn it on. This recipe wires it up for Claude Code (the reference executor). To run it under a different harness, see the executor contract.</p>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li>A ctx project (a git working tree with <code>.context/</code>).</li> <li>An <code>ideas/</code> folder at the project root (gitignored).</li> <li>The <code>ctx-dream</code> and <code>ctx-serendipity</code> skills installed (shipped with <code>ctx setup</code>).</li> <li>A non-interactive Claude Code credential (cron has no interactive fallback).</li> </ul>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#1-enable-it-in-ctxrc","level":2,"title":"1. Enable it in <code>.ctxrc</code>","text":"<p>Add a <code>dream:</code> section. <code>enabled: false</code> is the default — set it true:</p> <pre><code>dream:\n enabled: true\n mode: discipline # the only mode in v1\n max: 50 # max ideas processed per pass\n quiet_minutes: 60 # skip a pass if you were active within the window\n cadence: \"30 2 * * *\" # the cron schedule you'll install below\n budget: 40 # step/token ceiling per pass\n model: null # null = the session default model\n executor: \"\" # empty = the claude -p reference executor\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#2-confirm-dreams-is-gitignored","level":2,"title":"2. Confirm <code>dreams/</code> is gitignored","text":"<p>The dream writes its notebook (proposals, per-source state, ledger, backups) to a root-level <code>dreams/</code> directory. It inherits <code>ideas/</code>'s privacy class, so it must stay gitignored — <code>ctx init</code> adds the entry, and the don't-leak guard refuses any write that resolves to a tracked path. Verify:</p> <pre><code>git check-ignore dreams && echo \"ok: dreams/ is ignored\"\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#3-wire-the-guard-hook","level":2,"title":"3. Wire the guard hook","text":"<p>A headless pass runs with a PreToolUse guard so the agent can only write under <code>dreams/</code>. Point a dream-specific settings file at the bundled <code>guard.sh</code> (do not add it to your project's default settings — the dream is opt-in):</p> <pre><code>{\n \"hooks\": {\n \"PreToolUse\": [\n { \"matcher\": \"Write|Edit|MultiEdit\",\n \"hooks\": [{ \"type\": \"command\",\n \"command\": \"<skills>/ctx-dream/guard.sh\" }] },\n { \"matcher\": \"Bash\",\n \"hooks\": [{ \"type\": \"command\",\n \"command\": \"<skills>/ctx-dream/guard.sh\" }] }\n ]\n }\n}\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#4-install-the-cron-entry","level":2,"title":"4. Install the cron entry","text":"<p>Run one pass nightly. <code>ctx dream</code> does the gate (skips when there's no new idea delta or you were recently active), takes a lock, and invokes the executor:</p> <pre><code>30 2 * * * cd /path/to/project && PATH=/usr/local/bin:$PATH ctx dream >> ~/.ctx/dream.cron.log 2>&1\n</code></pre> <p>cron's PATH is minimal</p> <p>cron will not see a node/nvm-managed <code>claude</code> or even <code>ctx</code> unless you set <code>PATH</code> in the entry (as above). If the executor binary is not found, <code>ctx dream</code> fails loud and writes <code>dreams/.failed</code> — it never silently no-ops.</p>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#5-review-what-it-found","level":2,"title":"5. Review what it found","text":"<p>The dream nags you (via <code>ctx remind</code>) when a round is waiting. Walk the garden:</p> <pre><code>/ctx-serendipity\n</code></pre> <p>Each proposal shows its summary, evidence, and a one-line rationale. Accept / reject / amend / skip — no pressure to clear the set. Mechanical dispositions apply instantly; <code>merge</code>/<code>promote</code> are done from the full source. Rejections are recorded so they don't re-surface.</p> <p>You can also drive it directly:</p> <pre><code>ctx dream review\nctx dream accept <id>\nctx dream reject <id>\nctx dream amend <id> --action keep\n</code></pre>","path":["Recipes","Agents and Automation","Run the Dream"],"tags":[]},{"location":"recipes/run-the-dream/#what-it-will-never-do","level":2,"title":"What it will never do","text":"<ul> <li>Write the five canonical files (DECISIONS / LEARNINGS / CONVENTIONS / CONSTITUTION / TASKS). Ever.</li> <li>Act on a proposal without you. Every disposition into a tracked artifact passes through the human gate.</li> <li>Write anything outside <code>dreams/</code> during a pass (the guard enforces it), except your deliberate <code>promote</code> of an idea into <code>specs/</code>.</li> </ul>","path":["Recipes","Agents and Automation","Run the Dream"],"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":"<p>You work from multiple machines: a desktop and a laptop, or a local machine and a remote dev server.</p> <p>The scratchpad entries are encrypted. The ciphertext (<code>.context/scratchpad.enc</code>) travels with git, but the encryption key lives outside the project at <code>~/.ctx/.ctx.key</code> and is never committed. Without the key on each machine, you cannot read or write entries.</p> <p>How do you distribute the key and keep the scratchpad in sync?</p>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx init # 1. generates key\nscp ~/.ctx/.ctx.key user@machine-b:~/.ctx/.ctx.key # 2. copy key\nchmod 600 ~/.ctx/.ctx.key # 3. secure it\n# Normal git push/pull syncs the encrypted scratchpad.enc\n# On conflict: ctx pad resolve → rebuild → git add + commit\n</code></pre> <p>Finding Your Key File</p> <p>The key is always at <code>~/.ctx/.ctx.key</code> - one key, one machine.</p> <p>Treat the Key like a Password</p> <p>The scratchpad key is the only thing protecting your encrypted entries.</p> <p>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.</p> <p>Anyone with the key can decrypt every scratchpad entry.</p>","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 <code>ctx init</code> CLI command Initialize context (generates the key automatically) <code>ctx pad add</code> CLI command Add a scratchpad entry <code>ctx pad rm</code> CLI command Remove entries by stable ID (supports ranges) <code>ctx pad edit</code> CLI command Edit a scratchpad entry <code>ctx pad resolve</code> CLI command Show both sides of a merge conflict <code>ctx pad merge</code> CLI command Merge entries from other scratchpad files <code>ctx pad import</code> CLI command Bulk-import lines from a file <code>ctx pad export</code> CLI command Export blob entries to a directory <code>scp</code> Shell Copy the key file between machines <code>git push</code> / <code>git pull</code> Shell Sync the encrypted file via <code>git</code> <code>/ctx-pad</code> 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":"<p>Run <code>ctx init</code> on your first machine. The key is created automatically at <code>~/.ctx/.ctx.key</code>:</p> <pre><code>ctx init\n# ...\n# Created ~/.ctx/.ctx.key (0600)\n# Created .context/scratchpad.enc\n</code></pre> <p>The key lives outside the project directory and is never committed. The <code>.enc</code> file is tracked in git.</p> <p>Key Folder Change (v0.7.0+)</p> <p>If you built <code>ctx</code> from source or upgraded past v0.6.0, the key location changed to <code>~/.ctx/.ctx.key</code>. Check these legacy folders and copy your key manually:</p> <pre><code># 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</code></pre>","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":"<p>Use any secure transfer method. The key is always at <code>~/.ctx/.ctx.key</code>:</p> <pre><code># 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</code></pre> <p>Set permissions on Machine B:</p> <pre><code>chmod 600 ~/.ctx/.ctx.key\n</code></pre> <p>Secure the Transfer</p> <p>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). </p> <p>Never paste it in plaintext over email or chat.</p>","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":"<p>The encrypted file is committed, so standard git sync works:</p> <pre><code># 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</code></pre> <p>Both machines have the same key, so both can decrypt the same <code>.enc</code> file.</p>","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":"<p>Once the key is distributed, all <code>ctx pad</code> commands work identically on both machines. Entries added on Machine A are visible on Machine B after a <code>git pull</code>, and vice versa.</p>","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":"<p>If both machines add entries between syncs, pulling will create a merge conflict on <code>.context/scratchpad.enc</code>. Git cannot merge binary (encrypted) content automatically.</p> <p>The fastest approach is <code>ctx pad merge</code>: It reads both conflict sides, deduplicates, and writes the union:</p> <pre><code># 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</code></pre> <p>Alternatively, use <code>ctx pad resolve</code> to inspect both sides manually:</p> <pre><code>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</code></pre> <p>Then reconstruct the merged scratchpad:</p> <pre><code># 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</code></pre>","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":"<p>Here's a full scenario showing how conflicts arise and how to resolve them:</p> <p>1. Both machines start in sync (1 entry):</p> <pre><code>Machine A: 1. staging API key: sk-test-abc123\nMachine B: 1. staging API key: sk-test-abc123\n</code></pre> <p>2. Both add entries independently:</p> <pre><code>Machine A adds: \"check DNS after deploy\"\nMachine B adds: \"new endpoint: api.example.com/v2\"\n</code></pre> <p>3. Machine A pushes first. Machine B pulls and gets a conflict:</p> <pre><code>git pull\n# CONFLICT (content): Merge conflict in .context/scratchpad.enc\n</code></pre> <p>4. Machine B runs <code>ctx pad resolve</code>:</p> <pre><code>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</code></pre> <p>5. Rebuild with entries from both sides and commit:</p> <pre><code># 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</code></pre>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#conversational-approach","level":3,"title":"Conversational Approach","text":"<p>When working with an AI assistant, you can resolve conflicts naturally:</p> <pre><code>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</code></pre>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#tips","level":2,"title":"Tips","text":"<ul> <li>Back up the key: If you lose it, you lose access to all encrypted entries. Store a copy in your password manager.</li> <li>One key per project: Each <code>ctx init</code> generates a unique key. Don't reuse keys across projects.</li> <li>Keys work in worktrees: Because the key lives at <code>~/.ctx/.ctx.key</code> (outside the project), git worktrees on the same machine share the key automatically. No special setup needed.</li> <li>Plaintext fallback for non-sensitive projects: If encryption adds friction and you have nothing sensitive, set <code>scratchpad_encrypt: false</code> in <code>.ctxrc</code>. Merge conflicts become trivial text merges.</li> <li>Never commit the key: The key is stored outside the project at <code>~/.ctx/.ctx.key</code> and should never be copied into the repository.</li> </ul>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#next-up","level":2,"title":"Next Up","text":"<p>Hook Output Patterns →: Choose the right output pattern for your Claude Code hooks.</p>","path":["Recipes","Knowledge and Tasks","Syncing Scratchpad Notes Across Machines"],"tags":[]},{"location":"recipes/scratchpad-sync/#see-also","level":2,"title":"See Also","text":"<ul> <li>Scratchpad: feature overview, all commands, when to use scratchpad vs context files</li> <li>Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad</li> </ul>","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":"<p>During a session you accumulate quick notes, reminders, intermediate values, and sometimes sensitive tokens. They don't fit <code>TASKS.md</code> (not work items) or <code>DECISIONS.md</code> (not decisions). They don't have the structured fields that <code>LEARNINGS.md</code> requires.</p> <p>Without somewhere to put them, they get lost between sessions.</p> <p>How do you capture working memory that persists across sessions without polluting your structured context files?</p>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx pad add \"check DNS propagation after deploy\"\nctx pad # list entries\nctx pad show 1 # print entry (pipe-friendly)\n</code></pre> <p>Entries are encrypted at rest and travel with <code>git</code>. </p> <p>Use the <code>/ctx-pad</code> skill to manage entries from inside your AI session.</p>","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 <code>ctx pad</code> CLI command List all scratchpad entries <code>ctx pad show N</code> CLI command Output raw text of entry N (pipe-friendly) <code>ctx pad add</code> CLI command Add a new entry <code>ctx pad edit</code> CLI command Replace, append to, or prepend to an entry <code>ctx pad add --file</code> CLI command Ingest a file as a blob entry <code>ctx pad show N --out</code> CLI command Extract a blob entry to a file <code>ctx pad rm</code> CLI command Remove entries by stable ID (supports ranges) <code>ctx pad normalize</code> CLI command Reassign entry IDs as 1..N <code>ctx pad mv</code> CLI command Reorder entries <code>ctx pad --tag</code> CLI command Filter entries by tag <code>ctx pad tags</code> CLI command List all tags with counts <code>ctx pad import</code> CLI command Bulk-import lines from a file (or stdin) <code>ctx pad export</code> CLI command Export all blob entries to a directory <code>ctx pad undo</code> CLI command Restore the pad from the most recent snapshot <code>/ctx-pad</code> 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":"<p>You don't need to remember any syntax. Just tell your assistant what to jot down:</p> <pre><code>You: \"jot down: check DNS propagation after deploy\"\n\nAgent: \"Added to scratchpad:\n 1. check DNS propagation after deploy\"\n</code></pre> <p>Behind the scenes, the agent runs <code>ctx pad add \"check DNS propagation after deploy\"</code>.</p>","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":"<pre><code>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</code></pre>","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":"<pre><code>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</code></pre> <p>For partial edits, the agent can use <code>--append</code> or <code>--prepend</code>:</p> <pre><code>You: \"append the port number to entry 2\"\n\nAgent: \"Updated entry 2:\n staging API endpoint: api.prod.example.com/v2 :8443\"\n</code></pre>","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":"<p>Use <code>ctx pad show N</code> to pipe entry content into other operations:</p> <pre><code>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</code></pre>","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":"<pre><code>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</code></pre>","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":"<pre><code>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</code></pre>","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":"<p>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:</p> <pre><code># 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</code></pre>","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":"<p>Use <code>show --out</code> to write the decoded file back to disk:</p> <pre><code># 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</code></pre> <p>Blob entries are encrypted identically to text entries: They're just base64-encoded before encryption. The <code>--out</code> flag decodes and writes the raw bytes.</p>","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":"<p>When you have a file with many notes (one per line), import them in bulk instead of adding one at a time:</p> <pre><code># 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</code></pre> <p>All entries are written in a single encrypt/write cycle, regardless of how many lines the file contains.</p>","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":"<p>Export all blob entries to a directory as individual files. Each blob's label becomes the filename:</p> <pre><code># 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</code></pre> <p>When a file already exists, a unix timestamp is prepended to the filename to avoid collisions. Use <code>--force</code> to overwrite instead.</p>","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":"<p>Tags let you categorize entries without any structure beyond a <code>#word</code> token in the text. Add them when creating or editing entries:</p> <pre><code>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</code></pre> <p>Filter your scratchpad by tag:</p> <pre><code>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</code></pre> <p>Entry IDs are stable; they don't shift when other entries are deleted, so <code>ctx pad rm 3</code> always targets the same entry regardless of deletions or active filters. Use <code>ctx pad normalize</code> to reassign IDs as 1..N.</p> <p>Exclude a tag with <code>~</code>:</p> <pre><code>ctx pad --tag ~later # everything NOT tagged #later\nctx pad --tag later --tag ci # entries with BOTH tags (AND logic)\n</code></pre> <p>See what tags you're using:</p> <pre><code>You: \"what tags do I have?\"\n\nAgent: [runs ctx pad tags]\n \"ci 1\n later 2\n urgent 1\"\n</code></pre> <p>Tags work on blob entries too; they're extracted from the label:</p> <pre><code>ctx pad add \"deploy config #prod\" --file ./deploy.yaml\nctx pad --tag prod\n# 1. deploy config #prod [BLOB]\n</code></pre>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#using-ctx-pad-in-a-session","level":2,"title":"Using <code>/ctx-pad</code> in a Session","text":"<p>Invoke the <code>/ctx-pad</code> skill first, then describe what you want in natural language. Without the skill prefix, the agent may route your request to <code>TASKS.md</code> or another context file instead of the scratchpad.</p> <pre><code>You: /ctx-pad jot down: check DNS after deploy\nYou: /ctx-pad show my scratchpad\nYou: /ctx-pad delete entry 3\n</code></pre> <p>Once the skill is active, it translates intent into commands:</p> You say (after <code>/ctx-pad</code>) What the agent does \"jot down: check DNS after deploy\" <code>ctx pad add \"check DNS after deploy\"</code> \"remember this: retry limit is 5\" <code>ctx pad add \"retry limit is 5\"</code> \"show my scratchpad\" / \"what's on my pad\" <code>ctx pad</code> \"show me entry 3\" <code>ctx pad show 3</code> \"delete the third one\" / \"remove entry 3\" <code>ctx pad rm 3</code> \"remove entries 3 through 5\" <code>ctx pad rm 3-5</code> \"renumber my scratchpad\" <code>ctx pad normalize</code> \"change entry 2 to ...\" <code>ctx pad edit 2 \"new text\"</code> \"append ' +important' to entry 3\" <code>ctx pad edit 3 --append \" +important\"</code> \"prepend 'URGENT:' to entry 1\" <code>ctx pad edit 1 --prepend \"URGENT: \"</code> \"prioritize entry 4\" / \"move to the top\" <code>ctx pad mv 4 1</code> \"import my notes from notes.txt\" <code>ctx pad import notes.txt</code> \"export all blobs to ./ideas\" <code>ctx pad export ./ideas</code> \"show entries tagged later\" <code>ctx pad --tag later</code> \"show everything except later\" <code>ctx pad --tag ~later</code> \"what tags do I have\" <code>ctx pad tags</code> \"tag entry 5 as urgent\" <code>ctx pad edit 5 --tag urgent</code> <p>When in Doubt, Use the CLI Directly</p> <p>The <code>ctx pad</code> commands work the same whether you run them yourself or let the skill invoke them. </p> <p>If the agent misroutes a request, fall back to <code>ctx pad add \"...\"</code> in your terminal.</p>","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\") <code>ctx remind</code> 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 <code>TASKS.md</code> Trade-offs between alternatives with rationale <code>DECISIONS.md</code> Reusable lessons with context/lesson/application <code>LEARNINGS.md</code> Codified patterns and standards <code>CONVENTIONS.md</code> <p>Decision Guide</p> <ul> <li>If it has structured fields (context, rationale, lesson, application), it belongs in a context file like <code>DECISIONS.md</code> or <code>LEARNINGS.md</code>.</li> <li>If it's a work item you'll mark done, it belongs in <code>TASKS.md</code>.</li> <li>If you want a message relayed VERBATIM at the next session start, it belongs in <code>ctx remind</code>.</li> <li>If it's a quick note, reminder, or working value (especially if it's sensitive or ephemeral) it belongs on the scratchpad.</li> </ul> <p>Scratchpad Is Not a Junk Drawer</p> <p>The scratchpad is for working memory, not long-term storage.</p> <p>If a note is still relevant after several sessions, promote it:</p> <p>A persistent reminder becomes a task, a recurring value becomes a convention, a hard-won insight becomes a learning.</p>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#tips","level":2,"title":"Tips","text":"<ul> <li>Entries persist across sessions: The scratchpad is committed (encrypted) to git, so entries survive session boundaries. Pick up where you left off.</li> <li>Entries are numbered and reorderable: Use <code>ctx pad mv</code> to put high-priority items at the top.</li> <li><code>ctx pad show N</code> enables unix piping: Output raw entry text with no numbering prefix. Compose with <code>--append</code>, <code>--prepend</code>, or other shell tools.</li> <li>Never mention the key file contents to the AI: The agent knows how to use <code>ctx pad</code> commands but should never read or print the encryption key (<code>~/.ctx/.ctx.key</code>) directly.</li> <li>Encryption is transparent: You interact with plaintext; the encryption/decryption happens automatically on every read/write.</li> </ul>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#if-you-delete-the-wrong-thing","level":2,"title":"If You Delete the Wrong Thing","text":"<p>Every destructive <code>ctx pad</code> operation (add, edit, mv, rm, merge, normalize, resolve, tag) writes a snapshot of the prior pad blob to <code>.context/scratchpad.history/</code> before overwriting. There is no confirmation prompt on the hot path — and you don't need one, because <code>ctx pad undo</code> restores the most recent snapshot:</p> <pre><code>ctx pad rm 3 # oh no, that was the one with the API token\nctx pad undo # → \"Restored pad from snapshot 20260524...\"\n</code></pre> <p>A few things to know:</p> <ul> <li>Undo is itself snapshotted. Running <code>ctx pad undo</code> twice in a row is a redo — the first undo saves the post-mutation state, then promotes the pre-mutation state; the second undo reverses that.</li> <li>Empty history is not an error. On a brand-new project with no mutations yet, <code>ctx pad undo</code> prints <code>No pad history to restore.</code> and exits 0.</li> <li>Snapshots are encrypted with the same key as the live pad. Losing <code>~/.ctx/.ctx.key</code> makes both unreadable; the safety net does not change the key-loss failure mode.</li> <li>Retention is bounded. The 20 most recent snapshots (capped also at 30 days) are kept; older ones are pruned after each mutation. Off-host backups remain the recovery path for anything beyond that window.</li> </ul>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#next-up","level":2,"title":"Next Up","text":"<p>Syncing Scratchpad Notes Across Machines →: Distribute encryption keys and scratchpad data across environments.</p>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scratchpad-with-claude/#see-also","level":2,"title":"See Also","text":"<ul> <li>Scratchpad: feature overview, all commands, encryption details, plaintext override</li> <li>Persisting Decisions, Learnings, and Conventions: for structured knowledge that outlives the scratchpad</li> <li>The Complete Session: full session lifecycle showing how the scratchpad fits into the broader workflow</li> </ul>","path":["Recipes","Knowledge and Tasks","Using the Scratchpad"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/","level":1,"title":"Scrutinizing a Plan","text":"<p>When you have a plan and want it attacked, not validated, the <code>/ctx-plan</code> skill runs an adversarial interview. It surfaces what's weak, missing, or unexamined before you commit.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#when-to-use-it","level":2,"title":"When to Use It","text":"<ul> <li>Before starting a multi-day implementation.</li> <li>After writing a spec but before opening the first PR.</li> <li>When the team aligned suspiciously fast on a complex change.</li> <li>When you've drafted something and the obvious next step is to hand it to a senior reviewer.</li> </ul> <p><code>/ctx-plan</code> is not a brainstorming tool. Use <code>/ctx-brainstorm</code> for that. <code>/ctx-plan</code> assumes the plan exists and asks: does it survive contact with reality?</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#stop-conditions","level":2,"title":"Stop Conditions","text":"<p>The skill runs depth-first through assumptions, tradeoffs, and failure modes. Stop when one of these is true:</p> <ul> <li>Plan converges. The bet is clear, the sequencing is justified, and you can articulate what would falsify it.</li> <li>Plan dissolves. The interview surfaces a load-bearing assumption you can't defend; the plan needs rework, not more scrutiny.</li> <li>You hit information you don't have. Pause, gather it, resume.</li> </ul> <p>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.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#worked-example","level":2,"title":"Worked Example","text":"<pre><code>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</code></pre> <p>The interview keeps going until the bet is articulated, the falsifiable conditions are written down, and the rejected alternatives have a recall trigger.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#output","level":2,"title":"Output","text":"<p><code>/ctx-plan</code> concludes by offering to write a debated brief to <code>.context/briefs/<TS>-<slug>.md</code>: the bet, the rejections, the failure modes, the validation route, and the unwind cost, in your words. It deliberately does not produce an implementation plan or a task list — decomposition happens after the spec, via <code>/ctx-task-out</code>. Feed the interview's conclusions forward via:</p> <ul> <li><code>/ctx-spec --brief <path></code> to absorb the brief into a committed spec; multi-milestone specs then flow to <code>/ctx-task-out</code> for decomposition.</li> <li><code>/ctx-decision-add</code> if a tradeoff resolved into an architectural decision.</li> <li><code>/ctx-learning-add</code> if you discovered a project-specific gotcha during the interview.</li> </ul> <p>The skill itself is in <code>internal/assets/claude/skills/ctx-plan/SKILL.md</code>; the working contract lives there, the recipe is the on-ramp.</p>","path":["Recipes","Knowledge and Tasks","Scrutinizing a Plan"],"tags":[]},{"location":"recipes/scrutinizing-a-plan/#see-also","level":2,"title":"See Also","text":"<ul> <li>Design Before Coding: the brainstorming counterpart, used before a plan exists.</li> <li><code>ctx-spec</code>: scaffolds a feature spec from the project template.</li> </ul>","path":["Recipes","Knowledge and Tasks","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":"<p>After weeks of AI-assisted development you have dozens of sessions scattered across JSONL files in <code>~/.claude/projects/</code>. 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.</p> <p>There is no table of contents, no search, and no summaries.</p> <p>This recipe shows how to turn that raw session history into a browsable, searchable, and enriched journal site you can navigate in your browser.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tldr","level":2,"title":"TL;DR","text":"<p>Export and Generate</p> <pre><code>ctx journal import --all\nctx journal site --serve\n</code></pre> <p>Enrich</p> <pre><code>/ctx-journal-enrich-all\n</code></pre> <p>Rebuild</p> <pre><code>ctx journal site --serve\n</code></pre> <p>Read on for what each stage does and why.</p>","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 <code>ctx journal source</code> Command List parsed sessions with metadata <code>ctx journal source --show</code> Command Inspect a specific session in detail <code>ctx journal import</code> Command Import sessions to editable journal Markdown <code>ctx journal site</code> Command Generate a static site from journal entries <code>ctx journal obsidian</code> Command Generate an Obsidian vault from journal entries <code>ctx journal schema check</code> Command Validate JSONL files and report schema drift <code>ctx journal schema dump</code> Command Print the embedded JSONL schema definition <code>ctx serve</code> Command Serve any zensical directory (default: journal) <code>/ctx-history</code> Skill Browse sessions inside your AI assistant <code>/ctx-journal-enrich</code> Skill Add frontmatter metadata to a single entry <code>/ctx-journal-enrich-all</code> 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":"<p>The session journal follows a four-stage pipeline.</p> <p>Each stage is idempotent and safe to re-run:</p> <p>By default, each stage skips entries that have already been processed.</p> <pre><code>import -> enrich -> rebuild\n</code></pre> Stage Tool What it does Skips if Where Import <code>ctx journal import --all</code> Converts session JSONL to Markdown File already exists (safe default) CLI or agent Enrich <code>/ctx-journal-enrich-all</code> Adds frontmatter, summaries, topic tags Frontmatter already present Agent only Rebuild <code>ctx journal site --build</code> Generates browsable static HTML N/A CLI only Obsidian <code>ctx journal obsidian</code> Generates Obsidian vault with wikilinks N/A CLI only <p>Where Do You Run Each Stage?</p> <p>Import (Steps 1 to 3) works equally well from the terminal or inside your AI assistant via <code>/ctx-history</code>. The CLI is fine here: the agent adds no special intelligence, it just runs the same command.</p> <p>Enrich (Step 4) requires the agent: it reads conversation content and produces structured metadata.</p> <p>Rebuild and serve (Step 5) is a terminal operation that starts a long-running server.</p>","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":"<p>Start by seeing what sessions exist for the current project:</p> <pre><code>ctx journal source\n</code></pre> <p>Sample output:</p> <pre><code>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</code></pre> <p>Slugs Look Cryptic?</p> <p>These auto-generated slugs (<code>gleaming-wobbling-sutherland</code>) are hard to recognize later.</p> <p>Use <code>/ctx-journal-enrich</code> to add human-readable titles, topic tags, and summaries to exported journal entries, making them easier to find.</p> <p>Filter by project or tool if you work across multiple codebases:</p> <pre><code>ctx journal source --project ctx --limit 10\nctx journal source --tool claude-code\nctx journal source --all-projects\n</code></pre>","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":"<p>Before exporting everything, inspect a single session to see its metadata and conversation summary:</p> <pre><code>ctx journal source --show --latest\n</code></pre> <p>Or look up a specific session by its slug, partial ID, or UUID:</p> <pre><code>ctx journal source --show gleaming-wobbling-sutherland\nctx journal source --show twinkly\nctx journal source --show abc123\n</code></pre> <p>Add <code>--full</code> to see the complete message content instead of the summary view:</p> <pre><code>ctx journal source --show --latest --full\n</code></pre> <p>This is useful for checking what happened before deciding whether to export and enrich it.</p>","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":"<p>Import converts raw session data into editable Markdown files in <code>.context/journal/</code>:</p> <pre><code># 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</code></pre> <p><code>--keep-frontmatter=false</code> Discards Enrichments</p> <p><code>--keep-frontmatter=false</code> discards enriched YAML frontmatter during regeneration.</p> <p>Back up your journal before using this flag.</p> <p>Each imported file contains session metadata (date, time, duration, model, project, git branch), a tool usage summary, and the full conversation transcript.</p> <p>Re-importing is safe. Running <code>ctx journal import --all</code> only imports new sessions: Existing files are never touched. Use <code>--dry-run</code> to preview what would be imported without writing anything.</p> <p>To re-import existing files (e.g., after a format improvement), use <code>--regenerate</code>: 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.</p> <p><code>--regenerate</code> Replaces the Markdown Body</p> <p><code>--regenerate</code> preserves YAML frontmatter but replaces the entire Markdown body with freshly generated content from the source JSONL.</p> <p>If you manually edited the conversation transcript (added notes, redacted sensitive content, restructured sections), those edits will be lost.</p> <p>BACK UP YOUR JOURNAL FIRST.</p> <p>To protect entries you've hand-edited, you can explicitly lock them:</p> <pre><code>ctx journal lock <pattern>\n</code></pre> <p>Locked entries are always skipped, regardless of flags.</p> <p>If you prefer to add <code>locked: true</code> directly in frontmatter during enrichment, run <code>ctx journal sync</code> to propagate the lock state to <code>.state.json</code>:</p> <pre><code>ctx journal sync\n</code></pre> <p>See <code>ctx journal lock --help</code> and <code>ctx journal sync --help</code> for details.</p>","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":"<p>Raw imports have timestamps and transcripts but lack the semantic metadata that makes sessions searchable: topics, technology tags, outcome status, and summaries. The <code>/ctx-journal-enrich*</code> skills add this structured frontmatter.</p> <p>Locked entries are skipped by enrichment skills, just as they are by import. Lock entries you want to protect before running batch enrichment.</p> <p>Batch enrichment (recommended):</p> <pre><code>/ctx-journal-enrich-all\n</code></pre> <p>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.</p> <p>It shows you a grouped summary before applying changes so you can scan quickly rather than reviewing one by one.</p> <p>For large backlogs (20+ entries), the skill can spawn subagents to process entries in parallel.</p> <p>Single-entry enrichment:</p> <pre><code>/ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-02-06\n</code></pre> <p>Each enriched entry gets YAML frontmatter like this:</p> <pre><code>---\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</code></pre> <p>The skill also generates a summary and can extract decisions, learnings, and tasks mentioned during the session.</p>","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":"<p>With imported and enriched journal files, generate the static site:</p> <pre><code># 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</code></pre> <p>Then open <code>http://localhost:8000</code> to browse.</p> <p>The site includes a date-sorted index, individual session pages with full conversations, search (press <code>/</code>), dark mode, and enriched titles in the navigation when frontmatter exists.</p> <p>You can also serve an already-generated site without regenerating using <code>ctx serve</code> (serve-only, no regeneration).</p> <p>The site generator requires <code>zensical</code> (<code>pipx install zensical</code>).</p>","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":"<p>Export, list, and show are mechanical: The agent runs the same CLI commands you would, so you can stay in your terminal for those.</p> <p>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.</p> <p>You can also ask your agent to browse sessions conversationally instead of remembering flags:</p> <pre><code>What did we work on last week?\nShow me the session about Redis.\nImport everything to the journal.\n</code></pre> <p>This is convenient but not required: <code>ctx journal source</code> gives you the same inventory.</p> <p>Where the agent genuinely helps is chaining the pipeline:</p> <pre><code>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</code></pre> <p>The value is staying in one context while the agent runs import -> enrich without you manually switching tools.</p>","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":"<p>A typical pipeline from raw sessions to a browsable site:</p> <pre><code># Terminal: import and generate\nctx journal import --all\nctx journal site --serve\n</code></pre> <pre><code># AI assistant: enrich\n/ctx-journal-enrich-all\n</code></pre> <pre><code># Terminal: rebuild with enrichments\nctx journal site --serve\n</code></pre> <p>If your project includes <code>Makefile.ctx</code> (deployed by <code>ctx init</code>), use <code>make journal</code> to combine import and rebuild stages. Then enrich inside Claude Code, then <code>make journal</code> again to pick up enrichments.</p>","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":"<p>Claude Code does not keep JSONL transcripts forever. Understanding its cleanup behavior helps you avoid losing session history.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#default-behavior","level":3,"title":"Default Behavior","text":"<p>Claude Code retains session transcripts for approximately 30 days. After that, JSONL files are automatically deleted during cleanup. Once deleted, <code>ctx journal</code> can no longer see those sessions - the data is gone.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#the-cleanupperioddays-setting","level":3,"title":"The <code>cleanupPeriodDays</code> Setting","text":"<p>Claude Code exposes a <code>cleanupPeriodDays</code> setting in its configuration (<code>~/.claude/settings.json</code>) that controls retention:</p> Value Behavior <code>30</code> (default) Transcripts older than 30 days are deleted <code>60</code>, <code>90</code>, etc. Extends the retention window <code>0</code> Disables writing new transcripts entirely - not \"keep forever\" <p>Setting <code>cleanupPeriodDays</code> To 0</p> <p>Setting this to <code>0</code> does not mean \"never delete.\" It disables transcript creation altogether. No new JSONL files are written, which means <code>ctx journal</code> sees nothing new. This is rarely what you want.</p>","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":"<p>The journal import pipeline (Steps 1-4 above) is your archival mechanism. Imported Markdown files in <code>.context/journal/</code> persist independently of Claude Code's cleanup cycle. Even after the source JSONL files are deleted, your journal entries remain.</p> <p>Recommendation: import regularly - weekly, or after any session worth revisiting. A quick <code>ctx journal import --all</code> takes seconds and ensures nothing falls through the 30-day window.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#quick-archival-checklist","level":3,"title":"Quick Archival Checklist","text":"<ol> <li>Run <code>ctx journal import --all</code> at least weekly</li> <li>Enrich high-value sessions with <code>/ctx-journal-enrich</code> before the details fade from your own memory</li> <li>Lock enriched entries (<code>ctx journal lock <pattern></code>) to protect them from accidental regeneration</li> <li>Rebuild the journal site periodically to keep it current</li> </ol>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>/ctx-history</code> inside your AI assistant. If you want to quickly check what happened in a recent session without leaving your editor, <code>/ctx-history</code> lets you browse interactively without importing.</li> <li>Large sessions may be split automatically. Sessions with 200+ messages can be split into multiple parts (<code>session-abc123.md</code>, <code>session-abc123-p2.md</code>, <code>session-abc123-p3.md</code>) with navigation links between them. The site generator can handle this.</li> <li>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.</li> <li>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.</li> </ul> <p>Journal Files Are Sensitive</p> <p>Journal files MUST be <code>.gitignore</code>d.</p> <p>Session transcripts can contain sensitive data such as file contents, commands, error messages with stack traces, and potentially API keys.</p> <p>Add <code>.context/journal/</code>, <code>.context/journal-site/</code>, and <code>.context/journal-obsidian/</code> to your <code>.gitignore</code>.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#next-up","level":2,"title":"Next Up","text":"<p>Persisting Decisions, Learnings, and Conventions →: Record decisions, learnings, and conventions so they survive across sessions.</p>","path":["Recipes","Sessions","Browsing and Enriching Past Sessions"],"tags":[]},{"location":"recipes/session-archaeology/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: where session saving fits in the daily workflow</li> <li>Turning Activity into Content: generating blog posts from session history</li> <li>Session Journal: full documentation of the journal system</li> <li>CLI Reference: <code>ctx</code> journal: all journal subcommands and flags</li> <li>CLI Reference: <code>ctx</code> serve: serve-only (no regeneration)</li> <li>Context Files: the <code>.context/</code> directory structure</li> </ul>","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":"<p>Sessions have two critical moments: the start and the end.</p> <ul> <li>At the start, you need the agent to load context and confirm it knows what is going on. </li> <li>At the end, you need to capture whatever the session produced before the conversation disappears.</li> </ul> <p>Most <code>ctx</code> skills work conversationally: \"jot down: check DNS after deploy\" is as good as <code>/ctx-pad add \"check DNS after deploy\"</code>. But session boundaries are different. They are well-defined moments with specific requirements, and partial execution is costly.</p> <p>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.</p> <p>This Is One of the Few Times Being Explicit Matters</p> <p>Session ceremonies are the two bookend skills that mark these boundaries. </p> <p>They are the exception to the conversational rule:</p> <p>Invoke <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> explicitly as slash commands.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tldr","level":2,"title":"TL;DR","text":"<p>Start: <code>/ctx-remember</code>: load context, get a structured readback.</p> <p>End: <code>/ctx-wrap-up</code>: review session, propose candidates, persist approved items.</p> <p>Use the slash commands, not conversational triggers, for completeness.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#explicit-invocation-matters","level":2,"title":"Explicit Invocation Matters","text":"<p>Most <code>ctx</code> skills encourage natural language. These two are different:</p> <p>Well-defined moments: Sessions have clear boundaries. A slash command marks the boundary unambiguously.</p> <p>Ambiguity risk: \"Do you remember?\" could mean many things. <code>/ctx-remember</code> means exactly one thing: load context and present a structured readback.</p> <p>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.</p> <p>Muscle memory: Typing <code>/ctx-remember</code> at session start and <code>/ctx-wrap-up</code> at session end becomes a habit, like opening and closing braces.</p>","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 <code>/ctx-remember</code> Skill Load context and present structured readback <code>/ctx-wrap-up</code> Skill Gather session signal, propose and persist context <code>/ctx-commit</code> Skill Commit with context capture (offered by wrap-up) <code>ctx agent</code> CLI Load token-budgeted context packet <code>ctx journal source</code> CLI List recent sessions <code>ctx add</code> 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: <code>/ctx-remember</code>","text":"<p>Invoke at the beginning of every session:</p> <pre><code>/ctx-remember\n</code></pre> <p>The skill silently:</p> <ol> <li>Loads the context packet via <code>ctx agent --budget 4000</code></li> <li>Reads <code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code></li> <li>Checks recent sessions via <code>ctx journal source --limit 3</code></li> </ol> <p>Then presents a structured readback with four sections:</p> <ul> <li>Last session: topic, date, what was accomplished</li> <li>Active work: pending and in-progress tasks</li> <li>Recent context: 1-2 relevant decisions or learnings</li> <li>Next step: suggestion or question about what to focus on</li> </ul> <p>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.</p> <p>What about 'do you remember?'</p> <p>The conversational trigger still works. But <code>/ctx-remember</code> guarantees the full ceremony runs: </p> <ul> <li>context packet, </li> <li>file reads, </li> <li>session history,</li> <li>and all four readback sections. </li> </ul> <p>The conversational version may cut corners.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#session-end-ctx-wrap-up","level":2,"title":"Session End: <code>/ctx-wrap-up</code>","text":"<p>Invoke before ending a session where meaningful work happened:</p> <pre><code>/ctx-wrap-up\n</code></pre> <p>The skill runs four phases:</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-1-gather-signal","level":3,"title":"Phase 1: Gather Signal","text":"<p>Silently checks <code>git diff --stat</code>, recent commits, and scans the conversation for themes: architectural choices, gotchas, patterns established, follow-up work identified.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-2-propose-candidates","level":3,"title":"Phase 2: Propose Candidates","text":"<p>Presents a structured list grouped by type:</p> <pre><code>## 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</code></pre> <p>Each candidate has complete structured fields, not just a title. Empty categories are omitted.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-3-persist","level":3,"title":"Phase 3: Persist","text":"<p>After you approve (all, some, or modified), the skill runs the appropriate <code>ctx add</code> commands and reports results.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#nudge-suppression","level":3,"title":"Nudge Suppression","text":"<p>After persisting, the skill marks the session as wrapped up via <code>ctx system mark-wrapped-up</code>. This suppresses context checkpoint nudges for 2 hours so the wrap-up ceremony itself does not trigger noisy reminders.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#phase-4-commit-offer","level":3,"title":"Phase 4: Commit Offer","text":"<p>If there are uncommitted changes, offers to run <code>/ctx-commit</code>. Does not auto-commit.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#when-to-skip","level":2,"title":"When to Skip","text":"<p>Not every session needs ceremonies.</p> <p>Skip <code>/ctx-remember</code> when:</p> <ul> <li>You are doing a quick one-off lookup (reading a file, checking a value)</li> <li>Context was already loaded this session via <code>/ctx-agent</code></li> <li>You are continuing immediately after a previous session and context is still fresh</li> </ul> <p>Skip <code>/ctx-wrap-up</code> when:</p> <ul> <li>Nothing meaningful happened (only read files, answered a question)</li> <li>You already persisted everything manually during the session</li> <li>The session was trivial (typo fix, quick config change)</li> </ul> <p>A good heuristic: if the session produced something a future session should know about, run <code>/ctx-wrap-up</code>. If not, just close.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#quick-reference","level":2,"title":"Quick Reference","text":"<pre><code># Session start\n/ctx-remember\n\n# ... do work ...\n\n# Session end\n/ctx-wrap-up\n</code></pre> <p>That is the complete ceremony. Two commands, bookending your session.</p>","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 <code>/ctx-remember</code> Session start Load and confirm context <code>/ctx-reflect</code> Mid-session breakpoints Checkpoint at milestones <code>/ctx-wrap-up</code> Session end Full session review and persist <code>/ctx-commit</code> After completing work Commit with context capture <p><code>/ctx-reflect</code> is for mid-session checkpoints. <code>/ctx-wrap-up</code> is for end-of-session: it is more thorough, covers the full session arc, and includes the commit offer. If you already ran <code>/ctx-reflect</code> recently, <code>/ctx-wrap-up</code> avoids proposing the same candidates again.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#tips","level":2,"title":"Tips","text":"<ul> <li>Make it a habit: The value of ceremonies compounds over sessions. Each <code>/ctx-wrap-up</code> makes the next <code>/ctx-remember</code> richer.</li> <li>Trust the candidates: The agent scans the full conversation. It often catches learnings you forgot about.</li> <li>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.</li> <li>Do not force empty ceremonies: If <code>/ctx-wrap-up</code> finds nothing worth persisting, that is fine. A session that only read files and answered questions does not need artificial learnings.</li> </ul>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#next-up","level":2,"title":"Next Up","text":"<p>Browsing and Enriching Past Sessions →: Export session history to a browsable journal and enrich entries with metadata.</p>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-ceremonies/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: the full session workflow that ceremonies bookend</li> <li>Persisting Decisions, Learnings, and Conventions: deep dive on what gets persisted during wrap-up</li> <li>Detecting and Fixing Drift: keeping context files accurate between ceremonies</li> <li>Pausing Context Hooks: skip ceremonies entirely for quick tasks that don't need them</li> </ul>","path":["Recipes","Sessions","Session Ceremonies"],"tags":[]},{"location":"recipes/session-changes/","level":1,"title":"Reviewing Session Changes","text":"","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-changed-while-you-were-away","level":2,"title":"What Changed While You Were Away?","text":"<p>Between sessions, teammates commit code, context files get updated, and decisions pile up. <code>ctx change</code> gives you a single-command summary of everything that moved since your last session.</p>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#quick-start","level":2,"title":"Quick Start","text":"<pre><code># 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</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#how-reference-time-works","level":2,"title":"How Reference Time Works","text":"<p><code>ctx change</code> needs a reference point to compare against. It tries these sources in order:</p> <ol> <li><code>--since</code> flag: explicit duration (<code>24h</code>, <code>72h</code>) or date (<code>2026-03-10</code>, RFC3339 timestamp)</li> <li>Session markers: <code>ctx-loaded-*</code> files in <code>.context/state/</code>; picks the second-most-recent (your previous session start)</li> <li>Event log: last <code>context-load-gate</code> event from <code>.context/state/events.jsonl</code></li> <li>Fallback: 24 hours ago</li> </ol> <p>The marker-based detection means <code>ctx change</code> usually just works without any flags: it knows when you last loaded context and shows everything after that.</p>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#what-it-reports","level":2,"title":"What It Reports","text":"","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#context-file-changes","level":3,"title":"Context File Changes","text":"<p>Any <code>.md</code> file in <code>.context/</code> modified after the reference time:</p> <pre><code>### Context File Changes\n- `TASKS.md` - modified 2026-03-11 14:30\n- `DECISIONS.md` - modified 2026-03-11 09:15\n</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#code-changes","level":3,"title":"Code Changes","text":"<p>Git activity since the reference time:</p> <pre><code>### 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</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#integrating-into-session-start","level":2,"title":"Integrating into Session Start","text":"<p>Pair <code>ctx change</code> with the <code>/ctx-remember</code> ceremony for a complete session-start picture:</p> <pre><code># 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</code></pre> <p>Or script it:</p> <pre><code># .context/hooks/session-start.sh\nctx agent --budget 4000\necho \"---\"\nctx change\n</code></pre>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#team-workflows","level":2,"title":"Team Workflows","text":"<p>When multiple people share a <code>.context/</code> directory, <code>ctx change</code> shows who changed what:</p> <pre><code># After pulling from remote\ngit pull\nctx change --since 72h\n</code></pre> <p>This surfaces context file changes from teammates that you might otherwise miss in the commit log.</p>","path":["Recipes","Sessions","Reviewing Session Changes"],"tags":[]},{"location":"recipes/session-changes/#tips","level":2,"title":"Tips","text":"<ul> <li>No changes? If nothing shows up, the reference time might be wrong. Use <code>--since 48h</code> to widen the window.</li> <li>Works without git. Context file changes are detected by filesystem mtime, not git. Code changes require git.</li> <li>Hook integration. The <code>context-load-gate</code> hook writes the session marker that <code>ctx change</code> uses for auto-detection. If you're not using the <code>ctx</code> plugin, markers won't exist and it falls back to the event log or 24h window.</li> </ul>","path":["Recipes","Sessions","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":"<p>\"What does a full <code>ctx</code> session look like from start to finish?\"</p> <p>You have <code>ctx</code> installed and your <code>.context/</code> directory initialized, but the individual commands and skills feel disconnected.</p> <p>How do they fit together into a coherent workflow?</p> <p>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.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tldr","level":2,"title":"TL;DR","text":"<ol> <li>Load: <code>/ctx-remember</code>: load context, get structured readback.</li> <li>Orient: <code>/ctx-status</code>: check file health and token usage.</li> <li>Pick: <code>/ctx-next</code>: choose what to work on.</li> <li>Work: implement, test, iterate.</li> <li>Commit: <code>/ctx-commit</code>: commit and capture decisions/learnings.</li> <li>Reflect: <code>/ctx-reflect</code>: identify what to persist (at milestones)</li> <li>Wrap up: <code>/ctx-wrap-up</code>: end-of-session ceremony.</li> </ol> <p>Read on for the full walkthrough with examples.</p> <p>What Is a Readback?</p> <p>A readback is a structured summary where the agent plays back what it knows:</p> <ul> <li>last session,</li> <li>active tasks,</li> <li>recent decisions.</li> </ul> <p>This way, you can confirm it loaded the right context.</p> <p>The term \"readback\" comes from aviation, where pilots repeat instructions back to air traffic control to confirm they heard correctly.</p> <p>Same idea in <code>ctx</code>: The agent tells you what it \"thinks\" is going on, and you correct anything that's off before the work begins.</p> <ul> <li>Last session: topic, date, what was accomplished</li> <li>Active work: pending and in-progress tasks</li> <li>Recent context: 1-2 decisions or learnings that matter now</li> <li>Next step: suggestion or question about what to focus on</li> </ul>","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 <code>ctx status</code> CLI command Quick health check on context files <code>ctx agent</code> CLI command Load token-budgeted context packet <code>ctx journal source</code> CLI command List previous sessions <code>ctx journal source --show</code> CLI command Inspect a specific session in detail <code>/ctx-remember</code> Skill Recall project context with structured readback <code>/ctx-agent</code> Skill Load full context packet inside the assistant <code>/ctx-status</code> Skill Show context summary with commentary <code>/ctx-next</code> Skill Suggest what to work on with rationale <code>/ctx-commit</code> Skill Commit code and prompt for context capture <code>/ctx-reflect</code> Skill Structured reflection checkpoint <code>/ctx-history</code> 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":"<p>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:</p> <p>Load context > Orient > Pick a Task > Work > Commit > Reflect</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-1-load-context","level":3,"title":"Step 1: Load Context","text":"<p>Start every session by loading what you know. The fastest way is a single prompt:</p> <pre><code>Do you remember what we were working on?\n</code></pre> <p>This triggers the <code>/ctx-remember</code> skill. Behind the scenes, the assistant runs <code>ctx agent --budget 4000</code>, reads the files listed in the context packet (<code>TASKS.md</code>, <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>CONVENTIONS.md</code>), checks <code>ctx journal source --limit 3</code> for recent sessions, and then presents a structured readback.</p> <p>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.</p> <p>As an alternative, if you want raw data instead of a readback, run <code>ctx status</code> in your terminal or invoke <code>/ctx-status</code> for a summarized health check showing file counts, token usage, and recent activity.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-2-orient","level":3,"title":"Step 2: Orient","text":"<p>After loading context, verify you understand the current state.</p> <pre><code>/ctx-status\n</code></pre> <p>The status output shows which context files are populated, how many tokens they consume, and which files were recently modified. Look for:</p> <ul> <li>Empty core files: <code>TASKS.md</code> or <code>CONVENTIONS.md</code> with no content means the context is sparse</li> <li>High token count (over 30k): the context is bloated and might need <code>ctx compact</code></li> <li>No recent activity: files may be stale and need updating</li> </ul> <p>If the status looks healthy and the readback from Step 1 gave you enough context, skip ahead.</p> <p>If something seems off (stale tasks, missing decisions...), spend a minute reading the relevant file before proceeding.</p>","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":"<p>With context loaded, choose a task. You can pick one yourself, or ask the assistant to recommend:</p> <pre><code>/ctx-next\n</code></pre> <p>The skill reads <code>TASKS.md</code>, checks recent sessions to avoid re-suggesting completed work, and presents 1-3 ranked recommendations with rationale.</p> <p>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.</p> <p>If you already know what you want to work on, state it directly:</p> <pre><code>Let's work on the session enrichment feature.\n</code></pre>","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":"<p>This is the main body of the session: write code, fix bugs, refactor, research: whatever the task requires.</p> <p>During this phase, a few <code>ctx</code>-specific patterns help:</p> <p>Check decisions before choosing: when you face a design choice, check if a prior decision covers it.</p> <pre><code>Is this consistent with our decisions?\n</code></pre> <p>Constrain scope: keep the assistant focused on the task at hand.</p> <pre><code>Only change files in internal/cli/session/. Nothing else.\n</code></pre> <p>Use <code>/ctx-implement</code> for multistep plans: if the task has multiple steps, this skill executes them one at a time with build/test verification between each step.</p> <p>Context monitoring runs automatically: the <code>check-context-size</code> 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.</p>","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":"<p>When the work is ready, use the context-aware commit instead of raw <code>git commit</code>:</p> <pre><code>/ctx-commit\n</code></pre> <p>The Agent May Recommend Committing</p> <p>You do not always need to invoke <code>/ctx-commit</code> explicitly.</p> <p>After a commit, the agent may proactively offer to capture context:</p> <p>\"We just made a trade-off there. Want me to record it as a decision?\"</p> <p>This is normal: The Agent Playbook encourages persisting at milestones, and a commit is a natural milestone.</p> <p>As an alternative, you can ask the assistant \"can we commit this?\" and it will pick up the <code>/ctx-commit</code> skill for you.</p> <p>The skill runs a pre-commit build check (for Go projects, <code>go build</code>), reviews the staged changes, drafts a commit message focused on \"why\" rather than \"what\", and then commits.</p> <p>After the commit succeeds, it prompts you:</p> <pre><code>**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</code></pre> <p>If you made a decision, the skill records it with <code>ctx decision add</code>. If you learned something, it records it with <code>ctx learning add</code> including context, lesson, and application fields. This is the bridge between committing code and remembering why the code looks the way it does.</p> <p>If source code changed in areas that affect documentation, the skill also offers to check for doc drift.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#step-6-reflect","level":3,"title":"Step 6: Reflect","text":"<p>At natural breakpoints (after finishing a feature, resolving a complex bug, or before switching tasks) pause to reflect:</p> <pre><code>/ctx-reflect\n</code></pre> <p>Agents Reflect at Milestones</p> <p>Agents often reflect without explicit invocation.</p> <p>After completing a significant piece of work, the agent may naturally surface items worth persisting:</p> <p>\"We discovered that <code>$PPID</code> resolves differently inside hooks. Should I save that as a learning?\"</p> <p>This is the agent following the Work-Reflect-Persist cycle from the Agent Playbook.</p> <p>You do not need to say <code>/ctx-reflect</code> for this to happen; the agent treats milestones as reflection triggers on its own.</p> <p>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:</p> <pre><code>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</code></pre> <p>The skill asks before persisting anything. You choose what to keep.</p> <p>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.</p>","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":"<p>Before ending the session, run the wrap-up ceremony to capture outstanding learnings, decisions, conventions, and tasks:</p> <pre><code>/ctx-wrap-up\n</code></pre> <p>Ceremony Skills</p> <p><code>/ctx-remember</code> at session start and <code>/ctx-wrap-up</code> at session end are ceremony skills: Invoke them as explicit slash commands for completeness, not conversationally.</p> <p>See Session Ceremonies for details on why these two skills are the exception to the conversational rule.</p> <p>The skill gathers signal from <code>git diff</code>, recent commits, and the conversation, then proposes structured candidates for your approval. After you select which to keep, it persists them via <code>ctx add</code> and offers <code>/ctx-commit</code> if uncommitted changes remain.</p> <p>As its final step, <code>/ctx-wrap-up</code> writes a handover under <code>.context/handovers/<TS>-<slug>.md</code> — a former-agent-to-next-agent note with a past-tense summary and a future-tense \"first action for the next session\". The filename is timestamped so concurrent agent runs never overwrite each other. The next <code>/ctx-remember</code> reads this file as the authoritative recall surface; skipping <code>/ctx-wrap-up</code> means the next session has no handover to read and recall degrades to probabilistic reconstruction from canonical files plus journal.</p> <p>Session transcripts are automatically captured by Claude Code and can be browsed later with <code>ctx journal source</code> and <code>ctx journal source --show</code>.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#conversational-session-flow","level":2,"title":"Conversational Session Flow","text":"<p>The steps above describe the mechanics. In practice, a session with a <code>ctx</code>-aware agent feels more like a conversation than a command sequence.</p> <p>The agent knows the lifecycle and moves through it naturally, often without explicit invocation. Here is a realistic example:</p> <p>You: Do you remember what we were working on?</p> <p>Agent (loads context silently, presents structured readback):</p> <pre><code>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</code></pre> <p>You: Let's work on the Redis caching backend.</p> <p>Agent (picks up the task, begins implementation):</p> <pre><code>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</code></pre> <p>(The agent works... writes code, runs tests, iterates.)</p> <p>Agent (after implementing the connection pool and choosing a retry strategy):</p> <pre><code>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</code></pre> <p>You: Yes, go ahead.</p> <p>Agent:</p> <pre><code>Done. Added to DECISIONS.md: \"Exponential backoff with jitter for Redis\nreconnection, to avoid thundering herd on pool recovery.\"\n</code></pre> <p>(More work happens... the agent implements the cache read/write paths.)</p> <p>You: What else did we learn during this session?</p> <p>Agent:</p> <pre><code>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</code></pre> <p>You: Yes. And let's wrap up.</p> <p>Agent (reflects and persists... all in one flow):</p> <pre><code>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</code></pre> <p>Notice What Happened</p> <p>In the above workflow, the user never typed <code>/ctx-reflect</code> or <code>ctx learning add</code>.</p> <p>The agent moved through Load, Orient, Pick, Work, Commit, and Reflect driven by natural conversation.</p> <p>\"Let's wrap up\" was enough to trigger the full reflect-and-persist flow.</p> <p>The agent surfaced persist-worthy items at milestones: after a design choice, after discovering a gotcha: without waiting to be asked.</p> <p>This is the intended experience. </p> <p>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.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>Quick-reference checklist for a complete session:</p> <ul> <li> Load: <code>/ctx-remember</code>: load context and confirm readback</li> <li> Orient: <code>/ctx-status</code>: check file health and token usage</li> <li> Pick: <code>/ctx-next</code>: choose what to work on</li> <li> Work: implement, test, iterate (scope with \"only change X\")</li> <li> Commit: <code>/ctx-commit</code>: commit and capture decisions/learnings</li> <li> Reflect: <code>/ctx-reflect</code>: identify what to persist (at milestones)</li> <li> Wrap up: <code>/ctx-wrap-up</code>: end-of-session ceremony</li> </ul> <p>Conversational equivalents: you can drive the same lifecycle with plain language:</p> Step Slash command Natural language Load <code>/ctx-remember</code> \"Do you remember?\" / \"What were we working on?\" Orient <code>/ctx-status</code> \"How's our context looking?\" Pick <code>/ctx-next</code> \"What should we work on?\" / \"Let's do the caching task\" Work (none) \"Only change files in internal/cache/\" Commit <code>/ctx-commit</code> \"Commit this\" / \"Ship it\" Reflect <code>/ctx-reflect</code> \"What did we learn?\" / (agent offers at milestones) Wrap up <code>/ctx-wrap-up</code> (use the slash command for completeness) <p>The agent understands both columns.</p> <p>In practice, most sessions use a mix:</p> <ul> <li>Explicit Commands when you want precision;</li> <li>Natural Language when you want flow and agentic autonomy.</li> </ul> <p>The agent will also initiate steps on its own (particularly \"Reflect\") when it recognizes a milestone.</p> <p>Short sessions (quick bugfix) might only use: Load, Work, Commit.</p> <p>Long sessions should Reflect after each major milestone and persist learnings and decisions before ending.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#tips","level":2,"title":"Tips","text":"<p>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.</p> <p>Browse previous sessions by topic. If you need context from a prior session, <code>ctx journal source --show auth</code> will match by keyword. You do not need to remember the exact date or slug.</p> <p>Reflection is optional but valuable. You can skip <code>/ctx-reflect</code> 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.</p> <p>Let the hook handle context loading. The <code>PreToolUse</code> hook runs <code>ctx agent</code> automatically with a cooldown, so context loads on first tool use without you asking. The <code>/ctx-remember</code> prompt at session start is for your benefit (to get a readback), not because the assistant needs it.</p> <p>The agent is a proactive partner, not a passive tool. A <code>ctx</code>-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.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#next-up","level":2,"title":"Next Up","text":"<p>Session Ceremonies →: The two bookend rituals for every session: <code>/ctx-remember</code> at the start, <code>/ctx-wrap-up</code> at the end.</p>","path":["Recipes","Sessions","The Complete Session"],"tags":[]},{"location":"recipes/session-lifecycle/#see-also","level":2,"title":"See Also","text":"<ul> <li>Session Ceremonies: why <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> are explicit slash commands, not conversational</li> <li>CLI Reference: full documentation for all <code>ctx</code> commands</li> <li>Prompting Guide: effective prompts for ctx-enabled projects</li> <li>Tracking Work Across Sessions: deep dive on task management</li> <li>Persisting Decisions, Learnings, and Conventions: deep dive on knowledge capture</li> <li>Detecting and Fixing Drift: keeping context files accurate</li> <li>Pausing Context Hooks: shortcut the full lifecycle for quick tasks that don't need ceremony overhead</li> </ul>","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":"<p>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.</p>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tldr","level":2,"title":"TL;DR","text":"Command What it does <code>ctx hook pause</code> or <code>/ctx-pause</code> Silence all nudge hooks for this session <code>ctx hook resume</code> or <code>/ctx-resume</code> Restore normal hook behavior <p>Pause is session-scoped: It only affects the current session. Other sessions (same project, different terminal) are unaffected.</p>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-gets-paused","level":2,"title":"What Gets Paused","text":"<p>All nudge and reminder hooks go silent:</p> <ul> <li>Context size checkpoints</li> <li>Ceremony adoption nudges</li> <li>Persistence reminders</li> <li>Journal maintenance reminders</li> <li>Knowledge growth nudges</li> <li>Map staleness nudges</li> <li>Version update nudges</li> <li>Resource pressure warnings</li> <li>QA reminders</li> <li>Post-commit nudges</li> <li>Specs nudges</li> <li>Backup age warnings</li> <li>Context load gate</li> <li>Pending reminders relay</li> </ul>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#what-still-fires","level":2,"title":"What Still Fires","text":"<p>Security hooks always run, even when paused:</p> <ul> <li><code>block-non-path-ctx</code>: prevents <code>./ctx</code> invocations</li> <li><code>block-dangerous-commands</code>: blocks <code>sudo</code>, force push, etc.</li> </ul>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#workflow","level":2,"title":"Workflow","text":"<pre><code># 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</code></pre>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#graduated-reminder","level":2,"title":"Graduated Reminder","text":"<p>Paused hooks aren't completely invisible. A minimal indicator appears so you always know the state:</p> Paused turns What you see 1-5 <code>ctx:paused</code> 6+ <code>ctx:paused (N turns): resume with /ctx-resume</code> <p>This prevents the \"forgot I paused\" problem during long sessions.</p>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#tips","level":2,"title":"Tips","text":"<ul> <li> <p>Resume before wrapping up. If your quick task turns into real work, resume hooks before running <code>/ctx-wrap-up</code>. The wrap-up ceremony needs active hooks to capture learnings properly.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> <li> <p>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.</p> </li> </ul>","path":["Recipes","Sessions","Pausing Context Hooks"],"tags":[]},{"location":"recipes/session-pause/#see-also","level":2,"title":"See Also","text":"<p>See also: Session Ceremonies: the bookend rituals that pause lets you skip when they aren't needed.</p> <p>See also: Customizing Hook Messages: if you want to change what hooks say rather than silencing them entirely.</p> <p>See also: The Complete Session: the full session workflow that pause shortcuts for quick tasks.</p>","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":"<p>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.</p> <p>How do you leave a message that your next session opens with?</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx remind \"refactor the swagger definitions\"\nctx remind list\nctx remind dismiss 1 # or batch: ctx remind dismiss 1 3-5\n</code></pre> <p>Reminders surface automatically at session start: VERBATIM, every session, until you dismiss them.</p>","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 <code>ctx remind</code> CLI command Add a reminder (default action) <code>ctx remind list</code> CLI command Show all pending reminders <code>ctx remind dismiss</code> CLI command Remove a reminder by ID (or <code>--all</code>) <code>/ctx-remind</code> 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":"<p>Tell your agent what to remember, or run it directly:</p> <pre><code>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</code></pre> <p>Or from the terminal:</p> <pre><code>ctx remind \"refactor the swagger definitions\"\n</code></pre>","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":"<p>If the reminder shouldn't fire until a specific date:</p> <pre><code>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</code></pre> <p>The reminder stays silent until that date, then fires every session.</p> <p>The agent converts natural language dates (\"tomorrow\", \"next week\", \"after the release on Friday\") to <code>YYYY-MM-DD</code>. If it's ambiguous, it asks.</p>","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":"<p>Next session, the reminder appears automatically before anything else:</p> <pre><code>┌─ Reminders ──────────────────────────────────────\n│ [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n</code></pre> <p>No action needed: The <code>check-reminders</code> hook fires on <code>UserPromptSubmit</code> and the agent relays the box verbatim.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#step-4-dismiss-when-done","level":3,"title":"Step 4: Dismiss When Done","text":"<p>After you've acted on a reminder (or decided to skip it):</p> <pre><code>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</code></pre> <p>Or clear everything:</p> <pre><code>ctx remind dismiss --all\n</code></pre>","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":"<pre><code>ctx remind list\n</code></pre> <pre><code> [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</code></pre> <p>Date-gated reminders that haven't reached their date show <code>(not yet due)</code>.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#using-ctx-remind-in-a-session","level":2,"title":"Using <code>/ctx-remind</code> in a Session","text":"<p>Invoke the <code>/ctx-remind</code> skill, then describe what you want:</p> <pre><code>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</code></pre> You say (after <code>/ctx-remind</code>) What the agent does \"remind me to update the API docs\" <code>ctx remind \"update the API docs\"</code> \"remind me next week to check staging\" <code>ctx remind \"check staging\" --after 2026-03-02</code> \"what reminders do I have?\" <code>ctx remind list</code> \"dismiss reminder 3\" <code>ctx remind dismiss 3</code> \"dismiss reminders 3, 5 through 7\" <code>ctx remind dismiss 3 5-7</code> \"clear all reminders\" <code>ctx remind dismiss --all</code>","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 <code>ctx remind</code> Jot down a quick value or sensitive token <code>ctx pad</code> Track work with status and completion <code>TASKS.md</code> Record a decision or lesson for all sessions Context files <p>Decision guide:</p> <ul> <li>If it should announce itself at session start → <code>ctx remind</code></li> <li>If it's a quiet note you'll check manually → <code>ctx pad</code></li> <li>If it's a work item you'll mark done → <code>TASKS.md</code></li> </ul> <p>Reminders Are Sticky Notes, Not Tasks</p> <p>A reminder has no status, no priority, no lifecycle. It's a message to \"future you\" that fires until dismissed. </p> <p>If you need tracking, use a task in <code>TASKS.md</code>.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#tips","level":2,"title":"Tips","text":"<ul> <li>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.</li> <li>Date gating is session-scoped, not clock-scoped: <code>--after 2026-02-25</code> means \"don't show until sessions on or after Feb 25.\" It does not mean \"alarm at midnight on Feb 25.\"</li> <li>The agent handles date parsing: Say \"next week\" or \"after Friday\": The agent converts it to <code>YYYY-MM-DD</code>. The CLI only accepts the explicit date format.</li> <li>Reminders are committed to git: They travel with the repo. If you switch machines, your reminders follow.</li> <li>IDs never reuse: After dismissing reminder 3, the next reminder gets ID 4 (or higher). No confusion from recycled numbers.</li> </ul>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#next-up","level":2,"title":"Next Up","text":"<p>Using the Scratchpad →: For quiet notes and sensitive values that don't need session-start announcements.</p>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/session-reminders/#see-also","level":2,"title":"See Also","text":"<ul> <li>CLI Reference: <code>ctx</code> remind: full command syntax and flags</li> <li>The Complete Session: how reminders fit into the session lifecycle</li> <li>Managing Tasks: for work items that need status tracking</li> </ul>","path":["Recipes","Sessions","Session Reminders"],"tags":[]},{"location":"recipes/spec-driven-development/","level":1,"title":"Spec-Driven Development","text":"","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#the-problem","level":2,"title":"The Problem","text":"<p>A feature big enough to span several milestones doesn't fail at the keyboard. It fails at the seams: the bet gets re-argued halfway through implementation, a \"plan\" for milestone three turns out to be fiction by the time you reach it, a decision the code silently assumed was never written down, and two different files each claim to be the authoritative list of what's done.</p> <p>The five skills that make up the design-to-implementation pipeline each solve one seam. But the pipeline only holds together if you understand which skill owns which decision, and at what altitude. Read the skill texts in isolation and the chain looks like five ways to write a Markdown file. Run them without the mental model and you end up reverse-engineering the whole thing from error messages.</p> <p>This recipe is that mental model, from the operator's seat. It walks one invented-but-realistic feature — a weekly context digest — through all five stages, and calls out the five load-bearing rules that aren't obvious from any single skill.</p> <p>Relationship to Design Before Coding</p> <p>Design Before Coding is the gentle on-ramp: brainstorm → spec → task-out → implement, four skills, one small feature. This recipe is the full chain including the debated-brief step (<code>/ctx-plan</code>), aimed at multi-milestone work where the seams actually bite. If you only ever ship single-session features, the on-ramp is enough.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-brainstorm # shape the vague idea\n/ctx-plan # debate the bet → a brief\n/ctx-spec --brief .context/briefs/<TS>-<slug>.md # commit the whole spec\n/ctx-task-out --spec specs/<feature>.md --milestone m0 # decompose ONE milestone\n/ctx-implement specs/plans/m0.md # execute, verify, checkpoint\n</code></pre> <p>Five skills, one direction. The canonical chain, with the altitude each step works at:</p> <pre><code>/ctx-brainstorm → /ctx-plan → /ctx-spec → /ctx-task-out → /ctx-implement\n (vague) (contested) (committed) (decomposed) (execution)\n</code></pre> <p><code>/ctx-plan</code> is not optional decoration. It is where the bet is attacked and written down as a debated brief, before the spec commits to it. Skip it and the spec inherits an unexamined bet; the argument you avoided resurfaces mid-implementation, where it is most expensive.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>/ctx-brainstorm</code> Skill Turn a vague idea into a validated design (conversation only) <code>/ctx-plan</code> Skill Attack the bet; write a debated brief to <code>.context/briefs/</code> <code>/ctx-spec</code> Skill Absorb the brief into a committed spec covering all milestones <code>/ctx-task-out</code> Skill Decompose one milestone into <code>specs/plans/<milestone>.md</code> <code>/ctx-implement</code> Skill Execute the plan step-by-step, updating the execution ledger <code>/ctx-decision-add</code> Skill Record a blocking decision the milestone forces into the open","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#the-running-example","level":2,"title":"The Running Example","text":"<p>Every stage below moves the same feature forward. Follow it end to end rather than reading the stages as isolated commands.</p> <p>Weekly Context Digest (<code>ctx digest</code>). Over dozens of sessions, <code>DECISIONS.md</code> and <code>LEARNINGS.md</code> pile up and nobody re-reads them. A periodic rollup resurfaces what changed this week so it doesn't rot.</p> <p>The feature has four milestones. Only the first is planned in detail right now; the rest exist in the spec as boundaries, not task lists.</p> Milestone Scope m0 Render: <code>ctx digest --since <date></code> prints a Markdown rollup to stdout m1 Schedule: surface the digest at session start, at most weekly m2 Deliver: push the digest through the <code>ctx hook notify</code> webhook m3 (deferred) Roll up across projects via <code>ctx hub</code>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-1-debate-the-bet-ctx-plan","level":2,"title":"Stage 1 — Debate the bet (<code>/ctx-plan</code>)","text":"<p>You have a rough shape (<code>/ctx-brainstorm</code> got you here) but you have not committed. <code>/ctx-plan</code> is a skeptical collaborator: it attacks the bet one question at a time — scope, failure modes, rejected alternatives, sequencing, reversibility — and stops when you can state the bet, what you rejected, the top failure modes, the cheapest validation, and the unwind cost, without help.</p> <pre><code>You: /ctx-plan\n I want a weekly digest that summarizes what changed in the\n context files.\n\nAgent: One question at a time. Generated from the structured files, or\n summarized by an LLM from free text?\n\nYou: ...generated. An LLM summary would drift and I couldn't cite it.\n\nAgent: Then the cheapest thing that proves the bet is m0 render-only —\n no schedule, no delivery. What would tell you the digest is\n worth building delivery for?\n\nYou: Whether I actually read it. Ship m0, live with it a week, then\n decide on m1.\n</code></pre> <p>The deliverable is not a task list. It is a debated brief at <code>.context/briefs/<TS>-context-digest.md</code>: the bet (render from structured files, not LLM summary), the rejections (LLM summary; a separate digest datastore), the failure modes (empty window, giant window, digest nobody reads), the validation route (ship m0, measure readership), and the unwind cost.</p> <p>The bet is debated once, here, for the whole feature. Not once per milestone. That is the altitude rule — see below.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-2-commit-the-spec-ctx-spec-brief","level":2,"title":"Stage 2 — Commit the spec (<code>/ctx-spec --brief</code>)","text":"<p><code>/ctx-spec --brief <path></code> treats the brief as authoritative and skips the interactive Q&A. It lifts the brief into the spec template verbatim where the brief speaks, and writes <code>TBD</code> where the brief is silent — it does not invent. The result is <code>specs/context-digest.md</code>, covering all four milestones, plus the open questions the bet left unresolved:</p> <pre><code>Open Questions\n TBD-1 Default digest window — 7 days, or \"since last run\"?\n TBD-2 Delivery transport — webhook only, or email too?\n TBD-3 Cross-project identity/dedup for the hub rollup\n</code></pre> <p>Note what the spec is not: it is not a task breakdown, and it does not resolve the TBDs. It commits the what/why at spec altitude and hands the TBDs downstream, each to be forced open at the milestone that actually embeds it. A small, single-session spec would stop here and go straight to <code>/ctx-implement</code>. This one spans milestones, so it goes to <code>/ctx-task-out</code>.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-3-task-out-one-milestone-ctx-task-out","level":2,"title":"Stage 3 — Task out one milestone (<code>/ctx-task-out</code>)","text":"<p>This is the step the other four skills leave unowned: <code>/ctx-plan</code> disclaims implementation planning, <code>/ctx-spec</code> stops at spec altitude, and <code>/ctx-implement</code> opens with \"use when you have a plan document.\" <code>/ctx-task-out</code> produces that plan — for one milestone at a time.</p> <pre><code>You: /ctx-task-out --spec specs/context-digest.md --milestone m0\n\nAgent: Blocking-TBD gate for m0:\n TBD-1 (default window) — DEFERRABLE. m0 takes an explicit\n --since; no task assumes a default. Blocking at m1.\n TBD-2 (transport) — DEFERRABLE. m0 prints to stdout.\n Blocking at m2.\n TBD-3 (hub identity) — DEFERRABLE. Blocking at m3.\n No blocker for m0. Decomposing.\n\n Wrote specs/plans/m0.md: data model, CLI contract, test matrix,\n 10 tasks (T01–T10) with falsifiable acceptance criteria and an\n `st` column. TASKS.md gained one epic anchor:\n \"Digest m0: render — Plan: specs/plans/m0.md (T01–T10)\".\n</code></pre> <p>Two gates run here, and both are refusals, not warnings:</p> <ul> <li>Blocking-TBD gate. Every open question is classified blocking or deferrable for this milestone. A TBD is blocking if any task in the milestone would embed an assumption about its answer. The skill refuses to decompose past a blocker — it lists them, names who can resolve them, and stops. Resolution lands as a spec edit or a <code>DECISIONS.md</code> entry first; the plan only points at that record. A decision that exists nowhere but the plan is minting, and the gate exists to stop it.</li> <li>Rolling-wave gate. If a prior milestone's plan exists and its definition of done (DoD) is not checked off, the skill refuses to decompose the next one. Tasking a distant milestone produces fiction: the current milestone's measurements are allowed to reshape everything downstream.</li> </ul>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-4-implement-the-milestone-ctx-implement","level":2,"title":"Stage 4 — Implement the milestone (<code>/ctx-implement</code>)","text":"<p><code>/ctx-implement specs/plans/m0.md</code> breaks the plan into atomic steps, verifies each (build, test, or the task's own acceptance criterion, run verbatim), and checkpoints every 3–5 steps. Its bookkeeping is what keeps the two surfaces honest:</p> <ul> <li>It flips a task's <code>st</code> cell to <code>[x]</code> only when the acceptance criterion demonstrably passed — the command ran, the test is green, the behavior was observed. <code>st</code> never moves backward silently.</li> <li>When every id in an epic's range is <code>[x]</code> (or <code>[o]</code>, obsoleted by amendment), it marks that TASKS.md epic <code>[x]</code>. Sync is one-way, plan → TASKS.md.</li> <li>It leaves the DoD boxes alone. DoD is confirmed by measurement or by you — never derived from the tasks that \"cover\" it being done.</li> </ul> <p>For the digest, m0's DoD is not \"T01–T10 are all <code>[x]</code>.\" It is: you ran <code>ctx digest --since <date></code> against a real project and confirmed the output is readable and correct. You check that box after reading a real digest — because the whole bet was \"is this worth reading?\" and only measurement answers it.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#stage-5-roll-the-wave-the-next-milestone","level":2,"title":"Stage 5 — Roll the wave (the next milestone)","text":"<p>A week later you have read a few digests and decided m1 is worth building. Now — and only now — you check m0's DoD box. That single act opens the rolling-wave gate for m1:</p> <pre><code>You: /ctx-task-out --spec specs/context-digest.md --milestone m1\n\nAgent: Rolling-wave gate: m0 DoD is checked. Proceeding.\n Blocking-TBD gate for m1:\n TBD-1 (default window) — NOW BLOCKING. m1 schedules, so a task\n must assume a default window. Resolve before I decompose.\n Stopping. Resolve TBD-1 (spec edit or DECISIONS.md), then re-run.\n\nYou: /ctx-decision-add \"Digest default window is 'since last run',\n falling back to 7 days on first run\"\n\nAgent: Recorded D-014. Re-run /ctx-task-out --milestone m1 when ready.\n</code></pre> <p>The debate that would have been a per-milestone re-litigation of the bet is instead a single, scoped decision — exactly the one m1 embeds — forced into <code>DECISIONS.md</code> before any task can silently assume an answer. That is the blocking-TBD gate doing the job per-milestone debates used to do, without reopening the bet.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#the-rules-the-diagram-doesnt-show","level":2,"title":"The Rules the Diagram Doesn't Show","text":"<p>The arrows tell you the order. These five rules tell you why the order holds — and they are what a newcomer has to reverse-engineer.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#1-altitude-the-bet-is-debated-once","level":3,"title":"1. Altitude: the bet is debated once","text":"<p>The brief is per-bet, never per-milestone. <code>/ctx-plan</code> debates the bet one time; <code>/ctx-spec</code> commits it across every milestone; <code>/ctx-task-out</code> decomposes — it does not redesign the bet. If decomposition makes you want to re-argue scope or behavior, that is a signal to route back up to <code>/ctx-plan</code>, not to quietly change course in the plan. Milestones are altitudes of execution, not fresh betting opportunities.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#2-plans-are-just-in-time-behind-the-rolling-wave-gate","level":3,"title":"2. Plans are just-in-time, behind the rolling-wave gate","text":"<p>You plan the milestone you are about to build, and no further. A plan for a milestone three steps out is written against measurements you have not taken yet — it is fiction with a task table. The rolling-wave gate enforces this mechanically: milestone N+1 cannot be tasked out while milestone N's DoD is unmet. (You can override explicitly; the override is logged in the plan's Amendments section, so the fiction is at least on the record.)</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#3-blocking-tbd-gates-replace-per-milestone-debates","level":3,"title":"3. Blocking-TBD gates replace per-milestone debates","text":"<p>Because the bet is debated once, milestones don't get their own debates. What they get is the blocking-TBD gate: each <code>/ctx-task-out</code> run forces open exactly the decisions that milestone's tasks would otherwise embed as silent assumptions — no more, no fewer. A deferrable TBD doesn't vanish; it is carried into the plan (Out of scope or Risks), annotated with the milestone at which it graduates to blocking. This is how a big, half-decided spec becomes buildable without a design committee at every step.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#4-two-surfaces-one-truth","level":3,"title":"4. Two surfaces, one truth","text":"<p>There are two places milestone progress appears, and only one is authoritative:</p> <ul> <li>The plan (<code>specs/plans/<milestone>.md</code>) is the execution ledger. Its task table has an <code>st</code> column — <code>[ ]</code> pending, <code>[x]</code> done, <code>[o]</code> obsoleted — and its Scope & DoD section carries the DoD checkboxes. This is the single source of truth for what's done.</li> <li>TASKS.md epics are one-way projections. Each epic anchor carries a disjoint task-id range (<code>Plan: specs/plans/m0.md (T01–T10)</code>); the ranges partition the plan's ids with none double-counted. An epic is checked <code>[x]</code> only when its whole range is <code>[x]</code>/<code>[o]</code> in the plan. Sync flows plan → TASKS.md, never back.</li> </ul> <p>And the load-bearing exception: DoD is confirmed by measurement or by you, never derived from task completion. All ten tasks green does not check the DoD box. The rolling-wave gate reads only the DoD box — so if you let task completion auto-derive it, you have quietly disabled the gate that stops you from planning fiction.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#5-when-a-new-brief-is-legitimate","level":3,"title":"5. When a new brief is legitimate","text":"<p>Going back to <code>/ctx-plan</code> mid-feature is not failure — but only for the right reasons. A new brief is warranted when:</p> <ul> <li>A deferred bet returns. m3 (the hub rollup) was parked as Out of scope. Months later you want it. That is a new bet — deferred machinery coming back — so it earns a fresh <code>/ctx-plan</code> pass and its own brief. It is not an amendment to m0.</li> <li>Evidence falsifies the committed bet. If mid-m2 the measurements show webhook delivery is the wrong transport entirely, that disagreement is with the spec, and it routes up through <code>/ctx-plan</code>.</li> </ul> <p>What is never legitimate is relitigating the bet from below — at the implement seat, by weakening a task's acceptance criterion until it passes, or by inventing a decision in the plan that the spec never made. Amendments cover implementation reality (a task obsoleted, a new task appended, a measurement gate that fired); the bet is contested only at plan altitude, in the open.</p>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#tips","level":2,"title":"Tips","text":"<ul> <li>Don't skip <code>/ctx-plan</code> to \"save time.\" The argument you skip doesn't disappear; it moves to implementation, where it costs the most. Ten minutes of adversarial interview is cheap insurance.</li> <li>Let the DoD box be earned. The temptation to tick it when the tasks are all green is exactly the failure the rolling-wave gate guards against. Leave it for measurement or your own confirmation.</li> <li>A blocking TBD is a feature, not a blocker. When <code>/ctx-task-out</code> refuses, it just told you the one decision this milestone can't fake. Record it (<code>/ctx-decision-add</code>) and re-run — that is the workflow working.</li> <li>Never edit an acceptance criterion in place once its task has started. Weakening the test until it passes is the exact failure the amendment rule exists to prevent. A criterion change is an <code>/ctx-task-out</code> amendment run, logged with date · what · why.</li> <li>One milestone in flight at a time. If you find yourself wanting to task out two milestones before finishing the first, that is the rolling-wave gate telling you the first isn't actually done.</li> </ul>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/spec-driven-development/#see-also","level":2,"title":"See Also","text":"<ul> <li>Design Before Coding: the four-skill on-ramp; start there if the feature fits one session.</li> <li>Scrutinizing a Plan: a deeper look at the <code>/ctx-plan</code> adversarial interview and the debated brief.</li> <li>Tracking Work Across Sessions: the TASKS.md epic anchors the plan projects into.</li> <li>Persisting Decisions, Learnings, and Conventions: where a blocking TBD gets recorded when the gate forces it open.</li> <li>Skills Reference: /ctx-plan: the debated-brief contract.</li> <li>Skills Reference: /ctx-task-out: blocking-TBD and rolling-wave gates, the execution ledger.</li> <li>Skills Reference: /ctx-implement: ledger duties and step verification.</li> </ul>","path":["Recipes","Knowledge and Tasks","Spec-Driven Development"],"tags":[]},{"location":"recipes/state-maintenance/","level":1,"title":"State Directory Maintenance","text":"","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-problem","level":2,"title":"The Problem","text":"<p>Every session creates tombstone files in <code>.context/state/</code> - 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.</p> <p>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.</p>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#commands-used","level":2,"title":"Commands Used","text":"Tool Type Purpose <code>ctx prune</code> Command Remove old per-session state files <code>ctx status</code> Command Quick health overview including state dir","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#understanding-state-files","level":2,"title":"Understanding State Files","text":"<p>State files fall into two categories:</p> <p>Session-scoped (contain a UUID in the filename): Created per-session to suppress repeat nudges. Safe to prune once the session ends. Examples:</p> <pre><code>context-check-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\nheartbeat-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\npersistence-nudge-11e94c1d-1639-4c04-bf77-63dcf1f50ec7\n</code></pre> <p>Global (no UUID): Persist across sessions. <code>ctx prune</code> preserves these automatically. Some are legitimate state (<code>events.jsonl</code>, <code>memory-import.json</code>); others may be stale tombstones that need manual review.</p>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#the-workflow","level":2,"title":"The Workflow","text":"","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-1-preview","level":3,"title":"Step 1: Preview","text":"<p>Always dry-run first to see what would be removed:</p> <pre><code>ctx prune --dry-run\n</code></pre> <p>The output shows each file, its age, and a summary:</p> <pre><code> 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</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-2-prune","level":3,"title":"Step 2: Prune","text":"<p>Choose an age threshold. The default is 7 days:</p> <pre><code>ctx prune # older than 7 days\nctx prune --days 3 # older than 3 days\nctx prune --days 1 # older than 1 day (aggressive)\n</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-3-review-global-files","level":3,"title":"Step 3: Review Global Files","text":"<p>After pruning, check what <code>prune</code> preserved:</p> <pre><code>ls .context/state/ | grep -v '[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}'\n</code></pre> <p>Legitimate global files (keep):</p> <ul> <li><code>events.jsonl</code> - event log</li> <li><code>memory-import.json</code> - import tracking state</li> </ul> <p>Stale global tombstones (safe to delete):</p> <ul> <li>Files like <code>backup-reminded</code>, <code>ceremony-reminded</code>, <code>version-checked</code> with no session UUID are one-shot markers. If they are from a previous session, they are stale and can be removed manually.</li> </ul> <pre><code>rm .context/state/backup-reminded .context/state/ceremony-reminded\n</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#step-4-verify","level":3,"title":"Step 4: Verify","text":"<pre><code>ls .context/state/ | wc -l # should be manageable\n</code></pre>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#when-to-prune","level":2,"title":"When to Prune","text":"<ul> <li>Weekly: <code>ctx prune</code> with default 7-day threshold</li> <li>After heavy parallel work: Multiple concurrent sessions create many tombstones. Prune with <code>--days 1</code> afterward.</li> <li>When state directory exceeds ~100 files: A sign that pruning hasn't run recently</li> </ul>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#tips","level":2,"title":"Tips","text":"<p>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.</p> <p>No context files are stored in state: The state directory contains only tombstones, counters, and diagnostic data. Nothing in <code>.context/state/</code> affects your decisions, learnings, tasks, or conventions.</p> <p>Test artifacts sneak in: Files like <code>context-check-statstest</code> or <code>heartbeat-unknown</code> are artifacts from development or testing. They lack UUIDs so <code>prune</code> preserves them. Delete manually.</p>","path":["Recipes","Maintenance","State Directory Maintenance"],"tags":[]},{"location":"recipes/state-maintenance/#see-also","level":2,"title":"See Also","text":"<ul> <li>Detecting and Fixing Drift: broader context maintenance including drift detection and archival</li> <li>Troubleshooting: diagnostic workflow using <code>ctx doctor</code> and event logs</li> <li>CLI Reference: system: full flag documentation for <code>ctx prune</code> and related commands</li> </ul>","path":["Recipes","Maintenance","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":"<p>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.</p> <p>Before You Start</p> <p>If you're unsure whether a rule belongs in <code>steering/</code>, <code>DECISIONS.md</code>, or <code>CONVENTIONS.md</code>, read the \"Steering vs decisions vs conventions\" admonition on the <code>ctx steering</code> 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.</p>","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":"<p><code>ctx init</code> scaffolds four foundation steering files for you the first time you initialize a project:</p> File Purpose <code>.context/steering/product.md</code> Product context, goals, target users <code>.context/steering/tech.md</code> Tech stack, constraints, key dependencies <code>.context/steering/structure.md</code> Directory layout, naming conventions <code>.context/steering/workflow.md</code> Branch strategy, commit rules, pre-commit <p>Each file opens with an inline HTML comment that explains the three inclusion modes, what <code>priority</code> means, and the <code>tools</code> scope. The comment is invisible in rendered Markdown but visible when you edit the file. Delete it once the file is yours.</p> <p>All four default to <code>inclusion: always</code> and <code>priority: 10</code>, 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 <code>ctx</code> setup.</p> <p>What to fill in, by file:</p> <p><code>product.md</code>: The elevator pitch plus hard scope:</p> <ul> <li>One-sentence product description.</li> <li>Primary users and their top job-to-be-done.</li> <li>Two or three \"this is explicitly out of scope\" items so the AI doesn't wander.</li> </ul> <p><code>tech.md</code>: Technology and constraints:</p> <ul> <li>Languages and versions (<code>Go 1.22</code>, <code>Node 20</code>, etc.).</li> <li>Frameworks and key libraries.</li> <li>Runtime and deployment target.</li> <li>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.</li> </ul> <p><code>structure.md</code>: Layout and naming:</p> <ul> <li>Top-level directories and their purpose.</li> <li>Where new files should go (and where they should NOT).</li> <li>Naming conventions for packages, files, types.</li> </ul> <p><code>workflow.md</code>: Process rules:</p> <ul> <li>Branch strategy (main-only, trunk-based, feature branches).</li> <li>Commit message format, signed-off-by requirement.</li> <li>Pre-commit and pre-push checks.</li> <li>Review expectations.</li> </ul> <p>After editing, the next AI tool call in Claude Code will pick up the new rules automatically via the plugin's <code>PreToolUse</code> hook, with no sync step and no restart. Other tools (Cursor, Cline, Kiro) need <code>ctx steering sync</code> to export into their native format.</p> <p>Prefer a Bare <code>.context/steering/</code> Directory?</p> <p>Re-run <code>ctx init --no-steering-init</code> and delete the scaffolded files. <code>ctx init</code> leaves existing files alone, so the flag is only needed if you want to opt out of the initial scaffold.</p> <p>The rest of this recipe walks through creating an additional, scenario-specific steering file beyond the four foundation defaults.</p>","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#scenario","level":2,"title":"Scenario","text":"<p>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.</p> <p>Claude Code Users: Pick <code>always</code>, Not <code>auto</code></p> <p>This walkthrough uses <code>inclusion: auto</code> 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 <code>description</code> keyword match themselves).</p> <p>On Claude Code, <code>auto</code> does not fire through the plugin's <code>PreToolUse</code> hook. The hook passes an empty prompt to <code>ctx agent</code>, so only <code>always</code> files match. Claude can still reach an <code>auto</code> file by calling the <code>ctx_steering_get</code> MCP tool, but that requires Claude to decide to call it; there's no automatic injection.</p> <p>If Claude Code is your tool, set <code>inclusion: always</code> in Step 2 instead of <code>auto</code>. 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.</p> <p>See the <code>ctx steering</code> reference \"Prefer <code>inclusion: always</code> for Claude Code\" section for the full trade-off.</p>","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":"<pre><code>ctx steering add api-validation\n</code></pre> <p>That creates <code>.context/steering/api-validation.md</code> with default frontmatter:</p> <pre><code>---\nname: api-validation\ndescription:\ninclusion: manual\ntools: []\npriority: 50\n---\n</code></pre> <p>The defaults are deliberately conservative: <code>inclusion: manual</code> means the file won't be applied until you opt in, which keeps the rules out of the prompt until you've reviewed them.</p>","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":"<p>Open the file and write the rule body plus a focused description. The description is what <code>inclusion: auto</code> matches against later.</p> <pre><code>---\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</code></pre> <p>Notes on the choices:</p> <ul> <li><code>inclusion: auto</code>: this rule should fire automatically on HTTP-handler-shaped prompts, not always.</li> <li><code>priority: 20</code>: lower than the default, so this rule appears near the top of the prompt alongside other high-priority rules.</li> <li>Description is keyword-rich (\"HTTP handler input validation and request parsing\"); the <code>auto</code> matcher scores prompts against these words.</li> </ul>","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":"<p>Before committing the file, validate your description catches the prompts you care about:</p> <pre><code>ctx steering preview \"add an endpoint for updating user email\"\n</code></pre> <p>Expected output:</p> <pre><code>Steering files matching prompt \"add an endpoint for updating user email\":\n api-validation inclusion=auto priority=20 tools=all\n</code></pre> <p>Good, the prompt matches. Try a negative case:</p> <pre><code>ctx steering preview \"fix a bug in the JSON renderer\"\n</code></pre> <p>Expected: empty match (or whatever else is currently <code>auto</code>). If <code>api-validation</code> incorrectly fires for unrelated prompts, tighten the description. If it misses prompts it should catch, add more keywords.</p>","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":"<pre><code>ctx steering list\n</code></pre> <p>Should show <code>api-validation</code> alongside any other files, with its inclusion mode and priority. If the list is wrong, check the frontmatter for typos.</p>","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":"<p>Steering files are authored once in <code>.context/steering/</code>, but how they reach the AI depends on which tool you use. There are two delivery mechanisms:</p>","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":"<p>These tools read a specific directory for rules. <code>ctx steering sync</code> exports your files into that directory with tool-specific frontmatter:</p> <pre><code>ctx steering sync\n</code></pre> <p>Depending on the active tool in <code>.ctxrc</code> or <code>--tool</code>:</p> Tool Target Cursor <code>.cursor/rules/</code> Cline <code>.clinerules/</code> Kiro <code>.kiro/steering/</code> <p>The sync is idempotent; unchanged files are skipped. Run it whenever you edit a steering file.</p>","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":"<p>Claude Code and Codex have no native rules primitive, so <code>ctx steering sync</code> is a no-op for them; it deliberately skips both. Instead, steering reaches these tools through two non-sync channels:</p> <ol> <li> <p><code>PreToolUse</code> hook (automatic). The <code>ctx setup claude-code</code> plugin installs a hook that runs <code>ctx agent --budget 8000</code> before each tool call. <code>ctx agent</code> 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.</p> </li> <li> <p><code>ctx_steering_get</code> 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.</p> </li> </ol> <p>Both channels activate when you run:</p> <pre><code>ctx setup claude-code --write\n</code></pre> <p>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.</p> <p>Running <code>ctx steering sync</code> with Claude Code</p> <p>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 <code>sync</code>. If you use both Claude Code and (say) Cursor, run <code>sync</code> to keep Cursor up to date; the Claude pipeline takes care of itself via the hook.</p>","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":"<p>Open your AI tool and ask it something the rule should fire on:</p> <p>\"Add a POST /users endpoint that accepts email and name.\"</p> <p>If the rule is working, the AI's first response should mention input validation, typed structs, and the <code>internal/validate/</code> package, because that's what the steering file told it to do.</p> <p>If nothing happens, the fix depends on which path you're on:</p> <p>Path A (Cursor/Cline/Kiro):</p> <ol> <li>Re-run <code>ctx steering preview</code> with the literal prompt to confirm the match.</li> <li>Run <code>ctx steering list</code> and verify <code>inclusion</code> is <code>auto</code>, not <code>manual</code>.</li> <li>Check the tool's own config directory (e.g. <code>.cursor/rules/</code>); the file should be there after <code>ctx steering sync</code>.</li> </ol> <p>Path B (Claude Code):</p> <ol> <li>Re-run <code>ctx steering preview</code> with the literal prompt to confirm the match.</li> <li>Verify the plugin is installed: <code>cat .claude/hooks.json</code> should include <code>ctx agent --budget 8000</code> under <code>PreToolUse</code>. If not, re-run <code>ctx setup claude-code --write</code>.</li> <li>Run <code>ctx agent --budget 8000</code> manually and grep the output for your rule body. If it's there, the data is fine; if it's missing, the <code>inclusion</code> mode or <code>description</code> is at fault.</li> <li>As a last resort, ask Claude directly: \"Call the <code>ctx_steering_get</code> 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.</li> </ol>","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#common-mistakes","level":2,"title":"Common Mistakes","text":"<p>Too-generic descriptions. <code>description: general coding</code> will match almost every prompt and flood the context window. Keep descriptions specific to the scenario the rule applies to.</p> <p>Overlapping rules. If two steering files match the same prompt and contradict each other, the result is confusing. Use <code>priority</code> to resolve, but better: merge the files or narrow the descriptions so they don't overlap.</p> <p>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 <code>ctx decision add</code>, not <code>ctx steering add</code>.</p> <p>Committing <code>inclusion: always</code> without thinking. Rules marked <code>always</code> fire on every prompt, consuming tier-6 budget permanently. Only use <code>always</code> for true invariants (security, safety, licensing). Everything else should be <code>auto</code> or <code>manual</code>.</p>","path":["Recipes","Agents and Automation","Writing Steering Files"],"tags":[]},{"location":"recipes/steering/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx steering</code> reference: full command, flag, and frontmatter reference.</li> <li><code>ctx setup</code>: configure which tools the steering sync writes to.</li> <li>Authoring triggers: if you want script-based automation, not rule-based prompt injection.</li> </ul>","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":"<p><code>ctx</code> 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.</p> <p>How do you verify your hooks are actually running, audit what they do, and get alerted when they go silent?</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre> <p>Or ask your agent: \"Are our hooks running?\"</p>","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 <code>ctx system <hook></code> CLI command Run a system hook manually <code>ctx sysinfo</code> CLI command Show system resource status <code>ctx usage</code> CLI command Stream or dump per-session token stats <code>ctx hook notify setup</code> CLI command Configure webhook for audit trail <code>ctx hook notify test</code> CLI command Verify webhook delivery <code>.ctxrc</code> <code>notify.events</code> Configuration Subscribe to <code>relay</code> for full hook audit <code>.context/logs/</code> 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":"<p>System hooks are plumbing commands that <code>ctx</code> registers with your AI tool (Claude Code, Cursor, etc.) via the plugin's <code>hooks.json</code>. They fire automatically at specific events during your AI session:</p> Event When Hooks <code>UserPromptSubmit</code> Before the agent sees your prompt 10 check hooks + heartbeat <code>PreToolUse</code> Before the agent uses a tool <code>block-non-path-ctx</code>, <code>qa-reminder</code> <code>PostToolUse</code> After a tool call succeeds <code>post-commit</code> <p>You never run these manually. Your AI tool runs them for you: That's the point.</p>","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":"<p>These fire before every prompt, but most are throttled to avoid noise.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-context-size-context-capacity-warning","level":4,"title":"<code>check-context-size</code>: Context Capacity Warning","text":"<p>What: Adaptive prompt counter. Silent for the first 15 prompts, then nudges with increasing frequency (every 5<sup>th</sup>, then every 3<sup>rd</sup>).</p> <p>Why: Long sessions lose coherence. The nudge reminds both you and the agent to persist context before the window fills up.</p> <p>Output: VERBATIM relay box with prompt count.</p> <pre><code>┌─ 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</code></pre> <p>Usage: Every prompt records token usage to <code>.context/state/stats-{session}.jsonl</code>. Monitor live with <code>ctx usage --follow</code> or query with <code>ctx usage --json</code>. Usage is recorded even during wrap-up suppression (event: <code>suppressed</code>).</p> <p>Billing guard: When <code>billing_token_warn</code> is set in <code>.ctxrc</code>, 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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-persistence-context-staleness-nudge","level":4,"title":"<code>check-persistence</code>: Context Staleness Nudge","text":"<p>What: Tracks when <code>.context/*.md</code> files were last modified. If too many prompts pass without a write, nudges the agent to persist.</p> <p>Why: Sessions produce insights that evaporate if not recorded. This catches the \"we talked about it but never wrote it down\" failure mode.</p> <p>Output: VERBATIM relay after 20+ prompts without a context file change.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-ceremonies-session-ritual-adoption","level":4,"title":"<code>check-ceremonies</code>: Session Ritual Adoption","text":"<p>What: Scans your last 3 journal entries for <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> usage. Nudges once per day if missing.</p> <p>Why: Session ceremonies are the highest-leverage habit in <code>ctx</code>. This hook bootstraps the habit until it becomes automatic.</p> <p>Output: Tailored nudge depending on which ceremony is missing.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-journal-unimported-session-reminder","level":4,"title":"<code>check-journal</code>: Unimported Session Reminder","text":"<p>What: Detects unimported Claude Code sessions and unenriched journal entries. Fires once per day.</p> <p>Why: Exported sessions become searchable history. Unenriched entries lack metadata for filtering. Both decay in value over time.</p> <p>Output: VERBATIM relay with counts and exact commands.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-resources-system-resource-pressure","level":4,"title":"<code>check-resources</code>: System Resource Pressure","text":"<p>What: Monitors memory, swap, disk, and CPU load. Only fires at DANGER severity (memory >= 90%, swap >= 75%, disk >= 95%, load >= 1.5x CPU count).</p> <p>Why: Resource exhaustion mid-session can corrupt work. This provides early warning to persist and exit.</p> <p>Output: VERBATIM relay listing critical resources.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-knowledge-knowledge-file-growth","level":4,"title":"<code>check-knowledge</code>: Knowledge File Growth","text":"<p>What: Counts entries in <code>LEARNINGS.md</code>, <code>DECISIONS.md</code>, and lines in <code>CONVENTIONS.md</code>. Fires once per day when thresholds are exceeded.</p> <p>Why: Large knowledge files dilute agent context. 35 learnings compete for attention; 15 focused ones get applied. Thresholds are configurable in <code>.ctxrc</code>.</p> <p>Default thresholds:</p> <pre><code># .ctxrc\nentry_count_learnings: 30\nentry_count_decisions: 20\nconvention_line_count: 200\n</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-version-binaryplugin-version-drift","level":4,"title":"<code>check-version</code>: Binary/Plugin Version Drift","text":"<p>What: Compares the <code>ctx</code> binary version against the plugin version. Fires once per day. Also checks encryption key age for rotation nudge.</p> <p>Why: Version drift means hooks reference features the binary doesn't have. The key rotation nudge prevents indefinite key reuse.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-reminders-pending-reminder-relay","level":4,"title":"<code>check-reminders</code>: Pending Reminder Relay","text":"<p>What: Reads <code>.context/reminders.json</code> and surfaces any due reminders via VERBATIM relay. No throttle: fires every session until dismissed.</p> <p>Why: Reminders are sticky notes to future-you. Unlike nudges (which throttle to once per day), reminders repeat deliberately until the user dismisses them.</p> <p>Output: VERBATIM relay box listing due reminders.</p> <pre><code>┌─ Reminders ──────────────────────────────────────\n│ [1] refactor the swagger definitions\n│\n│ Dismiss: ctx remind dismiss <id>\n│ Dismiss all: ctx remind dismiss --all\n└──────────────────────────────────────────────────\n</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-freshness-technology-constant-staleness","level":4,"title":"<code>check-freshness</code>: Technology Constant Staleness","text":"<p>What: Stats files listed in <code>.ctxrc</code> <code>freshness_files</code> and warns if any haven't been modified in over 6 months. Daily throttle. Silent when no files are configured (opt-in via <code>.ctxrc</code>).</p> <p>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.</p> <p>Config (<code>.ctxrc</code>):</p> <pre><code>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</code></pre> <p>Each entry has a <code>path</code> (relative to project root), <code>desc</code> (what constants live there), and optional <code>review_url</code> (where to check current values). When <code>review_url</code> is set, the nudge includes \"Review against: {url}\". When absent, just \"Touch the file to mark it as reviewed.\"</p> <p>Output: VERBATIM relay listing stale files, silent otherwise.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#check-map-staleness-architecture-map-drift","level":4,"title":"<code>check-map-staleness</code>: Architecture Map Drift","text":"<p>What: Checks whether <code>map-tracking.json</code> is older than 30 days and there are commits touching <code>internal/</code> since the last map refresh. Daily throttle prevents repeated nudges.</p> <p>Why: Architecture documentation drifts silently as code evolves. This hook detects structural changes that the map hasn't caught up with and suggests running <code>/ctx-architecture</code> to refresh.</p> <p>Output: VERBATIM relay when stale and modules changed, silent otherwise.</p> <pre><code>┌─ 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#heartbeat-session-heartbeat-webhook","level":4,"title":"<code>heartbeat</code>: Session Heartbeat Webhook","text":"<p>What: Fires on every prompt. Sends a webhook notification with prompt count, session ID, context modification status, and token usage telemetry. Never produces stdout.</p> <p>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.</p> <p>Output: None (webhook + event log only).</p> <p>Payload:</p> <pre><code>{\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</code></pre> <p>Token fields (<code>tokens</code>, <code>context_window</code>, <code>usage_pct</code>) are included when usage data is available from the session JSONL file.</p>","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":"<code>block-non-path-ctx</code>: PATH Enforcement (Hard Gate)","text":"<p>What: Blocks any Bash command that invokes <code>./ctx</code>, <code>./dist/ctx</code>, <code>go run ./cmd/ctx</code>, or an absolute path to <code>ctx</code>. Only PATH invocations are allowed.</p> <p>Why: Enforces <code>CONSTITUTION.md</code>'s invocation invariant. Running a dev-built binary in production context causes version confusion and silent behavior drift.</p> <p>Output: Block response (prevents the tool call):</p> <pre><code>{\"decision\": \"block\", \"reason\": \"Use 'ctx' from PATH, not './ctx'...\"}\n</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#qa-reminder-pre-commit-qa-gate","level":4,"title":"<code>qa-reminder</code>: Pre-Commit QA Gate","text":"<p>What: Fires on every <code>Edit</code> tool use. Reminds the agent to lint and test the entire project before committing.</p> <p>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.</p> <p>Output: Agent directive with hard QA gate instructions.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#post-commit-context-capture-after-commit","level":4,"title":"<code>post-commit</code>: Context Capture After Commit","text":"<p>What: Fires after any <code>git commit</code> (excludes <code>--amend</code>). Prompts the agent to offer context capture (decision? learning?) and suggest running lints/tests before pushing.</p> <p>Why: Commits are natural reflection points. The nudge converts mechanical git operations into context-capturing opportunities.</p>","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":"<p>If you don't need an external audit trail, enable the local event log for a self-contained record of hook activity:</p> <pre><code># .ctxrc\nevent_log: true\n</code></pre> <p>Once enabled, every hook that fires writes an entry to <code>.context/state/events.jsonl</code>. Query it with <code>ctx hook event</code>:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<p>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.</p>","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":"<pre><code>ctx hook notify setup\n# Enter your webhook URL (Slack, Discord, ntfy.sh, IFTTT, etc.)\n</code></pre> <p>See Webhook Notifications for service-specific setup.</p>","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 <code>relay</code> Events","text":"<pre><code># .ctxrc\nnotify:\n events:\n - relay # all hook output: VERBATIM relays, directives, blocks\n - nudge # just the user-facing VERBATIM relays\n</code></pre> <p>The <code>relay</code> event fires for every hook that produces output. This includes:</p> Hook Event sent <code>check-context-size</code> <code>relay</code> + <code>nudge</code> <code>check-persistence</code> <code>relay</code> + <code>nudge</code> <code>check-ceremonies</code> <code>relay</code> + <code>nudge</code> <code>check-journal</code> <code>relay</code> + <code>nudge</code> <code>check-resources</code> <code>relay</code> + <code>nudge</code> <code>check-knowledge</code> <code>relay</code> + <code>nudge</code> <code>check-version</code> <code>relay</code> + <code>nudge</code> <code>check-reminders</code> <code>relay</code> + <code>nudge</code> <code>check-freshness</code> <code>relay</code> + <code>nudge</code> <code>check-map-staleness</code> <code>relay</code> + <code>nudge</code> <code>heartbeat</code> <code>heartbeat</code> only <code>block-non-path-ctx</code> <code>relay</code> only <code>post-commit</code> <code>relay</code> only <code>qa-reminder</code> <code>relay</code> 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":"<p>With <code>relay</code> enabled, your webhook receives a JSON payload every time a hook fires:</p> <pre><code>{\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</code></pre> <p>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?</p>","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":"<p>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:</p>","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":"<p>The simplest check. After a few prompts into a session:</p> <pre><code>\"Did you receive any hook output this session? Print the last\ncontext checkpoint or persistence nudge you saw.\"\n</code></pre> <p>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:</p> <ul> <li>The hooks aren't firing (check installation);</li> <li>The session is too short (hooks throttle early);</li> <li>The hooks fired but the agent absorbed them silently.</li> </ul> <p>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.</p>","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":"<p>If you have <code>relay</code> events enabled, check your webhook receiver. Every hook that fires sends a timestamped notification. No notification = no fire.</p> <p>This is the ground truth. The webhook is called directly by the <code>ctx</code> binary, not by the agent. The agent cannot fake, suppress, or modify webhook deliveries.</p> <p>Compare what the webhook received against what the agent claims to have relayed. Discrepancies mean the agent is absorbing nudges instead of surfacing them.</p>","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":"<p>Hooks that support logging write to <code>.context/logs/</code>:</p> <pre><code># 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</code></pre> <pre><code># 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</code></pre> <p>Logs are append-only and written by the <code>ctx</code> binary, not the agent.</p>","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":"<p>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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#the-staleness-signal","level":3,"title":"The Staleness Signal","text":"<p>If <code>.context/logs/check-context-size.log</code> 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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#false-positive-protection","level":3,"title":"False Positive Protection","text":"<p>A naive \"hooks haven't fired in N days\" alert fires incorrectly when you simply haven't used <code>ctx</code>. The correct check needs two inputs:</p> <ol> <li>Last hook fire time: from <code>.context/logs/</code> or webhook history</li> <li>Last session activity: from journal entries or <code>ctx journal source</code></li> </ol> <p>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.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#what-to-check","level":3,"title":"What to Check","text":"<p>When you suspect hooks aren't firing:</p> <pre><code># 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</code></pre>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>nudge</code>, graduate to <code>relay</code>: The <code>nudge</code> event covers user-facing VERBATIM relays. Add <code>relay</code> when you want full visibility into agent directives and hard gates.</li> <li>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.</li> <li>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.</li> <li>Daily markers live in <code>.context/state/</code>: Throttle files are stored in <code>.context/state/</code> alongside other project-scoped state. If you need to force a hook to re-fire during testing, delete the corresponding marker file.</li> <li>The QA reminder is intentionally noisy: Unlike other hooks, <code>qa-reminder</code> fires on every <code>Edit</code> call with no throttle. This is deliberate: The commit quality degrades when the reminder fades from salience.</li> <li>Log files are safe to commit: <code>.context/logs/</code> contains only timestamps, session IDs, and status keywords. No secrets, no code.</li> </ul>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#next-up","level":2,"title":"Next Up","text":"<p>Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.</p>","path":["Recipes","Hooks and Notifications","Auditing System Hooks"],"tags":[]},{"location":"recipes/system-hooks-audit/#see-also","level":2,"title":"See Also","text":"<ul> <li>Troubleshooting: full diagnostic workflow using <code>ctx doctor</code>, event logs, and <code>/ctx-doctor</code></li> <li>Customizing Hook Messages: override what hooks say without changing what they do</li> <li>Webhook Notifications: setting up and configuring the webhook system</li> <li>Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates</li> <li>Detecting and Fixing Drift: structural checks that complement runtime hook auditing</li> <li>CLI Reference: full <code>ctx system</code> command reference</li> </ul>","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":"<p>You have work that spans multiple sessions. Tasks get added during one session, partially finished in another, and completed days later.</p> <p>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. <code>TASKS.md</code> grows cluttered with completed checkboxes that obscure the remaining work.</p> <p>How do you manage work items that span multiple sessions without losing context?</p> <p>Prefer Skills over Raw Commands</p> <p>When working with an AI agent, use <code>/ctx-task-add</code> instead of raw <code>ctx task add</code>. The agent automatically picks up session ID, branch, and commit hash from its context, so no manual flags are needed.</p>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tldr","level":2,"title":"TL;DR","text":"<p>Manage Tasks:</p> <pre><code>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</code></pre> <p>Pick Up the Next Task:</p> <pre><code>/ctx-next # pick what's next\n</code></pre> <p>Read on for the full workflow and conversational patterns.</p>","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 <code>ctx task add</code> Command Add a new task to <code>TASKS.md</code> <code>ctx task complete</code> Command Mark a task as done by number or text <code>ctx task snapshot</code> Command Create a point-in-time backup of <code>TASKS.md</code> <code>ctx task archive</code> Command Move completed tasks to archive file <code>/ctx-task-add</code> Skill AI-assisted task creation with validation <code>/ctx-archive</code> Skill AI-guided archival with safety checks <code>/ctx-next</code> 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":"<p>Every piece of follow-up work gets a task. Use <code>ctx task add</code> from the terminal or <code>/ctx-task-add</code> from your AI assistant. Tasks should start with a verb and be specific enough that someone unfamiliar with the session could act on them.</p> <pre><code># 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</code></pre> <p>The <code>/ctx-task-add</code> 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.</p> <p>If you say \"fix the bug,\" it will ask you to clarify which bug and where.</p> <p>Tasks Are Often Created Proactively</p> <p>In practice, many tasks are created proactively by the agent rather than by explicit CLI commands.</p> <p>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.</p> <p>You do not need to dictate <code>ctx task add</code> commands; the agent picks up on work context and suggests tasks naturally.</p>","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":"<p>Tasks live in phase sections inside <code>TASKS.md</code>.</p> <p>Phases provide logical groupings that preserve order and enable replay.</p> <p>A task does not move between sections. It stays in its phase permanently, and status is tracked via checkboxes and inline tags.</p> <pre><code>## 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</code></pre> <p>Use <code>--section</code> when adding a task to a specific phase:</p> <pre><code>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</code></pre> <p>Without <code>--section</code>, the task is inserted before the first unchecked task in <code>TASKS.md</code>.</p>","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":"<p>At the start of a session, or after finishing a task, use <code>/ctx-next</code> to get prioritized recommendations. </p> <p>The skill reads <code>TASKS.md</code>, checks recent sessions, and ranks candidates using explicit priority, blocking status, in-progress state, momentum from recent work, and phase order.</p> <p>You can also ask naturally: \"what should we work on?\" or \"what's the highest priority right now?\"</p> <pre><code>/ctx-next\n</code></pre> <p>The output looks like this:</p> <pre><code>**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</code></pre> <p>In-progress tasks almost always come first: </p> <p>Finishing existing work takes priority over starting new work.</p>","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":"<p>When a task is done, mark it complete by number or partial text match:</p> <pre><code># By task number (as shown in TASKS.md)\nctx task complete 3\n\n# By partial text match\nctx task complete \"agent cooldown\"\n</code></pre> <p>The task's checkbox changes from <code>[ ]</code> to <code>[x]</code>. Tasks are never deleted: they stay in their phase section so history is preserved.</p> <p>Be Conversational</p> <p>You rarely need to run <code>ctx task complete</code> yourself during an interactive session.</p> <p>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.</p> <p>The CLI commands are most useful for manual housekeeping, scripted workflows, or when you want precision.</p>","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":"<p>Before a major refactor or any change that might break things, snapshot your current task state. This creates a copy of <code>TASKS.md</code> in <code>.context/archive/</code> without modifying the original.</p> <pre><code># Default snapshot\nctx task snapshot\n\n# Named snapshot (recommended before big changes)\nctx task snapshot \"before-refactor\"\n</code></pre> <p>This creates a file like <code>.context/archive/tasks-before-refactor-2026-02-08-1430.md</code>. If the refactor goes sideways, and you need to confirm what the task state looked like before you started, the snapshot is there.</p> <p>Snapshots are cheap: Take them before any change you might want to undo or review later.</p>","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 <code>TASKS.md</code> Gets Cluttered","text":"<p>After several sessions, <code>TASKS.md</code> accumulates completed tasks that make it hard to see what is still pending.</p> <p>Use <code>ctx task archive</code> to move all <code>[x]</code> items to a timestamped archive file.</p> <p>Start with a dry run to preview what will be moved:</p> <pre><code>ctx task archive --dry-run\n</code></pre> <p>Then archive:</p> <pre><code>ctx task archive\n</code></pre> <p>Completed tasks move to <code>.context/archive/tasks-2026-02-08.md</code>. Phase headers are preserved in the archive for traceability. Pending tasks (<code>[ ]</code>) remain in <code>TASKS.md</code>.</p> <p>The <code>/ctx-archive</code> skill adds two safety checks before archiving: it verifies that completed tasks are genuinely cluttering the view and that nothing was marked <code>[x]</code> prematurely.</p>","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":"<p>The steps above show the CLI commands for task management.</p> <p>In practice, most task management happens conversationally:</p> <p>An agent that has loaded the context files does not need you to type <code>ctx task add</code>. It tracks work naturally and offers the right operations.</p>","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":"<p>These conversational prompts replace explicit commands during interactive sessions:</p> Instead of typing... Just say... <code>ctx task add \"Write tests for X\" --session-id ID --branch BR --commit HASH</code> \"We should add tests for this: track that?\" <code>/ctx-next</code> \"What should we work on?\" <code>ctx task complete \"rate limiting\"</code> \"The rate limiter is done, what's next?\" <code>ctx task archive</code> \"<code>TASKS.md</code> is getting long, can you clean it up?\" <code>ctx task add ... --session-id ID --branch BR --commit HASH && ctx task add ...</code> \"Add follow-ups for what we just built.\" <p>The agent translates these into the right <code>ctx</code> operations behind the scenes.</p>","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":"<p>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:</p> <pre><code>**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</code></pre> <p>This is how an agent behaves once it has read the Agent Playbook.</p> <p>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?</p> <p>When the answer is yes, it acts.</p>","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":"<p>You don't always know what's worth persisting.</p> <p>Instead of reviewing the session yourself and typing specific commands, ask the agent to do the thinking:</p> 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 <p>This is especially powerful after long or exploratory sessions where multiple threads were touched. </p> <p>The agent has the full conversation in context and can spot follow-ups you might miss:</p> <pre><code>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</code></pre> <p>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.</p>","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":"<p>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:</p> <pre><code>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</code></pre> <p>The agent chains completion into next-task selection.</p> <p>One sentence from you triggers two operations.</p>","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":"<p>At the end of a session, the agent reviews what happened and catches loose ends:</p> <pre><code>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</code></pre> <p>This is the proactive persistence model at work.</p> <p>The agent monitors the conversation for mentioned-but-not-tracked work and surfaces it before context is lost.</p>","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":"<p>Here is what task management looks like in a real session when the agent is driving:</p> <pre><code>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</code></pre> <p>It's All Conversational</p> <p>Notice what did not happen: The user never typed a <code>ctx</code> command.</p> <p>The agent handled task completion, follow-up creation, learning capture, and next-task selection: all from natural conversation.</p>","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":"<pre><code># 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</code></pre>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#tips","level":2,"title":"Tips","text":"<ul> <li>Start tasks with a verb: \"Add,\" \"Fix,\" \"Implement,\" \"Investigate\": not just a topic like \"Authentication.\"</li> <li>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.\"</li> <li>Use <code>#in-progress</code> sparingly. Only one or two tasks should carry this tag at a time. If everything is in-progress, nothing is.</li> <li>Snapshot before, not after. The point of a snapshot is to capture the state before a change, not to celebrate what you just finished.</li> <li>Archive regularly. Once completed tasks outnumber pending ones, it is time to archive. A clean <code>TASKS.md</code> helps both you and your AI assistant focus.</li> <li>Never delete tasks. Mark them <code>[x]</code> (completed) or <code>[-]</code> (skipped with a reason). Deletion breaks the audit trail.</li> <li>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.</li> <li>Conversational prompts beat commands in interactive sessions. Saying \"what should we work on?\" is faster and more natural than running <code>/ctx-next</code>. Save explicit commands for scripts, CI, and unattended runs.</li> <li>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.</li> <li>Review proactive task suggestions before moving on. The best follow-ups come from items spotted in-context right after the work completes.</li> </ul>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#next-up","level":2,"title":"Next Up","text":"<p>Using the Scratchpad →: Store short-lived sensitive notes in an encrypted scratchpad.</p>","path":["Recipes","Knowledge and Tasks","Tracking Work Across Sessions"],"tags":[]},{"location":"recipes/task-management/#see-also","level":2,"title":"See Also","text":"<ul> <li>The Complete Session: full session lifecycle including task management in context</li> <li>Persisting Decisions, Learnings, and Conventions: capturing the \"why\" behind your work</li> <li>Detecting and Fixing Drift: keeping <code>TASKS.md</code> accurate over time</li> <li>CLI Reference: full documentation for <code>ctx add</code>, <code>ctx task complete</code>, <code>ctx task</code></li> <li>Context Files: <code>TASKS.md</code>: format and conventions for <code>TASKS.md</code></li> </ul>","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":"<p>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.</p> <p>Triggers Execute Arbitrary Code</p> <p>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:</p> <ul> <li>Only enable scripts you have read and understand.</li> <li>Never enable a trigger you downloaded from the internet without reviewing every line.</li> <li>Avoid shelling out to user-controlled values (<code>jq -r</code> output, <code>path</code> field, <code>tool</code> field) without quoting.</li> <li>A malicious or buggy trigger can block tool calls, corrupt context files, or exfiltrate data.</li> </ul> <p>The generated trigger template starts disabled (no executable bit) so you cannot accidentally run an unreviewed script. Enable it explicitly with <code>ctx trigger enable</code>.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#scenario","level":2,"title":"Scenario","text":"<p>You want a <code>pre-tool-use</code> trigger that blocks the AI from editing anything in <code>internal/crypto/</code> without explicit confirmation. Cryptographic code is sensitive, and accidental edits have caused outages before, and you want a hard gate.</p>","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":"<pre><code>ctx trigger add pre-tool-use protect-crypto\n</code></pre> <p>That creates <code>.context/hooks/pre-tool-use/protect-crypto.sh</code> with a template:</p> <pre><code>#!/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</code></pre> <p>Note: the directory is <code>.context/hooks/pre-tool-use/</code>; the on-disk layout still uses <code>hooks/</code> even though the command is <code>ctx trigger</code>. If you <code>ls .context/hooks/</code>, that's where your triggers live.</p>","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":"<p>Open the file and replace the template body:</p> <pre><code>#!/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</code></pre> <p>A few things to note:</p> <ul> <li><code>set -euo pipefail</code>: any unhandled error aborts the script. Critical for a security-relevant trigger.</li> <li>Quote everything from <code>jq</code>: the <code>path</code> field comes from the AI tool; treat it as untrusted input.</li> <li>Explicit <code>allow</code> case: the default is allow. An empty or missing response is a risky default.</li> <li>Use <code>jq -n --arg</code> for output construction, as it is safer than string concatenation when the message may contain special characters.</li> </ul>","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":"<p>Before enabling the trigger, test it with a realistic mock input using <code>ctx trigger test</code>. This runs the script against a synthetic JSON payload without actually firing any AI tool.</p> <pre><code># Test the \"should block\" case\nctx trigger test pre-tool-use --tool write_file --path internal/crypto/aes.go\n</code></pre> <p>Expected: the trigger returns <code>{\"action\":\"block\", \"message\": \"...\"}</code>.</p> <pre><code># Test the \"should allow\" case\nctx trigger test pre-tool-use --tool write_file --path internal/memory/mirror.go\n</code></pre> <p>Expected: the trigger returns <code>{\"action\":\"allow\"}</code>.</p> <pre><code># Test that non-write tools pass through\nctx trigger test pre-tool-use --tool read_file --path internal/crypto/aes.go\n</code></pre> <p>Expected: <code>{\"action\":\"allow\"}</code> because the <code>case</code> statement only gates write-family tools.</p> <p>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.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-4-enable-it","level":2,"title":"Step 4: Enable It","text":"<p>Once the test cases pass, enable the trigger:</p> <pre><code>ctx trigger enable protect-crypto\n</code></pre> <p>That sets the executable bit. Next time the AI starts a <code>pre-tool-use</code> event, the trigger will fire.</p> <p>Verify it's enabled:</p> <pre><code>ctx trigger list\n</code></pre> <p>Should show <code>protect-crypto</code> under <code>pre-tool-use</code> with an enabled indicator.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#step-5-iterate-safely","level":2,"title":"Step 5: Iterate Safely","text":"<p>If you discover a bug after enabling, disable first, fix second:</p> <pre><code>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</code></pre> <p>Disabling simply clears the executable bit; the script stays on disk, and <code>ctx trigger enable</code> re-enables it without rewriting anything.</p>","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":"<p>For auditing or analytics, return <code>{\"action\":\"allow\"}</code> always and append to a log as a side effect:</p> <pre><code>#!/usr/bin/env bash\nset -euo pipefail\npayload=$(cat)\necho \"$payload\" >> .context/logs/tool-use.jsonl\necho '{\"action\":\"allow\"}'\n</code></pre>","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":"<p>A <code>session-start</code> trigger can prepend text to the agent's initial prompt by emitting <code>{\"action\":\"inject\", \"content\": \"...\"}</code> . This is useful for injecting daily standup notes, open PRs, or rotating TODOs without storing them in a steering file.</p>","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":"<p>Multiple scripts in the same type directory all run. If any returns <code>action: block</code>, the block wins. Keep individual triggers single-purpose and rely on composition.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#common-mistakes","level":2,"title":"Common Mistakes","text":"<p>Forgetting the shebang. Without <code>#!/usr/bin/env bash</code>, the trigger won't execute even with the executable bit set.</p> <p>Not quoting <code>$path</code>. If you use <code>$path</code> in a command substitution or a <code>case</code> glob without quoting, a file name with spaces or metacharacters will break the trigger in surprising ways.</p> <p>Enabling before testing. <code>ctx trigger enable</code> makes the script live immediately. Always <code>ctx trigger test</code> first.</p> <p>Outputting non-JSON. The trigger's stdout must be valid JSON or <code>ctx</code>'s trigger runner will log a parse error. Use <code>jq -n</code> to construct output rather than hand-writing JSON strings.</p> <p>Mixing <code>hook</code> and <code>trigger</code> vocabulary. The command is <code>ctx trigger</code> but the on-disk directory is <code>.context/hooks/</code>. The feature was renamed; the directory name lags behind. Don't let this confuse you; they refer to the same thing.</p>","path":["Recipes","Agents and Automation","Authoring Lifecycle Triggers"],"tags":[]},{"location":"recipes/triggers/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx trigger</code> reference: full command, flag, and event-type reference.</li> <li><code>ctx steering</code>: 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.\"</li> <li>Writing steering files: the rule-based equivalent of this recipe.</li> </ul>","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":"<p>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.</p> <p>How do you figure out what's wrong and fix it?</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tldr","level":2,"title":"TL;DR","text":"<pre><code>ctx doctor # structural health check\nctx hook event --last 20 # recent hook activity\n# or ask: \"something seems off, can you diagnose?\"\n</code></pre>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>ctx doctor</code> CLI command Structural health report <code>ctx doctor --json</code> CLI command Machine-readable health report <code>ctx hook event</code> CLI command Query local event log <code>/ctx-doctor</code> 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: <code>ctx doctor</code>","text":"<p>Run <code>ctx doctor</code> 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:</p> <pre><code>ctx doctor\n</code></pre> <pre><code>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</code></pre> <p>Warnings are non-critical but worth fixing. Errors need attention. Informational notes (○) flag optional features that aren't enabled.</p> <p>For scripting:</p> <pre><code>ctx doctor --json | jq '.warnings'\n</code></pre>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#deep-dive-ctx-doctor","level":3,"title":"Deep Dive: <code>/ctx-doctor</code>","text":"<p>When you need the agent to reason about what's wrong, use the skill. Ask naturally or invoke directly:</p> <pre><code>Why didn't my hook fire?\nSomething seems off, can you diagnose?\n/ctx-doctor\n</code></pre> <p>The agent follows a triage sequence:</p> <ol> <li>Baseline: runs <code>ctx doctor --json</code> for structural health</li> <li>Events: runs <code>ctx hook event --json --last 100</code> (if event logging enabled)</li> <li>Correlate: connects findings across both sources</li> <li>Present: structured findings with evidence</li> <li>Suggest: actionable next steps (but doesn't auto-fix)</li> </ol> <p>The skill degrades gracefully: without event logging enabled, it still runs structural checks and notes what you'd gain by enabling it.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#raw-event-inspection","level":3,"title":"Raw Event Inspection","text":"<p>For power users: <code>ctx hook event</code> with filters gives direct access to the event log.</p> <pre><code># 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</code></pre> <p>Filters use AND logic: <code>--hook qa-reminder --session abc123</code> returns only QA reminder events from that specific session.</p>","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-at-this-directory","level":3,"title":"\"No <code>.context/</code> at this directory\"","text":"<p>Symptoms: Any <code>ctx</code> command fails with <code>ctx: no .context/ at <pwd>. Run \\</code>ctx init` here, or cd to a project that has one.`</p> <p>Cause: <code>ctx</code> reads <code>$PWD/.context/</code> and you ran the command from a directory that does not have one.</p> <p>Fix: either <code>cd</code> into a project root that already has <code>.context/</code>, or run <code>ctx init</code> in the current directory to create one.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#ctx-not-initialized","level":3,"title":"\"<code>ctx</code>: Not Initialized\"","text":"<p>Symptoms: <code>ctx</code> finds <code>.context/</code> at <code>$PWD</code> but the command fails with <code>ctx: not initialized - run \"ctx init\" first</code>.</p> <p>Cause: The directory exists but hasn't been populated with template files.</p> <p>Fix:</p> <pre><code>ctx init # create .context/ with template files\nctx init --minimal # or just the essentials (CONSTITUTION, TASKS, DECISIONS)\n</code></pre> <p>Commands that work without <code>.context/</code> or initialization: <code>ctx init</code>, <code>ctx setup</code>, <code>ctx doctor</code>, <code>ctx guide</code>, <code>ctx why</code>, <code>ctx config switch/status</code>, <code>ctx hub *</code>, and help-only grouping commands.</p>","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":"<p>Symptoms: A <code>!</code>-pragma or interactive <code>ctx</code> call writes to the wrong <code>.context/</code>; or you ran <code>ctx remind add</code> in shell A and the reminder shows up in project B's notifications.</p> <p>Cause: Different shells were launched from different working directories. <code>ctx</code> reads <code>$PWD/.context/</code>; if your terminal tab is <code>cd</code>'d into project A and your Claude Code session is in project B, <code>!</code>-pragma calls write to A while in-session calls write to B.</p> <p>Fix: <code>cd</code> the shell into the same project root the Claude Code session is in, or close the tab and reopen it from the right working directory.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#my-hook-isnt-firing","level":3,"title":"\"My Hook Isn't Firing\"","text":"<p>Symptoms: No nudges appearing, webhook silent, event log shows no entries for the expected hook.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>Plugin is not installed: run <code>ctx init --claude</code> to reinstall</li> <li>PATH issue: the hook invokes <code>ctx</code> from PATH; ensure it resolves</li> <li>Throttle active: most hooks fire once per day: check <code>.context/state/</code> for daily marker files</li> <li>Hook silenced: a custom message override may be an empty file: check <code>ctx hook message list</code> for overrides</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#too-many-nudges","level":3,"title":"\"Too Many Nudges\"","text":"<p>Symptoms: The agent is overwhelmed with hook output. Context checkpoints, persistence reminders, and QA gates fire constantly.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>QA reminder is noisy by design: it fires on every <code>Edit</code> call with no throttle. This is intentional. If it's too much, silence it with an empty override: <code>ctx hook message edit qa-reminder gate</code>, then empty the file</li> <li>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</li> <li>Short throttle window: if you deleted marker files in <code>.context/state/</code>, daily-throttled hooks will re-fire</li> <li>Outdated Claude Code plugin: Update the plugin using Claude Code → <code>/plugin</code> → \"Marketplace\"</li> <li><code>ctx</code> version mismatch: Build (or download) and install the latest <code>ctx</code> vesion.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#context-seems-stale","level":3,"title":"\"Context Seems Stale\"","text":"<p>Symptoms: The agent references outdated information, paths that don't exist, or decisions that were reversed.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>Drift accumulated: stale path references in <code>ARCHITECTURE.md</code> or <code>CONVENTIONS.md</code>. Fix with <code>ctx drift --fix</code> or ask the agent to clean up.</li> <li>Task backlog: too many completed tasks diluting active context. Archive with <code>ctx task archive</code> or <code>ctx compact --archive</code>.</li> <li>Large context files: <code>LEARNINGS.md</code> with 40+ entries competes for attention. Consolidate with <code>/ctx-consolidate</code>.</li> <li>Missing session ceremonies: if <code>/ctx-remember</code> and <code>/ctx-wrap-up</code> aren't being used, context doesn't get refreshed. See Session Ceremonies.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#the-agent-isnt-following-instructions","level":3,"title":"\"The Agent Isn't Following Instructions\"","text":"<p>Symptoms: The agent ignores conventions, forgets decisions, or acts contrary to <code>CONSTITUTION.md</code> rules.</p> <p>Diagnosis:</p> <pre><code># 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</code></pre> <p>Common causes:</p> <ul> <li>Context too large: if total tokens exceed the model's effective attention, instructions get diluted. Check <code>ctx doctor</code> for the size check. Compact with <code>ctx compact --archive</code>.</li> <li>Context not loading: if <code>context-load-gate</code> hasn't fired, the agent may not have received context. Verify the hook is registered.</li> <li>Conflicting instructions: <code>CONVENTIONS.md</code> says one thing, <code>AGENT_PLAYBOOK.md</code> says another. Review both files for consistency.</li> <li>Agent drift: the agent's behavior diverges from instructions over long sessions. This is normal. Use <code>/ctx-reflect</code> to re-anchor, or start a new session.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#prerequisites","level":2,"title":"Prerequisites","text":"<ul> <li>Event logging (optional but recommended): <code>event_log: true</code> in <code>.ctxrc</code></li> <li><code>ctx</code> initialized: <code>ctx init</code></li> </ul> <p>Event logging is not required for <code>ctx doctor</code> or <code>/ctx-doctor</code> to work. Both degrade gracefully: structural checks run regardless, and the skill notes when event data is unavailable.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#tips","level":2,"title":"Tips","text":"<ul> <li>Start with <code>ctx doctor</code>: 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.</li> <li>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.</li> <li>Use the skill for correlation: <code>ctx doctor</code> tells you what is wrong. <code>/ctx-doctor</code> tells you why by correlating structural findings with event patterns. The agent can spot connections that individual commands miss.</li> <li>Event log is gitignored: It's machine-local diagnostic data, not project context. Different machines produce different event streams.</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#next-up","level":2,"title":"Next Up","text":"<p>Detecting and Fixing Drift →: Keep context files accurate as your codebase evolves.</p>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/troubleshooting/#see-also","level":2,"title":"See Also","text":"<ul> <li>Auditing System Hooks: the complete hook catalog and webhook-based audit trails</li> <li>Detecting and Fixing Drift: structural and semantic drift detection and repair</li> <li>Webhook Notifications: push notifications for hook activity</li> <li><code>ctx doctor</code> CLI: full command reference</li> <li><code>ctx hook event</code> CLI: event log query reference</li> <li><code>/ctx-doctor</code> skill: agent-driven diagnosis</li> </ul>","path":["Recipes","Maintenance","Troubleshooting"],"tags":[]},{"location":"recipes/typical-kb-session/","level":1,"title":"Typical KB Session","text":"","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#the-problem","level":2,"title":"The Problem","text":"<p>You set the editorial pipeline up (Build a Knowledge Base). Now you sit down for a real research session: a transcript to ingest, a question to answer against existing evidence, a finding to capture for later. What's the actual flow?</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#tldr","level":2,"title":"TL;DR","text":"<pre><code>/ctx-remember # session-start recall\n/ctx-kb-ingest ./inputs/transcript.md \"topic\" # editorial pass\n/ctx-kb-ask \"does the kb say X?\" # grounded Q&A\n/ctx-kb-note \"follow-up: chase the v1.1 link\" # park a finding\n/ctx-wrap-up # ceremony → /ctx-handover\n</code></pre>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#commands-and-skills-used","level":2,"title":"Commands and Skills Used","text":"Tool Type Purpose <code>/ctx-remember</code> Skill Session-start recall (folds KB state when present) <code>/ctx-kb-ingest</code> Skill Mode-aware editorial pass <code>/ctx-kb-ask</code> Skill Q&A grounded in the kb <code>/ctx-kb-note</code> Skill Park a finding for the next ingest <code>/ctx-wrap-up</code> Skill End-of-session ceremony; delegates to the handover step <code>/ctx-handover</code> Skill Writes the per-session handover; called by <code>/ctx-wrap-up</code>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-1-session-start-recall","level":2,"title":"Step 1: Session Start (Recall)","text":"<pre><code>/ctx-remember\n</code></pre> <p><code>/ctx-remember</code> reads the latest handover under <code>.context/handovers/</code> (timestamped <code><TS>-<slug>.md</code> so concurrent agent runs never overwrite); its <code>## Summary</code> and <code>## Next session</code> are the authoritative recall surface. The five canonical files (<code>TASKS</code>, <code>DECISIONS</code>, etc.) are read as usual.</p> <p>When <code>.context/kb/</code> exists, <code>/ctx-remember</code> additionally folds editorial state into the readback: any closeouts whose <code>generated-at</code> postdates the handover are read for their <code>## What changed</code> sections (these are unfolded passes the last handover did not yet consume).</p> <p><code>SESSION_LOG.md</code> is not read at session start; it is mid-flight working memory, not a recall surface.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-2-ingest-the-sources-you-brought","level":2,"title":"Step 2: Ingest the Sources You Brought","text":"<pre><code>/ctx-kb-ingest ./inputs/2026-05-15-call.md \"cursor hooks\"\n</code></pre> <p>The skill declares its mode up front (most often <code>topic-page</code>), resolves sources, scans the source-coverage ledger for adjacent incomplete topics, and synthesizes prose into the topic page section by section. Every cited claim mints an <code>EV-###</code> row in <code>evidence-index.md</code> with the source short-name + locator + optional <code>sha:</code> pin for in-repo files.</p> <p>The pass ends with a circuit-breaker check (file exists, cites ≥ 1 <code>EV-###</code>, site builds clean, cold-reader rubric at <code>pass</code>) and writes a closeout.</p> <p>If the skill reports <code>topic-page: deferred</code> instead of <code>produced</code>, look at the closeout's <code>Next pass hint</code>. It names the exact resumption invocation.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-3-ask-grounded-questions","level":2,"title":"Step 3: Ask Grounded Questions","text":"<pre><code>/ctx-kb-ask \"does the kb say hooks block until they exit?\"\n</code></pre> <p><code>/ctx-kb-ask</code> reads the kb's prose and answers with <code>EV-###</code> citations. If the kb cannot answer, it opens a <code>Q-###</code> row in <code>outstanding-questions.md</code> and reports the gap rather than inventing.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-4-park-findings-for-later","level":2,"title":"Step 4: Park Findings for Later","text":"<pre><code>/ctx-kb-note \"check whether SIGTERM behavior changed in v1.2\"\n</code></pre> <p><code>/ctx-kb-note</code> appends one-liners to <code>.context/ingest/findings.md</code>, a lightweight surface for parking ideas that don't earn a full ingest pass right now. The next <code>/ctx-kb-ingest</code> can choose to absorb them.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#step-5-wrap-up","level":2,"title":"Step 5: Wrap Up","text":"<pre><code>/ctx-wrap-up \"Cursor Hooks: lifecycle deep dive\"\n</code></pre> <p><code>/ctx-wrap-up</code> runs the standard capture checklist (learnings, decisions, conventions, tasks) and delegates to <code>/ctx-handover</code> as its final step. In a KB session it additionally:</p> <ul> <li>Surfaces pending closeouts under <code>.context/ingest/closeouts/</code>.</li> <li>Counts <code>open</code> rows in <code>outstanding-questions.md</code>.</li> </ul> <p>The handover artifact lands at <code>.context/handovers/<TS>-<slug>.md</code> (timestamped so concurrent agent runs never overwrite). The handover folds postdated closeouts into a <code>## Folded closeouts</code> section and archives them under <code>.context/archive/closeouts/</code>. Editorial work that was incomplete at wrap-up (open <code>Q-###</code> rows, <code>topic-page: deferred</code> passes) is surfaced as recall on the next session start.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#common-shapes","level":2,"title":"Common Shapes","text":"","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#multiple-topics-in-one-session","level":3,"title":"Multiple Topics in One Session","text":"<p>Run <code>/ctx-kb-ingest</code> once per topic. Each pass writes its own closeout; the handover folds all of them at the end.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#mid-session-checkpoint","level":3,"title":"Mid-Session Checkpoint","text":"<pre><code>ctx handover write \"Mid-day checkpoint\" \\\n --summary \"...\" --next \"...\" --no-fold\n</code></pre> <p><code>--no-fold</code> writes the handover without consuming closeouts, useful when you want a recall anchor mid-session without ending the editorial chunking.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#aborted-session","level":3,"title":"Aborted Session","text":"<p>If you close the laptop after an ingest pass but before <code>/ctx-wrap-up</code>, the closeouts stay in place. The next session's <code>/ctx-remember</code> reads them as unfolded postdated closeouts; the next wrap-up's handover step folds them normally. See Recover an Aborted Session for the failure-mode detail.</p>","path":["Recipes","Knowledge Base","Typical KB Session"],"tags":[]},{"location":"recipes/typical-kb-session/#reference","level":2,"title":"Reference","text":"<ul> <li>Recipe: Build a Knowledge Base</li> <li>Recipe: Recover an Aborted Session</li> <li>Skill: <code>/ctx-kb-ingest</code></li> <li>Skill: <code>/ctx-handover</code></li> <li>Editorial constitution: <code>.context/ingest/KB-RULES.md</code></li> </ul>","path":["Recipes","Knowledge Base","Typical KB Session"],"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":"<p>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.</p> <p>How do you get notified about agent activity without watching the terminal?</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tldr","level":2,"title":"TL;DR","text":"<pre><code>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</code></pre>","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 <code>ctx hook notify setup</code> CLI command Configure and encrypt webhook URL <code>ctx hook notify test</code> CLI command Send a test notification <code>ctx hook notify --event <name> \"msg\"</code> CLI command Send a notification from scripts/skills <code>.ctxrc</code> <code>notify.events</code> 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":"<p>Any service that accepts HTTP POST with JSON works. Common options:</p> 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 <code>https://ntfy.sh/your-topic</code> (no signup) Pushover Use API endpoint with your user key <p>The URL contains auth tokens. <code>ctx</code> encrypts it; it never appears in plaintext in your repo.</p>","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":"<pre><code>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</code></pre> <p>This encrypts the URL with AES-256-GCM using the same key as the scratchpad (<code>~/.ctx/.ctx.key</code>). The encrypted file (<code>.context/.notify.enc</code>) is safe to commit. The key lives outside the project and is never committed.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-3-test-it","level":3,"title":"Step 3: Test It","text":"<pre><code>ctx hook notify test\n# Webhook responded: HTTP 200 OK\n</code></pre> <p>If you see <code>No webhook configured</code>, run <code>ctx hook notify setup</code> first.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#step-4-configure-events","level":3,"title":"Step 4: Configure Events","text":"<p>Notifications are opt-in: no events are sent unless you configure an event list in <code>.ctxrc</code>:</p> <pre><code># .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</code></pre> <p>Only listed events fire. Omitting an event silently drops it.</p>","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":"<p>Add <code>ctx hook notify</code> calls to any skill or script:</p> <pre><code># 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</code></pre> <p>The <code>2>/dev/null || true</code> suffix ensures the notification never breaks your script: If there's no webhook or the HTTP call fails, it's a silent noop.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#event-types","level":2,"title":"Event Types","text":"<p><code>ctx</code> fires these events automatically:</p> Event Source When <code>loop</code> Loop script Loop completes or hits max iterations <code>nudge</code> System hooks VERBATIM relay nudge is emitted (context checkpoint, persistence, ceremonies, journal, resources, knowledge, version) <code>relay</code> System hooks Any hook output (VERBATIM relays, agent directives, block responses) <code>heartbeat</code> System hook Every prompt: session-alive signal with prompt count and context modification status <code>test</code> <code>ctx hook notify test</code> Manual test notification (custom) Your skills You wire <code>ctx hook notify --event <name></code> in your own scripts <p><code>nudge</code> vs <code>relay</code>: The <code>nudge</code> event fires only for VERBATIM relay hooks (the ones the agent is instructed to show verbatim). The <code>relay</code> event fires for all hook output: VERBATIM relays, agent directives, and hard gates. Subscribe to <code>relay</code> for debugging (\"did the agent get the post-commit nudge?\"), <code>nudge</code> for user-facing assurance (\"was the checkpoint emitted?\").</p> <p>Webhooks as a Hook Audit Trail</p> <p>Subscribe to <code>relay</code> events and you get an external record of every hook that fires, independent of the agent. </p> <p>This lets you verify hooks are running and catch cases where the agent absorbs a nudge instead of surfacing it. </p> <p>See Auditing System Hooks for the full workflow.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#payload-format","level":2,"title":"Payload Format","text":"<p>Every notification sends a JSON POST:</p> <pre><code>{\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</code></pre> <p>The <code>detail</code> 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 <code>ctx hook notify</code> calls).</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#heartbeat-payload","level":3,"title":"Heartbeat Payload","text":"<p>The <code>heartbeat</code> event fires on every prompt with session metadata and token usage telemetry:</p> <pre><code>{\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</code></pre> <p>The <code>tokens</code>, <code>context_window</code>, and <code>usage_pct</code> 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).</p> <p>Unlike other events, <code>heartbeat</code> fires every prompt (not throttled). Use it for observability dashboards or liveness monitoring of long-running sessions.</p>","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 <code>~/.ctx/.ctx.key</code> No (user-level) <code>0600</code> Encrypted URL <code>.context/.notify.enc</code> Yes (safe) <code>0600</code> Webhook URL Never on disk in plaintext N/A N/A <p>The key is shared with the scratchpad. If you rotate the encryption key, re-run <code>ctx hook notify setup</code> to re-encrypt the webhook URL with the new key.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#key-rotation","level":2,"title":"Key Rotation","text":"<p><code>ctx</code> checks the age of the encryption key once per day. If it's older than 90 days (configurable via <code>key_rotation_days</code>), a VERBATIM nudge is emitted suggesting rotation.</p> <pre><code># .ctxrc\nkey_rotation_days: 30 # nudge sooner (default: 90)\n</code></pre>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#worktrees","level":2,"title":"Worktrees","text":"<p>The webhook URL is encrypted with the same encryption key (<code>~/.ctx/.ctx.key</code>). Because the key lives at the user level, it is shared across all worktrees on the same machine - notifications work in worktrees automatically.</p> <p>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.</p>","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":"<p>Don't need a webhook but want diagnostic visibility? Enable <code>event_log: true</code> in <code>.ctxrc</code>. The event log writes the same payload as webhooks to a local JSONL file (<code>.context/state/events.jsonl</code>) that you can query without any external service:</p> <pre><code>ctx hook event --last 20 # recent hook activity\nctx hook event --hook qa-reminder # filter by hook\n</code></pre> <p>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 <code>ctx doctor</code> integration.</p> <p>See Troubleshooting for how they work together.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#tips","level":2,"title":"Tips","text":"<ul> <li>Fire-and-forget: Notifications never block. HTTP errors are silently ignored. No retry, no response parsing.</li> <li>No webhook = no cost: When no webhook is configured, <code>ctx hook notify</code> exits immediately. System hooks that call <code>notify.Send()</code> add zero overhead.</li> <li>Multiple projects: Each project has its own <code>.notify.enc</code>. You can point different projects at different webhooks.</li> <li>Event filter is per-project: Configure <code>notify.events</code> in each project's <code>.ctxrc</code> independently.</li> </ul>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#next-up","level":2,"title":"Next Up","text":"<p>Auditing System Hooks →: Verify your hooks are running, audit what they do, and get alerted when they go silent.</p>","path":["Recipes","Hooks and Notifications","Webhook Notifications"],"tags":[]},{"location":"recipes/webhook-notifications/#see-also","level":2,"title":"See Also","text":"<ul> <li>CLI Reference: <code>ctx</code> hook notify: full command reference</li> <li>Configuration: <code>.ctxrc</code> settings including <code>notify</code> options</li> <li>Running an Unattended AI Agent: how loops work and how notifications fit in</li> <li>Hook Output Patterns: understanding VERBATIM relays, agent directives, and hard gates</li> <li>Auditing System Hooks: using webhooks as an external audit trail for hook execution</li> </ul>","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":"<p>You have a task, and you are wondering: \"should I throw more agents at it?\"</p> <p>More agents can mean faster results, but they also mean coordination overhead, merge conflicts, divergent mental models, and wasted tokens re-reading context. </p> <p>The wrong setup costs more than it saves.</p> <p>This recipe is a decision framework: It helps you choose between a single agent, parallel worktrees, and a full agent team, and explains what <code>ctx</code> provides at each level.</p>","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":"<ul> <li>Single agent for most work;</li> <li>Parallel worktrees when tasks touch disjoint file sets;</li> <li>Agent teams only when tasks need real-time coordination. When in doubt, start with one agent.</li> </ul>","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":"<p>There are three modes, ordered by complexity:</p>","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":"<p>One agent, one session, one branch. This is correct for most work.</p> <p>Use this when:</p> <ul> <li>The task has linear dependencies (step 2 needs step 1's output);</li> <li>Changes touch overlapping files;</li> <li>You need tight feedback loops (review each change before the next);</li> <li>The task requires deep understanding of a single area;</li> <li>Total effort is less than a few hours of agent time.</li> </ul> <p><code>ctx</code> provides: Full <code>.context/</code>: tasks, decisions, learnings, conventions, all in one session. </p> <p>The agent builds a coherent mental model and persists it as it goes.</p> <p>Example tasks: Bug fixes, feature implementation, refactoring a module, writing documentation for one area, debugging.</p>","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":"<p>2-4 agents, each in a separate git worktree on its own branch, working on non-overlapping parts of the codebase.</p> <p>Use this when:</p> <ul> <li>You have 5+ independent tasks in the backlog;</li> <li>Tasks group cleanly by directory or package;</li> <li>File overlap between groups is zero or near-zero;</li> <li>Each track can be completed and merged independently;</li> <li>You want parallelism without coordination complexity.</li> </ul> <p><code>ctx</code> provides: Shared <code>.context/</code> via <code>git</code> (each worktree sees the same tasks, decisions, conventions). <code>/ctx-worktree</code> skill for setup and teardown. <code>TASKS.md</code> as a lightweight work queue.</p> <p>Example tasks: Docs + new package + test coverage (three tracks that don't touch the same files). Parallel recipe writing. Independent module development.</p> <p>See: Parallel Agent Development with Git Worktrees</p>","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":"<p>Multiple agents communicating via messages, sharing a task list, with a lead agent coordinating. Claude Code's team/swarm feature.</p> <p>Use this when:</p> <ul> <li>Tasks have dependencies but can still partially overlap;</li> <li>You need research and implementation happening simultaneously;</li> <li>The work requires different roles (researcher, implementer, tester);</li> <li>A lead agent needs to review and integrate others' work;</li> <li>The task is large enough that coordination cost is justified.</li> </ul> <p><code>ctx</code> provides: <code>.context/</code> as shared state that all agents can read. Task tracking for work assignment. Decisions and learnings as team memory that survives individual agent turnover.</p> <p>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.</p>","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":"<p>Ask these questions in order:</p> <pre><code>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</code></pre>","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":"<p>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).</p> <pre><code>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</code></pre> <p>When in doubt, keep things in one track. A merge conflict in a critical file costs more time than the parallelism saves.</p>","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":"<p>\"More agents\" is not always better. Watch for these patterns:</p> <p>Merge hell: If you are spending more time resolving conflicts than the parallel work saved, you split wrong: Re-group by file overlap.</p> <p>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.</p> <p>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.</p> <p>Re-reading overhead: Every agent reads <code>.context/</code> 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.</p>","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 <code>ctx</code> Gives You at Each Level","text":"<code>ctx</code> Feature Single Agent Worktrees Team <code>.context/</code> files Full access Shared via git Shared via filesystem <code>TASKS.md</code> Work queue Split by track Assigned by lead Decisions/Learnings Persisted in session Persisted per branch Persisted by any agent <code>/ctx-next</code> Picks next task Picks within track Lead assigns <code>/ctx-worktree</code> N/A Setup + teardown Optional <code>/ctx-commit</code> 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":"<p>Four practical team compositions for common workflows.</p>","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 <code>specs/</code>, breaks work into TASKS.md phases Implementer Picks tasks from TASKS.md, writes code, marks <code>[x]</code> done Reviewer Runs tests, <code>ctx drift</code>, lint; files issues as new tasks <p>Coordination: TASKS.md checkboxes. Architect writes tasks before implementer starts. Reviewer runs after each implementer commit.</p> <p>Anti-pattern: All three agents editing the same file simultaneously. Sequence the work so only one agent touches a file at a time.</p>","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 <code>ctx drift</code>, 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 <p>Coordination: Auditor's <code>ctx drift</code> output is the shared work queue. Each agent claims a subset of issues by adding <code>#in-progress</code> labels.</p> <p>Anti-pattern: Fixer and doc writer both editing ARCHITECTURE.md. Assign file ownership explicitly.</p>","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 <p>Coordination: Both read TASKS.md to identify what shipped. Release notes agent works from <code>git log</code>; validation agent works from <code>make audit</code>.</p> <p>Anti-pattern: Release notes agent running tests \"to verify.\" Each agent stays in its lane.</p>","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 <p>Coordination: Content agent writes files first. Cross-linker updates <code>zensical.toml</code> and index pages after content lands. Verifier builds after each batch.</p> <p>Antipattern: Content and cross-linker both editing <code>zensical.toml</code>. Batch nav updates into the cross-linker's pass.</p>","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":"<ul> <li>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.</li> <li>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.</li> <li>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.</li> <li>Use <code>ctx</code> as the shared brain: Whether it's one agent or four, the <code>.context/</code> directory is the single source of truth. Decisions go in <code>DECISIONS.md</code>, not in chat messages between agents.</li> <li>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.</li> <li><code>TASKS.md</code> conflicts are normal: Multiple agents completing different tasks will conflict on merge. The resolution is always additive: accept all <code>[x]</code> completions from both sides.</li> </ul>","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":"<p>Parallel Agent Development with Git Worktrees →: Run multiple agents on independent task tracks using git worktrees.</p>","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":"<ul> <li>CLI Reference: all commands and flags</li> <li>Integrations: setup for Claude Code, Cursor, Aider</li> <li>Session Journal: browse and search session history</li> </ul>","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":"<ul> <li>Parallel Agent Development with Git Worktrees: the mechanical \"how\" for worktree-based parallelism</li> <li>Running an Unattended AI Agent: serial autonomous loops: a different scaling strategy</li> <li>Tracking Work Across Sessions: managing the task backlog that feeds into any multi-agent setup</li> </ul>","path":["Recipes","Agents and Automation","When to Use a Team of Agents"],"tags":[]},{"location":"reference/","level":1,"title":"Reference","text":"<p>Technical reference for <code>ctx</code> commands, skills, and internals.</p>","path":["Reference"],"tags":[]},{"location":"reference/#the-system-explains-itself","level":3,"title":"The System Explains Itself","text":"<p>The 12 properties that must hold for any valid <code>ctx</code> implementation. Not features: constraints. The system's contract with its users and contributors.</p>","path":["Reference"],"tags":[]},{"location":"reference/#code-conventions","level":3,"title":"Code Conventions","text":"<p>Common patterns and fixes for the AST compliance tests in <code>internal/audit/</code>. When a test fails, find the matching section.</p>","path":["Reference"],"tags":[]},{"location":"reference/#cli","level":3,"title":"CLI","text":"<p>Every command, subcommand, and flag. Now a top-level section: see CLI Reference.</p>","path":["Reference"],"tags":[]},{"location":"reference/#skills","level":3,"title":"Skills","text":"<p>The full skill catalog: what each skill does, when it triggers, and how skills interact with commands.</p>","path":["Reference"],"tags":[]},{"location":"reference/#tool-ecosystem","level":3,"title":"Tool Ecosystem","text":"<p>How <code>ctx</code> compares to Cursor Rules, Aider conventions, CLAUDE.md, and other context approaches.</p>","path":["Reference"],"tags":[]},{"location":"reference/#session-journal","level":3,"title":"Session Journal","text":"<p>Export, browse, and enrich your session history. Covers the journal site, Obsidian export, and the enrichment pipeline.</p>","path":["Reference"],"tags":[]},{"location":"reference/#scratchpad","level":3,"title":"Scratchpad","text":"<p>Encrypted, git-tracked scratch space for short notes and sensitive values that travel with the project.</p>","path":["Reference"],"tags":[]},{"location":"reference/#version-history","level":3,"title":"Version History","text":"<p>Changelog for every <code>ctx</code> release.</p>","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":"<p>This guide documents the code conventions enforced by <code>internal/audit/</code> AST tests. Each section shows the violation pattern, the fix, and the rationale. When a test fails, find the matching section below.</p> <p>All tests skip <code>_test.go</code> files. The patterns apply only to production code under <code>internal/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#variable-shadowing-bare-err-reuse","level":2,"title":"Variable Shadowing (Bare <code>err :=</code> Reuse)","text":"<p>Test: <code>TestNoVariableShadowing</code></p> <p>When a function has multiple <code>:=</code> assignments to <code>err</code>, each shadows the previous one. This makes it impossible to tell which error a later <code>if err != nil</code> is checking.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>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</code></pre> <p>Rule: Use descriptive error names (<code>readErr</code>, <code>writeErr</code>, <code>parseErr</code>, <code>walkErr</code>, <code>absErr</code>, <code>relErr</code>) so each error site is independently identifiable.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#import-name-shadowing","level":2,"title":"Import Name Shadowing","text":"<p>Test: <code>TestNoImportNameShadowing</code></p> <p>When a local variable has the same name as an imported package, the import becomes inaccessible in that scope.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>import \"github.com/ActiveMemory/ctx/internal/session\"\n\nfunc process(sess *entity.Session) {\n // session package still accessible\n}\n</code></pre> <p>Rule: Parameters, variables, and return values must not reuse imported package names. Common renames: <code>session</code> -> <code>sess</code>, <code>token</code> -> <code>tok</code>, <code>config</code> -> <code>cfg</code>, <code>entry</code> -> <code>ent</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-strings","level":2,"title":"Magic Strings","text":"<p>Test: <code>TestNoMagicStrings</code></p> <p>String literals in function bodies are invisible to refactoring tools and cause silent breakage when the value changes in one place but not another.</p> <p>Before (string literals):</p> <pre><code>func loadContext() {\n data := filepath.Join(dir, \"TASKS.md\")\n if strings.HasSuffix(name, \".yaml\") {\n // ...\n }\n}\n</code></pre> <p>After:</p> <pre><code>func loadContext() {\n data := filepath.Join(dir, config.FilenameTask)\n if strings.HasSuffix(name, config.ExtYAML) {\n // ...\n }\n}\n</code></pre> <p>Before (format verbs, also caught):</p> <pre><code>func EntryHash(text string) string {\n h := sha256.Sum256([]byte(text))\n return fmt.Sprintf(\"%x\", h[:8])\n}\n</code></pre> <p>After:</p> <pre><code>func EntryHash(text string) string {\n h := sha256.Sum256([]byte(text))\n return hex.EncodeToString(h[:cfgFmt.HashPrefixLen])\n}\n</code></pre> <p>Before (URL schemes, also caught):</p> <pre><code>if strings.HasPrefix(target, \"https://\") ||\n strings.HasPrefix(target, \"http://\") {\n return target\n}\n</code></pre> <p>After:</p> <pre><code>if strings.HasPrefix(target, cfgHTTP.PrefixHTTPS) ||\n strings.HasPrefix(target, cfgHTTP.PrefixHTTP) {\n return target\n}\n</code></pre> <p>Exempt from this check:</p> <ul> <li>Empty string <code>\"\"</code>, single space <code>\" \"</code>, indentation strings</li> <li>Regex capture references (<code>$1</code>, <code>${name}</code>)</li> <li><code>const</code> and <code>var</code> definition sites (that's where constants live)</li> <li>Struct tags</li> <li>Import paths</li> <li>Packages under <code>internal/config/</code>, <code>internal/assets/tpl/</code></li> </ul> <p>Rule: If a string is used for comparison, path construction, or appears in 3+ files, it belongs in <code>internal/config/</code> as a constant. Format strings belong in <code>internal/config/</code> as named constants (e.g., <code>cfgGit.FlagLastN</code>, <code>cfgTrace.RefFormat</code>). User-facing prose belongs in <code>internal/assets/</code> YAML files accessed via <code>desc.Text()</code>.</p> <p>Common fix for <code>fmt.Sprintf</code> with format verbs:</p> Pattern Fix <code>fmt.Sprintf(\"%d\", n)</code> <code>strconv.Itoa(n)</code> <code>fmt.Sprintf(\"%d\", int64Val)</code> <code>strconv.FormatInt(int64Val, 10)</code> <code>fmt.Sprintf(\"%x\", bytes)</code> <code>hex.EncodeToString(bytes)</code> <code>fmt.Sprintf(\"%q\", s)</code> <code>strconv.Quote(s)</code> <code>fmt.Sscanf(s, \"%d\", &n)</code> <code>strconv.Atoi(s)</code> <code>fmt.Sprintf(\"-%d\", n)</code> <code>fmt.Sprintf(cfgGit.FlagLastN, n)</code> <code>\"https://\"</code> <code>cfgHTTP.PrefixHTTPS</code> <code>\"&lt;\"</code> config constant in <code>config/html/</code>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-printf-calls","level":2,"title":"Direct Printf Calls","text":"<p>Test: <code>TestNoPrintfCalls</code></p> <p><code>cmd.Printf</code> and <code>cmd.PrintErrf</code> bypass the write-package formatting pipeline and scatter user-facing text across the codebase.</p> <p>Before:</p> <pre><code>func Run(cmd *cobra.Command, args []string) {\n cmd.Printf(\"Found %d tasks\\n\", count)\n}\n</code></pre> <p>After:</p> <pre><code>func Run(cmd *cobra.Command, args []string) {\n write.TaskCount(cmd, count)\n}\n</code></pre> <p>Rule: All formatted output goes through <code>internal/write/</code> which uses <code>cmd.Print</code>/<code>cmd.Println</code> with pre-formatted strings from <code>desc.Text()</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#raw-time-format-strings","level":2,"title":"Raw Time Format Strings","text":"<p>Test: <code>TestNoRawTimeFormats</code></p> <p>Inline time format strings (<code>\"2006-01-02\"</code>, <code>\"15:04:05\"</code>) drift when one call site is updated but others are missed.</p> <p>Before:</p> <pre><code>func formatDate(t time.Time) string {\n return t.Format(\"2006-01-02\")\n}\n</code></pre> <p>After:</p> <pre><code>func formatDate(t time.Time) string {\n return t.Format(cfgTime.DateFormat)\n}\n</code></pre> <p>Rule: All time format strings must use constants from <code>internal/config/time/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#direct-flag-registration","level":2,"title":"Direct Flag Registration","text":"<p>Test: <code>TestNoFlagBindOutsideFlagbind</code></p> <p>Direct cobra flag calls (<code>.Flags().StringVar()</code>, etc.) scatter flag wiring across dozens of <code>cmd.go</code> files. Centralizing through <code>internal/flagbind/</code> gives one place to audit flag names, defaults, and description key lookups.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>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</code></pre> <p>Rule: All flag registration goes through <code>internal/flagbind/</code>. If the helper you need doesn't exist, add it to <code>flagbind/flag.go</code> before using it.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#todo-comments","level":2,"title":"TODO Comments","text":"<p>Test: <code>TestNoTODOComments</code></p> <p>TODO, FIXME, HACK, and XXX comments in production code are invisible to project tracking. They accumulate silently and never get addressed.</p> <p>Before:</p> <pre><code>// TODO: handle pagination\nfunc listEntries() []Entry {\n</code></pre> <p>After:</p> <p>Remove the comment and add a task to <code>.context/TASKS.md</code>:</p> <pre><code>- [ ] Handle pagination in listEntries (internal/task/task.go)\n</code></pre> <p>Rule: Deferred work lives in TASKS.md, not in source comments.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#dead-exports","level":2,"title":"Dead Exports","text":"<p>Test: <code>TestNoDeadExports</code></p> <p>Exported symbols with zero references outside their definition file are dead weight. They increase API surface, confuse contributors, and cost maintenance.</p> <p>Fix: Either delete the export (preferred) or demote it to unexported if it's still used within the file.</p> <p>If the symbol existed for historical reasons and might be needed again, move it to <code>quarantine/deadcode/</code> with a <code>.dead</code> extension. This preserves the code in git without polluting the live codebase:</p> <pre><code>quarantine/deadcode/internal/config/flag/flag.go.dead\n</code></pre> <p>Each <code>.dead</code> file includes a header:</p> <pre><code>// Dead exports quarantined from internal/config/flag/flag.go\n// Quarantined: 2026-04-02\n// Restore from git history if needed.\n</code></pre> <p>Rule: If a test-only allowlist entry is needed (the export exists only for test use), add the fully qualified symbol to <code>testOnlyExports</code> in <code>dead_exports_test.go</code>. Keep this list small; prefer eliminating the export.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#core-package-structure","level":2,"title":"Core Package Structure","text":"<p>Test: <code>TestCoreStructure</code></p> <p><code>core/</code> directories under <code>internal/cli/</code> must contain only <code>doc.go</code> and test files at the top level. All domain logic lives in subpackages. This prevents <code>core/</code> from becoming a god package.</p> <p>Before:</p> <pre><code>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</code></pre> <p>After:</p> <pre><code>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</code></pre> <p>Rule: Extract each logical unit into its own subpackage under <code>core/</code>. Each subpackage gets a <code>doc.go</code>. The subpackage name should match the domain concept (<code>golang</code>, <code>check</code>, <code>fix</code>, <code>store</code>), not a generic label (<code>util</code>, <code>helper</code>).</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cross-package-types","level":2,"title":"Cross-Package Types","text":"<p>Test: <code>TestCrossPackageTypes</code></p> <p>When a type defined in one package is used from a different module (e.g., <code>cli/doctor</code> importing a type from <code>cli/notify</code>), the type has crossed its module boundary. Cross-cutting types belong in <code>internal/entity/</code> for discoverability.</p> <p>Before:</p> <pre><code>// 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</code></pre> <p>After:</p> <pre><code>// 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</code></pre> <p>Exempt: Types inside <code>entity/</code>, <code>proto/</code>, <code>core/</code> subpackages, and <code>config/</code> packages. Same-module usage (e.g., <code>cli/doctor/cmd/</code> using <code>cli/doctor/core/</code>) is not flagged.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#type-file-convention","level":2,"title":"Type File Convention","text":"<p>Test: <code>TestTypeFileConvention</code>, <code>TestTypeFileConventionReport</code></p> <p>Exported types in <code>core/</code> subpackages should live in <code>types.go</code> (the convention from CONVENTIONS.md), not scattered across implementation files. This makes type definitions discoverable. <code>TestTypeFileConventionReport</code> generates a diagnostic summary of all type placements for triage.</p> <p>Exception: <code>entity/</code> organizes by domain (<code>task.go</code>, <code>session.go</code>), <code>proto/</code> uses <code>schema.go</code>, and <code>err/</code> packages colocate error types with their domain context.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-yaml-linkage","level":2,"title":"DescKey / YAML Linkage","text":"<p>Test: <code>TestDescKeyYAMLLinkage</code></p> <p>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.</p> <p>Fix for orphan YAML key: Delete the YAML entry, or add the corresponding <code>DescKey</code> constant in <code>config/embed/{text,cmd,flag}/</code>.</p> <p>Fix for orphan DescKey: Delete the constant, or add the corresponding entry in the YAML file under <code>internal/assets/commands/text/</code>, <code>cmd/</code>, or <code>flag/</code>.</p> <p>If the orphan YAML entry was once valid but the feature was removed, move the YAML entry to a <code>.dead</code> file in <code>quarantine/deadcode/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#package-doc-quality","level":2,"title":"Package Doc Quality","text":"<p>Test: <code>TestPackageDocQuality</code></p> <p>Every package under <code>internal/</code> must have a <code>doc.go</code> with a meaningful package doc comment (at least 8 lines of real content). One-liners and file-list patterns (<code>// - foo.go</code>, <code>// Source files:</code>) are flagged because they drift as files change.</p> <p>Template:</p> <pre><code>// / 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</code></pre>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-regex-compilation","level":2,"title":"Inline Regex Compilation","text":"<p>Test: <code>TestNoInlineRegexpCompile</code></p> <p><code>regexp.MustCompile</code> and <code>regexp.Compile</code> inside function bodies recompile the pattern on every call. Compiled patterns belong at package level.</p> <p>Before:</p> <pre><code>func parse(s string) bool {\n re := regexp.MustCompile(`\\d{4}-\\d{2}-\\d{2}`)\n return re.MatchString(s)\n}\n</code></pre> <p>After:</p> <pre><code>// 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</code></pre> <p>Rule: All compiled regexes live in <code>internal/config/regex/</code> as package-level <code>var</code> declarations. Two tests enforce this: <code>TestNoInlineRegexpCompile</code> catches function-body compilation, and <code>TestNoRegexpOutsideRegexPkg</code> catches package-level compilation outside <code>config/regex/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#doc-comments","level":2,"title":"Doc Comments","text":"<p>Test: <code>TestDocComments</code></p> <p>All functions (exported and unexported), structs, and package-level variables must have a doc comment. Config packages allow group doc comments for <code>const</code> blocks.</p> <p>Before:</p> <pre><code>func buildIndex(entries []Entry) map[string]int {\n</code></pre> <p>After:</p> <pre><code>// 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</code></pre> <p>Rule: Every function, struct, and package-level <code>var</code> gets a doc comment in godoc format. Functions include <code>Parameters:</code> and <code>Returns:</code> sections. Structs with 2+ fields document every field. See CONVENTIONS.md for the full template.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#line-length","level":2,"title":"Line Length","text":"<p>Test: <code>TestLineLength</code></p> <p>Lines in non-test Go files must not exceed 80 characters. This is a hard check, not a suggestion.</p> <p>Before:</p> <pre><code>_ = trace.Record(fmt.Sprintf(cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum), state.Dir())\n</code></pre> <p>After:</p> <pre><code>ref := fmt.Sprintf(\n cfgTrace.RefFormat, cfgTrace.RefTypeTask, matchedNum,\n)\n_ = trace.Record(ref, state.Dir())\n</code></pre> <p>Rule: Break at natural points: function arguments, struct fields, chained calls. Long strings (URLs, struct tags) are the rare acceptable exception.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#literal-whitespace","level":2,"title":"Literal Whitespace","text":"<p>Test: <code>TestNoLiteralWhitespace</code></p> <p>Bare whitespace string and byte literals (<code>\"\\n\"</code>, <code>\"\\r\\n\"</code>, <code>\"\\t\"</code>) must not appear outside <code>internal/config/token/</code>. All other packages use the token constants.</p> <p>Before:</p> <pre><code>output := strings.Join(lines, \"\\n\")\n</code></pre> <p>After:</p> <pre><code>output := strings.Join(lines, token.Newline)\n</code></pre> <p>Rule: Whitespace literals are defined once in <code>internal/config/token/</code>. Use <code>token.Newline</code>, <code>token.Tab</code>, <code>token.CRLF</code>, etc.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#magic-numeric-values","level":2,"title":"Magic Numeric Values","text":"<p>Test: <code>TestNoMagicValues</code></p> <p>Numeric literals in function bodies need constants, with narrow exceptions.</p> <p>Before:</p> <pre><code>if len(entries) > 100 {\n entries = entries[:100]\n}\n</code></pre> <p>After:</p> <pre><code>if len(entries) > config.MaxEntries {\n entries = entries[:config.MaxEntries]\n}\n</code></pre> <p>Exempt: <code>0</code>, <code>1</code>, <code>-1</code>, <code>2</code>-<code>10</code>, strconv radix/bitsize args (<code>10</code>, <code>32</code>, <code>64</code> in <code>strconv.Parse*</code>/<code>Format*</code>), octal permissions (caught separately by <code>TestNoRawPermissions</code>), and <code>const</code>/<code>var</code> definition sites.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#inline-separators","level":2,"title":"Inline Separators","text":"<p>Test: <code>TestNoInlineSeparators</code></p> <p><code>strings.Join</code> calls must use token constants for their separator argument, not string literals.</p> <p>Before:</p> <pre><code>result := strings.Join(parts, \", \")\n</code></pre> <p>After:</p> <pre><code>result := strings.Join(parts, token.CommaSep)\n</code></pre> <p>Rule: Separator strings live in <code>internal/config/token/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stuttery-function-names","level":2,"title":"Stuttery Function Names","text":"<p>Test: <code>TestNoStutteryFunctions</code></p> <p>Function names must not redundantly include their package name as a PascalCase word boundary. Go callers already write <code>pkg.Function</code>, so <code>pkg.PkgFunction</code> stutters.</p> <p>Before:</p> <pre><code>// In package write\nfunc WriteJournal(cmd *cobra.Command, ...) {\n</code></pre> <p>After:</p> <pre><code>// In package write\nfunc Journal(cmd *cobra.Command, ...) {\n</code></pre> <p>Exempt: Identity functions like <code>write.Write</code> / <code>write.write</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#predicate-naming-no-ishascan-prefix","level":2,"title":"Predicate Naming (No <code>Is</code>/<code>Has</code>/<code>Can</code> Prefix)","text":"<p>Test: None (manual review convention)</p> <p>Exported methods that return <code>bool</code> must not use <code>Is</code>, <code>Has</code>, or <code>Can</code> prefixes. The predicate reads more naturally without them, especially at call sites where the package name provides context.</p> <p>Before:</p> <pre><code>func IsCompleted(t *Task) bool { ... }\nfunc HasChildren(n *Node) bool { ... }\nfunc IsExemptPackage(path string) bool { ... }\n</code></pre> <p>After:</p> <pre><code>func Completed(t *Task) bool { ... }\nfunc Children(n *Node) bool { ... } // or: ChildCount > 0\nfunc ExemptPackage(path string) bool { ... }\n</code></pre> <p>Rule: Drop the prefix. Private helpers may use prefixes when it reads more naturally (<code>isValid</code> in a local context is fine). This convention applies to exported methods and package-level functions. See CONVENTIONS.md \"Predicates\" section.</p> <p>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.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#mixed-visibility","level":2,"title":"Mixed Visibility","text":"<p>Test: <code>TestNoMixedVisibility</code></p> <p>Files with exported functions must not also contain unexported functions. Public API and private helpers live in separate files.</p> <p>Before:</p> <pre><code>load.go\n func Load() { ... } // exported\n func parseHeader() { ... } // unexported, violation\n</code></pre> <p>After:</p> <pre><code>load.go\n func Load() { ... } // exported only\nparse.go\n func parseHeader() { ... } // private helper\n</code></pre> <p>Exempt: Files with exactly one function, <code>doc.go</code>, test files.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#stray-errgo-files","level":2,"title":"Stray Err.Go Files","text":"<p>Test: <code>TestNoStrayErrFiles</code></p> <p><code>err.go</code> files must only exist under <code>internal/err/</code>. Error constructors anywhere else create a broken-window pattern where contributors add local error definitions when they see a local <code>err.go</code>.</p> <p>Fix: Move the error constructor to <code>internal/err/<domain>/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#cli-cmd-structure","level":2,"title":"CLI Cmd Structure","text":"<p>Test: <code>TestCLICmdStructure</code></p> <p>Each <code>cmd/$sub/</code> directory under <code>internal/cli/</code> may contain only <code>cmd.go</code>, <code>run.go</code>, <code>doc.go</code>, and test files. Extra <code>.go</code> files (helpers, output formatters, types) belong in the corresponding <code>core/</code> subpackage.</p> <p>Before:</p> <pre><code>internal/cli/doctor/cmd/root/\n cmd.go\n run.go\n format.go # violation: helper in cmd dir\n</code></pre> <p>After:</p> <pre><code>internal/cli/doctor/cmd/root/\n cmd.go\n run.go\ninternal/cli/doctor/core/format/\n format.go\n doc.go\n</code></pre>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#desckey-namespace","level":2,"title":"DescKey Namespace","text":"<p>Test: <code>TestUseConstantsOnlyInCobraUse</code>, <code>TestDescKeyOnlyInLookupCalls</code>, <code>TestNoWrongNamespaceLookup</code></p> <p>Three tests enforce DescKey/Use constant discipline:</p> <ol> <li><code>Use*</code> constants appear only in cobra <code>Use:</code> struct field assignments, never as arguments to <code>desc.Text()</code> or elsewhere.</li> <li><code>DescKey*</code> constants are passed only to <code>assets.CommandDesc()</code>, <code>assets.FlagDesc()</code>, or <code>desc.Text()</code>, never to cobra <code>Use:</code>.</li> <li>No cross-namespace lookups: <code>TextDescKey</code> must not be passed to <code>CommandDesc()</code>, <code>FlagDescKey</code> must not be passed to <code>Text()</code>, etc.</li> </ol>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#yaml-examples-registry-linkage","level":2,"title":"YAML Examples / Registry Linkage","text":"<p>Test: <code>TestExamplesYAMLLinkage</code>, <code>TestRegistryYAMLLinkage</code></p> <p>Every key in <code>examples.yaml</code> and <code>registry.yaml</code> must match a known entry type constant. Prevents orphan entries that are never rendered.</p> <p>Fix: Delete the orphan YAML entry, or add the corresponding constant in <code>config/entry/</code>.</p>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#other-enforced-patterns","level":2,"title":"Other Enforced Patterns","text":"<p>These tests follow the same fix approach: extract the operation to its designated package:</p> Test Violation Fix <code>TestNoNakedErrors</code> <code>fmt.Errorf</code>/<code>errors.New</code> outside <code>internal/err/</code> Add error constructor to <code>internal/err/<domain>/</code> <code>TestNoRawFileIO</code> Direct <code>os.ReadFile</code>, <code>os.Create</code>, etc. Use <code>io.SafeReadFile</code>, <code>io.SafeWriteFile</code>, etc. <code>TestNoRawLogging</code> Direct <code>fmt.Fprintf(os.Stderr, ...)</code> Use <code>log/warn.Warn()</code> or <code>log/event.Append()</code> <code>TestNoExecOutsideExecPkg</code> <code>exec.Command</code> outside <code>internal/exec/</code> Add command to <code>internal/exec/<domain>/</code> <code>TestNoCmdPrintOutsideWrite</code> <code>cmd.Print*</code> outside <code>internal/write/</code> Add output helper to <code>internal/write/<domain>/</code> <code>TestNoRawPermissions</code> Octal literals (<code>0644</code>, <code>0755</code>) Use <code>config/fs.PermFile</code>, <code>config/fs.PermExec</code>, etc. <code>TestNoErrorsAs</code> <code>errors.As()</code> Use <code>errors.AsType()</code> (generic, Go 1.23+) <code>TestNoStringConcatPaths</code> <code>dir + \"/\" + file</code> Use <code>filepath.Join(dir, file)</code>","path":["Reference","Code Conventions"],"tags":[]},{"location":"reference/audit-conventions/#general-fix-workflow","level":2,"title":"General Fix Workflow","text":"<p>When an audit test fails:</p> <ol> <li>Read the error message. It includes <code>file:line</code> and a description of the violation.</li> <li>Find the matching section above. The test name maps directly to a section.</li> <li>Apply the pattern. Most fixes are mechanical: extract to the right package, rename a variable, or replace a literal with a constant.</li> <li>Run <code>make test</code> before committing. Audit tests run as part of <code>go test ./internal/audit/</code>.</li> <li>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).</li> </ol>","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":"<p>Many tools help AI think.</p> <p><code>ctx</code> helps AI remember.</p> <ul> <li>Not by storing thoughts,</li> <li>but by preserving intent.</li> </ul>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#how-ctx-differs-from-similar-tools","level":2,"title":"How <code>ctx</code> Differs from Similar Tools","text":"<p>There are many tools in the AI ecosystem that touch parts of the context problem:</p> <ul> <li>Some manage prompts. </li> <li>Some retrieve data. </li> <li>Some provide runtime context objects. </li> <li>Some offer enterprise platforms.</li> </ul> <p><code>ctx</code> focuses on a different layer entirely.</p> <p>This page explains where <code>ctx</code> fits, and where it intentionally does not.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#the-core-distinction","level":2,"title":"The Core Distinction","text":"<p>Most tools treat context as input.</p> <p><code>ctx</code> treats context as infrastructure.</p> <p>That single difference explains nearly all of <code>ctx</code>'s design choices.</p> Question Most tools <code>ctx</code> 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":"<p>Examples include:</p> <ul> <li>prompt templates;</li> <li>reusable system prompts;</li> <li>prompt libraries;</li> <li>prompt versioning tools.</li> </ul> <p>These tools help you start a session.</p> <p>They do not help you continue one.</p> <p>Prompt tools:</p> <ul> <li>inject text at session start;</li> <li>are ephemeral by design;</li> <li>do not evolve with the project.</li> </ul> <p><code>ctx</code>:</p> <ul> <li>persists knowledge over time;</li> <li>accumulates decisions and learnings;</li> <li>makes the context part of the repository itself.</li> </ul> <p>Prompt tooling and <code>ctx</code> are complementary; not competing. Yet, they operate in different layers.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#retrieval-augmented-generation-rag","level":2,"title":"Retrieval-Augmented Generation (RAG)","text":"<p>RAG systems typically:</p> <ul> <li>index documents</li> <li>embed text</li> <li>retrieve chunks dynamically at runtime</li> </ul> <p>They are excellent for:</p> <ul> <li>large knowledge bases</li> <li>static documentation</li> <li>reference material</li> </ul> <p>RAG answers questions like:</p> <p>\"What information might be relevant right now?\"</p> <p><code>ctx</code> answers a different question:</p> <p>\"What have we already decided, learned, or committed to?\"</p> <p>Here are some key differences:</p> RAG <code>ctx</code> Statistical relevance Intentional relevance Embedding-based File-based Opaque retrieval Explicit structure Runtime query Persistent memory <p><code>ctx</code> does not replace RAG. Instead, it defines a persistent context layer that RAG can optionally augment.</p> <p>RAG belongs to the data plane; <code>ctx</code> defines the context control plane.</p> <p>It focuses on project memory, not knowledge search.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#agent-frameworks","level":2,"title":"Agent Frameworks","text":"<p>Agent frameworks often provide:</p> <ul> <li>task loops</li> <li>tool orchestration</li> <li>planner/executor patterns</li> <li>autonomous iteration</li> </ul> <p>These systems are powerful, but they typically assume that:</p> <ul> <li>memory is external</li> <li>context is injected</li> <li>state is transient</li> </ul> <p>Agent frameworks answer:</p> <p>\"How should the agent act?\"</p> <p><code>ctx</code> answers:</p> <p>\"What should the agent remember?\"</p> <p>Without persistent context, agents tend to:</p> <ul> <li>rediscover decisions</li> <li>repeat mistakes</li> <li>lose architectural intent</li> </ul> <p>This is why <code>ctx</code> pairs well with autonomous loop workflows:</p> <ul> <li>The loop provides iteration</li> <li><code>ctx</code> provides continuity</li> </ul> <p>Together, loops become cumulative instead of forgetful.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#sdk-level-context-objects","level":2,"title":"SDK-Level Context Objects","text":"<p>Some SDKs expose \"context\" objects that exist:</p> <ul> <li>inside a process</li> <li>during a request</li> <li>for the lifetime of a call chain</li> </ul> <p>These are extremely useful and completely different.</p> <p>SDK context objects:</p> <ul> <li>are in-memory</li> <li>disappear when the process ends</li> <li>are not shared across sessions</li> </ul> <p><code>ctx</code>:</p> <ul> <li>survives process restarts</li> <li>survives new chats</li> <li>survives new days</li> </ul> <p>They share a name, not a purpose.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#enterprise-context-platforms","level":2,"title":"Enterprise Context Platforms","text":"<p>Enterprise platforms often provide:</p> <ul> <li>centralized context services</li> <li>dashboards</li> <li>access control</li> <li>organizational knowledge layers</li> </ul> <p>These tools are designed for:</p> <ul> <li>teams</li> <li>governance</li> <li>compliance</li> <li>managed environments</li> </ul> <p><code>ctx</code> is intentionally:</p> <ul> <li>local-first: context lives next to your code, not behind a service boundary.</li> <li>file-based: everything important is a Markdown file you can read, diff, grep, and version-control.</li> <li>single-binary core: the context persistence path (<code>init</code>, <code>add</code>, <code>agent</code>, <code>status</code>, <code>drift</code>, <code>load</code>, <code>sync</code>, <code>compact</code>, <code>task</code>, <code>decision</code>, <code>learning</code>, and their siblings) is a single Go binary with no required runtime dependencies. Optional integrations (<code>ctx trace</code> (needs <code>git</code>), <code>ctx serve</code> (needs <code>zensical</code>), the <code>ctx</code> Hub (needs a running hub), Claude Code plugin (needs <code>claude</code>)) are opt-in and each declares its dependency explicitly.</li> <li>CLI-driven: every feature is reachable from the command line and scriptable.</li> <li>developer-controlled: no auto-updating cloud service, no telemetry, no account to sign up for.</li> </ul> <p>The core <code>ctx</code> binary does not require:</p> <ul> <li>a server</li> <li>a database</li> <li>an account</li> <li>a SaaS backend</li> <li>network connectivity (for core operations)</li> </ul> <p><code>ctx</code> optimizes for individual and small-team workflows where context should live next to code; not behind a service boundary.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#specific-tool-comparisons","level":2,"title":"Specific Tool Comparisons","text":"<p>Users often evaluate <code>ctx</code> against specific tools they already use. These comparisons clarify where responsibilities overlap, where they diverge, and where the tools are genuinely complementary.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#claude-code-memory-anthropic-auto-memory","level":3,"title":"Claude Code Memory / Anthropic Auto-Memory","text":"<p>Anthropic's auto-memory is tool-managed memory (L2): the model decides what to remember, stores it automatically, and retrieves it implicitly. <code>ctx</code> is system memory (L3): humans and agents explicitly curate decisions, learnings, and tasks in inspectable files.</p> <p>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. <code>ctx</code> files are plain Markdown in your repository, visible in diffs and code review.</p> <p>The two are complementary. <code>ctx</code> 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.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cursorrules-clauderules","level":3,"title":".Cursorrules / .Claude/rules","text":"<p>Static rule files (<code>.cursorrules</code>, <code>.claude/rules/</code>) declare conventions: coding style, forbidden patterns, preferred libraries. They are effective for what to do and load automatically at session start.</p> <p><code>ctx</code> 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, <code>ctx</code> context accumulates - each session can add to it, and token budgeting ensures only the most relevant context is injected.</p> <p>Use rule files for static conventions. Use <code>ctx</code> for evolving project memory.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#aider-read-watch","level":3,"title":"Aider <code>--read</code> / <code>--watch</code>","text":"<p>Aider's <code>--read</code> flag injects file contents at session start; <code>--watch</code> reloads them on change. The concept is similar to <code>ctx</code>'s \"load\" step: make the agent aware of specific files.</p> <p>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. <code>ctx</code> provides the full lifecycle: load, accumulate, persist, and budget.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#copilot-workspace","level":3,"title":"Copilot @Workspace","text":"<p>GitHub Copilot's <code>@workspace</code> performs workspace-wide code search. It answers \"what code exists?\" - finding function definitions, usages, and file structure across the repository.</p> <p><code>ctx</code> answers a different question: \"what did we decide?\" It stores architectural intent, not code indices. Copilot's workspace search and <code>ctx</code>'s project memory are orthogonal; one finds code, the other preserves the reasoning behind it.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#cline-memory","level":3,"title":"Cline Memory","text":"<p>Cline's memory bank stores session context within the Cline extension. The motivation is similar to <code>ctx</code>: help the agent remember across sessions.</p> <p>The key difference is portability. Cline memory is tied to Cline - it does not transfer to Claude Code, Cursor, Aider, or any other tool. <code>ctx</code> is tool-agnostic: context lives in plain files that any editor, agent, or script can read. Switching tools does not mean losing memory.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-a-good-fit","level":2,"title":"When <code>ctx</code> Is a Good Fit","text":"<p><code>ctx</code> works best when:</p> <ul> <li>you want AI work to compound over time;</li> <li>architectural decisions matter;</li> <li>context must be inspectable;</li> <li>humans and AI must share the same source of truth;</li> <li>Git history should include why, not just what.</li> </ul>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#when-ctx-is-not-the-right-tool","level":2,"title":"When <code>ctx</code> Is Not the Right Tool","text":"<p><code>ctx</code> is probably not what you want if:</p> <ul> <li>you only need one-off prompts;</li> <li>you rely exclusively on RAG;</li> <li>you want autonomous agents without a human-readable state;</li> <li>you require centralized enterprise control;</li> <li>you want black-box memory systems,</li> </ul> <p>These are valid goals; just different ones.</p>","path":["Reference","Tool Ecosystem"],"tags":[]},{"location":"reference/comparison/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>You Can't Import Expertise: why project-specific context matters more than generic best practices</li> </ul>","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":"<p>These are the properties that must hold for any valid <code>ctx</code> implementation.</p> <ul> <li>These are not features.</li> <li>These are constraints.</li> </ul> <p>A change that violates an invariant is a category error, not an improvement.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#cognitive-state-tiers","level":2,"title":"Cognitive State Tiers","text":"<p><code>ctx</code> distinguishes between three forms of state:</p> <ul> <li>Authoritative state: Versioned, inspectable artifacts that define intent and survive time.</li> <li>Delivery views: Deterministic assemblies of the authoritative state for a specific budget or workflow.</li> <li>Ephemeral working state: Local, transient, or sensitive data that assists interaction but does not define system truth.</li> </ul> <p>The invariants below apply primarily to the authoritative cognitive state.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#1-cognitive-state-is-explicit","level":2,"title":"1. Cognitive State Is Explicit","text":"<p>All authoritative context lives in artifacts that can be inspected, reviewed, and versioned.</p> <p>If something is important, it must exist as a file: Not only in a prompt, a chat, or a model's hidden memory.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#2-assembly-is-reproducible","level":2,"title":"2. Assembly Is Reproducible","text":"<p>Given the same:</p> <ul> <li>repository state,</li> <li>configuration,</li> <li>and inputs,</li> </ul> <p>context assembly produces the same result.</p> <p>Heuristics may rank or filter for delivery under constraints.</p> <p>They do not alter the authoritative state.</p>","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":"<p>The authoritative cognitive state must be stored in formats that a human can:</p> <ul> <li>read,</li> <li>diff,</li> <li>review,</li> <li>and edit directly.</li> </ul> <p>Sensitive working memory may be encrypted at rest. However, encryption must not become the only representation of authoritative knowledge.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#4-artifacts-outlive-sessions","level":2,"title":"4. Artifacts Outlive Sessions","text":"<p>Sessions are transient.</p> <p>Knowledge persists.</p> <p>Reasoning, decisions, and outcomes must remain available after the interaction that produced them has ended.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#5-authority-is-user-defined","level":2,"title":"5. Authority Is User-Defined","text":"<p>What enters the authoritative context is an explicit human decision.</p> <p>Models may suggest.</p> <p>Automation may assist.</p> <p>Selection is never implicit.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#6-operation-is-local-first","level":2,"title":"6. Operation Is Local-First","text":"<p>The core system must function without requiring network access or a remote service.</p> <p>External systems may extend <code>ctx</code>.</p> <p>They must not be required for its operation.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#7-versioning-is-the-memory-model","level":2,"title":"7. Versioning Is the Memory Model","text":"<p>The evolution of the authoritative cognitive state must be:</p> <ul> <li>preserved,</li> <li>inspectable,</li> <li>and branchable.</li> </ul> <p>Ephemeral and sensitive working state may use different retention and diff strategies by design.</p> <p>Understanding includes understanding how we arrived here.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#8-structure-enables-scale","level":2,"title":"8. Structure Enables Scale","text":"<p>Unstructured accumulation is not memory.</p> <p>Authoritative cognitive state must have a defined layout that:</p> <ul> <li>communicates intent,</li> <li>supports navigation,</li> <li>and prevents drift.</li> </ul>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#9-verification-is-the-scoreboard","level":2,"title":"9. Verification Is the Scoreboard","text":"<p>Claims without recorded outcomes are noise.</p> <p>Reality (observed and captured) is the only signal that compounds.</p> <p>This invariant defines a required direction:</p> <p>The authoritative state must be able to record expectation and result.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#10-capture-once-reuse-indefinitely","level":2,"title":"10. Capture Once, Reuse Indefinitely","text":"<p>Work that has already produced understanding must not be re-derived from scratch.</p> <p>Explored paths, rejected options, and validated conclusions are permanent assets.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#11-policies-are-encoded-not-remembered","level":2,"title":"11. Policies Are Encoded, Not Remembered","text":"<p>Alignment must not depend on recall or goodwill.</p> <p>Constraints that matter must exist in machine-readable form and participate in context assembly.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#12-the-system-explains-itself","level":2,"title":"12. The System Explains Itself","text":"<p>From the repository state alone it must be possible to determine:</p> <ul> <li>what was authoritative,</li> <li>what constraints applied.</li> </ul> <p>Delivery views may be optimized.</p> <p>They must not become the only explanation.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#non-goals","level":1,"title":"Non-Goals","text":"<p>To avoid category errors, <code>ctx</code> does not attempt to be:</p> <ul> <li>a skill,</li> <li>a prompt management tool,</li> <li>a chat history viewer,</li> <li>an autonomous agent runtime,</li> <li>a vector database,</li> <li>a hosted memory service.</li> </ul> <p>Such systems may integrate with <code>ctx</code>.</p> <p>They do not define it.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#implications-for-contributions","level":1,"title":"Implications for Contributions","text":"<p>Valid contributions:</p> <ul> <li>strengthen an invariant,</li> <li>reduce the cost of maintaining an invariant,</li> <li>or extend the system without violating invariants.</li> </ul> <p>Invalid contributions:</p> <ul> <li>introduce hidden authoritative state,</li> <li>replace reproducible assembly with non-reproducible behavior,</li> <li>make core operation depend on external services,</li> <li>reduce human inspectability of authoritative state,</li> <li>or bypass explicit user authority over what becomes authoritative.</li> </ul>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/design-invariants/#the-contract","level":1,"title":"The Contract","text":"<p>Everything else (commands, skills, layouts, integrations, optimizations) is an implementation detail.</p> <p>These invariants are the system.</p>","path":["Reference","Invariants"],"tags":[]},{"location":"reference/dream-executor-contract/","level":1,"title":"Dream Executor Contract","text":"<p>The ctx-dream executor is the thing that actually runs an out-of-band dream pass: it reads <code>ideas/</code>, classifies and grounds each idea, and writes proposals into the <code>dreams/</code> notebook. ctx ships cron <code>claude -p</code> as the reference executor (see Run the Dream), but the executor is a documented contract, not a hardcoded assumption — any harness (a different AI CLI, a raw model-API loop, a CI runner) can implement it.</p> <p>This page is the contract. If you are wiring the dream into a non-Claude- Code harness, implement everything below.</p>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#what-ctx-owns-executor-agnostic","level":2,"title":"What ctx owns (executor-agnostic)","text":"<p>The Go package <code>internal/dream</code> owns the parts that must behave identically regardless of executor:</p> <ul> <li>The data contract — the proposal schema, the per-source state record (<code>dreams/state.json</code>), and the append-only ledger (<code>dreams/ledger.md</code>).</li> <li>Delta selection — the hash-based \"discipline clock\" that decides which ideas are new or changed since last triage.</li> <li>The two structural guards as callable logic — <code>WriteScope</code> and <code>Leak</code>.</li> </ul> <p>Your executor must use these, not reimplement them.</p>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#what-an-executor-must-do","level":2,"title":"What an executor must do","text":"<ol> <li>Run one bounded pass. Honor the <code>max</code> ideas and step/token <code>budget</code> from the <code>dream:</code> <code>.ctxrc</code> section. Read only the idea delta.</li> <li>Propose, never act, never touch canonical. The pass writes provenance-bearing proposals as a single JSON array to <code>dreams/<ts>/proposals.json</code> (the run directory is handed to the executor) and nothing else. It must not archive/merge/promote/tag ideas and must never write the five canonical files. (Acting on proposals is the human's <code>/ctx-serendipity</code> step, out of band from the pass.)</li> <li>Enforce the three guards structurally — not via prompt text. This is the load-bearing portability requirement:</li> <li>Write-scope — a write is allowed only under <code>dreams/</code> during a pass.</li> <li>Don't-leak — every write target must be gitignored (<code>git check-ignore</code>); a write that resolves to a tracked path is refused.</li> <li>Sources-as-data — idea text is wrapped as untrusted and is never executed as instructions. The Claude Code reference enforces write-scope and don't-leak with a PreToolUse hook (<code>guard.sh</code>) and sources-as-data via the skill's <code><<<UNTRUSTED>>></code> wrapping. A harness without hook interception must call the same checks in its own tool executor before every write — that is where <code>internal/dream.WriteScope</code> and <code>internal/dream.Leak</code> move. A prompt instruction is not enforcement.</li> <li>Fail loud. On auth failure, a missing executor binary, or a PATH/env problem, write a failmark (<code>dreams/.failed</code>) and exit non-zero. Never silently no-op — a dream that quietly does nothing is indistinguishable from a healthy one that found nothing, and that ambiguity rots trust.</li> <li>Serialize passes. Take the <code>dreams/.lock</code> before a pass; if it is held, exit cleanly. A review in progress reads a committed proposal set and is unaffected.</li> <li>Defer on a dirty tree. If the working tree under the dream's paths is dirty, defer the pass to avoid torn reads.</li> </ol>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#the-proposal-contract","level":2,"title":"The proposal contract","text":"<p>Proposals are a JSON array in <code>dreams/<ts>/proposals.json</code>, each element matching the <code>internal/dream.Proposal</code> schema:</p> <pre><code>{\n \"id\": \"<stable-id>\",\n \"targets\": [\"ideas/<file>.md\"],\n \"status\": \"implemented|duplicate|meritorious|sidenote|blog-candidate\",\n \"action\": \"archive|merge|promote|mark-blog|keep\",\n \"evidence\": \"<commit / spec path / near-neighbor + why>\",\n \"confidence\": \"high|med|low\",\n \"rationale\": \"<one-line why>\"\n}\n</code></pre> <p><code>id</code> must be stable (so a re-run does not duplicate an already-decided proposal, and so v2 canonical supersession is not foreclosed). An executor must not re-emit a proposal whose <code>id</code> already appears in <code>dreams/ledger.md</code> unless the source content changed.</p>","path":["Reference","Dream Executor Contract"],"tags":[]},{"location":"reference/dream-executor-contract/#why-the-contract-not-just-cron","level":2,"title":"Why the contract, not just cron","text":"<p>The ctx dev team is multi-tool, and ctx's users are more so. Hardcoding \"the dream is cron + Claude Code\" would exclude everyone else and couple a memory feature to one harness. Keeping the cognition in a skill and the invariants in <code>internal/dream</code> means the same dream — same guards, same ledger, same proposals — runs anywhere the contract is met. See <code>specs/ctx-dream.md</code> and the decision record in <code>.context/DECISIONS.md</code> (\"ctx-dream executor is a documented contract\").</p>","path":["Reference","Dream Executor Contract"],"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 <code>ctx</code> Scratchpad?","text":"<p>A one-liner scratchpad, encrypted at rest, synced via <code>git</code>.</p> <p>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.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#encrypted-by-default","level":2,"title":"Encrypted by Default","text":"<p>Scratchpad entries are encrypted with <code>AES-256-GCM</code> before touching the disk.</p> Component Path Git status Encryption key <code>~/.ctx/.ctx.key</code> User-level, <code>0600</code> permissions Encrypted data <code>.context/scratchpad.enc</code> Committed <p>The key is generated automatically during <code>ctx init</code> (256-bit via <code>crypto/rand</code>) and stored at <code>~/.ctx/.ctx.key</code>. One key per machine, shared across all projects.</p> <p>The ciphertext format is <code>[12-byte nonce][ciphertext+tag]</code>. No external dependencies: Go stdlib only.</p> <p>Because the key is <code>.gitignore</code>d and the data is committed, you get:</p> <ul> <li>At-rest encryption: the <code>.enc</code> file is opaque without the key</li> <li>Git sync: push/pull the encrypted file like any other tracked file</li> <li>Key separation: the key never leaves the machine unless you copy it</li> </ul>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#commands","level":2,"title":"Commands","text":"Command Purpose <code>ctx pad</code> List all entries (numbered 1-based) <code>ctx pad show N</code> Output raw text of entry N (no prefix, pipe-friendly) <code>ctx pad add \"text\"</code> Append a new entry <code>ctx pad rm ID [ID...]</code> Remove entries by stable ID (supports ranges: <code>3-5</code>) <code>ctx pad edit N \"text\"</code> Replace entry N with new text <code>ctx pad edit N --append \"text\"</code> Append text to the end of entry N <code>ctx pad edit N --prepend \"text\"</code> Prepend text to the beginning of entry N <code>ctx pad edit N --tag tagname</code> Add a tag to entry N <code>ctx pad add TEXT --file PATH</code> Ingest a file as a blob entry (TEXT is the label) <code>ctx pad show N --out PATH</code> Write decoded blob content to a file <code>ctx pad normalize</code> Reassign entry IDs as 1..N <code>ctx pad mv N M</code> Move entry from position N to position M <code>ctx pad resolve</code> Show both sides of a merge conflict for resolution <code>ctx pad import FILE</code> Bulk-import lines from a file (or stdin with <code>-</code>) <code>ctx pad import --blob DIR</code> Import directory files as blob entries <code>ctx pad export [DIR]</code> Export all blob entries to a directory as files <code>ctx pad merge FILE...</code> Merge entries from other scratchpad files into current <code>ctx pad --tag TAG</code> List entries filtered by tag (prefix with <code>~</code> to exclude) <code>ctx pad tags</code> List all tags with counts <code>ctx pad tags --json</code> List all tags with counts as JSON <p>All commands decrypt on read, operate on plaintext in memory, and re-encrypt on write. The key file is never printed to stdout.</p> <p>For blob entries, <code>--append</code>, <code>--prepend</code>, and <code>--tag</code> modify the label while preserving the blob data.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#examples","level":3,"title":"Examples","text":"<pre><code># 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</code></pre>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#tags","level":2,"title":"Tags","text":"<p>Entries can contain <code>#word</code> tags for lightweight categorization. Tags are convention-based: any <code>#word</code> token in an entry's text is a tag. No special syntax to add or remove them; use the existing <code>add</code> and <code>edit</code> commands.</p> <pre><code># 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</code></pre> <p>Entry IDs are stable; they don't shift when other entries are deleted, so <code>ctx pad rm 3</code> always targets the same entry. Use <code>ctx pad normalize</code> to reassign IDs as 1..N if gaps bother you. Tags are case-sensitive and support letters, digits, hyphens, and underscores (<code>#high-priority</code>, <code>#v2</code>, <code>#my_tag</code>).</p> <p>For blob entries, tags are extracted from the label only.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#bulk-import-and-export","level":2,"title":"Bulk Import and Export","text":"<p>Import lines from a file in bulk (each non-empty line becomes an entry):</p> <pre><code># Import from a file\nctx pad import notes.txt\n\n# Import from stdin\ngrep TODO *.go | ctx pad import -\n</code></pre> <p>Export all blob entries to a directory as files:</p> <pre><code># 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</code></pre>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#merging-scratchpads","level":2,"title":"Merging Scratchpads","text":"<p>Combine entries from other scratchpad files into your current pad. Useful when merging work from parallel worktrees, other machines, or teammates:</p> <pre><code># 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</code></pre> <p>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.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#file-blobs","level":2,"title":"File Blobs","text":"<p>The scratchpad can store small files (up to 64 KB) as blob entries. Files are base64-encoded and stored with a human-readable label.</p> <pre><code># 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</code></pre> <p>Blob entries are encrypted identically to text entries. The internal format is <code>label:::base64data</code>: You never need to construct this manually.</p> Constraint Value Max file size (pre-encoding) 64 KB Storage format <code>label:::base64(content)</code> Display <code>label [BLOB]</code> in listings <p>When Should You Use Blobs</p> <p>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.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#using-with-ai","level":2,"title":"Using with AI","text":"<p>Use Natural Language</p> <p>As in many <code>ctx</code> features, the <code>ctx</code> scratchpad can also be used with natural langauge. You don't have to memorize the CLI commands.</p> <p>CLI gives you \"precision\", whereas natural language gives you flow.</p> <p>The <code>/ctx-pad</code> skill maps natural language to <code>ctx pad</code> commands. You don't need to remember the syntax:</p> You say What happens \"jot down: check DNS after deploy\" <code>ctx pad add \"check DNS after deploy\"</code> \"show my scratchpad\" <code>ctx pad</code> \"delete the third entry\" <code>ctx pad rm 3</code> \"update entry 2 to include the new endpoint\" <code>ctx pad edit 2 \"...\"</code> \"move entry 4 to the top\" <code>ctx pad mv 4 1</code> \"import my notes from notes.txt\" <code>ctx pad import notes.txt</code> \"export all blobs to ./backup\" <code>ctx pad export ./backup</code> \"merge the scratchpad from the worktree\" <code>ctx pad merge worktree/.context/scratchpad.enc</code> <p>The skill handles the translation. You describe what you want in plain English; the agent picks the right command.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#worktrees","level":2,"title":"Worktrees","text":"<p>The encryption key lives at <code>~/.ctx/.ctx.key</code> (outside the project directory). Because all worktrees on the same machine share this path, <code>ctx pad</code> works in worktrees automatically - no special setup needed.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#key-distribution","level":2,"title":"Key Distribution","text":"<p>The encryption key (<code>~/.ctx/.ctx.key</code>) stays on the machine where it was generated. <code>ctx</code> never transmits it.</p> <p>To share the scratchpad across machines:</p> <ol> <li>Copy the key manually: <code>scp</code>, USB drive, password manager.</li> <li>Push/pull the <code>.enc</code> file via git as usual.</li> <li>Both machines can now read and write the same scratchpad.</li> </ol> <p>Never Commit the Key</p> <p>The key is <code>.gitignore</code>d by default. If you override this, anyone with repo access can decrypt your scratchpad. </p> <p>Treat the key like an SSH private key.</p> <p>See the Syncing Scratchpad Notes Across Machines recipe for a step-by-step walkthrough.</p>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#plaintext-override","level":2,"title":"Plaintext Override","text":"<p>For projects where encryption is unnecessary, disable it in <code>.ctxrc</code>:</p> <pre><code>scratchpad_encrypt: false\n</code></pre> <p>In plaintext mode:</p> <ul> <li>Entries are stored in <code>.context/scratchpad.md</code> instead of <code>.enc</code>.</li> <li>No key is generated or required.</li> <li>All <code>ctx pad</code> commands work identically.</li> <li>The file is human-readable and diffable.</li> </ul> <p>When Should You Use Plaintext</p> <p>Plaintext mode is useful for non-sensitive projects, solo work where encryption adds friction, or when you want scratchpad entries visible in <code>git diff</code>.</p>","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 <code>TASKS.md</code> Trade-offs with rationale <code>DECISIONS.md</code> Reusable lessons with context/lesson/application <code>LEARNINGS.md</code> Codified patterns and standards <code>CONVENTIONS.md</code> <p>Rule of thumb: </p> <ul> <li>If it needs structure or will be referenced months later, use a context file (i.e. <code>DECISIONS.md</code>, <code>LEARNINGS.md</code>, <code>TASKS.md</code>). </li> <li>If it is working memory for the current session or week, use the scratchpad.</li> </ul>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/scratchpad/#see-also","level":2,"title":"See Also","text":"<ul> <li>Syncing Scratchpad Notes Across Machines: Key distribution, push/pull workflow, merge conflict resolution</li> <li>Using the Scratchpad: Natural language examples, blob workflow, when to use scratchpad vs context files</li> <li>Context Files: Format and conventions for all <code>.context/</code> files</li> <li>Security: Trust model and permission hygiene</li> </ul>","path":["Reference","Scratchpad"],"tags":[]},{"location":"reference/session-journal/","level":1,"title":"Session Journal","text":"<p>Important Security Note</p> <p>Session journals contain sensitive data such as file contents, commands, API keys, internal discussions, error messages with stack traces, and more. </p> <p>The <code>.context/journal-site/</code> and <code>.context/journal-obsidian/</code> directories MUST be <code>.gitignore</code>d.</p> <ul> <li>DO NOT host your journal publicly.</li> <li>DO NOT commit your journal files to version control.</li> </ul>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#browse-your-session-history","level":2,"title":"Browse Your Session History","text":"<p><code>ctx</code>'s Session Journal turns your AI coding sessions into a browsable, searchable, and editable archive.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#quick-start","level":2,"title":"Quick Start","text":"<p>After using <code>ctx</code> for a couple of sessions, you can generate a journal site with:</p> <pre><code># Import all sessions to markdown\nctx journal import --all\n\n# Generate and serve the journal site\nctx journal site --serve\n</code></pre> <p>Then open http://localhost:8000 to browse your sessions.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#what-you-get","level":2,"title":"What You Get","text":"<p>The Session Journal gives you:</p> <ul> <li>Browsable history: Navigate through all your AI sessions by date</li> <li>Full conversations: See every message, tool use, and result</li> <li>Token usage: Track how many tokens each session consumed</li> <li>Search: Find sessions by content, project, or date</li> <li>Dark mode: Easy on the eyes for late-night archaeology</li> </ul> <p>Each session page includes the following sections:</p> 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":"<pre><code># Import new sessions and complete any whose transcript has grown\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</code></pre> <p>Imported sessions go to <code>.context/journal/</code> as editable Markdown files.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#2-generate-the-site","level":3,"title":"2. Generate the Site","text":"<pre><code># 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</code></pre> <p>The site is generated in <code>.context/journal-site/</code> by default.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#3-browse-and-search","level":3,"title":"3. Browse and Search","text":"<p>Open http://localhost:8000 after running <code>--serve</code>.</p> <ul> <li>Use the sidebar to navigate by date</li> <li>Use search (<code>/</code> key) to find specific content</li> <li>Click any session to see the full conversation</li> </ul>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#editing-sessions","level":2,"title":"Editing Sessions","text":"<p>Imported sessions are plain Markdown in <code>.context/journal/</code>. You can:</p> <ul> <li>Add summaries: Fill in the <code>## Summary</code> section</li> <li>Add notes: Insert your own commentary anywhere</li> <li>Highlight key moments: Use Markdown formatting</li> <li>Delete noise: Remove irrelevant tool outputs</li> </ul> <p>After editing, regenerate the site:</p> <pre><code>ctx journal site --serve\n</code></pre> Self-Healing by Default <p>Running <code>ctx journal import --all</code> imports new sessions and completes any whose source transcript has grown since the last import, re-rendering them up to the current end. Sessions whose source is unchanged are skipped, and hand-edited entries are detected and left untouched with a warning (your edits and enrichments are never clobbered).</p> <p><code>--regenerate</code> is an edge-case full re-render, not the routine way to update. Reach for it after a render-format change or to heal a pre-self-heal truncated entry. Conversation content is regenerated, but YAML frontmatter (topics, type, outcome, etc.) is preserved. You'll be prompted before any existing files are overwritten; add <code>-y</code> to skip the prompt.</p> <p>Use <code>--keep-frontmatter=false</code> to discard enriched frontmatter during regeneration.</p> <p>Locked entries (via <code>ctx journal lock</code>) are always skipped, regardless of flags. If you prefer to add <code>locked: true</code> to frontmatter during enrichment, run <code>ctx journal sync</code> to propagate the lock state to <code>.state.json</code>.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#large-sessions","level":2,"title":"Large Sessions","text":"<p>Sessions with many messages (200+) are automatically split into multiple parts for better browser performance. Navigation links connect the parts:</p> <pre><code>session-abc123.md (Part 1 of 3)\nsession-abc123-p2.md (Part 2 of 3)\nsession-abc123-p3.md (Part 3 of 3)\n</code></pre>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#suggestion-sessions","level":2,"title":"Suggestion Sessions","text":"<p>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.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enriching-journal-entries","level":2,"title":"Enriching Journal Entries","text":"<p>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.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#why-enrich","level":3,"title":"Why Enrich?","text":"<p>Without enrichment, you have timestamps and raw conversations. With enrichment:</p> <ul> <li>Find sessions by topic: \"Show me all auth-related sessions\"</li> <li>Filter by outcome: \"What did I abandon vs complete?\"</li> <li>Track technology usage: \"When did I last work with PostgreSQL?\"</li> <li>Identify key files: Jump directly to the files discussed</li> <li>Get summaries: Understand what happened without reading transcripts</li> </ul>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#the-frontmatter-schema","level":3,"title":"The Frontmatter Schema","text":"<p>Enriched entries begin with YAML frontmatter:</p> <pre><code>---\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</code></pre> Field Required Description <code>title</code> Yes Descriptive title (not the session slug) <code>date</code> Yes Session date (YYYY-MM-DD) <code>type</code> Yes Session type (see below) <code>outcome</code> Yes How the session ended (see below) <code>topics</code> No Subject areas discussed <code>technologies</code> No Languages, databases, frameworks <code>libraries</code> No Specific packages or libraries used <code>key_files</code> No Important files created or modified <p>Type values:</p> Type When to use <code>feature</code> Building new functionality <code>bugfix</code> Fixing broken behavior <code>refactor</code> Restructuring without behavior change <code>exploration</code> Research, learning, experimentation <code>debugging</code> Investigating issues <code>documentation</code> Writing docs, comments, README <p>Outcome values:</p> Outcome Meaning <code>completed</code> Goal achieved <code>partial</code> Some progress, work continues <code>abandoned</code> Stopped pursuing this approach <code>blocked</code> Waiting on external dependency","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-ctx-journal-enrich","level":3,"title":"Using <code>/ctx-journal-enrich</code>","text":"<p>The <code>/ctx-journal-enrich</code> skill automates enrichment by analyzing conversation content and proposing metadata.</p> <p>Invoke by session identifier:</p> <pre><code>/ctx-journal-enrich twinkly-stirring-kettle\n/ctx-journal-enrich twinkly\n/ctx-journal-enrich 2026-01-24\n/ctx-journal-enrich 76fe2ab9\n</code></pre> <p>The skill will:</p> <ol> <li>Check if locked - locked entries are skipped (same as export);</li> <li>Find the matching journal file;</li> <li>Read and analyze the conversation;</li> <li>Propose frontmatter (type, topics, outcome, technologies);</li> <li>Generate a 2-3 sentence summary;</li> <li>Extract decisions, learnings, and tasks mentioned;</li> <li>Show a diff and ask for confirmation before writing.</li> </ol>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#before-and-after","level":3,"title":"Before and After","text":"<p>Before enrichment:</p> <pre><code># 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</code></pre> <p>After enrichment:</p> <pre><code>---\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</code></pre>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#enrichment-and-site-generation","level":3,"title":"Enrichment and Site Generation","text":"<p>The journal site generator uses enriched metadata for better organization:</p> <ul> <li>Titles appear in navigation instead of slugs</li> <li>Summaries provide context in the index</li> <li>Topics enable filtering (when using search)</li> <li>Types allow grouping by work category</li> </ul> <p>Future improvements will add topic-based navigation and outcome filtering to the generated site.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#batch-enrichment","level":3,"title":"Batch Enrichment","text":"<p>To enrich multiple sessions, process them one at a time:</p> <pre><code># List unenriched sessions (those without frontmatter)\ngrep -L \"^---$\" .context/journal/*.md | head -10\n</code></pre> <p>Then run <code>/ctx-journal-enrich</code> on each. Enrichment is intentionally interactive to ensure accuracy.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#obsidian-vault-export","level":2,"title":"Obsidian Vault Export","text":"<p>If you use Obsidian for knowledge management, you can export your journal as an Obsidian vault instead of (or alongside) the static site:</p> <pre><code>ctx journal obsidian\n</code></pre> <p>This generates a vault in <code>.context/journal-obsidian/</code> with:</p> <ul> <li>Wikilinks (<code>[[target|display]]</code>) instead of Markdown links</li> <li>MOC pages (Map of Content) for topics, key files, and session types</li> <li>Related sessions footer per entry: links to entries sharing the same topics</li> <li>Transformed frontmatter: <code>topics</code> renamed to <code>tags</code> (Obsidian-recognized), <code>aliases</code> added from title for search</li> <li>Graph-optimized structure: MOC hubs and cross-linked entries create dense graph connectivity</li> </ul> <p>To use: open the output directory in Obsidian (\"Open folder as vault\").</p> <pre><code># Custom output directory\nctx journal obsidian --output ~/vaults/ctx-journal\n</code></pre> <p>Static Site vs Obsidian Vault</p> <p>Use <code>ctx journal site</code> when you want a web-browsable archive with search and dark mode. Use <code>ctx journal obsidian</code> when you want graph view, backlinks, and tag-based navigation inside Obsidian. Both use the same enriched source entries: you can generate both.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#full-pipeline","level":2,"title":"Full Pipeline","text":"<p>The complete journal workflow has four stages. Each is idempotent: safe to re-run, and stages skip already-processed entries.</p> <pre><code>import → enrich → rebuild\n</code></pre> Stage Command / Skill What it does Skips if Import <code>ctx journal import --all</code> Converts session JSONL to Markdown Source unchanged since last import Enrich <code>/ctx-journal-enrich</code> Adds frontmatter, summaries, topics Frontmatter already present Rebuild <code>ctx journal site --build</code> Generates static HTML site (never) Obsidian <code>ctx journal obsidian</code> Generates Obsidian vault with wikilinks (never) <p>One-Command Pipeline</p> <p><code>/ctx-journal-enrich-all</code> handles import automatically - it detects unimported sessions and imports them before enriching. You only need to run <code>ctx journal site --build</code> afterward.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#using-make-journal","level":3,"title":"Using <code>make journal</code>","text":"<p>If your project includes <code>Makefile.ctx</code> (deployed by <code>ctx init</code>), the first and last stages are combined:</p> <pre><code>make journal # import + rebuild\n</code></pre> <p>After it runs, it reminds you to enrich in Claude Code:</p> <pre><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</code></pre> <p>Rendering Issues?</p> <p>If individual entries have rendering problems (broken fences, malformed lists), check the programmatic normalization in the import pipeline. Most cases are handled automatically during <code>ctx journal import</code>.</p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#tips","level":2,"title":"Tips","text":"<p>Daily workflow: <pre><code># Import, browse, then enrich in Claude Code\nmake journal && make journal-serve\n# Then in Claude Code: /ctx-journal-enrich <session>\n</code></pre></p> <p>After a productive session: <pre><code># Import just that session and add notes\nctx journal import <session-id>\n# Edit .context/journal/<session>.md\n# Regenerate: ctx journal site\n</code></pre></p> <p>Searching across all sessions: <pre><code># Use grep on the journal directory\ngrep -r \"authentication\" .context/journal/\n</code></pre></p>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#requirements","level":2,"title":"Requirements","text":"Use <code>pipx</code> for <code>zensical</code> <p><code>pip install zensical</code> may install a non-functional stub on system Python. Using <code>venv</code> has other issues too.</p> <p>These issues especially happen on Mac OSX.</p> <p>Use <code>pipx install zensical</code>, which creates an isolated environment and handles Python version management automatically.</p> <p>The journal site uses zensical for static site generation:</p> <pre><code>pipx install zensical\n</code></pre>","path":["Reference","Session Journal"],"tags":[]},{"location":"reference/session-journal/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx journal</code>: Session discovery and listing</li> <li><code>ctx journal site</code>: Static site generation</li> <li><code>ctx journal obsidian</code>: Obsidian vault export</li> <li>Context Files: The <code>.context/</code> directory structure</li> </ul>","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":"<p>Skills are slash commands that run inside your AI assistant (e.g., <code>/ctx-next</code>), as opposed to CLI commands that run in your terminal (e.g., <code>ctx status</code>). </p> <p>Skills give your agent structured workflows: It knows what to read, what to run, and when to ask. Most wrap one or more <code>ctx</code> CLI commands with opinionated behavior on top. </p> <p>Skills Are Best Used Conversationally</p> <p>The beauty of <code>ctx</code> 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.</p> <p>See the Prompting Guide for natural-language triggers that invoke these skills conversationally.</p> <p>However, when you need a more precise control, you have the option to invoke the relevant skills directly.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#all-skills","level":2,"title":"All Skills","text":"Skill Description Type <code>/ctx-remember</code> Recall project context and present structured readback user-invocable <code>/ctx-wrap-up</code> End-of-session context persistence ceremony user-invocable <code>/ctx-status</code> Show context summary with interpretation user-invocable <code>/ctx-agent</code> Load full context packet for AI consumption user-invocable <code>/ctx-next</code> Suggest 1-3 concrete next actions with rationale user-invocable <code>/ctx-commit</code> Commit with integrated context persistence user-invocable <code>/ctx-reflect</code> Pause and reflect on session progress user-invocable <code>/ctx-task-add</code> Add actionable task to TASKS.md user-invocable <code>/ctx-decision-add</code> Record architectural decision with rationale user-invocable <code>/ctx-learning-add</code> Record gotchas and lessons learned user-invocable <code>/ctx-convention-add</code> Record coding convention for consistency user-invocable <code>/ctx-archive</code> Archive completed tasks from TASKS.md user-invocable <code>/ctx-pad</code> Manage encrypted scratchpad entries user-invocable <code>/ctx-history</code> Browse and import AI session history user-invocable <code>/ctx-journal-enrich</code> Enrich single journal entry with metadata user-invocable <code>/ctx-journal-enrich-all</code> Full journal pipeline: export if needed, then batch-enrich user-invocable <code>/ctx-blog</code> Generate blog post draft from project activity user-invocable <code>/ctx-blog-changelog</code> Generate themed blog post from a commit range user-invocable <code>/ctx-humanize</code> Remove formulaic LLM writing patterns from human-facing prose user-invocable <code>/ctx-consolidate</code> Consolidate redundant learnings or decisions user-invocable <code>/ctx-drift</code> Detect and fix context drift user-invocable <code>/ctx-prompt-audit</code> Analyze prompting patterns for improvement user-invocable <code>/ctx-link-check</code> Audit docs for dead internal and external links user-invocable <code>/ctx-permission-sanitize</code> Audit Claude Code permissions for security risks user-invocable <code>/ctx-brainstorm</code> Structured design dialogue before implementation user-invocable <code>/ctx-plan</code> Stress-test a plan through adversarial interview user-invocable <code>/ctx-spec</code> Scaffold a feature spec from a project template user-invocable <code>/ctx-task-out</code> Decompose a committed spec into a per-milestone plan user-invocable <code>/ctx-plan-import</code> Import Claude Code plan files into project specs user-invocable <code>/ctx-implement</code> Execute a plan step-by-step with verification user-invocable <code>/ctx-loop</code> Generate autonomous loop script user-invocable <code>/ctx-worktree</code> Manage git worktrees for parallel agents user-invocable <code>/ctx-architecture</code> Build and maintain architecture maps user-invocable <code>/ctx-architecture-failure-analysis</code> Adversarial failure analysis for correctness bugs user-invocable <code>/ctx-remind</code> Manage session-scoped reminders user-invocable <code>/ctx-doctor</code> Troubleshoot <code>ctx</code> behavior with health checks and event analysis user-invocable <code>/ctx-skill-audit</code> Audit skills against Anthropic prompting best practices user-invocable <code>/ctx-skill-create</code> Create, improve, and test skills user-invocable <code>/ctx-pause</code> Pause context hooks for this session user-invocable <code>/ctx-resume</code> Resume context hooks after a pause user-invocable <code>/ctx-kb-ingest</code> Editorial KB pass (topic-page / triage / evidence-only) user-invocable <code>/ctx-kb-ask</code> Q&A grounded in the KB; refuses to web-jump user-invocable <code>/ctx-kb-site-review</code> Mechanical KB structural audit user-invocable <code>/ctx-kb-ground</code> Re-ground the KB against listed external sources user-invocable <code>/ctx-kb-note</code> Park a finding in <code>ingest/findings.md</code> user-invocable <code>/ctx-handover</code> Handover step delegated by <code>/ctx-wrap-up</code>; folds postdated closeouts sub-mechanism","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-lifecycle","level":2,"title":"Session Lifecycle","text":"<p>Skills for starting, running, and ending a productive session.</p> <p>Session Ceremonies</p> <p>Two skills in this group are ceremony skills: <code>/ctx-remember</code> (session start) and <code>/ctx-wrap-up</code> (session end). Unlike other skills that work conversationally, these should be invoked as explicit slash commands for completeness. See Session Ceremonies.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remember","level":3,"title":"<code>/ctx-remember</code>","text":"<p>Recall project context and present a structured readback. Ceremony skill: invoke explicitly at session start.</p> <p>Wraps: <code>ctx agent --budget 4000</code>, <code>ctx journal source --limit 3</code>, reads TASKS.md, DECISIONS.md, LEARNINGS.md</p> <p>See also: Session Ceremonies, The Complete Session</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-status","level":3,"title":"<code>/ctx-status</code>","text":"<p>Show context summary (files, token budget, tasks, recent activity) with interpreted suggestions.</p> <p>Wraps: <code>ctx status [--verbose] [--json]</code></p> <p>See also: The Complete Session, <code>ctx status</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-agent","level":3,"title":"<code>/ctx-agent</code>","text":"<p>Load the full context packet optimized for AI consumption. Also runs automatically via the PreToolUse hook with cooldown.</p> <p>Wraps: <code>ctx agent [--budget] [--format] [--cooldown] [--session]</code></p> <p>See also: The Complete Session, <code>ctx agent</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-next","level":3,"title":"<code>/ctx-next</code>","text":"<p>Suggest 1-3 concrete next actions ranked by priority, momentum, and unblocked status.</p> <p>Wraps: reads TASKS.md, <code>ctx journal source --limit 3</code></p> <p>See also: The Complete Session, Tracking Work Across Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-commit","level":3,"title":"<code>/ctx-commit</code>","text":"<p>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.</p> <p>Wraps: <code>git add</code>, <code>git commit</code>, optionally chains to <code>/ctx-decision-add</code> and <code>/ctx-learning-add</code></p> <p>See also: The Complete Session</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-reflect","level":3,"title":"<code>/ctx-reflect</code>","text":"<p>Pause and reflect on session progress. Walks through a checklist of learnings, decisions, task completions, and session notes to persist.</p> <p>Wraps: chains to <code>ctx learning add</code>, <code>ctx decision add</code>, manual TASKS.md updates</p> <p>See also: The Complete Session, Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-wrap-up","level":3,"title":"<code>/ctx-wrap-up</code>","text":"<p>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 <code>ctx add</code>. Offers <code>/ctx-commit</code> if uncommitted changes remain. Always delegates to <code>/ctx-handover</code> as its final step, regardless of whether <code>.context/kb/</code> exists: KB presence only affects what gets folded into the handover, not whether it is written. Ceremony skill: invoke explicitly at session end.</p> <p>Trigger phrases: \"let's wrap up\", \"save context\", \"save state\", \"leave a handover\", \"before I go\", \"stepping away\", \"end of session\"</p> <p>Wraps: <code>git diff --stat</code>, <code>git log</code>, <code>ctx learning add</code>, <code>ctx decision add</code>, <code>ctx convention add</code>, <code>ctx task add</code>, chains to <code>/ctx-commit</code>, delegates to <code>/ctx-handover</code></p> <p>See also: Session Ceremonies, The Complete Session, <code>/ctx-handover</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#context-persistence","level":2,"title":"Context Persistence","text":"<p>Skills for recording work artifacts: tasks, decisions, learnings, conventions: into <code>.context/</code> files.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-task-add","level":3,"title":"<code>/ctx-task-add</code>","text":"<p>Add an actionable task with optional priority and phase section.</p> <p>Wraps: <code>ctx task add \"description\" [--priority high|medium|low] --session-id ID --branch BR --commit HASH</code></p> <p>See also: Tracking Work Across Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-decision-add","level":3,"title":"<code>/ctx-decision-add</code>","text":"<p>Record an architectural decision with context, rationale, and consequence. Supports Y-statement (lightweight) and full ADR formats.</p> <p>Wraps: <code>ctx decision add \"title\" --context \"...\" --rationale \"...\" --consequence \"...\" --session-id ID --branch BR --commit HASH</code></p> <p>See also: Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-learning-add","level":3,"title":"<code>/ctx-learning-add</code>","text":"<p>Record a project-specific gotcha, bug, or unexpected behavior. Filters for insights that are searchable, project-specific, and required real effort to discover.</p> <p>Wraps: <code>ctx learning add \"title\" --context \"...\" --lesson \"...\" --application \"...\" --session-id ID --branch BR --commit HASH</code></p> <p>See also: Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-convention-add","level":3,"title":"<code>/ctx-convention-add</code>","text":"<p>Record a coding convention that should be standardized across sessions. Targets patterns seen 2-3+ times.</p> <p>Wraps: <code>ctx convention add \"rule\" --section \"Name\"</code></p> <p>See also: Persisting Decisions, Learnings, and Conventions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-archive","level":3,"title":"<code>/ctx-archive</code>","text":"<p>Archive completed tasks from TASKS.md to a timestamped file in <code>.context/archive/</code>. Preserves phase headers for traceability.</p> <p>Wraps: <code>ctx task archive [--dry-run]</code></p> <p>See also: Tracking Work Across Sessions</p>","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":"<code>/ctx-pad</code>","text":"<p>Manage the encrypted scratchpad: add, remove, edit, and reorder one-liner notes. Encrypted at rest with AES-256-GCM.</p> <p>Wraps: <code>ctx pad</code>, <code>ctx pad add</code>, <code>ctx pad rm</code>, <code>ctx pad edit</code>, <code>ctx pad mv</code>, <code>ctx pad import</code>, <code>ctx pad export</code>, <code>ctx pad merge</code></p> <p>See also: Scratchpad, Using the Scratchpad</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#journal-history","level":2,"title":"Journal & History","text":"<p>Skills for browsing, exporting, and enriching your AI session history into a structured journal.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-history","level":3,"title":"<code>/ctx-history</code>","text":"<p>Browse, inspect, and import AI session history. List recent sessions, show details by slug or ID, and import to <code>.context/journal/</code>.</p> <p>Wraps: <code>ctx journal source</code>, <code>ctx journal source --show</code>, <code>ctx journal import</code></p> <p>See also: Browsing and Enriching Past Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich","level":3,"title":"<code>/ctx-journal-enrich</code>","text":"<p>Enrich a single journal entry with YAML frontmatter: title, type, outcome, topics, technologies, and summary. Shows diff before writing.</p> <p>Wraps: reads and edits <code>.context/journal/*.md</code> files</p> <p>See also: Browsing and Enriching Past Sessions, Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-journal-enrich-all","level":3,"title":"<code>/ctx-journal-enrich-all</code>","text":"<p>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.</p> <p>Wraps: <code>ctx journal import --all</code> + iterates <code>/ctx-journal-enrich</code></p> <p>See also: Browsing and Enriching Past Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#content-creation","level":2,"title":"Content Creation","text":"<p>Skills for turning project activity into publishable content.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog","level":3,"title":"<code>/ctx-blog</code>","text":"<p>Generate a blog post draft from recent project activity: git history, decisions, learnings, tasks, and journal entries. Requires a narrative arc (problem, approach, outcome).</p> <p>Wraps: reads <code>git log</code>, DECISIONS.md, LEARNINGS.md, TASKS.md, journal entries; writes to <code>docs/blog/</code></p> <p>See also: Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-blog-changelog","level":3,"title":"<code>/ctx-blog-changelog</code>","text":"<p>Generate a themed blog post from a commit range. Takes a starting commit and unifying theme, analyzes diffs and journal entries from that period.</p> <p>Wraps: <code>git log</code>, <code>git diff --stat</code>; writes to <code>docs/blog/</code></p> <p>See also: Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-humanize","level":3,"title":"<code>/ctx-humanize</code>","text":"<p>Review, rewrite, or edit human-facing prose (blog posts, docs, READMEs, announcements) to remove formulaic LLM writing patterns: significance inflation, brochure language, forced triplets, chatbot residue, em-dash typography. Preserves meaning, certainty, and voice; invents nothing. Defaults to review mode and only edits files when asked.</p> <p>Wraps: a 28-pattern catalog adapted from Wikipedia's \"Signs of AI writing\"; verifies typography mechanically before returning</p> <p>See also: Turning Activity into Content</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#auditing-health","level":2,"title":"Auditing & Health","text":"<p>Skills for detecting drift, auditing alignment, and improving prompt quality.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-consolidate","level":3,"title":"<code>/ctx-consolidate</code>","text":"<p>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.</p> <p>Wraps: reads LEARNINGS.md and DECISIONS.md, writes consolidated entries, archives originals (the index is computed on demand by <code>ctx index</code>, so no rebuild step is needed)</p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-drift","level":3,"title":"<code>/ctx-drift</code>","text":"<p>Detect and fix context drift: stale paths, missing files, file age staleness, task accumulation, entry count warnings, and constitution violations via <code>ctx drift</code>. Also detects skill drift against canonical templates.</p> <p>Wraps: <code>ctx drift [--fix]</code></p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-prompt-audit","level":3,"title":"<code>/ctx-prompt-audit</code>","text":"<p>Analyze recent prompting patterns to identify vague or ineffective prompts. Reviews 3-5 journal entries and suggests rewrites with positive observations.</p> <p>Wraps: reads <code>.context/journal/</code> entries</p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-doctor","level":3,"title":"<code>/ctx-doctor</code>","text":"<p>Troubleshoot <code>ctx</code> behavior. Runs structural health checks via <code>ctx doctor</code>, analyzes event log patterns via <code>ctx hook event</code>, and presents findings with suggested actions. The CLI provides the structural baseline; the agent adds semantic analysis of event patterns and correlations.</p> <p>Wraps: <code>ctx doctor --json</code>, <code>ctx hook event --json --last 100</code>, <code>ctx remind list</code>, <code>ctx hook message list</code>, reads <code>.ctxrc</code></p> <p>Trigger phrases: \"diagnose\", \"troubleshoot\", \"doctor\", \"health check\", \"why didn't my hook fire?\", \"hooks seem broken\", \"something seems off\"</p> <p>Graceful degradation: If <code>event_log</code> is not enabled, the skill still works but with reduced capability. It runs structural checks and notes: \"Enable <code>event_log: true</code> in <code>.ctxrc</code> for hook-level diagnostics.\"</p> <p>See also: Troubleshooting, <code>ctx doctor</code> CLI, <code>ctx hook event</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-link-check","level":3,"title":"<code>/ctx-link-check</code>","text":"<p>Scan all Markdown files under <code>docs/</code> 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.</p> <p>Wraps: Glob + Grep to scan, <code>curl</code> for external checks</p> <p>Trigger phrases: \"check links\", \"audit links\", \"any broken links?\", \"dead links\"</p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-permission-sanitize","level":3,"title":"<code>/ctx-permission-sanitize</code>","text":"<p>Audit <code>.claude/settings.local.json</code> 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.</p> <p>Wraps: reads <code>.claude/settings.local.json</code>, edits with confirmation</p> <p>Trigger phrases: \"audit permissions\", \"are my permissions safe?\", \"sanitize permissions\", \"check settings\"</p> <p>See also: Claude Code Permission Hygiene</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#planning-execution","level":2,"title":"Planning & Execution","text":"<p>Skills for structured design, implementation, and parallel agent workflows.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-brainstorm","level":3,"title":"<code>/ctx-brainstorm</code>","text":"<p>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.</p> <p>Wraps: reads DECISIONS.md, relevant source files; chains to <code>/ctx-decision-add</code> for recording design choices</p> <p>Trigger phrases: \"let's brainstorm\", \"design this\", \"think through\", \"before we build\", \"what approach should we take?\"</p> <p>See also: <code>/ctx-plan</code>, <code>/ctx-spec</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-plan","level":3,"title":"<code>/ctx-plan</code>","text":"<p>Stress-test a plan through an adversarial interview before it becomes a spec. Asks one question at a time across scope, failure modes, rejected alternatives, sequencing, reversibility, and hidden assumptions — pushing back rather than validating. Stops when the user can articulate the bet, the rejections, the top failure modes, the cheapest validation, and the unwind cost. Concludes by offering to write a debated brief to <code>.context/briefs/<TS>-<slug>.md</code>, the canonical input for <code>/ctx-spec --brief</code>. Deliberately does not produce an implementation plan or task list — that happens two steps later, at <code>/ctx-task-out</code>.</p> <p>Wraps: reads code and context files; writes <code>.context/briefs/<TS>-<slug>.md</code></p> <p>Trigger phrases: \"attack this plan\", \"poke holes in this\", \"stress-test my plan\", \"scrutinize this before I commit\"</p> <p>See also: Scrutinizing a Plan, <code>/ctx-brainstorm</code>, <code>/ctx-spec</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-spec","level":3,"title":"<code>/ctx-spec</code>","text":"<p>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.</p> <p>Wraps: reads <code>specs/tpl/spec-template.md</code>, writes to <code>specs/</code>, optionally chains to <code>/ctx-task-add</code></p> <p>Trigger phrases: \"spec this out\", \"write a spec\", \"create a spec\", \"design document\"</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#-brief-path-flag","level":4,"title":"<code>--brief <path></code> flag","text":"<p>When invoked as <code>/ctx-spec --brief <path></code>, the skill treats the file at <code><path></code> as the authoritative source and skips the interactive Q&A. Use this when a prior <code>/ctx-plan</code> session produced a debated brief that already covers the design.</p> <p>The skill enforces this authority order when sources disagree:</p> <ol> <li>Frozen contracts in <code>docs/</code> (release notes, public CLI docs)</li> <li>Recorded decisions in <code>.context/DECISIONS.md</code></li> <li>The brief at <code><path></code></li> <li>Agent inference, only when 1 through 3 are silent, and labeled <code>TBD</code> in the resulting spec so it stands out for review.</li> </ol> <p>Light compression for clarity is allowed; new facts are not. Where the brief is silent, the spec writes <code>TBD</code> rather than filling the gap from inference. If the brief contradicts a frozen contract, the contradiction is surfaced to the user rather than silently followed.</p> <p>Both flows end with a tasking handoff: specs that span multiple milestones (or more than roughly one session of implementation) are routed to <code>/ctx-task-out</code> for decomposition; small specs go straight to <code>/ctx-implement</code>.</p> <p>See also: <code>/ctx-brainstorm</code>, <code>/ctx-plan</code>, <code>/ctx-task-out</code>, <code>/ctx-plan-import</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-task-out","level":3,"title":"<code>/ctx-task-out</code>","text":"<p>Decompose a committed spec into a per-milestone implementation plan at <code>specs/plans/<milestone>.md</code> — data model, contracts, an invariant-test matrix, and typically 15-40 tasks, each with a falsifiable acceptance criterion (a command to run, a test that must pass, an observable behavior). The plan is the document <code>/ctx-implement</code> executes. The skill is a decomposer, not a designer: disagreements with the spec route back through <code>/ctx-plan</code> instead of being relitigated here.</p> <p>Two hard gates refuse rather than degrade:</p> <ol> <li>Blocking-TBD gate: the spec's open questions are classified as blocking or deferrable for the target milestone; decomposition refuses to proceed past a blocking TBD (a task that would embed an assumption about its answer).</li> <li>Rolling-wave gate: milestone N+1 is not decomposed while milestone N's definition of done is unmet, unless the user overrides explicitly (recorded in the plan header).</li> </ol> <p>TASKS.md receives epic-level anchors only, each annotated <code>Plan: specs/plans/<milestone>.md</code> — the plan owns the fine-grained tasks, one-way sync, nothing moved or deleted. Single-session specs skip this step entirely: the spec is the plan.</p> <p>Wraps: reads the spec, TASKS.md, DECISIONS.md, CONVENTIONS.md; writes <code>specs/plans/<milestone>.md</code>, appends anchors to TASKS.md</p> <p>Trigger phrases: \"task this out\", \"break down the spec\", \"decompose the spec\", \"plan out the milestone\"</p> <p>See also: <code>/ctx-spec</code>, <code>/ctx-implement</code></p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-plan-import","level":3,"title":"<code>/ctx-plan-import</code>","text":"<p>Import Claude Code plan files (<code>~/.claude/plans/*.md</code>) into the project's <code>specs/</code> directory. Lists plans with dates and H1 titles, supports filtering (<code>--today</code>, <code>--since</code>, <code>--all</code>), slugifies headings for filenames, and optionally creates tasks referencing each imported spec.</p> <p>Wraps: reads <code>~/.claude/plans/*.md</code>, writes to <code>specs/</code>, optionally chains to <code>/ctx-task-add</code></p> <p>See also: Importing Claude Code Plans, Tracking Work Across Sessions</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-implement","level":3,"title":"<code>/ctx-implement</code>","text":"<p>Execute a multi-step plan with build and test verification at each step. The canonical input is <code>specs/plans/<milestone>.md</code> as written by <code>/ctx-task-out</code>, but hand-written plan files and plans from conversation context work too. Breaks the plan into atomic steps and checkpoints after every 3-5 steps. Handed a bare multi-milestone spec instead of a plan, it redirects to <code>/ctx-task-out</code> rather than decomposing on the fly.</p> <p>Wraps: reads plan file, runs verification commands (<code>go build</code>, <code>go test</code>, etc.)</p> <p>See also: <code>/ctx-task-out</code>, Running an Unattended AI Agent</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-loop","level":3,"title":"<code>/ctx-loop</code>","text":"<p>Generate a ready-to-run shell script for autonomous AI iteration. Supports Claude Code, Aider, and generic tool templates with configurable completion signals.</p> <p>Wraps: <code>ctx loop [--tool] [--prompt] [--max-iterations] [--completion] [--output]</code></p> <p>See also: Autonomous Loops, Running an Unattended AI Agent</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-worktree","level":3,"title":"<code>/ctx-worktree</code>","text":"<p>Manage git worktrees for parallel agent development. Create sibling worktrees on dedicated branches, analyze task blast radius for grouping, and tear down with merge.</p> <p>Wraps: <code>git worktree add</code>, <code>git worktree list</code>, <code>git worktree remove</code>, <code>git merge</code></p> <p>See also: Parallel Agent Development with Git Worktrees</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture","level":3,"title":"<code>/ctx-architecture</code>","text":"<p>Build and maintain architecture maps incrementally. Creates or refreshes <code>ARCHITECTURE.md</code> (succinct project map, loaded at session start) and <code>DETAILED_DESIGN.md</code> (deep per-module reference, consulted on-demand). Coverage is tracked in <code>map-tracking.json</code> so each run extends the map rather than re-analyzing everything.</p> <p>Wraps: <code>ctx status</code>, <code>git log</code>, reads source files; writes <code>ARCHITECTURE.md</code>, <code>DETAILED_DESIGN.md</code>, <code>map-tracking.json</code></p> <p>See also: Detecting and Fixing Drift</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-architecture-failure-analysis","level":3,"title":"<code>/ctx-architecture-failure-analysis</code>","text":"<p>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.</p> <p>Requires <code>/ctx-architecture</code> artifacts as input. Reads <code>ARCHITECTURE.md</code>, <code>DETAILED_DESIGN*.md</code>, and <code>map-tracking.json</code>, 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.</p> <p>Produces <code>.context/DANGER-ZONES.md</code> with ranked findings split into Critical (risk >= 7, silent/cascading) and Elevated tiers.</p> <p>Wraps: reads architecture artifacts, source code; writes <code>DANGER-ZONES.md</code>. Optionally uses a code-intelligence MCP (canonical: GitNexus) for blast radius and a web-search-with-citations MCP (canonical: Gemini Search) for cross-referencing known failure patterns.</p> <p>Relationship:</p> Skill Mode <code>/ctx-architecture</code> Map what exists <code>/ctx-architecture-enrich</code> Improve map fidelity <code>/ctx-architecture-failure-analysis</code> Generate falsifiable incident hypotheses","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-remind","level":3,"title":"<code>/ctx-remind</code>","text":"<p>Manage session-scoped reminders via natural language. Translates user intent (\"remind me to refactor swagger\") into the corresponding <code>ctx remind</code> command. Handles date conversion for <code>--after</code> flags.</p> <p>Wraps: <code>ctx remind</code>, <code>ctx remind list</code>, <code>ctx remind dismiss</code></p> <p>See also: Session Reminders</p>","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":"<code>/ctx-skill-audit</code>","text":"<p>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.</p> <p>Wraps: reads <code>internal/assets/claude/skills/*/SKILL.md</code> or <code>.claude/skills/*/SKILL.md</code>, references <code>anthropic-best-practices.md</code></p> <p>Trigger phrases: \"audit this skill\", \"check skill quality\", \"review the skills\", \"are our skills any good?\"</p> <p>See also: <code>/ctx-skill-create</code>, Contributing</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-skill-create","level":3,"title":"<code>/ctx-skill-create</code>","text":"<p>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.</p> <p>Wraps: reads/writes <code>.claude/skills/</code> and <code>internal/assets/claude/skills/</code></p> <p>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\"</p> <p>See also: Contributing</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#session-control","level":2,"title":"Session Control","text":"<p>Skills for controlling hook behavior during a session.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-pause","level":3,"title":"<code>/ctx-pause</code>","text":"<p>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.</p> <p>Wraps: <code>ctx hook pause</code></p> <p>Trigger phrases: \"pause <code>ctx</code>\", \"pause context\", \"stop the nudges\", \"quiet mode\"</p> <p>See also: Pausing Context Hooks</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-resume","level":3,"title":"<code>/ctx-resume</code>","text":"<p>Resume context hooks after a pause. Restores normal nudge, reminder, and ceremony behavior. Silent no-op if not paused.</p> <p>Wraps: <code>ctx hook resume</code></p> <p>Trigger phrases: \"resume <code>ctx</code>\", \"resume context\", \"turn nudges back on\", \"unpause\"</p> <p>See also: Pausing Context Hooks</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#knowledge-base-phase-kb","level":2,"title":"Knowledge Base (Phase KB)","text":"<p>Skills for the editorial knowledge-ingestion pipeline. Active when <code>.context/kb/</code> exists (laid down by <code>ctx init</code>). The pipeline gives you evidence-tracked knowledge with confidence bands, folder-shaped topic pages, a source-coverage state machine, and per-session handovers that fold postdated closeouts.</p> <p>See the Build a Knowledge Base recipe for the full workflow. The editorial constitution lives at <code>.context/ingest/KB-RULES.md</code>.</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-ingest","level":3,"title":"<code>/ctx-kb-ingest</code>","text":"<p>Mode-aware editorial pass. Declares its pass-mode (<code>topic-page</code> / <code>triage</code> / <code>evidence-only</code>) up front, scans the source-coverage ledger for adjacent incomplete topics, synthesizes prose into <code>.context/kb/topics/<slug>/index.md</code>, mints <code>EV-###</code> rows in <code>evidence-index.md</code>, runs a four-invariant completion circuit breaker, and writes a closeout under <code>.context/ingest/closeouts/</code>. Refuses on empty input.</p> <p>Wraps: <code>ctx kb ingest</code>, <code>ctx kb topic new</code>, the writer packages under <code>internal/write/kb/</code>.</p> <p>Trigger phrases: \"ingest the transcripts\", \"pull this into the kb\", \"add evidence from\"</p> <p>See also: Build a Knowledge Base, Typical KB Session, <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-ask","level":3,"title":"<code>/ctx-kb-ask</code>","text":"<p>Q&A grounded in the KB. Cites <code>EV-###</code> rows; refuses to web-jump. When the KB cannot answer, opens a <code>Q-###</code> row in <code>outstanding-questions.md</code> rather than inventing. Refuses on empty question.</p> <p>Wraps: <code>ctx kb ask</code>, reads <code>.context/kb/*.md</code></p> <p>Trigger phrases: \"does the kb say\", \"according to evidence\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-site-review","level":3,"title":"<code>/ctx-kb-site-review</code>","text":"<p>Mechanical structural audit. Coerces malformed Confidence-band capitalization, flags malformed closeout frontmatter, refuses judgment calls that require evidence (those go through ingest).</p> <p>Wraps: <code>ctx kb site-review</code></p> <p>Trigger phrases: \"audit the kb\", \"check kb for rot\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-ground","level":3,"title":"<code>/ctx-kb-ground</code>","text":"<p>External re-grounding pass. Reads <code>.context/ingest/grounding-sources.md</code> and refreshes each listed source. Refuses cleanly when the file is absent or empty.</p> <p>Wraps: <code>ctx kb ground</code></p> <p>Trigger phrases: \"re-ground the kb\", \"check upstream\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-kb-note","level":3,"title":"<code>/ctx-kb-note</code>","text":"<p>Lightweight capture into <code>.context/ingest/findings.md</code>. Never writes to a topic page or <code>evidence-index.md</code>. Use for parking findings the next ingest pass should absorb.</p> <p>Wraps: <code>ctx kb note \"<text>\"</code></p> <p>Trigger phrases: \"drop a note\", \"park this finding\"</p> <p>See also: <code>ctx kb</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#ctx-handover","level":3,"title":"<code>/ctx-handover</code>","text":"<p>Per-session handover artifact writer; the sub-mechanism that <code>/ctx-wrap-up</code> delegates to as its final step. Collects <code>--summary</code> (past tense) and <code>--next</code> (future tense, specific) and calls <code>ctx handover write</code>. Writes the handover to <code>.context/handovers/<TS>-<slug>.md</code> (timestamped so concurrent agent runs never overwrite). Folds postdated closeouts into a <code>## Folded closeouts</code> section and physically archives the source closeouts under <code>.context/archive/closeouts/</code> (closeouts are append-never-rewrite; archival moves bytes but does not modify them). <code>--no-fold</code> skips the fold for mid-session checkpoints.</p> <p>Mandatory tail of <code>/ctx-wrap-up</code>. Direct invocation is reserved for <code>--no-fold</code> mid-session checkpoints and recovery after an aborted session.</p> <p>Wraps: <code>ctx handover write <title> --summary X --next Y</code></p> <p>See also: <code>/ctx-wrap-up</code>, Typical KB Session, Recover an Aborted KB Session, <code>ctx handover</code> CLI</p>","path":["Reference","Skills"],"tags":[]},{"location":"reference/skills/#project-specific-skills","level":2,"title":"Project-Specific Skills","text":"<p>The <code>ctx</code> plugin ships the skills listed above. Teams can add their own project-specific skills to <code>.claude/skills/</code> in the project root: These are separate from plugin-shipped skills and are scoped to the project.</p> <p>Project-specific skills follow the same format and are invoked the same way.</p> <p>Custom skills are not covered in this reference.</p>","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":"<p>Documentation snapshots for each release. </p> <p>Tap the corresponding view docs to view the docs as they were at that release.</p>","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":"<code>v0.8.0</code>: The Architecture Release","text":"<p>MCP server for tool-agnostic AI integration. Memory bridge connecting Claude Code auto-memory to <code>.context/</code>. Complete CLI restructuring into <code>cmd/ + core/</code> taxonomy. All user-facing strings externalized to YAML. <code>fatih/color</code> removed; two direct dependencies remain.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v060-the-integration-release","level":3,"title":"<code>v0.6.0</code>: The Integration Release","text":"<p>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.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v030-the-discipline-release","level":3,"title":"<code>v0.3.0</code>: The Discipline Release","text":"<p>Journal static site generation via zensical. 49-skill audit and fix pass (positive framing, phantom reference removal, scope tightening). Context consolidation skill. <code>golangci-lint</code> v2 migration.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v020-the-archaeology-release","level":3,"title":"<code>v0.2.0</code>: The Archaeology Release","text":"<p>Session journal system: <code>ctx journal import</code> converts Claude Code JSONL transcripts to browsable Markdown. Constants refactor with semantic prefixes (<code>Dir*</code>, <code>File*</code>, <code>Filename*</code>). CRLF handling for Windows compatibility.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v012","level":3,"title":"<code>v0.1.2</code>","text":"<p>Default Claude Code permissions deployed on <code>ctx init</code>. Prompting guide published as a standalone documentation page.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v011","level":3,"title":"<code>v0.1.1</code>","text":"<p>Bug fixes: hook schema key format corrected, JSON unicode escaping fixed in context file output.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#v010-initial-release","level":3,"title":"<code>v0.1.0</code>: Initial Release","text":"<p>CLI with 15 subcommands, 6 context file types (CONSTITUTION, TASKS, CONVENTIONS, ARCHITECTURE, DECISIONS, LEARNINGS), Makefile build system, and Claude Code hook integration.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#latest","level":2,"title":"Latest","text":"<p>The main documentation always reflects the latest development version.</p> <p>For the most recent stable release, see v0.8.0.</p>","path":["Reference","Version History"],"tags":[]},{"location":"reference/versions/#changelog","level":2,"title":"Changelog","text":"<p>For detailed changes between versions, see the GitHub Releases page.</p>","path":["Reference","Version History"],"tags":[]},{"location":"security/","level":1,"title":"Security","text":"<p>Security model, agent hardening, and vulnerability reporting.</p>","path":["Security"],"tags":[]},{"location":"security/#security-design","level":3,"title":"Security Design","text":"<p>Trust model, what <code>ctx</code> does for security, permission hygiene, state file management, and the log-first audit trail principle. Read first to understand the security boundaries.</p>","path":["Security"],"tags":[]},{"location":"security/#securing-ai-agents","level":3,"title":"Securing AI Agents","text":"<p>Defense in depth for unattended AI agents: five layers of protection, each with a known bypass, strength in combination.</p>","path":["Security"],"tags":[]},{"location":"security/#reporting-vulnerabilities","level":3,"title":"Reporting Vulnerabilities","text":"<p>How to report a security issue: email, GitHub private reporting, PGP-encrypted submissions, what to include, and the response timeline.</p>","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":"<p>An unattended AI agent with unrestricted access to your machine is an unattended shell with unrestricted access to your machine.</p> <p>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.</p> <p>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.</p>","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":"<p>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.</p> 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 <code>CLAUDE.md</code>, <code>.cursorrules</code>, or <code>.context/</code> 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":"<p>Depends entirely on what permissions and access the agent has:</p> 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":"<p>No single layer is sufficient. Each layer catches what the others miss.</p> <pre><code>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</code></pre>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-1-soft-instructions-probabilistic","level":3,"title":"Layer 1: Soft Instructions (Probabilistic)","text":"<p>Markdown files like <code>CONSTITUTION.md</code> 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.</p> <p>What it catches: Most common mistakes. An agent that has been told \"never delete production data\" will usually not delete production data.</p> <p>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.</p> <p>Verdict: Necessary but not sufficient. Good for the common case. Do not rely on it for security boundaries.</p>","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":"<p>AI tool runtimes (Claude Code, Cursor, etc.) provide permission systems: tool allowlists, command restrictions, confirmation prompts.</p> <p>For Claude Code, <code>ctx init</code> writes both an allowlist and an explicit deny list into <code>.claude/settings.local.json</code>. The golden images live in <code>internal/assets/permissions/</code>:</p> <p>Allowlist (<code>allow.txt</code>): only these tools run without confirmation:</p> <pre><code>Bash(ctx:*)\nSkill(ctx-convention-add)\nSkill(ctx-decision-add)\n... # all bundled ctx-* skills\n</code></pre> <p>Deny list (<code>deny.txt</code>): these are blocked even if the agent requests them:</p> <pre><code># 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</code></pre> <p>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 <code>rm</code>, <code>curl</code>, <code>sudo</code>, or <code>docker</code> are not allowed and <code>sudo</code>/<code>curl</code>/<code>wget</code> are explicitly denied, the agent cannot invoke them regardless of what any prompt says.</p> <p>What it misses: The agent can modify the allowlist itself. In an autonomous loop, if the agent writes to <code>.claude/settings.local.json</code>, 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.</p> <p>Verdict: Strong first layer. Must be combined with self-modification prevention (Layer 3).</p>","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":"<p>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 <code>CAP_NET_RAW</code> cannot open raw sockets. These are kernel boundaries.</p> Control Purpose Dedicated user account No <code>sudo</code>, no privileged group membership (<code>docker</code>, <code>wheel</code>, <code>adm</code>). 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 <code>CLAUDE.md</code>, <code>.claude/settings.local.json</code>, and <code>.context/CONSTITUTION.md</code> owned by a different user or marked immutable (<code>chattr +i</code> on Linux). The agent cannot modify its own guardrails. <p>What it catches: Privilege escalation, self-modification, lateral movement to other projects or users.</p> <p>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.</p> <p>Verdict: Essential. This is the layer that makes the other layers trustworthy.</p> <p>OS-level isolation does not make the agent safe; it makes the other layers meaningful.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-4-network-controls","level":3,"title":"Layer 4: Network Controls","text":"<p>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.</p> Scenario Recommended control Agent does not need the internet <code>--network=none</code> (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. <p>What it catches: Data exfiltration, phone-home payloads, downloading additional tools, and instruction injection via fetched content.</p> <p>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.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#layer-5-infrastructure-isolation","level":3,"title":"Layer 5: Infrastructure Isolation","text":"<p>The strongest boundary is a separate machine (or something that behaves like one).</p> <p>The moment you stop arguing about prompts and start arguing about kernels, you are finally doing security.</p> <p>Containers (Docker, Podman):</p> <pre><code>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</code></pre> <p>Docker Socket Is Sudo Access</p> <p>Critical: never mount the Docker socket (<code>/var/run/docker.sock</code>).</p> <p>An agent with socket access can spawn sibling containers with full host access, effectively escaping the sandbox. </p> <p>Use rootless Docker or Podman to eliminate this escalation path.</p> <p>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.</p> <p>Resource limits: CPU, memory, and disk quotas prevent a runaway agent from consuming all resources. Use <code>ulimit</code>, cgroup limits, or container resource constraints.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#putting-it-all-together","level":2,"title":"Putting It All Together","text":"<p>A defense-in-depth setup for overnight autonomous runs:</p> Layer Implementation Stops Soft instructions <code>CONSTITUTION.md</code> with \"never delete tests\", \"always run tests before committing\" Common mistakes (probabilistic) Application allowlist <code>.claude/settings.local.json</code> with explicit tool permissions Unauthorized commands (deterministic within runtime) Immutable config <code>chattr +i</code> on <code>CLAUDE.md</code>, <code>.claude/</code>, <code>CONSTITUTION.md</code> Self-modification between iterations Unprivileged user Dedicated user, no sudo, no docker group Privilege escalation Container <code>--cap-drop=ALL --network=none</code>, rootless, no socket mount Host escape, network exfiltration Resource limits <code>--memory=4g --cpus=2</code>, disk quotas Resource exhaustion <p>Each layer is straightforward: The strength is in the combination.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#common-mistakes","level":2,"title":"Common Mistakes","text":"<p>\"I'll just use <code>--dangerously-skip-permissions</code>\": 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.</p> <p>\"The agent is sandboxed in Docker\": A Docker container with the Docker socket mounted, running as root, with <code>--privileged</code>, and full network access is not sandboxed. It is a root shell with extra steps.</p> <p>\"<code>CONSTITUTION.md</code> 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.</p> <p>\"I reviewed the <code>CLAUDE.md</code>, it's fine\": The agent can modify <code>CLAUDE.md</code> during iteration N. Iteration N+1 loads the modified version. Unless the file is immutable, your review is stale.</p> <p>\"The agent only has access to this one project\": Does the project directory contain <code>.env</code> files, SSH keys, API tokens, or credentials? Does it have a <code>.git/config</code> with push access to a remote? Filesystem isolation means isolating what is in the directory too.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-security-considerations","level":2,"title":"Team Security Considerations","text":"<p>When multiple developers share a <code>.context/</code> directory, security considerations extend beyond single-agent hardening.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#code-review-for-context-files","level":3,"title":"Code Review for Context Files","text":"<p>Treat <code>.context/</code> changes like code changes. Context files influence agent behavior (a modified <code>CONSTITUTION.md</code> or <code>CONVENTIONS.md</code> changes what every agent on the team will do next session). Review them in PRs with the same scrutiny you apply to production code.</p> <p>Watch for:</p> <ul> <li>Weakened constitutional rules (removed constraints, softened language)</li> <li>New decisions that contradict existing ones without acknowledging it</li> <li>Learnings that encode incorrect assumptions</li> <li>Task additions that bypass the team's prioritization process</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#gitignore-patterns","level":3,"title":"Gitignore Patterns","text":"<p><code>ctx init</code> configures <code>.gitignore</code> automatically, but verify these patterns are in place:</p> <ul> <li>Always gitignored: <code>.ctx.key</code> (encryption key), <code>.context/logs/</code>, <code>.context/journal/</code></li> <li>Team decision: <code>scratchpad.enc</code> (encrypted, safe to commit for shared scratchpad state); <code>.gitignore</code> if scratchpads are personal</li> <li>Never committed: <code>.env</code>, credentials, API keys (enforced by drift secret detection)</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#multi-developer-context-sharing","level":3,"title":"Multi-Developer Context Sharing","text":"<p><code>CONSTITUTION.md</code> is the shared contract. All team members and their agents inherit it. Changes require team consensus, not unilateral edits.</p> <p>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.</p>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#team-conventions-for-context-management","level":3,"title":"Team Conventions for Context Management","text":"<p>Establish and document:</p> <ul> <li>Who reviews context changes: Same reviewers as code, or a designated context owner?</li> <li>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.</li> <li>Frequency of context maintenance: Weekly <code>ctx drift</code> checks, monthly consolidation passes, archival after each milestone.</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#checklist","level":2,"title":"Checklist","text":"<p>Before running an unattended AI agent:</p> <ul> <li> Agent runs as a dedicated unprivileged user (no sudo, no docker group)</li> <li> Agent's config files are immutable or owned by a different user</li> <li> Permission allowlist restricts tools to the project's toolchain</li> <li> Container drops all capabilities (<code>--cap-drop=ALL</code>)</li> <li> Docker socket is NOT mounted</li> <li> Network is disabled or restricted to specific domains</li> <li> Resource limits are set (memory, CPU, disk)</li> <li> No SSH keys, API tokens, or credentials are accessible to the agent</li> <li> Project directory does not contain <code>.env</code> or secrets files</li> <li> Iteration cap is set (<code>--max-iterations</code>)</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/agent-security/#further-reading","level":2,"title":"Further Reading","text":"<ul> <li>Running an Unattended AI Agent: the <code>ctx</code> recipe for autonomous loops, including step-by-step permissions and isolation setup</li> <li>Security: <code>ctx</code>'s own trust model and vulnerability reporting</li> <li>Autonomous Loops: full documentation of the loop pattern, prompt templates, and troubleshooting</li> </ul>","path":["Security","Securing AI Agents"],"tags":[]},{"location":"security/design/","level":1,"title":"Security Design","text":"<p>How <code>ctx</code> 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.</p> <p>For vulnerability disclosure, see Reporting Vulnerabilities.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#trust-model","level":2,"title":"Trust Model","text":"<p><code>ctx</code> operates within a single trust boundary: the local filesystem.</p> <p>The person who authors <code>.context/</code> files is the same person who runs the agent that reads them. There is no remote input, no shared state, and no server component.</p> <p>This means:</p> <ul> <li><code>ctx</code> 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.</li> <li>If you place adversarial instructions in your own <code>.context/</code> files, your agent will follow them. This is expected behavior. You control the context; the agent trusts it.</li> </ul> <p>Shared Repositories</p> <p>In shared repositories, <code>.context/</code> 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 <code>CONSTITUTION.md</code> or <code>TASKS.md</code>.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#what-ctx-does-for-security","level":2,"title":"What <code>ctx</code> Does for Security","text":"<p><code>ctx</code> is designed with security in mind:</p> <ul> <li>No secrets in context: The constitution explicitly forbids storing secrets, tokens, API keys, or credentials in <code>.context/</code> files.</li> <li>Local only: <code>ctx</code> runs entirely locally with no external network calls.</li> <li>No code execution: <code>ctx</code> reads and writes Markdown files only; it does not execute arbitrary code.</li> <li>Git-tracked: Core context files are meant to be committed, so they should never contain sensitive data. Exception: <code>sessions/</code> and <code>journal/</code> contain raw conversation data and should be gitignored.</li> </ul>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#permission-hygiene","level":2,"title":"Permission Hygiene","text":"<p>Claude Code evaluates permissions in deny → ask → allow order. <code>ctx init</code> automatically populates <code>permissions.deny</code> with rules that block dangerous operations before the allow list is ever consulted.</p> <p>Default deny rules block:</p> <ul> <li><code>sudo</code>, <code>git push</code>, <code>rm -rf /</code>, <code>rm -rf ~</code>, <code>curl</code>, <code>wget</code>, <code>chmod 777</code></li> <li><code>Read</code> / <code>Edit</code> of <code>.env</code>, credentials, secrets, <code>.pem</code>, <code>.key</code> files</li> </ul> <p>Even with deny rules in place, the allow list accumulates one-off permissions over time. Periodically review for:</p> <ul> <li>Destructive commands: <code>git reset --hard</code>, <code>git clean -f</code>, etc.</li> <li>Config injection vectors: permissions that allow modifying files controlling agent behavior (<code>CLAUDE.md</code>, <code>settings.local.json</code>).</li> <li>Broad wildcards: overly permissive patterns that pre-approve more than intended.</li> </ul> <p>For the full hygiene workflow, see the Claude Code Permission Hygiene recipe.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#state-file-management","level":2,"title":"State File Management","text":"<p>Hook state files (throttle markers, prompt counters, pause markers) are stored in <code>.context/state/</code>, which is project-scoped and gitignored. State files are automatically managed by the hooks that create them; no manual cleanup is needed.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#log-first-audit-trail","level":2,"title":"Log-First Audit Trail","text":"<p>The event log (<code>.context/state/events.jsonl</code>) is the authoritative record of what <code>ctx</code> hooks did during a session. Several audit-adjacent features depend on that log being trustworthy, not merely best-effort:</p> <ul> <li><code>ctx event</code> / <code>ctx system view-events</code> replays session history from the log.</li> <li>Webhook notifications give operators a real-time signal that assumes every notification corresponds to a logged event.</li> <li>Drift, freshness, and map-staleness checks count events over time and surface regressions.</li> </ul> <p>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.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#the-rule","level":3,"title":"The Rule","text":"<p>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.</p> <p>In code, this shape:</p> <pre><code>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</code></pre> <p>The <code>nudge.Relay</code> helper in <code>internal/cli/system/core/nudge</code> enforces this for the common \"log + webhook\" pair. Hook <code>Run</code> functions that compose their own sequence (<code>sessionevent</code>, <code>heartbeat</code>, several <code>check_*</code> hooks) follow the same ordering explicitly.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#known-gaps","level":3,"title":"Known Gaps","text":"<ul> <li>Nudge webhooks have no log channel. <code>nudge.EmitAndRelay</code> 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.</li> <li><code>ctx agent --cooldown</code> and <code>ctx doctor</code> 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.</li> <li>Verbose hook logs in <code>core/log.Message</code> 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 <code>log/warn.Warn</code> rather than propagating, because losing an operational log line is not a correctness problem.</li> </ul>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#background","level":3,"title":"Background","text":"<p>The <code>error</code> returns on <code>event.Append</code>, <code>io.AppendBytes</code>, <code>nudge.Relay</code>, and <code>cooldown.Active</code> / <code>cooldown.TouchTombstone</code> 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.</p>","path":["Security","Security Design"],"tags":[]},{"location":"security/design/#best-practices","level":2,"title":"Best Practices","text":"<ol> <li>Review before committing: Always review <code>.context/</code> files before committing.</li> <li>Use <code>.gitignore</code>: If you must store sensitive notes locally, add them to <code>.gitignore</code>.</li> <li>Drift detection: Run <code>ctx drift</code> to check for potential issues.</li> <li>Permission audit: Review <code>.claude/settings.local.json</code> after busy sessions.</li> </ol>","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":"<code>ctx</code> Hub: Security Model","text":"<p>What the hub defends against, what it does not defend against, and the concrete mechanisms in play.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#threat-model","level":2,"title":"Threat Model","text":"<p>The hub is designed for trusted cross-project knowledge sharing within a team or homelab. It assumes:</p> <ul> <li>The hub host is trusted. Anyone with root on that box can read every entry ever published.</li> <li>Network is semi-trusted. Hub traffic is gRPC over TCP; TLS is strongly recommended but not mandatory.</li> <li>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.</li> <li>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.</li> </ul> <p>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.</p>","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":"<p>All RPCs except <code>Register</code> require a bearer token in gRPC metadata. Two kinds of tokens exist:</p> Kind Format Scope Lifetime Admin token <code>ctx_adm_...</code> Register new projects Manual rotate Client token <code>ctx_cli_...</code> Publish, Sync, Listen, Status Project lifetime <p>Tokens are compared in constant time (<code>crypto/subtle</code>) to prevent timing oracles, and looked up via an <code>O(1)</code> hash map so the comparison cost does not depend on the total number of registered clients.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#client-side-encryption-at-rest","level":3,"title":"Client-Side Encryption at Rest","text":"<p><code>.context/.connect.enc</code> 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 <code>ctx</code>'s local keyring (see <code>internal/crypto</code>).</p> <p>An attacker with read access to the project directory cannot learn the client token without also breaking <code>ctx</code>'s local keyring.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#hub-side-token-storage","level":3,"title":"Hub-Side Token Storage","text":"<p>Tokens Are Stored in Plaintext on the Hub Host</p> <p><code><data-dir>/clients.json</code> 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.</p> <p>Mitigations today:</p> <ul> <li>Run the hub as an unprivileged user and lock the data directory with <code>chmod 700 <data-dir></code>.</li> <li>Use the systemd unit in Operations, which enables <code>ProtectSystem=strict</code>, <code>NoNewPrivileges=true</code>, and a dedicated user.</li> <li>Never expose <code><data-dir></code> over NFS, SMB, or shared filesystems.</li> <li>Treat <code><data-dir></code> the same way you'd treat <code>/etc/shadow</code>: back it up encrypted, never check it into version control.</li> </ul> <p>Hashing <code>clients.json</code> 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.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#input-validation","level":3,"title":"Input Validation","text":"<p>Every published entry is validated before it touches the log:</p> <ul> <li>Type must be one of: <code>decision</code>, <code>learning</code>, <code>convention</code>, <code>task</code>. Unknown types are rejected.</li> <li>ID and Origin are required and non-empty.</li> <li>Content size is capped at 1 MB. Reasonable for text, hostile for attempts to fill the disk.</li> <li>Duplicate project registration is rejected; a client that replays an old <code>Register</code> call gets an error, not a second token.</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#no-script-execution","level":3,"title":"No Script Execution","text":"<p>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.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#audit-trail","level":3,"title":"Audit Trail","text":"<p><code>entries.jsonl</code> 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).</p>","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":"<ul> <li>Untrusted entry senders. A client with a valid token can publish anything (within the 1 MB cap). There is no content validation beyond shape.</li> <li>Denial of service from a registered client. A misbehaving client can publish until disk is full. Monitor <code>entries.jsonl</code> growth.</li> <li>Network eavesdropping without TLS. Plain gRPC leaks entry content and tokens. Use a TLS-terminating reverse proxy (see Multi-machine recipe).</li> <li>Host compromise. Root on the hub host = access to every entry and every token. Harden the host.</li> <li>Accidental secret upload. The hub will happily fan out a decision containing an API key. Sanitize content before publishing.</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#operational-hardening-checklist","level":2,"title":"Operational Hardening Checklist","text":"<ul> <li> Run the hub as an unprivileged user with <code>NoNewPrivileges=true</code> and <code>ProtectSystem=strict</code> (see the systemd unit in Operations).</li> <li> Terminate TLS in front of the hub for anything beyond a trusted LAN.</li> <li> Restrict the listen port with firewall rules to the client subnet only.</li> <li> Back up <code><data-dir>/admin.token</code> to a secrets manager; do not leave it in shell history.</li> <li> Rotate the admin token when a team member with access leaves. Client tokens keep working across rotations.</li> <li> Monitor <code>entries.jsonl</code> growth; alert on sudden spikes.</li> <li> Run NTP on all clients to prevent entry-timestamp skew.</li> <li> Do not publish from machines you do not trust.</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#responsible-disclosure","level":2,"title":"Responsible Disclosure","text":"<p>Security issues in the hub follow the same process as the rest of <code>ctx</code>; see Reporting.</p>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/hub/#see-also","level":2,"title":"See Also","text":"<ul> <li><code>ctx</code> Hub Operations</li> <li><code>ctx</code> Hub failure modes</li> <li>HA cluster recipe</li> </ul>","path":["Security","Hub Security Model"],"tags":[]},{"location":"security/reporting/","level":1,"title":"Reporting Vulnerabilities","text":"<p>Disclosure process for security issues in <code>ctx</code>. For the broader security model (trust boundaries, audit trail, permission hygiene), see Security Design.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#reporting-vulnerabilities","level":2,"title":"Reporting Vulnerabilities","text":"<p>At <code>ctx</code> we take security very seriously.</p> <p>If you discover a security vulnerability in <code>ctx</code>, please report it responsibly.</p> <p>Do NOT open a public issue for security vulnerabilities.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#email","level":3,"title":"Email","text":"<p>Send details to security@ctx.ist.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#github-private-reporting","level":3,"title":"GitHub Private Reporting","text":"<ol> <li>Go to the Security tab;</li> <li>Click \"Report a Vulnerability\";</li> <li>Provide a detailed description.</li> </ol>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#encrypted-reports-optional","level":3,"title":"Encrypted Reports (Optional)","text":"<p>If your report contains sensitive details (proof-of-concept exploits, credentials, or internal system information), you can encrypt your message with our PGP key:</p> <ul> <li>In-repo: <code>SECURITY_KEY.asc</code></li> <li>Keybase: keybase.io/alekhinejose</li> </ul> <pre><code># Import the key\ngpg --import SECURITY_KEY.asc\n\n# Encrypt your report\ngpg --armor --encrypt --recipient security@ctx.ist report.txt\n</code></pre> <p>Encryption is optional. Unencrypted reports to security@ctx.ist or via GitHub Private Reporting are perfectly fine.</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#what-to-include","level":3,"title":"What to Include","text":"<ul> <li>Description of the vulnerability,</li> <li>Steps to reproduce,</li> <li>Potential impact,</li> <li>Suggested fix (if any).</li> </ul>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#attribution","level":2,"title":"Attribution","text":"<p>We appreciate responsible disclosure and will acknowledge security researchers who report valid vulnerabilities (unless they prefer to remain anonymous).</p>","path":["Security","Reporting Vulnerabilities"],"tags":[]},{"location":"security/reporting/#response-timeline","level":2,"title":"Response Timeline","text":"<p>Open Source, Best-Effort Timelines</p> <p><code>ctx</code> is a volunteer-maintained open source project.</p> <p>The timelines below are guidelines, not guarantees, and depend on contributor availability.</p> <p>We will address security reports on a best-effort basis and prioritize them by severity.</p> 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":"<p>Volkan Özçelik - me@volkan.io</p> <p>February 2026</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#abstract","level":3,"title":"Abstract","text":"<p>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.</p> <p>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.</p> <p>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 <code>ctx</code>, 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#1-introduction","level":2,"title":"1. Introduction","text":"<p>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.</p> <p>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.</p> <p>This model has improved substantially over the past year. <code>CLAUDE.md</code> 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.</p> <p>This paper does not propose a universal replacement for retrieval-centric workflows. It defines a persistence layer (embodied in <code>ctx</code> (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. </p> <p>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 <sup>1</sup> <sup>6</sup>.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#2-the-limits-of-prompt-time-context","level":2,"title":"2. The Limits of Prompt-Time Context","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#21-non-reproducibility","level":3,"title":"2.1 Non-Reproducibility","text":"<p>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.</p> <p>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 <sup>1</sup> <sup>2</sup>. 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#22-opaque-knowledge","level":3,"title":"2.2 Opaque Knowledge","text":"<p>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) <sup>3</sup>.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#23-loss-of-intent","level":3,"title":"2.3 Loss of Intent","text":"<p>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) <sup>4</sup>.</p> <p>Session transcripts provide history. Cognitive state requires something more: the persistent, structured representation of the knowledge required for correct decision-making.</p>","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":"<p>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.</p> <p>Previous formulations of this idea have treated cognitive state as a monolithic concept. In practice, a three-tier model better captures the operational reality:</p> <p>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).</p> <p>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.</p> <p>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.</p> <p>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:</p> <pre><code>delivery_view = assemble(authoritative_state, budget, policy)\noutput = model(delivery_view) # stochastic\n</code></pre> <p>The persistence layer's contribution is making <code>assemble</code> reproducible, not making <code>model</code> deterministic.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#32-separation-of-concerns","level":3,"title":"3.2 Separation of Concerns","text":"<p>The decision to separate authoritative state into distinct files with distinct purposes is not cosmetic. Different types of knowledge have different lifecycles:</p> 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\" <p>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.</p> <p>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).</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#4-design-invariants","level":2,"title":"4. Design Invariants","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-1-markdown-on-filesystem-persistence","level":3,"title":"Invariant 1: Markdown-on-Filesystem Persistence","text":"<p>Context files must be human-readable, git-diffable, and editable with any text editor. No database. No binary storage.</p> <p>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 <code>cat DECISIONS.md</code> 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-2-zero-runtime-dependencies","level":3,"title":"Invariant 2: Zero Runtime Dependencies","text":"<p>The tool must work with no installed runtimes, no running services, and no API keys for core functionality.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-3-deterministic-context-assembly","level":3,"title":"Invariant 3: Deterministic Context Assembly","text":"<p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-4-human-authority-over-persistent-state","level":3,"title":"Invariant 4: Human Authority over Persistent State","text":"<p>The agent may propose changes to context files but must not unilaterally modify them. All persistent changes go through human-reviewable git commits.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-5-local-first-air-gap-capable","level":3,"title":"Invariant 5: Local-First, Air-Gap Capable","text":"<p>Core functionality must work offline with no network access. Cloud services may be used for optional features but never for core context management.</p> <p>Validation: 7 independent rejection decisions protected this property. Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or constrained-environment scenarios. A filesystem-native model continues to function under all conditions where the repository is accessible.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#invariant-6-no-default-telemetry","level":3,"title":"Invariant 6: No Default Telemetry","text":"<p>Any analytics, if ever added, must be strictly opt-in.</p> <p>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.</p> <p>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.<sup>1</sup></p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#5-landscape-analysis","level":2,"title":"5. Landscape Analysis","text":"<p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#51-primitive-taxonomy","level":3,"title":"5.1 Primitive Taxonomy","text":"<p>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:</p> <p>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 <code>CLAUDE.md</code> files) as partial participants: both use document-based context as an input but organize around different core primitives.</p> <p>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.</p> <p>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).</p> <p>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.</p> <p>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).</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#52-comparison-matrix","level":3,"title":"5.2 Comparison Matrix","text":"<p>The five primitive categories differ along seven dimensions:</p> 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 <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#53-convergent-patterns","level":3,"title":"5.3 Convergent Patterns","text":"<p>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:</p> <p>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.</p> <p>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).</p> <p>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 <sup>5</sup>.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","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":"<p>We now instantiate the three-tier model in a concrete system (<code>ctx</code>) and illustrate the difference between prompt-time retrieval and cognitive state persistence using a real scenario from its development.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#61-the-problem","level":3,"title":"6.1 The Problem","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#62-prompt-time-retrieval-model","level":3,"title":"6.2 Prompt-Time Retrieval Model","text":"<p>In a retrieval-based system, the decision to remove the middle layer depends on whether the retrieval function surfaces the relevant context:</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#63-cognitive-state-model","level":3,"title":"6.3 Cognitive State Model","text":"<p>In the persistence model, the decision is recorded as a structured artifact at write time:</p> <pre><code>## [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</code></pre> <p>This artifact is:</p> <ul> <li>Deterministically included in every subsequent session's delivery view (budget permitting, with title-only fallback if budget is exceeded)</li> <li>Human-readable and reviewable as a diff in the commit that introduced it</li> <li>Permanent: it persists in version control regardless of retrieval heuristics</li> <li>Causally linked: it explicitly supersedes four earlier decisions, creating an auditable chain</li> </ul> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#64-the-diff-when-policy-changes","level":3,"title":"6.4 The Diff When Policy Changes","text":"<p>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:</p> <pre><code>- **Status**: Accepted\n+ **Status**: Superseded by [2026-08-15] Reintroduce session storage\n+ for multi-agent correlation\n</code></pre> <p>The new decision record references the old one, creating a chain of reasoning visible in <code>git log</code>. In the retrieval model, the old decision would simply be ranked lower over time and eventually forgotten.</p>","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":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#71-scale-and-structure","level":3,"title":"7.1 Scale and Structure","text":"<p>The development produced the following authoritative state artifacts:</p> <ul> <li>8 consolidated decision records covering 24 original decisions spanning context injection architecture, hook design, task management, security, agent autonomy, and webhook systems</li> <li>18 consolidated learning records covering 75 original observations spanning agent compliance, hook behavior, testing patterns, documentation drift, and tool integration</li> <li>A constitution with 13 inviolable rules across 4 categories (security, quality, process, context preservation)</li> <li>389 enriched journal entries providing a complete session-level audit trail</li> </ul> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#72-architectural-reversals","level":3,"title":"7.2 Architectural Reversals","text":"<p>Three architectural reversals during development provide evidence that the persistence model captures and communicates reasoning effectively:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#73-compliance-ceiling","level":3,"title":"7.3 Compliance Ceiling","text":"<p>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.</p> <p>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).</p> <p>The architectural response maps directly to the formal model defined in Section 3.1. Content requiring 100% compliance is included in <code>authoritative_state</code> and injected by the deterministic <code>assemble</code> 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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#74-compounding-returns","level":3,"title":"7.4 Compounding Returns","text":"<p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#75-scope-and-generalizability","level":3,"title":"7.5 Scope and Generalizability","text":"<p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#8-situating-the-persistence-layer","level":2,"title":"8. Situating the Persistence Layer","text":"<p>The persistence layer occupies a specific position in the stack of AI-assisted development:</p> <pre><code>Application Logic\nAI Interaction / Agents\nContext Retrieval Systems\nCognitive State Persistence Layer\nVersion Control / Storage\n</code></pre> <p>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.</p>","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":"<p>A cognitive state persistence layer is most appropriate when:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>Offline or air-gapped operation is required: Infrastructure-dependent memory systems cannot operate in classified environments, isolated networks, or constrained-environment scenarios.</p>","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":"<p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#93-incremental-adoption","level":3,"title":"9.3 Incremental Adoption","text":"<p>The transition does not require full system replacement. An incremental path:</p> <p>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 <sup>4</sup>. This alone converts ephemeral reasoning into the cognitive state.</p> <p>Step 2: Make inclusion deterministic: Define explicit assembly rules. Retrieval may still exist, but it is no longer authoritative.</p> <p>Step 3: Move policy into cognitive state: When system behavior depends on stable constraints, encode those constraints as versioned knowledge. Behavior becomes reproducible.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#94-the-curation-cost","level":3,"title":"9.4 The Curation Cost","text":"<p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#10-future-work","level":2,"title":"10. Future Work","text":"<p>Several directions are compatible with the model described here:</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#11-conclusion","level":2,"title":"11. Conclusion","text":"<p>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.</p> <p>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.</p> <p>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.</p> <p>When context is the state:</p> <ul> <li>Reasoning is reproducible: the same authoritative state, budget, and policy produce the same delivery view.</li> <li>Knowledge is auditable: decisions are traceable to explicit artifacts with context, rationale, and consequences.</li> <li>Understanding compounds: each session's curation improves all subsequent sessions.</li> </ul> <p>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.</p> <p>🐸🖤 \"Gooood... let the deterministic context flow through the repository...\" - Kermit the Sidious, probably</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#appendix-a-representative-rejection-decisions","level":2,"title":"Appendix A: Representative Rejection Decisions","text":"<p>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.</p> <p>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 (<code>kin show <id></code> vs. <code>cat DECISIONS.md</code>).</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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.</p> <p>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).</p>","path":["The Thesis"],"tags":[]},{"location":"thesis/#references","level":2,"title":"References","text":"<ol> <li> <p>Reproducible Builds Project, \"Reproducible Builds: Increasing the Integrity of Software Supply Chains\", 2017. https://reproducible-builds.org/docs/definition/ ↩↩↩</p> </li> <li> <p>S. McIntosh et al., \"The Impact of Build System Evolution on Software Quality\", ICSE, 2015. https://doi.org/10.1109/ICSE.2015.70 ↩</p> </li> <li> <p>C. Manning, P. Raghavan, H. Schütze, Introduction to Information Retrieval, Cambridge University Press, 2008. https://nlp.stanford.edu/IR-book/ ↩</p> </li> <li> <p>M. Nygard, \"Documenting Architecture Decisions\", Cognitect Blog, 2011. https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions ↩↩</p> </li> <li> <p>L. Torvalds et al., Git Internals - Git Objects (content-addressed storage concepts). https://git-scm.com/book/en/v2/Git-Internals-Git-Objects ↩</p> </li> <li> <p>Kief Morris, Infrastructure as Code, O'Reilly, 2016. ↩</p> </li> <li> <p>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 ↩</p> </li> <li> <p>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 ↩</p> </li> </ol>","path":["The Thesis"],"tags":[]}]} \ No newline at end of file diff --git a/specs/opencode-skill-parity.md b/specs/opencode-skill-parity.md new file mode 100644 index 000000000..e61fefccd --- /dev/null +++ b/specs/opencode-skill-parity.md @@ -0,0 +1,87 @@ +# Spec: OpenCode Skill Parity — Generate the Tree from Canonical Claude Skills + +Issue: https://github.com/ActiveMemory/ctx/issues/158 + +## Problem + +The OpenCode integration ships 10 hand-written skills while Claude has +54 and Copilot CLI has 49. The entire planning arc documented in the +[Design Before Coding](https://ctx.ist/recipes/design-before-coding/) +recipe — `/ctx-brainstorm`, `/ctx-spec`, `/ctx-task-out`, +`/ctx-implement` — is absent, so OpenCode users cannot follow the +project's own recommended design workflow. + +Diffing the 10 hand-written skills against their Claude counterparts +shows the terseness is mostly truncated reference material (dropped +flag tables, output descriptions), not OpenCode-specific adaptation. +Two conventions coexisting in one tree is unintentional divergence. + +## Approach + +Align OpenCode with the Copilot CLI model: generate the tree from the +canonical Claude skills at build time. `hack/sync-copilot-skills.sh` +already proves the shape in production (see the closed issue #61): +derive each enrolled skill from +`internal/assets/claude/skills/<name>/SKILL.md` with the Claude-specific +`allowed-tools:` frontmatter key stripped, opt-in by directory +presence, wired into `make build`, gated by a `check-*` target in +`make audit`. + +No Go changes: the embed glob +(`integrations/opencode/skills/*/SKILL.md`), `agent.OpenCodeSkills()`, +and `deploySkills()` all walk whatever directories exist. + +## Deliverables + +1. **`hack/sync-opencode-skills.sh`** — sibling of + `hack/sync-copilot-skills.sh`, same contract: iterate + `internal/assets/integrations/opencode/skills/*/`, overwrite each + `SKILL.md` from the Claude source with `allowed-tools:` stripped; + skills with no Claude counterpart are left untouched. +2. **Makefile wiring** — `sync-opencode-skills` runs as part of + `make build`; `check-opencode-skills` (freshness gate, mirrors + `check-copilot-skills`) runs as part of `make audit`. +3. **Enrollment** — the existing 10 skills (ctx-agent, ctx-handover, + ctx-kb-ask, ctx-kb-ground, ctx-kb-ingest, ctx-kb-note, + ctx-kb-site-review, ctx-remember, ctx-status, ctx-wrap-up) become + synced; 7 new skills enroll: the planning arc (ctx-brainstorm, + ctx-spec, ctx-task-out, ctx-implement, ctx-plan) plus the capture + pair the arc's workflow leans on (ctx-task-add, ctx-decision-add). + 17 total, canonical Claude names throughout. +4. **Docs** — `docs/home/opencode.md` slash-command section updated + from the hand-listed 4 to the full synced set. + +## Decisions + +- **Canonical bodies replace terse variants.** The issue's open + question (a `terse` transform for OpenCode's context budget) is + resolved as: no terse transform. The truncation was unintentional + divergence. The few genuinely OpenCode-specific lines in the + hand-written bodies (e.g. ctx-status's "the slash command takes no + arguments" note) are dropped with them; if OpenCode-specific + adaptation is ever needed, the honest fix is a transform in the sync + script, not hand-edits that the next sync overwrites. +- **The five planning-arc skills carry no `allowed-tools:` key**, so + their sync transform is a byte-identical copy. Their `/ctx-*` + cross-references are closed within the enrolled set. + +## Acceptance Criteria + +- [ ] `hack/sync-opencode-skills.sh` exists and mirrors the Copilot + script's contract +- [ ] `make build` syncs OpenCode skills; `make check-opencode-skills` + fails on staleness +- [ ] The Design Before Coding arc is available in OpenCode +- [ ] Enrolled OpenCode skills are byte-identical to their Claude + source minus `allowed-tools:` +- [ ] Skill names align 1:1 with the Claude tree +- [ ] Build, lint, and compliance tests pass + (`TestSkillFrontmatter` covers the new dirs via the embed glob) + +## Non-Goals + +- Renaming or enrolling the 14 legacy-named unsynced Copilot skills + (separate concern; OpenCode already uses canonical names) +- A terse/summarizing transform in the sync script +- Any change to skill deployment (`ctx setup opencode --write`) or the + embed layer