goal-engine
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@goal-engineset a goal: all unit tests pass and lint is clean"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
goal-engine
Run-until-done /goal loops for every major agentic CLI — Claude Code, Codex CLI, OpenCode, Cursor, and any MCP-compatible agent.
You state a completion condition ("all tests pass", "the PR is ready"); the agent keeps working across turns until an external evaluator confirms the condition is verifiably met — or until a loop guard or turn budget stops a runaway session.
Architecture: three composable layers
┌─────────────────────────────────────────────────────────┐
│ Layer 3 — npm package + installer CLI │
│ npx -y goal-engine · goal-engine install --all │
├─────────────────────────────────────────────────────────┤
│ Layer 2 — MCP server (goal-engine) │
│ set_goal / check_goal / get_status / clear_goal │
│ Evaluator via MCP sampling (no external API key) │
│ SQLite state · loop guard · turn budget │
├─────────────────────────────────────────────────────────┤
│ Layer 1 — portable SKILL.md │
│ Works standalone on any Agent Skills runtime │
└─────────────────────────────────────────────────────────┘Each layer works on its own. The skill alone gives you self-checked goal loops anywhere; adding the MCP server upgrades the self-check to an independent evaluator with persistent state.
Related MCP server: agent-runtime-mcp
Why an external evaluator?
A skill-only goal loop asks the model to grade its own work inside the same context window — a confused agent can convince itself the goal is met. The MCP spec's sampling primitive lets this server request a completion from the connected client's own model in a fresh context, with a strict evaluation prompt. No API key, no extra provider, CLI-agnostic.
Evaluator fallback chain (strongest available wins):
MCP sampling — the client's model judges the transcript (zero config)
Anthropic API — set
ANTHROPIC_API_KEY(model:claude-opus-4-8, override withGOAL_ENGINE_EVAL_MODEL)OpenAI API — set
OPENAI_API_KEY(model:gpt-4o, override withGOAL_ENGINE_OPENAI_MODEL)Self-check — the tool returns strict self-verification instructions and never auto-completes
A flaky evaluator can never end a goal early: every evaluator failure resolves to done: false.
Install
# Install the /goal skill into every detected agent CLI
npx -y goal-engine install --all
# Or a specific one
npx -y goal-engine install --to claude-code # also: codex, opencode, cursorThen connect the MCP server:
Claude Code
claude mcp add goal-engine -- npx -y goal-engineCodex CLI (~/.codex/config.toml)
[mcp_servers.goal-engine]
command = "npx"
args = ["-y", "goal-engine"]OpenCode (~/.config/opencode/config.json)
{ "mcp": { "goal-engine": { "type": "local", "command": ["npx", "-y", "goal-engine"] } } }Bun users can substitute bunx goal-engine everywhere — the server auto-selects bun:sqlite, node:sqlite, or a JSON file for state.
Usage
/goal all unit tests pass and lint is cleanThe agent then:
calls
set_goalwith the condition verbatim,works toward it with all available tools,
calls
check_goalat the end of every turn with a concrete work summary,treats each
done: falsereason as its next instruction,stops only on
done: true(or escalates onloop_detected/budget_exhausted).
MCP tools
Tool | Input | Output |
|
|
|
|
|
|
|
|
|
|
|
|
Safety rails built into check_goal:
Loop guard — 3 identical consecutive summaries return
loop_detectedand tell the agent to change approach or ask the user.Turn budget —
max_turns(default 40, max 500) returnsbudget_exhaustedwith a partial-progress instruction.Strict parsing — unparseable evaluator verdicts resolve to
done: false.
Optional: Claude Code Stop hook
The MCP-tool flow relies on the agent calling check_goal. The Stop hook closes the gap: it fires whenever Claude tries to stop, and blocks the stop while a goal is active and unmet.
mkdir -p ~/.goal-engine
cp hooks/stop-goal-evaluator.sh ~/.goal-engine/
chmod +x ~/.goal-engine/stop-goal-evaluator.sh~/.claude/settings.json:
{
"hooks": {
"Stop": [{ "hooks": [{ "type": "command", "command": "~/.goal-engine/stop-goal-evaluator.sh" }] }]
}
}Notes:
The hook honors
stop_hook_active(no infinite recursion) and lets the agent stop once the turn budget is exhausted.Claude Code caps consecutive Stop-hook blocks at 8 by default; set
CLAUDE_CODE_STOP_HOOK_BLOCK_CAP=40to match the default turn budget.With
ANTHROPIC_API_KEYset, the hook evaluates the transcript's last assistant message; without it, the block reason instructs the agent to self-verify and finish viaclear_goal completed=true.
Environment
Variable | Default | Purpose |
|
| State file path |
|
| Data directory |
| — | Evaluator fallback when MCP sampling is unavailable |
|
| Anthropic evaluator model |
| — | Second evaluator fallback |
|
| OpenAI evaluator model |
Development
bun install
bun run typecheck # tsc --noEmit
bun test # unit + MCP integration tests (in-memory transport)
bun run build # tsc → dist/
bun run smoke # drives dist/index.js over stdio with raw JSON-RPCProject layout:
SKILL.md Layer 1 — portable Agent Skill
src/index.ts CLI entry: serve (default) | install | check-hook
src/server.ts MCP server: the four goal tools + sampling wiring
src/evaluator.ts Evaluator chain: sampling → Anthropic → OpenAI → self-check
src/db.ts State: bun:sqlite | node:sqlite | JSON fallback
src/loop-guard.ts Identical-turn loop detection
src/hook.ts Claude Code Stop hook logic
src/installer.ts Cross-CLI skill installer
hooks/stop-goal-evaluator.sh Stop hook wrapper script
agents/openai.yaml Codex plugin metadataLicense
MIT
Available Tools
4 toolscheck_goalCheck goalA
Evaluate whether the active goal is fully met. Call at the end of every turn with a concrete summary of the work just done. Returns done=true when finished, or done=false plus the specific gap to address next.
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | Session identifier returned by set_goal. | |
| summary | Yes | Concrete summary of this turn's work: commands run, files changed, test results. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, description carries burden. It discloses return format (done=true or done=false plus gap) and expected input. Lacks details on side effects or auth, but for a non-destructive evaluation tool this is adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences: first establishes purpose, second provides usage and return behavior. No wasted words, efficient and front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite no output schema, description fully explains return values and when to call. Parameter explanations in schema complement description. Complete for this tool's needs.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema covers both parameters with descriptions (session_id and summary). The description reinforces usage ('concrete summary') but adds little beyond schema. Baseline 3 for high coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states 'Evaluate whether the active goal is fully met' with a specific verb and resource. Distinguishes from siblings (clear_goal, get_status, set_goal) by its unique evaluation purpose.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly advises 'Call at the end of every turn' and specifies what to include in summary. Does not explicitly mention alternatives, but context with siblings implies it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
clear_goalClear goalA
End a goal session. Pass completed=true when the goal was verifiably met (used by the self-check fallback); otherwise the session is abandoned.
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | Session identifier returned by set_goal. | |
| completed | No | True when the goal condition was verifiably met. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It discloses that the tool ends the session, distinguishes between completed and abandoned states, and mentions 'self-check fallback' as context. Adequate for a simple termination action.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, zero wasted words. Information is front-loaded with the primary action then parameter usage. Perfectly concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema exists, and the description does not mention what the tool returns (e.g., success indication, error cases). For a simple 'end session' tool, this is a minor gap; some agents may need to know if the action succeeded. Otherwise, the description covers the essentials for invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so baseline is 3. The description adds value beyond the schema by explaining the 'self-check fallback' context for completed=true and explicitly stating that omitting or passing false means abandoned. This enhances understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states 'End a goal session' as verb+resource. Distinct from sibling tools (check_goal, get_status, set_goal) which are about checking, retrieving, or starting goals. The description also specifies the two usage modes via the completed parameter.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides clear guidance on when to use completed=true (when goal verifiably met) vs other cases (abandoned). Does not explicitly contrast with sibling tools, but the distinction between ending vs checking/getting is implicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_statusGet goal statusA
Inspect the current goal session: condition, turn count, elapsed time, and last evaluation.
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | No | Session to inspect. Defaults to the most recent active session. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden for behavioral disclosure. The verb 'inspect' suggests a read-only operation, and listing specific fields provides transparency about what is returned. However, it does not explicitly state that it has no side effects or require permissions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence that front-loads the purpose and lists key details without unnecessary words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema, the description adequately informs the agent of the return fields (condition, turn count, elapsed time, last evaluation). The single optional parameter is clearly explained, making the tool usage unambiguous.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100% for session_id, and the description adds context that it defaults to the most recent active session, which goes beyond the schema alone.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'inspect' and the resource 'current goal session', listing specific fields such as condition, turn count, elapsed time, and last evaluation. It is specific enough to distinguish from sibling tools like check_goal, clear_goal, and set_goal.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for inspection of session status but does not provide explicit guidance on when to use this tool versus alternatives, nor does it mention when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
set_goalSet goalA
Start a run-until-done goal loop. Records the completion condition; the agent should then work toward it and call check_goal at the end of every turn until the goal is met.
| Name | Required | Description | Default |
|---|---|---|---|
| goal | Yes | The completion condition, stated verbatim (max 4000 characters). | |
| session_id | No | Optional session identifier. Generated when omitted; reuse it on every check_goal call. | |
| max_turns | No | Hard turn budget before the loop stops and reports partial progress. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must fully disclose behavioral traits. It states the tool 'records the completion condition' and starts a loop, but does not explain what happens if set_goal is called again while a goal is active (overwrite? error?), nor does it cover side effects or required permissions. The description is too brief on behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description consists of two succinct sentences. The first states the purpose, and the second provides a usage instruction. No redundant or extraneous information. Highly efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the presence of three parameters and no output schema or annotations, the description covers the core usage pattern but lacks details on edge cases (e.g., re-calling set_goal, what happens on max_turns reached, error handling). It is minimally adequate but not fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, but the description adds meaningful context beyond the schema: for session_id, it explains it's generated when omitted and should be reused; for max_turns, it clarifies it is a hard turn budget. This additional detail justifies a score above the baseline of 3.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool starts a 'run-until-done goal loop' and records a completion condition. It mentions the follow-up tool check_goal, distinguishing set_goal as the starter. However, it does not explicitly contrast with clear_goal or get_status.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description specifies when to use the tool (to start a goal loop) and instructs the agent to work toward the goal and call check_goal each turn. It lacks explicit guidance on when not to use it (e.g., if a goal is already active) or other alternatives, but the provided instruction is clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.1.0- First observed
check_goal - First observed
clear_goal - First observed
get_status - First observed
set_goal
TDQS
Scored across 4 tools
Each tool has a distinct purpose: set_goal starts, check_goal evaluates, clear_goal ends, and get_status inspects. No overlap or confusion.
All tools follow a consistent verb_noun pattern with underscores (set_goal, check_goal, clear_goal, get_status), making them predictable.
Four tools are exactly right for a goal engine's core lifecycle: start, evaluate, end, and inspect. No unnecessary extras or missing essentials.
The set covers the full lifecycle of a goal session: set, check, clear (with success/failure), and status. No obvious gaps for the intended functionality.
Maintenance
Related MCP Connectors
Durable, user-controlled goals and governed plans for AI agents.
Persistent work tracking for AI agents: tasks, status and history that follow you across machines
Goal and task planning MCP for Codex and AI agents, with evidence-backed completion.
ADHD system of record for agents: tasks, goals, loops, calendar, focus stats.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides state and log management tools designed for long-lived AI agents that may be interrupted and resumed. It enables tracking agent progress and maintaining an append-only event history to ensure continuity across multiple sessions.4MIT
- FlicenseNot gradedqualityDmaintenanceEnables persistent task and goal management with AI-powered decomposition, cross-session continuity, and fault-tolerant multi-agent pipelines.1-
- AlicenseBqualityCmaintenancePersistent brain, memory, loop controller, and reminder engine for AI coding agents.4217 npmMIT
- AlicenseAqualityCmaintenanceProvides AI agents with a lightweight task-management and self-verification layer to define goals, track checkpoints, detect scope drift, and verify completion against explicit done criteria.12MIT