GitHub team workflow automation β session-based issue generation, git operations, and PR review coordination via slash command.
- Session-based workflow β Draft in
wip.json, confirm when ready. No accidental API calls. - AI-assisted issue creation β
/gtw newreads the parent session history and auto-generates a structured issue draft (title + body) with no manual input required. - Git operations β
fix,push, andprcommands wrap standard git workflows. - Emoji review protocol β eyes claim β checklist β approved/changes verdict.
- GitHub CLI integration β Uses
ghfor auth; no manual token config needed.
openclaw plugins install ~/code/plugins/gtw -l --dangerously-force-unsafe-install
openclaw gateway restart-l(link mode): changes to the source directory take effect immediately without reinstalling.--dangerously-force-unsafe-install: the dangerous-code scanner flagschild_processcalls used to invokegit/ghCLI. These are intentional β gtw is a GitHub workflow tool that wraps these CLIs. Use this flag to skip the false-positive scan result.- Gateway auto-reloads the plugin;
openclaw gateway restartensures a clean start.
/gtw <command> [args]
/gtw on <workdir> Set working directory (resolves git remote)
/gtw new Read conversation history, auto-generate issue draft (title + body) via AI, save to wip.json
/gtw update #<id> Update issue draft
/gtw confirm Execute all pending operations (create issue/branch/PR)
/gtw issue List open issues
/gtw show #<id> Show issue details
/gtw poll List open issues and PRs
/gtw fix <issue_id> Claim issue (add gtw/wip label), fetch issue, derive branch name, create branch,
inject directive to trigger subagent, subagent fixes automatically, creates
pendingCommit, requires /gtw confirm to push, then unclaims (removes label)
/gtw push Stage β auto-commit (conventional format) β generate commit draft β save as pendingCommit
(two-step: run /gtw confirm to actually push)
/gtw rebase [branch] Sync current branch with remote β ζεζ―εοΌfetch β checkout β rebase θΏη¨εζ―
β ζ εζ―εοΌgit pull --rebase origin <ε½εεζ―>
/gtw pr [issue_id] Generate PR title/body via LLM from commit diff, save as pendingPr draft
β /gtw pr (no args): uses current branch; never reads wip.json
β /gtw pr <issue_id>: derives branch from issue title (same as /gtw fix)
If remote branch exists β checks out and hard-resets to it.
If local branch exists but remote missing β checks out and prompts to run /gtw push.
If neither exists β uses current branch.
(two-step: run /gtw confirm to actually create the PR)
/gtw review Claim earliest PR with gtw/ready label from watch list
/gtw review <pr> Claim/review specific PR in current repo
/gtw watch add <owner>/<repo> Add repo to watch list
/gtw watch rm <owner>/<repo> Remove repo from watch list
/gtw watch list Show watched repos
/gtw config Show current config and wip.json
/gtw model Show current AI model (gtw-specific or session default)
/gtw model <model> Set custom AI model (e.g. github/gpt-4o)
/gtw model off Clear custom model, use session default
/gtw login Interactive OAuth login (device code flow)
/gtw login --pat <token> Register a Personal Access Token directly
gtw supports multiple authentication methods:
Method 1: Personal Access Token (PAT) - Recommended for CI
Option A: Direct PAT input
/gtw login --pat ghp_your_token_here
Validates the token via GitHub API and caches it to ~/.gtw/token.json.
Option B: Environment variable
export GITHUB_TOKEN=ghp_your_token_here
/gtw login --patUses and validates GITHUB_TOKEN, then caches it.
Option C: Cached PAT from previous login
Automatically used if you previously ran /gtw login --pat.
Generate a PAT at: https://github.com/settings/tokens (requires repo and workflow scopes)
Method 2: Interactive OAuth Login
Use the device code flow for interactive login:
/gtw login
This will:
- If GITHUB_CLIENT_ID is set: Use custom OAuth app with device code flow
- If GITHUB_CLIENT_ID is NOT set (default): Fall back to
gh auth loginusing GitHub CLI's built-in OAuth app- Opens browser for device code authentication
- Caches the token from gh CLI for gtw use
- No need to configure client ID/secret manually
Method 3: GitHub CLI Integration
gtw automatically uses gh CLI token if available. Make sure gh auth login has been run with repo scope:
gh auth login --hostname github.com --scopes repo,workflow
gh auth statusToken Priority:
GITHUB_TOKENenvironment variable (PAT)- Cached token in
~/.gtw/token.json(PAT or OAuth) gh auth token(validated before use)
Check auth status anytime:
/gtw config
~/.gtw/config.json stores gtw-specific settings:
{
"model": "github/gpt-4o",
"watchList": ["owner/repo1", "owner/repo2"],
"maxReviewRounds": 5
}| Field | Default | Description |
|---|---|---|
model |
session default | AI model used for issue/PR generation and review. Use github/<model> for Copilot models, minimax/<model> for MiniMax, etc. |
watchList |
[] |
Watch list of repos scanned by /gtw review (no-arg) for gtw/ready PRs. |
maxReviewRounds |
5 |
Maximum review rounds before a PR is marked gtw/stuck. Set to 0 to disable. |
llmTimeoutSeconds |
60 |
Timeout in seconds for LLM API calls. If a request times out, it is retried once. If both attempts time out, a TimeoutError is thrown. Can be overridden with the GTW_LLM_TIMEOUT_SECONDS environment variable (takes precedence). |
View/edit via:
/gtw model <provider/model-id> # set custom AI model
/gtw model # show current model
/gtw model off # clear custom model
/gtw watch add <owner>/<repo> # add to watch list
/gtw watch list # show watch list
You: /gtw on ~/code/myproject
β β
Switched to owner/repo
π Workdir: /home/user/code/myproject
Let's discuss the requirements first β no code yet.
You: /gtw new
β Draft saved:
Title: fix: handle null pointer in auth
Body:
## Background
...
## Acceptance Criteria
...
You: /gtw fix 42
β πΏ Fix workflow started
Issue: #42
Title: fix: handle null pointer in auth
Branch: fix/handle-null-pointer
β³ Subagent spawned β the main session will now:
1. Spawn coding subagent to fix the issue
2. Wait for subagent to finish
3. Run push + confirm automatically
(gtw/wip label is applied to issue #42)
You: /gtw push
β π Commit draft β run /gtw confirm to push
π Commit Message: fix(auth): handle null pointer in auth
π Changes: +10 -2
Run /gtw confirm to commit and push.
You: /gtw confirm
β π¦ Committed and pushed
Branch: fix/handle-null-pointer
(gtw/wip label removed from issue #42)
You: /gtw pr
β π PR draft β run /gtw confirm to create PR
π Title: fix: handle null pointer in auth
πΏ Branch: fix/handle-null-pointer β main
You: /gtw confirm
β β
PR #42 created
URL: https://github.com/owner/repo/pull/42
You: /gtw pr 13
β π PR draft for issue #13 β run /gtw confirm to create PR
π Title: fix: handle null pointer in auth
πΏ Branch: fix/handle-null-pointer
β οΈ Remote branch missing β please run /gtw push to publish this branch
Issue: #13 β handle null pointer in auth
You: /gtw push
β π Commit draft β run /gtw confirm to push
π Commit Message: fix(auth): handle null pointer in auth
Run /gtw confirm to commit and push.
You: /gtw confirm
β π¦ Committed and pushed
Branch: fix/handle-null-pointer
You: /gtw pr 13
β π PR draft for issue #13 β run /gtw confirm to create PR
π Title: fix: handle null pointer in auth
πΏ Branch: fix/handle-null-pointer β main
Issue: #13 β handle null pointer in auth
You: /gtw confirm
β β
PR #42 created
URL: https://github.com/owner/repo/pull/42
You: /gtw watch add owner/repo
β β
Now watching: owner/repo
You: /gtw review
β eyes Claimed PR #23: fix: handle null pointer
Linked Issue: #12 β handle null pointer in auth
Files changed (3):
- src/auth.js: +10 -2
- tests/auth.test.js: +5 -0
Review [Round 1/5]
- [ ] Destructive
- [ ] Out-of-scope
Review the diff against the issue requirements.
Run /gtw review 23 again after resolving items.
You: /gtw review 23
β eyes PR #23 re-review (Round 2/5)
[Items still unresolved kept as unchecked]
Review the diff and update checklist.
Review protocol:
/gtw review(no-arg): Scans watch list for PRs labeledgtw/ready, picks the oldest byupdated_at, claims it (gtw/wip), creates a Round 1 checklist./gtw review <pr>: Reviews specific PR in the current repo (fromwip.json). If a checklist exists, increments the round and updates the same comment.- Checklist items (always two): Destructive and Out-of-scope β the canonical checks to prevent AI-caused unplanned or out-of-scope modifications.
- Each invocation increments the round number. Unresolved items remain unchecked.
- When all checkboxes are resolved (all items checked): checklist comment is deleted, approved comment posted,
gtw/lgtmlabel applied. PR is ready to merge. - When unresolved items remain:
gtw/reviselabel is applied (replacesgtw/wip), a new "changes needed" comment is posted listing the unresolved items. The previous checklist comment is preserved as-is. - When round reaches
maxReviewRounds(default 5) with unresolved items:gtw/stucklabel applied, manual intervention required. - No GitHub Review API is used β all review state is tracked via labels and a single persistent checklist comment per PR.
Label system (mutually exclusive):
| Label | Meaning |
|---|---|
gtw/ready |
Pending review |
gtw/wip |
Review in progress |
gtw/lgtm |
Approved |
gtw/revise |
Needs changes |
gtw/stuck |
Exceeded max rounds |
State transition diagram:
ββββββββββββββββββββββββββββββββββββββββ
β β
ββββββββββββββββββΌβββββββββββ reviewer claims β
β gtw/ready ββββββββββββββββββββββββββββ€
β (pending review) β β
ββββββββββββββββββββββββββββββ β
β² β β β
β β β β
β β β β
βββββββββββββ΄βββββ β β ββββββββββββββββββββββββββ
β β β β β
β round β₯ max β β β β
β ββββββββββ+ββββΌβββββββΌβββ
β β β
β ββββββββββββββββββΌβββββββΌβββββββββββββββ
β β gtw/wip β
β β (review in progress) β
β ββββββββββββββββββββββββββββββββββββββββ
β β
β ββββββββββββββββββββββββββββββββββββββββββββ
β β β
β β all checklist items resolved β unresolved items remain
β βΌ β
β ββββββββββββ βββββββββββββ
β β gtw/lgtm β β gtw/reviseβ
β ββββββββββββ βββββββββββββ
β β
β β developer resubmits
β β /gtw review <pr>
β β
β βΌ
β ββββββββββββββββββββββββββββ
β β gtw/wip (resets, round++) β
β ββββββββββββββββββββββββββββ
β
β unresolved + round β₯ max
β
ββββββββββΊββββββββββββ
β gtw/stuckβ (manual intervention required)
ββββββββββββ
Note:
gtw/reviseis automatically applied when unresolved items remain. When the developer resubmits (/gtw review <pr>),gtw/wipis set and the round increments.
~/.gtw/wip.json # Workdir, repo, pendingCommit, pendingPr, issue, branch
~/.gtw/token.json # Cached token (PAT, OAuth, or gh CLI)
~/.gtw/device_code.json # Cached device code for OAuth login reuse
~/.gtw/config.json # Custom AI model setting
All mutating operations (/gtw push, /gtw pr) follow a two-step pattern for safety:
- Step 1 β Draft: Command generates a draft (commit message or PR title/body) and saves it as
pendingCommitorpendingPrinwip.json. Nothing is pushed or created yet. - Step 2 β Confirm:
/gtw confirmreads the pending draft and executes the actual GitHub API call (push or PR creation).
This means every workflow that involves pushing or creating a PR will have a β /gtw confirm step before the final success message.
After any change to command logic, verify the affected flow:
/gtw push flow:
cd <workdir> && echo "// test" >> README.md/gtw pushβ should show "π Commit draft β run /gtw confirm to push" (NOT immediate push)cat ~/.gtw/wip.jsonβ should containpendingCommitwith title/body/branch/gtw confirmβ should show "π¦ Committed and pushed"git log --oneline -1β should show the commit
/gtw fix flow:
/gtw fix 13β should claim issue (gtw/wip label appears on GitHub), create branch- After subagent completes:
git log --onelineβ should have fix commits /gtw confirmβ should push the branch- GitHub issue #13 β gtw/wip label should be removed
/gtw pr flow:
- Ensure branch is pushed and on the correct branch
/gtw prβ should show "π PR draft β run /gtw confirm to create PR"cat ~/.gtw/wip.jsonβ should containpendingPrwith title/body/gtw confirmβ should create PR on GitHub and show URLcat ~/.gtw/wip.jsonβpendingPrshould be cleared,prshould be set
/gtw review flow:
/gtw reviewβ should claim an unclaimed PR (eyes comment appears)/gtw review <pr> approvedβ should post approved comment and submit GitHub review- PR page β should show review state as "Approved"
| Flow | Check |
|---|---|
pendingCommit created |
wip.json contains pendingCommit after /gtw push |
pendingPr created |
wip.json contains pendingPr after /gtw pr |
gtw/wip label applied |
GitHub issue shows gtw/wip label after /gtw fix |
gtw/wip label removed |
GitHub issue loses gtw/wip label after fix flow completes |
gtw/ready PR claimed |
GitHub PR shows gtw/wip label after /gtw review |
| Checklist comment posted | GitHub PR shows ## Review [Round N] comment |
| Checklist cleared | Checklist comment deleted, gtw/lgtm applied |
gtw/
βββ index.js # Plugin entry (ESM, registerCommand)
βββ openclaw.plugin.json # Plugin manifest
βββ package.json # ESM package
βββ commands/ # OOP Commander pattern (one class per command)
β βββ Commander.js # Base interface
β βββ CommanderFactory.js # Factory: cmd string β Commander instance
β βββ OnCommand.js # Set workdir + repo
β βββ NewCommand.js # Auto-generate issue draft via AI
β βββ FixCommand.js # Claim issue, create branch, spawn subagent fix
β βββ PushCommand.js # Generate commit message draft (pendingCommit)
β βββ ConfirmCommand.js # Execute pending actions
β βββ ReviewCommand.js # Review workflow with checklist comments + labels
β βββ WatchCommand.js # Manage watch list (add/rm/list repos)
β βββ *.js
βββ utils/
βββ session.js # Parent session read/write (JSONL injection)
βββ *.js