Skip to main content

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

pattern8-0.2.0.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pattern8-0.2.0-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

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

Hashes for pattern8-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dea88e02831364ab7f4cc625601e76e780be2cdb5a691e55b92f43ebc4e28c38
MD5 d896536ed852c5990719023de948d69c
BLAKE2b-256 bc5526b4f955b5e74863f580eb6f43511482e7985777f9471f5e85e1787b8e41

See more details on using hashes here.

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

Hashes for pattern8-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f15c9d70f5537f0beb536d4e30a0e4a8e1f3cb7ccc94e58b6d018561fce40c7
MD5 6da7bef6f2b61479897ef54012f6b8c1
BLAKE2b-256 7f61cdbbaba2dd77943501d1a6e76377d225d14f48de0b71ab709328b376e1ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page