--- name: context argument-hint: "[file, directory, or topic; leave empty for current-focus pickup]" description: "Surface the rules, ADRs, specs, patterns, and reference docs that apply to a code area before changing it — or recap project focus when picking up work. Use for 'what rules apply to X', 'before I touch Y', 'pick up where we left off', 'load project context'. Not for creating docs, planning, or audits." --- # /archcore:context Pull-mode project context. Surfaces the rules, decisions, specs, and patterns that apply to a code area before you change it — or recaps current focus when picking up work. _Not related to the AI context window or session state — this is about the `.archcore/` knowledge base._ ## When to use - "What rules apply to `src/payments/`?" - "Before I refactor the auth module, show me what I should know" - "Show me the decisions for `src/api/`" - "Pick up where we left off" - "What was I working on in payments?" - "Where is the checkout work right now?" - "Load project context" **Not context:** - Creating documentation → `/archcore:capture`, `/archcore:decide` - Planning a feature → `/archcore:plan` - Detecting stale docs → `/archcore:audit --drift` - Health audit, counts, or status breakdown → `/archcore:audit` (`--deep` for the full audit) ## Routing table Classify `$ARGUMENTS` into one mode: | Signal | Mode | |---|---| | Empty or whitespace only | **pickup** | | Contains `/`, OR matches an existing repo directory | **path** | | Otherwise | **topic** | ## Execution ### Step 1: Classify Determine mode from `$ARGUMENTS` per routing table. ### Step 2: Query **Path mode:** Normalize the argument: trim whitespace, convert `\` to `/`, strip trailing `/`. Call `mcp__archcore__search_documents(path_ref="", limit=50, sort="relevance")`. **Topic mode:** Call `mcp__archcore__search_documents(content="", limit=50, sort="relevance")`. Topic search is strict substring — singular/plural and near-synonyms do not match. If the first call returns empty, retry once with a shorter or alternate phrasing of the same term before falling through to the empty state. **Pickup mode:** Call in parallel: - `mcp__archcore__search_documents(types=["plan", "idea"], status="draft", limit=10, sort="mtime")` - `mcp__archcore__search_documents(types=["adr", "rule"], status="accepted", mtime_after="30d", limit=10, sort="mtime")` If the recent-accepted call returns empty, retry once with `mtime_after="90d"`. ### Step 3: Group **Path and topic modes** — group results by type: | Section | Types included | |---|---| | Rules | `rule` | | Decisions | `adr` | | Specs | `spec` | | Patterns | `cpat` | | Reference | `doc`, `rfc`, orphan `guide` (any `guide` not inlined by Step 4) | | In Progress | `plan` or `idea` with status `draft` | Drop remaining types — accepted `plan`/`idea`, `task-type`, and vision/requirements (`prd`, `mrd`, `brd`, `urd`, `brs`, `strs`, `syrs`, `srs`). Results are already sorted by `search_documents` (specificity → type priority → mtime); keep the top 5 per section. Inside Reference the same sort applies, so `rfc` (typeRank 3) outranks `guide` (6) and `doc` (17) when specificity ties. **Pickup mode** — three fixed sections: - **In Progress** — results from the drafts call - **Recent Decisions** — `adr` results from the recent-accepted call - **Recent Rules** — `rule` results from the recent-accepted call ### Step 4: Guide routing For each item in the Rules, Decisions, or Specs sections, inspect its `incoming_relations`. If a relation of type `implements` or `related` points from a `guide`, inline that guide as an indented bullet under the parent. Skip a guide that is already inlined under a sibling in the same section. Track the set of guide paths inlined this way — any `guide` present in the search results but **not** in this set is an "orphan guide" and is routed to the Reference section in Step 3 instead of being dropped. ### Step 5: Render ``` ## Rules (N) - **** [rule · <status> · <match.kind>] `<path>` > <excerpt> - 📖 **<guide title>** [guide · <status>] ## Decisions (N) - **<title>** [adr · <status> · <match.kind>] `<path>` > <excerpt> ## Specs (N) ... ## Patterns (N) ... ## Reference (N) - **<title>** [<type> · <status> · <match.kind>] `<path>` > <excerpt> ## In Progress (N) ⚠️ **<title>** [plan · draft] `<path>` > <excerpt> _Classified as: <mode>._ ``` **Do NOT emit a section header if its group is empty.** The classification footer is always emitted. If all sections are empty, fall through to Step 6. ### Step 6: Empty state - Call `mcp__archcore__list_documents(limit=1)`. If the knowledge base is empty → "No documents indexed yet. Run `/archcore:capture` or `/archcore:decide` to seed `.archcore/`." - Otherwise → "No documents reference `<scope>`. Consider using `@<scope>` in a rule or ADR so future work in this area surfaces the context automatically." ## Result A grouped markdown surface of the rules, ADRs, specs, patterns, reference docs (`doc`, `rfc`, orphan `guide`), and in-progress work that applies to the requested scope — or a pickup summary of draft work + recent accepted decisions and rules when called with no argument. A classification footer identifies which mode was chosen.