{"slug": "show-hn-directed-contexts-repo-owned-instruction-modules-for-coding-agents", "title": "Show HN: Directed Contexts – repo-owned instruction modules for coding agents", "summary": "A developer released Directed Contexts, an open-source pattern for creating repository-owned instruction modules that coding agents can load inline or spawn in isolation, enabling bounded codebase ownership and deterministic validation. The project includes a scanner, generator, and drift detection tool, extracted from a working prototype and hardened with mechanisms from sibling repositories.", "body_md": "Generate bounded codebase ownership contexts that agents can load inline or spawn in isolation.\n\nA **Directed Context** is a repository-owned instruction module with an\nexplicit domain, owned paths, invariants, adjacent contexts, and verification\ncontract. This repository ships the pattern specification, a generator skill\nthat produces context sets for any repository, a deterministic validation\ntool, and two golden examples.\n\nThe outputs are portable Markdown. They do not require Claude, Codex, Copilot, or any particular subagent implementation — a harness with native subagents can spawn one scoped by a context; a harness without them loads the same context inline.\n\n```\nyour-repo/\n├── AGENTS.md                    # Context Router: universal rules + routing tables\n└── .subagents/\n    ├── README.md                # Context index\n    ├── AGENTS-RUNTIME.md        # Directed context (primary owner of paths)\n    ├── AGENTS-WORKER.md         # Directed context (primary owner of paths)\n    ├── AGENTS-SECURITY.md       # Policy overlay (cross-cutting, owns no paths)\n    └── route-cases.json         # Testable routing fixtures\n```\n\nThe codebase is the state.\n\n`AGENTS.md`\n\nis the map.`.subagents/*.md`\n\nare bounded ownership contexts. The runtime chooses whether to load or spawn.\n\nThe pattern was extracted from a working prototype —\n[leather](https://github.com/TGPSKI/leather)'s seventeen-guide `.subagents/`\n\nrouting table — and hardened with mechanisms from three sibling repositories:\nit sits beside [directed-workflows](https://github.com/TGPSKI/directed-workflows)\n(processes agents walk users through), borrows its coordinate-verification\ngate from [abductive-triage](https://github.com/TGPSKI/abductive-triage), and\ntakes its detect-deterministically/ask-only-judgment split from\n[security-context-spec](https://github.com/TGPSKI/security-context-spec).\nThe full ancestry, including what the prototype still teaches the\nabstraction, is in [LINEAGE.md](/TGPSKI/directed-contexts/blob/main/LINEAGE.md).\n\nPoint your agent at a repository and invoke the skill (`SKILL.md`\n\n). It will:\n\n- Run the deterministic scanner —\n`contextctl scan`\n\n— to inventory packages, entry points, existing instructions, CODEOWNERS, and commands. - Verify the repo's coordinate system (root, monorepo boundaries, source vs. generated trees) before modeling anything.\n- Propose ownership boundaries from weighted evidence, asking only about genuinely ambiguous ones.\n- Generate the contexts, index, router, and route-case fixtures.\n- Validate everything mechanically.\n\n```\n# what the skill runs under the hood\ngo run scripts/contextctl.go scan   --repo /path/to/your/repo\ngo run scripts/contextctl.go check  --repo /path/to/your/repo\ngo run scripts/contextctl.go routes --repo /path/to/your/repo --cases .subagents/route-cases.json\n```\n\nFor a repo that already has a router and contexts, the skill routes to audit mode:\n\n```\ngo run scripts/contextctl.go check --repo /path/to/your/repo\ngo run scripts/contextctl.go drift --repo /path/to/your/repo\n```\n\n`drift`\n\nreports unowned packages, deleted owned paths, overlapping claims,\nstale review dates, missing verification commands, and split/merge\ncandidates.\n\n| Path | Contents |\n|---|---|\n|\n\n[LINEAGE.md](/TGPSKI/directed-contexts/blob/main/LINEAGE.md)[SKILL.md](/TGPSKI/directed-contexts/blob/main/SKILL.md)[references/](/TGPSKI/directed-contexts/blob/main/references)[scripts/contextctl.go](/TGPSKI/directed-contexts/blob/main/scripts/contextctl.go)`scan`\n\n, `check`\n\n, `routes`\n\n, `drift`\n\n[assets/templates/](/TGPSKI/directed-contexts/blob/main/assets/templates)[examples/abductive-triage/](/TGPSKI/directed-contexts/blob/main/examples/abductive-triage)[examples/security-context-spec/](/TGPSKI/directed-contexts/blob/main/examples/security-context-spec)| Term | Meaning |\n|---|---|\nContext Router |\nRoot `AGENTS.md` ; maps work signals and paths to contexts |\nDirected Context |\nOne `.subagents/AGENTS-{DOMAIN}.md` module |\nContext Set |\nThe router plus every directed context |\nPrimary context |\nThe sole owner of a package/path |\nPolicy overlay |\nCross-cutting security, performance, operations, or quality context |\nInline load |\nRead the context into the current session |\nIsolated spawn |\nStart a subagent scoped by that context |\nRoute case |\nA representative task with an expected context selection |\nContext drift |\nCodebase structure or behavior no longer matching the router/guides |\n\nFull definitions and invariants live in [PATTERN.md](/TGPSKI/directed-contexts/blob/main/PATTERN.md).\n\n**The Markdown is canonical.** There is no hidden manifest;`contextctl`\n\nparses and validates the routing tables and context files directly.**Contexts are coordination, not authorization.** A spawned subagent inherits the caller's permissions; ownership scopes are never security enforcement.**Deterministic where possible, human where necessary.** The scanner answers every question that lives on disk; users decide only contested boundaries.**Read-only by default.** The scanner never writes, never executes repository content, never follows symlinks out of the repo, and generation shows the proposed file set before writing.\n\nRequires Go 1.22+.\n\n```\nmake test            # unit tests (fixtures + golden examples)\nmake check           # lint + format check + tests + golden validation\nmake check-examples  # validate both golden context sets\nmake scan REPO=...   # run the scanner against any repo\n```\n\n", "url": "https://wpnews.pro/news/show-hn-directed-contexts-repo-owned-instruction-modules-for-coding-agents", "canonical_source": "https://github.com/TGPSKI/directed-contexts", "published_at": "2026-07-11 11:15:49+00:00", "updated_at": "2026-07-11 11:35:03.169227+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents", "ai-tools"], "entities": ["TGPSKI", "leather", "directed-workflows", "abductive-triage", "security-context-spec", "Claude", "Codex", "Copilot"], "alternates": {"html": "https://wpnews.pro/news/show-hn-directed-contexts-repo-owned-instruction-modules-for-coding-agents", "markdown": "https://wpnews.pro/news/show-hn-directed-contexts-repo-owned-instruction-modules-for-coding-agents.md", "text": "https://wpnews.pro/news/show-hn-directed-contexts-repo-owned-instruction-modules-for-coding-agents.txt", "jsonld": "https://wpnews.pro/news/show-hn-directed-contexts-repo-owned-instruction-modules-for-coding-agents.jsonld"}}