pi-rules
v0.1.0
Published
PI extension that injects markdown rules for any pi tool, including custom registered tools
Maintainers
Readme
pi-rules
PI extension that loads markdown rules from .pi/rules/ and .claude/rules/ and injects matching rule bodies into tool_result output for any PI tool, including tools registered by other extensions.
Install
pi install npm:pi-rulesRule format
---
description: TypeScript style
tools: "*"
paths:
- "src/**/*.ts"
inputPaths:
- path
includeErrors: false
dedupe: session
---
Prefer named exports. Avoid `any` unless unavoidable.Rules are discovered from ~/.pi/rules/, ~/.claude/rules/, <project>/.pi/rules/, and <project>/.claude/rules/.
If tools is omitted, compatibility mode matches read, edit, and write. Use tools: "*" to match every built-in and custom tool. If paths is omitted, the rule is tool-scoped and does not need a target path.
Runtime API
import { registerInjectionRule, registerToolAdapter } from "pi-rules/runtime";
registerToolAdapter({
id: "my-extension.my_tool.paths",
tools: "my_tool",
inputPaths: ["target.path", "extraFiles[]"],
});
registerInjectionRule({
id: "my-extension.my_tool.instructions",
description: "Instructions for my_tool",
tools: "my_tool",
body: "When using my_tool, validate inputs and summarize side effects.",
});Diagnostics
Run /tool-rules doctor inside PI to list filesystem rules, runtime rules, adapters, parse errors, skipped files, symlink escapes, and invalid glob warnings.
