> For the complete documentation index, see [llms.txt](https://pharaoh.so/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pharaoh.so/docs/use-pharaoh/choose-codebase-context.md).

# Case study: Choose codebase context

Choose between source search, repository packs and Pharaoh's structural map for an AI coding question, and check each answer against the right revision.

Choose context according to the question and the source revision. Native source tools, repository packs and a structural map can be used together.

| Need                                          | Useful starting point                                  | Check before relying on the answer                                     |
| --------------------------------------------- | ------------------------------------------------------ | ---------------------------------------------------------------------- |
| Inspect implementation or local changes       | Source search, file reads and language-aware IDE tools | The files are from the intended checkout.                              |
| Give another tool a source snapshot           | A selected repository pack                             | The selection includes the evidence needed for the question.           |
| Investigate detected callers and entry points | Pharaoh's structural tools                             | The completed map matches the intended default-branch state.           |
| Check a pull request's new wiring             | PR Guard plus source review                            | The check concerns the current PR revision and its analysis completed. |

## Begin with a concrete question

For the same helper, a caller investigation needs relationships, a behavior change needs implementation details, and a rename needs references that may include tests or configuration. Use a structural query to locate paths, then switch to source reads and language-aware tools for the edit. A selected repository pack is useful when the next reviewer or AI client needs a portable source snapshot.

For relationships, ask:

```
Which production entry points reach this function? Use the structural
tools, show the detected paths and limits, then inspect the relevant
source before proposing a change.
```

For behavior, ask:

```
Read this implementation and its relevant callers. Explain the input
assumptions and observable behavior. Use tests and source as evidence;
the structural map alone cannot establish the function's behavior.
```

For a rename, ask:

```
Find source references, tests, configuration and string-based uses of
this name. Use the available language-aware tools and text search.
List the changes needed and unresolved dynamic uses before editing.
```

Use the [generated tool reference](/docs/use-pharaoh/overview.md) for the current Pharaoh tools and schemas. For freshness, supported analysis and branch scope, see [Scope and troubleshooting](/docs/use-pharaoh/troubleshooting.md).

## Keep repository packs scoped and inspectable

Tools such as [Repomix](https://repomix.com/guide/usage) and [Gitingest](https://gitingest.com/) prepare source for another consumer. Select files for the task and record the revision. If the question concerns callers outside a selected directory, include the work needed to discover those callers.

Use the tool's current documentation for compression and incremental retrieval. Preserve access to full implementation details when the question requires them. Check where selected source will be processed and stored, including the receiving AI service.

## Compare workflows fairly

Use the same model, task and source revision. Establish an answer key from source before reading candidate answers. Run fresh sessions, record caching conditions and account for context preparation as well as answering time.

Keep these observations separate:

* Whether the answer is correct and complete enough for the task.
* Time spent preparing context and obtaining an answer.
* Token usage and billed cost, using the provider's actual accounting.

Check relationships and unsupported additions rather than scoring only name mentions. Repeat runs when measuring performance, and retain slow results and failures alongside successful ones. A subscription price, a token count and a per-request API charge describe different costs.
