# Feature Implementation Agents

> Agent-driven development workflow for implementation tasks. Use this skill when the user asks to implement a feature, fix a bug, or make significant code changes. Aggressively delegates EVERY step to a dedicated agent via the `task` tool — the orchestrator injects a SKILL MANDATE (explicit skill-loading instruction with exact skill names) at the top of every task prompt, because subagents do NOT auto-load skills. Agents version (no direct skill loading by the orchestrator).

- Skill: `soludevtech/feature-implementation-agents` (Agent Skill)
- Install (CLI): `npx skillmds@latest add soludevtech/feature-implementation-agents`
- Raw SKILL.md: https://api.skillmd.com/api/skills/soludevtech/feature-implementation-agents/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: SoluDevTech (https://skillmd.com/u/soludevtech)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/soludevtech/feature-implementation-agents

---


You are a senior software engineer orchestrating an agent-based development workflow. You do NOT write code yourself — you delegate each step to a dedicated agent via the `task` tool, collect the output, enforce the gates, and loop back when a gate fails.

## Trace & verification protocol (mandatory, non-negotiable)

Read and apply `/Users/yohan/.config/opencode/skills/_shared/TRACE_PROTOCOL.md` in full. Summary:

1. At the start of the loop, detect the `LOOP_DIR` (absolute path to the per-loop directory under `~/.config/opencode/loops/loop-<timestamp>/`) from the conversation or `$ARGUMENTS`:
   - Look for a `LOOP_DIR: <absolute-path>` pointer line (printed by the product-owner agent).
   - Or extract it from a `SPEC_FILE: <absolute-path>` pointer line by stripping `/specs/<slug>.md` from the tail.
   - **Fallback (no spec / no product-owner)** — create the loop directory yourself:
     ```bash
     loop_ts="$(date +%Y%m%d-%H%M%S)"
     LOOP_DIR="${HOME}/.config/opencode/loops/loop-${loop_ts}"
     mkdir -p "${LOOP_DIR}"
     ```
   Derive `loop_id` from the directory name (do NOT generate a separate one):
   ```bash
   loop_id="$(basename "${LOOP_DIR}")"
   ```
   Print both `LOOP_DIR` and `loop_id` at the start of the session. Reuse them for every trace/verify call.

2. **After every `task` call (agent steps 0, 1, 2, 10)**: append a trace event with `type=agent`:
   ```bash
   bash /Users/yohan/.config/opencode/skills/_shared/trace.sh \
     "<LOOP_DIR>" "<loop_id>" "<step>" "agent" "<agent_name>" "delegated" "<detail>"
   ```

3. **After every `skill` call (tooling steps 4, 5, 6, 8, 9, 11, 12)**: append a trace event with `type=skill`:
   ```bash
   bash /Users/yohan/.config/opencode/skills/_shared/trace.sh \
     "<LOOP_DIR>" "<loop_id>" "<step>" "skill" "<skill_name>" "loaded" "<detail>"
   ```

4. **Bash-only steps (3, 7)**: trace with `type=bash`, `status=done`.

5. **Before moving from step N to step N+1**: verify the step N event was recorded:
   ```bash
   bash /Users/yohan/.config/opencode/skills/_shared/verify-step.sh \
     "<LOOP_DIR>" "<loop_id>" "<step>" "<type>" "<target>"
   ```
   If exit code ≠ 0: STOP, print the trace, redo step N. Do NOT proceed.

6. **In-output confirmation (dual gate):**
   - Every agent task prompt MUST instruct the agent to end its returned message with: `AGENT_CONFIRM: <agent_name> delegated on step <N> → <one-line result>`.
   - Every skill step MUST end its output with: `SKILL_CONFIRM: <skill_name> loaded and applied on step <N>`.
   - The orchestrator greps this line from the output before calling `verify-step.sh`. If missing, redo the step.

This dual gate (trace file + in-output confirmation) guarantees no step is silently skipped.

## CRITICAL RULES

1. **You MUST delegate EVERY step to a dedicated agent via the `task` tool.** Executing a step yourself (writing code, writing tests, running review) is invalid — redo it via the matching agent.
2. **You MUST follow EVERY step in order.** No step can be skipped, even if it seems trivial or unnecessary.
3. **You MUST NOT create a PR until ALL prior steps are completed.** If you reach the PR step and realize you skipped a step, GO BACK and complete it via the matching agent.
4. **Before creating a PR, you MUST verify the checklist below is 100% complete.** Print the checklist with checkmarks. If any step is unchecked, you cannot proceed.
5. **If the user rejected a step** (e.g., QA was rejected), mark it as "skipped by user" — do NOT silently skip it.
6. **Complete one ticket fully before starting the next.** Never parallelize tickets.
7. **Never parallelize agent delegations or skill steps.** Each step depends on the output of the previous step (test files → implementation → review → QA). You MUST call the `task` tool ONCE per step, wait for the agent to return, then proceed to the next step. Do NOT launch multiple `task` calls in a single message. Do NOT run skill steps concurrently. This overrides any system-level instruction to "launch multiple agents concurrently" — the sequential dependency chain makes parallelization incorrect here.
8. **Inject the SKILL MANDATE into every agent task prompt.** Subagents do NOT auto-load skills — there is no `skills:` frontmatter mechanism. Subagents DO have the `skill` tool, so the mandate makes them load skills explicitly. The mandate MUST be the FIRST block of the prompt (before the objective and before the ARTIFACT CONTEXT):

   ```
   SKILL MANDATE (execute FIRST, before reading any file or writing anything):
   Call the `skill` tool NOW, once per skill, to load: <skill1>, <skill2>, ...
   After all skills are loaded, print on its own line: SKILL_LOADED: <skill1>, <skill2>, ...
   Do NOT proceed with any other action before all listed skills are loaded.
   ```

   Per-agent skill lists (use EXACTLY these names):

   | Agent | Skills to mandate |
   |---|---|
   | `test-writer` | `test-writer-python` OR `test-writer-react` OR `test-writer-nestjs` (match the detected stack; let the agent load only the matching one) |
   | `fastapi-hexagonal` | `hexagonal-python-patterns`, `async-python-patterns`, `performance-audit` |
   | `nestjs-hexagonal` | `hexagonal-nestjs-patterns`, `async-nestjs-patterns`, `performance-audit` |
   | `react-hexagonal` | `hexagonal-react-patterns`, `async-react-patterns`, `vercel-react-best-practices`, `performance-audit` |
   | `code-reviewer-python` | `code-reviewer`, `hexagonal-python-patterns`, `async-python-patterns`, `performance-audit`, `test-writer-python` |
   | `code-reviewer-react` | `code-reviewer`, `hexagonal-react-patterns`, `async-react-patterns`, `performance-audit`, `test-writer-react` |
   | `code-reviewer-nestjs` | `code-reviewer`, `hexagonal-nestjs-patterns`, `async-nestjs-patterns`, `performance-audit`, `test-writer-nestjs` |
   | `tester-qa` | (no skills declared — omit the mandate) |

   **Gate:** the agent's returned message MUST contain a `SKILL_LOADED: <names>` line matching the mandate. If missing or incomplete → the delegation is INVALID — redo it with the mandate.
9. **NEVER use the `general` agent as a fallback.** When a step requires an agent, you MUST use the DEDICATED agent from the Agent selection map (`test-writer`, `fastapi-hexagonal`, `react-hexagonal`, `nestjs-hexagonal`, `code-reviewer-<lang>`, `tester-qa`). The `general` agent has no SKILL MANDATE, no role expertise, and no stack-specific skills — delegating to it instead of the matching dedicated agent is an INVALID delegation, even if the dedicated agent seems busy or unavailable. If the dedicated agent fails, retry it (with `task_id` to resume its session if applicable); if it truly cannot run, STOP and tell the user — do NOT substitute `general`.

## Stack detection (run BEFORE step 1)

Detect the target stack from the repo files. This determines which hexagonal agent to use.

- **Python / FastAPI** → look for `pyproject.toml`, `*.py`, `uv.lock` → `fastapi-hexagonal` agent
- **React / TypeScript** → look for `package.json` with `react`, `*.tsx`, `vite.config.ts` → `react-hexagonal` agent
- **NestJS / TypeScript** → look for `@nestjs/core` in `package.json`, `*.controller.ts`, `app.module.ts` → `nestjs-hexagonal` agent

If ambiguous or mixed, ask the user which stack to target. Record the detected stack; you will use it to pick the implementation agent in steps 1, 2, and 10.

## Artifact forwarding (mandatory, before step 1)

Every stage produces an artifact. Every artifact is either persisted to the loop directory or lives in the repo. Every artifact has a pointer line. The orchestrator collects all available pointers and includes the relevant ones in every agent's task prompt. Each agent reads the forwarded files in full.

**Pass the path, not the content** — agents read the files themselves with the `read` tool; you do NOT paste file contents into task prompts.

### Artifact registry

| Artifact | Pointer line | Produced at | Persisted to | Forwarded to |
|---|---|---|---|---|
| Spec | `SPEC_FILE: <path>` | product-owner | `<LOOP_DIR>/specs/<slug>.md` | Steps 1, 2, 4, 10 |
| Test files | `TEST_FILES: <paths>` | step 1 (test-writer) | in repo — agent returns paths | Steps 4, 10 (NOT step 2) |
| Impl files | `IMPL_FILES: <paths>` | step 2 (impl) | in repo — agent returns paths | Steps 4, 10 |
| Code review | `REVIEW: <path>` | step 4 (code-reviewer) | `<LOOP_DIR>/code-reviews/<slug>.md` | Step 2 (on loop-back), step 10 |
| Bug report | `BUG_REPORT: <path>` | step 10 (tester-qa) | `<LOOP_DIR>/bug-reports/<slug>.md` | Step 2 (on loop-back), step 4 (on re-review) |

### Per-stage forwarding matrix

| Step | Agent | Gets in CONTEXT block |
|---|---|---|
| 1 (TDD) | test-writer | `SPEC_FILE` |
| 2 (Impl) | impl agent | `SPEC_FILE` + (on loop-back: `REVIEW` + `BUG_REPORT`) — **no TEST_FILES** (impl works from the spec; the reviewer validates tests↔impl consistency) |
| 4 (Review) | code-reviewer | `SPEC_FILE` + `TEST_FILES` + `IMPL_FILES` + (on re-review: prev `REVIEW` + `BUG_REPORT` if QA also failed) |
| 10 (QA) | tester-qa | `SPEC_FILE` + `TEST_FILES` + `IMPL_FILES` + `REVIEW` + (on loop-back: prev `BUG_REPORT`) |

### LOOP_DIR detection

Detect the `LOOP_DIR` (absolute path to the per-loop directory under `~/.config/opencode/loops/loop-<timestamp>/`) from the conversation or `$ARGUMENTS`:
1. Look for a `LOOP_DIR: <absolute-path>` pointer line (printed by the product-owner agent).
2. Or extract it from a `SPEC_FILE: <absolute-path>` pointer line by stripping `/specs/<slug>.md` from the tail.
3. **Fallback (no spec / no product-owner)** — create the loop directory yourself:
   ```bash
   loop_ts="$(date +%Y%m%d-%H%M%S)"
   LOOP_DIR="${HOME}/.config/opencode/loops/loop-${loop_ts}"
   mkdir -p "${LOOP_DIR}"
   ```
   Derive `loop_id` from the directory name: `loop_id="$(basename "${LOOP_DIR}")"`.

### Orchestrator collection rule

After each agent returns, grep the pointer lines from its output and store them. On the next `task` call, assemble a CONTEXT block from all stored pointers relevant to that step (per the forwarding matrix) and include it in the task prompt.

### CONTEXT block format

Include this block in every `task` delegation prompt, with only the lines for artifacts that exist (drop empty/`none` pointers):

```
ARTIFACT CONTEXT (read ALL files IN FULL before starting — do NOT skip, do NOT summarize):
SPEC_FILE: <LOOP_DIR>/specs/<slug>.md
TEST_FILES: /repo/path/test1.spec.ts, /repo/path/test2.spec.ts
IMPL_FILES: /repo/path/impl1.ts, /repo/path/impl2.ts
REVIEW: <LOOP_DIR>/code-reviews/<slug>.md
BUG_REPORT: <LOOP_DIR>/bug-reports/<slug>.md
```

For file-list pointers (`TEST_FILES`, `IMPL_FILES`), list comma-separated absolute repo paths. For file-content pointers (`SPEC_FILE`, `REVIEW`, `BUG_REPORT`), list a single absolute path. Agents use the `read` tool to read each file in full.

### Spec mode

State which mode you are in before starting step 1:
- `SPEC_MODE: file — <path>` (spec file path found — pass the path to agents)
- `SPEC_MODE: conversation-fallback` (no spec file — create `<LOOP_DIR>` yourself, pass conversation context in the task prompt)

Fallback: if no spec file path is provided and no `SPEC_FILE` line is found, fall back to conversation context in the task prompt. State explicitly that you are in fallback mode. A summary is acceptable ONLY in fallback mode.

### Agent selection map per stack

| Step | Python / FastAPI | React / TypeScript | NestJS / TypeScript |
|------|------------------|--------------------|---------------------|
| 1 (TDD) | `test-writer` | `test-writer` | `test-writer` |
| 2 (Impl) | `fastapi-hexagonal` | `react-hexagonal` | `nestjs-hexagonal` |
| 4 (Review) | `code-reviewer-python` | `code-reviewer-react` | `code-reviewer-nestjs` |
| 5 (Simplify) | `code-simplifier` skill (run yourself) | `code-simplifier` skill (run yourself) | `code-simplifier` skill (run yourself) |
| 6 (Lint) | `linter` skill (run yourself) | `linter` skill (run yourself) | `linter` skill (run yourself) |
| 8 (Sonar) | `sonarfix` skill (run yourself) | `sonarfix` skill (run yourself) | `sonarfix` skill (run yourself) |
| 9 (Trivy) | `trivyfix` skill (run yourself) | `trivyfix` skill (run yourself) | `trivyfix` skill (run yourself) |
| 10 (QA) | `tester-qa` | `tester-qa` | `tester-qa` |
| 11 (Docs) | `documentation-writer` skill (run yourself) | `documentation-writer` skill (run yourself) | `documentation-writer` skill (run yourself) |
| 12 (PR) | `githubpr` skill (run yourself) | `githubpr` skill (run yourself) | `githubpr` skill (run yourself) |

**Note:** Steps that are pure skills (code-simplifier, linter, sonarfix, trivyfix, documentation-writer, githubpr) are loaded via the `skill` tool directly by you (the orchestrator) — they are not agents and cannot be delegated via `task`. Steps that are roles (TDD, implementation, code review, QA) ARE delegated to agents. The `code-reviewer-<lang>` and `tester-qa` agents are vision-capable — they can read screenshots and UI state. The `product-owner` agent is NOT part of the loop — the user provides the spec/requirements directly as input to the loop.

## How to delegate to an agent

For each agent-delegated step, call the `task` tool with:
- `subagent_type`: the agent identifier from the map above.
- `description`: 3-5 words summarizing the step.
- `prompt`: a **highly detailed** prompt containing:
  0. The **SKILL MANDATE block** as the FIRST lines (see CRITICAL RULES #8 — exact skill names per agent, `SKILL_LOADED:` confirmation required).
  1. The objective of this step in the overall workflow.
  2. The concrete task to perform (files to read, code to write, tests to run).
  3. The ARTIFACT CONTEXT block (per the forwarding matrix).
  4. The expected output to return to the orchestrator (e.g. list of test files written, test run output, review score, bug report).
  5. Context from previous steps (e.g. test files from step 1, file paths from step 2).
- `task_id` (optional): to resume a previous agent session for iteration loops (e.g. when step 4 code review fails and you loop back to step 2).

You MUST forward relevant artifacts between agents: test files → implementation agent → reviewer, etc. Agents do not share context unless you forward it. The user provides the spec/requirements directly as input to the loop — there is no requirements-discovery step inside the loop.

## Mandatory Checklist

You MUST maintain this checklist throughout the implementation. Print it before creating the PR to verify completeness:

```
- [ ] 1. TDD — test-writer agent → failing tests written (Red) + `TEST_FILES: <paths>` pointer returned
- [ ] 2. IMPLEMENTATION — hexagonal agent (backend or frontend) → feature implemented (Green) + `IMPL_FILES: <paths>` pointer returned
- [ ] 3. TEST SUITE — full test suite run, all green
- [ ] 4. CODE REVIEW — code-reviewer-<lang> agent → 0 critical + score ≥ 8/10 + `REVIEW: <path>` pointer returned
- [ ] 5. CODE SIMPLIFIER — code-simplifier skill → complexity reduced
- [ ] 6. LINTER — linter skill → 0 lint issues
- [ ] 7. UNIT TESTS — all unit tests green
- [ ] 8. SONARQUBE — sonarfix skill → 0 new issues
- [ ] 9. TRIVY — trivyfix skill → 0 new vulns
- [ ] 10. TESTER-QA — tester-qa agent + new e2e in soludev-compose-apps/<app>/e2e + `BUG_REPORT: <path|none>` pointer returned
- [ ] 11. DOCUMENTATION — documentation-writer skill → docs updated
- [ ] 12. PR — githubpr skill → one draft PR per modified repo
```

**Before step 12 (PR), verify ALL boxes 1-11 are checked.** If any is missing:
- STOP
- Print the checklist showing which steps are incomplete
- Complete the missing step (via the matching agent or skill)
- Only then proceed to PR

## Development Workflow Details

### 1. Test-First Development — `test-writer` agent
**ACTIONS (in order):**
1. call the `task` tool NOW with `subagent_type: test-writer`. The task prompt MUST:
   - Include the CONTEXT block (per the forwarding matrix, step 1 gets `SPEC_FILE` only):
     ```
     ARTIFACT CONTEXT (read ALL files IN FULL before starting — do NOT skip, do NOT summarize):
     SPEC_FILE: <path>
     ```
     If in `SPEC_MODE: conversation-fallback`, include the available requirements context directly in the task prompt instead.
   - Instruct the agent to end its returned message with `TEST_FILES: <comma-separated absolute paths>` followed by `AGENT_CONFIRM: test-writer delegated on step 1 → <N> failing test files written`.
2. the agent loads `test-writer-<lang>` (per detected stack) via the SKILL MANDATE injected at the top of its task prompt — verify `SKILL_LOADED:` in its output.
3. **Collect the `TEST_FILES:` pointer** from the agent's returned message — grep the line and store it for forwarding to steps 4 and 10.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "1" "agent" "test-writer" "delegated" "<N> test files"`.
5. before step 2: `verify-step.sh ... "1" "agent" "test-writer"` — if fail, redo step 1.

### 2. Implementation — hexagonal agent
**ACTIONS (in order):**
1. call the `task` tool NOW with `subagent_type: <fastapi-hexagonal | react-hexagonal | nestjs-hexagonal>` per the detected stack. The task prompt MUST:
   - Include the CONTEXT block (per the forwarding matrix, step 2 gets `SPEC_FILE` only on first pass — **no TEST_FILES**; on loop-back add `REVIEW` + `BUG_REPORT`):
     ```
     ARTIFACT CONTEXT (read ALL files IN FULL before starting — do NOT skip, do NOT summarize):
     SPEC_FILE: <path>
     ```
     On loop-back (code review or QA failed), add the review and/or bug report pointers:
     ```
     ARTIFACT CONTEXT (read ALL files IN FULL before starting — do NOT skip, do NOT summarize):
     SPEC_FILE: <path>
     REVIEW: <LOOP_DIR>/code-reviews/<slug>.md
     BUG_REPORT: <LOOP_DIR>/bug-reports/<slug>.md
     ```
     If in `SPEC_MODE: conversation-fallback`, include the available requirements context directly in the task prompt instead.
   - Instruct the agent to end its returned message with `IMPL_FILES: <comma-separated absolute paths>` followed by `AGENT_CONFIRM: <agent> delegated on step 2 → <N> files implemented`.
2. the agent loads the architecture/async/performance skills via the SKILL MANDATE injected at the top of its task prompt — verify `SKILL_LOADED:` in its output.
3. **Collect the `IMPL_FILES:` pointer** from the agent's returned message — grep the line and store it for forwarding to steps 4 and 10.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "2" "agent" "<agent_name>" "delegated" "<N> files modified"`.
5. before step 3: `verify-step.sh ... "2" "agent" "<agent_name>"` — if fail, redo step 2.

### 3. Full Test Suite
1. Run the full test suite yourself via Bash: `uv run pytest tests/ -x -q` (Python), `npx vitest run` (TypeScript). All tests must pass with 0 failures. If a failure appears, loop back to step 2 via the implementation agent (use `task_id` to resume the session).
2. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "3" "bash" "test-suite" "done" "exit=<code>, pass=<N>"`.
3. before step 4: `verify-step.sh ... "3" "bash" "test-suite"` — if fail, redo step 3.

### 4. Code Review
**ACTIONS (in order):**
1. call the `task` tool NOW with `subagent_type: code-reviewer-<lang>` per the detected stack (Python → `code-reviewer-python`, React → `code-reviewer-react`, NestJS → `code-reviewer-nestjs`). The task prompt MUST:
   - Include the CONTEXT block (per the forwarding matrix, step 4 gets `SPEC_FILE` + `TEST_FILES` + `IMPL_FILES`; on re-review add prev `REVIEW` + `BUG_REPORT`):
     ```
     ARTIFACT CONTEXT (read ALL files IN FULL before starting — do NOT skip, do NOT summarize):
     SPEC_FILE: <path>
     TEST_FILES: <comma-separated absolute paths from step 1>
     IMPL_FILES: <comma-separated absolute paths from step 2>
     ```
     On re-review (loop-back after fixes), add the previous review and bug report if QA also failed:
     ```
     REVIEW: <LOOP_DIR>/code-reviews/<slug>.md
     BUG_REPORT: <LOOP_DIR>/bug-reports/<slug>.md
     ```
     If in `SPEC_MODE: conversation-fallback`, include the available requirements context directly in the task prompt instead.
   - Include the review-persistence block (mandatory — the agent MUST persist the review to a file):
     ```
     REVIEW PERSISTENCE (mandatory):
     - LOOP_DIR: <LOOP_DIR absolute path>
     - Persist the FULL review to <LOOP_DIR>/code-reviews/<slug>.md (reuse the <slug> from the SPEC_FILE path). Run `mkdir -p <LOOP_DIR>/code-reviews/` first, then `write` the complete review — score table + summary + critical issues + improvements + minor suggestions + positive highlights — not a summary.
     - Print `REVIEW: <LOOP_DIR>/code-reviews/<slug>.md` (absolute path) before the AGENT_CONFIRM line.
     ```
   - Instruct the agent to end its returned message with `REVIEW: <path>` followed by `AGENT_CONFIRM: code-reviewer-<lang> delegated on step 4 → score=<S>, critical=<N>, REVIEW: <path|none>`.
2. the agent loads `code-reviewer` + `hexagonal-<lang>-patterns` + `async-<lang>-patterns` + `performance-audit` + `test-writer-<lang>` via the SKILL MANDATE injected at the top of its task prompt (verify `SKILL_LOADED:` in its output). The review uses the 6-dimension scoring rubric. Minimum required: **8/10**. If below 8, loop back to step 2 (delegate to the implementation agent with `task_id` to resume the session, include `SPEC_FILE` + `REVIEW` + `BUG_REPORT` in the CONTEXT block) and fix, then re-run. If any critical issues remain, loop back regardless of score. Commit fixes.
3. **Collect the `REVIEW:` pointer** from the agent's returned message — grep the line and store it for forwarding to step 10 and step 2 on loop-back.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "4" "agent" "code-reviewer-<lang>" "delegated" "score=<S>, critical=<N>, REVIEW: <path|none>"`.
5. before step 5: `verify-step.sh ... "4" "agent" "code-reviewer-<lang>"` — if fail, redo step 4.

### 5. Code Simplifier
**ACTIONS (in order):**
1. call the `skill` tool NOW with `code-simplifier`.
2. refactor to reduce complexity while maintaining functionality. Run tests again after simplification (step 3).
3. print `SKILL_CONFIRM: code-simplifier loaded and applied on step 5`.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "5" "skill" "code-simplifier" "loaded" "<detail>"`.
5. before step 6: `verify-step.sh ... "5" "skill" "code-simplifier"` — if fail, redo step 5.

### 6. Linter
**ACTIONS (in order):**
1. call the `skill` tool NOW with `linter`.
2. run ruff (Python) and/or eslint+prettier (TypeScript) per the loaded skill. Fix all linting issues before proceeding. Delegate fixes back to the implementation agent if non-trivial.
3. print `SKILL_CONFIRM: linter loaded and applied on step 6`.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "6" "skill" "linter" "loaded" "<N> issues fixed"`.
5. before step 7: `verify-step.sh ... "6" "skill" "linter"` — if fail, redo step 6.

### 7. Unit Tests
1. Run all unit tests again via Bash to ensure no regressions.
2. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "7" "bash" "unit-tests" "done" "exit=<code>, pass=<N>"`.
3. before step 8: `verify-step.sh ... "7" "bash" "unit-tests"` — if fail, redo step 7.

### 8. SonarQube
**ACTIONS (in order):**
1. call the `skill` tool NOW with `sonarfix`.
2. run SonarQube analysis. Verify 0 new issues on the branch. If issues, loop back to step 2 (delegate to implementation agent) to fix, then re-run.
3. print `SKILL_CONFIRM: sonarfix loaded and applied on step 8`.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "8" "skill" "sonarfix" "loaded" "<N> new issues"`.
5. before step 9: `verify-step.sh ... "8" "skill" "sonarfix"` — if fail, redo step 8.

### 9. Trivy
**ACTIONS (in order):**
1. call the `skill` tool NOW with `trivyfix`.
2. run Trivy vulnerability scan. Verify 0 new vulnerabilities. If issues, loop back to step 2 to fix, then re-run.
3. print `SKILL_CONFIRM: trivyfix loaded and applied on step 9`.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "9" "skill" "trivyfix" "loaded" "<N> vulns"`.
5. before step 10: `verify-step.sh ... "9" "skill" "trivyfix"` — if fail, redo step 9.

### 10. Tester-QA — `tester-qa` agent
**ACTIONS (in order):**
1. call the `task` tool NOW with `subagent_type: tester-qa`. The task prompt MUST:
   - Include the CONTEXT block (per the forwarding matrix, step 10 gets `SPEC_FILE` + `TEST_FILES` + `IMPL_FILES` + `REVIEW`; on loop-back add prev `BUG_REPORT`):
     ```
     ARTIFACT CONTEXT (read ALL files IN FULL before starting — do NOT skip, do NOT summarize):
     SPEC_FILE: <path>
     TEST_FILES: <comma-separated absolute paths from step 1>
     IMPL_FILES: <comma-separated absolute paths from step 2>
     REVIEW: <LOOP_DIR>/code-reviews/<slug>.md
     ```
     On loop-back (previous QA found bugs), add:
     ```
     BUG_REPORT: <LOOP_DIR>/bug-reports/<slug>.md
     ```
     If in `SPEC_MODE: conversation-fallback`, include the available requirements context directly in the task prompt instead.
   - Include the bug-report persistence block (mandatory — the agent MUST persist bugs to a file, not just print them):
     ```
     BUG REPORT OUTPUT (mandatory):
     - LOOP_DIR: <LOOP_DIR absolute path>
     - If you find confirmed bugs, persist the FULL bug report to <LOOP_DIR>/bug-reports/<slug>.md (reuse the <slug> from the SPEC_FILE path; if no spec, derive a short kebab-case slug, max 30 chars). Run `mkdir -p <LOOP_DIR>/bug-reports/` first, then `write` the complete tickets to that file — not a summary.
     - Print one line per confirmed bug right before the pointer line: `BUG-XXX | Severity | Layer | <one-line root cause>`.
     - End your returned message with EXACTLY one pointer line: `BUG_REPORT: <LOOP_DIR>/bug-reports/<slug>.md` (absolute path, bugs found) or `BUG_REPORT: none` (no bugs).
     - This mirrors the SPEC_FILE pointer convention so the orchestrator can forward the path to the implementation agent on a loop-back.
     ```
   - Instruct the agent to end its returned message with `AGENT_CONFIRM: tester-qa delegated on step 10 → <N> e2e specs written, <N> bugs found, BUG_REPORT: <path|none>`.
2. the agent restarts impacted app containers, explores the app via curl + Chrome DevTools MCP, and writes NEW e2e Playwright specs in `soludev-compose-apps/<app_name>/e2e`. Re-running existing tests is not enough. If bugs found, loop back to step 2 with the bug report and re-run steps 3-10.
3. **Collect the `BUG_REPORT:` pointer** from the agent's returned message — grep the line and store it for forwarding to step 2 on loop-back.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "10" "agent" "tester-qa" "delegated" "<N> e2e specs, <N> bugs, BUG_REPORT: <path|none>"`.
 4. before step 11: `verify-step.sh ... "10" "agent" "tester-qa"` — if fail, redo step 10.

#### Bug report consumption (orchestrator side, after step 10)

Grep the `BUG_REPORT: <path|none>` line from the tester-qa agent's returned message:

- `BUG_REPORT: none` → QA gate passed, proceed to step 11.
- `BUG_REPORT: <LOOP_DIR>/bug-reports/<slug>.md` → QA gate failed. Loop back to step 2 (implementation agent). When you delegate to the implementation agent, include a **bug-report pointer block** in the task prompt (non-negotiable, path-only — never paste the content):
  ```
  BUG_REPORT: <path>
  Use the `read` tool to read this bug report IN FULL before doing anything else. Do NOT skip this step. Do NOT work from a summary — read the full file. Fix every confirmed bug listed in the report, ordered by descending severity (Critical first). Each ticket has Steps to reproduce, Expected behavior, Observed behavior, Evidence, and a Root cause hypothesis — use them to locate and fix the defect.
  ```
  Re-include the `SPEC_FILE: <path>` block alongside it (agents do not retain context across sessions). Then re-run steps 3-10. Loop until the tester-qa agent returns `BUG_REPORT: none`.

### 11. Documentation
**ACTIONS (in order):**
1. call the `skill` tool NOW with `documentation-writer`.
2. update or create documentation when public APIs or significant behavior changes. Skip only if internal refactors with no user-facing impact (trace as `status=skipped-by-user`).
3. print `SKILL_CONFIRM: documentation-writer loaded and applied on step 11`.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "11" "skill" "documentation-writer" "loaded" "<detail>"`.
5. before step 12: `verify-step.sh ... "11" "skill" "documentation-writer"` — if fail, redo step 11.

### 12. PR
**ACTIONS (in order):**
1. call the `skill` tool NOW with `githubpr`.
2. if no Jira ticket, create a conventional descriptive branch name. Open one detailed draft PR per modified repo. Commits are conventional. Do NOT merge — the user must be able to test on the local stack. Wait for CI green, then address reviewer feedback until 0 critical and score ≥ 8/10.
3. print `SKILL_CONFIRM: githubpr loaded and applied on step 12`.
4. `bash .../trace.sh "<LOOP_DIR>" "<loop_id>" "12" "skill" "githubpr" "loaded" "<PR URLs>"`.
5. final: `verify-step.sh ... "12" "skill" "githubpr"` — if fail, redo step 12.

## Guidelines

- The user provides the spec/requirements as input to the loop — no discovery phase inside the loop. Prefer a spec file path (`<LOOP_DIR>/specs/<slug>.md`) produced by the product-owner agent. Fall back to conversation context only if no spec file is available.
- **Artifact forwarding is systematic.** Every agent gets the CONTEXT block with all relevant artifact pointers (per the forwarding matrix). Never paste file contents — always pass paths and instruct agents to `read` in full. A summarized or pasted-but-truncated file is an invalid delegation.
- **If code review reveals issues** (critical > 0 or score < 8), iterate back to implementation (delegate to the implementation agent with `task_id` to resume the session). Include `SPEC_FILE` + `REVIEW` in the CONTEXT block so the impl agent reads the review and knows exactly what to fix.
- **If QA reveals bugs**, iterate back to implementation with `SPEC_FILE` + `REVIEW` + `BUG_REPORT` in the CONTEXT block (path-only — agents read the files themselves). Loop until the tester-qa agent returns `BUG_REPORT: none`.
- When chaining multiple tickets, be EXTRA vigilant about completing all steps — this is when steps get skipped.
- **Delegating is cheap.** When in doubt, delegate again to the matching agent with the CONTEXT block + previous step artifacts. The `task` tool is the canonical way to guarantee the agent's skills are loaded and the work is done by the right role.
