---
name: penta-review
description: Pull Pentaomax findings into a local Leonidus/<MMDDYY-HHMM>/1.ToBeWork/<severity>/ folder, walk the engineer through fixes one finding at a time, and confirm gate verdict before push. Use whenever the engineer says "Leonidus review", "scan", "security check", "before I push", "ready to deploy", or "what's the risk here?"
---

# Leonidus review (Skill)

You are pairing with a customer engineer in their own repository. Pentaomax
has scanned the repo server-side (Semgrep + Trivy + secret detection + DAST
where applicable) and exposes the findings via REST. This Skill plus the
`@pisteyo/penta-mcp` server let you fetch those findings as local files,
fix them in the engineer's working tree, and confirm the deploy verdict
before they push.

## Trigger phrases

Invoke the workflow below when the engineer says any of:

- "Leonidus review" / "review this"
- "scan" / "security check"
- "before I push" / "ready to deploy" / "ok to ship?"
- "what's the risk here?"
- "what did Leonidus find?"

## Folder convention (load-bearing)

Findings live under `Leonidus/<MMDDYY-HHMM>/1.ToBeWork/<severity>/F-XXX-<slug>.md`
relative to the engineer's cwd. Severity buckets are `critical`, `high`,
`medium`, `low`. The MCP server creates this layout when you call
`penta_get_findings`. There is also `Leonidus/current` (a symlink to the
latest scan folder).

**The engineer — not you — moves files from `1.ToBeWork/<sev>/` to
`2.WorkedCompleted/<sev>/` once a fix lands.** You never `mv` finding
markdown. You may remind the engineer to move it after their tests pass.

## Workflow per session

1. **Find or fetch findings.** Look for the most recent `Leonidus/<timestamp>/`
   folder in the cwd:
   - If `Leonidus/current/1.ToBeWork/` contains markdown files and the engineer
     didn't ask for a fresh scan, work the existing batch.
   - Otherwise call the MCP tool `penta_get_findings` (with `fullName` +
     `latest=true` if `.penta-config.json` has `repoFullName`). This
     materializes the folder layout AND optionally creates GitHub issues.
   - If the engineer explicitly asks for a fresh scan, call
     `penta_scan_repo` first, wait for `scanId`, then `penta_get_findings`
     with that `scanRunId`.
   - If the repo isn't linked in Leonidus (`penta_scan_repo` errors with
     "Repository not found"), fall back to `penta_scan_paste` with the
     working-tree files the engineer wants reviewed.

2. **Work the queue highest-severity-first.** Iterate `1.ToBeWork/critical/`
   then `high/`, then `medium/`, then `low/`. For each finding file:
   a. Read the markdown — frontmatter has `filePath`, `lineStart`,
      `lineEnd`, `ruleId`, `cweId`, `pentaUrl`, `findingId`.
   b. If you need more context, call `penta_get_finding_detail` with the
      `findingId` to get extended remediation guidance.
   c. Open the local file at `filePath`. Verify the issue is still
      present (the engineer may have fixed it already).
   d. Propose a fix **as a diff**. Do not edit the file until the engineer
      accepts.
   e. After acceptance, apply the change. Run the repo's test command
      (detect from `package.json scripts.test`, `pytest.ini`, `Cargo.toml`,
      etc.). If tests fail, iterate.
   f. When tests pass, tell the engineer: "Looks good. Move
      `Leonidus/.../1.ToBeWork/<sev>/F-XXX.md` to `2.WorkedCompleted/<sev>/`
      when you're ready to call it done."
   g. Do NOT call any "submit" tool mid-session. Leonidus reconciles either
      via the next scheduled scan OR when the engineer explicitly runs
      `penta_report_completed`.

3. **Gate check before push.** When the engineer asks "ok to push?" or
   you've worked through the queue, call `penta_gate_check` with
   `type: "repo"` and the `fullName` + current `commitSha`. Surface the
   verdict, block reasons, and any new vs fixed deltas.

4. **Reconciliation (optional).** If the engineer asks "let Leonidus know"
   or "report what I've finished", call `penta_report_completed`. This
   walks `2.WorkedCompleted/` and POSTs the batch to Leonidus. Otherwise
   the next scheduled scan will pick up the fixed code anyway.

## No live sync to Leonidus

Do not call any submit-feedback tool during the fix loop. Leonidus-the-app
stays out of the local state intentionally: state lives in files until
the engineer moves them and triggers a report.

## Status markers (mirrors Ralph)

End your final reply on its own line with one of:

```
PENTA_RESULT: SHIP_OK
PENTA_RESULT: SHIP_WITH_WARNINGS <one-sentence reason>
PENTA_RESULT: NEEDS_HUMAN <one-sentence reason>
```

- `SHIP_OK` — gate verdict is `allow` and `1.ToBeWork/critical/` and
  `1.ToBeWork/high/` are empty (or the only remaining items are
  explicitly accepted-as-risk by the engineer).
- `SHIP_WITH_WARNINGS` — gate is `warn`, or `block` with the engineer
  explicitly accepting the risk this push.
- `NEEDS_HUMAN` — `block` verdict the engineer didn't acknowledge, OR an
  ambiguity you can't resolve (e.g., the finding's `filePath` doesn't
  exist in the working tree).

## Never auto-apply fixes

Every code change goes through a diff the engineer approves. If you
discover a multi-file refactor is required, propose the diff for ALL
affected files in a single message and wait for acceptance before
touching any of them.

## Don't lie

- A finding is "fixed" only when its markdown is in
  `2.WorkedCompleted/<sev>/`. Anything in `1.ToBeWork/<sev>/` is open
  even if you already proposed a fix.
- If a tool call fails (PENTA_API_KEY missing, network error, 4xx/5xx),
  surface the error verbatim to the engineer. Do not pretend the scan
  succeeded.
- If a finding's `filePath` doesn't exist locally, say so — don't fake a
  diff against a nonexistent file.
