Api

From stackhawk/agent-skills · View interactive version

Api is an AI agent skill from the GitHub repository stackhawk/agent-skills. Use this skill when a user or agent needs to query the StackHawk platform for security reporting, findings analysis, or app management. Triggers include: "stackhawk api", "security posture", "findings report", "show me findings", "untriaged findings", "which apps", "scan history", "security dashboar

How to use this skill

Skill file

StackHawk API Skill

This skill enables Claude to act as a security reporting agent against the StackHawk

platform. The core workflow is:

Question → Authenticate → Query API via hawk op → Present Results → Suggest Next Actions

All platform queries run through the hawk binary's op subtree

(hawk op …). It authenticates, refreshes tokens, follows pagination, and

emits stable JSON. There is no raw-REST fallback — if hawk is unavailable,

install it and run hawk init --browser rather than hand-rolling curl.

See CODE0.


Step 1: Assess Context

Before making any calls, check what's available:

  1. Is hawk installed and configured? (hawk version reports v6.0.0 or greater)

```bash

# Identify the driving skill for CLI usage telemetry (read by hawk/hawkop).

export _STACKHAWK_SKILL=api

command -v hawk >/dev/null && hawk op status

```

has no hawk op init — hawk init writes ~/.hawk/hawk.properties, which

hawk op reads along with the HAWK_API_KEY env var).

docs.stackhawk.com) and stop; do not fall back to curl.

  1. Is hawk op authenticated? For interactive local use, hawk init --browser stores

credentials in ~/.hawk/hawk.properties — no env var needed for interactive

sessions. Verify:

```bash

hawk op status

```

> Any non-interactive session (CI, containers, headless agents): set HAWK_API_KEY.

> hawk op reads it directly — no config file, no browser.

  1. Is orgId known? Required for most endpoints.
  1. Route based on user intent:

| User says... | Go to... |

|---|---|

| "What's my security posture?" or "dashboard" | Step 3 (org summary) |

| "Tell me about [app]'s findings" or "what needs attention" | Step 4 (app deep dive) |

| "What apps haven't been scanned recently?" | Step 3 with stale-app focus |

| "What changed since last week?" or "what's new" | Step 4 with diff recipe |

| "Show me untriaged findings" | Step 3, then drill into Step 4 for flagged apps |


Step 2: Authenticate

hawk init --browser once for interactive setup — the CLI stores credentials in

~/.hawk/hawk.properties and hawk op handles token refresh and 401 retry on

every call. No further auth work for this skill.

→ Full setup commands (install, CI env var, profiles for org switching):

CODE0.


Step 3: Org Posture Summary

Goal: Give the user a bird's-eye view of security health across all apps and environments.

Approach

Use hawk op app list and hawk op scan list to assemble an org-level view.

hawk op app list --format json returns app metadata; hawk op scan list --format json

returns per-scan severity counts. Join on applicationId to build a posture table.

# All apps with metadata (team, type, env count)
hawk op app list --format json

# Recent scans across the org — has per-scan severity counts
hawk op scan list --limit 500 --format json

Fields available per scan: highAlertCount, mediumAlertCount, lowAlertCount,

applicationId, environmentName, startedTimestamp, status.

Present as a table

Format the response as:

| App | Environment | High | Medium | Low | Last Scan |

|-----|-------------|------|--------|-----|-----------|

| My API | Production | 3 | 7 | 12 | 2024-01-15 |

| Auth Service | Staging | 0 | 2 | 4 | 2024-01-10 |

Resolve applicationId → app name via hawk op app list --format json.

Flag priority items

After presenting the table

Offer to drill down on any flagged app:

Full recipe with jq transforms:

→ CODE0


Step 4: App Deep Dive

Goal: Get specific finding details for a single app — what was found, where, and what it means.

`hawk op scan get` (one command covers ~90% of cases)

hawk op scan get walks the scan → alerts → findings chain internally. No manual drill-down, no ID extraction, no token handling.

# Latest scan for an app — overview + alerts table
hawk op scan get --app "<APP_NAME>"

# Full findings with HTTP evidence + remediation (best for AI agent reasoning)
hawk op scan get --app "<APP_NAME>" --detail full --format json

--detail full returns every alert, every affected URI, HTTP messages (subject to

--max-body-size), and remediation guidance in one JSON blob. It fetches per-plugin detail for

at most 10 plugins per call (the CLI prints "Fetching 10 plugin details"); for a

scan with more alert types, drill the rest with --plugin-id, or read the scanner's own

hawk scan --json-output file, which is the complete list.

→ Specific scan IDs, single-alert / single-URI drill-down, --max-findings tuning:

CODE0 §2.

Present findings

Show a structured summary:

Link to the scan on the platform:

https://app.stackhawk.com/scans/{scanId}

"What changed?" — diff recipe

Compare two scans: use hawk op scan list to get the two most recent scan IDs for

the app, pull alerts for each via hawk op scan get, diff the pluginId sets.

→ Executable recipe (hawk op pipeline with comm diff):

CODE0 §2.

→ Full jq recipes: CODE0.


Step 5: Present Results and Suggest Next Actions

Formatting

Next action suggestions

Base suggestions on what the data shows:

| Finding | Suggested action |

|---|---|

| High severity findings present | Recommend immediate remediation; offer to hand finding details to → hawkscan skill for a re-scan to verify fixes |

| Stale apps (no scan > 30 days) | Recommend running a fresh scan → hawkscan skill |

| Clean results across all envs | Note that low path count may mean the spider needs tuning → hawkscan skill, config-patterns reference |

| Untriaged findings (status: NEW) | Direct to platform for triage: app.stackhawk.com — triage write operations are out of scope for this skill |

| ENV_INCOMPLETE app status | Direct to platform to complete environment configuration |

Platform UI vs API data

Use API data (this skill) when:

Direct to platform UI when:


Common Mistakes to Avoid

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.