/spwf:pr-createfrom spwf
Phase 7 — PR / MR Create. Run pre-PR checks then create a pull request (GitHub) or merge request (GitLab) via the active forge's CLI. CI/CD owns deployment after merge. The request is the deliverable. Halts if any pre-flight check fails. Security checks (secret scan, SAST, dependency audit) run if tools are available; high/critical findings halt creation.
Ships in spwf. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Run the pre-flight checklist. If all checks pass, create the pull request (GitHub) or merge request (GitLab). Report the URL.
Forge selection follows _shared/forge-dispatch.md — auto-detected from
git remote get-url origin unless overridden in .spwf/forge.yaml. GitLab
default; GitHub supported.
Run each check in order. If any blocking check fails, stop and report — do not proceed to PR creation.
# Resolve the base branch (.spwf/branch.yaml: base, else main)
BASE=$(sed -n 's/^base:[[:space:]]*//p' .spwf/branch.yaml 2>/dev/null); BASE=${BASE:-main}
# Check 1: Not on base
BRANCH=$(git branch --show-current)
echo "Branch: $BRANCH (base: $BASE)"
# Check 2: Commits exist ahead of base
git log "${BASE}...HEAD" --oneline
# Check 3: No uncommitted changes
git status --short
Check 1 — Not on main (with rescue offer):
If branch is the base (main / master, or .spwf/branch.yaml: base), do not
halt with a bare error. Detect whether this is the rescuable failure state and,
if so, offer to fix it automatically. Performs the operation in
_shared/branch-management.md §4
directly — the same section branch-rescue follows.
Detect:
CHANGE_ID=$(openspec list --json 2>/dev/null | jq -r '.[0].name')git log origin/{base}..HEAD --oneline non-emptyIf an active change exists and there are commits ahead, present the rescue plan inline with the exact commands, then ask:
You're on `{base}` with {N} commit(s) for active change `{change-id}`.
I can rescue this — local-only, nothing pushed:
1. git checkout -b feature/{change-id} # preserve your work
2. git checkout {base} && git reset --hard {base-commit} # reset local base
3. (verify {base} == origin/{base})
After rescue, local `{base}` is diverged from origin only if commits were
pushed; publish manually when ready:
git push --force-with-lease origin {base}
Proceed with rescue? [Y/n]
On Y / enter: perform the three local-only operations yourself, exactly as
_shared/branch-management.md §4 "Rescue operation"
specifies. Do not invoke spwf:branch-rescue through the Skill tool: it is
user-only (disable-model-invocation: true), so the call is blocked. Both skills
follow the same shared section, so the result is identical. Then continue into Step 1b (security pre-flight) on the
newly-created feature/{change-id} branch.
On n: halt with the legacy message so manual handling is not surprised by silent skipping:
✗ Cannot ship from main branch.
Create a feature branch first: git checkout -b {branch-name}
If no active change is found, fall back to the legacy halt above (nothing to rescue automatically).
Check 2 — Commits exist: If no commits found ahead of base, halt:
✗ No commits to ship.
Implement a task first: /spwf:build
Check 3 — No uncommitted changes: If uncommitted changes exist, warn (not halt):
⚠ Uncommitted changes present. These will not be included in the PR.
Run security checks against the diff about to be shipped. Each check is conditional on the tool being installed. If none of the tools are available, warn once and continue — do not halt.
# Secret scan — halt on any finding
if command -v gitleaks >/dev/null 2>&1; then
gitleaks detect --source . --no-banner
fi
# SAST — halt on high or critical severity
if command -v semgrep >/dev/null 2>&1; then
semgrep --config=auto --severity=ERROR --quiet .
fi
# Dependency audit — prefer dep-audit skill for full ecosystem + Docker coverage;
# fall back to inline host-only checks when tools are not in containers.
DEP_AUDIT_SH="$(find ~/.claude -name 'dep-audit.sh' -path '*/dep-audit/scripts/*' 2>/dev/null | head -1 || true)"
if [ -n "$DEP_AUDIT_SH" ]; then
bash "$DEP_AUDIT_SH" 2>&1
else
# Host-only fallback (no Docker awareness)
if [ -f package.json ] && command -v npm >/dev/null 2>&1; then
npm audit --audit-level=high --json | \
jq -e '.metadata.vulnerabilities | (.high + .critical) > 0' && \
echo "npm audit: high/critical vulnerabilities found" || true
fi
if { [ -f requirements.txt ] || [ -f pyproject.toml ]; } && command -v pip-audit >/dev/null 2>&1; then
pip-audit --severity high
fi
if [ -f Cargo.toml ] && command -v cargo-audit >/dev/null 2>&1; then
cargo audit --deny warnings
fi
if [ -f composer.json ] && command -v composer >/dev/null 2>&1; then
composer audit 2>/dev/null || true
fi
fi
Secret scan finding (gitleaks): Any detected secret is a hard halt:
✗ Secret detected in diff. Remove before shipping.
{gitleaks output}
SAST finding (semgrep ERROR severity): Halt with findings listed, and recommend deep review:
✗ SAST: {N} high/critical finding(s). Review before shipping.
{semgrep output}
For a thorough security review before merge, run:
/trailofbits:semgrep
(curated rulesets: Trail of Bits + 0xdea + Decurity; SARIF output; Important-only filtering)
Dependency audit — high/critical vulnerability: Halt with findings:
✗ Dependency: {N} high/critical vulnerability/vulnerabilities found.
Run /spwf:dep-audit for full details and fix commands (Docker-aware).
No tools installed — actionable setup recommendations:
Do not silently skip. Report each missing tool with its setup path:
⚠ Security pre-flight: tools not configured. Recommendations:
── Secret scanning (gitleaks) ──────────────────────────────────
gitleaks is not installed. Recommended setup:
1. Install: brew install gitleaks
2. Pre-commit hook (catches secrets before commit):
echo 'gitleaks protect --staged' >> .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
3. CI workflow (catches anything that slips through):
# GitHub Actions — .github/workflows/security.yml
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GitLab CI — .gitlab-ci.yml
gitleaks:
stage: test
image: zricethezav/gitleaks:latest
script: gitleaks detect --source . --no-banner
── SAST (semgrep) ──────────────────────────────────────────────
semgrep is not installed. For production-grade SAST with curated
Trail of Bits rulesets, use the vetted skill instead of raw semgrep:
/trailofbits:semgrep
(parallel scanning, SARIF output, --metrics=off enforced, Important-only filtering)
── Dependency audit ────────────────────────────────────────────
For comprehensive multi-ecosystem coverage (npm, composer, pip, cargo, go, ruby)
with Docker Compose awareness, use the dedicated skill:
/spwf:dep-audit
Install individual tools: pip install pip-audit | cargo install cargo-audit
brew install trivy (image scanning)
Read these files to derive the PR title and body:
openspec/changes/*/proposal.md — for the change descriptiongit log "${BASE}...HEAD" --oneline — for commit summary (BASE resolved in Step 1)Detect the active forge per _shared/forge-dispatch.md. Run {cli} auth status
first.
Fail fast on missing CLI. If the required CLI (glab for GitLab, gh for
GitHub) is missing or unauthenticated, halt with:
"Forge CLI
{cli}not installed or not authenticated. Install (brew install {cli}) and run{cli} auth login. Seeplugins/spwf/skills/_shared/forge-dispatch.md."
Compose the title and body, then dispatch:
TITLE="{verb-led title from proposal or commits}"
BODY=$(cat <<'EOF'
## Summary
{bullet points from proposal What Changes section}
## Test plan
- [ ] All tests passing
- [ ] Code simplified
- [ ] No regressions
## OpenSpec change
`{change-id}`
EOF
)
# GitLab (default) — note: --description, not --body; --target-branch, not --base
glab mr create --title "$TITLE" --description "$BODY"
# GitHub
gh pr create --title "$TITLE" --body "$BODY"
Use the active forge's vocabulary. GitHub: "PR created". GitLab: "MR created".
Always end with the Next step block pointing at /spwf:close. This is the
handoff that keeps the golden path from ending at "merge and close the ticket"
— the retrospective lives inside close, and an agent that stops here skips it.
✓ {PR | MR} created: {URL}
CI/CD will handle deployment after merge.
── Next step ───────────────────────────────────────────────────
After this {PR | MR} merges, run /spwf:close to finish the change:
• runs the retrospective (learn-from-mistakes, spec audit, doc-lint,
workflow-lint, recap)
• archives the OpenSpec change
• transitions the linked tracker ticket to its done state
• deletes the local feature branch (with safety checks)
"Merge and close the ticket" is NOT complete until /spwf:close runs —
the retrospective is part of close, not an optional extra.
Do not invoke /spwf:close automatically. pr-create points forward only.
Close is a human-gated, destructive final phase (archives the change,
transitions the ticket, deletes the branch) and must not fire as a side effect
of opening a request — pr-create does not even merge.
npm audit exits 1 on any finding. The pre-flight uses --audit-level=high to suppress low/moderate noise — don't remove that flag or every PR with transitive dependencies will halt..gitleaksignore or [allowlist] in .gitleaks.toml for known fixture paths rather than removing the scan.semgrep --config=auto is slow on large repos. On repos with >10k files the auto ruleset can take 3+ minutes. If that's causing timeouts, scope it: semgrep --config=auto --include="*.py" . or pin to a specific ruleset. The /trailofbits:semgrep skill handles this better than raw semgrep.Do not wait for CI, do not describe deployment steps, do not merge.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub simon-potter/spwf --plugin spwf38 skills in this plugin
/address-reviewPhase 6.5 — Address Review. Turn review feedback into action. Sources feedback from either a local report file (e.g. {branch}-review.md from /spwf:pr-review or {branch}-self-review.md from /spwf:simplify) or fetched human comments on an open PR/MR. For each item runs READ → VERIFY → EVALUATE → implement-or-push-back, in priority order (blocking → important → nit). Forbids performative agreement ("you're absolutely right"). Use after pr-review, or whenever a reviewer leaves comments./agent-optimiseCross-cutting — Audit both the project .claude/ and personal ~/.claude/ for quality issues. Covers CLAUDE.md scope and length, agent descriptions, skill frontmatter, and settings.json conflicts. Always audits both scopes. Produces a prioritised P1/P2/P3 fix list./approve-planPhase 2 — Approve plan. Reviews the task list from spec for quality (atomicity, testability, clarity), then applies four adversarial lenses (Skeptic, Architect, Minimalist, Security) as advisory input for the human reviewer. Quality issues are blocking; adversarial findings are advisory. Security lens identifies tasks touching auth, billing, user input, or secrets so the builder has explicit awareness before writing those tasks. Presents everything for explicit human go/no-go before building starts./branch-rescueRecovery skill — moves commits that landed on the base branch onto a proper feature branch and resets local base, without touching origin. Resolves the active OpenSpec change, detects the pre-spec base commit (subject-line grep with manual-confirm fallback), performs three local-only safe git operations, and surfaces the force-push command for the user to run manually. Run standalone; pr-create's rescue offer runs the same procedure inline (_shared/branch-management.md §4), because this skill is user-only./briefPhase 1.5 — Explain a planned change before it is built. Runs between spec and approve-plan, so a mismatch costs a conversation rather than a change. Five sections, expanding then summarising — what will be built, why this way, the choices you didn't make, what it touches, and a short summary. Never blocks: it prints, offers one skippable prompt, and returns. Calibrated via .spwf/learner.md. Companion to recap and understand, which teach after the fact; this teaches before. Runs on changes, not bug fixes./buildPhase 3 orchestrator — Full Red-Green-Refactor cycle. For each pending task: invokes write-tests (Red: write failing tests), then opsx:apply (Green: implement via OpenSpec), then run-tests (Verify: confirm green before moving on). Loops until all tasks complete. After all tasks complete, runs opsx:verify (spec sign-off), then recommends simplify (Refactor).