Pattern 8 (P8) โ AI Agent Governance Framework
Project description
Pattern 8 (P8)
๐ฑ AI Agent Governance Framework
P8 constrains how AI Agents (Claude, Cursor, Gemini, etc.) behave in your project. Law (SKILL files) + Police (code engine) + Zero-Trust (Hook + Rules) = Agents can't jailbreak.
Architecture
Developer-editable (Law) Read-only Engine (Police)
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SKILL.md โ โ SecurityGuard โ
โ checklist.yaml โ read โ โ โณ regex blacklist โ
โ template.yaml โ โ โณ path restrictions โ
โ guidelines.yaml โ โ Reviewer โ
โ security.yaml โ โ โณ static rule engine โ
โ โ โ โณ P8AuditError rollback โ
โ "Constitution" โ โ "Police" โ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Agent calls via MCP โ
Three Defense Layers
| Layer | Method | Can Agent bypass? |
|---|---|---|
| Layer 1 | AGENTS.md + Cursor Rules prompt injection |
โ ๏ธ Theoretically yes |
| Layer 2 | MCP Tools (submit_review / execute_tool) |
โ Code-enforced |
| Layer 3 | Git pre-commit hook | โ Impossible to bypass |
Progressive Disclosure (aligned with Google ADK)
Agent loads lightweight Resources on startup; audit rules are loaded internally on demand:
| Type | Interface | Visible to Agent? |
|---|---|---|
| Resource | skill://index โ SKILL list |
โ |
| Resource | skill://{name}/checklist โ Entry checklist |
โ |
| Resource | skill://{name}/template โ Output template |
โ |
| Tool | submit_review โ Submit for audit |
โ Interface visible |
| Tool | execute_tool โ Request execution |
โ Interface visible |
| ๐ | guidelines.yaml โ Audit rules |
โ Loaded internally |
| ๐ | security.yaml โ Security red lines |
โ Loaded internally |
Installation
# Basic install (CLI + SKILL management)
pip install pattern8
# Full install (with MCP enforcement server)
pip install 'pattern8[enforcement]'
Quick Start
# 1. Initialize P8 (auto-installs 5 components)
p8 init my-project
# โ
AGENTS.md โ Global agent instructions
# โ
skills/ (5 SKILLs) โ Built-in governance rules
# โ
.gitignore
# โ
.git/hooks/pre-commit โ Commit-time audit
# โ
.cursor/rules/ โ Forces agent to use MCP
# 2. Manage SKILLs
p8 list # List all SKILLs
p8 new my_custom_skill # Create custom SKILL
p8 validate skills/example # Validate SKILL integrity
# 3. Start enforcement server
p8 serve # Start MCP enforcement server
p8 mcp-config --client cursor # Generate Cursor MCP config
Connect to Cursor
p8 mcp-config --client cursor
Paste the output into .cursor/mcp.json:
{
"mcpServers": {
"pattern8": {
"command": "p8",
"args": ["serve"]
}
}
}
5 Patterns ร 5 Built-in SKILLs
| Pattern | Controls | Config File |
|---|---|---|
| Pipeline | Step execution order | SKILL.md |
| Inversion | Blocks if info is missing, asks user | checklist.yaml |
| Generator | Output format constraints | template.yaml |
| Tool Wrapper | Dangerous command interception | security.yaml |
| Reviewer | Output quality audit | guidelines.yaml |
| SKILL | Use Case |
|---|---|
example |
PRD document generation |
code_review |
Code review (correctness / security / performance / maintainability) |
bug_fix |
Bug fixing (locate โ root cause โ fix โ regression) |
refactor |
Code refactoring (functional equivalence guarantee) |
feature_dev |
Feature development (requirements โ design โ implement โ verify) |
SKILL Directory Structure
skills/code_review/
โโโ SKILL.md # Pipeline + <HARD-GATE> blockers
โโโ assets/
โ โโโ checklist.yaml # Inversion entry checklist
โ โโโ template.yaml # Generator output template
โโโ references/
โโโ guidelines.yaml # Reviewer audit rules (๐ invisible to Agent)
โโโ security.yaml # Tool Wrapper security red lines (๐ invisible to Agent)
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.2.0.tar.gz.
File metadata
- Download URL: pattern8-0.2.0.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dea88e02831364ab7f4cc625601e76e780be2cdb5a691e55b92f43ebc4e28c38
|
|
| MD5 |
d896536ed852c5990719023de948d69c
|
|
| BLAKE2b-256 |
bc5526b4f955b5e74863f580eb6f43511482e7985777f9471f5e85e1787b8e41
|
File details
Details for the file pattern8-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pattern8-0.2.0-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f15c9d70f5537f0beb536d4e30a0e4a8e1f3cb7ccc94e58b6d018561fce40c7
|
|
| MD5 |
6da7bef6f2b61479897ef54012f6b8c1
|
|
| BLAKE2b-256 |
7f61cdbbaba2dd77943501d1a6e76377d225d14f48de0b71ab709328b376e1ab
|