how-to-code
How To Code
Use this guide to write code with strong engineering taste: small core, explicit lifecycle boundaries, durable facts, extensible edges, dependency-light packages, and docs that explain how the system behaves under pressure.
This skill is distilled from a coding agent harness codebase, but the target is general software design and down-to-earth handwritten code touching the architectural heavens. Apply the principles to your domain instead of copying the product vocabulary.
How To Use The Examples
Treat every concrete name and code as an example of a transferable pattern. Copy the shape, not the nouns. If an example mentions specifics like sessions, providers, tools, context builders, terminal UI, or model streams, translate it into the equivalent boundary in your project: documents, jobs, plugins, imports, renderers, services, workflows, or whatever your domain actually owns.
The Taste
Build a small core that owns real invariants.
Do not keep adding built-ins because a workflow is useful. Put project-specific or preference-heavy workflows behind extension points, plugins, configuration, external tools, or plain files. The core should be small enough that its correctness model fits in your head.
Make state reconstructable.
Persist facts. Derive views. Prefer records with explicit identifiers and parent links over hidden mutable side channels. One example: conversation history is stored as durable entries such as message, model change, compaction, branch summary, label, and custom extension data; a context builder walks from a leaf back to root and derives the model-facing view. Generalize that into your own durable records and derived projections.