Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/agent-work-item.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Agent work item
about: Minimal issue body for agent-consumable units of work
title: ""
labels: agent-work
---

## Context
- SKILL.md

## Work
- [ ]
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- `PATTERN.md`: the Directed Contexts pattern specification — vocabulary,
invariants, context kinds, router contract, ownership matching, route
cases, and instruction-file classification.
- `SKILL.md`: the `generate-directed-contexts` skill router with operating
- `SKILL.md`: the `directed-contexts` skill router with operating
modes for bootstrap, adopt, recover, audit, and decline.
- `references/`: phase modules for coordinate check, boundary model,
generation, validation, adoption of existing instruction files, and
lifecycle maintenance.
- `scripts/contextctl.go`: stdlib-only Go tool with `scan` (deterministic
JSON inventory), `check` (Markdown contract validation), `routes`
(route-case evaluation), and `drift` (codebase/context-set divergence).
`scan` reports `instruction_surfaces.primary_surface` — the root file an
agent reads first, resolved by precedence: Context Router, root `SKILL.md`,
root `AGENTS.md`, root harness alias.
- `assets/templates/`: skeletons for the root router, context index, domain
context, policy context, and the target-repo lifecycle skill.
context, policy context, the target-repo lifecycle skill, and the agent
work-item issue template.
- `.github/ISSUE_TEMPLATE/agent-work-item.md`, and Phase 3 Step 7 generating
the same template for target repos with the Context line resolved from the
scan.
- Golden examples for
[abductive-triage](https://github.com/TGPSKI/abductive-triage) (semantic
ownership) and
Expand Down
9 changes: 4 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Contributing

Thanks for your interest in Directed Contexts.

## Ground rules

- **The pattern is the product.** `PATTERN.md` is canonical. Changes to the
Expand Down Expand Up @@ -44,6 +42,7 @@ A new golden example needs:

## Reporting issues

Use GitHub issues. For validation bugs, include the offending Markdown and
the `contextctl` output. For boundary-modeling discussion, a route case that
routes wrongly is worth a thousand words.
Use GitHub issues; `agent-work-item` is the template for agent-consumable
work. For validation bugs, include the offending Markdown and the `contextctl`
output. For boundary-modeling discussion, include a route case that routes
wrongly.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ candidates.
| [SKILL.md](SKILL.md) | The generator skill router |
| [references/](references/) | Phase modules: coordinate check, boundary model, generate, validate, adoption, lifecycle |
| [scripts/contextctl.go](scripts/contextctl.go) | Stdlib-only Go tool: `scan`, `check`, `routes`, `drift` |
| [assets/templates/](assets/templates/) | Skeletons for the router, domain/policy contexts, index, and lifecycle skill |
| [assets/templates/](assets/templates/) | Skeletons for the router, domain/policy contexts, index, lifecycle skill, and issue template |
| [examples/abductive-triage/](examples/abductive-triage/) | Golden example: semantic ownership in an all-Markdown repo |
| [examples/security-context-spec/](examples/security-context-spec/) | Golden example: mixed spec/tooling/workflow ownership |

Expand Down
11 changes: 6 additions & 5 deletions SKILL.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: generate-directed-contexts
name: directed-contexts
description: "Generate bounded codebase ownership contexts that agents can load inline or spawn in isolation. Analyzes a repository, proposes ownership boundaries, and produces a root AGENTS.md router plus .subagents/ context modules with executable validation. Use when asked to create directed contexts, split a large AGENTS.md, set up subagent contexts, add an agent routing table, or audit an existing context set."
license: GPL-3.0
compatibility: "Requires Go toolchain (1.22+) for the contextctl scan/check/routes/drift tool."
Expand Down Expand Up @@ -69,7 +69,7 @@ Inspect the scan output's `instruction_surfaces` to select an operating mode.
| Router and contexts exist | **Audit** — run `contextctl check` + `drift`, then `references/lifecycle.md` |
| Native `.claude/agents/` or `.github/agents/` exist | Preserve them; classify personas vs. ownership contexts per `PATTERN.md`, then continue detected mode |
| Nested `AGENTS.md` files exist | Decide retain-vs-consolidate per `references/adoption-existing-agents.md`, then continue |
| Repository too small for meaningful partitioning | **Decline** — recommend one concise `AGENTS.md`; do not manufacture contexts |
| Repository too small for meaningful partitioning | **Decline** — recommend one concise `AGENTS.md`; do not manufacture contexts. The Phase 3 Step 7 issue template still applies |

**Too small** means any two of: fewer than ~30 source files, one package root,
one entry point, one audience. Say so plainly and stop.
Expand All @@ -91,8 +91,8 @@ one entry point, one audience. Say so plainly and stop.
| ----- | ---------------------------------------- | -------------------------------------------------- | ------------------------ |
| 1 | `references/phase-01-coordinate-check.md` | Verify repo coordinates before modeling anything | Nothing |
| 2 | `references/phase-02-boundary-model.md` | Propose ownership boundaries with weighted evidence | Proposal table only |
| 3 | `references/phase-03-generate.md` | Generate contexts, index, router, lifecycle skill | The context set |
| 4 | `references/phase-04-validate.md` | Mechanical checks and route-case validation | Route-case fixtures |
| 3 | `references/phase-03-generate.md` | Generate contexts, index, router, lifecycle skill, route cases, issue template | The context set |
| 4 | `references/phase-04-validate.md` | Mechanical checks and route-case validation | Nothing |
| — | `references/adoption-existing-agents.md` | Rules for existing AGENTS.md / nested files / personas | — |
| — | `references/lifecycle.md` | Audit, drift, split/merge maintenance loop | — |

Expand All @@ -108,7 +108,7 @@ Each phase inherits from its predecessors — never re-ask for these:
| --------------------------- | -------------- |
| Repo root and package roots | Phase 1 |
| Source vs. generated/vendor classification | Phase 1 |
| Instruction-surface inventory | Phase 1 |
| Instruction-surface inventory, including the primary surface | Phase 1 |
| Confirmed boundary table | Phase 2 |
| Context names and owned paths | Phase 2 |
| Generated file list | Phase 3 |
Expand All @@ -122,6 +122,7 @@ Each phase inherits from its predecessors — never re-ask for these:
| `assets/templates/domain-context.md` | Primary domain context skeleton |
| `assets/templates/policy-context.md` | Policy overlay skeleton |
| `assets/templates/maintain-directed-contexts/SKILL.md` | Lifecycle skill for the target repo |
| `assets/templates/agent-work-item.md` | Target-repo issue template |

After generation, always run:

Expand Down
2 changes: 1 addition & 1 deletion assets/templates/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# {REPO_NAME} — Agent Instructions

<!-- Context Router. Generated by generate-directed-contexts; maintained by humans.
<!-- Context Router. Generated by the directed-contexts skill; maintained by humans.
This routing table is canonical — tooling parses this Markdown directly. -->

{ONE_PARAGRAPH_REPO_DESCRIPTION}
Expand Down
12 changes: 12 additions & 0 deletions assets/templates/agent-work-item.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Agent work item
about: Minimal issue body for agent-consumable units of work
title: ""
labels: agent-work
---

## Context
- {PRIMARY_INSTRUCTION_SURFACE}

## Work
- [ ]
6 changes: 5 additions & 1 deletion examples/abductive-triage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ skill, not by any domain.

- `source.json` — pinned source commit metadata
- `inventory.json` — deterministic `contextctl scan` snapshot at that commit
- `expected/` — the complete generated context set
- `expected/` — the complete generated context set, issue template included

The issue template's Context line is `AGENTS.md`, not the source repo's
pre-generation primary surface (`SKILL.md`): the router this run generates
outranks it. See `references/phase-03-generate.md`, Step 7.

## Validate

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Agent work item
about: Minimal issue body for agent-consumable units of work
title: ""
labels: agent-work
---

## Context
- AGENTS.md

## Work
- [ ]
1 change: 1 addition & 0 deletions examples/abductive-triage/inventory.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"languages": [],
"entry_points": [],
"instruction_surfaces": {
"primary_surface": "SKILL.md",
"root_agents_md": true,
"has_routing_table": false,
"nested_agents_md": [],
Expand Down
2 changes: 1 addition & 1 deletion examples/security-context-spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ keep new files inside automatically owned.

- `source.json` — pinned source commit metadata
- `inventory.json` — deterministic `contextctl scan` snapshot at that commit
- `expected/` — the complete generated context set
- `expected/` — the complete generated context set, issue template included

## Validate

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Agent work item
about: Minimal issue body for agent-consumable units of work
title: ""
labels: agent-work
---

## Context
- AGENTS.md

## Work
- [ ]
1 change: 1 addition & 0 deletions examples/security-context-spec/inventory.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"tools/validate"
],
"instruction_surfaces": {
"primary_surface": "AGENTS.md",
"root_agents_md": true,
"has_routing_table": false,
"nested_agents_md": [],
Expand Down
2 changes: 1 addition & 1 deletion references/adoption-existing-agents.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: adoption-existing-agents
description: "Rules for adopting a repository that already has instruction files: monolithic AGENTS.md, nested AGENTS.md hierarchies, CLAUDE.md aliases, native personas, and skills."
parent: generate-directed-contexts
parent: directed-contexts
metadata:
author: TGPSKI
version: "0.1"
Expand Down
3 changes: 2 additions & 1 deletion references/lifecycle.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: lifecycle
description: "Audit and maintenance loop for an existing context set: drift detection, split/merge decisions, review-date hygiene."
parent: generate-directed-contexts
parent: directed-contexts
metadata:
author: TGPSKI
version: "0.1"
Expand Down Expand Up @@ -40,6 +40,7 @@ go run scripts/contextctl.go drift --repo /path/to/target/repo
| Stale review date | Re-read the guide against the code; fix or confirm, then re-date |
| Verification command missing | Replace with a command that exists; never leave aspirational commands |
| New entry point / trust surface | Check whether an overlay's activation table covers it |
| Issue-template Context line points at a moved or deleted file | Repoint it at the current primary instruction surface |
| Context above split threshold | Step 3 |
| Context below merge threshold | Step 4 |

Expand Down
7 changes: 5 additions & 2 deletions references/phase-01-coordinate-check.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: phase-01-coordinate-check
description: "Verify the repository's coordinate system — root, package layout, source classification, instruction surfaces — before any boundary modeling."
parent: generate-directed-contexts
parent: directed-contexts
metadata:
author: TGPSKI
version: "0.1"
Expand Down Expand Up @@ -32,7 +32,9 @@ The scan establishes, without asking the user:
`pyproject.toml`, `Cargo.toml`, `pom.xml`, `Makefile`, …);
- languages and manifests;
- source versus generated/vendor/build trees;
- existing `AGENTS.md`, `CLAUDE.md`, `CODEX.md`, skills, and native agents;
- existing `AGENTS.md`, `CLAUDE.md`, `CODEX.md`, skills, and native agents,
and which of them is the repository's primary instruction surface
(`instruction_surfaces.primary_surface`);
- CODEOWNERS and ownership documentation;
- entry points, binaries, APIs, and deployment units;
- build, test, lint, and validation commands (from Makefile targets and
Expand Down Expand Up @@ -95,6 +97,7 @@ A short coordinate summary the user confirms, carried forward to Phase 2:
- Package roots: {list}
- Source trees: {list} | Generated: {list} | Vendored: {list}
- Instruction surfaces: {list, with router/context/skill/persona classification}
- Primary instruction surface: {path, or "none"}
- Declared ownership: {CODEOWNERS summary or "none"}
- Build/test commands: {list}
- Unresolved questions: {none, or the questions asked above}
Expand Down
14 changes: 13 additions & 1 deletion references/phase-02-boundary-model.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: phase-02-boundary-model
description: "Construct candidate ownership domains from weighted evidence, resolve ambiguous boundaries with competing hypotheses, and produce a confirmed boundary table."
parent: generate-directed-contexts
parent: directed-contexts
metadata:
author: TGPSKI
version: "0.1"
Expand Down Expand Up @@ -91,6 +91,18 @@ Rules the table must satisfy:
- Every source path from Phase 1 is either owned or deliberately left
unowned with a stated reason.

Present the file set the table implies alongside it, so the user sees every
path Phase 3 will write before confirming:

| File | What it is |
| --------------------------------------------- | --------------------------------------- |
| `AGENTS.md` | Router; replaces or absorbs any existing root file |
| `.subagents/README.md` | Context index |
| `.subagents/AGENTS-{DOMAIN}.md` | One per row of the table above |
| `.subagents/route-cases.json` | Route fixtures |
| `.agents/skills/maintain-directed-contexts/SKILL.md` | Lifecycle skill, if accepted |
| `.github/ISSUE_TEMPLATE/agent-work-item.md` | Issue template, unless the repo is not on GitHub |

## Step 5: Confirm

**Decide**: Present the table. Ask the user **only** about medium- or
Expand Down
Loading