diff --git a/.claude/skills/publish/SKILL.md b/.claude/skills/publish/SKILL.md index d99b155..c534ea4 100644 --- a/.claude/skills/publish/SKILL.md +++ b/.claude/skills/publish/SKILL.md @@ -1,15 +1,17 @@ --- name: publish -description: Refactor recent changes then ship as a PR with auto-merge. +description: Refactor recent changes, ship as a PR with auto-merge, then monitor CI and auto-fix failures until merged. user-invocable: true -allowed-tools: Read, Edit, Write, Bash, Glob, Grep, Agent +allowed-tools: Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch --- ## Publish Sync, refactor recent changes, sync again, then ship the -current branch as a PR with auto-merge enabled. Be thorough -on refactoring but efficient on shipping. +current branch as a PR with auto-merge enabled. After +shipping, monitor CI checks and proactively fix any failures +until the PR merges. Be thorough on refactoring but efficient +on shipping. **Input:** `$ARGUMENTS` optionally describes what was done (used for the commit message and PR description). @@ -129,11 +131,99 @@ If conflicts, STOP and show files. Otherwise, in parallel: --- +### Phase 3 — Monitor & Validate + +After shipping, monitor the PR until it merges or a hard-stop +condition is reached. Be proactive: if CI fails, diagnose and +fix the issue, then push again. + +This phase adapts to the project: not all repos have CI +checks, deployments, or auto-merge. Detect what applies and +skip what doesn't. + +#### Step 0 — Detect project capabilities + +```text +Run in parallel: +- gh pr checks --json name,state → HAS_CHECKS (non-empty list) +- gh pr view --json autoMergeRequest → HAS_AUTO_MERGE (non-null) + +If no checks and no auto-merge: + Skip monitoring entirely → go to Final Output +If no checks but auto-merge is set: + Wait for merge only (skip Fix step entirely) +``` + +#### Monitor loop + +```text +fix_count = 0 +wait = 30 # seconds +round = 0 + +while round < 10: + round += 1 + sleep seconds + wait = min(wait * 1.5, 120) + + Run in parallel: + - gh pr view --json state,mergeStateStatus,mergeable + - gh pr checks --json name,state,conclusion,detailsUrl + + Evaluate: + + A) PR state == MERGED → go to Validate step + B) All checks passing, merge pending → continue loop + C) One or more checks failed → go to Fix step + D) PR closed (not merged) → STOP: "PR was closed" + E) Merge conflicts → STOP: "Merge conflicts — rebase manually" +``` + +#### Fix step + +```text +if fix_count >= 3: + STOP: "CI still failing after 3 fix attempts. + Failing checks: . Manual intervention required." + +fix_count += 1 + +1. Identify failed check(s) from gh pr checks output +2. For each failed check: + a. Extract run-id from the details URL + b. Get log: gh run view --log-failed + c. Read error output and diagnose root cause +3. Apply fixes to the codebase +4. Stage and commit: + fix: resolve CI failure in +5. Fetch + rebase: + git fetch origin && git rebase origin/ +6. Push: git push --force-with-lease origin HEAD +7. Reset wait = 30 +8. Continue monitor loop +``` + +#### Validate step + +After the PR merges: + +1. Confirm merge: `gh pr view --json state` → assert MERGED +2. Check for deployment workflows: + `gh run list --branch --limit 5 --json name,status,conclusion` +3. If a deployment run is found and in progress, poll every + 30s (max 5 times) until it completes +4. If no deployment runs exist, skip — not all projects deploy + +--- + ### Final Output -Print a short summary (max 5 lines): +Print a summary (max 8 lines): - Refactor: Pass 1 + Pass 2 changes (counts) - Commit: new or amended, with message - PR: URL -- Auto-merge: enabled +- Auto-merge: enabled / not configured +- CI: passed (or fixed N times) / no checks +- Merge: confirmed / pending +- Deploy: status / no deployment detected diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7129da..a5fd625 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install rumdl + run: cargo install rumdl + - name: Lint Markdown + run: rumdl check . - name: "TODO: Add your lint steps" - run: echo "Add linting commands here" + run: echo "Add additional linting commands here" test: name: Test diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34b2e99..9d4017b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,3 +14,12 @@ repos: rev: v8.30.0 hooks: - id: gitleaks + + - repo: local + hooks: + - id: rumdl-check + name: Markdown lint check + entry: rumdl check . + language: system + types: [markdown] + pass_filenames: false diff --git a/.rumdl.toml b/.rumdl.toml new file mode 100644 index 0000000..73251e4 --- /dev/null +++ b/.rumdl.toml @@ -0,0 +1,12 @@ +[global] +# MD041 triggers on files with YAML frontmatter (e.g. Claude skills) +extend-disable = ["MD041"] + +exclude = [ + ".git", + "node_modules", + "vendor", + "dist", + "build", + "CHANGELOG.md", +] diff --git a/README.md b/README.md index 4d11fba..08155e0 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ standardized tooling and GitHub configuration. template" on GitHub, or `gh repo create --template`). 2. **Run the setup script** to configure GitHub settings: + ```bash ./scripts/setup-repo.sh ``` @@ -25,6 +26,7 @@ standardized tooling and GitHub configuration. ## What's Included ### CI/CD + - **GitHub Actions** (`ci.yml`): Minimal CI with placeholder lint/test jobs, conventional commit check, and an `All Checks` gate job. @@ -32,17 +34,22 @@ standardized tooling and GitHub configuration. with automerge and conventional commit messages. ### Git Hooks + - **Conventional commits**: Enforced at commit-msg stage. - **Secret detection**: Gitleaks runs on every commit. +- **Markdown linting**: rumdl checks all `.md` files. ### Claude Code + - **`/refactor`**: 3-pass refactoring (structure, coherence, tests). - **`/ship`**: Commit, sync, push, create PR with auto-merge. - **`/sync`**: Fetch and rebase onto default branch. -- **`/publish`**: Sync, refactor, sync again, then ship as PR. +- **`/publish`**: Sync, refactor, ship as PR, then monitor CI + and auto-fix failures until merged. ### Repository Configuration + - **`scripts/setup-repo.sh`**: Configures GitHub repo via `gh` CLI: - Rebase-only merges