Goal Engineering

June 30, 2026 · View on GitHub

Goal Engineering — Run until verifiably done

Explore the Showcase

GitHub stars goal-audit dogfood goal-audit npm goal-init npm goal-cost npm goal meta CLI npm MIT Pages

Goal engineering is replacing one-shot prompts with verifiable, run-until-done objectives. You define what "done" means, Grok Build works across turns until the condition holds — and reports progress via /goal and update_goal.

This is the canonical public reference for Grok Build CLI's /goal feature.

→ Interactive showcase + pattern picker
→ Canonical essay · → Golden path (10 min replay)
→ Companion: Loop Engineering (scheduled cadence) · Fleet Engineering (governed populations)

🔄 Loop Engineering v1.5.0 just shippedloop-sync, loop-constraints, MCP server on npm.
Loops discover work on a cadence. Goals finish bounded tasks. Stack cookbook →

The One-Line Definition

A goal is a single autonomous objective with a verifiable completion condition. Unlike a loop (which fires on a schedule), a goal persists across turns until Grok marks it complete, blocked, or you pause it.

Prompt  = one turn, one answer
Loop    = recurring discovery + triage on a cadence
Goal    = run until done (or blocked / paused)

Quick Start (2 minutes)

# Unified CLI (recommended)
npx @cobusgreyling/goal doctor . --suggest
npx @cobusgreyling/goal init . --pattern tests-green --tool grok

# Or individual packages
npx @cobusgreyling/goal-audit . --suggest
npx @cobusgreyling/goal-init . --pattern tests-green --tool grok --lang python

In Grok Build:

/goal All tests pass — goal-verifier before completed: true

Manage the active goal:

/goal status    # check progress
/goal pause     # pause without clearing
/goal resume    # continue
/goal clear     # end goal mode

Replay a full session: examples/golden-path/SESSION.md

Contents

Why Goals Matter

Most agent work fails in the gap between "looks done" and actually done. Goals close that gap:

  1. Persistence — the objective survives compaction and new turns
  2. Progress telemetryupdate_goal logs status without spamming the chat
  3. Explicit lifecycle — pause, resume, clear, blocked
  4. Verifiable completion — you define the stop condition up front

Goals pair naturally with loop engineering: loops discover work; goals finish it. See docs/stack-cookbook.md.

Try the stack: morning loop triage → pick top item → /goal until verifier passes:

# Loop side (v1.5.0 — just released)
npx @cobusgreyling/loop-init . --pattern daily-triage --tool grok
npx @cobusgreyling/loop-audit . --suggest

# Goal side (this repo)
npx @cobusgreyling/goal init . --pattern fix-bug --tool grok
npx @cobusgreyling/goal doctor . --suggest

Grok Build API

SurfacePurpose
/goal <objective>Set a new autonomous goal
/goal statusShow current goal state
/goal pause / resumePause or continue
/goal clearExit goal mode
update_goal toolAgent reports progress (message), completion (completed: true), or blockers (blocked_reason)

Full reference: docs/api-reference.md

Availability: /goal appears when the goal feature is enabled and update_goal is in the session toolset. No slash command? See examples/no-slash-command/GOAL-only.md.

The Four Primitives

PrimitiveJob in a Goal
ObjectiveOne sentence + verifiable done condition
VerifierSeparate check — implementer must not grade its own homework
StateGOAL.md or equivalent external memory
BudgetToken/turn caps and kill switches

Detail: docs/primitives.md · Cross-tool matrix: docs/primitives-matrix.md

Anatomy of a Goal

flowchart LR
    A["/goal &lt;objective&gt;"] --> B[Scope + done condition]
    B --> C[(GOAL.md state)]
    C --> D[Implementer turns]
    D --> E[Verifier sub-agent / tests]
    E --> F{Done?}
    F -->|yes| G["update_goal(completed: true)"]
    F -->|blocked| H["update_goal(blocked_reason)"]
    F -->|no| D
    G --> I[/goal clear or new goal/]

Patterns

PatternStarterWhen to use
Tests Greenstarters/tests-greenCI red → green with verifier gates
Migrate Modulestarters/migrate-moduleAPI/module migration + import scan
Implement Featurestarters/implement-featureScoped feature + acceptance criteria
Fix Bugstarters/fix-bugRepro → fix → regression test
Refactor Safelystarters/refactor-safelyBehavior-preserving refactor
Coverage Targetstarters/coverage-targetRaise coverage to threshold

Unsure? Pattern Picker · When not to use goals: docs/when-not-to-use-goals.md

Getting Started (5 minutes)

npx @cobusgreyling/goal init . --pattern tests-green --tool grok
npx @cobusgreyling/goal estimate --pattern tests-green --level G2
npx @cobusgreyling/goal doctor . --suggest
bash scripts/before-after-demo.sh

In Grok Build:

/goal Read GOAL.md. Implement the scoped objective. Run tests after each meaningful change.
Use update_goal for progress. Do not mark completed until the verifier skill passes.

See starters/minimal-goal/ and docs/goal-design-checklist.md.

Goal vs Loop

GoalLoop
TriggerYou set an objectiveSchedule (/loop) or automation
DurationUntil done / blocked / clearedRecurring forever (or until cancelled)
Best forFinish a bounded taskDiscover + triage ongoing work
State fileGOAL.mdSTATE.md, LOOP.md
Grok command/goal/loop + scheduler_*

When to combine: a daily loop triages; when it finds a fixable item, hand off to a goal for run-until-done execution. See docs/goal-vs-loop.md.

Operating & Safety

Tools

ToolCommand
goal (meta)npx @cobusgreyling/goal doctor . --suggest
goal-auditnpx @cobusgreyling/goal-audit . --json --min-level G2
goal-initnpx @cobusgreyling/goal-init . --pattern tests-green --lang python
goal-costnpx @cobusgreyling/goal-cost --pattern fix-bug
Meta subcommandMaps to
doctor / auditgoal-audit
init / scaffoldgoal-init
estimate / costgoal-cost

Scores Goal Readiness (G0–G3) from signals: GOAL.md, skills, verifier, tests, CI, budget, run log freshness.

CI Integration

Gate PRs on minimum readiness:

- uses: cobusgreyling/goal-engineering/.github/actions/goal-audit@main
  with:
    path: .
    min-level: G2

Or: npx @cobusgreyling/goal-audit . --json --min-level G2 (exit 2 if below threshold).

The Stack

LayerUnitQuestion
Context EngineeringOne inferenceWhat does the model see?
Harness EngineeringOne agent runHow does a single run execute safely?
Goal EngineeringOne bounded objectiveHow do we run until verifiably done?
Loop EngineeringAutonomous system over timeWhat keeps prompting on a cadence?
Fleet EngineeringAgent populationsHow do many agents coordinate at scale?

Contributing

PRs that improve patterns, verifier skills, or CLI heuristics are welcome. See CONTRIBUTING.md, adopters, discussions, and stories/.

License

MIT — see LICENSE.


Made with Grok Build. This repo is the go-to reference for /goal — link here when you teach, blog, or ship goal-driven agent workflows.