Skip to content
Skills Library
Management & product · Planning

forge

/forge

Use when the user has an idea, feature, design, or change that needs exploration before implementation — architecture decisions, new features, system design, refactoring plans, or any creative/building task that benefits from structured design thinking before code.

Licence
MIT
Last repository change
31.07.2026

Assessment and security

91/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content26 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
13
Scripts
1
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 31.07.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 1 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: tests/test_avengers_intake.py

What it does and when to use it

Use when the user has an idea, feature, design, or change that needs exploration before implementation — architecture decisions, new features, system design, refactoring plans, or any creative/building task that benefits from structured design thinking before code.

Original author description

Use when the user has an idea, feature, design, or change that needs exploration before implementation — architecture decisions, new features, system design, refactoring plans, or any creative/building task that benefits from structured design thinking before code.

How it works

  1. Overview
  2. Checklist
  3. Complexity Assessment
  4. Skill Gap Detection
  5. Step 4b: Orchestration tier (S055 — feature-detected)
  6. Step 6A fast path — design-tournament workflow (optional, main-loop only)
  7. Step 6B: Design exploration team (portable, canonical) — Phase 1
  8. Contract Map Generation (Step 8a)
  9. Phase 2: Implementation via bob
  10. Amendment Mode (S029)
Original SKILL.md headings · 1,087 lines, 9,715 words
SKILL.md preview
---
name: forge
description: Use when the user has an idea, feature, design, or change that needs exploration before implementation — architecture decisions, new features, system design, refactoring plans, or any creative/building task that benefits from structured design thinking before code.
---

# Forge — Ideas Into Designs & Implementation

## Overview

Turn ideas into fully formed designs through collaborative dialogue, then orchestrate implementation via **bob** (autonomous executor agent). Uses a two-phase approach: **Design Team** explores approaches with dual challengers (Claude + Codex) and UX advocate, then **bob** handles all execution — work package decomposition, team orchestration via agent-teams, verification, and delivery.

Every design and implementation decision must account for real human behaviour — how end users actually see, navigate, and interact with the product.

<HARD-RULE>
**Multi-Model Second Opinion**: For MEDIUM and COMPLEX tasks, run BOTH Codex (GPT-5.5) AND Antigravity CLI (`agy`, via `agy --sandbox -p`) in parallel alongside Claude agents — three models catch what two miss. For SIMPLE tasks, external models are optional. If Codex/agy unavailable, fall back gracefully but note each gap explicitly.
</HARD-RULE>

<HARD-RULE>
**Do NOT invoke `superpowers:brainstorming`**. Forge is the canonical design workflow. Forge has its own internal design exploration team (approach agents, challengers, Codex). The superpowers brainstorming skill is a separate, overlapping workflow that lacks Codex integration, multi-agent teams, and custom skill awareness. If you feel tempted to invoke brainstorming, you are already inside the right workflow — continue with forge.
</HARD-RULE>

<HARD-RULE>
**Codex Escalation**: When Claude agents are stuck on a problem (2+ failed attempts, circular reasoning, or no clear solution), delegate the problem to Codex for a fresh perspective before asking the user.
</HARD-RULE>

<HARD-RULE>
**Contract Map Required**: For any design that introduces components (new services, modules, endpoints, integration points), a valid signed `progress/contract-map.yaml` MUST exist before spawning bob. This is enforced mechanically by bob's G1 subprocess check, not by prose.

- Forge invokes the `component-contract-mapping` skill at Step 8a to produce the map.
- Forge signs it with HMAC-SHA256 using `.forge/session.key` (per spec section 7.4).
- The signed payload MUST include `map_hash`, `map_revision`, `forge_session_id`, and `signed_at`.
- Missing or unsigned map = refuse to spawn bob. No workarounds. No "we'll add it later".
- Pure refactoring / single-file bugfixes with no new components are exempt.
</HARD-RULE>

<HARD-RULE>
**Multi-subsystem requests emit handoff docs, not inline decomposition** (S038 Batch G, 2026-05-25). When forge Step 1 detects that a request describes multiple independent subsystems (existing "Large Project Decomposition" pattern), instead of inline-spawning sub-forge cycles (depth+1), forge MUST invoke the `handoff` skill to emit one `/tmp/handoff-<sub>-<date>-<uuid>.md` per decomposed sub-project. Each handoff doc records the slice of context relevant to that sub-project and a "Suggested skills: forge (MEDIUM cycle on this sub)" directive. The user picks which sub-project to start first; forge does NOT recurse into all of them. Recursion limit (depth≥3 REFUSE per existing rule) remains in effect — handoff is the new exit, not a way around the limit.
</HARD-RULE>

<HARD-GATE>
Do NOT write any code, scaffold any project, or take any implementation action until:
1. A design has been presented and the user has approved it
2. Bob has been spawned with the approved design doc
This applies to EVERY project regardless of perceived simplicity.
</HARD-GATE>

---

## Checklist

You MUST create a task for each item and complete in order:

1. **Explore project context** — read PROJECT.md (architecture map, components, integration edges) and relevant COMPONENT.md files FIRST. Check history.md (if >400 lines, head+tail only — older context lives in `history/INDEX.md`), session_control.md. Invoke `project-documentation` to ensure all docs exist (creates PROJECT.md + COMPONENT.md stubs if missing). **If a wiki exists for the project** (CWD contains `.wiki/` OR `~/.wiki-registry.yaml` lists this project), use Tier 1 access: `Grep` the wiki's `wiki/` directory for prior decisions, research, and ADRs on the task topic. Include any findings in `shared_context` as a "Prior Wiki Knowledge" section so design agents can reference existing decisions. **Also run `python3 ~/.claude/skills/_meta/scan_hard_rules.py`** (plain mode) to scan CLAUDE.md (global + project-local) for hard-rule directives and diff against `~/.claude/skills/_meta/hard-rules-checklist.md`. If any are flagged as potentially missing, surface them to the user with a 1-line summary and ask: "add to checklist / wire into a skill / apply ad-hoc / ignore?" — do NOT silently skip. This is idempotent with the SessionStart hook but catches cases where forge is invoked from a subagent, after `cd`, or in sessions where the hook didn't run.

   **Dependency currency check (advisory only, MEDIUM+ tasks):** if any manifest is present at the project root (`pyproject.toml`, `package.json`, `Cargo.toml`, `go.mod`, `Gemfile`, `pom.xml`), invoke `dep-currency-check` to populate `shared_context.dependency_health`. Run it advisory-only — forge Step 1 NEVER fails on its exit code; blocking enforcement lives at bob's WP boundary, the `G_DEP_CURRENCY` gate, and pre-commit hooks. Skip for TRIVIAL/SIMPLE tasks (latency budget). Pattern:
   ```bash
   if find "$PWD" -maxdepth 4 \( -name 'pyproject.toml' -o -name 'package.json' -o -name 'Cargo.toml' -o -name 'go.mod' -o -name 'Gemfile' -o -name 'pom.xml' \) 2>/dev/null | grep -q .; then
     PYTHONPATH="$HOME/.claude/skills/dep-currency-check" python3 -m dep_currency_check "$PWD" \
       --format json --severity high --quiet \
       --output "/tmp/forge-dep-currency-${FORGE_SESSION_ID:-default}.json" 2>&1 || true
   fi
   ```
   The `|| true` is mandatory — Step 1 MUST NOT fail. Read the JSON if present, include `dependency_health` in shared_context. See `~/.claude/skills/dep-currency-check/references/integration-forge.md` for the full payload shape + skip rules.
2. **Offer visual companion** (if topic involves visual questions) — see Visual Companion section. This is its own message, not combined with clarifying questions.
3. **Ask clarifying questions** — one at a time, understand purpose/constraints/success criteria. If the request describes multiple independent subsystems, flag and decompose first (see Large Project Decomposition). **Founder-intent routing:** if the request is "I have a startup idea" / "generate ideas" / "validate my idea" / "what should I build" / any pre-execution founder / innovator / inventor intent — route to the `founder` skill FIRST (not forge directly). Founder owns pre-execution (ideation, validation, business model, GTM); forge owns execution. Founder will hand back at the Scope→Launch gate with a populated `forge_brief` when the venture is ready for build. See `founder/references/forge-handshake.md` for the full contract.

**Explicit founder handoff**: If the spawn prompt or user message includes `came_from_founder: true` with a `venture_brief_path`, read that file and use its `forge_brief` block as the pre-clarified task statement:

- `forge_brief.problem` -> the design challenge (skip "what are we building?" questions)
- `forge_brief.success_criteria` -> pass to design agents as constraints
- `forge_brief.non_goals` -> pass as explicit scope boundaries
- `forge_brief.complexity_hint` -> seed Step 4 complexity assessment
- `forge_brief.open_questions` -> ask ONLY these in Step 3 (skip all other questions)
- `ideas_considered` / `assumptions` / `experiments` -> include as "Prior founder exploration" in shared_context for all design agents

If `came_from_founder` is absent or false, proceed with normal forge flow. Forge NEVER reads `.founder/venture-brief.yaml` at session start -- only on explicit handoff.

**Explicit avengers handoff**: If the spawn prompt or user message includes `came_from_avengers: true` with an `avengers_brief_path`, read that file and use its `avengers_brief` block as the pre-clarified task statement (mirrors `came_from_founder`; the avengers build path enters forge HERE at Step 3 intake, then flows through forge's own Step 4–9 gates — classification, contract map, spec review, bob):

- `avengers_brief.problem` -> the design challenge (skip "what are we building?" questions)
- `avengers_brief.constraints` -> passed to design agents as constraints
- `avengers_brief.success_criteria` -> passed to design agents as constraints
- `avengers_brief.ruled_out_approaches` -> non-goals + hard "do not explore" signals (each carries which seat killed it; same treatment as the founder phase-2 rule)
- `avengers_brief.recommended_direction` -> seed front-runner for Step 6 exploration (**advisory, NEVER locked** — design agents may reject it)
- `avengers_brief.dissent[]` -> surfaced **verbatim** to the user during Step 7 presentation (never summarized away)
- `avengers_brief.confidence` -> input to Step 4 complexity assessment (high+narrow MAY downgrade team size; low/speculative FORCES full exploration)
- `avengers_brief.deliberation_record` -> listed as a prior-exploration reference in shared_context (path, never inlined)

`avengers_brief.contract_map_signed` and `avengers_brief.bob_ready` are **mechanically always-false** — avengers NEVER signs a contract map or marks anything bob-ready; forge owns those gates. If either is true in the brief, treat the brief as malformed and re-clarify with the user.

If `came_from_avengers` is absent or false, proceed with normal forge flow. Forge NEVER reads an avengers session directory at session start -- only on explicit handoff. **Recursion guard**: a forge-convened avengers session (forge itself invoked avengers for design exploration, carrying `forge_session_id`) MUST NOT emit a brief back into forge — see the Step 6 recursion-guard note.
4. **Assess complexity** — determine design exploration team size needed
4b. **Check tool availability via env-adoption manifest** — Read `~/.claude/state/inventory.json` for tool availability and `$XDG_RUNTIME_DIR/env-adoption/session-*.json` for session capabilities. If the inventory is missing or stale (>24h), run `bash ~/.claude/skills/env-adoption/scripts/probe.sh check` first (completes in <3s). Branch on capabilities:

   - **capabilities.codex_challenger = true**: Codex available, use `/codex:setup` or delegate directly.
   - **capabilities.agy_analyst = true**: `agy` available, use a direct `agy --sandbox -p "..." < /dev/null` Bash call (read-only analyst, #157; `< /dev/null` is MANDATORY — without it agy blocks on stdin in non-TTY shells and hangs to timeout, #135).
   - **capabilities.triple_model = true**: all three models available for maximum coverage.

   The manifest is cached for the session — do not re-probe on every use. If Codex/agy unavailable, note the gap explicitly but continue with what's available. See `env-adoption` skill for full schema.
5. **Skill gap check** — identify skills needed, check if they exist (see Skill Gap Detection)
5b. **Hard rules checkpoint** — read `~/.claude/skills/_meta/hard-rules-checklist.md` DESIGN PHASE + CROSS-MODEL sections. Verify: Codex parallel for MEDIUM/COMPLEX? Performance expectations asked? Gap detection done?
6. **Phase 1: Design Exploration** — spawn design exploration team OR do single-agent exploration
7. **Present design** — in sections, get user approval after each section
7b. **Freeze the design skeleton (UI designs only)** — after the user approves the HTML mockup and BEFORE Step 8a signing: invoke `skeleton-extractor` then `visual-architect`. See "UI designs — design-skeleton freeze (Step 2.5)" under Visual Companion.
8. **Write design doc** — save to `docs/plans/YYYY-MM-DD-<topic>-design.md`
8a. **Generate & sign contract map** (if design introduces components) — invoke `component-contract-mapping` skill, run G2 validation, sign via HMAC (see Contract Map Generation)
8b. **Spec review** — run spec self-review checklist, then dispatch reviewer subagent (see Spec Review)
8c. **User reviews spec** — ask user to review spec file before proceeding. Wait for approval.
8d. **Hard rules checkpoint** — read `~/.claude/skills/_meta/hard-rules-checklist.md` EXECUTION PHASE section before spawning bob.
9. **Spawn bob** — pass design doc path and shared context (see Execution Method Selection)
10. **Wait for bob** — bob handles decomposition, orchestration, verification autonomously
11. **Final integration** — collect execution results, verify, present to user

---

## Complexity Assessment

Before spawning any design exploration team, assess complexity:

| Complexity | Signals | Design Exploration Team Size |
|------------|---------|---------------------|
| **Simple** | Config change, single-file tweak, obvious solution | No team — single agent explores + optional Codex/agy |
| **Medium** | 2-3 valid approaches, touches 3-5 files | 2-3 approach agents + triple challengers (Claude + Codex + agy) |
| **Complex** | Architecture decision, 4+ approaches, cross-layer | 4-5 approach agents + triple challengers (Claude + Codex + agy) + Codex approach agent |

### Adaptive Checklist

| Step | Simple | Medium | Complex |
|------|--------|--------|---------|
| 1. Project context | Read if exists | Read | Read + invoke project-documentation |
| 2. Visual companion | Skip | If UI-facing | If UI-facing |
| 3. Clarifying questions | 1-2 max | As needed | As needed |
| 4. Complexity assessment | Done | Done | Done |
| 4b. Codex + agy check (sandbox-aware) | Skip | Check both + detect mode | Check both + detect mode |
| 5. Skill gap check | Skip | Check | Check |
| 6. Design exploration | Lead proposes directly | 2-3 agents + Codex + agy | Full team + Codex + agy |
| 7. Present design | Brief, 1 section | Sections | Sections with approval each |
| 8. Write design doc | Optional (skip if <20 lines change) | Yes | Yes |
| 8b. Spec review | Self-review only | Self + subagent | Self + subagent |
| 8c. User reviews | Quick confirm | Review file | Review file |
| 9-11. Bob | Direct or bob | Bob | Bob |

---

## Skill Gap Detection

After assessing complexity, identify what domain skills agents will need:

Follow gap-detection protocol at `~/.claude/skills/research-for-skills/gap-detection.md`

---

## Step 4b: Orchestration tier (S055 — feature-detected)

Before Step 6, decide HOW design exploration runs. This is a fast-path choice,
never a dependency — the documented main path (Step 6B below) completes with
ZERO orchestration primitives.

- Read `bash ~/.claude/skills/env-adoption/scripts/probe.sh get capabilities.workflow_tool`
  (the ONLY capability API — never inline-probe, never raw jq) AND confirm the
  live context via `probe.sh context` (must be `main-loop`). The decision rule,
  restated: `can_orchestrate = capabilities.workflow_tool AND context == main-loop`.
  See `env-adoption/references/context-detection.md` — `capabilities.*` alone
  NEVER authorizes orchestration (session files are shared with subagents).
- **If both true (Step 6A fast path):** the main loop MAY run the
  `design-tournament` saved workflow (parallel approach/challenge/converge fan-out
  that returns a DRAFT synthesis + a script-computed disagreement matrix). The
  converge DECISION, all user questions/approvals, and the design-doc write STAY
  inline in forge (Workflow Boundary, below). External challengers are
  PRE-LAUNCHED inline by forge and passed as transcripts (agy is UNREACHABLE from
  workflow stages — WP-2 live finding).
- **Else (Step 6B portable, canonical):** run the existing design exploration
  team inline (Phase 1 below). This is byte-identical to the prior forge flow.
  Codex/Copilot/VS Code/older-Claude hosts always take this path.

## Step 6A fast path — `design-tournament` workflow (optional, main-loop only)

When the orchestration tier (Step 4b) selected the fast path: invoke
`Workflow({name: "design-tournament", args: {...}})` with `run_started_at`,
`run_label`, `brief_path`+`brief_sha256`, `shared_context_path`+`shared_context_sha256`,
`approaches[]`, `consultants[]`, `consultant_cmds{}`, `ui_facing`, `budget_tokens`,
`transcript_dir`, `external_transcripts[]` (pre-launched), `models{}`. The
workflow returns a `design-synthesis.v1` DRAFT + the disagreement matrix; forge
presents it section-by-section and OWNS the converge decision. **Budget floor:**
if the budget cannot cover ≥2 approaches + 1 challenger + synthesis, the workflow
returns `status: INCOMPLETE` with zero synthesis — an under-budget tournament
looks unfinished, not polished. Shed ladder (documented, never silent): codex
approach-explorer → agy analyst → approach agents above the minimum 2; NEVER shed
the Claude challenger or UX-when-`ui_facing`. Spend is reported observe-only
(#147 design half — no enforcement). On ANY fast-path failure, fall back to
Step 6B (byte-identical, portable).

## Step 6B: Design exploration team (portable, canonical) — Phase 1

**Recursion guard (avengers ↔ forge)**: forge MAY convene `avengers` in design-exploration mode as an adjunct to the approach team. When it does, forge passes its `forge_session_id` in the avengers `came_from` block. A forge-convened avengers session is depth-capped and its build path is **BLOCKED**: it returns a `decision` (forced), never a `forge_brief`, so it cannot emit a `came_from_avengers` handoff back into forge (which forge itself started). This prevents infinite forge→avengers→forge recursion. Forge already pays for its own challengers; a convened avengers is for contention, not a second build gate.

### Step 1: Understanding (Lead Only)

The lead handles all user interaction:
- Check current project state (files, docs, recent commits)
- Ask questions **one at a time** (prefer multiple choice)
- Focus on: purpose, constraints, success criteria
- **Performance expectations** (ask if task creates/modifies endpoints, queries, UI, or batch processes):
  - "Expected concurrency / data volume?"
  - "Latency requirements? (e.g., p95 < 200ms)"
  - "Is this on a hot path?"
  - "Existing performance budgets to respect?"
- **Runtime / observability branch** (ask once, not a full questionnaire):
  "Does this change runtime behavior, service boundaries, or SLOs?"
  - If YES: delegate full capacity questionnaire to `performance` skill
    (`references/capacity-questionnaire.md`), full signals-map drafting to
    `observability` skill, BEFORE design-team exploration. Capture the
    signals-map path + capacity answers into `shared_context` so design
    agents consume them as constraints.
  - If NO: skip. Existing performance-expectation questions still apply.
- **Security / threat-model branch** (ask once, not a full questionnaire):
  "Does this component process untrusted input, hold secrets/tokens, cross a
  trust boundary, OR consume content the LLM agent will read (prompts, tool
  results, wiki pages, mail, web)?"
  - If YES: capture into `shared_context.security_model`:
    (a) `trust_boundary` — what's inside vs outside the trust perimeter
    (b) `attacker_model` — who's the adversary, what can they touch
    (c) `sensitive_inputs` — PII / secrets / tokens / untrusted-from-network
    (d) `egress_destinations` — external systems reached
    Then delegate to `threat-modeling` skill for STRIDE / LINDDUN if high-stakes,
    AND to `llm-security` skill if the component is part of an agentic chain
    (prompt injection / OWASP LLM Top 10 defense — Dual LLM pattern where
    consequential tool use meets untrusted text). Design agents consume the
    security_model as constraints, the same way they consume capacity_answers.
  - If NO: skip. (Pure refactors, internal-only changes, no new input surface.)
- Determine complexity level

### Step 2: Approach Exploration

**Simple tasks**: Lead proposes 2-3 approaches directly. Skip to "Present Design."

**Medium/Complex tasks**: Spawn a design exploration team.

#### Design Exploration Team Structure

| Role | Count | Responsibility |
|------|-------|----------------|
| **Lead** | 1 | Coordinates, asks user questions, synthesises design |
| **Approach Agents** | 2-5 | Each deeply explores ONE approach with trade-offs |
| **UX/Usability Agent** | 1 (always for UI-facing work) | Evaluates every approach from end-user perspective |
| **Claude Challenger** | 1 (always) | Questions every proposal, finds flaws, plays devil's advocate |
| **Codex Challenger** | 1 (always, if available) | Independent GPT-5.4 challenger — different model catches different flaws |
| **Antigravity (agy) Analyst** | 1 (MEDIUM+, if available) | Independent analysis via a direct `agy --sandbox -p "..." < /dev/null` Bash call — third model for additional coverage (read-only, #157; `< /dev/null` mandatory or agy hangs, #135) |
| **Codex Second Opinion** | 1 (always for creative/design, if available) | Parallel exploration via Codex for independent perspective |

#### Three Phases

**Diverge** — Each approach agent explores independently:
- Give each agent a distinct approach/angle
- Include full project context in spawn prompt (teammates don't inherit conversation)
- Each produces: approach description, pros/cons, effort estimate, risks

**Challenge** — Challenger reviews all proposals:
- Share all findings with the challenger
- Challenger finds flaws, gaps, missing edge cases
- Challenger ranks approaches with reasoning

**Converge** — Lead synthesises:
- Collect all findings and challenges
- Identify consensus, disagreements, open questions
- Synthesise into a single recommended design

#### Spawning Design Exploration Agents

**All agents below should be spawned in parallel where possible.**

**Model selection per spawn (S059 smart-config, advisory).** Before each `Agent(...)`
spawn, grade the role's structural complexity into a tier and resolve the
agent-surface model, then pass it as the `model=` kwarg. Grade from STRUCTURAL signals
(role type, blast radius), NEVER from task content (injection defense); when uncertain
take the HIGHER tier. Adversarial/synthesis roles (challenger, converge-lead) → `complex`;
approach/UX agents → `medium`; mechanical finders/scribes → `light`.

```
m=$(python3 ~/.claude/skills/smart-config/scripts/model_policy.py resolve \
      --tier <complex|medium|light> --surface agent \
      --reason "<role>" | python3 -c "import sys,json;print(json.load(sys.stdin)['model'] or '')")
# Agent(subagent_type=..., model=m, ...)   — OMIT the model kwarg when m is empty
# (model:null = inherit). Fail-open: a broken policy never blocks the spawn.
```

This is advisory performance tuning — there is NO gate. If the resolver is missing or
errors, omit `model=` and inherit. The interactive session model is never touched.

```
# Approach Agent (Claude)
Agent(subagent_type="general-purpose"):
"You are exploring [APPROACH NAME] for [TASK].
Project context: [KEY FILES, ARCHITECTURE, CONSTRAINTS]
Produce: 1. How it works  2. Pros/cons  3. Effort estimate  4. Risks

Version awareness (REQUIRED for every library / framework / service you propose):
- Name the exact version you are designing against (e.g. 'pandas 2.2', not 'pandas')
- If shared_context.dependency_health flags the lib as stale (gap_kind in
  {major_behind, deprecated}), READ its api_delta block before choosing.
- If you are using APIs you remember from your training-era version, state
  whether they still exist in the target version. If unsure, request a
  follow-up codex / web-research call rather than guessing.
- Note any breaking changes / deprecations / new functionality that affect
  the approach. A version mismatch between your design and the installed
  version is a HIGH risk — surface it explicitly.

Security CVE awareness (REQUIRED, parallel to version awareness):
- If shared_context.dependency_health flags a CVE in any lib you propose
  (look for `cves` / `vulnerabilities` / `advisories` keys in the dep-currency
  finding), state explicitly: (a) the CVE id, (b) whether you're proposing an
  upgrade past the fixed version OR a mitigation (input filter, sandbox,
  removal of the vulnerable code path), (c) why the mitigation is acceptable
  if you're NOT upgrading. Designing against a known-vulnerable version
  without acknowledging the CVE is a HIGH risk and will be flagged in review.
- If shared_context.security_model exists (set by Step 1 security branch),
  treat its attacker_model / sensitive_inputs / egress_destinations as
  constraints. A design that ignores them is structurally wrong, not just
  insecure. Examples: trust_boundary='public API' means your approach MUST
  include input validation at the boundary; sensitive_inputs containing
  tokens/secrets means your approach MUST address storage hardening.
- For agentic components (LLM consuming untrusted text + having tools):
  reference Dual LLM architecture (Quarantined LLM processes untrusted data
  without tool access, Privileged LLM uses only symbolic vars) as the
  default-safe pattern. Deviations need explicit justification."

# UX Agent (for UI-facing work)
# subagent_type MUST be one that exists on this host. Verify against the available
# agent-type list before spawning — a nonexistent type does NOT fail loudly, it
# silently degrades, and the specialist runs without its intended role. (S073: this
# line named `multi-platform-apps:ui-ux-designer`, which was never installed —
# `enabledPlugins` contains only `superpowers` — so every UI-facing forge cycle had
# been falling back silently.)
Agent(subagent_type="general-purpose"):
"You are the UX advocate for [TASK].
Invoke the `ux-reviewer` skill first (and `audience-experience-design` when the task
is design-before-build rather than review-after-build).
Evaluate every approach through: user journey, visual hierarchy,
cognitive load, mobile ergonomics, trust/emotion, accessibility.
Rank approaches by real-world usability."

# Claude Challenger Agent
Agent(subagent_type="general-purpose"):
"You are the devil's advocate for [TASK].
Invoke the `challenger` skill first.
Find flaws in EVERY proposal including UX findings.
Rank approaches with reasoning."
```

#### Spawning Codex Agents (ALWAYS — in parallel with Claude agents)

Check Codex availability first (step 4b). If unavailable, skip Codex agents and note the gap.

**CHECK AVAILABILITY FIRST.** The `/codex:*` commands come from a Codex *plugin*, which is a
separate thing from the `codex` CLI. Having the CLI does NOT mean you have the commands. Verify
the plugin is in `enabledPlugins` (`~/.claude/settings.json`) — or that the commands exist under
`~/.claude/commands/` — before using this path. If it is absent, go straight to raw `codex exec`
below; that path is fully capable and needs only the CLI. (S073: on this host `enabledPlugins`
contains only `superpowers`, so every `/codex:*` invocation documented here was unavailable while
raw `codex exec` worked normally.)

**Preferred when available: Codex plugin commands** (structured output, job tracking, resume capability):

```
# Codex Challenger — use /codex:adversarial-review for design challenge
# Run via Skill("codex:adversarial-review") or invoke the command:
/codex:adversarial-review --background look for scalability, security, maintainability issues and rank approaches

# Codex Research — use /codex:rescue for independent exploration
/codex:rescue --background "Explore approaches for [TASK]. Context: [KEY FILES, ARCHITECTURE, CONSTRAINTS]. Produce top 2-3 approaches with pros/cons, effort, risks."

# Check status of background jobs
/codex:status
# Retrieve results when done
/codex:result [job-id]
```

**Fallback: Raw `codex exec`** (for parallel batch tasks or custom briefs). **STDIN RULE (#155):** the agy stdin rule applies to `codex exec` exactly the same — close stdin (`< /dev/null`) on every headless argv-prompt invocation or it hangs to timeout in background shells:

```bash
CODEX_WORK=$(mktemp -d /tmp/codex-XXXXXXXXXX)

# Codex Challenger (runs simultaneously with Claude challenger)
cat > "$CODEX_WORK/brief-challenger.md" << 'BRIEF'
# Challenger Review Brief
## Context
[TASK DESCRIPTION + KEY CONSTRAINTS]
Project files at: [PROJECT_DIR]
## Your Role
You are a devil's advocate / challenger. Find flaws in EVERY approach.
Focus on: scalability, security, maintainability, edge cases, operational complexity.
For each issue: Severity (critical/moderate/minor), What's wrong, Why it matters, How to fix.
Rank overall design: strong / acceptable / needs-rework / reject.
BRIEF

timeout 600 codex exec --ephemeral -C "$PROJECT_DIR" -s read-only \
  -o "$CODEX_WORK/challenger.md" \
  "Read $CODEX_WORK/brief-challenger.md and execute the challenger review." < /dev/null || echo "CODEX_TIMEOUT: Codex did not respond within 600s" > "$CODEX_WORK/challenger.md" &

# Codex Second Opinion / Approach Explorer (independent perspective)
timeout 600 codex exec --ephemeral -C "$PROJECT_DIR" -s read-only \
  -o "$CODEX_WORK/approach.md" \
  "You are exploring approaches for [TASK].
Context: [KEY FILES, ARCHITECTURE, CONSTRAINTS]
Produce your top 2-3 recommended approaches with:
1. How it works  2. Pros/cons  3. Effort estimate  4. Risks
Be opinionated — recommend the best approach and explain why." < /dev/null || echo "CODEX_TIMEOUT: Codex did not respond within 600s" > "$CODEX_WORK/approach.md" &

# Codex Research (when task needs up-to-date info; web search is automatic — no flag)
timeout 600 codex exec --ephemeral --skip-git-repo-check \
  -o "$CODEX_WORK/research.md" \
  "Research current best practices for [TECHNOLOGY/PATTERN] as of 2026.
Latest versions, known limitations, community adoption, alternatives." < /dev/null || echo "CODEX_TIMEOUT: Codex did not respond within 600s" > "$CODEX_WORK/research.md" &

wait  # Wait for all Codex tasks to complete
```

**When to use plugin vs raw exec**: Plugin commands are preferred for single challenger/research tasks (structured output, job tracking). Use raw `codex exec` when running 3+ parallel tasks in a batch or when custom brief files with skill injection are needed.

#### Spawning Antigravity (agy) Analyst (MEDIUM+ — in parallel with Claude and Codex agents)

Check `agy` availability first: `command -v agy`. If unavailable, skip and note the gap.

`agy -p` returns **plain text on stdout** — the lead parses the text reply, not JSON fields.
Raise `--print-timeout` above the 5m default for long analyses. Append a `served_by` probe
line to the prompt and capture it — self-reported model identity is unreliable.

**STDIN RULE (root-caused 2026-06-05, #135):** headless `agy` MUST have stdin closed or piped —
`< /dev/null` on every call. agy reads non-TTY stdin until EOF *before* the model call; in
background/harness shells stdin never EOFs, so agy hangs forever producing 0 bytes and
`--print-timeout` never fires (it only guards the print phase). Also wrap in a shell `timeout`.

Prompt size is NOT a factor (verified: 30-char prompt hung; 11KB prompt with `< /dev/null`
answered in 9s).

**SANDBOX RULE (S052 rogue-commit incident, #157):** the agy analyst is a READ-ONLY role — ALWAYS
invoke it with `--sandbox`. agy has write/shell/git tools by default; in S052 an un-sandboxed
"analyst" auto-authored and git-committed broken code mid-design (HARD-GATE violation). Codex is
unaffected (it already runs `-s read-only`). FLAG ORDER (root-caused 2026-07-02): `--sandbox` and
every other flag BEFORE `-p`, prompt LAST — `agy -p --sandbox "X"` silently runs UN-sandboxed
with the literal prompt `--sandbox` and discards "X" (agy then improvises from implicit memory —
the "does work instead of consulting" failure mode). Scope caveat (verified 2026-07-02, 1.0.15):
`--sandbox` constrains shell/git only, NOT native file writes — prefer piping content over
`--add-dir` on a writable repo, open the prompt with "Advisory only — do not modify any files;
answer on stdout", and run `git status --short` afterwards if a repo was exposed.

```bash
# Antigravity (agy) Analyst — independent third-model analysis
timeout 600 agy --sandbox -p "You are an analyst for [TASK].
Project context: [KEY FILES, ARCHITECTURE, CONSTRAINTS]
Analyze: 1. Architecture trade-offs  2. Scalability limits  3. Security surface
4. What approaches work best at scale for this pattern?
Be specific and cite real-world precedents where possible.
At the very end print one line: SERVED_BY=<model-id-you-are-running-as>." < /dev/null

# For codebase context, add the relevant paths to the workspace with --add-dir:
# CAUTION: --sandbox does NOT gate native file writes into --add-dir trees — prefer piping;
# if you must --add-dir a writable repo, run `git status --short` afterwards and revert strays.
timeout 600 agy --sandbox --add-dir [PATHS] -p "Advisory only — do not modify any files; answer on stdout.
Review the codebase at [PATHS] for [TASK].
Focus on: cross-cutting concerns, hidden coupling, N+1 patterns, missing error boundaries." < /dev/null

# For multi-methodology brainstorming (frame the methodology in the prompt itself):
timeout 600 agy --sandbox -p "Brainstorm approaches for [TASK] using the Six Thinking Hats methodology —
work through White (facts), Red (intuition), Black (caution), Yellow (benefits),
Green (alternatives), and Blue (process) in turn, then summarise." < /dev/null
```

**When to use agy vs Codex**: `agy` is a useful independent third model for architecture analysis, codebase review (add paths with `--add-dir`), and multi-methodology brainstorming. Codex excels at focused code review, devil's advocate challenger work, and prototype exploration.

#### Converging Triple-Model Findings

When collecting results, the lead MUST:
1. Read Claude challenger output AND Codex challenger output (`$CODEX_WORK/challenger.md`) AND agy analyst output
2. Read Codex approach exploration (`$CODEX_WORK/approach.md`)
3. Identify where models **agree** (high confidence) vs **disagree** (needs deeper analysis)
4. Flag disagreements to the user: "Claude, Codex, and agy disagree on X — here are all perspectives"
5. Weight all model findings equally — each has different blind spots and strengths
6. agy findings that cite real-world precedents — flag these as evidence (and verify per Stage 1.5)

#### Codex Escalation (When Claude Is Stuck)

When Claude agents fail to solve a problem after 2+ attempts or enter circular reasoning:

**Primary: Use `/codex:rescue`** (managed job with resume capability):

```
/codex:rescue "Claude agents are stuck on [PROBLEM]. Tried: [APPROACHES]. Blocker: [ISSUE]. Need a fresh approach — challenge the assumptions that led to the dead end."
```

**Fallback: Raw `codex exec`** (for custom briefs):

```bash
CODEX_WORK=$(mktemp -d /tmp/codex-XXXXXXXXXX)

cat > "$CODEX_WORK/escalation-brief.md" << 'BRIEF'
# Escalation: Claude agents are stuck on [PROBLEM]

## What was tried
[LIST APPROACHES THAT FAILED AND WHY]

## The specific blocker
[DESCRIBE THE EXACT ISSUE]

## Project context
[KEY FILES, ARCHITECTURE]

## What we need
A fresh approach to solve this. Don't repeat what was already tried.
Think differently — challenge the assumptions that led to the dead end.
BRIEF

timeout 600 codex exec --ephemeral -C "$PROJECT_DIR" -s read-only \
  -o "$CODEX_WORK/escalation-result.md" \
  "Read $CODEX_WORK/escalation-brief.md and provide a fresh solution." < /dev/null || echo "CODEX_TIMEOUT: Codex did not respond within 600s" > "$CODEX_WORK/escalation-result.md"
```

### Escalation Termination

Max escalation chain: Claude 2 attempts -> Codex 1 attempt -> user.

If Codex escalation also fails or times out:
1. Present the problem to the user with ALL attempted approaches
2. Include what Claude tried, what Codex tried, and why both failed
3. Ask the user for direction
4. Do NOT retry automatically. Do NOT loop back to Claude.

### Step 3: Present Design

After convergence:
- Present design in sections scaled to complexity
- Ask after each section: "Does this look right so far?"
- Cover: architecture, components, data flow, error handling, testing approach, performance considerations
- **Always include a UX section** for UI-facing work
- **If `came_from_avengers`**: surface the `avengers_brief.dissent[]` entries **verbatim** in the presentation — attributed to the seat, with each entry's trip-wire. Do NOT summarize or drop them; the user judges the design with the deliberation's dissent in view (mirrors the founder minority-report surfacing).
- Be ready to revise based on user feedback

### Step 4: Write Design Doc

- Save to `docs/plans/YYYY-MM-DD-<topic>-design.md`
- Update `history.md` and `index.md`
- Shut down design exploration team (if created)

---

## Contract Map Generation (Step 8a)

### Step 8a.0: Emit + corroborate the classification artifact (S042 / #115)

BEFORE deciding whether to build a map, forge MUST write `.forge/classification.json` (schema `contract-classification.v1`) — the recorded classification that travels with the cycle, analogous to the signed contract map. This closes the bare-`Contract map: N/A` hole at the producer side (not just bob's front door).

The artifact states:
- `introduces_components`: `"yes" | "no"`
- `reason_code`: a value from the **closed enum** {`skill_text`, `doc_only`, `direct_bugfix`, `refactor`, `self_contained_meta_helper`, `sidecar_telemetry`, `agent_text`, `existing_component_extension`} — NOT free-text (free-text reasons are a loophole).
- `design_doc`, `planned_globs`, `evidence` (confirmed_positives / negatives / prose_only).

Forge may hand-write it, or derive a default via the helper:
```bash
python3 ~/.claude/skills/_meta/classify_emit.py "<project_root>" \
  --design-doc "<design-doc-path>" --classified-by forge_design \
  --files-from "<planned-file-touch-list>"
```

Then forge **locally runs `G_CLASSIFY` to fail-fast at design time** (catch a misclassification before bob is ever spawned):
```bash
python3 ~/.claude/skills/_meta/gates.py G_CLASSIFY "<project_root>" \
  --design-doc "<design-doc-path>" \
  --asserted "<N/A if introduces_components==no, else provided>" \
  --files-from "<planned-file-touch-list>"
```
- Exit 0 → classification corroborated; proceed.
- Exit 2 → the scan contradicts the artifact (named signals). Fix the design/classification before continuing; do NOT hand bob a false N/A.
- Exit 3 → ambiguous; resolve with the user before spawning bob.

The artifact is a CLAIM the gate re-derives and corroborates — never trusted (the threat model includes a buggy/drifting producer). `existing_component_extension` makes the Ship-of-Theseus case (appending component logic into existing allowed files) a *declarable, checkable* category rather than a silent dodge.

### Step 8a.1+: Build the signed contract map (component cycles only)

When a design introduces components (new services, modules, APIs, integration points), forge MUST produce a signed contract map BEFORE invoking the spec review (Step 8b) and before spawning bob.

Pure refactors, bugfixes, and single-file changes with no new components are exempt.

### Step 8a.1: Invoke component-contract-mapping

Invoke the `component-contract-mapping` skill with:

1. The draft design doc path
2. Relevant PROJECT.md and COMPONENT.md paths
3. The user's spoken intent from design dialogue

The skill will:
1. Extract components from the design discussion
2. Define types dictionary with semantic_type per field (from the v1 18-type registry)
3. Write `progress/contract-map.yaml` (single writer — only ever written here)
4. Run G2 validation locally by invoking `python -m gates G2 progress/contract-map.yaml`
5. Auto-render a markdown table into the design doc
6. Request forge to sign the map

If G2 validation fails, fix the design doc (not the YAML — the skill rewrites it from the design doc). Re-invoke the skill. Bob will refuse to execute without a valid signed contract map.

### Step 8a.2: Emit session material and sign

Forge is responsible for the session material and the signing payload.

```bash
# Create session material once per forge session (idempotent)
mkdir -p .forge
[[ -f .forge/session-id ]] || uuidgen > .forge/session-id
[[ -f .forge/session.key ]] || ( umask 077; openssl rand -hex 32 > .forge/session.key )  # umask 077: created 0600, no readable window

# Read current state
MAP_HASH=$(sha256sum progress/contract-map.yaml | awk '{print $1}')
MAP_REVISION=$(yq eval '.revision' progress/contract-map.yaml)
SESSION_ID=$(cat .forge/session-id)
SIGNED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

# Build the signed payload per spec section 7.4 — full payload including session_id
PAYLOAD=$(jq -cn --arg h "$MAP_HASH" --arg r "$MAP_REVISION" --arg s "$SESSION_ID" --arg t "$SIGNED_AT" \
  '{map_hash: $h, map_revision: ($r | tonumber), forge_session_id: $s, signed_at: $t}')

# Canonical JSON (sort keys, no whitespace) — must match gates.py canonical_json() bit-for-bit
CANONICAL=$(printf '%s' "$PAYLOAD" | jq -cS .)

# Compute HMAC-SHA256 using the session key file content (ALL BYTES, including the
# trailing newline from `openssl rand -hex 32 > file`) as the key.
#
# gates.py reads the key via pathlib.Path.read_bytes() which returns 65 bytes
# (64 hex chars + newline). Shell command substitution `$(cat file)` strips trailing
# newlines and produces a 64-byte key — mismatches gates.py. This produced a G1
# signature-mismatch on every forge-signed contract map before 2026-04-19; see
# foundry-lab/docs/reviews/2026-04-19-product-merger-codex-spec-review.md (tasks.md #85).
#
# Mirrors _meta/gates.sh §HMAC verification (Python oracle preferred; bash fallback uses
# xxd round-trip + openssl -macopt hexkey: to preserve the trailing newline byte).
if command -v python3 >/dev/null 2>&1; then
  SIG=$(printf '%s' "$CANONICAL" | python3 -c "
import hmac, hashlib, sys, pathlib
key = pathlib.Path('.forge/session.key').read_bytes()
msg = sys.stdin.buffer.read()
print(hmac.new(key, msg, hashlib.sha256).hexdigest())
")
else
  KEY_HEX=$(xxd -p -c 0 .forge/session.key)
  SIG=$(printf '%s' "$CANONICAL" | \
    openssl dgst -sha256 -mac HMAC -macopt "hexkey:$KEY_HEX" -binary | \
    xxd -p -c 256 | tr -d '\n')
fi

# Write the signature file — contains both payload and signature
jq -cn --argjson p "$PAYLOAD" --arg s "$SIG" '{payload: $p, signature: $s}' > progress/contract-map.yaml.sig
```

### Step 8a.3: Verify signature

Run G1 locally (with `--no-ledger-binding`, since bob has not yet initialized the ledger):

```bash
python3 ~/.claude/skills/_meta/gates.py G1 "$(pwd)" --no-ledger-binding
# exit 0 = signature valid, safe to hand off to bob
# exit 2 = G1_FAIL — fix and re-sign
```

If G1 fails, re-run Step 8a.2 after fixing the underlying issue (most common: the skill re-wrote the YAML without updating the signature; re-sign).

### Step 8a.3b: Re-pin the retro-scan baseline (MANDATORY after any map write)

**Run this immediately after signing a NEW map, and again after every AMENDMENT.**

```bash
python3 ~/.claude/skills/retro-scan-s028/scripts/scan.py "$(pwd)"
# rewrites progress/retro-scan-S028.yaml, re-pinned to the new contract_map_hash
```

**Why this is not optional.** `progress/retro-scan-S028.yaml` records
`contract_map_hash`. `G_CONTRACT_SCOPE` compares that stored hash against the
live map and, on a mismatch, **silently declines to consult the baseline at all**
(warning to stderr only — see `gates.py` §7.5 safety notes). No baseline means no
grandfathering, so every pre-existing path the baseline was holding down re-emits
as a **fresh critical undeclared**, `critical_undecided` jumps from 0 to dozens,
and the cycle freezes in `AWAITING_AMENDMENT` — pointing at paths that were
already known and already accepted.

The failure is doubly nasty because it is **delayed and misattributed**: signing
succeeds, G1 passes, and the breakage only surfaces later at a WP boundary, where
it reads as "the implementation introduced scope creep" rather than "the baseline
went stale." **S033 and S069 each lost a full pause cycle to exactly this.**

Verify the re-pin before handing off:

```bash
grep contract_map_hash progress/retro-scan-S028.yaml    # must equal the live map's hash
```

Keep the superseded baseline alongside the new one (`progress/retro-scan-S028.yaml.pre-<cycle>-amend`)
so a bad re-pin can be diffed rather than guessed at.

### Step 8a.4: Stage for bob

At this point the workspace contains:
- `progress/contract-map.yaml` (frozen — never edited after this)
- `progress/contract-map.yaml.sig` (full signed payload)
- `progress/retro-scan-S028.yaml` (re-pinned to the map hash — Step 8a.3b)
- `.forge/session-id` (UUID, inherited by bob)
- `.forge/session.key` (0600, inherited by bob)

Proceed to Step 8b (spec review).

---

## Phase 2: Implementation via bob

After the user approves the design, delegate execution to **bob** — the autonomous executor agent.

Bob handles everything: work package decomposition, team orchestration, monitoring, verification, and delivery. Forge stays focused on design.

### Step 5: Spawn bob

```
Agent(name: "bob", subagent_type: "bob", prompt: """
Execute this approved design.

Design document: [PATH_TO_DESIGN_DOC]
Project root: [PROJECT_DIR]

Contract map (required if design introduces components):
- Map:        progress/contract-map.yaml
- Signature:  progress/contract-map.yaml.sig
- Session id: .forge/session-id (inherited)
- Session key: .forge/session.key (inherited, 0600)

Bob MUST run gates.py G1 against the map before Step 1 completes. If G1 fails,
HALT and report to forge. Do NOT infer or fabricate a contract map.

Shared context:
- Architecture: PROJECT.md at [path]
- Component docs: [relevant COMPONENT.md paths]
- Coding conventions: [any style guide or conventions]
- Existing interfaces to respect: [if any]

The design has been reviewed and approved by the user. Execute it as specified.
""")
```

The contract-map block is OMITTED only for designs that do not introduce components (pure refactors, single-file bugfixes). In that case, include an explicit line: `Contract map: N/A (no new components in this change) — <reason>.` **This `N/A` line is ADVISORY only** (S042 / #115): bob does NOT trust it: bob's mandatory `G_CLASSIFY` pre-flight independently re-derives and corroborates the classification, and authorizes skipping Step 1.5 SOLELY on a green (`exit 0`) gate. A false N/A is caught (exit 2 BLOCK with named signals).

**What to include in bob's prompt:**
- Path to the design doc (bob reads it himself)
- **Path to `.forge/classification.json`** (the Step 8a.0 classification artifact — bob's `G_CLASSIFY` pre-flight corroborates it)
- Architecture docs: PROJECT.md path + relevant COMPONENT.md paths
- Coding conventions (if any)
- Existing interface contracts to respect
- Performance requirements (budgets, concurrency targets from design doc)
- Any user-specified constraints (e.g., "don't touch the database schema")

### Step 6: Collect Results

Bob returns a structured execution report. When you receive it:

1. **Check status** — COMPLETE / PARTIAL / FAILED
2. **If PARTIAL or FAILED** — present bob's report to the user with remaining items and recommended next steps
3. **If COMPLETE** — present bob's report to the user:

```
## Implementation Complete: [Feature Name]

### What Was Built
[From bob's report — deliverables with descriptions]

### Files Changed
[From bob's report — all modified/created files]

### Verification
[From bob's report — what passed, what didn't]

### Cycle cost (observe-only, S046 #124)
[If bob's report includes a `Spawn cost` line, surface it verbatim: "captured
Claude-verifier spend: $X across N spawns; summed spawn duration Ys —
coverage: partial (forge approach-agents + Codex + agy costs NOT captured);
budget_enforced: false". This is OBSERVE-ONLY — v1 records, does not cap
(enforcement deferred → #147). Omit if bob ran no cold-context verifier spawn.]

### How to Verify
[From bob's report — step-by-step testing instructions]

### Known Limitations
[From bob's report — deferred items or edge cases]
```

**Forge spot-checks bob's verification artifacts.** Bob produces concrete verification artifacts (test output, lint output, build output) in his report. For medium/complex tasks, forge must:
1. Pick at least one verification artifact from bob's report and re-run the command independently
2. Read at least one modified file and confirm it matches the plan
3. If spot-check passes: present bob's report to the user
4. If spot-check fails: flag the discrepancy to the user before presenting

---

## Amendment Mode (S029)

This section runs only when bob spawns forge with `mode=amendment` during a contract-scope pause cycle. It is **not a numbered step** in the main checklist — Step 9 (Spawn bob) remains in place. Amendment Mode is an out-of-band invocation that handles a specific bob-initiated pause-state subprotocol.

**Trigger.** Bob's `G_CONTRACT_SCOPE` gate has flagged a critical undeclared artifact during a WP boundary or `INTEGRATED → VERIFIED` re-check; bob has acknowledged the pause and reached `MAP_UPDATING`. Bob then spawns forge with:

```
mode: amendment
project_root: <abs path>
contract_map_path: <abs path to current signed progress/contract-map.yaml>
gaps_dir: <abs path to .ledger/scope-deltas/>
pause_epoch: <epoch returned by claims.request_scope_pause>
```

**Authority — USER IS SOLE AUTHORITY (Q3b lock).** Forge cannot self-approve any amendment. Bob cannot self-approve. Both only mechanically apply user-approved decisions. There are **no waivers** — the only legal bypass for `G_CONTRACT_SCOPE` is a user-approved amendment of the signed contract map.

**What forge does in amendment mode.**
1. Load the helper from `~/.claude/skills/_meta/forge_amendment_helper.py`.
2. Read all undecided scope_delta records: `fah.read_undecided_deltas(project_root)`.
3. For each record, present a structured prompt to the user (path, artifact_kind, severity, requesting_wp, detection_point, closest declared component(s)) with decision options: **a**mend (add path to a component's `source_paths`), **e**xclude (add to top-level `excluded_paths`), **d**efer (leave undecided — escalate or HALT), **r**eject (forge proposes nothing for this delta; bob's pause cycle will time out → ROLLBACK).
4. Build a `decisions` list from the user's input.
5. Call `fah.draft_amendment(contract_map_path, decisions)` to obtain amended-YAML text. The helper bumps `revision` (rev_N → rev_N+1) and is a **pure function** — no I/O, no signing.
6. Write the proposal to a non-canonical path (recommended: `<project_root>/.forge/amendment-rev-<N>.yaml.proposal`). **Forge never overwrites `progress/contract-map.yaml`.**
7. Return `fah.return_to_bob(amended_path, deltas_resolved)` to bob — a dict `{amended_map_path, deltas_resolved}`.

**What forge does NOT do** (these are bob's responsibilities, enforced by static-scan tests on the helper):
- Compute or modify the HMAC signature, touch `.forge/session.key`, or write `progress/contract-map.yaml.sig`.
- Write to `progress/integration-ledger.md`, `.ledger/claims/`, `.ledger/deltas/`, or any subpath under `.ledger/`.
- Call `scope_delta.update_status` (bob's hand-off step at 8.7).
- Call `pause_state.transition_to`, `pause_state.request_pause`, or any other pause-state mutator (CB4: only `scope_reaction.handle` may call `pause_state.request_pause`; bob orchestrates the rest).
- Run G2 as the authoritative check — bob runs G2 again on receipt before signing.

**Reference.** Full protocol detail (entry signature, dialogue script, output contract, worked SQL-table-D example, HARD-RULEs) lives in `~/.claude/skills/forge/references/amendment.md`. Read that doc before handling any `mode=amendment` invocation.

**Cross-references:**
- Helper: `~/.claude/skills/_meta/forge_amendment_helper.py` (CONTRACT-C1).
- Schema: `~/.claude/skills/_meta/schemas/scope_delta.v1.json` (CONTRACT-A2).
- Bob hot path: `~/.claude/agents/bob.md` HARD-RULE 6, Step 4.6, Step 8.7.
- Pause state machine: `~/.claude/skills/_meta/pause_state.py` (CONTRACT-A0).
- Reaction (only legal pause-state caller): `~/.claude/skills/_meta/scope_reaction.py` (CONTRACT-B2).
- Design doc: `docs/plans/2026-04-26-contract-scope-enforcement-keystone-design.md` §7.3.

---

## Visual Companion

The local `visual-companion` skill provides a server-less browser-based companion for showing mockups, diagrams, and visual options during design. It writes self-contained HTML files to `/tmp/visual-companion-<session>/` that the user opens in their browser, with no server or client-side state.

**When to offer:** After exploring project context, if upcoming questions will involve visual content (mockups, layouts, diagrams, architecture), offer it once:

> "Some of what we're working on might be easier to explain if I can show it to you in a web browser — mockups, diagrams, comparisons. Want to try the visual companion? (I'll write HTML files to /tmp/ that you open in your browser.)"

**This offer MUST be its own message.** Do not combine with clarifying questions. If they accept, invoke the `visual-companion` skill — read its SKILL.md for the protocol and templates.

**Per-question decision:** Even after acceptance, decide FOR EACH QUESTION whether to use browser or terminal. Use browser for visual content (mockups, wireframes, layout comparisons). Use terminal for text content (requirements, tradeoffs, scope decisions).

### UI designs — design-skeleton freeze (Step 2.5)

For UI-facing designs — the design output includes an HTML mockup, CSS file, new user-facing screen, or new interactive element, and `ui_scope` is not `none` — the approved mockup MUST be frozen into a signed design-skeleton. This runs AFTER the user approves the HTML mockup (checklist Step 7b) and BEFORE Step 8a contract-map signing. This is the design-phase freeze that the `visual-architect` skill refers to as "forge Step 2.5".

1. **Invoke `skeleton-extractor`** — transforms the approved HTML mockup into a draft `design-skeleton.v1` YAML (`.design-ledger/skeletons/<screen>.draft.yaml`): puppeteer-core DOM walk at 3 breakpoints, bboxes + computed styles back-resolved to declared tokens + wired interaction handlers. The draft is UNSIGNED — `interactions[].binds_to` may be `null`, and hardcoded CSS values the extractor could not back-resolve land in `unresolved_tokens_report`.
2. **User reviews the draft** — the user supplies a `capability://...` URI (or `visual_only`) for every null `binds_to`, and explicitly approves or rejects every unresolved token. Capture these as a user-edits YAML (schema in `visual-architect/SKILL.md`).
3. **Invoke `visual-architect`** (`scripts/freeze.py freeze`) — validates every `binds_to: capability://...` URI resolves via `uri.exists` (first failure → challenge filed, exit 1); enforces **D2 strict** on unresolved tokens (each MUST be explicitly user-approved into the tokens block or explicitly rejected — no silent skip; otherwise exit 2); HMAC-signs the payload with `.forge/session.key` (file bytes including trailing newline); atomically two-file writes `.design-ledger/skeletons/index.yaml` + `<screen>.yaml` via `trusted_runner.bundle_write`; emits a `skeleton_frozen` transition request to `.ledger/requests/` — **bob applies it (CB4: bob is sole ledger writer; forge/visual-architect write nothing to `.ledger/claims/` or `progress/integration-ledger.md`)**.

**Why this cannot be skipped:** bob's UI-INTEGRATED → UI-VERIFIED transition verifies the built product against the frozen skeleton — `visual-arbiter` measures bbox / computed styles / interaction wiring against it, and both the `G_XR` gate and the visual-verdict 8-field tuple require `skeleton_hash`. No frozen skeleton means no `skeleton_hash`, and UI-VERIFIED is unreachable for that screen.

Read `skeleton-extractor/SKILL.md` and `visual-architect/SKILL.md` for invocation commands, exit codes, and the user-edits schema before invoking either.

---

## Large Project Decomposition

Before asking detailed design questions, assess scope. If the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"):

1. **Flag immediately** — don't spend questions refining details of a project that needs decomposition
2. **Help decompose** — identify independent pieces, relationships, and build order
3. **Brainstorm first sub-project** — each sub-project gets its own forge cycle (design -> approval -> implementation)

### Recursion Limit

Forge tracks decomposition depth:
- depth=0: top-level task (default)
- depth=1: first sub-project from decomposition
- depth=2: sub-project of a sub-project — WARN user: "Deeply nested. Consider flattening."
- depth>=3: REFUSE to recurse. Present remaining work as a flat list for the user to prioritize.

When spawning a sub-project forge cycle, pass depth+1 in the prompt.

---

## Spec Review

After writing the design doc (step 8), run a two-stage review:

**Stage 1 — Self-review (inline):**
1. **Placeholder scan:** Any "TBD", "TODO", incomplete sections, vague requirements? Fix them.
2. **Internal consistency:** Do any sections contradict each other? Does the architecture match the feature descriptions?
3. **Scope check:** Is this focused enough for a single implementation plan, or does it need decomposition?
4. **Ambiguity check:** Could any requirement be interpreted two different ways? Pick one and make it explicit.

Fix issues inline. Then proceed to stage 2.

**Stage 1.5 — External-finding verification (S030-quickwins #37):**

If Stage 2 will dispatch external-model reviewers (Codex, agy), or if
external-model findings already exist from earlier in the design (Step 4b
challengers, the agy analyst), run the **verification pass** BEFORE
merging any of those findings into the consolidated review report.

For each external-model finding that cites a specific code/file/symbol:

1. Open the cited artifact and confirm the citation actually exists.
2. Mark the finding `VERIFIED` (citation + claim match), `FALSE-POSITIVE`
   (citation does not match the claim — e.g. spec text contradicts the
   model's interpretation), or `NEEDS-FOLLOWUP` (citation is unclear or
   needs human judgement).
3. Only `VERIFIED` findings flow into the consolidated review report. Move
   `FALSE-POSITIVE` findings to a separate "False positives, with grep
   evidence" section. Move `NEEDS-FOLLOWUP` to a third section for the
   user to adjudicate.

Codex and agy have observed false-positive rates of 60-65% on adversarial
spec/design review (DLP pilot 2026-04-09; S030-init WP-0). Skipping this
verification pass would propagate model hallucinations into the design doc
and waste user attention. The protocol — including worked examples of how
to distinguish a real bug from a model misread — lives at
`~/.claude/skills/forge/references/external-finding-verification.md`.

**Fast path — `ratify-design` workflow (S055, optional, main-loop only).**
When the orchestration tier (Step 4b) is the fast path (`probe.sh get
capabilities.workflow_tool` true AND `probe.sh context == main-loop`), Stage 1.5
MAY run as the `ratify-design` saved workflow, which MECHANIZES this verification
pass: deliberate (child `cross-cli-deliberation` — ratify-design is invoked
TOP-LEVEL via `Workflow({name})`, NEVER via `workflow()` from another script, so
its child consumes the single nesting level, WP-2 finding 7) → extract-findings
(substring-checks every quote against the ballot transcript; non-matching ⇒
`extraction_suspect` ⇒ NEEDS-FOLLOWUP) → verify-findings (ONE cold-context
verifier PER cited finding; deterministic-first `grep -n -F "<quote>"` at the
cited path — quote absent verbatim ⇒ FALSE-POSITIVE `citation-not-found`,
MANDATORY; a VERIFIED verdict without `cited_text_verbatim` + a grep line is
SCHEMA-INVALID) → assemble (`ratification-record.v1` with the per-run measured
`fp

[…] pełny plik w paczce .zip
Files in this package (13)
  • SKILL.md 69 KB
  • references/amendment.md 11 KB
  • references/external-finding-verification.md 6 KB
  • schemas/approach-output.v1.json 1 KB
  • schemas/challenger-verdict.v1.json 1 KB
  • schemas/design-synthesis.v1.json 2 KB
  • schemas/external-challenger-verdict.v1.json 2 KB
  • schemas/finding-list.v1.json 2 KB
  • schemas/finding-verification.v1.json 2 KB
  • schemas/ratification-record.v1.json 2 KB
  • schemas/ux-review.v1.json 1 KB
  • tests/test_avengers_intake.py 4 KB
  • tests/fixtures/avengers_intake_mapping.json 1 KB

Versions

RepositoryScoreLicence
This page · joogy06/agent-foundry91MIT
aimi-so/aimi-engineering-plugin100MIT
claudemods/context-forge100MIT
cwinvestments/memstack100MIT
MohammedAtya/guardrail-forge100MIT
faizanio/FORGE100MIT
thecrazybob/claude-code-plugins100MIT
floka-as/floka-marketplace100MIT

Database snapshot: 13.11.2026 · package version 24e76f3c2c2a (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100feature-planning
    Use when the user says \"plan a feature\", \"brainstorm\", \"explore this idea\", or wants to go from idea to structured plan and roadmap.
  • 90brainstorming
    You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
  • 100exploration-protocol
    Structured approach to explore features before production development. Templates for objectives, acceptance criteria, architecture, prototypes, and verification. This skill should be used when the user asks to "explore a feature", "start an exploration", "create a task folder",…
  • 100brainstorming-gate
    Use when about to implement any feature, build any component, or make any behavioral change — requires design exploration and user approval before implementation
  • 100brainstorm
    Use when the user has a complex idea that needs design exploration before story decomposition.
  • 100feature-design
    Use when the user has a rough idea for a feature, product change, or new capability and wants to brainstorm, shape, design, or spec it before building, such as "I'm thinking of adding…", "how should we approach…", "help me design…", or "write a spec for…".

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.