sarvesh.
Blogs

From Prompt Engineering to Goal Engineering

I have had a single GPT-5.6 Sol /goals run building Power Atlas for more than 48 hours.

During that run, Codex has researched official sources, reconciled conflicting data, written ingestion pipelines, improved the interface, tested mobile layouts, published releases, audited its own coverage, and moved on to the next gap.

The biggest lesson was surprisingly simple:

The quality of the goal matters more than the quality of any individual prompt.

Prompt engineering is for answers. Goal engineering is for autonomous work.

A normal prompt asks the model to complete a task:

Build a map of power plants.

A goal defines how the agent should operate over time:

Build the most comprehensive and accurate infrastructure atlas possible. Continuously audit missing coverage, prioritize the highest-value gap, research authoritative sources, implement it, verify the product, publish a release, and repeat.

That difference matters.

A prompt produces an output. A goal creates a continuing decision-making loop.

I now think of goal engineering as the practice of defining:

  • what success looks like
  • how work should be prioritized
  • which principles must never be violated
  • how progress should be tested
  • what the agent should do when blocked
  • when it should continue
  • what “finished” actually means

The goal becomes the agent’s operating system

The original Power Atlas goal was intentionally durable:

Build the most comprehensive, accurate, and useful map of the physical infrastructure that powers, computes, and connects the world.

Everything else followed from that north star.

The goal also included permanent rules:

  • never invent coordinates
  • preserve source provenance and uncertainty
  • keep operating, construction, approved, proposed, cancelled, and retired projects distinct
  • never double-count shared capacity
  • do not present partial coverage as complete
  • test every release on desktop and mobile
  • continue after every dataset, country, or deployment

These rules proved more valuable than detailed instructions for any single feature. They helped Codex make good decisions in situations I had never anticipated.

Do not constantly rewrite the mission

One of my most important lessons was learning to separate the durable goal from the immediate priority.

When the application became slow, I did not replace the entire goal with a performance specification.

I added a temporary priority:

Before expanding coverage further, profile and improve map performance, publish and verify the upgrade, then resume the broader goal.

We used the same method when:

  • submarine cables broke at the edge of the world map
  • country views collapsed into giant clusters
  • explanatory cards covered the map
  • statistics became confusing
  • the application needed better mobile behavior

The pattern is:

Preserve the mission. Update the current priority.

This prevents the agent from drifting every time the product needs a correction.

Why two people can get very different results from the same model

My wife, Sunidhi, could ask the same model to build an application and receive something much more generic.

The difference is rarely just the framework or model. It is often the amount of product taste encoded into the goal.

“Build a clean website” leaves almost everything undefined.

A stronger goal explains what “clean” means:

  • the primary content should dominate the screen
  • controls should float over low-information areas
  • use cards and overlays instead of dense grids and borders
  • avoid unnecessary horizontal and vertical divider lines
  • use clear visual hierarchy and generous spacing
  • expose explanations through small tooltips rather than persistent panels
  • use subtle micro-interactions to communicate selection and state changes
  • make mobile a first-class experience rather than a compressed desktop layout

The stack can help, but the stack alone does not create taste.

For modern web applications, a useful default is:

  • Next.js
  • TypeScript
  • Tailwind CSS
  • shadcn/ui
  • Framer Motion for restrained, purposeful micro-interactions

Framer Motion should not animate everything. It should make transitions, drawers, hover states, loading changes, and selection feel intentional.

The goal should encode taste without prescribing pixels

Many disappointing AI-built products are technically functional. They simply lack product judgment.

“Make it modern” is too vague. But specifying every component, animation, and spacing value turns the goal into brittle micromanagement.

The better approach is to encode principles:

  • primary content should dominate
  • the first screen should reveal the product’s value
  • explanations should not obscure the interface
  • overview and detail states should reveal information progressively
  • connected information should remain visually continuous
  • labels should make sense to first-time users
  • desktop and mobile interactions should be intentionally designed
  • performance should be measured, not assumed

Then let the agent decide whether the right answer is a tooltip, drawer, bottom sheet, canvas layer, vector tile, or something else.

Hardcode what must be true. Leave room for the agent to decide how to make it true.

That may be one of the most important lessons from the entire run.

Protect the product from agent drift

Long-running agents can sometimes over-refactor, delete working behavior, or optimize one area while damaging another.

The goal should include explicit safeguards:

  • preserve existing working behavior unless a change is necessary
  • inspect the current implementation before rewriting it
  • make incremental, reversible changes
  • commit durable checkpoints
  • never delete data or functionality merely to simplify an implementation
  • compare before-and-after behavior
  • run regression tests after every meaningful change
  • verify the published product, not only the local build
  • document anything intentionally removed or changed

The agent should be allowed to improve the architecture, but not to casually replace proven behavior.

Performance should be expressed as an outcome

It is tempting to say:

Use WebGPU.

But that may prematurely constrain the solution.

A better goal says:

Profile loading, parsing, rendering, memory, and interaction bottlenecks in Chrome. Optimize based on measured results. Keep the map responsive as the dataset grows.

Then provide likely techniques without making them mandatory:

  • GPU-backed map layers instead of thousands of DOM markers
  • vector tiles or chunked datasets
  • viewport-based loading
  • progressive detail by zoom level
  • lazy-loaded inspectors
  • web workers
  • caching and compression
  • stable layer references to avoid unnecessary rerenders

The requirement is not a specific technology.

The requirement is that the product feels fast.

A reusable Codex goal for polished web applications

Build and continuously improve a production-quality web application.

Use Next.js, TypeScript, Tailwind CSS, shadcn/ui, and restrained Framer Motion micro-interactions where they improve clarity.

Start by understanding the product, its users, the current implementation, and the most important user journey. Preserve working behavior and make incremental, reversible improvements rather than rewriting functional parts unnecessarily.

PRODUCT EXPERIENCE

Create a clean, modern, responsive interface with strong visual hierarchy.

- Make the primary content dominate the screen
- Use whitespace, cards, overlays, drawers, and bottom sheets instead of excessive borders or divider lines
- Keep controls compact and place them where they do not obscure important content
- Use clear, self-explanatory labels
- Use small tooltips for secondary explanations
- Add subtle hover, selection, loading, and transition states
- Make desktop and mobile intentionally designed experiences
- Avoid generic dashboard layouts unless the product genuinely requires one

PRODUCT JUDGMENT AND INTERACTION QUALITY

Use strong product and design judgment rather than mechanically implementing isolated requirements.

Before making changes:

- Inspect the existing product and understand its primary user journey
- Identify what should attract attention first
- Preserve working behavior and established strengths
- Distinguish the underlying problem from one suggested implementation
- Prefer incremental, reversible improvements over unnecessary rewrites

Optimize the experience around these principles:

- The product’s value should be understandable within the first few seconds
- Primary content should dominate; controls and explanations should support it without obscuring it
- Default states should demonstrate the product’s value rather than appear empty, overly filtered, or generic
- Use progressive disclosure: show the right amount of information at overview, intermediate, and detailed states
- Preserve continuity across navigation, scrolling, pagination, maps, timelines, graphs, and connected records
- Use aggregation only when it improves comprehension; reveal individual detail as space and context permit
- Use clear user-facing language rather than internal terminology
- Make equivalent interactions work appropriately across mouse, keyboard, and touch devices
- Handle loading, empty, error, dense-data, long-content, slow-network, and small-screen states deliberately
- Keep statistics, labels, units, and relationships unambiguous
- Use restrained motion and micro-interactions to explain state changes, hierarchy, and selection—not as decoration
- Maintain accessibility, responsive behavior, URL state, browser navigation, and reduced-motion support

Treat specific examples in the goal as signals of broader product principles. Inspect the rest of the application for similar issues and solve them consistently.

Be precise about outcomes and guardrails, but choose the best implementation based on the current architecture, measured performance, and user experience. If a suggested technique is inappropriate, use a better equivalent and document the reasoning.

After each meaningful change, compare the experience before and after, verify that existing functionality was preserved, and test the primary journey on desktop and mobile.

PERFORMANCE

Profile performance in Chrome before changing architecture.

- Avoid loading unnecessary data upfront
- Use progressive loading and rendering
- Lazy-load secondary content
- Avoid thousands of DOM elements where GPU or canvas rendering is more appropriate
- Prevent unrelated UI changes from rerendering expensive components
- Use caching, compression, code splitting, and web workers where beneficial
- Keep interactions smooth and the interface responsive

AUTONOMOUS LOOP

Continuously:

1. Audit the current product
2. Identify the highest-impact improvement
3. Research or inspect what is needed
4. Implement the improvement
5. Run build, lint, tests, and regression checks
6. Verify the real user experience on desktop and mobile
7. Publish a durable checkpoint
8. Re-audit and repeat

Do not stop after one feature, fix, or release while meaningful improvements remain.

ROBUSTNESS

- Preserve existing functionality unless its removal is explicitly justified
- Never delete working data or behavior merely to simplify the implementation
- Keep changes incremental and testable
- Commit durable checkpoints
- Maintain typed schemas and reproducible systems
- Check for browser-console errors, broken layouts, overflow, regressions, and accessibility issues
- If blocked, document the limitation and move to the next defensible improvement

Prioritize usefulness, clarity, performance, maintainability, and correctness over superficial complexity.

When the broader mission remains valid but a specific problem becomes urgent, treat it as an immediate priority, complete and verify it, then resume the durable goal.

Prompt, context, and goal engineering

Prompt engineering tells the model what to produce. Context engineering gives it what it needs to know. Goal engineering teaches it how to keep making good decisions.

And the core formula becomes:

North star + product principles + guardrails + autonomous loop + verification + room for judgment.

That is what turns a prompt from a task request into an operating system for a long-running agent.

The takeaway

The goal is not supposed to predict every task the agent will perform.

It should give the agent enough structure to make good decisions when new tasks appear.

A strong Codex goal needs:

  • a durable north star
  • clear priorities
  • product and design principles
  • non-negotiable guardrails
  • an autonomous improvement loop
  • verification requirements
  • a stopping condition

The biggest unlock in Codex is not discovering one perfect prompt.

It is learning to write a goal that can survive reality.

Vibe coding built the first version. Goal engineering kept it building for 48 hours.

Originally published on Field Notes.