Author: Evan

  • Ralph Loop Memory Layers

    Ralph Loop Memory Layers


    An autonomous loop does not need one giant memory file. It needs several kinds of state with different owners, lifetimes, and validation rules. Mixing a current task status, a repository-wide convention, an unverified debugging note, and a dependency relationship into the same document turns convenience into ambiguity.

    Ralph Loop memory is therefore better treated as a layered design problem. The original Ralph pattern emphasizes durable plans, repository changes, and executable feedback. Particular implementations add their own state surfaces. The job for a team is to decide what each surface means, who may update it, and when it expires.

    What Ralph Loop Memory Includes

    At least four layers usually matter:

    The purpose of Ralph Loop memory is to preserve those layers without granting temporary task notes the authority of reviewed project rules or current source.

    • Task state: what is being attempted, what is complete, what failed, and what remains.
    • Project rules: stable commands, conventions, boundaries, and review requirements that apply beyond one task.
    • Experience: observations from an iteration, including failed approaches and useful paths, which may or may not deserve promotion into a project rule.
    • Code structure: current modules, symbols, dependencies, call paths, and test relationships derived from source.

    These layers overlap, but they are not interchangeable. “Run the API tests after changing the schema” may become a durable rule. “Test 17 failed because my fixture was stale” is task history. “Package B imports interface A” is a structural claim that should be regenerated or verified when the code changes.

    Task state, project rules, reviewed experience, and code structure as distinct memory layers

    The names of the storage files are implementation details. Huntley’s original Ralph description discusses a plan file, repository work, and feedback from builds or tests. The snarktank implementation uses prd.json, progress.txt, Git history, and prompt guidance.

    Task State vs Project Rules

    Task state is scoped and mutable. It can record the selected story, acceptance criteria, incomplete checks, and a concise note for the next iteration. It should reset or archive when the task or branch changes. If task state accumulates indefinitely, the next loop must distinguish relevant evidence from historical noise.

    A search for Ralph progress.txt is useful only after the team has confirmed that it is discussing the snarktank implementation rather than Ralph as a general pattern.

    Project rules are broader and more stable. They include build commands, style constraints, package ownership, security requirements, and known repository-specific traps. They should change through review because a mistaken rule can misdirect every later task. The AGENTS.md specification supports scoped instruction files: instructions apply to a directory tree, and a more deeply nested file can refine or override them within its own scope.

    That hierarchy is useful because many “global” rules are not global. A frontend package and a data migration directory may have different validation commands and write constraints. Putting both in a root note forces every loop to carry irrelevant instructions. Scoped project rules reduce context while making ownership visible.

    The boundary is promotion. An iteration may discover a recurring repository fact, but it should not silently convert a one-off observation into a permanent rule. Promotion should require evidence, a clear scope, and an owner. Otherwise the memory layer becomes a collection of confident anecdotes.

    Progress Files, AGENTS.md, and Git History

    In snarktank’s loop, progress.txt is an append-oriented handoff between iterations. The prompt template tells the agent to read it, use Git history, work on one story, run quality checks, commit, and append useful information. The README says the file is archived and reset when a new branch starts. Those are properties of that implementation, not of every Ralph loop.

    A team searching for a Ralph loop Codex workflow should design the memory layers first rather than copying those filenames without their semantics.

    Git history serves a different purpose. It records durable changes and their sequence, but a commit message is not necessarily a complete task handoff. The next loop may need current test failures or a reason an attempted approach was abandoned. That short-lived operational context belongs in task state, while the code itself remains the primary record of implementation.

    AGENTS.md should hold reusable instructions, not a transcript of the current story. A useful entry explains a command, invariant, or directory convention that future tasks will need. Story-specific steps should remain in the task plan or progress file. This division prevents a temporary workaround from becoming permanent policy.

    No layer should be trusted merely because it persisted. Read the current source, inspect recent changes, and use tests or static checks as backpressure. Memory narrows where to look; it does not supersede the repository.

    Where Code Graphs Store Structural Knowledge

    Structural knowledge has a different update model from prose memory. Imports, calls, implementations, schema references, and test coverage can change with a single commit. A code graph can index those relationships and answer a task-scoped query, but the returned facts should include file, symbol, commit SHA, and index version.

    For a Ralph loop, this creates a read-mostly orientation layer. The task can ask which modules depend on a changed interface or which tests touch a call path, then verify the cited source before editing. Graphify is one possible codebase graph layer for this use case. It should complement exact text search and source inspection, not replace them.

    This is an extension to the Ralph pattern. The cited Huntley, snarktank, and Anthropic Ralph implementations do not define a native code graph. Claude Code supports external integrations through MCP, but a graph service still needs its own freshness, access, and provenance controls.

    Structural facts should rarely be hand-edited as prose. If the graph disagrees with source at the active commit, source wins and the index should be repaired. Human annotations may explain an architectural intent, but they should be stored separately from derived edges so reviewers know which assertions were computed and which were authored.

    Failure Modes and Cleanup Notes

    The first failure mode is stale authority. An old note may describe a module that moved, a command that changed, or a task that was abandoned. Every layer needs an expiration policy: task state resets at a task boundary, project rules are reviewed when contradicted, and structural indexes invalidate on commit or schema drift.

    Memory lifecycle showing reset, review, promotion, invalidation, conflict resolution, and cleanup

    The second is conflict. A root instruction, nested instruction, progress note, and current source may disagree. Resolve the conflict by scope and authority: current source and executable checks establish behavior; the most specific reviewed instruction governs process; task notes explain intent but do not override verified reality. Record the resolution so the next iteration does not repeat it.

    The third is uncontrolled growth. Append-only logs are useful for audit, but poor as an active prompt once they become long. Archive completed episodes, summarize only verified lessons, and keep the active handoff small. Do not delete history that is required for review; remove it from the hot context.

    Finally, prevent sensitive data from entering shared memory. Progress logs and graph indexes can outlive a session and reach more agents than the original prompt. Store secrets in approved secret systems, restrict indexed paths, and review access separately for task, policy, and structural layers.

    FAQ

    What memory should be read-only?

    Treat derived structural indexes, approved project rules, and finalized task specifications as read-only to an implementation loop unless an explicit workflow authorizes updates. The loop can propose changes, but another check or owner should validate them. Active task status can be writable within its branch and scope.

    When should progress files reset?

    Reset or archive them when the branch, feature, or task identity changes, or when a completed episode no longer belongs in active context. Preserve an auditable copy if the work requires it. Snarktank documents a new-branch reset, but other implementations can choose a different boundary if they state it clearly.

    Who resolves memory conflicts?

    The owner of the affected scope should decide process or architecture disputes. Before escalation, the agent should gather current source, applicable instructions, commit history, and test evidence. Conflicts involving security, public APIs, or cross-team ownership should not be resolved by an autonomous loop alone.

    What is the Ralph loop pattern?

    It is a repeated agent-development cycle driven by a stable task or plan and constrained by feedback such as tests, builds, or static analysis. Some implementations start a new process per iteration; Anthropic’s official plugin continues through a Stop hook in the current Claude Code session. Memory surfaces therefore vary by implementation.

    Conclusion

    Good Ralph Loop memory is less about remembering everything and more about preserving the right evidence at the right layer. Task state should be small and resettable. Project rules should be scoped and reviewed. Experience should be promoted cautiously. Code structure should be derived from current source and carry provenance.

    When those boundaries are explicit, a fresh iteration can recover what it needs without treating an old conversation as architecture. For the structural retrieval layer, see knowledge graphs for AI coding assistants. For the reset boundary that makes these layers necessary, see Ralph fresh context trade-offs.

  • Ralph Loop Large Codebase Context

    Ralph Loop Large Codebase Context


    A loop can keep an agent moving without keeping it oriented. On a small repository, reopening a few files may be enough. On a large codebase, the agent must repeatedly recover module ownership, call paths, test boundaries, generated surfaces, and local conventions before it can make a safe edit. That recovery cost is easy to mistake for implementation work.

    The Ralph pattern makes this tension visible because it deliberately repeats an implementation cycle. Geoffrey Huntley’s original description uses a simple outer loop, a stable plan, one task per iteration, and tests or builds as backpressure. It does not prescribe a universal repository-memory system. A practical Ralph Loop large codebase workflow therefore needs a separate answer to a narrower question: what repository context should each iteration recover, and how should it verify that context before writing?

    Why Ralph Loops Repeat Repository Search

    Each iteration begins with an information deficit. The task may be durable, but the agent still needs to locate the relevant implementation and understand how it fits the repository. In Huntley’s formulation, each loop receives a new context window. In the snarktank implementation, each iteration launches a new Amp or Claude process. That makes rediscovery an expected property of those implementations, not proof that the loop is broken.

    In a Ralph Loop large codebase workflow, that information deficit should be treated as an orientation problem with a bounded evidence target.

    Fresh loop iterations repeating broad repository orientation before a scoped handoff

    The problem becomes expensive when discovery restarts from the repository root. A broad text search can find exact names, but a task often arrives in behavioral language: “preserve the import contract,” “update every consumer,” or “find the test that protects this path.” The relevant code may use aliases, wrappers, dependency injection, generated clients, or a name that differs from the task wording. An agent can spend several iterations reconstructing the same relationships.

    What Fresh Context Helps With

    Fresh context can reduce attachment to a failed approach. The next iteration reads the current repository rather than relying on a long conversational narrative about what the repository used to contain. If the previous attempt changed code, tests, or the plan, the new iteration can inspect those artifacts directly. This supports Ralph’s core bias toward durable work products and executable feedback.

    It also limits the amount of incidental discussion competing with the task. A concise specification, current source, and test result are usually better inputs than a transcript containing several abandoned hypotheses. For long-running work, that reset can improve attention and make the loop easier to inspect.

    Useful Ralph repository context is therefore the smallest set of durable artifacts that lets the iteration verify the current task without inheriting every abandoned hypothesis.

    But “fresh” is implementation-specific. The official Anthropic Ralph Loop plugin uses a Stop hook to continue inside the current Claude Code session. It does not create the same clean-process boundary as the snarktank script. Teams should document the actual reset boundary instead of assuming that the word Ralph guarantees one.

    What Large Codebases Need Beyond Search

    Large repositories need a compact structural orientation layer. At minimum, an iteration should be able to answer:

    This is also why the phrase “Ralph loop GitHub” is ambiguous. Huntley’s pattern, snarktank’s shell scripts, Anthropic’s Claude Code plugin, and Ralph Orchestrator make different choices about process lifetime and persisted state. Treating one repository’s files as properties of every Ralph loop creates false assumptions before repository search even begins.

    • Which module owns the behavior?
    • Which public entry points reach it?
    • Which modules depend on the symbols likely to change?
    • Which tests, schemas, migrations, or generated artifacts constrain the edit?
    • Which repository rules apply in this directory?

    Text search remains part of the answer. ripgrep is a deterministic, line-oriented regular-expression search tool. Its default treatment of ignored, hidden, and binary files matters, and text matches alone do not encode call or dependency relationships. The safe conclusion is not that search is unreliable. It is that search has a defined retrieval model, and the task may require evidence outside that model.

    Repository rules should also follow scope. An AGENTS.md file can carry instructions for a tree, with more deeply nested files taking precedence for their subdirectories, as described by the AGENTS.md specification. That is useful policy context, but it is different from code structure. Combining policy, architecture, task status, and observations into one undifferentiated note makes every layer harder to validate.

    Where Code Graphs Fit the Loop

    A code graph can serve as one possible repository-orientation layer. It can index modules, definitions, imports, calls, inheritance, and test relationships, then return a task-sized subgraph instead of a repository-wide dump. For example, an iteration changing an authentication interface could request the definition, direct and indirect consumers, related tests, and paths where the interface crosses a package boundary.

    Revision-pinned graph retrieval selecting a task-scoped slice for source verification

    That result should be treated as candidate context, not truth. The agent still needs to open the cited files, confirm symbol resolution, and run the repository’s tests or static checks. Graph data can be stale, incomplete, or blind to dynamic behavior. It is most useful when every returned relationship includes provenance such as file path, symbol, commit SHA, and index version.

    Graphify is one possible codebase graph layer for this role. The relevant product claim is modest: structure-aware retrieval may reduce repeated orientation work when a repository’s relationships are difficult to recover from isolated text matches. It does not make every repository easier, replace source inspection, or remove the need for backpressure.

    This integration is an editorial extension to the Ralph pattern. Neither Huntley’s original loop nor the cited snarktank and Anthropic implementations include a native code-graph bridge. Claude Code can connect to external tools through MCP, but the existence and behavior of any graph service must be verified separately.

    Limits and Verification Notes

    The first limit is drift. A graph built at one commit can mislead an agent working at another. Pin retrieval to the active commit when possible, reject results with mismatched provenance, and rebuild or incrementally update the index after structural edits. If a relationship cannot be traced to current source, it should not authorize a change.

    The second limit is task scope. Retrieving every caller in a monorepo can recreate the same context overload as reading the repository root. Queries should begin with the task’s expected behavior and write scope, then expand only when evidence exposes an additional dependency. The output needs ranking and boundaries, not merely more nodes.

    The third limit is verification quality. Tests are backpressure, not a proof that the retrieved architecture is complete. Reviewers should ask which files were searched, which graph edges were followed, what assumptions remain, and whether generated or runtime-only relationships were inspected. A change that passes a narrow unit test can still violate an external contract.

    Finally, teams should measure the orientation layer against real failures. Useful signals include repeated opening of the same files, missed consumers found in review, unnecessary full-repository scans, and stale results rejected by provenance checks. Those observations are more defensible than a generic promise of faster agents.

    FAQ

    What should persist between loops?

    Persist durable task state, accepted repository rules, committed code, test results, and verified structural findings with provenance. Keep short-lived hypotheses separate. The exact files depend on the implementation: snarktank uses prd.json, Git, and progress.txt, while Huntley describes a plan file and repository artifacts. Do not treat those names as a universal Ralph contract.

    Who reviews recovered architecture assumptions?

    The agent should verify them against current source and tests first. A human reviewer or designated code owner should review assumptions that affect public interfaces, security boundaries, data models, migrations, or multiple teams. The review should cite paths and symbols so disagreement can be resolved from evidence rather than summaries.

    When should search results be ignored?

    Do not ignore them merely because they are incomplete. Treat them as one evidence source. Reject or qualify results when they come from the wrong commit, excluded paths, generated output that is not authoritative, ambiguous symbols, or an index with unknown freshness. Then use another retrieval method and inspect the source.

    What is Ralph in AI coding?

    Ralph is a development pattern in which an agent repeatedly works from a stable task or plan, changes the repository, and receives feedback from tests, builds, or other checks. Implementations differ in session lifetime, memory files, stopping conditions, and concurrency, so the name describes a family of loops rather than one fixed tool.

    Conclusion

    The central challenge in a Ralph Loop large codebase workflow is not preserving the entire previous conversation. It is recovering the smallest trustworthy slice of repository context for the next task. Fresh iterations help when durable artifacts and executable feedback carry the work forward, but they can waste time when architecture must be rediscovered from scratch.

    Start with scoped text search, repository rules, current source, and tests. Add structure-aware retrieval when repeated failures show that relationships are the missing layer. Keep every result tied to current code, and let the loop expand context only when the task requires it. For the broader retrieval model, see knowledge graphs for AI coding assistants; for the state layers between iterations, see Ralph Loop memory.

  • OpenSpec Compound Engineering Layers

    OpenSpec Compound Engineering Layers


    OpenSpec compound engineering is best understood as an editorial layering pattern, not a documented product integration. OpenSpec can organize change intent and implementation artifacts. Compound Engineering can preserve reusable work knowledge. A proposed external code graph can supply current structural facts. Each layer answers a different question, and source code plus tests remain the final behavior check.

    The value comes from clean handoffs. The risk comes from letting three independently changing layers appear to agree when they do not.

    Quick Verdict

    Use the layers this way:

    This OpenSpec compound engineering split is useful only when each layer keeps its own authority and update rule.

    Layer Primary question Typical artifact Authority limit
    OpenSpec What change are we agreeing to build? proposal, delta specs, design, tasks Expresses intended behavior and work, not current code structure.
    Compound Engineering What did prior engineering work teach us? plan, review findings, solution record Preserves scoped workflow knowledge, not an exhaustive system map.
    Proposed external code graph How is this revision structurally connected? typed, provenance-bearing nodes and edges Generated facts can be incomplete and need source verification.

    Equal context layers for intent, reusable work memory, and revision-aware structure

    There is no documented first-party integration among OpenSpec, Compound Engineering, and Graphify in the pinned primary sources. [OPENSPEC-OVERVIEW-20260724] [CE-README-20260724] The workflow below is therefore a proposed composition that teams must implement and govern themselves.

    Also separate two uses of “graph.” OpenSpec's schema can define dependencies among change artifacts. That artifact dependency graph controls creation order. It is not a code knowledge graph of symbols, calls, implementations, or tests. [OPENSPEC-SCHEMA-20260724]

    The structural layer is introduced in Knowledge Graph for AI Coding Assistants. The broader memory model is covered in Compound Engineering Memory Explained.

    OpenSpec as Intent Context

    OpenSpec provides a structured process for agreeing on a change before implementation. Its current overview describes a change folder with artifacts such as a proposal explaining why and scope, delta specifications describing added or modified behavior, a design explaining technical decisions, and tasks tracking implementation work. [OPENSPEC-OVERVIEW-20260724]

    That makes it useful intent context, but “intent” should not be reduced to one proposal file. In spec-driven development:

    • the proposal frames the problem and change boundary;
    • delta specs define expected behavior through requirements and scenarios;
    • the design records the implementation approach and trade-offs;
    • tasks turn the agreement into executable work.

    The current OPSX command flow uses /opsx:* commands to explore, propose, apply, verify, and archive changes. [OPENSPEC-COMMANDS-20260724] Teams should use the terminology present in their installed version rather than copying older command examples from secondary guides.

    OpenSpec artifacts are strongest when reviewers can test them for internal consistency. Does each task implement a requirement? Does the design address the constraints in the proposal? Do scenarios cover the edge case that motivated the change? They are weaker as evidence of current runtime behavior. A spec may be correct while the code is incomplete, or obsolete while the code moved on.

    Compound Engineering as Work Memory

    Compound Engineering contributes reusable knowledge about how work was understood, implemented, and reviewed. The pinned current repository documents planning, review, and compounding capabilities. Its ce-compound skill writes one selected durable learning to solutions/, and ce-compound-refresh can maintain stale or overlapping solution records. [CE-README-20260724] [CE-COMPOUND-20260724] [CE-REFRESH-20260724]

    This work-memory layer must not be conflated with Claude Code auto memory, which is supplied by the host rather than the Compound Engineering plugin. [ANTHROPIC-MEMORY-20260724]

    The accepted search form Everyinc/compound-engineering-plugin refers to the canonical repository spelling EveryInc/compound-engineering-plugin. The distinction is small for search, but exact entity naming matters when a team pins a repository or commit for audit.

    Work memory should not duplicate the OpenSpec change package. A useful solution record might explain why a production failure evaded the original scenario, which diagnostic path found it, and which validation now prevents recurrence. The associated OpenSpec artifacts still own the intended change. The solution record owns the transferable learning from performing or repairing the work.

    Compound Engineering does not provide OpenSpec's artifact model in the cited repository, and OpenSpec does not provide Compound Engineering's solution workflow. Any connector between them must state how artifact IDs, repository revisions, review status, and permissions are carried across.

    Code Graphs as System Structure

    A proposed external code graph answers questions neither artifact set can answer exhaustively: which current symbol implements a specified behavior, which callers are in the change radius, which tests reach the path, or whether a path named in an old solution still exists.

    The graph should use typed edges and expose provenance. A fact such as CheckoutHandler CALLS PaymentService needs a repository, indexed commit, source location, extraction method, and access scope. It is a structural candidate for the agent to verify, not a statement of intended behavior.

    Graphify can be considered as one possible external code graph layer. It is not a built-in OpenSpec or Compound Engineering component, and this article makes no first-party integration claim.

    Do not import OpenSpec's artifact dependency graph and call it a code graph. The former can say that a design artifact depends on approved specs before it is created. The latter represents properties of a code revision. [OPENSPEC-SCHEMA-20260724] A connector may link a requirement to candidate symbols, but that cross-layer link should show whether it was curated, inferred, or generated by similarity.

    The graph is most valuable when it narrows verification. If it cannot support the requested language, branch, generated source, or runtime configuration, it should return uncertainty and let the agent inspect the repository directly.

    How the Layers Fit an Agent Workflow

    Consider a change to idempotent payment retries.

    Cross-layer handoff and correction loop from intent through work memory and code structure

    1. Explore the request. Clarify the failure, constraints, and affected user behavior. Do not write graph facts or durable solutions yet.
    2. Create the OpenSpec change. Capture why and scope in the proposal, behavior in delta specs, technical choices in design, and implementation work in tasks. [OPENSPEC-OVERVIEW-20260724]
    3. Retrieve prior work memory. Search reviewed Compound Engineering solutions for the same subsystem, error class, or constraint. Preserve their version scope and treat conflicting records as a review signal.
    4. Query proposed structural context. Resolve requirement terms and prior solution references to candidate symbols, callers, and tests on the target revision. Return provenance and uncertainty.
    5. Plan and implement. Use the intent artifacts as the acceptance boundary, prior solutions as scoped evidence, and graph results as navigation. Open the source and run tests before accepting any claim.
    6. Verify. OpenSpec's current /opsx:verify workflow checks implementation against change artifacts and is designed to report findings rather than block all progress automatically. [OPENSPEC-COMMANDS-20260724]
    7. Update the changed layer. Revise the spec if agreed behavior changed, compound a reusable lesson if the work produced one, and rebuild structural facts for the new revision.

    The order may loop. A structural query may reveal a hidden caller that changes the design. A prior solution may expose a missing scenario. When that happens, update the authoritative artifact before continuing rather than carrying an informal exception in the conversation.

    Limits and Handoff Risks

    Cross-layer references can look precise while being stale. A task may link to a requirement that was revised. A solution may name a removed path. A graph may cover main while implementation occurs on a release branch. Every handoff should carry stable artifact IDs, repository revision, review status, and source permissions.

    Disagreement is normal and should be visible:

    • spec versus code may mean incomplete implementation or obsolete intent;
    • solution versus spec may mean a historical workaround conflicts with a new requirement;
    • graph versus code may mean ingestion lag or extraction error;
    • artifact dependency versus code dependency may be a category mistake.

    OpenSpec documents a review process for checking change artifacts, and its verification workflow should be treated as evidence within a broader engineering review, not proof of runtime correctness. [OPENSPEC-REVIEW-20260724] [OPENSPEC-COMMANDS-20260724]

    Privacy also crosses layers. A public spec should not make a private incident or repository relationship visible through a generated summary. Query-time permission checks, derived-data deletion, and audit logs are required when systems have different access models.

    Finally, measure the composed workflow on matched tasks. Track missing scenarios, stale links, irrelevant retrievals, reviewer corrections, and time to verified evidence. Do not assert a universal token-saving percentage for the three-layer design.

    FAQ

    Which layer should be updated first?

    Update the layer whose authoritative knowledge changed. If agreed behavior changes, revise OpenSpec before implementation proceeds. If only the code structure changed, rebuild the graph after the commit. If the work produced a reusable diagnostic or solution, compound that lesson after it has been validated. Cross-links should update after their targets are stable.

    Can specs and graphs disagree?

    Yes. A spec expresses intended behavior; a graph reflects extracted structure for a revision. Disagreement may indicate incomplete implementation, stale intent, ingestion lag, or an extraction error. Surface both sources and ask the responsible reviewer to classify the mismatch rather than automatically preferring one.

    Who owns cross-layer review?

    The change owner should coordinate it, with artifact-specific responsibility retained by spec reviewers, subsystem maintainers, and the platform team operating retrieval. Security and privacy owners should review cross-system permissions. No connector should erase those ownership boundaries.

    What is OpenSpec for Claude Code?

    OpenSpec is a spec-driven workflow that can expose slash commands and change artifacts to supported AI coding tools, including Claude Code configurations documented by the project. [OPENSPEC-OVERVIEW-20260724] It organizes change intent and work; it is not Claude Code memory or a code graph.

    Conclusion

    OpenSpec, Compound Engineering, and a proposed external code graph can form a coherent context architecture when their responsibilities stay narrow. OpenSpec owns agreed change artifacts. Compound Engineering preserves reviewed work learning. The graph supplies revision-aware structural candidates.

    The composition is a design pattern, not an official integration. Make every handoff carry identity, revision, status, provenance, and permissions, then verify behavior in source code and tests. Clear boundaries make the three layers useful; blurred authority makes them dangerous.

  • Compound Engineering Token Usage

    Compound Engineering Token Usage


    Reusable knowledge can reduce repeated investigation, but it is not free. Compound engineering token usage depends on what the agent loads, when it loads it, and whether the retrieved material still applies. A short, relevant solution record may replace several searches. A stale instruction file or a bundle of unrelated Skills may add context before useful work begins.

    There is no credible universal savings percentage. Teams should measure the same task on the same repository revision with the same model and tool configuration, then inspect both token use and engineering correctness.

    Why CE Can Save Tokens

    Compound Engineering can reduce repeated work by distilling a completed investigation into a reusable artifact. The current ce-compound skill writes one durable learning to a solutions/ directory. Its lightweight path uses the current conversation, while its fuller path can gather additional evidence, including session history, before producing the document. [CE-COMPOUND-20260724]

    For compound engineering token usage, this distillation is one stage in the current plan–work–review–compound cycle, not a guarantee that every later task will use fewer tokens.

    The potential gain is straightforward: when a later task matches the recorded problem class, the agent can retrieve a focused explanation instead of rediscovering the same files, failed hypotheses, and validation steps. A reviewed solution can point directly to the affected subsystem and the test that distinguishes the real cause from a similar symptom.

    That is only a potential. If retrieval returns the wrong solution, or the solution lacks version scope, the agent may spend more context verifying and correcting it. The useful unit is not “tokens removed.” It is verified work completed per unit of context.

    The current plugin also includes ce-compound-refresh, which is intended to maintain stale and overlapping solution documents. [CE-REFRESH-20260724] Maintenance matters because compounding without pruning turns reuse into accumulation.

    For structural retrieval fundamentals, see Knowledge Graph for AI Coding Assistants. The three-layer handoff is evaluated in OpenSpec Compound Engineering Layers.

    Where Context Overhead Appears

    Claude Code's context can include the conversation, instructions, file reads, tool results, auto memory, and loaded Skill content. Anthropic documents /context as a way to inspect the current context breakdown. [ANTHROPIC-CONTEXT-20260724]

    Standing context, on-demand retrieval, and noisy overhead flowing into a task

    Billing and context are related but not identical. Anthropic's current usage documentation distinguishes subscription usage from pay-as-you-go API usage, where /cost can report token-based cost. [ANTHROPIC-USAGE-20260724] A team measuring Claude Code context cost should record the authentication and billing mode rather than comparing unlike numbers.

    Tool output is easy to overlook. Long logs, broad searches, generated plans, and repeated file reads all occupy context. A workflow can use fewer prompt words while still carrying more total context because its tools return too much evidence.

    Skills, Notes, and Old Docs as Hidden Cost

    Instruction and Skill systems load at different times. Anthropic's current documentation says CLAUDE.md instructions are loaded into context, while Skills advertise descriptions and load their full content when invoked. User-invoked-only Skills can avoid loading until called. [ANTHROPIC-MEMORY-20260724] [ANTHROPIC-FEATURES-20260724]

    A Compound engineering token usage example should therefore count more than the final answer. Suppose two runs fix the same test failure. The first run opens 25 files and several tool outputs. The second loads one relevant solution, opens six files, and verifies the same test. The second may be more efficient—but only if both start from the same commit, use the same model and settings, and produce an equally correct result.

    This creates several hidden costs:

    • a large CLAUDE.md sends rarely relevant guidance into many sessions;
    • broad Skill descriptions compete for attention even when full Skill bodies are not loaded;
    • overlapping solution documents make retrieval return several versions of the same lesson;
    • old path names and dependency versions trigger verification work;
    • full compounding gathers more evidence than a lightweight pass, even when the lesson is obvious.

    Anthropic recommends keeping CLAUDE.md concise, with a target below roughly 200 lines, and notes that imported instruction content still loads into context. [ANTHROPIC-MEMORY-20260724] Its auto-memory mechanism limits the portion of MEMORY.md loaded at session start and allows topic files to be read on demand. [ANTHROPIC-MEMORY-20260724] Auto memory is a Claude Code host feature, not a feature supplied by Compound Engineering.

    Count duplication across formats. The same rule repeated in CLAUDE.md, a Skill, three solution records, and an agent prompt creates both token overhead and an authority problem.

    Retrieval and Expiration Strategies

    Start with a context budget by layer. Keep standing instructions small. Retrieve solution documents only after the task has a sufficiently specific subsystem or symptom. Load graph neighborhoods, logs, and long reference files on demand. Limit the number of retrieved artifacts and show why each matched.

    Rank evidence by scope and freshness, not text similarity alone. A solution tied to the current package and a recent compatible revision should outrank a semantically similar note for another service. Return the revision, review status, and invalidation condition with the excerpt.

    Expire records through explicit triggers:

    • referenced symbols or files disappear;
    • a dependency or schema version moves beyond the documented range;
    • the fix is reverted or superseded;
    • a new reviewed solution covers the same problem class;
    • the owning team marks the assumption invalid.

    Use ce-compound-refresh as one maintenance input, then keep human review for high-impact conflicts. [CE-REFRESH-20260724] A proposed external code graph can help detect renamed or removed symbols, but that is not an official Compound Engineering integration and its extracted facts still require revision checks.

    That proposed code knowledge graph should expose revision-aware nodes and edges with queryable provenance so an agent can inspect why a structural fact matched.

    The best retrieval system can also answer “nothing reliable found.” Filling the context window with weak matches is worse than letting the agent inspect the repository directly.

    Limits and Measurement Notes

    Use a matched evaluation harness. Freeze the repository commit, task, acceptance tests, model, agent version, authentication mode, enabled tools, and context limits. Run enough repeated trials to account for model variability. Record:

    Matched experiment lanes comparing context volume, tool paths, and verified correctness

    • input and output tokens where the interface exposes them;
    • tool calls, files opened, and tool-output volume;
    • time to a test-passing result;
    • irrelevant or stale artifacts retrieved;
    • reviewer corrections and regressions;
    • success against the same acceptance tests.

    Token counts alone can reward a short but wrong answer. Cost alone can be distorted by caching, model choice, or billing plan. A fair result states the full setup and separates observed measurements from explanations.

    Do not extrapolate a single repository result into “Compound Engineering saves X percent.” Report the task family and confidence interval if the sample permits it. If a proposed external graph changes retrieval, test it as a separate variable instead of combining it with new instructions, a new model, and a changed Skill set.

    FAQ

    How should teams measure context waste?

    Measure context that was loaded but neither used nor needed to reach the verified result. Track unopened retrievals, repeated file reads, stale guidance, duplicate instructions, and long tool outputs. Compare matched runs and include correction rate so a smaller but inaccurate context is not counted as an improvement.

    When should a Skill be retired?

    Retire or narrow it when its trigger no longer maps to a real task, its instructions duplicate a better source, its dependencies are obsolete, or it repeatedly loads irrelevant context. Preserve a versioned record when audit history matters, but remove it from active discovery and default use.

    What context should load only on demand?

    Long reference documents, historical solutions, detailed logs, generated graph neighborhoods, and subsystem-specific procedures should usually wait until the task identifies a relevant scope. Repository-wide safety rules and essential commands can remain standing instructions, provided they stay concise.

    How does Compound Engineering work with Claude Code?

    Compound Engineering is a plugin workflow that can run in Claude Code, while Claude Code supplies the host context, instruction, Skill, and memory mechanisms. [CE-README-20260724] [ANTHROPIC-FEATURES-20260724] The two should not be described as one memory product.

    Conclusion

    Compound engineering token usage improves when durable knowledge replaces repeated investigation and only relevant artifacts enter context. It worsens when instructions, Skills, old notes, and tool output accumulate without ownership or expiry.

    Measure controlled tasks, not anecdotes. Record correctness alongside tokens and cost, expose what loaded, and change one context variable at a time. That produces a result a team can reproduce instead of a savings claim it cannot defend.

  • Compound Engineering Knowledge Graph

    Compound Engineering Knowledge Graph


    A compound engineering knowledge graph can be useful, but it is not a documented feature of the current Compound Engineering plugin. It is a proposed external design: connect current code structure to reviewed solution records, issues, pull requests, and design documents so an agent can retrieve a bounded evidence set for a task.

    The hard part is not drawing more edges. It is defining authority, provenance, version scope, and permissions before generated relationships enter an agent's context.

    Before You Build the Graph

    Start with questions, not a schema. A platform team may need to answer:

    A compound engineering knowledge graph earns its operational cost only when those cross-artifact questions recur and ordinary repository search no longer answers them reliably.

    • Which current symbols participate in this failing request path?
    • Which reviewed solution records concern the same subsystem?
    • Which pull request introduced the behavior?
    • Which tests and owners should be included before a change?

    If ordinary repository search answers these questions reliably, a graph may add unnecessary operations. Build the layer only where repeated traversal across artifacts is a measured bottleneck.

    Define the source-of-truth policy before ingestion. Code and tests verify current behavior. Reviewed specifications and decisions express intent. Solution records preserve scoped reasoning. Issues and pull requests supply history, but their comments may include superseded hypotheses. Generated links support navigation and must not silently override those sources.

    Also define the version key. A relationship without a commit, branch, or release scope is unsafe in a changing repository.

    Start with Knowledge Graph for AI Coding Assistants if the graph model is unfamiliar. Evaluate context overhead separately in Compound Engineering Token Usage.

    Connect Code, Docs, Bugs, PRs, and Solutions

    A useful initial schema is small.

    An engineering knowledge graph built from this schema should remain a bounded evidence index, not a claim that every engineering artifact belongs in one database.

    Small provenance-first schema linking engineering artifact types to a revision rail

    Node types might include Repository, Revision, File, Symbol, Test, Document, Issue, PullRequest, Solution, and Owner. Edge types might include DEFINES, CALLS, IMPLEMENTS, IMPORTS, TESTS, CHANGED_BY, DISCUSSED_IN, SOLVES, OWNS, and VALID_AT.

    Every node and edge should have provenance fields:

    • source system and stable source identifier;
    • repository and revision;
    • extraction time and method;
    • confidence or resolution status where applicable;
    • access scope;
    • expiry or invalidation condition;
    • reviewer for curated links.

    The graph should distinguish extracted facts from curated assertions. A parser may extract Symbol A CALLS Symbol B from one revision. A maintainer may curate Solution 17 SOLVES retry duplication in Settlement. Those claims were produced differently and should not share an unexplained confidence score.

    The current Compound Engineering workflow gives the proposed graph a useful document type: ce-compound writes a selected learning to solutions/, while refresh tooling can maintain stale or overlapping solution records. [CE-COMPOUND-20260724] [CE-REFRESH-20260724] The integration itself remains hypothetical. A connector would need to ingest those records, preserve their repository history, and keep review state visible.

    Those solution records must not be conflated with Claude Code auto memory, which is a separate host-managed context layer. [ANTHROPIC-MEMORY-20260724]

    Graphify can be evaluated as one possible external code-structure provider in this model. It should not be presented as an official Compound Engineering component or as a complete source of product, incident, and pull-request truth.

    Model Similar Problems and Past Fixes

    “Similar problem” is not a primitive fact. Two incidents may share an error string but have different causes. Two solution documents may describe the same root cause with different vocabulary. An engineering knowledge graph needs an explicit method for proposing similarity.

    The phrase Compound engineering knowledge graph GitHub can imply that such a graph already exists in the official repository. It does not appear in the pinned current Compound Engineering documentation. The plugin documents planning, review, and durable solution workflows; this article's graph is an external architecture proposal. [CE-README-20260724] [CE-COMPOUND-20260724]

    Use several signals rather than a single magic edge:

    • shared affected symbols or subsystems;
    • common error types, test failures, or stack frames;
    • overlapping dependencies and change paths;
    • curated labels or incident categories;
    • text or code embeddings used as candidate generators.

    Represent the output as POSSIBLY_SIMILAR_TO, not SAME_AS, until reviewed. Store the features and model version that produced the candidate. If the relationship comes from an embedding classifier, say so; graph topology alone does not infer semantic similarity.

    Past fixes also need outcomes. Record whether a solution was accepted, reverted, superseded, or limited to a version. A pull request that mentions an issue is not automatically the correct fix, and a merged change can later be reverted. Model these events instead of flattening them into one permanent SOLVES edge.

    For privacy, avoid embedding unrestricted issue text into a broadly queryable index. The permission intersection of every source should constrain the returned evidence.

    Query the Graph During Agent Tasks

    Graph retrieval should be a bounded step inside an agent workflow, not a request to “load the repository.” A practical query contract includes task terms, repository, target revision, maximum traversal depth, allowed node types, and an evidence budget.

    Bounded graph query selecting a revision-scoped slice for source and test verification

    For a failing checkout test, the sequence could be:

    1. Resolve the failing test and symbols on the target commit.
    2. Traverse one or two typed edges to callers, implementations, and affected tests.
    3. Retrieve reviewed solution records linked to those components.
    4. Return paths, source identifiers, indexed revision, and uncertainty.
    5. Let the agent open the source and reproduce the behavior before editing.

    In a proposed Graphify workflow, the code graph supplies structural candidates. Compound Engineering solution documents contribute scoped prior learning. The agent's host supplies instructions and tool execution. These are separate systems joined by an explicit retrieval contract, not a built-in vendor integration.

    Good queries are falsifiable. “Show current callers of this symbol at commit X” can be checked. “Tell me everything relevant” cannot. Log which returned facts were opened, accepted, corrected, or ignored; that evidence helps tune traversal and expiry.

    Do not automatically write agent conclusions back as graph truth. Send proposed curated edges through review, especially SOLVES, OWNS, and cross-artifact intent relationships.

    Drift, Privacy, and Review Risks

    Drift occurs in more than code. Symbols move, issue labels change, owners rotate, solution records become obsolete, and pull-request links can point to a branch that no longer reflects production. Each data source needs a freshness rule and a deletion path.

    Index status should be visible in every response. If the requested commit is newer than the graph, return a qualified partial answer or require live repository inspection. Dynamic dispatch, runtime configuration, generated code, and incomplete language support should also lower confidence.

    Permissions must be evaluated at query time. A user who can read repository A but not a linked incident in system B should not receive the incident title, extracted text, or a summary that reveals it. Derived embeddings and cached responses need the same retention discipline as source content.

    Schema review matters because edge types shape agent behavior. Adding APPROVED_BY or redefining OWNS can change which evidence an agent trusts. Treat schema changes like API changes: document semantics, migrate old data, sample results, and assign an approver.

    Measure the system with controlled tasks and correction logs. Useful signals include stale edges found, unsupported links rejected, time to verified evidence, and reviewer corrections. Do not publish a universal token-saving percentage without matched conditions.

    FAQ

    What sources should be excluded?

    Exclude data without a legitimate access path, retention policy, or clear task value. Raw private messages, unrestricted transcript archives, secrets, and low-quality generated summaries should not enter by default. For each source, document the permitted users, expiry rule, and whether derived embeddings must be deleted with the original.

    Who approves graph schema changes?

    A named cross-functional owner should approve them: typically the platform team operating the graph plus representatives from security and the affected engineering domains. High-authority relationships such as ownership, approval, or solution status need stricter review than mechanically extracted imports.

    How should bad links be corrected?

    Preserve the original provenance, mark the link invalid for the affected revision, and record why it failed. Fix the extractor or curated assertion at its source, rebuild the relevant slice, and add a regression sample. Do not merely hide the edge in the UI while leaving agents able to retrieve it.

    What are the steps in compound engineering?

    The current plugin organizes work around planning, implementation support, review, and a compounding step that captures reusable learning; exact available skills should be checked in the pinned official repository. [CE-README-20260724] A code graph is not one of those documented first-party steps.

    Conclusion

    A credible compound engineering knowledge graph begins with narrow questions and evidence rules. Connect code, tests, documents, issues, pull requests, and solutions only when every relationship exposes provenance, revision, access scope, and status.

    The graph should help an agent find evidence, not manufacture authority. Keep Compound Engineering's reviewed solution records, the agent host's instructions, and the proposed external structural layer distinct. That separation makes conflicts inspectable and corrections possible.

  • CLAUDE.md vs Knowledge Graph

    CLAUDE.md vs Knowledge Graph


    Choosing CLAUDE.md vs knowledge graph is the wrong decision frame. CLAUDE.md is best for instructions the agent should follow. Solution documents are best for reusable explanations of validated fixes. A code knowledge graph is best for traversing current structural relationships. They overlap at the edges, but they do not have the same job, authority, or lifecycle.

    The practical design question is which layer should answer a given prompt—and how the agent should react when two layers disagree.

    Quick Verdict

    Use the smallest authoritative layer that matches the question.

    The practical CLAUDE.md vs knowledge graph verdict is therefore additive: keep policy in instructions, validated reasoning in solution documents, and current relationships in a revision-aware structural layer.

    Agent question Best first layer Why
    “Which test command must I run?” CLAUDE.md It is an explicit repository instruction.
    “Why did we avoid this retry strategy?” Reviewed solution document It preserves evidence and engineering reasoning.
    “Which handlers call this service on this commit?” Proposed external code graph It can traverse revision-aware structural links.
    “Is this claim safe enough to change code?” Source code and tests They remain the final verification boundary.

    Equal-weight comparison of instruction, solution-document, and knowledge-graph context

    CLAUDE.md and solution documents are prose. A code graph is generated structure. Neither format makes a claim correct by itself. Authority should come from source, scope, revision, and review status.

    The broader structural model is explained in Knowledge Graph for AI Coding Assistants; implementation-level graph governance is covered in Compound Engineering Knowledge Graph.

    What CLAUDE.md Is Best For

    CLAUDE.md is the right place for concise guidance that should influence work across many sessions: build and test commands, repository conventions, architectural boundaries, security requirements, and pointers to narrower documentation.

    Anthropic documents a hierarchy of memory and instruction files for Claude Code. Project instructions can live in CLAUDE.md or .claude/CLAUDE.md, and more specific files can apply at lower directory levels. These instructions are loaded into context; imports can organize them but do not make the imported content free. [ANTHROPIC-MEMORY-20260724]

    That behavior gives CLAUDE.md high reach and a real context cost. It should say “Always run the migration compatibility test before modifying schemas,” not contain the history of every past migration. Anthropic's current guidance recommends concise instruction files and suggests keeping each file under roughly 200 lines. [ANTHROPIC-MEMORY-20260724]

    Treat instructions as policy. Give them owners, review repository-wide changes carefully, and avoid facts that can be derived more reliably from the current code. An instruction that names a path likely to move should link to a stable concept or verification command instead.

    This makes CLAUDE.md one input to coding agent memory, not the whole system.

    What Solution Docs Are Best For

    Solution documents preserve reasoning that would be expensive to reconstruct. They can describe symptoms, failed approaches, root cause, the validated fix, affected components, tests, and invalidation conditions. This is the durable part of coding agent memory that turns one investigation into a reusable engineering record.

    The current Compound Engineering ce-compound skill selects one durable learning and writes it under solutions/; its fuller path can use session history as evidence. The separate ce-compound-refresh workflow is designed to maintain stale and overlapping solution documents. [CE-COMPOUND-20260724] [CE-REFRESH-20260724]

    In the current plan–work–review–compound sequence, solution-document persistence belongs to the compounding step. A search such as Claude md vs knowledge graph Reddit often mixes personal preference, generic memory advice, and several different products; this comparison instead keeps documented instruction behavior separate from the proposed graph layer.

    This makes solution docs more selective than transcripts and more explanatory than instructions. They should not tell every session what to do. They should become relevant when the current task matches the recorded problem class.

    The critical fields are scope and status. A solution must say which versions and components it covers, whether it was reproduced on the current revision, who reviewed it, and what would make it obsolete. Without those fields, confident prose can outlive the system it describes.

    What Code Knowledge Graphs Are Best For

    A code knowledge graph is best for questions that require traversal or filtering across many structural facts: callers, implementations, dependencies, routes, tests, ownership boundaries, and links from code to reviewed documents.

    In this article, the graph is a proposed external layer. It is not part of CLAUDE.md, Claude Code auto memory, or the official Compound Engineering plugin. Graphify can be evaluated as one possible implementation, but no first-party Compound Engineering–Graphify integration is claimed.

    Each graph fact should identify the indexed commit, source artifact, extraction method, and access scope. An edge saying CheckoutHandler CALLS PaymentService is useful only if the agent can tell which revision produced it and can open the source. Generated edges are candidates for retrieval, not instructions.

    Graphs are weaker at intent and causality. A call edge does not explain why a boundary exists, why a workaround was chosen, or whether a maintainer approves changing it. Those explanations belong in reviewed prose. Dynamic dispatch and runtime configuration can also make graph extraction incomplete.

    How the Three Layers Work Together

    Suppose an agent must change an idempotency rule.

    Context assembly workflow from rules and prior solutions through graph retrieval to verification

    1. CLAUDE.md supplies the non-negotiable rules: required tests, forbidden direct database writes, and the command for validating migrations.
    2. A relevant solution document explains the previous duplicate-settlement incident, the failed approaches, and the assumption that justified the current rule.
    3. A proposed external code graph retrieves the handlers, service methods, storage paths, and tests connected to the rule on the indexed revision.
    4. The agent opens the returned code and runs the required tests before accepting any graph or prose claim.
    5. After review, the team updates the layer whose knowledge changed: instructions for a new standing rule, the solution doc for revised reasoning, or the graph index for a new revision.

    The retrieval order is not fixed. A policy question starts with instructions. A recurring failure starts with solutions. A blast-radius question starts with structure. The final action still returns to source evidence.

    This layering also creates a useful conflict signal. If CLAUDE.md forbids a pattern that the solution doc recommends, stop and ask for review. If the graph contradicts a path named in prose, verify the current branch before deciding which artifact is stale.

    Limits and Trade-Offs

    Every layer can create context waste. Large instruction files load guidance that may be irrelevant. Too many solution documents create noisy retrieval and duplicate explanations. An over-connected graph returns a broad neighborhood instead of a bounded evidence set.

    Govern them differently:

    • audit CLAUDE.md for reach, clarity, and instruction conflicts;
    • refresh solution documents for overlap, scope, and expiry;
    • monitor graph ingestion for revision lag, extraction errors, permission leaks, and low-value edges.

    Do not use one global confidence score to hide these differences. A human instruction can be authoritative but outdated. A graph edge can be mechanically reproducible but incomplete. A solution document can be well reasoned but scoped to an older release.

    Measure the combined system on controlled repository tasks. Record whether the agent retrieved the right evidence, how much irrelevant context it opened, which claims required correction, and whether reviewers could trace the result to source. Avoid universal token-savings claims.

    FAQ

    Can one layer override another?

    Only through an explicit authority rule. Current source code and tests verify behavior; reviewed repository instructions define working policy; scoped solution records explain prior decisions; generated graph facts support navigation. When layers conflict, the agent should surface the conflict and request the responsible owner's review rather than silently selecting the most confident wording.

    Who audits generated graph facts?

    The platform team should monitor extraction and freshness, while subsystem owners validate samples and high-impact paths. Security, authorization, migration, billing, and deletion flows deserve stricter checks. Every returned fact should expose enough provenance for a developer to reproduce it against source.

    How should teams version context layers?

    Version prose in the repository when possible. Record the commit or release scope in solution documents. Stamp graph indexes and query responses with their source revision. If a task targets a different branch, qualify or reject facts that cannot be reproduced there.

    What does CLAUDE.md do in Claude Code?

    It supplies persistent instructions that Claude Code reads as context according to the documented user, project, and directory hierarchy. [ANTHROPIC-MEMORY-20260724] It is not a database of every fact about the codebase and should remain concise.

    Conclusion

    The useful answer to CLAUDE.md vs knowledge graph is division of labor. Put stable rules in concise instructions. Put validated reasoning in owned solution documents. Use a proposed external graph for revision-aware structural retrieval, then verify its output against code and tests.

    When each layer exposes its authority, provenance, and expiry, the agent can select context instead of accumulating it. That is a stronger foundation than asking one artifact to behave like all three.

  • Compound Engineering Large Codebase Memory

    Compound Engineering Large Codebase Memory


    The first fifty solution notes feel useful. The next five hundred can become another repository to search. In compound engineering large codebase work, the problem is not whether Markdown is good or bad. It is whether each type of context is represented in a form that matches the questions agents need to answer.

    Markdown remains the right format for explanations, decisions, and operating guidance. Large systems also need current structural links: which modules depend on a changed package, which implementations satisfy an interface, and which tests exercise a path. Those links should complement repository memory, not replace it.

    Why Large Codebases Stress Markdown Memory

    Markdown is organized for reading, while an agent often needs to traverse relationships. A document can say that the billing service calls a ledger adapter, but it cannot automatically show every caller, the revision on which the statement was true, or whether a second document disagrees.

    That is the central scaling problem in compound engineering large codebase work: durable prose remains valuable, while structural questions need revision-scoped evidence.

    Markdown notes multiplying and losing alignment as a repository grows

    Scale makes four problems visible:

    • Discovery: relevant notes are distributed across directories and use different vocabulary.
    • Granularity: one document mixes repository-wide rules with a one-version workaround.
    • Freshness: the explanation remains after symbols, modules, or ownership boundaries move.
    • Collision: several teams document the same subsystem from different perspectives.

    Compound Engineering's current ce-compound skill writes a focused durable learning to solutions/, and ce-compound-refresh can inspect the collection for staleness and overlap. [CE-COMPOUND-20260724] [CE-REFRESH-20260724] Those controls improve document hygiene. They do not turn prose into a revision-aware map of the repository.

    For the underlying graph concept, see Knowledge Graph for AI Coding Assistants. For a layer-by-layer decision, use CLAUDE.md vs Knowledge Graph.

    What Markdown Notes Still Do Well

    Markdown is excellent when the answer needs judgment rather than traversal. It can explain why a migration was staged, which incident revealed a design weakness, or why a tempting fix was rejected. Those are durable narratives with context that a call graph cannot infer.

    Use concise repository instructions for rules that should affect most sessions. Anthropic documents CLAUDE.md as an instruction mechanism loaded into Claude Code context and recommends keeping it concise. [ANTHROPIC-MEMORY-20260724] Use solution documents for validated problem-solution records that should be retrieved when a related issue appears. Use architecture decision records for decisions whose alternatives and consequences matter beyond one fix.

    Claude Code auto memory is a separate host feature; it is not the same thing as Compound Engineering's solution-document layer.

    Good notes state their scope. They identify a subsystem, the repository revision or release window, the evidence that validated the conclusion, an owner, and an invalidation condition. A note titled “Queue retries” is weak. A record titled “Prevent duplicate settlement after queue redelivery” with affected paths, tests, and version assumptions is useful repository memory.

    Prose should own meaning. It should not pretend to be an exhaustive index of the code.

    What Large Systems Need Beyond Notes

    Large repositories need a structural index that can answer bounded questions against the current revision. Useful relationships include:

    The awkward search phrase Compound engineering large codebase GitHub points to a reasonable evaluation task: inspect the current official repository rather than assuming an older guide describes the present plugin. The pinned repository used for this article documents the current command and skill surface. [CE-README-20260724]

    • package imports package;
    • function calls function;
    • type implements interface;
    • endpoint reaches handler and service;
    • test covers symbol or route;
    • owner maintains directory;
    • solution document concerns subsystem.

    This is a proposed external layer, not a documented feature of Compound Engineering. Each relationship should carry provenance: source file, line or symbol identifier, commit, extraction method, and confidence where static resolution is incomplete. Access scope matters too. A cross-repository link must not expose a private service name to a user who cannot read the source repository.

    The result is not “all company knowledge in a graph.” It is a narrower, testable map of relationships an agent otherwise has to rediscover. Human explanations remain in Markdown. The graph helps select the relevant code and documents.

    How Structured Links Improve Repository Memory

    Consider a task to change an authorization policy. A text search finds the policy name and several old incident notes. A revision-aware structural query can add the middleware that calls it, the endpoints that reach the middleware, the tests connected to those paths, and the solution record for a previous regression.

    Revision-aware structural links connecting code, tests, documents, and verified solutions

    The agent can then retrieve a small evidence bundle instead of reading every nearby file. In a proposed Graphify-assisted workflow, Graphify is one possible external code graph layer that returns structural candidates with provenance. It is not an official integration with Compound Engineering, and the agent must verify high-impact links against the repository before changing code.

    Structured links also make disagreement visible. If a solution document says service A owns validation while the current call path places it in service B, the system should surface a conflict rather than silently choose. That conflict becomes a review task: either the note is stale, the graph extraction is wrong, or the architecture drifted without documentation.

    This division of labor is the useful pattern: graph for retrieval and traversal, prose for reasoning, source code and tests for final verification.

    Limits and Maintenance Risks

    Structured memory has its own maintenance cost. Dynamic dispatch, generated code, reflection, runtime configuration, and feature flags can produce incomplete or misleading links. Branches can diverge. Renames can preserve behavior while breaking identity. An index built on yesterday's main branch should not be presented as fact for today's release branch.

    The maintenance plan should name an operator, a subsystem reviewer, an incident path, and a maximum acceptable lag for each indexed repository.

    Define freshness as a service-level property. Record the indexed commit, expose ingestion failures, and reject or qualify queries when the requested revision is outside the index. Sample important links against source code, especially around security, billing, migrations, and destructive operations.

    Avoid measuring success only by graph size. More nodes can mean more noise. Better measures include time to verified evidence, irrelevant files opened, stale claims detected, corrections after review, and coverage of the subsystem under test. Compare the same task, revision, agent, and model configuration before attributing an improvement to the memory layer.

    Finally, set deletion and retention rules. Removing a repository or branch should remove derived facts and embeddings. Historical links can be useful for incident review, but they should be clearly separated from current retrieval.

    FAQ

    When should notes become structured data?

    Convert a claim when agents repeatedly need to filter, traverse, compare, or validate it across many artifacts. Keep the explanation in prose, but represent stable identifiers and relationships as structured facts. A one-off decision rationale does not need a graph node simply because it can have one.

    Who validates architecture links?

    The team that owns the affected boundary should validate high-impact links. A platform team may operate the index and its extraction rules, while service owners review samples and investigate conflicts. Links used for security, data integrity, or migrations should be checked against code and tests before action.

    How often should repo memory be rebuilt?

    Rebuild structural facts whenever the required freshness contract would otherwise be violated—often on relevant commits or merges, not an arbitrary calendar schedule. Review prose on ownership changes, upgrades, incidents, and stated expiry conditions. The indexed revision should always be visible.

    What is a compound engineer?

    In this context, it is an engineer who turns completed work into reusable inputs for later work: clearer plans, reviewed changes, and durable solution records. The current Compound Engineering plugin encodes parts of that workflow, but the role is broader than any one tool. [CE-README-20260724]

    Conclusion

    Large codebases do not outgrow Markdown. They outgrow using Markdown for every context problem. Keep rules, explanations, and validated solutions in concise, owned documents. Add a proposed external structural layer when agents need revision-aware traversal across code and related records.

    Reliable repository memory is not the largest archive. It is the smallest evidence set that lets an agent find the relevant structure, understand the prior reasoning, and verify both against the current code.

  • Compound Engineering Memory Explained

    Compound Engineering Memory Explained


    An agent fixes a difficult bug on Monday. On Thursday, a second agent meets the same failure and starts from zero. The missing piece is not a larger prompt. It is a maintained record of what the team learned, why the fix worked, and when that knowledge stops being trustworthy.

    That is the useful meaning of compound engineering memory. It is an editorial model for durable engineering context, not a named memory product inside Compound Engineering. The current Compound Engineering workflow contributes solution documents and maintenance commands; Claude Code contributes instruction and auto-memory mechanisms; a code knowledge graph can add structural context as an external layer. Those systems have different owners and failure modes, so treating them as one feature creates more confusion than reuse.

    What Compound Engineering Memory Means

    Compound engineering memory is the part of the workflow that makes a solved problem cheaper to recognize and reason about the next time. It should preserve a small amount of high-value context:

    • repository rules that should guide many tasks;
    • validated solution records for recurring problem classes;
    • limited task history when it explains a decision;
    • revision-aware facts about code structure, when an external system supplies them.

    The official Compound Engineering repository does not document a feature named “Compound Engineering Memory.” Its current ce-compound skill identifies one durable learning from the completed work and writes it to the repository's solutions/ directory. A separate ce-compound-refresh skill reviews those documents for stale, overlapping, or conflicting guidance. [CE-COMPOUND-20260724] [CE-REFRESH-20260724]

    This distinction matters. Memory is not every transcript, search result, or note an agent ever produced. It is selected evidence with an authority level, an owner, and a review date. A repository becomes easier to work in when the agent can find the right record quickly and can also tell whether that record still applies.

    For the structural foundation, see Knowledge Graph for AI Coding Assistants. The scale-specific transition is covered separately in Compound Engineering Large Codebase Memory.

    Memory Layers in the Workflow

    A practical stack has four layers.

    Four-layer compound engineering memory stack with distinct persistence boundaries

    First, repository instructions such as CLAUDE.md state stable rules: build commands, test expectations, architectural constraints, and working conventions. Claude Code loads these instruction files into context, which makes them appropriate for concise guidance that should affect most sessions. [ANTHROPIC-MEMORY-20260724]

    Second, Compound Engineering solution documents explain validated problem-solution pairs. The current ce compound workflow writes one focused learning rather than a generic session summary. That keeps the record closer to an engineering runbook than a diary. [CE-COMPOUND-20260724]

    Third, task history provides temporary evidence. The current Compound Engineering plugin can inspect session history in its fuller compounding path, but that history is an input to distillation, not the durable artifact itself. [CE-COMPOUND-20260724]

    Fourth, an external code knowledge graph can represent relationships such as “handler calls service,” “type implements interface,” or “test covers endpoint.” That layer is not part of the official plugin. It is a proposed integration pattern for teams whose repositories need queryable structural context.

    Where Memory Breaks Down

    Memory fails quietly. A note can remain plausible after the code has changed. Two solution documents can recommend different fixes because they were written for different releases. A task transcript can preserve an abandoned hypothesis next to the final explanation. An inferred code link can outlive the commit that supported it.

    The search phrase Compound engineering plugin often collapses these layers into one thing. The safer model is to decide which layer should answer each question and which source has authority.

    Three controls reduce that risk.

    Provenance, scope, review, and expiration controls for durable engineering memory

    Provenance records where a claim came from: a file and revision, an issue, a test result, or a reviewed solution. Scope says which service, version, or configuration the claim applies to. Status distinguishes proposed, validated, superseded, and expired records.

    The current ce-compound-refresh workflow is designed to find stale and overlapping solution documents, then route meaningful changes through review. [CE-REFRESH-20260724] That is useful maintenance, but it does not make every note correct automatically. Teams still need a named owner for high-impact guidance and a rule for resolving conflicts.

    Expiration should be based on evidence, not age alone. A stable explanation of a protocol may remain valid for years. A workaround tied to a specific dependency version may expire at the next upgrade. The memory record should carry the condition that invalidates it.

    How Code Knowledge Graphs Help

    Markdown is good at explaining why. It is weaker at answering structural questions across thousands of changing files. A code knowledge graph can complement solution documents by making relationships explicit and queryable.

    In a proposed external design, every graph fact should include its source revision, extraction method, confidence, and access scope. An agent could then ask for the callers of a changed function, the tests linked to those callers, and solution documents associated with the same subsystem. The graph narrows the search space; the solution document explains the reasoning behind a previous fix.

    Graphify can be evaluated as one possible external code graph layer, but that is not an official Compound Engineering integration. The useful contract is vendor-neutral:

    1. retrieve structural facts for the current revision;
    2. link facts to reviewed human or agent-authored explanations;
    3. show provenance in the agent response;
    4. fall back to repository inspection when evidence is missing or stale.

    A graph should not be treated as a truth oracle. Generated edges can be incomplete, dynamic calls can be hard to resolve, and branch differences can invalidate otherwise correct facts. The gain is better navigation and auditable retrieval, not certainty.

    Limits and Governance Notes

    The memory stack needs governance proportional to its effect. A typo in a local scratch note has low impact. A repository-wide instruction that changes migrations or authorization checks has high impact and should require review.

    Keep repository instructions short and stable. Anthropic's current guidance recommends concise CLAUDE.md files and warns that overly large instruction files consume context and reduce adherence. [ANTHROPIC-MEMORY-20260724] Put detailed, situation-specific learning in solution documents that can be retrieved when relevant. Keep raw transcripts temporary unless a compliance or debugging requirement justifies retention.

    For an external graph, define who can ingest private repositories, which branches are indexed, how deleted code is removed, and whether sensitive identifiers can appear in embeddings or logs. A structural fact should be revision-aware, and any cross-link to an issue or pull request should respect the source system's permissions.

    Finally, measure usefulness with controlled tasks. Compare the same repository revision, task, model, and tool configuration. Record retrieval latency, irrelevant context, correction rate, and whether the final answer cites evidence. Do not infer a universal token-saving percentage from one successful session.

    FAQ

    Who should own memory cleanup?

    The team that owns the affected subsystem should own the meaning of its durable records. A platform or developer-experience team can maintain templates, refresh jobs, and retention rules, but it should not silently decide whether an authentication or data-integrity workaround is still valid. Assign a reviewer in the solution document and route high-impact changes through normal code or architecture review.

    How should teams handle conflicting notes?

    Do not merge them into a vague compromise. Record the scope and evidence for each note, reproduce the relevant behavior on the current revision, and mark one record as current only after review. Keep a link to the superseded record when it explains historical behavior, but remove it from default retrieval.

    When should old solutions expire?

    Expire a solution when its stated assumptions no longer hold: the referenced code is removed, a dependency version changes, the underlying incident class is eliminated, or a newer reviewed solution supersedes it. Time-based review reminders are useful, but the invalidation condition is more informative than a fixed age.

    What is compound engineering in AI?

    It is a workflow in which completed engineering work produces reusable knowledge for later work. In the current Compound Engineering plugin, that includes planning, review, and a compounding step that captures a durable solution. [CE-README-20260724] It does not mean saving every conversation forever.

    Conclusion

    Compound engineering memory works when each context layer has a narrow job. Instructions define stable rules. Solution documents preserve validated reasoning. Task history remains temporary evidence. A proposed external code graph supplies revision-aware structural links.

    The operational test is simple: can an agent retrieve a relevant claim, see where it came from, know whether it applies to the current code, and discover who can correct it? If any part is missing, the repository has accumulated notes, not reliable memory.

  • Kimi K3 Context Window vs Repo Structure

    Kimi K3 Context Window vs Repo Structure


    Kimi K3's context window can put more code and project material in one request, but repository structure still determines whether a coding agent can find, interpret, and verify the right evidence. Use the larger window to carry a scoped task packet and retrieved files. Use structure—module boundaries, dependency paths, tests, decisions, and revision-linked graph queries—to discover relationships and keep the plan reviewable.

    The current official Kimi API documentation describes kimi-k3 with a one-million-token context window. Kimi Code, however, documents two K3 choices: k3 is up to 1M only on eligible membership tiers, while k3-256k is fixed at 256K. The meaningful comparison is therefore not “1M versus structure.” It is the effective client window and context policy versus a source-linked model of the repository.

    Quick Verdict

    Choose a larger Kimi K3 context window when a known task needs several related files, tests, decisions, or tool results together. Choose structured repo context when the difficult part is finding the relevant relationships across modules, generated layers, documents, and history. Use both for high-impact multi-file work: retrieve a small, revision-bound evidence set, give it to K3, inspect current source, and verify the change.

    Need Larger context helps most when Repo structure adds most when Required final check
    Diagnose a known subsystem The relevant files and logs are already identified The failure may cross an unknown dependency boundary Read source and reproduce the failure
    Plan a multi-file change The task packet includes contracts, tests, and decisions Consumers, configuration, or ownership are unclear Review cited paths and affected tests
    Refactor an interface The agent must compare several implementations at once Callers, schemas, migrations, and rollout paths must be found Run compatibility and regression checks
    Reuse project knowledge A stable brief can remain in the request Facts must survive sessions and model changes with provenance Match every result to a revision

    This page owns the K3-specific capacity-versus-structure decision. It does not prescribe a benchmark or test rubric; Kimi K3 Codebase Understanding Tests owns that separate evaluation problem.

    What a Larger Context Window Helps With

    A larger window reduces the need to choose between a task description, code excerpts, a failing test, a decision record, and prior tool output. It can make long context coding more coherent when those materials are known, current, and traceable. Kimi's K3 quick-start documentation also describes automatic prefix caching for repeated long prefixes, which can make a stable task packet operationally practical on the API surface.

    Kimi Code adds an important constraint: the actual window depends on model ID and plan. Its current model documentation says k3 can reach 1M for higher-tier members, whereas k3-256k is a 256K variant. It also notes that a tool may compact a session when switching from the 1M model to the 256K model if the current history exceeds 256K. A coding agent can therefore have less usable evidence than a headline context number suggests.

    Use the window deliberately for:

    • a task contract with desired behavior, constraints, and non-goals;
    • code excerpts and tests already selected by a maintainer or retrieval step;
    • recent, source-linked architecture and decision records;
    • tool results that include the command, revision, paths, and uncertainty; and
    • a final plan that separates observed facts from hypotheses.

    Abstract diagram showing a large Kimi K3 context packet receiving scoped files, tests, decisions, and tool evidence

    More tokens do not make every input equally valuable. A large prompt can preserve an obsolete configuration, an earlier wrong assumption, a hidden consumer, or duplicated summaries. The window is capacity. Selection, freshness, and verification remain workflow responsibilities.

    What Repo Structure Adds Beyond Tokens

    Repository structure turns relationships into evidence the agent can query. At minimum, it identifies module boundaries, entry points, public interfaces, dependency paths, configuration, tests, ownership, and decisions. A revision-bound code knowledge graph can make those relationships explicit across source and project material, but it should return source paths and an indexed commit rather than a free-floating answer.

    This is valuable because software systems have relationships that token order hides. A schema can affect a worker defined far from its API route. A feature flag can alter behavior without appearing in an import tree. A generated client can conceal a consumer. A decision record can explain why a seemingly simple refactor is forbidden. Reading more files may find these facts, but it does not guarantee that the model selects or interprets them correctly.

    For a coding agent, structured repo context should answer questions such as:

    1. Which modules own the behavior and public contract?
    2. Which direct and indirect consumers may break?
    3. Which tests, fixtures, migrations, and deployment settings constrain the change?
    4. What source or decision record supports each relationship, and at which revision?

    That is why repository structure AI is not a substitute for K3 and K3 is not a substitute for structure. The model uses evidence; the structure discovers and qualifies it. The practical workflow in Kimi K3 Context Engineering for Coding Agents shows how to turn those answers into a task packet.

    Where Long Context Still Fails

    Long context fails when the important fact is absent, stale, ambiguous, or lost in a broad packet. It also fails when a client compacts the history, changes model IDs, omits tool-call history, or configures a context cap below the model's advertised maximum. Kimi's own K3 guidance says multi-turn and tool workflows must preserve the full assistant message, while Kimi Code warns that model changes invalidate cache context and can trigger compaction. These are explicit operational limits, not edge cases to ignore.

    Common failure patterns include:

    • False locality: The agent edits files near a symptom but misses a configuration or external consumer.
    • Stale authority: A design note or prior summary conflicts with the current branch and is treated as fact.
    • Relationship hallucination: The model infers a call or ownership link that source does not support.
    • Prompt overload: Relevant evidence is present but not distinguished from irrelevant history.
    • Unverified completion: The patch looks coherent but focused tests, contract checks, or rollout evidence are absent.

    Do not solve these failures by simply maximizing the window. Require file and symbol citations, record the effective context setting, give tool results their source revision, and make the agent state what it could not inspect. If the task crosses a high-risk boundary, route it to a human reviewer before edits are merged.

    How to Combine Context Windows and Code Graphs

    Combine the approaches in sequence. First use a repository index or knowledge graph to retrieve the narrowest current set of modules, relationships, tests, decisions, and gaps. Then place that evidence in K3's context with the task contract. Let the agent use tools to inspect current files and run focused checks. Finally, refresh or invalidate affected graph records after the change.

    Step Window role Structure role Review signal
    Scope the task Carries goal, non-goals, and accepted constraints Names likely boundary and owner No unapproved expansion
    Retrieve evidence Holds selected files and tool output together Finds callers, dependencies, docs, tests, and gaps Sources point to task revision
    Plan Compares evidence and states uncertainty Keeps relationships typed and attributable Every critical claim is cited
    Change and verify Retains the patch and test evidence Identifies affected consumers and stale records Tests and human review pass

    Graph retrieval should not be treated as an answer key. A graph can miss runtime behavior or become stale; K3 can misread a correct result. Pair graph output with source inspection and tests. Kimi K3 Knowledge Graph for AI Developers explains the graph layer in detail, while Macaron Context vs Code Knowledge Graph offers a separate product-context comparison. For Graphify's broader code-relationship work, start at the Graphify hub.

    Abstract decision loop combining task scope, repository relationship discovery, a focused context packet, verification, and refresh

    FAQ

    What context window claims should teams verify?

    Verify the official model ID, the API or client surface, account-tier entitlement, configured client context limit, compaction behavior, reasoning setting, and whether tool and prior-assistant messages are retained. For K3, distinguish the API's one-million-token documentation from Kimi Code's plan-dependent k3 capacity and fixed-256K k3-256k variant. Record the effective setting for every serious trial.

    When should teams prefer structured repo context?

    Prefer it when the task requires discovering callers, ownership, configuration, schema consumers, tests, historical decisions, or relationships across repositories and documents. It is also the safer default when multiple agents or sessions need a shared, reviewable evidence layer. Use long context after that retrieval step, not in place of it.

    Can long context and code graphs conflict?

    Yes. A long prompt can carry an old branch summary while a graph is indexed from a newer revision, or the graph can be stale while the prompt includes current files. Compare revisions and sources, inspect the disputed code, and refresh or invalidate the graph record. Never settle the conflict by assuming the larger context or the more polished graph output is correct.

    Conclusion

    Kimi K3 gives developers substantial context capacity, but capacity does not establish repository structure, freshness, or authority. Use the effective K3 window to reason over a focused evidence packet. Use structured repository context to discover relationships and preserve provenance. Use source, tests, and human review to decide whether a change is safe.

    The durable rule is simple: more code in context helps only after the team has identified which code, relationships, and constraints matter for the task at the current revision.

  • Kimi K3 Knowledge Graph for AI Developers

    Kimi K3 Knowledge Graph for AI Developers


    A Kimi K3 knowledge graph workflow gives the model structured, revision-bound evidence about a repository; it does not give K3 a built-in graph or replace source inspection. K3's large context can carry code and tool results. A code knowledge graph adds named entities, typed relationships, source provenance, and freshness rules so an agent can ask narrower questions before it plans or edits.

    Kimi documents K3 with a one-million-token API context window and tool-calling support, and Kimi Code exposes a k3 coding-model surface with plan-dependent context. Those capabilities are useful transport and reasoning capacity. They are not documentation that K3 maintains a code graph, automatically knows repository history, or can validate graph edges. The graph remains an external evidence layer that a team must build, refresh, and audit.

    What a Kimi K3 Knowledge Graph Means

    For AI developers, a code knowledge graph is a queryable representation of repository facts. Nodes can represent modules, files, symbols, services, schemas, tests, configuration, decisions, or documentation. Edges can represent imports, calls, ownership, data flow, build dependencies, test coverage, or a claim's source. Every useful result should name the revision and the evidence behind it.

    The phrase “Kimi K3 knowledge graph” therefore describes an integration pattern, not a Moonshot product feature. The model receives a focused graph query or evidence packet, reasons over it, and then reads the current source or runs a tool when the decision is consequential. The agent does not get to promote a guessed relationship into graph truth.

    Use this ownership model:

    Layer Responsibility What it should not claim
    Kimi K3 Interpret task instructions, request tools, synthesize an answer or plan Permanent repository memory or verified graph edges
    Graph/index service Return versioned entities and relationships with provenance Runtime behavior it has not observed
    Source, tests, and runtime checks Establish current implementation and behavior Architectural intent without a decision record
    Human owner Approve contracts, risk boundaries, and corrections That a generated summary is automatically current

    This separation makes failures diagnosable. If an answer is wrong, the team can ask whether the model reasoned badly, the graph was stale, the query was too broad, source was missing, or the approval rule was skipped.

    Long Context vs Structured Code Knowledge

    Long context and structured code knowledge solve different parts of the problem. A K3 request can carry a large task packet, code excerpts, decisions, and tool results. That helps when a task needs several related artifacts in one reasoning window. It does not make relationships explicit, select the relevant evidence, or reveal that a dependency was rebuilt after the packet was created.

    Structured code knowledge makes relationships queryable. An agent can ask for callers of a symbol, the services that consume a schema, the tests around a route, or the source records behind a design constraint. The answer should still be a starting point, not a patch instruction. Dynamic dispatch, generated code, reflection, plugins, undocumented operational dependencies, and stale indexing can all make an edge incomplete.

    Abstract comparison between raw context capacity, revision-bound code relationships, and source verification for Kimi K3

    The decision rule is practical:

    • Use a bounded context packet when the task has a known scope and the relevant artifacts can be cited directly.
    • Use graph retrieval when the hard question is relationship discovery across modules, documents, tests, and ownership boundaries.
    • Read source and run verification when the answer will change behavior, permissions, data, or a public contract.

    The two approaches can work together. A graph query finds a narrow evidence set; K3 reads it in context; tools confirm the current revision; a reviewer evaluates the resulting plan. The Kimi K3 Context Engineering guide explains how to make that packet accountable.

    What Graphs Add for AI Developers

    A useful AI code graph adds traceability more than it adds prose. Instead of asking an agent to remember a long repository dump, give it a relationship query with file and symbol evidence. That is especially valuable when the codebase has repeated names, indirect dependencies, generated layers, design records outside source, or multiple agents working from different sessions.

    Four graph capabilities are worth prioritizing:

    1. Module and ownership maps: Show where a responsibility begins, which public interfaces cross its boundary, and who can review a change.
    2. Dependency and impact paths: Connect imports, calls, schemas, configuration, queues, build artifacts, and affected tests without pretending all edges are runtime proof.
    3. Decision and document links: Connect a technical choice to its source record, owner, date, and the code paths it constrains.
    4. Freshness and provenance: Attach an indexed commit, generation time, extractor version, and source locations to every important result.

    K3's official API documentation supports custom tools, tool choices, and tool-result turns. That makes it possible to expose graph queries through an agent harness. The documentation is a protocol contract, not a guarantee that a graph query is correct; the harness must return clear evidence, respect access boundaries, and preserve the complete tool-call history required by K3's multi-turn flow.

    For a product-level model of structured repository evidence, visit the Graphify knowledge-graph hub. For a comparison that keeps a model-specific context system separate from graph retrieval, Macaron Context vs Code Knowledge Graph offers a related decision boundary.

    When Graph Retrieval Can Still Fail

    A graph can be wrong in a more precise way than a raw prompt, but it can still be wrong. Static extraction can miss dynamic imports. A call graph can overapproximate a dispatch path. A code graph may not see private deployment configuration. A document link may be obsolete. A branch can move after the graph is indexed. And a retrieved neighborhood can be so broad that K3 treats incidental relationships as task requirements.

    Build failure handling into the response format. A graph query should return its indexed revision, timestamps, source paths or symbols, relationship type, confidence or unknown state, and a statement of what it cannot observe. Make the agent say which edges it inspected in source and which remain graph-derived. This prevents a polished dependency diagram from functioning as an unearned fact.

    The same rule applies to model memory. K3 may have earlier messages, a compacted summary, or client-managed cache context, but those states are not authoritative over a revision-bound source record. When graph context and a prior model statement disagree, treat the disagreement as a retrieval task, not a vote.

    How to Combine Both Approaches

    Use a two-stage workflow. First, query a versioned graph for the smallest set of modules, dependencies, tests, decisions, and unknowns that can bound the task. Second, place that evidence and its provenance into K3's context, let the agent inspect current files and tools, and require an explicit plan before an edit. K3's kimi-k3 API documentation says long conversations and tool calls must carry the full assistant message forward; retain that record so later reviewers can reconstruct the evidence path.

    Then add governance:

    Stage Required artifact Stop condition
    Retrieve Revision, sources, relationships, and known gaps Graph revision does not match the task revision
    Interpret K3's evidence-backed plan and uncertainties Plan contains an uncited critical claim
    Verify Source reads, focused tests, and diff review A graph edge is relied on but never checked
    Refresh New index or marked stale records after change Changed paths invalidate indexed facts

    Keep the graph independent of a single model or provider. That lets a team reuse the same evidence layer when a client or model changes, while preserving access controls and audit records. CC Switch Knowledge Graph Workflow shows why provider routing and structured repository evidence should not be conflated.

    Abstract lifecycle for versioned sources, code relationships, freshness audit, selected agent evidence, and graph refresh

    FAQ

    What facts should a code graph expose?

    Expose facts that a reviewer can trace: entity names and types, source paths and symbols, relationship types, indexed revision, generation time, owner, links to supporting documents, and explicit unknowns. Start with module boundaries, public interfaces, dependencies, tests, configuration, and decisions. Do not expose a generated narrative without its source locations.

    How should teams audit graph freshness?

    Store the indexed commit and extractor version on every result, invalidate or flag records when relevant files, configuration, schemas, or lockfiles change, and sample important edges against current source and tests. A high-risk task should refuse graph evidence from an unmatched revision instead of silently accepting it.

    Can graph context conflict with model memory?

    Yes. A prior prompt, session summary, or cached prefix can describe an earlier branch or a mistaken inference. Treat the conflict as an evidence mismatch: compare revisions, inspect the named sources, update or invalidate the graph record, and make a human decide if the technical contract is ambiguous. Neither a large context window nor a graph result wins automatically.

    Conclusion

    Kimi K3 can reason over large, tool-assisted context, but that is different from maintaining structured repository knowledge. A well-governed code graph supplies versioned relationships and provenance; K3 turns a focused evidence set into questions, plans, and proposed changes; source, tests, and humans remain the authority.

    Combine them when relationship discovery is the bottleneck. Keep them separate when reporting capabilities: the model is not the graph, the graph is not the repository, and neither removes the need to verify the current revision.