C1: Wire MergeGuard into maybeMergePullRequest (processor.ts)
C2: Wire MetricsCollector.recordMergeAttempt into merge path
C3: Wire isAlreadyMergedError from github/errors.ts (shared)
C4: Fix sort comparator NaN in markReviewCheckApproved
C5: Guard conflict resolution behind !disposition.requiresAdminApproval
C6: Extract isNotFoundError + isAlreadyMergedError to github/errors.ts
Remove 3 duplicated local copies (chat/processor, webhook/processor, processor.ts)
R1: Create shared github/errors.ts for production code
Docs: audit-v2-final.md, critical-review-v2.md, report-v2.html, workflow_status.md
Skill: .claude/skills/ghbot-workflow/SKILL.md
name: ghbot-workflow description: Full workflow guide for ghbot: development cycle, adding endpoints, review checks, audits, and releases. metadata: last_verified: "2026-08-24" repo_baseline: "v1.2.0"
ghbot workflow skill
When to use
This skill covers the operational workflow for the ghbot GitHub review bot project. Use it when asked about development workflow, adding features, running audits, or releasing.
Do not use
- For unrelated SaaS features
- For changing AUTO_MERGE default value
- For reusing old review cache as a new-head approval
- For running paid LLM E2E without budget
- For pushing to remotes without write permission
1. Full Workflow: test → typecheck → lint → build → e2e → release
Local development loop
# 1. Test (fastest first)
npm test # node --import tsx --test test/**/*.test.ts
# 2. Type check
npm run typecheck # tsc --noEmit
# 3. Lint
npm run lint # eslint src test
npm run lint:fix # auto-fix lint issues
# 4. Format check
npm run format:check # prettier --check
# 5. Build
npm run build # tsc -p tsconfig.json, output to dist/
# 6. Build + test (CI equivalent)
npm run ci:test # node --import tsx --experimental-test-coverage --test test/**/*.test.ts
CI gate (.github/workflows/ci.yml)
The CI workflow runs on every push/PR to main:
npm ci— clean installnpm run typecheck— strict type checknpm run lint— ESLintnpm run format:check— Prettier style checknode --import tsx --experimental-test-coverage --test test/**/*.test.ts— full test + coverage
Pre-commit hooks
The repo uses scripts/husky-pre-commit.cjs via scripts/install-husky.cjs. Run node scripts/install-husky.cjs to set up.
E2E smoke test
E2E tests require real LLM (goose) and GitHub API access. Run locally only with explicit budget:
# Requires GOOSE_API_KEY set in .env
# Run the webhook server locally, then send test events
npm run dev:webhook # tsx src/webhook/server.ts
Release checklist
See section 5 below.
2. How to Add a New API Endpoint
ghbot has two entry points: GitHub Actions events and the optional webhook HTTP server.
Adding a new Actions event handler
-
Define the event type — Add a new type in
src/actions/router.ts(e.g.,type NewPayload = { ... }). -
Register a handler — In
buildDefaultEventRouter()insidesrc/actions/router.ts, add a new.register()call:
router.register({
name: "my-new-event",
canHandle: (eventName, action) => eventName === "my_event",
handle: async (ctx) => {
// Implement your logic
}
});
-
Wire the payload — In
src/actions/runReview.ts, add the new event name tobuildPayloadFromWorkflowCallEnv(). -
Extend the reusable workflow — In
.github/workflows/review-reusable.yml, add new inputs if needed. -
Add tests — Create
test/my-new-event.test.tswith AAA tests.
Adding a new webhook HTTP endpoint
- Add route — In
src/webhook/server.ts,createWebhookServer(), add a new conditional branch:
if (request.method === "POST" && pathname === "/my-endpoint") {
// validate, parse, handle
writeJson(response, 200, { ok: true });
return;
}
-
Add handler — Extend
WebhookDeliveryHandleror create a separate handler function. -
Add metrics — Use
MetricsRegistry.inc()fromsrc/webhook/metrics.ts. -
Add tests — Test the HTTP handler in
test/webhook.test.ts.
Adding a new workflow_call input
- Add to
configSchemainsrc/config.ts— use the appropriate Zod validator. - Add to
review-reusable.ymlinputs:section. - Add to
review.ymlwith:section, wiring fromvars.*orsecrets.*. - Add to
.env.examplefor local development.
3. How to Add a New Review Check
The review pipeline is: GooseReviewer.review() → normalizeReviewDecision() → evaluateReviewDecision() → submitReview().
Adding a new finding type in the goose prompt
- Extend the prompt — Edit
src/review/prompt.ts,buildSystemPrompt()function. Add a new rule:
// Example: add a new check for hardcoded credentials
const newRule = "Check for hardcoded credentials (API keys, passwords, tokens) in the patch. Report as 'change' (blocking) when found in production code.";
-
Update the output schema — If the new finding needs a new field, update
reviewDecisionSchemainsrc/review/gooseReviewer.tsand theReviewDecisiontype insrc/types.ts. -
Update normalization — If the new field needs validation, update
src/review/normalize.ts.
Adding a post-goose processing step
- Add a new check function in
src/review/— e.g.,src/review/staticChecks.ts:
import type { ReviewFinding } from "../types.js";
export function runStaticChecks(files: unknown[]): ReviewFinding[] {
// Implement static analysis
return [];
}
- Integrate into processor — In
src/review/processor.ts,processPullRequest(), after the goose review call, merge static findings:
const staticFindings = runStaticChecks(compactFiles);
const mergedFindings = [...decision.change, ...staticFindings];
- Add tests — Test the static check function in isolation.
Adding a new review policy option
- Add the policy value — Add to
REVIEW_POLICYzod enum insrc/config.ts:
reviewPolicy: z.enum(["allow", "require_approval", "reject", "new_policy"]).default("allow"),
-
Handle in policy.ts — Update
evaluateReviewDecision()insrc/review/policy.tsto handle the new value. -
Update the review format — Update
formatReviewBody()insrc/review/format.tsto display the new policy. -
Update docs — Add to
.env.example,README.md, andREADME-zh.md.
4. How to Run the Audit
Full audit
The comprehensive audit report is at docs/audit-v2-final.md. To run a fresh audit:
# 1. Verify baseline
npm run typecheck && npm test && npm run build
# 2. Generate coverage report
node --import tsx --experimental-test-coverage --test test/**/*.test.ts
# 3. Review compatibility table
# Check docs/audit-v2-final.md for the latest requirements matrix
Quick health check
# Type + lint + test + build — all four must pass
npm run typecheck && npm run lint && npm test && npm run build
Manual audit checklist
- Requirements trace — Compare
docs/audit-v2-final.mdsection 1 against actual code behavior. - Blind spot scan — Review
docs/audit-v2-final.mdsection 2 for known gaps. - Coverage — Section 7 for current coverage numbers.
- Security — Section 6 for the security review matrix.
- Architecture — Section 4 for module health.
Continuous audit
Update workflow_status.md after each milestone:
- Mark completed items with ✅
- Note remaining items with reasons
- Track coverage, test count, and build passes
5. How to Do a Release
Pre-release checklist
npm run typecheckpassesnpm run lintpasses (0 errors)npm run format:checkpassesnpm testpasses (all tests green)- Coverage meets 80% lines target (check
ci:testoutput) npm run buildsucceedsworkflow_status.mdis up to datedocs/audit-v2-final.mdis up to date (if applicable)README.mdandREADME-zh.mdreflect current behavior.env.examplecovers all config options
Release steps
- Update version — Edit
package.json:
{
"version": "2.0.0"
}
- Update changelog — Create or update
CHANGELOG.mdwith conventional commits format:
# Changelog
## [2.0.0] - 2026-08-24
### Added
- feat: MergeGuard merge deduplication
- feat: MetricsCollector for Actions runs
- feat: failureMessages error categorization
- feat: smart retry with jitter and total timeout
### Fixed
- fix: normalizeKnowledge line ending normalization
- Commit and tag:
git add -A
git commit -m "chore: bump version to v2.0.0"
git tag v2.0.0
git push origin main --tags
- Create GitHub Release:
gh release create v2.0.0 --title "v2.0.0" --notes "Release notes here"
- Verify release:
- Check that
review.ymlworkflow dispatches correctly - Verify the reusable workflow at the new tag works
- Confirm CI passes on the release commit
Post-release
- Update
workflow_status.mdwith the new baseline - Archive the audit report to
docs/reports/if detailed - Update
metadata.repo_baselinein this skill file
Configuration Reference
All config is defined in src/config.ts with Zod schema validation. Key environment variables:
| Variable | Default | Description |
|---|---|---|
GOOSE_API_KEY |
— | LLM API key for goose |
GOOSE_MODEL |
gpt-5.4 |
Model name |
REVIEW_POLICY |
allow |
Review policy: allow/require_approval/reject |
REVIEW_STRICTNESS |
normal |
Review strictness: normal/strict |
AUTO_MERGE |
false |
Auto-merge on pass |
AUTO_RESOLVE_CONFLICTS |
false |
Auto-resolve merge conflicts |
TRIAGE_ENABLED |
true |
Enable issue/PR triage |
WEBHOOK_ENABLED |
false |
Enable webhook mode |
Full list in .env.example and src/config.ts.
Key Files
| Path | Purpose |
|---|---|
src/actions/router.ts |
Event routing and handler registration |
src/actions/runReview.ts |
Actions entry point |
src/review/processor.ts |
Core review orchestration |
src/review/policy.ts |
Review policy evaluation |
src/review/gooseReviewer.ts |
LLM review prompt + schema |
src/review/conflictResolver.ts |
Merge conflict resolution |
src/triage/processor.ts |
Issue/PR triage and duplicate detection |
src/chat/processor.ts |
@bot chat in disposable containers |
src/ai/gooseCli.ts |
Goose CLI and Docker wrappers |
src/ai/apiProxy.ts |
One-time credential proxy |
src/config.ts |
All env config with Zod validation |
src/metrics/collector.ts |
Actions metrics collector |
src/review/merge-guard.ts |
Merge deduplication guard |
src/ai/failureMessages.ts |
Error categorization |
docs/audit-v2-final.md |
Comprehensive audit report |
workflow_status.md |
Milestone tracking |
.github/workflows/ci.yml |
CI pipeline |
.github/workflows/review.yml |
PR review workflow |