Mikie / Guides

How to organize context for AI coding

Build better AI coding context with entry points, callers, tests, constraints, and handoffs. Includes a practical context packet and repair rules.

Technical guide7 min readUpdated
Select relevant code from a repository, then use it for a focused coding task.REPOSITORYFOCUSED TASK
Less to read. More to work with.

The quick answer

Organize context around the decision: include the goal, implementation, callers, tests, and constraints. Keep paths and anchors so changed facts can be refreshed. Expand the packet when a concrete dependency appears.

Choose context for the next decision

A response-field change and a timeout investigation need different source. State the behavior first, then choose code explaining it and constraints that can invalidate the patch.

For a response field, inspect builder, callers, schema, and tests. For a timeout, begin with the failing request, handler, and boundary where work stalls.

Choose context for the next decision: practical comparison
TaskFirst sources
API responseHandler, type, consumers, serialization test
UI interactionComponent, event handler, interaction test
Data bugFailing input, transformation, invariant test
RefactorPublic API, callers, behavior tests

Create an actionable packet

Use source anchors instead of an untraceable summary. Include known facts, constraints, and uncertainty. A summary guides a refresh; it does not replace changed source.

Example packet
Goal: optional displayName in profile responses.
Entry: profile handler and serializer.
Consumers: account menu and settings.
Constraint: older clients may omit displayName.
Verify: serializer tests and both UI states.
Unknown: whether another import exposes a second serializer; inspect if callers indicate it.

Keep invariants and necessary dependencies

Keep authorization, compatibility, and data invariants governing the change. Leave out old logs and unrelated architecture unless needed. A small packet missing a required invariant is expensive to repair.

  • Actual failure or desired behavior.
  • Implementation and relevant callers.
  • Tests defining expected behavior.
  • Permission and compatibility constraints.
  • Uncertain or stale facts identified.

Refresh changed facts and repair gaps

After an edit, refresh affected regions and dependencies. After a branch or configuration change, rebuild relevant context. If the agent changes the wrong layer, add the failing input's call path. If a consumer breaks, add its contract.

Use Mikie for focused context, then assess whether the selected lines support the task. Resolve demonstrated gaps before editing.

  • Important facts have sources.
  • Required callers and tests are present.
  • Code matches the current revision.
  • No credentials or private configuration values appear.
A focused follow-up
The serializer changed. Refresh it and its tests. Reuse client constraints unless current source contradicts them. Expand if the updated signature exposes another caller.

Put it into practice

  1. Define behavior and proof.
  2. Find entry point, callers, and tests.
  3. Create an anchored context packet.
  4. Refresh changed facts and concrete dependencies.
Where workflow changes make a difference
AreaWhat it meansWho controls it
SelectionInclude facts affecting this change.Your workflow
OrderingPut the goal and constraints first.Your workflow
FreshnessRefresh changed source and assumptions.Your workflow
DependenciesRelevant callers and invariants remain necessary.The provider or measurement
CapacityContext management stays within the model's window.The provider or measurement

How Mikie helps

Mikie compiles a bounded, line-anchored context packet through local MCP tools. Inspect selected sources and request focused follow-ups for gaps. Current source and verification remain the authority.

See the setup and workflow →

Sources

  • OpenAI ↗

    Goals, relevant context, output requirements, and task boundaries.

  • Anthropic ↗

    What occupies a context window and why cached context still occupies it.

  • Anthropic ↗

    Verification, focused sessions, /clear, and /compact.

Provider plans and prices can change. Source dates show when this guide was checked. How Mikie measures results.

Common questions

Should I paste the entire repository?

Start with relevant code and constraints. Expand for real dependencies; a complete packet can be smaller than a repository dump.

What is a context packet?

A focused set of task facts, source anchors, constraints, and checks for the next coding decision.

When should context be refreshed?

When relevant source, branch, configuration, or assumptions change. A handoff is guidance rather than proof of current code.

Put better context to work.

Keep your coding agent. Give it a clearer view of the code it needs.

Set up Mikie →