AGENTUPDATE JOURNAL

1000usdinchina.com Dev Retrospective (5) - Claude Code Workflow: Prompt, Context, Harness, Loop

1000usdinchina.com Dev Retrospective (5) - Claude Code Workflow: Prompt, Context, Harness, Loop
Table of Contents

I shipped a 100-city, four-language travel app — 1000usdinchina.com — solo. The leverage wasn't "the AI wrote my code." It was treating an AI coding agent (Claude Code) as a system to be engineered across four disciplines: prompt, context, harness, and loop engineering. This is the flagship post of the series and the one most worth your time if you build with coding agents.

The four disciplines of a Claude Code workflow — prompt, context, harness, and loop engineering

Table of contents

The four disciplines

A coding agent is not a chatbot you ask for snippets. It's an autonomous system that reads, edits, runs, and verifies. Reliability comes from engineering four layers:

flowchart TB
    P[Prompt engineering
what to do] --> C[Context engineering
what the agent knows] C --> H[Harness engineering
what the agent can do] H --> L[Loop engineering
how it iterates to done] L -->|feeds back| C

Skip any one and the agent gets unreliable: vague prompts wander, missing context hallucinates, a weak harness can't verify, and no loop means no convergence.

1. Prompt engineering: say what, not how

The first lesson: instructions say WHAT, not HOW. "Add a family-cost rule" is a goal, not a procedure. The agent owns the procedure. Over-specifying how fights the agent's planning; under-specifying what lets it drift. Good prompts pin the intent and the acceptance criteria, and leave the implementation to the agent — then verify the result.

The corollary, learned the hard way: a "yes, do X" is not a license to start typing code. For anything non-trivial, the agent should plan first, document the plan, and only then build on an explicit implementation verb. Prompt engineering is as much about restraint as instruction.

2. Context engineering: the agent's working memory

This is where most of the leverage lives. An agent is only as good as what's in its context window. Four mechanisms keep that context high-signal:

  • A project constitution (CLAUDE.md). Hard constraints live in one always-loaded file: "TypeScript strict, no any", "edge runtime — no Node APIs", "never commit unless asked", "internal docs in Chinese, UI + code in English." These override default behavior every turn.

    ## Hard constraints (violating = bug)
    1. TypeScript strict + no `any`
    2. Edge runtime — no fs/path/child_process
    3. i18n currency hard-coupling (en→USD, ja→JPY...)
    4. never commit unless explicitly asked
    
  • Persistent memory. Facts that should survive across sessions (decisions, gotchas, the state of a half-finished task) are written to durable memory files, not re-derived each time.

  • Deliberate compaction. Context doesn't auto-compress at a useful threshold, so I compact manually at a clean breakpoint (~60% full) to keep summaries high-quality, before the harness is forced to auto-compact late.

  • Subagent isolation. A noisy operation — a full test run, a build with hundreds of static routes — is handed to a subagent that reads the firehose in its own context and returns only {ok, errors:[...]}. The main context never sees the 268-route build log.

flowchart LR
    M[Main agent context
high-signal] -->|delegate noisy job| S[Subagent context] S -->|reads full output| Logs[(build/test firehose)] S -->|returns summary only| M

Context engineering is the difference between an agent that stays sharp over a long session and one that drowns in its own tool output.

3. Harness engineering: tools, permissions, subagents

The harness is everything the agent can do: its tools, permission boundaries, hooks, and the deploy pipeline it drives. Engineering it well means:

  • A staged pipeline the agent operates. Local → dev worker → prod, green before advancing. The agent runs each stage; gates (tests, Lighthouse CI) decide promotion. (Full detail in post 7 on testing & DevOps.)
  • Permission-aware actions. Some actions are irreversible or outward-facing (commits, pushes, deploys). The harness requires explicit authorization — the agent never commits or ships on its own initiative.
  • Subagents as workers. Beyond context isolation, subagents parallelize independent work and run long jobs in the background, reporting back structured results.

The mental model: you design the harness; the agent operates within it. A good harness makes the safe path the easy path.

4. Loop engineering: iterate to done

Agents shine in loops: do → observe → correct → repeat until a condition holds. The art is defining the exit condition and keeping each iteration cheap.

The concrete example from this project is the four-language i18n translation loop. Translating a growing app into four languages isn't a one-shot prompt — it's a loop:

flowchart TD
    A[Scan UI for untranslated strings] --> B{Any found?}
    B -->|yes| C[Translate into 4 locales, currency-aware]
    C --> D[Run i18n smoke + lint]
    D --> E{Green?}
    E -->|no| C
    E -->|yes| A
    B -->|no| F[Done: all locales in sync]

Each pass finds untranslated strings, fills all four locales (respecting currency coupling), runs the i18n smoke tests, and repeats until a scan comes back empty. A self-paced agent loop turns "translate the whole app" — a task no single prompt completes — into a convergent process. That's loop engineering: not one big ask, but a cheap step plus a crisp exit condition, run until done.

Superpowers skills: reusable expertise

The glue across all four disciplines is skills — packaged, reusable procedures the agent loads on demand. Instead of re-explaining "how we do TDD" or "how we validate the ETL" every session, that expertise lives in a skill the agent invokes:

  • General process skills: brainstorming (before any feature), test-driven-development, systematic-debugging, subagent-driven-development.
  • Project-specific skills: validate the ETL output, add a new city, add a new locale (with the currency + zero-decimal checks baked in), and the deploy procedure.

Skills are how a coding agent accumulates institutional knowledge. A new session starts already knowing the project's disciplines — because they're encoded, not remembered.

Key takeaways

  • Treat a coding agent as a system engineered across four layers: prompt, context, harness, loop.
  • Prompts say what and the acceptance criteria; the agent owns how. Restraint matters.
  • Context is the real leverage: a project constitution, persistent memory, deliberate compaction, and subagent isolation keep it high-signal.
  • The harness defines what's safe and easy; the agent operates within it and never ships unauthorized.
  • Loop engineering turns unbounded tasks (like translating into four languages) into convergent processes with a clear exit condition.
  • Skills encode reusable expertise so each session starts smart.

FAQ

What is context engineering for AI coding agents? The practice of curating what's in the agent's context window — via a project constitution, persistent memory, deliberate compaction, and offloading noisy output to subagents — so the agent stays accurate over long sessions.

What is harness engineering? Designing the tools, permissions, hooks, and pipeline the agent operates within, so the safe path (tested, gated, authorized deploys) is also the easy path.

What is loop engineering? Structuring work as a cheap repeated step plus a crisp exit condition — e.g. "find and translate untranslated strings until a scan returns none" — so the agent converges on done.

Can one person ship a real app with Claude Code? Yes. This 100-city, four-language app was built solo by engineering the agent across these four disciplines, not by asking it for one-off snippets.


Next → Building an LLM trip-planner on a free tier: Qwen + Cloudflare Workers AI