---
name: reversa-coding
description: Drives the execution of actions.md into code. Updates checkboxes to [X], writes progress.jsonl, generates legacy-impact.md and regression-watch.md. Use when the user types "/reversa-coding", "reversa-coding", "execute plan", or asks to start coding the active feature. Last skill of the forward cycle, after `/reversa-to-do` (and optionally `/reversa-audit` or `/reversa-quality`).
license: MIT
compatibility: Claude Code, Codex, Cursor, Gemini CLI, and other Agent Skills-compatible agents.
metadata:
  author: pnocera
  version: "1.0.0"
  framework: reversa
  phase: forward
  stage: coding
---

You are the executor. Your mission is to transform `actions.md` into real code, phase by phase, respecting parallelism and dependencies. When finished, leave two audit trails: `legacy-impact.md` (what was changed in the legacy) and `regression-watch.md` (what must remain true in future extractions).

## Before starting

1. Read `.reversa/state.json` to resolve `output_folder` and `forward_folder`
2. Use the real values wherever the text mentions `_reversa_sdd/` or `_reversa_forward/`

## Non-negotiable prerequisite: reverse extraction

This skill **REQUIRES** that the reverse pipeline has been executed at least once before. Without `_reversa_sdd/`, the two central artifacts of this skill (`legacy-impact.md` and `regression-watch.md`) have no anchor and lose all value — the forward cycle becomes just another generic framework. Reversa only makes sense with the legacy-code bridge alive.

The check is strict: `_reversa_sdd/` must exist as a directory AND contain at least `architecture.md` AND `domain.md`. If any condition fails, the skill aborts with a clear message, does NOT offer an option to proceed anyway, and does NOT write anything to disk.

## Initial Checks

1. Read `.reversa/active-requirements.json`
   1.1. If absent, abort with a message pointing to `/reversa-requirements`
2. Verify the existence of `feature-dir/actions.md`
   2.1. If absent, abort with a message pointing to `/reversa-to-do`
3. Verify the reverse extraction prerequisite:
   3.1. If `_reversa_sdd/` does not exist as a directory, abort with the message:

       > 🛑 `/reversa-coding` requires the reverse pipeline to have been executed first. The `_reversa_sdd/` folder was not found.
       >
       > Run `/reversa` to generate the legacy extraction and then come back here. Without this context, `legacy-impact.md` and `regression-watch.md` would have no anchor and the forward cycle would lose its differentiator.

   3.2. If `_reversa_sdd/` exists but `architecture.md` is missing, abort with the message:

       > 🛑 `/reversa-coding` requires `_reversa_sdd/architecture.md` (generated by Architect in the reverse pipeline). The file is absent — the extraction may have been partial.
       >
       > Run `/reversa` in full mode (minimum `essencial`) and come back here.

   3.3. If `_reversa_sdd/architecture.md` exists but `_reversa_sdd/domain.md` is missing, abort with the message:

       > 🛑 `/reversa-coding` requires `_reversa_sdd/domain.md` (generated by Detective in the reverse pipeline). The file is absent.
       >
       > Run `/reversa` to complete the extraction and come back here.

   3.4. In all cases in step 3, do NOT create `legacy-impact.md`, do NOT create `regression-watch.md`, do NOT touch `actions.md`, do NOT write `progress.jsonl`. Only report and stop.

4. Apply `before-coding` in the standard way

## Round scope

1. If the free argument indicates a phase or ID range (e.g., "only Core", "T001-T005"), restrict execution to that scope
2. Otherwise, execute in order all `[ ]` actions not yet completed

## Execution loop by phase

For each phase, in the order Preparation, Tests, Core, Integration, Polish:

1. Select all actions in the phase with status `[ ]`
2. Calculate the independent set (actions with no open dependency)
3. For the independent set, identify the sub-set marked `[//]`
   3.1. Execute that sub-set treating each action as a coherent block, but report separately
4. Execute the remaining actions in the set sequentially
5. After each action:
   5.1. Update `feature-dir/actions.md` changing `[ ]` to `[X]`
   5.2. Write a line to `feature-dir/progress.jsonl` with ISO 8601 timestamp, action ID, final status, files touched
6. If an action fails:
   6.1. Keep `[ ]` in actions
   6.2. Record `status: failed` in progress
   6.3. Stop the phase and report to the user

## Generating legacy-impact.md

After executing (even partially):

1. For each project file touched, map it to the corresponding component in `_reversa_sdd/architecture.md` when possible
2. For each affected component, classify the type of impact: `rule-changed`, `rule-removed`, `new-rule`, `new-component`, `component-removed`, `data-delta`, `external-contract-delta`
3. Assign severity aligned with `/reversa-audit` (CRITICAL, HIGH, MEDIUM, LOW)
4. List 🟢 rules from `_reversa_sdd/domain.md` that remain intact (go to the "Preserved" section)
5. List 🟢 rules that were changed or removed (go to the "Modified" section)

File structure:

1. Header with date and feature identifier
2. Table `Affected file | Component | Type | Severity | Justification`
3. Conceptual diff per component, in prose
4. "Preserved" section
5. "Modified" section

Write to `feature-dir/legacy-impact.md` with atomic write, full rewrite.

## Generating regression-watch.md

1. For each rule in the "Modified" section of `legacy-impact.md`, generate a watch item
2. For explicitly removed rules, generate a watch item of type `absence`
3. For changed rules, generate a watch item of type `wording` or `presence` as appropriate
4. For rules with downgraded confidence, generate a watch item of type `confidence`
5. Assign a stable ID `W001`, `W002`, ..., recycling old IDs from the file if it already exists

Structure:

1. Header with feature identifier
2. Table `ID | Origin (file, section) | Expected rule after change | Verification type | Violation signal`
3. "Re-extraction history" section initially empty — will be filled by the reverse agent when `/reversa` runs again
4. "Archived" section initially empty

NEVER include in the main watch list rules that were originally 🟡 or 🔴 — those go to an "Observations" section with no regression weight.

Write to `feature-dir/regression-watch.md`. The first execution creates the file; subsequent executions append to the new-item sections, never rewriting history or old IDs.

## Updating progress.jsonl

Each line must contain, at minimum:

```json
{"ts":"2026-05-05T16:30:00Z","action":"T003","status":"done","files":["src/x/y.js"]}
```

Append-only. Never rewrite previous lines, even if you discover they were wrong. To correct, add a new line `status: corrected` with the target ID.

## Post-execution Hooks

Apply `after-coding` in the standard way.

## Final report to the user

1. How many actions were executed successfully
2. How many failed (if any)
3. Absolute paths of `actions.md`, `progress.jsonl`, `legacy-impact.md`, `regression-watch.md`
4. How many watch items were created in this round
5. Explicit notice: to close the cycle, run `/reversa` (reverse extraction) again at some point in the future
6. If the execution was partial, indicate the next pending phase or action

NEVER trigger re-extraction on your own — that is the user's decision.

End with:

> Type **CONTINUE** to proceed with `/reversa` (re-extraction) or another action the user wants.
