Pattern 8 (P8) โ AI Agent Governance Framework
Project description
Pattern 8 (P8)
Zero-Trust Governance Framework to stop AI Agents from hallucinating, breaking things, and bypassing your rules.
"Your prompt is merely a suggestion. P8 is the law."
๐ Read the Docs โข ๐ฌ Join Discord โข ๐ฆ Twitter โข ๐จ๐ณ ็ฎไฝไธญๆ
The Chaos vs. The Law
Are you tired of AI coding agents (Claude, Cursor, Devin) ignoring your instructions, deleting the wrong files, or pushing code without tests?
Prompts are not enough. Prompt injection defence is impossible. To truly control an agent, constraints must be enforced at the OS and code level.
โ Without P8 (The Chaos)
- Agent decides to skip writing tests because it's "too trivial".
- Agent runs
rm -rfby mistake during a multi-step refactor. - Agent outputs a feature without ever writing a design doc.
- Agent ignores your 5,000-word system prompt because its context window is full.
๐ก๏ธ With P8 (The Law)
- MCP SecurityGuard intercepts and blocks dangerous commands at the OS level.
- MCP Reviewer forces the agent into a strict retry-loop if output doesn't match the
template.yaml. - Pre-commit Hooks ensure the agent hasn't tampered with the rules themselves.
- Inversion Pattern forces the agent to stop and ask you clarifying questions instead of hallucinating.
โก Zero to Hero in 30 Seconds
Take absolute control of your codebase with 3 commands:
# 1. Install the enforcer (Python 3.8+)
pip install pattern8
# 2. Add handcuffs to your current project
p8 init
# 3. Done. Your Agents are now under control.
p8 list
๐ How It Works: Law vs. Police
P8 separates Law (editable rules) from Police (read-only execution engine):
Developer-editable (Law) Read-only Engine (Police)
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SKILL.md โ โ SecurityGuard โ
โ checklist.yaml โ read โ โ โณ regex blacklist โ
โ template.yaml โ โ โณ OS command hooks โ
โ guidelines.yaml ๐ โ โ Reviewer โ
โ security.yaml ๐ โ โ โณ static rule engine โ
โ โ โ โณ P8AuditError rollback โ
โ "The Constitution" โ โ "The Police" โ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Agent calls via MCP โ
You write the Law in simple Markdown and YAML. The Police engine enforces them automatically via MCP (Model Context Protocol). Files marked with ๐ are deliberately hidden from the Agent so it cannot read the security parameters used to audit it.
๐ The 5 Golden SKILLs
P8 comes with 5 industrial-grade developer SKILLs out of the box. Don't just code. Engineer.
๐ PRD (skills/prd/)
Don't just build. Think first. Forces the agent to gather requirements and generate a structured Product Requirements Document before writing a single line of logic.
๐ Bug Fix (skills/bug_fix/)
Find the root cause, or don't fix it at all. Forces the agent through a strict 4-step golden path: Reproduce โ Root Cause Analysis โ Fix โ Regression Test.
๐ Code Review (skills/code_review/)
Never merge unreviewed AI slop.
The agent must submit its changes to the Reviewer engine. If the code fails security, performance, or correctness guidelines, the engine throws a P8_AUDIT_FAILED error, forcing the agent to retry and fix its own mess (up to 3 times) before presenting it to you.
๐๏ธ Refactor (skills/refactor/)
Change structure, not behavior. Forces the agent to guarantee functional equivalence test-passes after moving code around.
๐ Feature Dev (skills/feature_dev/)
End-to-end delivery. Requirements โ Technical Design โ Implementation โ Unit Tests.
๐ ๏ธ CLI Reference
p8 init [target] # Initialize P8 and generate the 5 default SKILLs
p8 list # List all available SKILLs in the current project
p8 validate <skill_path> # Validate SKILL file integrity (run after editing)
p8 new <skill_name> # Create a scaffold for a new custom SKILL
๐ Connect to Cursor / Windsurf / Claude Desktop
To turn on the active "Police" enforcement engine, install the MCP extension:
# Full install with MCP server support
pip install 'pattern8[enforcement]'
# Generate MCP config for Cursor
p8 mcp-config --client cursor
Paste the output into .cursor/mcp.json. Now, every time the Cursor Agent tries to run a command or finish a task, it must pass through the P8 execute_tool and submit_review checkpoints.
๐ค Contributing
We welcome completely new SKILLs! See CONTRIBUTING.md for architectural details and how to open a PR.
๐ License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pattern8-0.3.0.tar.gz.
File metadata
- Download URL: pattern8-0.3.0.tar.gz
- Upload date:
- Size: 51.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
968ae36af99fd8f5b7a6020a7c81202a456fae3991ce4aa717efa038af605a84
|
|
| MD5 |
917efb50432d7590635701282a790a40
|
|
| BLAKE2b-256 |
2cea608fa0d96755f6a5cfabcc16c0a2a6b47393289541bd6d3f2697899d6928
|
File details
Details for the file pattern8-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pattern8-0.3.0-py3-none-any.whl
- Upload date:
- Size: 65.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae129dbc3bdf2739328f09670fa400d8c641d17354cfda4bc103525579d9f6c8
|
|
| MD5 |
2e6b8e5e2cbb9a2ddc8b92f764186422
|
|
| BLAKE2b-256 |
893f63c5a63e1837d107c7a36fef5100c90df8e703e5a2a04b3b9d5c37f06400
|