AgentSkillsCN

Deploy

部署

SKILL.md

Skill: Deploy

Description

Promotes test to main via a pull request. Creates the PR, runs tests, and merges if they pass. One approval, no extra prompts.

Trigger

  • Invoked by the /deploy slash command.
  • Requires test branch to exist and be ahead of main.

Process

Phase 1: Preparation

  1. Save current branch — Record it so we can return at the end.
  2. Auto-stash if dirty — If git status --porcelain shows changes, run git stash --include-untracked -m "deploy-auto-stash". Do NOT ask — just stash and continue.
  3. Checkout testgit checkout test.
  4. Push testgit push origin test to ensure remote is up to date.
  5. Verify ahead of maingit log main..test --oneline. If empty, report "Nothing to deploy", restore stash, return to original branch, exit.

Phase 2: Quality Gate

  1. Run testsuv run pytest on the test branch.

    • If any fail: report failures, restore stash, return to original branch. Stop.
    • If all pass: record the count.
  2. Run ruffuv run ruff check foundry_app/. Record result.

Phase 3: Build Release Notes

  1. Identify beans — Parse git log main..test --oneline for BEAN-NNN: messages. Cross-reference with ai/beans/_index.md for titles.

  2. Count branches to clean — List all bean/* branches (local + remote). Count how many are merged into test.

Phase 4: User Approval — ONE prompt

  1. Present summary and ask once:

    code
    ===================================================
    DEPLOY: test → main (via PR)
    ===================================================
    
    Beans: <list>
    Tests: N passed, 0 failed
    Ruff: clean / N violations
    
    Post-merge: N feature branches will be deleted
    
    On "go": create PR, merge it, delete branches,
    restore working tree. No further prompts.
    ===================================================
    
  2. Single approval with options: go / go with tag / abort.

    CRITICAL: This is the ONLY user prompt. Everything after "go" runs without stopping.

Phase 5: Execute (no further prompts)

  1. Create PR:

    bash
    gh pr create --base main --head test \
      --title "Deploy: <date> — <bean list summary>" \
      --body "<release notes>"
    
  2. Merge PR:

    bash
    gh pr merge <pr-number> --merge --subject "Deploy: <date> — <bean list>"
    

    Use --merge (not squash/rebase) to preserve history.

  3. Tag (optional) — If requested: git tag <version> && git push origin --tags.

  4. Delete local feature branches — All bean/* branches merged into main: git branch -d. Stale/orphaned ones for Done beans: git branch -D.

  5. Delete remote feature branches — Any remotes/origin/bean/*: git push origin --delete.

  6. Sync local maingit checkout main && git pull origin main.

  7. Restore stash — If we auto-stashed: git stash pop. On conflict, prefer HEAD for files that came from test.

  8. Report success — PR URL, merge commit, beans deployed, branches deleted.

Key Rules

  • One approval gate. User says "go" once. Everything after is automatic.
  • Auto-stash, auto-restore. Dirty working tree handled silently.
  • PR is created AND merged. Not just created — the full cycle completes.
  • Branch cleanup included. No separate step needed.
  • If a command is blocked by sandbox: print the exact command for the user to run manually, then continue with the rest.

Error Conditions

ErrorResolution
Nothing to deployReport and exit
Tests failReport failures, restore stash, return. Fix first.
PR create failsReport error. Check gh auth status.
PR merge failsReport error. Check branch protection / conflicts.
User abortsRestore stash, return to original branch
Command blockedPrint command for manual execution, continue