# Strategy Loop

The expected user flow is:

1. User asks for project discovery and recommended segmentations.
2. Claude Code/Codex uses `docs/agent-context/router.md` to classify the task.
3. Claude Code/Codex loads the smallest relevant local context from `contexts/`.
4. Claude Code/Codex adds `projectContextJson` from Loomi MCP or optional Bloomreach CLI card context when available.
5. Claude Code/Codex builds a task packet with goal, loaded facts, scope, assumptions, and missing context.
6. Claude Code/Codex calls `build_project_brief`.
7. Claude Code/Codex calls `recommend_segmentations`.
8. User gives feedback.
9. Claude Code/Codex calls `refine_segmentations`.
10. User approves one or more segments.
11. Claude Code/Codex calls `generate_scenario_from_segments`.
12. Claude Code/Codex calls `generate_node_content` for scenario nodes.
13. User reviews and gives final feedback.

## Tool Responsibilities

`build_project_brief`

- Turns raw Loomi MCP context into a compact intelligence brief.
- Identifies data strengths, data gaps, lifecycle coverage, constraints, and opportunity themes.

`recommend_segmentations`

- Produces a ranked opportunity matrix, not a generic idea list.
- Every recommendation includes objective, segment logic, conversion mechanism, personalization hooks, impact, effort, confidence, risk, missing data, and recommended scenario.

`refine_segmentations`

- Applies user feedback while preserving the decision record.
- Re-ranks rather than rewriting from scratch.

`generate_scenario_from_segments`

- Builds a manual Bloomreach scenario blueprint from approved segment IDs.
- Includes trigger, eligibility gates, contentgen API webhook, cache key storage, dynamic email send, waits, branches, exits, measurement, and implementation notes.

`generate_node_content`

- Produces contentgen API payloads, webhook action config, dynamic email bindings, channel-specific content guidance, and QA checks.
- For email, the generated subject, preheader, hero, messages, recommendations, and CTA are read from `catalogs.content.item_by_id(customer.customer_variant).content_json | from_json`.

## Design Rule

The generator should always explain:

- why this segment
- why this timing
- why this message
- which project data supports it
- what could go wrong
- how to measure it
