Pathrule

Category

The AI coding context layer

An AI coding context layer indexes a team's typed knowledge (memories, rules and skills) by path and delivers only the relevant slice to the AI assistants that team uses, before the first tool call. Pathrule implements that layer, and Pathrule Studio is the workspace built on it.

AI coding context layer

The routing layer between a team's typed knowledge (memories, rules and skills) and the AI coding assistants the team uses. It stores that knowledge in a path-indexed graph and delivers only the slice that applies to the current working directory at hook time, before the first tool call.

It is not the AI assistant. It is not the IDE. It is not a source-code indexer. It is the missing layer that turns one engineer's CLAUDE.md tweak into a team's living, reviewable knowledge, and keeps the assistant's context window focused on the work in front of it.

Why the category exists

The first wave of AI coding assistants treated context as one flat instruction file: CLAUDE.md, AGENTS.md, .cursorrules. That model works when one person uses one agent on one repository and the conventions fit on a page. It breaks at the second person or the second agent, whichever arrives first.

Three structural problems emerge at team scale:

  • Signal loss. Long instruction files lose their hold on the model. Each new rule dilutes the rest.

  • Tool sprawl. Each AI tool reads a different file. The same team has to maintain the same rules in three places, with no shared review trail.

  • Lost team knowledge. What one engineer learned this morning does not reach the assistant the next teammate opens this afternoon.

An AI coding context layer treats these as the same problem: team knowledge needs its own home, separate from any single tool's instruction file, and the model needs a focused slice of it on every turn, not the whole file.

Five ways teams give an agent context

  • Instruction files. CLAUDE.md, AGENTS.md, .cursorrules. Right when one person uses one agent on one repository: the file is checked in, the agent reads it, and nothing else has to exist. It breaks at the second person or the second agent, because team knowledge must now travel between people or tools and each tool wants its own copy.

  • Memory APIs. A service you call to store and recall facts, such as Supermemory or Mem0. Right when you are building memory into your own product and you own the call site. As an agent's context layer it is quiet by design: it answers when it is queried, so a constraint the agent never thought to ask about never arrives.

  • Vector search over the repository. Embed the codebase and retrieve the nearest chunks. Right when what you need is written down somewhere and you cannot predict where. It cannot help with a decision that is in no file at all, and similarity is a guess about relevance where a path is a fact about it.

  • Agent workspaces. A desktop app that runs several agents, each in its own checkout, such as Xirp. Right when parallel work is the bottleneck. Isolation is a real problem genuinely solved, but a second checkout is just a different folder: it does not decide which knowledge belongs to which part of the tree.

  • A path-scoped context layer. Team knowledge stored against paths and delivered before the agent's first tool call, which is what Pathrule is. Right as soon as either a second person or a second engine is involved: a teammate who has to receive what you learned, or you switching between Claude Code, Codex and Cursor on the same repository. Overkill only if you are one person running one agent.

How to tell which one fits

ApproachChoose it whenWhen knowledge arrivesSurvives a tool change
Instruction filesOne person, one repository, few conventionsEvery turn, all of itNo, each tool reads its own file
Memory APIYou are building memory into your own productWhen something queries itYes, if you own the call site
Vector searchThe answer is written down, location unknownWhen something queries itYes, though the index is yours to run
Agent workspaceParallel agents are the bottleneckPer session, not per pathNot the point: it is the tool
Path-scoped layerOne person across several engines, or a team on one repositoryBefore the first tool call, scoped to the pathYes, the knowledge lives outside every tool

Two of these are not competitors. A memory API inside your own product and a context layer for your agents can both be true at the same time.

What a context layer carries

Memories

What the team has learned

The "we tried that, it did not work" facts that disappear when the engineer who learned them moves on. Attached to the path where they apply.

Rules

What to do or avoid

Advisory and strict constraints. The hard guardrails (no console.log in /apps/web) and the soft preferences (prefer named exports in /packages/ui).

Skills

Multi-step playbooks

Procedures the team has worked out: how to add a migration, how to ship a feature flag, how to run the security review. Invokable by name.

Path-indexed

Knowledge lives near its work

Every memory, rule and skill is attached to a path. A rule for /services/billing never fires when the model is working in /apps/mobile.

What it is not

  • Not an AI coding tool. A context layer does not generate code, run inference or replace your IDE. It is the layer between your team and whichever assistant you choose.

  • Not a code indexer. A well-built context layer does not read, scan or upload source files. It stores only the typed content the team writes.

  • Not tied to a chat interface. The Context Layer works beneath Studio's surfaces and beneath the agents you already run elsewhere. Whichever one holds the prompt, it is fed rather than replaced.

  • Not a single-file replacement. Your CLAUDE.md, AGENTS.md or .cursorrules can keep doing what they are good at: repository-wide constants. The context layer carries the path-scoped knowledge those files cannot model well.

Single file vs context layer

Single instruction fileAI coding context layer
One file at repo root, every turn, every path.Path-scoped slice for the directory the model is working in.
Token cost grows linearly with team rules.Token cost scales with the relevant slice, not the whole rule set.
One assistant per file. Tool churn loses team knowledge.One layer, many assistants. Tool churn does not reset the team.
Editable by anyone with push. No structured review.Reviewable knowledge graph with row-level security and a stale-rule detector.
Knowledge passed along by tribal memory.Knowledge written once, delivered automatically to the next teammate's session.

How Pathrule implements the context layer

Pathrule implements the context layer as a path-indexed knowledge graph with hook-time delivery. Memories, rules and skills are stored in a graph that mirrors your repository's folder structure, and at hook time only the matching subtree reaches the model. Studio is the workspace on top of it; the CLI, the VS Code extension and MCP are the other ways in.

  • One MCP server. The same knowledge drives every supported AI coding assistant.

  • Hook-time injection. Pathrule runs at PreToolUse and UserPromptSubmit, before the first tool call, on every turn.

  • Three node types. Memories, rules and skills. Typed, versioned, reviewable.

  • Row-level security. Team membership is enforced server-side. No service-role keys on any client.

  • Source-code privacy. Pathrule never reads, scans or uploads source files. The full breakdown is on the Security page.

What it looks like in a session

Here is the same task two ways. A developer opens an assistant and asks it to add a discount to an order. The detail that matters is not in any file the model can read: on this codebase, a coupon lives on the line item, never on the order total. One engineer learned that the hard way last quarter. Without a context layer, that fact is tribal knowledge a code scan cannot surface.

Before and after: one task, two ways

Without a context layerWith a context layer
The assistant opens the order module, reads the schema, follows imports into pricing and tax, and reads the discount handler to infer where a coupon attaches.The matching slice for the order path arrives at hook time, before the first tool call. The model already knows coupons live on the line item.
It writes a plausible change that attaches the discount to the order total. The diff compiles. It is wrong in the way the team already knows about.It applies the discount to the line item on the first pass, because the rule was in context before it started.
A reviewer catches it, explains the line-item convention again, and the loop repeats. The knowledge stays in one person's head.A strict rule can block a change that attaches the discount to the wrong place before it lands, so the correction happens before review, not after.
Many files read, many tool calls, a long input window, and a wrong turn that costs a review cycle.A short, focused context window and a targeted change, because only the rules for this path were injected.

What the difference adds up to

  • Fewer files read. On a public reference task, the context layer ran with about 10 times fewer files read, because the model did not have to scan the repo to re-derive what the team already knew.

  • Fewer tool calls. About 5 times fewer tool calls on the same reference task. The relevant knowledge arrived first, so the model spent fewer turns searching.

  • A smaller input window. About 85 percent fewer input tokens on that task, because only the path-scoped slice was injected rather than a whole instruction file or a pile of file reads.

  • Faster wall-clock time. 5 to 8 times faster on knowledge-heavy edits in the same comparison. These are figures observed on a reference task, not a per-session guarantee.

Why the scan does not help

The before column is not a tooling failure. A capable assistant did exactly what it should: it read the code and reasoned about it. The miss is structural. The fact it needed (coupons attach to the line item) is a team decision, not something the source files state. A context layer carries that decision to the path where it applies, on every turn, so the model starts from what the team already learned instead of rediscovering it.

What the install looks like

Pathrule does not patch your AI tool. It writes a hook entry into the configuration file the tool already reads at startup. The hook script is a single, unobfuscated Node.js file. Removing the entry removes Pathrule instantly.

~/.claude/settings.json
{
  "hooks": {
    "PreToolUse": [
      { "command": "node ~/.pathrule/bin/pathrule-hook.js pre-tool-use" }
    ],
    "UserPromptSubmit": [
      { "command": "node ~/.pathrule/bin/pathrule-hook.js user-prompt-submit" }
    ]
  }
}

Supported AI coding assistants

Frequently asked questions

What is an AI coding context layer?

The routing layer between a team's typed knowledge (memories, rules and skills) and the AI coding assistants the team uses. It indexes that knowledge by path and delivers only the relevant slice to the model at hook time, before the first tool call.

How is a context layer different from CLAUDE.md or AGENTS.md?

CLAUDE.md and AGENTS.md are flat files that ship every instruction on every turn. A context layer is one level higher: it stores knowledge in a path-indexed graph and routes only the matching subtree into the model, so each instruction the model sees is load-bearing for the current path.

Is a context layer an AI coding tool?

No. A context layer does not generate code, run inference or replace your IDE. It is the layer between your team and whichever AI coding assistant you choose, making each session smarter without locking the team to a single tool.

What does a context layer carry?

Three kinds of typed team knowledge: memories (what you have learned), rules (what to do or avoid) and skills (multi-step playbooks). It does not carry source code, repository indexes or model prompts.

How does Pathrule implement the AI coding context layer?

Pathrule stores team knowledge in a path-indexed graph, exposes a single MCP server and runs at the PreToolUse and UserPromptSubmit hook points already supported by Claude Code, Cursor, Codex and Windsurf. Only the slice that matches the current working directory is injected into the model.

Does a context layer see source code?

A well-built context layer does not. Pathrule never reads, scans or uploads source files. The cloud stores only the typed memories, rules and skills the team writes. Full breakdown on the Security page.

Which context tool should I choose?

It depends on which problem you actually have. One person running one agent on one repository is served by a checked-in CLAUDE.md. Memory inside your own product is a memory API. Knowledge that is written down but hard to locate is vector search. Parallel agents in isolated checkouts are an agent workspace. A path-scoped context layer is for the moment a second engine or a second person enters the picture, which for most people is the second engine. The five approaches, and where each one breaks, are set out above.

What is the difference between a context layer and a memory API?

Delivery timing. A memory API answers when it is queried, so a constraint the agent never thought to ask about never arrives. A context layer reads the path the agent is about to work in and delivers the matching knowledge before the first tool call, whether or not the agent would have asked for it.

Is vector RAG a context layer?

No. Vector retrieval finds text that is already written down, ranked by similarity to a query. A context layer carries decisions that are in no file, keyed to the path they govern, and it can enforce them: a rule has a scope, a priority and an enforcement level where a store returns text. Similarity is a guess about relevance; a path is a fact about it. Long-form: Vector RAG vs path-scoped context.

Do I need a context layer if I work alone?

Working alone is not really the question. How many agents you run is. One person with one agent and a page of conventions is exactly what an instruction file is good at. One person running Claude Code, Codex and Cursor on the same repository already has the problem a context layer solves: what you teach one of them stays inside it, and each one reads a different file. Pathrule is free for individual use for that reason.

Get started with Pathrule.