Category

The AI coding context layer

An AI coding context layer is 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. Pathrule is the context layer Claude Code, Cursor, Codex, Windsurf and GitHub Copilot were missing.

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 for one engineer and one project. It breaks at the second engineer and the second directory.

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.

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 a chat product. The model you already use stays in charge of the prompt. The context layer feeds it; it does not compete with it.

  • 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 stays flat. Only relevant rules are injected.
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 is a path-indexed knowledge graph with a hook-time injection layer. Memories, rules and skills are stored in a graph that mirrors your repository's folder structure. At hook time, only the matching subtree is delivered to the model.

  • 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.

Get started with Pathrule.