/stackhawk-optimize:optimizefrom stackhawk-optimize
Analyzes a codebase to produce an optimal HawkScan configuration — tech flags, scan-policy plugin selection, and stackhawk.yml corrections — then runs a non-destructive trial scan and promotes or discards the setup. Use when tuning HawkScan, reducing false positives, or picking the right plugins/policy for an app.
Ships in stackhawk-optimize. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Turn a codebase into an optimal HawkScan configuration. The skill detects the real tech
stack and app shape, expresses that as a trial scan policy (tech flags + plugins) plus
local stackhawk.yml corrections, runs one trial scan so the user sees real results, and
then promotes the setup or discards it with no residue.
Org scan policies are stored as hosted assets and downloaded by the scanner at scan time
when app.scanPolicy.name is set (see references/trial-lifecycle.md). Creating a trial
policy and referencing it in stackhawk.yml therefore leaves the application's own policy,
plugins, and tech flags untouched until the user promotes. This is the core safety
property.
# Identify the driving skill for CLI usage telemetry (read by hawk/hawkop).
export _STACKHAWK_SKILL=optimize
hawk version,
hawk config --help, hawk op auth). Additionally confirm the policy write commands
exist: hawk op policy create --help must succeed. If it errors with "unrecognized
subcommand", STOP and tell the user to upgrade hawk.
Also confirm metrics support: hawk op scan metrics --help must succeed. If it errors
with "unrecognized subcommand", the metrics/refine phase is skipped (pre-scan
optimization still works); tell the user to upgrade hawk to enable refinement.ORG_POLICY_MANAGEMENT + WRITE_POLICY
/DELETE_POLICY. If a policy create dry-run reports a permission/feature error,
degrade to recommend-only: print the proposed policy JSON + yml diff and stop.Two modes. Setup configures scan policy + tech flags (no scan) and is what hawkscan
Phase 0c invokes on every fresh stackhawk.yml; it is also re-runnable anytime via /optimize. Refine runs a trial
scan and tunes from per-path metrics; it runs only via /optimize or when a scan is slow.
references/mapping.md.stackhawk.yml corrections. Default to a balanced profile; honor an explicit
speed↔coverage lean if the user gives one. See references/mapping.md.hawk op policy get --name DEFAULT
or the API/GraphQL preset matching the app), edit its tech flags + toggle plugin
families, write the result to a temp JSON file, and create it under a deterministic
name matching ^[A-Z0-9_]+$ (e.g. OPTIMIZE_TRIAL_<APP>_<ENV>, upper-snake, sanitized).
See references/cli-contract.md and references/trial-lifecycle.md.stackhawk.yml, then set
app.scanPolicy: { name: OPTIMIZE_TRIAL_… } plus app-type/OpenAPI/auth corrections.
Show the diff; never clobber unrelated keys. Setup ends here — the named policy is
referenced in stackhawk.yml (the scanner downloads it by name); promotion to the app
default is a Refine concern, not required here.hawk scan. The scanner downloads the policy and applies
its tech flags + plugins. Capture the trial scan id, findings, and duration.hawk op scan metrics <SCAN_ID> --format json and parse
the per-path/operation metrics, signal flags, and request health. See
references/metrics-and-refine.md. If no metrics are available, skip to step 8.rate-limited / timeout-prone
(hawk.scan.concurrentRequests — halve from its current yml value, default 20, floor 1);app.excludePaths for
heavy-path/slow-path; app.authentication.* for auth-wall) with the exact yml
diff, applying only approved changes.
If any change was applied, re-scan and return to step 6 with the new scan id.
STOP when no new high-severity flags remain, after 3 refine iterations, or when the
user declines further refinement. All edits go to the trial stackhawk.yml (backed up).
See references/metrics-and-refine.md for the full mapping + loop control.excludePaths/concurrentRequests), then ask:
promote or discard.references/trial-lifecycle.md. Promote: re-create the
policy under a permanent name, point stackhawk.yml at it (keeping the refined
scope/concurrency yml edits), delete the trial policy, leave the yml change for the user
to commit. Discard: hawk op policy delete the trial policy and restore the
stackhawk.yml backup.--dry-run a policy create/delete first when validating preflight.stackhawk.yml backup before reporting the error.OPTIMIZE_TRIAL_… before creating a fresh one).concurrentRequests, excludePaths) go to the trial stackhawk.yml only;
discard reverts them with the backup. Never auto-apply path exclusions or auth changes —
those require explicit confirmation.hawk.scan.concurrentRequests at 1 (never 0).hawkscan — runs the actual scan loop and owns the onboarding flow + the fallback
tech-flag detection heuristics (references/tech-flags.md), used only when this skill
can't create a scan policy.api — read-only platform lookups via hawk op (app/env/policy listing).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
hawkscan, scan-optimization, stackhawk, security-scanning, policy-tuning
npx claudepluginhub stackhawk/agent-skills --plugin stackhawk-optimize2 plugins ship this exact skill · first indexed Sep 16, 2026
Other plugins' skills for the same job