Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .agents/plugins/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "workbench",
"interface": {
"displayName": "workbench"
},
"plugins": [
{
"name": "workbench",
"source": {
"source": "local",
"path": "./"
},
"policy": {
"installation": "AVAILABLE",
"authentication": "ON_INSTALL"
},
"category": "Productivity"
}
]
}
15 changes: 15 additions & 0 deletions .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "workbench",
"version": "1.2.0",
"description": "Ticket-to-PR development workflow: triage, plan with verified citations, implement inside the plan, review, commit, PR. Pluggable issue trackers (Jira, Azure DevOps, GitHub Issues) or a backlog in the repo, so it works with no tracker at all.",
"author": {
"name": "matheusPavaneli",
"url": "https://github.com/matheusPavaneli"
},
"homepage": "https://github.com/matheusPavaneli/workbench",
"repository": "https://github.com/matheusPavaneli/workbench",
"license": "MIT",
"keywords": ["codex", "codex-plugin", "ai-agents", "agentic-coding", "developer-tools", "workflow", "planning", "code-review"],
"skills": "./skills/",
"hooks": "./hooks/codex.json"
}
11 changes: 11 additions & 0 deletions .workflow/tasks/WB-61.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"key": "WB-61",
"title": "Make workbench agent-agnostic, not Claude Code only",
"type": "feature",
"status": "done",
"desc": "Decouple the edges from Claude Code so skills, hooks and wb run work with other coding agents (Codex, Cursor, Gemini CLI). Coupling today: (1) skills/*/SKILL.md call ${CLAUDE_PLUGIN_ROOT}/lib/wb.py and ${CLAUDE_PLUGIN_ROOT}/shared/*; (2) hooks/hooks.json + lib/wb_hook.py + lib/workbench/hooks.py speak only the Claude Code hook protocol; (3) lib/workbench/agent.py has claude -p as the only Agent, cli/run.py hardcodes --permission-mode and the claude install hint; (4) README/docs describe it as Claude Code only. Acceptance: skills resolve wb without CLAUDE_PLUGIN_ROOT (fallback to wb on PATH / WB_ROOT) and still work in Claude Code; hook logic behind an agent-neutral interface with Claude Code as one adapter; wb run selects an agent by config (run.agent), claude-code default, at least one second adapter or a documented seam; README install section per agent; all existing tests pass, new tests for path resolution and agent selection. Non-goals: dropping Claude Code support.",
"created": "2026-09-28T17:51:08Z",
"updated": "2026-09-28T18:31:53Z",
"comments": [],
"linked": []
}
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,35 @@ command's own output, and one that removes it. A `--json` payload that loses or
renames a key raises its `schema` number in the same release, and
`contract.VERSIONS` is asserted against the real output so it cannot drift.

## Unreleased

workbench runs under Claude Code, OpenAI Codex, Gemini CLI and Cursor: the
same skills, the same scope guard and the same headless runner.

### Added

- **`wb run --agent claude-code|codex|gemini|cursor`**, or `"run": {"agent":
...}` in the repo config. Each agent's report is normalised to the same
`run.json` keys; one it does not report is absent. **Upgrade cost:** none,
`claude-code` is the default.
- **`wb hooks install gemini|cursor [--write]`** proposes the scope guard's
entries for `.gemini/settings.json` or `.cursor/hooks.json` and, with
`--write`, merges them in, keeping every key it did not write. **Upgrade
cost:** none.
- **A Codex plugin**: `.codex-plugin/plugin.json`, `.agents/plugins/marketplace.json`
and `hooks/codex.json`, whose `PreToolUse` reads the paths out of an
`apply_patch`. **Upgrade cost:** none.
- `lib/wb_hook.py --agent NAME`; with no agent it answers as Claude Code, as
before.

### Changed

- **Skills call `wb`**, falling back to `../../lib/wb.py` relative to the
skill, instead of `${CLAUDE_PLUGIN_ROOT}/lib/wb.py`, which only Claude Code
substitutes. Shared references are relative to the skill too. **Upgrade
cost:** none in Claude Code, which puts the plugin's `bin/` on its shell's
PATH; elsewhere, put `bin/` on PATH.

## 1.2.0

Work in a critical zone is planned from the start, not after a finished fix,
Expand Down
57 changes: 47 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# workbench

Ticket-to-PR development workflow skills for Claude Code, with pluggable issue
trackers (Jira Cloud, Azure DevOps, GitHub Issues, GitLab Issues, Linear, or a backlog in the repo).
Ticket-to-PR development workflow skills for coding agents -- Claude Code,
OpenAI Codex, Gemini CLI and Cursor -- with pluggable issue trackers (Jira
Cloud, Azure DevOps, GitHub Issues, GitLab Issues, Linear, or a backlog in the repo).

Ten skills, one CLI, two hooks, 1206 tests, no third-party dependencies.
Ten skills, one CLI, two hooks, four agents, 1245 tests, no third-party dependencies.

## Quickstart

Expand All @@ -16,7 +17,7 @@ wb next # the one command to run now
wb status # everything in flight
```

In a Claude Code session the skills call `wb` themselves. In a terminal, put
In an agent session the skills call `wb` themselves. In a terminal, put
the plugin's `bin/` on your PATH first (see [Install](#install)).

## Two design rules
Expand All @@ -41,22 +42,52 @@ off standing.

## Install

Requires Python 3.9+. The same skills, CLI and scope guard serve every agent;
what differs is how each one loads them.

| Agent | Skills | Scope guard (hooks) | `wb run` |
|---|---|---|---|
| Claude Code | plugin | plugin (`hooks/hooks.json`) | `--agent claude-code` (default) |
| Codex | plugin | plugin (`hooks/codex.json`) | `--agent codex` |
| Gemini CLI | `.agents/skills/` | `wb hooks install gemini --write` | `--agent gemini` |
| Cursor | `.agents/skills/` | `wb hooks install cursor --write` | `--agent cursor` |

**Claude Code**

```
/plugin marketplace add matheusPavaneli/workbench
/plugin install workbench@workbench
```

`wb` is `python "${CLAUDE_PLUGIN_ROOT}/lib/wb.py"`. Requires Python 3.9+.
**Codex** reads the repo's `.agents/plugins/marketplace.json` and the
`.codex-plugin/plugin.json` manifest: add this repo as a plugin marketplace
in Codex and install `workbench` from it. Its hooks are `hooks/codex.json`, so
Codex never loads the Claude-format `hooks/hooks.json`.

**Gemini CLI and Cursor** load skills from `.agents/skills/` (one repo) or
`~/.agents/skills/` (every repo), and hooks from the project. From a clone:

```sh
cp -r skills/* ~/.agents/skills/ # or link them, to follow upgrades
wb hooks install gemini --write # or: cursor -- merges into .gemini/settings.json / .cursor/hooks.json
```

`wb hooks install` proposes first and writes only with `--write`; it keeps every
key it did not write, and a rerun replaces its own entries. The command it
writes names this clone's `lib/wb_hook.py`, so run it again after moving the
clone. Cursor's stop hook cannot block, so `"hooks": "strict"` there submits one
follow-up message instead.

Skills call it by that path. To type `wb` in a terminal, put the plugin's `bin/`
directory on PATH: it holds `wb` (sh) and `wb.cmd` (Windows), both running the
same `lib/wb.py`. From a clone:
**`wb` on PATH.** Skills call `wb`, falling back to `lib/wb.py` relative to the
skill's own directory. Put the plugin's `bin/` directory on PATH: it holds `wb`
(sh) and `wb.cmd` (Windows), both running the same `lib/wb.py`. Claude Code puts
it there for its shell tool on its own. From a clone:

```sh
export PATH="$PWD/bin:$PATH" # PowerShell: $env:Path = "$PWD\bin;$env:Path"
```

For the installed plugin, use the directory Claude Code installed it into.
For an installed plugin, use the directory the agent installed it into.

### One pass to a working setup

Expand Down Expand Up @@ -384,6 +415,11 @@ being written, both stay silent.
`"hooks": "strict"` makes `Stop` block instead of report. `WB_NO_HOOKS=1` or
`"hooks": false` turns both off.

The decision is made once, in `lib/workbench/hooks.py`; each agent's protocol
-- which tool writes a file, how a refusal is spelled -- is an adapter in
`lib/workbench/hook_agents.py`. Codex's `apply_patch` is held to the plan path
by path, and a patch touching one unplanned file is refused whole.

## Quality presets

The preset sets the bar a plan must clear. It never lowers the floor: a unit test
Expand Down Expand Up @@ -453,7 +489,8 @@ wb doctor everything that has to be true, in one pass
wb start KEY [--refresh] read the ticket, branch for it, route it: one command to pick up work
wb finish KEY -m MESSAGE [--commit] light path: every check against the real change, then the commit (or its command)
wb approve [KEY] [TOKEN] show the one decision waiting on you, or approve exactly it by its token
wb run KEY [--until commit|pr] drive it headless through Claude Code, stopping at every decision (off by default)
wb run KEY [--until commit|pr] [--agent NAME] drive it headless, stopping at every decision (off by default)
wb hooks install gemini|cursor [--write] put the scope guard into an agent's project config
wb route [KEY] the steps this change actually needs
wb next [KEY] the single command to run now
wb status [KEY] | --stats where work stands, and what to run next
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ drops another.
| `execute` | by hand | `false` refuses every `--execute`, standing |
| `light_max_lines` | by hand | the most estimated lines changed a plan may have and stay on the light tier; 100 when absent |
| `light_path` | by hand | `false` puts every ticket on the standard route: `wb start` stops offering the light path, and `wb finish` moves a ticket already on it to the standard route; on when absent |
| `run` | by hand | `{"enabled": true}` turns `wb run` on for this repo (`WB_RUN=1` does for one call); `"permission_mode"` is passed to each `claude` session, `acceptEdits` when absent; off when absent |
| `run` | by hand | `{"enabled": true}` turns `wb run` on for this repo (`WB_RUN=1` does for one call); `"agent"` picks the agent it drives (`claude-code`, `codex`, `gemini`, `cursor`; `claude-code` when absent, `--agent` overrides it); `"permission_mode"` is passed to each Claude Code session, `acceptEdits` when absent; off when absent |
| `hooks` | by hand | `false` turns the plugin's hooks off; `"strict"` makes the stop hook block |
| `field_map` | by hand | custom tracker fields this repo wants read, by destination |
| `generated` | by hand | globs of generated code (`["src/gen/**"]`) that follow a planned change through the scope guard unlisted; none when absent |
Expand Down
37 changes: 31 additions & 6 deletions docs/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,22 @@ time are appended to `.workflow/KEY/run.json`. At most `--max-sessions`
(default 4) per call, each within `--timeout` seconds (default 1800).

The agent sits behind one interface (`workbench.agent`): run a session on a
prompt in a checkout, within a time limit, and report how it ended. Claude
Code (`claude -p --output-format json`) is the only implementation; `--model`,
`--permission-mode`, `--plugin-dir` and `--setting-sources` pass through to it. It is off by
prompt in a checkout, within a time limit, and report how it ended.
`--agent` (or `"run": {"agent": ...}`) picks the implementation, `claude-code`
when neither is set:

| Agent | Invocation | Report |
|---|---|---|
| `claude-code` | `claude -p --output-format json --permission-mode ...` | one JSON object |
| `codex` | `codex exec --json --sandbox workspace-write` | JSON lines: `thread.started`, `turn.completed` usage, `turn.failed` |
| `gemini` | `gemini -p --output-format json --approval-mode auto_edit` | one JSON object; tokens summed over `stats.models` |
| `cursor` | `agent -p --output-format json --force --workspace <checkout>` | one JSON object |

Each report is normalised to the same keys (`session_id`, `num_turns`,
`usage`, `total_cost_usd`, `is_error`); one an agent does not report is absent,
never guessed. `--model` goes to every agent; `--permission-mode`,
`--plugin-dir` and `--setting-sources` are Claude Code's and are not passed to
another. It is off by
default: `"run": {"enabled": true}` in `.workflow/config.json`, or `WB_RUN=1`
for one call. An autopilot over an expensive flow spends faster, and a headless
session is where a stop nobody sees would hide.
Expand Down Expand Up @@ -341,11 +354,23 @@ Forward slashes work everywhere and are the simpler choice.

## Hooks

`hooks/hooks.json` registers two Claude Code hooks. The decisions live in
`lib/workbench/hooks.py`; `lib/wb_hook.py` only reads the event from stdin
(1 MiB at most) and prints the answer. It is kept out of `wb` so that a hook
Two hooks, one decision. `lib/workbench/hooks.py` decides (`guard_edit`,
`check_stop`) in terms of paths and messages; `lib/workbench/hook_agents.py`
reads each agent's payload and spells its answer; `lib/wb_hook.py
[--agent NAME] <pre-tool-use|stop>` only reads the event from stdin (1 MiB at
most) and prints the answer, Claude Code's when no agent is named. It is kept out of `wb` so that a hook
firing on every edit does not fill the command history `--stats` reads.

| Agent | Registered by | Edit tools | Refusal | Stop, strict |
|---|---|---|---|---|
| Claude Code | `hooks/hooks.json` | `Edit`, `Write`, `MultiEdit`, `NotebookEdit` | `hookSpecificOutput` deny | `decision: block`, once |
| Codex | `hooks/codex.json` | `apply_patch` (paths read from the patch), `Edit`, `Write` | `hookSpecificOutput` deny | `decision: block`, once |
| Gemini CLI | `wb hooks install gemini` | `write_file`, `replace` | `decision: deny` | `AfterAgent` deny, once |
| Cursor | `wb hooks install cursor` | `Write` | `permission: deny` | one `followup_message`; Cursor's stop cannot block |

Cursor refuses a tool call whose hook answer does not match its schema, so on
an internal error the Cursor adapter prints nothing and reports on stderr.

**The active ticket is the one the branch names**, among tickets with
artifacts. `wb next` falls back to the most recently touched ticket; a hook
that refuses edits must not, or a checkout on `main` would be held to last
Expand Down
28 changes: 28 additions & 0 deletions hooks/codex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"description": "workbench for Codex: refuse edits outside the active ticket's audited plan, and report unverified work at stop",
"hooks": {
"PreToolUse": [
{
"matcher": "apply_patch|Edit|Write",
"hooks": [
{
"type": "command",
"command": "python \"${PLUGIN_ROOT}/lib/wb_hook.py\" --agent codex pre-tool-use",
"timeout": 15
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python \"${PLUGIN_ROOT}/lib/wb_hook.py\" --agent codex stop",
"timeout": 60
}
]
}
]
}
}
5 changes: 4 additions & 1 deletion lib/wb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

Invoked as:

python "${CLAUDE_PLUGIN_ROOT}/lib/wb.py" <group> <action> [flags]
wb <group> <action> [flags] # bin/ on PATH
python "<plugin root>/lib/wb.py" <group> <action> [flags]

The surface is deliberately closed. There is no free-text query flag -- no
--jql, no --wiql, no --fields, no --url -- because a free-text flag is an
Expand Down Expand Up @@ -34,6 +35,7 @@
from workbench.cli import finish as finish_cli # noqa: E402
from workbench.cli import flow as flow_cli # noqa: E402
from workbench.cli import git as git_cli # noqa: E402
from workbench.cli import hooks as hooks_cli # noqa: E402
from workbench.cli import impl as impl_cli # noqa: E402
from workbench.cli import init as init_cli # noqa: E402
from workbench.cli import next as next_cli # noqa: E402
Expand All @@ -57,6 +59,7 @@
"finish": finish_cli,
"approve": approve_cli,
"run": run_cli,
"hooks": hooks_cli,
"status": status_cli,
"next": next_cli,
"route": route_cli,
Expand Down
39 changes: 29 additions & 10 deletions lib/wb_hook.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""Entry point for the Claude Code hooks in hooks/hooks.json.
"""Entry point for every agent's hooks: hooks/hooks.json (Claude Code),
hooks/codex.json (Codex), and what ``wb hooks install`` writes for Gemini CLI
and Cursor.

python "${CLAUDE_PLUGIN_ROOT}/lib/wb_hook.py" <pre-tool-use|stop>
python "<plugin root>/lib/wb_hook.py" [--agent <name>] <pre-tool-use|stop>

Thin on purpose: the decisions live in ``workbench.hooks``, where they are
tested. This reads the event from stdin, prints the answer as JSON (or nothing,
With no ``--agent`` it speaks Claude Code's protocol, as it always has.

Thin on purpose: the decisions live in ``workbench.hooks`` and each agent's
protocol in ``workbench.hook_agents``, where they are tested. This reads the event from stdin, prints the answer as JSON (or nothing,
which lets the tool call through), and always exits 0.

Kept out of ``wb``: a hook fires on every edit, and routing it through the CLI
Expand All @@ -25,11 +29,21 @@

MAX_PAYLOAD = 1024 * 1024
EVENTS = ("pre-tool-use", "stop")
# Agents that refuse a tool call whose hook answer does not match the event's schema.
SCHEMA_STRICT = ("cursor",)


def main(argv: list[str], stdin, stdout) -> int:
name = ""
if argv[:1] == ["--agent"]:
name, argv = (argv[1] if len(argv) > 1 else ""), argv[2:]
event = argv[0] if argv else ""
try:
from workbench import gitctx, hook_agents

agent = hook_agents.AGENTS.get(name or hook_agents.DEFAULT)
if agent is None:
raise ValueError(f"unknown agent {name!r}; expected one of: {', '.join(hook_agents.AGENTS)}")
if event not in EVENTS:
raise ValueError(f"unknown hook event {event!r}; expected one of: {', '.join(EVENTS)}")
raw = stdin.read(MAX_PAYLOAD + 1)
Expand All @@ -39,13 +53,18 @@ def main(argv: list[str], stdin, stdout) -> int:
if not isinstance(payload, dict):
raise ValueError("hook payload is not a JSON object")

from workbench import gitctx, hooks

root = gitctx.checkout(Path(str(payload.get("cwd") or Path.cwd())))
handler = hooks.pre_tool_use if event == "pre-tool-use" else hooks.stop
answer = handler(payload, root)
root = gitctx.checkout(Path(hook_agents.root_hint(payload) or Path.cwd()))
handler = hook_agents.pre_tool_use if event == "pre-tool-use" else hook_agents.stop
answer = handler(agent, payload, root)
except Exception as exc: # noqa: BLE001 -- reported below, never swallowed
answer = {"systemMessage": f"workbench {event or 'hook'} did not run ({type(exc).__name__}: {exc}); edit allowed"}
message = f"workbench {event or 'hook'} did not run ({type(exc).__name__}: {exc}); edit allowed"
if name in SCHEMA_STRICT:
# A key outside the event's schema would refuse the edit here, so the
# report goes to stderr instead.
sys.stderr.write(message + "\n")
answer = None
else:
answer = {"systemMessage": message}

if answer:
stdout.write(json.dumps(answer) + "\n")
Expand Down
Loading
Loading