Goal
Claude Code-style /goal for OpenCode v2: set a completion condition and the agent keeps working until it is met.
5
近 30 天 +2
0
29.6
生态多维模型
5 天前
2026-10-15
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@el4cteo/opencode-goal@1.0.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@el4cteo/opencode-goal@1.0.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @el4cteo/opencode-goalOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Claude Code's /goal for OpenCode v2. Give the agent a finish line; it keeps working, turn after turn, until an evaluator confirms the condition is met.

Install
opencode plugin add @el4cteo/opencode-goal
Or from GitHub: opencode plugin add github:EL4CTEO/opencode-goal, or point plugins in opencode.json at a local clone:
{ "plugins": ["/path/to/opencode-goal"] }
Requires OpenCode 2.0.29 or newer.
Use
| Command | What it does |
|---|---|
/goal <condition> |
Sets the goal and starts working on it right away |
/goal |
Shows status: condition, time, turns, spend, last evaluator reason |
/goal clear |
Removes the goal (stop, off, reset, none, cancel also work) |
/goal bun test passes with 0 failures and no test file is modified
While a goal runs, the footer shows its state:

Write a good condition: one measurable end state, how to prove it (npm test exits 0), and anything that must not change. Add a limit for open-ended work, e.g. or stop after 20 turns.
How it works
- After every turn, an evaluator reads the conversation and answers met, not met or impossible.
- Not met: the agent gets the reason and starts the next turn on its own.
- Met / impossible: the goal ends and a note is added to the transcript.
- The evaluator only sees what's in the conversation, so the agent is told to show proof (test output, command results).
- By default the evaluator reuses the session's cached context, so each check costs little more than a short answer.
Safety rails:
- Pauses after 3 turns in a row without tool use, on rate limits, on interrupt (Esc), or at the 200-turn cap. Send any message to resume.
- Retries dropped connections and overloads with backoff (up to 3 times).
- Clears on errors you must fix: auth, credit, context overflow, missing model.
- Waits while subagents or background shells run, with check-ins at 30 min, then 60, then 120.
- Restores active goals after a restart or plugin reload.
Options
All optional, set in opencode.json:
{
"plugins": [
{
"package": "@el4cteo/opencode-goal",
"options": {
"evaluator": { "model": "opencode-go/deepseek-v4.1-flash" },
"maxTurns": 200,
"stallTurns": 3,
"checkinMinutes": 30,
"maxRetries": 3,
"systemReminder": false,
"transcriptNotes": true
}
}
]
}
| Option | Default | Meaning |
|---|---|---|
evaluator.model |
session model | Separate model that judges the goal (fresh eyes, uses a transcript digest) |
evaluator.mode |
auto |
session, independent, or auto (independent when a model is set) |
maxTurns |
200 |
Hard turn cap, 0 = none |
stallTurns |
3 |
Turns without tool use before pausing |
checkinMinutes |
30 |
First background check-in; 0 disables check-ins and retries |
maxRetries |
3 |
Automatic retries after transient errors |
systemReminder |
false |
Also put the goal in the system prompt (costs one cache miss) |
transcriptNotes |
true |
Record achieved/impossible verdicts in the transcript |
Environment overrides: OPENCODE_GOAL_MODEL, OPENCODE_GOAL_MAX_TURNS, OPENCODE_GOAL_CHECKIN_MINUTES.
Develop
bun install
bun run check # typecheck + unit tests
bun run e2e <empty-dir> [provider/model] # real run against a private opencode server
License
MIT
同类生态推荐
Loopd
@bojackduy/opencode-loopd
Codex-inspired background goal engine for OpenCode — autonomous subagents, engine-driven loop, child worker sessions and modal TUI dashboard. Like Claude Code loop for OpenCode.
Better Hashline
opencode-better-hashline
Fail-closed, snapshot-bound line editing for OpenCode
Goal
@prevalentware/opencode-goal-plugin
OpenCode goal plugin that adds Codex-style long-running goal mode, /goal commands, persistence, and TUI status for AI coding agents.