# What Is the Execution Contract in reverse‑skill? The 9‑Step Canonical Workflow

> Discover the execution contract in reverse-skill. Learn the 9-step canonical workflow AI agents must follow for security and reverse-engineering tasks in this framework.

- Repository: [ZhaoXu/reverse-skill](https://github.com/zhaoxuya520/reverse-skill)
- Tags: deep-dive
- Published: 2026-08-01

---

**The execution contract is an immutable, step‑by‑step workflow defined in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) that every AI agent must follow before performing any security or reverse‑engineering task in the reverse‑skill framework.**

The **execution contract in reverse‑skill** serves as the single source of truth for AI behavior within the zhaoxuya520/reverse‑skill repository. This mandatory protocol ensures that all reverse‑engineering operations begin with proper authorization, follow standardized routing procedures, and conclude with documented evidence. Defined primarily in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) and visualized in [`ARCHITECTURE.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ARCHITECTURE.md), the contract transforms ad‑hoc analysis into a reproducible, legally compliant workflow.

## The 9‑Step Canonical Behavior Chain

The contract enumerates nine mandatory phases that constitute the **Canonical Behavior Chain**. If any step is omitted, the AI must halt execution and invoke corrective measures such as re‑reading missing files, bootstrapping tools, or requesting user clarification.

### 1. Establish Authorization

Before any file system interaction, the AI must read [`skills/field-journal/precedent-auth.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/field-journal/precedent-auth.md). This document provides the legal **authorization status** that gates all subsequent operations.

### 2. Detect the Package Root

The system computes the absolute repository path (`<SKILL_ROOT>`) by locating [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) and deriving its parent directory. This ensures all relative paths resolve correctly regardless of where the script is invoked.

### 3. Write Global Routing Rules

On first execution, the AI injects routing rules into the client’s global configuration file (e.g., `~/.claude/CLAUDE.md`). This permanent injection ensures the reverse‑skill framework remains available across sessions.

### 4. Select the Primary Skill

Using [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md) (or the `master-route.ps1` script), the AI identifies which [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file governs the current task. If ambiguity exists, the system falls back to [`routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.md) for disambiguation.

### 5. Initialize the Case Scope

The `skills/scripts/case-init.ps1` script (or [`ops/scope-contract.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ops/scope-contract.md) when scripts are unavailable) sets critical runtime variables, including `auth.status=granted` and the `network_profile` definition.

### 6. Assign Roles and Open the Skill

The AI consults [`ops/role-map.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ops/role-map.md) to determine role assignments, then opens the target [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file. This step transitions the system from setup to execution.

### 7. Validate Tool Availability

The system checks [`skills/tool-index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/tool-index.md) for required binaries. If a tool is marked missing, the platform‑specific bootstrap script (e.g., `skills/scripts/bootstrap-reverse.ps1`) executes automatically to install dependencies.

### 8. Execute the Skill Workflow

The AI follows the timeline and work items defined in the active [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md), applying the **evidence→finding→path** logic defined in the `ops/` directory. This structured approach ensures findings are traceable to specific evidence artifacts.

### 9. Generate Mandatory Outputs

Upon completion, the AI must produce four distinct artifacts:
- A formal report generated via the `docs-generator` skill
- At least one diagram created by the `diagram-generator` skill
- An anonymized entry written to the `field-journal`
- Updated system indexes ([`_index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/_index.md), [`routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.md), [`tool-index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/tool-index.md))

## Key Files That Enforce the Contract

| File | Purpose |
|------|---------|
| [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) | Master list containing the Canonical Behavior Chain and self‑audit checklist |
| [`ARCHITECTURE.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ARCHITECTURE.md) | Visual flow diagram illustrating the contract’s execution order |
| [`skills/field-journal/precedent-auth.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/field-journal/precedent-auth.md) | Legal authorization prerequisite (step 0) |
| [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md) | Skill selection router (step 4) |
| `skills/scripts/case-init.ps1` | Case scope initialization script (step 5) |
| [`ops/role-map.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ops/role-map.md) | Role assignment configuration (step 6) |
| [`skills/tool-index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/tool-index.md) | Tool availability registry (step 7) |
| `skills/scripts/bootstrap-reverse.ps1` | Automatic tool installer triggered when index misses entries |

## PowerShell Implementation Examples

The following snippets demonstrate how the contract translates into executable logic:

Detecting the package root and setting the environment variable:

```powershell

# Derive SKILL_ROOT from RULES.md location

$SKILL_ROOT = (Split-Path -Parent (Get-Item "$PSScriptRoot\RULES.md")).FullName

```

Injecting global routing rules on first run:

```powershell
$globalConfig = "$HOME\.claude\CLAUDE.md"
if (-not (Select-String -Path $globalConfig -Pattern 'reverse skill routing')) {
    Add-Content -Path $globalConfig -Value @"

# Reverse skill routing (auto‑injected)

include: $SKILL_ROOT/RULES.md
"@
}

```

Validating and bootstrapping missing tools:

```powershell
if ((Get-Content "$SKILL_ROOT/skills/tool-index.md") -notmatch 'jadx\s+yes') {
    & "$SKILL_ROOT/skills/scripts/bootstrap-reverse.ps1" -Capability @('jadx') -StartServices
    & "$SKILL_ROOT/skills/scripts/refresh-tool-index.ps1"
}

```

## Summary

- The **execution contract in reverse‑skill** is an immutable behavioral protocol defined in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md).
- Nine discrete steps form the **Canonical Behavior Chain**, beginning with authorization and ending with mandatory documentation.
- **Authorization** via [`precedent-auth.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/precedent-auth.md) is always the first operation; no tool execution may precede it.
- **Tool validation** occurs automatically through [`tool-index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/tool-index.md), with missing dependencies resolved via `bootstrap-reverse.ps1`.
- **Output generation** is contractual, requiring reports, diagrams, journal entries, and index updates for every completed task.

## Frequently Asked Questions

### What happens if an AI agent skips a step in the execution contract?

The contract is considered **broken**, and the AI must immediately revert to corrective action. Depending on the violation, this includes re‑reading missing files (e.g., [`precedent-auth.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/precedent-auth.md)), invoking `bootstrap-reverse.ps1` to install missing tools, or halting execution to ask the user for clarification.

### Where is the execution contract formally documented?

The canonical definition lives in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) under the section titled **Canonical Behavior Chain**. Supplementary visualization appears in [`ARCHITECTURE.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ARCHITECTURE.md), which diagrams the flow from authorization through output generation.

### How does the contract handle missing reverse‑engineering tools?

During step 7, the AI reads [`skills/tool-index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/tool-index.md). If a required tool (e.g., `jadx`) is not listed as available, the system automatically executes `skills/scripts/bootstrap-reverse.ps1` with the appropriate capability flags, then runs `refresh-tool-index.ps1` to update the registry.

### Is the authorization step optional for local or test environments?

No. According to the source code in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md), reading [`skills/field-journal/precedent-auth.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/field-journal/precedent-auth.md) is marked as step 0 with the annotation **(MUST be first)**. This applies universally; the contract does not distinguish between production and test contexts regarding legal authorization.