Skip to main content

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."

PyPI version Python CI Coverage License: MIT

๐Ÿ“š Read the Docs โ€ข ๐Ÿ’ฌ Join Discord โ€ข ๐Ÿฆ Twitter

P8 intercepts dangerous agent command

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 -rf by 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

pattern8-0.2.6.tar.gz (32.5 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.6-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pattern8-0.2.6.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pattern8-0.2.6.tar.gz
Algorithm Hash digest
SHA256 a4532bd1e8fac89528ec9c35c5e7f763e6866ecc2ab833da0f7de6a0eed032fa
MD5 680e2f7f6060d4bfb147cb7ae4462b14
BLAKE2b-256 7684ff77fa176fd372dd9d8441abf361b824c52be8c19658a3adf6a3eb02d283

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pattern8-0.2.6-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.13

File hashes

Hashes for pattern8-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 80c48025946494bb806bc39d15144c7c8939955433ee68231770744dfb8302eb
MD5 a7867d3f703ca0183cc3681a11a5d166
BLAKE2b-256 646c8d934217a59c83b48fa4fea2f82189789d1b54d9dc00357435e2bfd4e059

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