Protocol-Driven Development

The prompt is
the contract.

Stop hardcoding prompts inside your application logic.
Stop generating them blindly without governance.
Write them as typed, versioned, validated protocols.

Get started → What is PDD?
$ python cli.py protocols

// the problem

Two kinds of wrong.

There are two broken approaches to prompts in production today. Neither scales. Neither is maintainable. Both make debugging a nightmare.

Hardcoded
in the logic

The prompt is buried inside Python functions, concatenated with f-strings, mixed with business logic. Change the behavior? Edit the code. Refactor the code? Break the behavior. Invisible coupling everywhere.

def analyze(code): # 400-char string buried here prompt = f"You are an expert..." f"Analyze: {code}" f"Return JSON with..." # pray it works return llm.call(prompt)

Generated
without structure

The prompt is thrown at the AI ad-hoc, with no validation, no output schema, no versioning. It works once and breaks randomly. Nobody knows why it changed. Nobody owns it.

# slack message to the team "hey the AI is acting weird today" # the 'protocol' "gpt make me an analysis of this code and return something useful thx" # production. real. 2024.

// the solution

Prompts are infrastructure.

Protocol-Driven Development (PDD) treats every prompt as a typed, validated contract. Written in Markdown. Versioned in Git. Injected by an SDK that guarantees output schemas.

"If your Dockerfile defines what runs, your protocol.md defines how your model thinks. One governs the container. The other governs the cognition."
proto.md manifesto
performance_analyst.md
# [Protocol] Performance Analyst Version: 2.1.0 Model: anthropic/claude-sonnet-4 Author: platform-team ## Context You are a static analysis engine operating via semantic inference. You do not guess. You measure. ## Slots {{code_snippet}} string — the code to analyze {{strictness}} int(1..10) — enforcement level {{language}} string — programming language ## Constraints 1. Output MUST be valid JSON matching ## Schema 2. Never suggest external libraries unless asked 3. Strictness < 5: report only critical issues 4. Strictness ≥ 5: report all issues found ## Schema { "score": "number(0..100)", "issues": "Issue[]", "summary": "string" }

// mvp status

Lint-first workflow.
CI-ready contracts.

The current MVP ships parser + validator + CLI + tests + quality workflow. Run protocol checks locally and enforce them on pull requests before deploy.

CLI
$ python cli.py protocols protocols/invalid_protocol.md errors: 2 Error: Slots usados mas não declarados: {'undeclared'} Error: Campos obrigatórios faltando: ['schema'] protocols/valid_protocol.md errors: 0 2 errors · 0 warnings · 1/2 valid
Quality CI
# .github/workflows/quality-check.yml name: Quality Check on: [push, pull_request] jobs: quality: steps: - run: python -m py_compile parser.py validator.py cli.py test_mvp.py - run: python -m unittest -v - run: python cli.py protocols/valid_protocol.md --format json - run: python cli.py protocols/valid_protocol.md --strict --format compact
proto-lint MVP — the build check
$ python cli.py protocols --format compact protocols/valid_protocol.md: OK protocols/invalid_protocol.md: ERROR - Slots usados mas não declarados: {'undeclared'} exit code 1 on errors · CI blocks merge

// why it matters

Governance for the
cognitive layer.

[#]

Type-safe injection

Slots are declared with types. Inject the wrong type or a missing slot and the build breaks. Same discipline as typed code.

[v]

Semantic versioning

Every protocol has a semver. Breaking changes to slots or schema are major bumps. Your app pins the version.

[>]

Schema validation

Output is validated against the declared schema before it reaches your application. No more surprise shapes in production.

[~]

Composable protocols

Protocols can import and extend each other. Build a library of reusable cognitive contracts like Lego.

[*]

Model-agnostic

Declare the model in the protocol. Switch from Claude to GPT to Gemini by changing one line. Your code stays the same.

[?]

Human-readable

It's Markdown. Non-engineers can read, review, and understand what the AI is instructed to do. PRs are meaningful.


// get started

From zero to
first protocol.

Four steps. No magic. Just structure you should have had from the start.

step 01

Install MVP dependencies

The MVP runs directly from the repository. Install runtime dependencies and use the local CLI.

$ pip install pyyaml jsonschema
step 02

Write your first protocol

Create a protocols/ directory and add a `.md` protocol with frontmatter, slots, constraints and schema.

$ cp protocols/valid_protocol.md protocols/my_first.md
step 03

Lint before you commit

Run `proto-lint` locally and in CI. If slots are mismatched or schema is missing, the pipeline fails with exit code 1.

$ python cli.py protocols $ python -m unittest -v
step 04

Gate merges with quality workflow

Use GitHub Actions to run syntax checks, tests and CLI smoke checks on every push/PR to `main`.

$ git add . $ git push origin main # quality-check.yml runs automatically

Stop writing prompts.
Start writing protocols.

Your model's behavior deserves the same discipline as your code. Version it. Lint it. Own it.

View on GitHub → Read the docs