GOALMD(5)GOALMD(5)

NAME

GOAL.md — instruction file for Claude Code

SYNOPSIS

./

METADATA

FORMATMarkdown
FILENAMEGOAL.md
CASE SENSITIVEYes
TOOLClaude Code
ENCODINGUTF-8
GIT COMMITTEDYes

DESCRIPTION

GOAL.md is a file format for directing autonomous AI agent optimization loops. Inspired by Andrej Karpathy's autoresearch pattern, it provides a structured way to define what an agent should optimize, how to measure success, and what actions it can take.

Unlike CLAUDE.md (which is instructional — describing how to work in a codebase), GOAL.md is directive and metric-driven. It defines fitness functions with quantitative targets, improvement loops with explicit iteration strategies, and action catalogs that constrain the agent's search space.

The core pattern is: observe metrics, hypothesize a change, implement it, measure the result, and decide whether to keep or revert. This creates a feedback loop that allows an agent to make incremental progress toward a measurable goal without human intervention at each step.

GOAL.md is particularly useful for optimization tasks (performance tuning, bundle size reduction, test coverage improvement) where the objective is clear and measurable but the path to get there requires experimentation. The action catalog prevents the agent from taking unbounded risks, while the fitness functions ensure every change is evaluated objectively.

The format is designed to be committed to version control alongside CLAUDE.md, creating a complete agent configuration: CLAUDE.md provides the working context, GOAL.md provides the optimization target.

STRUCTURE

├──ObjectiveREQUIRED
A concise statement of the high-level goal the agent is optimizing toward. Should be measurable and falsifiable, not aspirational.
├──Fitness FunctionsREQUIRED
Quantitative metrics that define success. Each fitness function has a name, measurement method, target value, and current baseline. The agent uses these to evaluate whether its actions are improving the system.
├──Improvement LoopsREQUIRED
The iteration cycle the agent follows: observe metrics, hypothesize changes, implement, measure results, decide whether to keep or revert. Defines loop frequency, stopping conditions, and rollback criteria.
├──Action Catalog
An enumerated list of actions the agent is permitted to take. Each action has preconditions, expected effects, and risk level. Constrains the agent's search space to safe, productive operations.
└──Metrics Dashboard
Instructions for how and where to record progress. Can reference log files, tracking tables in the GOAL.md itself, or external systems. Provides the agent with a feedback loop.

ANNOTATED EXAMPLE

GOAL.md
markdown
1# GOAL.md — Autonomous Optimization Target
2
3## Objective
4Reduce cold-start latency of the API server to under 200ms
5while maintaining 100% test pass rate.
6
7## Fitness Functions
8
9| Metric              | Baseline | Target  | Measurement                        |
10|---------------------|----------|---------|------------------------------------|
11| Cold-start latency  | 450ms    | <200ms  | `time node dist/server.js`         |
12| Bundle size         | 2.4MB    | <1.5MB  | `du -sh dist/`                     |
13| Test pass rate      | 100%     | 100%    | `npm test -- --reporter=json`      |
14| Import count        | 47       | <30     | `grep -c "^import" src/server.ts`  |
15
16## Improvement Loop
17
181. **Observe**: Run all fitness function measurements
192. **Hypothesize**: Identify the largest contributor to cold-start time
203. **Implement**: Make ONE targeted change (lazy import, tree-shake, etc.)
214. **Measure**: Re-run fitness functions
225. **Decide**:
23   - If latency improved AND tests pass → commit and continue
24   - If tests fail → revert immediately
25   - If latency unchanged after 3 attempts on same target → move to next
26
27**Stop when**: All targets met, OR 10 iterations completed.
28
29## Action Catalog
30
31| Action                    | Risk   | Precondition                  |
32|---------------------------|--------|-------------------------------|
33| Convert static import → dynamic | Low    | Module not used at startup     |
34| Remove unused dependency  | Low    | No import references found     |
35| Replace heavy lib with lighter alt | Medium | Equivalent API coverage     |
36| Refactor module structure | Medium | Tests cover affected code      |
37| Modify build config       | High   | Snapshot current config first  |
38
39## Progress Log
40
41| Iteration | Change                          | Latency | Tests | Status |
42|-----------|---------------------------------|---------|-------|--------|
43| 0         | Baseline                        | 450ms   | PASS  | —      |

COMMON MISTAKES

Gotchas
WRONG Using GOAL.md as a replacement for CLAUDE.md
RIGHT GOAL.md complements CLAUDE.md — use both together

CLAUDE.md provides instructional context (code style, architecture, commands). GOAL.md provides directive context (what to optimize, how to measure success). They serve different purposes: CLAUDE.md tells the agent how to work; GOAL.md tells it what to achieve.

WRONG Defining vague goals like 'improve code quality'
RIGHT Use specific, measurable fitness functions: 'reduce p95 latency from 450ms to under 200ms'

Autonomous loops need quantitative feedback to function. Without measurable targets, the agent cannot evaluate whether its changes are improvements. Every fitness function should have a number, a measurement method, and a target.

WRONG Omitting rollback criteria from improvement loops
RIGHT Always define when to revert: 'if test failures increase by >5%, revert and try a different approach'

Without explicit rollback conditions, an autonomous agent can compound bad changes across iterations. Each improvement loop should specify what constitutes a failed experiment and how to recover.

WRONG Giving the agent an unbounded action catalog
RIGHT Enumerate permitted actions explicitly with risk levels

An open-ended action space is dangerous in autonomous loops. The action catalog constrains what the agent can try, preventing it from making risky changes (deleting files, changing APIs) without explicit permission.

USED BY

SIMILAR FILES

CLAUDE.mdClaude Memory File

COMPARISONS

agentconfig.ing2026-03-17GOALMD(5)