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.2.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.2-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

Details for the file pattern8-0.2.2.tar.gz.

File metadata

  • Download URL: pattern8-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 50763c81b6fb083f55fd0f229aad3033d1c6b0a0c893205f409467712746aa60
MD5 0b679df7a62763e31ac0b9ee8de207d8
BLAKE2b-256 45108e86233019c9ea52a3f1dc040e277670634946ff0eaa18a9bb5b7bcd0e24

See more details on using hashes here.

File details

Details for the file pattern8-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pattern8-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 39.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff89254721e33eb5832f3c87f3a3b217807aeb17d32628e31f79979353d13301
MD5 26c506514d89a95569e2d6bf059f468d
BLAKE2b-256 aa1252340c1c8437f8beef442b1f1b02506e4817849da64b89a39ab0ecdb6e0d

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