# Agent Context Router

Use this lightweight router before reading context or calling generator tools.

## Default Load Path

1. Read the user task and `AGENTS.md`.
2. Classify the task family.
3. Open `contexts/overview.md` when you need the local context map.
4. Load only the relevant local files under `contexts/`.
5. Add supplied `projectContext` / `projectContextJson` when available.
6. If an optional Bloomreach CLI `context/` export exists, use `context/context-router.md`, `context/search-index.json`, and selected `context/cards/**/*.md`.
7. Use raw JSON only for selected-object fallback detail.
8. Build a task packet before answering, generating, debugging, or reviewing.

## Task Families

### Strategy

Use for broad segmentation, lifecycle, opportunity, campaign, or audit requests.

Load:

- `contexts/team.md` when business rules, offer policy, or brand context matter
- `contexts/industries/<industry>.md`
- `contexts/platforms/bloomreach.md`
- `contexts/use-cases/<industry>.json`
- `contexts/projects/<project>/project.md`, `schema.md`, and `assets.md` when targeting a saved local project
- supplied `projectContextJson` for current project evidence

If Bloomreach CLI context exists, read `context/cards/index.md` only for broad inventory or coverage tasks.

### Scenario

Use when the task asks for a scenario, journey, automation flow, trigger, wait, branch, content node, or implementation checklist.

Load:

- strategy context above, scoped to the request
- relevant saved project files under `contexts/projects/<project>/`
- supplied `projectContextJson` for exact event, property, consent, frequency, and existing-scenario evidence
- optional CLI scenario card and selected raw `context/scenarios.json#<id>` only when working from a named existing scenario

### Content

Use for email, SMS, push, weblayer copy, Jinja, personalization, or visual structure.

Load:

- `contexts/team.md` for voice, offer, consent, suppression, and do-not-touch rules
- industry context for channel norms and risk
- selected scenario/segment evidence from the task packet
- supplied project context for exact variables/properties

### Debug Or Review

Use when the user reports a symptom, asks why something is wrong, or asks for review.

Load:

- the smallest local and supplied project context needed to reproduce the reasoning
- optional CLI cards for named existing assets if available
- selected raw fallback only for exact payloads, filters, thresholds, or node config

### Answer

Use for concise explanations and repo questions.

Load:

- `README.md`, `AGENTS.md`, and targeted docs/source files
- no Bloomreach project context unless the question needs it

## Task Packet

Before tool calls or final synthesis, assemble:

- goal and task family
- industry and project if known
- loaded local context files
- supplied project context used
- optional CLI cards/raw objects used
- confirmed facts
- assumptions
- scope and non-goals
- missing context and smallest next discovery step

## Guardrails

- Local `contexts/` are enough for deterministic demos and lightweight generation.
- `projectContextJson` is the normal live-evidence input.
- Bloomreach CLI cards are optional, not required.
- Raw JSON is a fallback, not the default starting point.
- Do not fetch or expose customer records or PII unless explicitly required.
- Name missing context instead of inventing facts.
