Setting up a persistent knowledge graph for a coding agent changed how reliably it could run complex local workflows. Instead of stuffing huge instruction manuals into every session, the agent loads only the entities and neighbors relevant to the task at hand.

Key-value graph vs. markdown skills

On an end-to-end local stack workflow (identifying projects, pulling code, building containers, bringing services up, and logging in with test credentials), I compared a tuned multi-file markdown skill against a Neo4j memory graph:

  • Skill files: 6 files / 18,618 bytes loaded, 8 minutes execution time, 35% context (~40k tokens)
  • Graph memory: 1 hub / 4,839 bytes loaded, 2 minutes execution time, 13% context (~8.4k tokens)

The graph-backed run came in roughly 75% faster and leaner, and showed stronger reasoning, likely because fewer prescriptive instructions leave the model room to think instead of fighting prompt bloat.

  • Skill files tradeoffs: Very reliable once tuned, but slow and fragile to maintain, with weaker reasoning under heavy rules.
  • Graph memory tradeoffs: Flexible, stronger reasoning, and faster, though you have to balance "too much vs. too little" detail and attach lightweight rules so steps aren't skipped.

Attaching lightweight rules directly to specific tool and project entities gave the best of both worlds: strictness where commands are picky, flexibility everywhere else.

From flat key-value lookup to graph traversal

The next leap was moving from "load everything you think you might need up front" to graph traversal:

  • Load one small entry hub (general_workflow), which holds pointers to neighboring entities and traversal rules.
  • Let the agent follow directed relations (SUBCOMMAND_OF, GOVERNED_BY, CONSUMES_PACKAGE) just-in-time as the task narrows.
  • Feed session friction back after a run: pass noisy transcripts to the agent so it refines observations and rules directly in the graph rather than editing sprawling skill files.

Why this works better than monolithic skills:

  • Focus: Queries only the entity the task touches.
  • Awareness: Neighbor names provide a cheap index without dumping full bodies.
  • Just-in-time detail: Conditional rules signal when to dig deeper into a neighbor.

Two parsing strategies (and a subagent trap)

When populating a graph from real systems, two parsing strategies emerged:

  1. Batched direct reads: Best for dozens of small structured config files (compose YAMLs, shell scripts, task definitions). Read 3-6 files at a time, write entities immediately, commit, and move on before context fills up.
  2. Pre-parse pipeline: Best for huge specs (76K-line OpenAPI schemas or deep CLI --help trees). Parse raw specs into clean normalized JSON via Python scripts first, then dispatch parallel workers per domain so agents never touch raw megabyte specs.

One practical lesson during graph generation: when ingesting source files requires reading everything in the main context, telling an LLM "do not delegate to subagents" wasn't enough, it still spawned them. Adding a small hook blocking the Agent delegation tool forced direct, batched reads and kept the context intact.