pi-rules

PI extension that injects markdown rules for any pi tool, including custom registered tools

Packages

Package details

extensionskill

Install pi-rules from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-rules
Package
pi-rules
Version
0.1.1
Published
Jun 1, 2026
Downloads
188/mo · 20/wk
Author
conte777
License
MIT
Types
extension, skill
Size
110.9 KB
Dependencies
2 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./dist/index.js"
  ],
  "skills": [
    "./dist/skills"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

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-rules

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

Path-scoped rules match project-relative targets and absolute targets outside the current PI cwd. For outside-cwd absolute paths, generic suffix globs such as **/*.go match by basename/absolute path; directory-specific globs should include a leading **/ when they must match anywhere, e.g. **/internal/**/*.go.

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.