MCP and AI clients

Claude Code

How Pathrule shows up to Claude Code through hooks and MCP, and what gets written into your project for the integration to work.


Claude Code is the first class integration target for Pathrule. The integration uses two layers: hooks that push path scoped context before a tool call, and MCP tools that Claude can pull from when it wants more.

This page covers what gets written into your project, how the two layers fit together, and how to verify the integration end to end.

Two layers, one workspace

  • Hooks (push). On PreToolUse, UserPromptSubmit, and PostToolUse, Claude Code invokes Pathrule's hook supervisor. The supervisor reads a precomputed slice from the local cache and returns it as context. No network call in the hot path.
  • MCP tools (pull). When the hook payload is not enough (discovery prompts, full memory bodies, writes), Claude calls the Pathrule MCP server directly through tools like pathrule_get_context and pathrule_write_memory.

Hooks are the default. MCP tools are the deep path. The same content tree drives both.

Companion files

When you install Pathrule into Claude Code, three files appear in your project.

  • CLAUDE.md. The workspace overview Claude reads at session start. Includes the protocol summary and a router to the deeper Pathrule MCP.
  • .claude/settings.json. The Claude Code config. Pathrule writes the MCP server entry and the hook registrations here.
  • .claude/rules/pathrule-protocol.md. A small protocol file the assistant reads to understand how to interact with Pathrule (when to call pathrule_get_context, when to write memories, what ::skill-name means).

Skills attached to your workspace are also materialized into .claude/skills/<name>/SKILL.md so Claude can invoke them by name.

Rule enforcement

A rule has two independent settings: a priority (high, medium, low) that ranks how it surfaces, and an enforcement mode (advisory or strict) that decides whether it can block. Blocking is driven by enforcement, not by priority.

  • On PreToolUse, the hook checks the upcoming tool call against strict rules that define a matching pattern.
  • If a strict rule matches and the call would violate it, the hook blocks the call before it runs and returns the rule as the reason.
  • Claude Code stops, surfaces the reason to the user, and asks for guidance.

Advisory rules do not block. They ride along as context and the assistant decides how to apply them. Strict enforcement runs through the local hook on Claude Code; the Remote MCP surface has no hooks, so it surfaces rules as context only.

Install

Through Pathrule Studio:

  1. Open the app, attach your workspace to the local directory.
  2. Open the AI clients tab, enable Claude Code.
  3. The app writes the configs and registers the hooks.

Through Pathrule CLI:

pathrule install claude
pathrule sync
pathrule doctor

The doctor confirms the hooks are wired, the MCP server is reachable, and CLAUDE.md is current.

Verify

Open Claude Code in a directory you attached. Start a new turn. The Pathrule section should appear in the context surface before the first tool call, listing the path it resolved, the matching rules, and the memory titles in scope.

If nothing appears, run:

pathrule doctor --client claude

The doctor reports which step is off: missing config, stale cache, hooks not registered, MCP server unreachable.

When Claude writes content

Claude can write memories, rules, and skills back into Pathrule using the MCP write tools. The runtime tags the source as claude so you can see in the UI which content was AI authored.

Use the pathrule_log_activity tool to make every file modifying response visible in the activity log. This is the bridge between what Claude did and what your team sees.