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

The execution contract is an immutable, step‑by‑step workflow defined in 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 and visualized in 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. 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 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 (or the master-route.ps1 script), the AI identifies which SKILL.md file governs the current task. If ambiguity exists, the system falls back to routing.md for disambiguation.

5. Initialize the Case Scope

The skills/scripts/case-init.ps1 script (or 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 to determine role assignments, then opens the target SKILL.md file. This step transitions the system from setup to execution.

7. Validate Tool Availability

The system checks 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, 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, routing.md, tool-index.md)

Key Files That Enforce the Contract

File Purpose
RULES.md Master list containing the Canonical Behavior Chain and self‑audit checklist
ARCHITECTURE.md Visual flow diagram illustrating the contract’s execution order
skills/field-journal/precedent-auth.md Legal authorization prerequisite (step 0)
skills/MASTER-ROUTING.md Skill selection router (step 4)
skills/scripts/case-init.ps1 Case scope initialization script (step 5)
ops/role-map.md Role assignment configuration (step 6)
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:


# 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:

$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:

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.
  • Nine discrete steps form the Canonical Behavior Chain, beginning with authorization and ending with mandatory documentation.
  • Authorization via precedent-auth.md is always the first operation; no tool execution may precede it.
  • Tool validation occurs automatically through 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), 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 under the section titled Canonical Behavior Chain. Supplementary visualization appears in 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. 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, reading 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.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →