How I One-Shot Coding Projects with Pharaoh

Kyle · · 23 min read
One-shot coding with Pharaoh for complete projects

One-shot coding with Pharaoh isn’t “write it and pray.” On a multi-module repo, agents usually grab fragments, miss callers, and produce a clean-looking diff that quietly duplicates logic or breaks a path you didn’t inspect.

Start with the map, then read the source it points to. You need a tight change boundary, real production callers, and tests that prove the wiring—not just a helper that passes alone. Watch for:

  • stale default-branch maps versus local changes
  • existing behavior hiding under another module
  • entry points your agent never opened

Make the first diff worth reviewing.

What One-Shot Coding With Pharaoh Actually Means

One-shot coding with Pharaoh doesn't mean perfect code on the first try. It means your first pass is serious work, not a lottery ticket.

When we say "one-shot," we mean you prepare one implementation request so well that your agent can produce a strong first diff with the right tests and a reviewable scope. You are not trying to remove iteration. You are trying to remove dumb iteration.

The target brief already contains:

  • acceptance criteria
  • constraints
  • reuse boundaries
  • affected callers
  • verification steps

That changes the emotional texture of the work. A lot of AI-assisted coding has this low hum of doubt under it. The code might compile. It might even look clean. But you still wonder what it quietly broke. A map-first workflow replaces that dread with something calmer. Not certainty. Orientation.

Here's the workflow in one line:

acceptance criteria -> map the repo -> inspect source -> brief the agent -> implement -> test -> review

For larger repositories, this is one of the most practical efficient coding techniques we've found because it treats missing context as the real problem. Most "prompting problems" are just visibility problems wearing a fake mustache.

Why the First Pass Usually Fails on Real Repositories

The first pass usually fails because the agent is reading fragments and inventing the rest.

That's the whole issue.

It sees a helper, a controller, maybe a test, then guesses the architecture around them. The result is often plausible code that ignores a production caller, duplicates behavior that already exists, or changes a function without noticing three paths depend on its current shape.

Native search still matters. We use it all the time for reading implementations, finding local edits, and checking string references. But search is weak on relationship questions. "Where is this symbol defined?" is easy. "Which production path reaches this function?" is where grep starts shrugging.

A selected repository pack has its place too. If another tool needs a portable source snapshot, a curated pack is useful. But don't confuse "I selected these files" with "these files contain the whole truth." They often don't.

This is where Pharaoh earns its keep. Pharaoh maps modules, functions, dependencies, callers, entry points, blast radius, and dead code so your coding agent can ask structure-first questions before it edits anything. On mapped repos, that structural view is usually the missing ingredient behind improving coding speed with Pharaoh.

A blunt way to say it: great AI-assisted development is often a visibility problem before it is a prompting problem.

A Benchmark Result That Explains the Map-First Bet

The map-first idea is not just a preference for a different tool. In a 30-task benchmark of a FastAPI RealWorld application, researchers compared an MCP graph-navigation tool with vanilla Claude Code and BM25-augmented retrieval across 258 completed trials.

The sharpest result came from tasks with hidden architectural dependencies: files connected through the codebase structure but not easily surfaced by keywords or vector retrieval. On that group, graph navigation reported 99.4% ACS, compared with 76.2% for vanilla Claude Code and 78.2% for BM25 retrieval. That is a 23.2-percentage-point improvement over the vanilla condition and a 21.2-point improvement over BM25.

There is an important catch: the graph tool was invoked in only 42.0% of its assigned trials. When it was used, mean ACS was 99.5%; when the agent skipped it despite an instruction to use it, mean ACS was 80.2%. The lesson for this workflow is practical: structural context is most useful when the task actually requires it—and when the agent is explicitly made to fetch it before editing.

This was a preprint evaluating CodeCompass, not Pharaoh, on one benchmark application. It is evidence for the general map-first premise, not a performance claim about Pharaoh or a guarantee for every repository.

Extending a Mapped Repository Is Not the Same as Starting Greenfield

This workflow is strongest when you're extending an existing repository Pharaoh has already mapped.

Greenfield is different. If the system barely exists, there's not much architecture to query yet. Your first move isn't graph analysis. It's deciding folder shape, naming, interfaces, boundaries, and a small instruction file that keeps the agent from spraying logic across random files.

So use the Pharaoh project workflow where it fits:

  • extending an existing service
  • changing a shared module
  • tracing impact before a signature change
  • checking whether behavior already exists in another part of the repo

For brand-new work, start simpler:

  • define conventions
  • create a narrow initial layout
  • write a short instruction file
  • keep the first pass small enough to inspect quickly

There's another practical limit worth stating plainly. Pharaoh's interactive map reflects pushed code on the default branch. It does not see your uncommitted changes, worktrees, or unmerged branches through that map. If your checkout has drifted, don't act like the graph is your local truth. It isn't.

On setup, map the repo first and confirm it's ready. The first map often takes around 1 to 5 minutes, and large repositories can take up to 15. That sounds minor until someone asks the agent for structural answers against a repo that hasn't finished mapping yet. Then the whole workflow starts with false confidence, which is worse than no confidence.

Start With Acceptance Criteria and Non-Negotiable Constraints

Before you open the graph, define the task.

Not vaguely. Not "add support for X." That's how you get vague code.

At minimum, your brief should answer these:

  • What user-visible behavior changes?
  • What interface is touched?
  • What must stay the same?
  • Are there performance or security constraints?
  • How should errors behave?
  • What is explicitly out of scope?
  • If this goes wrong, what gets rolled back?

This is project management for developers at the ticket level. Not corporate ceremony. Just enough definition so the agent isn't forced to make product and architecture decisions on your behalf.

Sharp constraints make agents behave better. Good examples:

  • Reuse the existing payments module. Do not create a new shared abstraction unless the current module cannot support the change.
  • Leave public function signatures unchanged unless a caller update is explicitly listed.
  • Avoid schema changes.
  • Keep the change inside these two modules unless source evidence forces a wider edit.

That last point matters more than people think. Speed comes from smaller decision surfaces, not from typing faster. If you want tips for quick coding success, start there. Narrow the space. Force the tradeoffs into the open.

This is the rule that makes the whole workflow work:

In mapped repositories, ask Pharaoh where the relevant code is, what calls it, and whether what you need already exists before searching or reading files.

Start with get_codebase_map. Use it to identify the right repository or module and confirm map freshness. If the map is stale or doesn't match the work you intend to do, your confidence level should drop immediately.

Then ask plain questions that map to structural facts:

  • Which module owns this behavior?
  • Which files define it?
  • What depends on it?
  • Which production entry points reach it?
  • Is there already a similar implementation elsewhere?

For risky edits, get_blast_radius matters a lot. Use it before changing a function signature, removing a helper, or moving logic between modules. Ask for direct and indirect production callers and entry points. Group them separately. That one distinction saves review time because direct callers often need edits, while indirect callers change your risk picture.

If the work smells like "new logic," check whether it's actually old logic hiding in another path. get_unused_code can help surface unreachable code, but treat it as a prompt to inspect source, not a verdict from heaven. Framework loading, plugins, and public exports can look unused when they aren't.

Also pay attention to returned limits, incomplete analysis signals, and freshness mismatches. Experienced operators don't just read the answer. They read the confidence conditions around the answer.

ToolBest used forAsk forConfidence checks
get_codebase_mapStart every mapped-repo investigation by locating the right repository or module.The relevant repository or module and the map freshness information.If the map is stale or does not match the work you intend to do, lower confidence immediately.
get_blast_radiusRisky edits such as changing a function signature, removing a helper, or moving logic between modules.Direct and indirect production callers plus entry points, grouped separately.Read returned limits and incomplete analysis signals, then inspect source before editing.
get_unused_codeCheck whether supposed new logic is really old logic hiding on another path, or whether code only appears unreachable.Unreachable-code candidates and their reachability evidence so you can inspect the source.Treat the result as a prompt, not a verdict; framework loading, plugins, and public exports can look unused.

Inspect the Returned Files and Verify What Already Exists

Pharaoh gets you to the right files faster. Source still decides behavior.

Open the defining function. Open the relevant callers. Open the nearby tests in your current checkout. Then verify the things agents routinely get wrong:

  • argument assumptions
  • return values
  • permission checks
  • side effects
  • failure handling
  • whether similar logic already exists under another helper name

This is where one-shot coding with Pharaoh stays grounded. The graph tells you relationships. The source tells you what the code actually does.

One subtle mistake shows up all the time: production caller analysis is not test coverage. A function can have a clear runtime path and still have weak tests. The reverse is also common. A helper can have lots of unit tests and still not be wired into a real entry point.

String-based references, mocks, and config also need separate search. Rename safety is not the same thing as reachability. If you skip that distinction, the agent can produce a diff that is structurally tidy and still broken in ways the graph could never prove.

Build a Focused Implementation Brief for the Agent

Once you've checked the map and read the source, give the agent a brief that defines the safe operating area.

A strong implementation brief usually includes:

  • exact acceptance criteria
  • likely files to touch
  • modules to reuse
  • callers that may need updates
  • tests to add or run
  • explicit non-goals
  • commands for verification

Name reuse boundaries directly. If you don't, the agent may invent a parallel abstraction because it sees a local pattern and assumes it should generalize it. That's how small feature work turns into a cleanup project nobody asked for.

Ask for the smallest change set first. In multi-module codebases, small edits beat wide refactors unless the current shape is truly blocking the work.

A practical brief sounds like this:

Reuse the existing webhook parsing path in payments. Do not add a new payment rule engine. Update affected callers only if the current helper cannot express the behavior. Add or adjust tests around webhook handling and run the targeted payments test suite plus type checks.

That is one of the most useful coding tools for productivity habits: not the agent itself, but the discipline of briefing it precisely enough that it can't wander.

A Copyable Prompt and the One Line for AGENTS.md

Here's a copyable prompt you can adapt for Claude Code, Cursor, Codex, or another MCP client. It's intentionally plain.

Use Pharaoh first.

1. Use get_codebase_map to identify the relevant repository or module for this task.
Report the map freshness information and flag any mismatch or uncertainty
between the mapped default branch and the source I am about to change.

2. Before editing, tell me:
- whether this behavior already exists
- where the relevant code lives
- what calls it directly and indirectly
- which production entry points reach it
If the change is risky, use get_blast_radius and separate direct callers
from indirect callers. Note any returned limits or incomplete analysis.

3. Inspect the returned files in source before proposing edits.
Summarize the current implementation, nearby tests, and any string-based,
config, or mock references that still need separate search.

4. Implement this task with the smallest change set that satisfies the brief:
[acceptance criteria]
[constraints]
[reuse boundaries]
[expected caller impact]
[tests to add or update]
[commands to run]

5. After coding, provide:
- a short diff summary
- verification results
- any remaining uncertainty
- anything you chose not to change and why

And this is the AGENTS.md line we recommend adding exactly as written:

In repos Pharaoh has mapped, before searching or reading files, ask Pharaoh where the relevant code is, what calls it, and whether what you need already exists.

That one line matters because it changes the default behavior from grep-first to map-first. Small instruction. Big correction.

Illustrative Example: Extending a Mapped Payments Module

This example is illustrative. It's here to show the workflow, not to document a real project outcome.

Say your mapped repository has a payments module with functions like:

  • createPayment
  • handleWebhook
  • getSubscription
  • cancelSubscription

The task: adjust webhook handling to recognize a new event state without breaking subscription logic or duplicating existing payment rules.

Start with the brief:

  • Accept the new webhook state in handleWebhook
  • Reuse current subscription lookup behavior if it already covers the case
  • Do not change public subscription APIs unless source evidence forces it
  • Do not introduce a second payment-status mapping helper
  • Add or update tests around webhook processing and subscription effects

Then go map-first.

Research flow

  1. Confirm module

    Use get_codebase_map to confirm the payments module and check freshness.

  2. Trace reachability

    Ask what calls handleWebhook, what depends on it, and which entry points reach it.

  3. Find prior art

    Ask whether similar status-mapping logic already exists in payments or a shared module.

  4. Inspect source

    Inspect the returned files and relevant callers in source.

  5. Draft brief

    Build the implementation brief for the agent.

A useful brief for the agent might say:

Reuse existing status normalization if present. Keep edits inside payments
unless a confirmed caller requires a change. Inspect handleWebhook, its
direct callers, and tests first. Update affected callers only if needed.
Do not create a parallel webhook translation helper.

That last sentence is doing real work. Duplicate helpers are one of the easiest ways to fake progress in AI-assisted coding.

One-shot coding with Pharaoh: extending a mapped payments module

Review the Diff Like a Surgeon, Not a Spectator

The first implementation only matters if the diff respects the brief and the repository's existing shape.

When you review, check for a few things with real suspicion:

  • Did the agent reuse existing code?
  • Did it touch only the expected modules?
  • Did it update affected callers?
  • Did it preserve contracts?
  • Did it avoid creating duplicate helpers or sideways abstractions?

Then run the normal verification layer:

  • targeted tests
  • type checks
  • linting
  • any feature-specific commands your repo expects

If your team already uses PR Guard, it can add structural checks during review for unreachable exports, regression risk, test coverage gaps, and breaking changes. That's useful because most review tools catch mistakes after the wrong shape is already in the diff. Structural review is earlier. It asks whether the code belongs where it landed.

This is where confidence becomes earned. One-shot coding works when the map, the source, and the diff agree.

Where Iteration Still Belongs

Some work still needs more than one pass. That's normal.

Expect iteration when you have unclear requirements, stale maps, heavy local edits, cross-repo migrations, dynamic framework loading, or string-based wiring. Public library exports and plugin systems also need judgment because they can look unused when they are legitimate entry points.

Keep the branch scope in mind too. Pharaoh's map describes the default branch snapshot, not your hidden local state. If your checkout has moved ahead or sideways, slow down.

A healthy definition of success is simpler than people want it to be:

  • the first pass found the right files
  • respected the architecture
  • updated the right callers
  • passed the right checks

If that still needs a second pass, the workflow still worked. Improving coding speed with Pharaoh is mostly about cutting wrong turns, not forcing heroics.

Common Failure Modes That Break the Workflow

Most broken runs come from the same handful of mistakes.

  • Starting in "just build it" mode before defining acceptance criteria or reuse boundaries
  • Treating the mapped default branch like the exact current checkout
  • Using structural output to infer behavior without reading implementation and tests
  • Confusing production reachability with test coverage or rename safety
  • Adding a new helper before checking whether the behavior already exists
  • Letting the brief sprawl across unrelated subsystems
  • Ignoring incomplete analysis signals or freshness warnings

If you remember one thing, make it this: broad prompts create broad damage.

Conclusion

One-shot coding with Pharaoh works best when the agent starts with structure, not fragments, and when you still verify behavior in source and review. That's the whole method.

Define the change, ask Pharaoh first, inspect the source, brief the agent tightly, then review and test the result.

If you want a practical next step, add the AGENTS.md instruction and try this on one well-scoped feature in a mapped repository. Compare that first diff with your usual grep-first process. You don't need a dramatic win to notice the difference. Fewer wrong turns is enough.

Article Record

ReferencesPrimary sources used for this article
  1. The Navigation Paradox in Large-Context Agentic Coding: Graph-Structured Dependency Navigation Outperforms Retrieval in Architecture-Heavy TasksThanks: Code, benchmarks, and experimental infrastructure available at: https://github.com/tpaip607/research-codecompass
  2. Prometheus: Towards Long-Horizon Codebase Navigation for Repository-Level Problem SolvingThanks: ∗Equal contribution. †Corresponding author. Email: he.ye@ucl.ac.uk.
  3. How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoring
Update HistoryMeaningful revisions to this article
Initial publication.
← Back to blog