Architecture Intelligence for Smarter, Safer AI Coding

Dan Greer · · 10 min read

Part of the Tool Comparisons guide. Start with Best Architecture Mapping Software for Developers

What architecture intelligence means for software teams in smarter, safer AI coding

The caller list for checkAdminOrOwner spans four modules, with an API service, a connected-apps helper, a tRPC handler and four web components. Before changing its permission logic, I'd inspect all seven.

That's the kind of answer I want before an assistant starts changing code.

I build Pharaoh. It maps repositories into a graph that an assistant can query over MCP, with functions and their callers, module dependencies, endpoints and cron jobs available as structural context.

What architecture intelligence means in software

My working definition of architecture intelligence is queryable information about how a codebase connects, tied to a known revision, detailed enough to guide an edit, and explicit about what the map doesn't cover.

A useful answer should let me open the relevant code. If it names a dependency, I want the file behind it, the direction of the relationship, and enough detail to check whether the proposed change affects that dependency.

I use a code knowledge graph to inspect those relationships before changing an export.

There's a judgment call left over. A caller relationship tells me where to investigate, but deciding whether an authorization rule belongs in a shared helper, for instance, requires an explanation of the intended behavior.

Start with the repository, then narrow to a module

In Pharaoh, get_codebase_map returns the repository's modules with file counts and lines of code, dependencies between modules, files changed most in 90 days, and endpoints with their handler files. It flags two-way module dependencies.

Ask your connected assistant for the repository map before choosing a file. Use it to identify the module that contains the behavior, inspect its neighbors, find the handler that exposes it, and decide which area deserves a closer read.

Then ask for get_module_context on that module. Its response includes exported signatures, imports in both directions, database access, and callers from other modules.

Here is captured get_module_context output for features/auth from cal.diy (owner Pharaoh-so, revision 54343aa6). It was captured on October 26, 2026, trimmed by removing whole lines, and left in its original order, with the remaining text unchanged.

# Module: features/auth
## Structure
43 files, 5,342 LOC, 99 functions
### Exported Functions (50)
- function checkAdminOrOwner(role: MembershipRole | null | undefined): role is "OWNER" | "ADMIN" [complexity: 2, lines 3-5]
- async function getSession(options: GetSessionParams): Promise<Session | null> [async, complexity: 1, lines 5-10]
## Dependencies
### Imported by:
- web/app (weight: 69)
- web/modules (weight: 9)
- trpc/server (weight: 20)
## External Callers
### api/v2
- apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts: getEventTypesAppIntegration() → checkAdminOrOwner()
### app-store/_utils
- packages/app-store/_utils/getConnectedApps.ts: getConnectedApps() → checkAdminOrOwner()
### trpc/server
- packages/trpc/server/routers/viewer/ooo/outOfOfficeEntriesList.handler.ts: outOfOfficeEntriesList() → checkAdminOrOwner()
### web/modules
- apps/web/modules/data-table/components/segment/DuplicateSegmentDialog.tsx: DuplicateSegmentDialog() → checkAdminOrOwner()
- apps/web/modules/data-table/components/segment/FilterSegmentSelect.tsx: FilterSegmentSelect() → checkAdminOrOwner()
- apps/web/modules/data-table/components/segment/SaveFilterSegmentButton.tsx: SaveFilterSegmentButton() → checkAdminOrOwner()
- apps/web/modules/users/components/UserTable/UserListTable.tsx: UserListTableContent() → checkAdminOrOwner()

The counts describe the captured module. Only a selection of its exports and callers appears here, so don't read the shortened list as a complete inventory, infer a new total from it, or assume these numbers describe your repository.

The useful detail is where the callers live. Before editing this helper, open each of those seven call sites, check how it uses the return value, and carry those findings into the edit plan.

Check a relationship in the source

You can inspect that example without connecting Pharaoh. In a checkout of Pharaoh-so/cal.diy, verify you're at revision 54343aa6, make sure ripgrep is installed, and run this from the repository root.

rg -n -F -t ts 'checkAdminOrOwner'

rg searches the current directory recursively when no path is given, and -t ts limits it to TypeScript files. At 54343aa6, it prints 16 lines in nine files, covering the definition, an import and a call in each of the seven callers' files, and a re-export in packages/platform/libraries/index.ts. ripgrep's guide explains literal matching.

Open the definition and a caller. Follow the import.

rg searches text, so inspect each match before treating it as a call, because a definition is also a match, an import can be a match, and a comment mentioning the function can be one too. That's useful evidence for checking the graph's answer.

For a proposed change, ask get_blast_radius about the specific function after reading its module context. Pharaoh returns production callers and affected endpoints, cron jobs, and database operations, with a default traversal of three hops and a maximum of five. Test-file callers are excluded from that result. Use the blast radius workflow for detailed traversal steps, or the code impact analysis guide to plan the broader review.

For vendor selection, see codebase intelligence tools compared.

Read the limits alongside the answer

Pharaoh's graph covers the default branch. It doesn't include another branch's changes or your uncommitted edits.

A live repository re-maps on pushes to its default branch, and pharaoh_account can request a refresh before the next push, but you still need to compare the mapped code with the branch you're editing, especially when the relevant caller has changed.

Language coverage matters too. Pharaoh supports TypeScript, JavaScript, Python, C and C++.

tree-sitter builds syntax trees from source files, as its documentation explains, and Pharaoh's parser uses it, but a reported relationship still needs checking, especially when you're changing the code that established it.

Be particularly careful with deletion. Pharaoh labels unused code Dead only when no entry point reaches it, no other file names it, and no production file imports its file.

Possibly unused means the function is unreached but is named elsewhere or its file is imported. Read the named files, investigate dynamic loading, check the framework's entry points, and settle those questions before deleting anything.

Try it on one module you know

Install the GitHub App on the account or organization that owns the repository.

Then run the documented Claude Code setup command in a terminal.

npx @pharaoh-so/mcp

npx executes a command supplied by an npm package, as described in the npm documentation. Follow the setup prompts and sign in with GitHub.

claude mcp list reports configured servers and their status (Claude Code's MCP documentation). Run it to check the connection before asking for a map.

Every repository is live during the trial and on Pro.

Pharaoh keeps graph metadata rather than source-file bodies. Mapping uses a temporary clone, which is deleted when the job ends, including a failed job, while the graph retains metadata.

The GitHub App reads authorized repositories. Its only write permission publishes check results.

Pick a module you already understand and ask for its map position, then its module context. Choose an export with a known external caller, open the reported path, compare it with the current source, and write down any missing relationship before using the answer to plan an edit.

I'd start there. A familiar module gives you a way to judge the answer before you depend on it in an unfamiliar one.

Connect a repository and inspect its map.

Architecture intelligence FAQ

What is architecture intelligence?

Architecture intelligence is queryable information about how a codebase connects, tied to a known revision, detailed enough to guide an edit, and explicit about what the map does not cover.

How should I use a repository map before changing code?

Start with the repository map to identify the relevant module, its neighbors, and the handler that exposes the behavior. Then request module context to inspect exports, imports, database access, and callers.

How can I verify an architecture relationship?

Open the reported definition and at least one caller, follow the import, and inspect each search match because definitions, imports, comments, and calls can all appear in the results.

What are the limits of an architecture map?

The graph covers the default branch and does not include another branch's changes or uncommitted edits. Reported relationships still need checking against the code you are editing.

How can architecture intelligence help assess a proposed change?

After reading the module context, ask for the specific function's blast radius. The result can identify production callers and affected endpoints, cron jobs, and database operations, but test-file callers are excluded.

Article Record

ReferencesPrimary sources used for this article
  1. Connect Claude Code to tools via MCP - Claude Code Docs
  2. Tree-sitter
  3. GUIDE.md
  4. npx
Update HistoryMeaningful revisions to this article
Added an Architecture Intelligence FAQ
  • Added five frequently asked questions to help readers understand architecture intelligence for safer, smarter AI coding.
Initial publication.

More in Tool Comparisons

← Back to blog