---
name: p0-scope
description: Phase 0 scoping of a smart-contract audit — establish the effective in/out-of-scope surface, the upgrade/trust model, provenance integrity, and run the tool-environment pre-flight that installs what the later phases need. Use when scoping an audit target, starting from a bounty competition link and/or a GitHub repo, or when you need the exhaustive Phase-0 tool checklist. Runs the full applicable p0 surface, not a hand-picked few.
---

# Phase 0 — Scoping

Establish the engagement's ground truth *before* any analysis: the effective scope, the
upgrade/trust model, provenance integrity, and — the pre-flight — that the tools every
*later* phase needs (static analysis, fuzzing, formal) are actually installed.

## Run

1. `set_phase("p0")`.
2. **Tool-environment pre-flight (report → install → re-verify):** `tools_report` +
   `check_external_server_env`, then `bash scripts/install-audit-toolchains.sh` to
   un-degrade the static-analysis / fuzzing / formal toolchains, then `tools_report`
   again. Use each missing tool's `→ install:` hint for anything the script doesn't cover.
3. Establish the engagement source (`engagement_source`), then `scope_recon`,
   `provenance_check`, `target_profile`, and the formal-engagement tools where they apply.
4. Delegate the scope/provenance judgement to the **`scope-analyst`** lead; the `/scope`
   command drives this same flow.

## Completeness

Run **every** p0 tool whose precondition the target meets — see [`checklist.md`](checklist.md)
for the exhaustive list (MCP tools + the external binaries this phase invokes, with install
hints). A tool is left unrun only when genuinely N/A (record why) or its binary is absent
(auto-`skippedReason`). Close the phase by reconciling **run / N/A / skipped**.

Provenance red flags are findings — surface them loudly; in `/audit`, stop and alert the
user. Full playbook: [`../../../docs/phases.md`](../../../docs/phases.md) (p0 section).
