Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/code-yeongyu/pi-rules/agents-mdgit clone --depth 1 https://github.com/code-yeongyu/pi-rulesWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00670 | $0.00670 |
| Opus 5 | $0.00335 | $0.00335 |
| Sonnet 5 | $0.00134 | $0.00134 |
| Haiku 4.5 | $0.00067 | $0.00067 |
Grade A, and why
pi-rules AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 55 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
Project rules for pi-rules itself.
Code style
- TypeScript strict mode (
noUncheckedIndexedAccess,strict: true). - NO
anyinsrc/(production). Useunknownand narrowing. - Imports use
.jsextension for project files (Node16 module resolution). - Tabs (
indentWidth: 3), 120-char line width, biome-formatted. - ESM only (
"type": "module").
Test conventions
- Vitest, real temp filesystem via
test/helpers/temp-fs.tsfor fs-touching tests. - Naming:
it("#given X #when Y #then Z")with// given / // when / // thenbody comments. - NO test deletion or skipping.
- NO writes to real
~/.pi. Use injectable home dir. - NO network access.
Architecture
src/rules/— pure logic units (parser, matcher, scanner, finder, ordering, cache, formatter, truncator, project-root, tool-paths) and orchestratingengine.ts(uses dependency injection).src/ui/— TUI components (rules-banner, dynamic-border).src/commands.ts— slash command handlers.src/index.ts—default function piRulesExtension(pi: ExtensionAPI): voidfactory; registers flags + hooks + commands.
When adding a new rule source
- Add the path/extension to
src/rules/constants.ts(PROJECT_RULE_SUBDIRSorPROJECT_SINGLE_FILESorUSER_HOME_RULE_SUBDIRS). - Update
RuleSourceunion insrc/rules/types.ts. - Add
SOURCE_PRIORITYentry. - Update
findRuleCandidatesinsrc/rules/finder.tsif discovery semantics differ. - Add tests covering the new source in
test/finder.test.tsand the integration tests. - Update
README.md"What gets loaded" section.
Hook contract reminders
before_agent_start: return{ systemPrompt: event.systemPrompt + block }. NEVER mutateevent.systemPromptin place. Useevent.systemPromptOptions.contextFilesto dedup against pi's native loader.tool_result: return{ content: [...event.content, { type: "text", text: block }] }. NEVER mutateevent.contentin place.session_start: reset state, but never throw.- All hooks are idempotent: dedup via cache keys (cwd+realPath+hash for static, toolCallId+realPath+hash for dynamic).
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 55 lines · 670 tokens per session scan A 9faaacc38082
pi-rules AGENTS.md is an instructions file published in the GitHub repository code-yeongyu/pi-rules (10 stars, last pushed 5d ago), licensed MIT. It adds 670 tokens to every session, about $0.0034 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other instructions, from other repositories
AGENTS.md AGENTS.md
Instructions for Anbeeld/AGENTS.md, covering global instructions, priorities, boundaries, uncertainty and evidence.
ruleblast AGENTS.md
Instructions for Kpoiut/ruleblast, covering ruleblast repository instructions, evidence before confidence, change discipline and before a commit.
codex-rules AGENTS.md
Instructions for code-yeongyu/codex-rules, covering repository conventions, style, commands, constraints and don'ts.
balakit AGENTS.md
AGENTS.md instructions for afaraha8403/balakit, covering project rules, base rules, the meta-principle, ai behavior & communication (dual-mode) and think before coding.
deep-init copilot-instructions.md
Instructions for deepfusionlabs/deep-init, covering repository instructions (copilot projection), kemal — agent context, architecture, components (7) and critical to know (non-obvious, load-bearing).
agentic-coding-workflow AGENTS.md
Instructions for abhilash-m96/agentic-coding-workflow, covering agentic coding workflow, rules, step 1 — understand the full scope, step 2 — propose the chunk plan and step 3 — write the finalised plan.