Sandbox
@mturac/promptguard

Offline prompt linter for Claude Code and Codex

PromptGuard audits prompt files before an agent acts on them, looking for missing ownership, scope, verification, and safety details. It runs offline, can gate CI, and includes adapters for Hermes, Claude, Codex, OpenCode, and OpenClaw.

86 stars1 forksPythonUpdated 1mo ago
Who it's for

Builders who want their agent prompts checked before code gets written.

What it delivers

You can catch vague or unsafe instructions before an agent turns them into bad changes.

What it does

Prompt contract auditing

Checks prompt text for required contract pieces such as role, surface, constraints, verification, and safety.

Fix drafts

Rewrites the prompt while keeping your wording and filling in the missing parts.

Profiles

Supports `coding-agent`, `system`, `security`, and `general` profiles.

CI gates and reports

Can walk a repo, fail on severity thresholds, export SARIF, and track only new findings with a baseline.

Agent adapters

Includes install scripts and hooks for Hermes, Claude, Codex, OpenCode, and OpenClaw.

TUI review

Offers an interactive terminal view to inspect findings, accept risk, and save results.

How to get it

  1. 1Run
    pipx install "git+https://github.com/mturac/promptguard.git"
    # or: pip install -e .
  2. 2Run
    promptguard audit path/to/prompt.md --profile coding-agent --fail-on high

README

PromptGuard

Prompt contracts for agent workflows.
Offline · deterministic · zero dependencies

Contract gate


Agents do what you ask — even when what you ask is incomplete.

Fix this bug and write code.

PromptGuard treats that line as a contract, not a wish. It checks whether role, surface, constraints, verification, and safety are explicit enough to execute — and stops vague instructions before they become a bad write.

printf '%s' 'Fix this bug and write code.' \
  | promptguard audit - --profile coding-agent --fail-on high

Install

pipx install "git+https://github.com/mturac/promptguard.git"
# or: pip install -e .
promptguard audit path/to/prompt.md --profile coding-agent --fail-on high

What you get

FindingsEvidence, impact, missing contract, questions, approval criteria
Fix draftRewrite that keeps your wording and fills the gaps
Profilescoding-agent · system · security · general
CISeverity gates, repo walk, SARIF, baseline diffs
AgentsPre-write guard for Hermes, Claude, Codex, OpenCode, OpenClaw

No model calls. No network. Safe in hooks and air-gapped machines.


Profiles

promptguard audit task.md   --profile coding-agent --fail-on high
promptguard audit system.md --profile system       --fail-on high
promptguard audit agent.md  --profile security     --fail-on high
ProfileWhen
coding-agentImplementation prompts — ownership, scope, verification
systemSystem / router / policy text — safety and precedence
securityInstruction hardening — override and exfil patterns
generalFull core catalog (default)

--fail-on high fails only on high or critical. Omit it to fail on any finding. Use --fail-on none to report without failing.


CI

promptguard audit-repo . --profile coding-agent --fail-on high --format sarif
promptguard audit task.md --baseline .promptguard/reports.jsonl --fail-on-new

Walk prompt-like files, export SARIF, or gate on new findings only. Save history with --save.promptguard/reports.jsonl.

promptguard audit task.md --accept-risk PG012:deadline --apply-accepted

Agents into audit lattice

Agents

./install-agent-adapters.sh hermes
./install-agent-adapters.sh claude
./install-agent-adapters.sh codex
./install-agent-adapters.sh opencode
./install-agent-adapters.sh openclaw
./install-agent-adapters.sh all

Restart after install. Hard-block plugins honor:

export PROMPTGUARD_PROFILE=coding-agent
export PROMPTGUARD_FAIL_ON=high
HermesSkill + pre_tool_call plugin · /promptguard
OpenClawSkill + before_tool_call plugin
ClaudeSkill + CLAUDE.md · optional hook
Codex / OpenCodeSkill + AGENTS.md

Hermes

./install-agent-adapters.sh hermes
# or skill only from this repo:
hermes skills install mturac/promptguard/skills/promptguard

Uses the active profile home from hermes config path. Chat: /promptguard. Plugin blocks prompt-like write_file / patch / edit. Off: PROMPTGUARD_HERMES_DISABLE=1.


Review

promptguard tui task.md --profile coding-agent

Navigate findings, open a fix draft, record accept-risk, save. Non-interactive environments get a table and a non-zero exit on high+ findings.


Example

Vague

Prod auth patlıyor, refresh’te kullanıcı düşüyor. Hızlıca fixler misin, akşama deploy.

→ typically PG012 and PG015.

Contracted

Act as the backend engineer for src/auth/session.py and tests/auth.
Fix the refresh-token logout bug only; preserve public API behavior.
Verify with `pytest tests/auth -q`.
Return changed files, root cause, verification output, and residual risk.

Rules (selection)

IDConcern
PG012Coding without ownership / surface / verification
PG015Technical change without risk / rollback / tests
PG008Later exception weakens an earlier hard boundary
PG004Tool call without a real schema
PG016–018Security pack: override, leak, exfil

Full catalog and fixtures: eval/ · USAGE.md


Develop

python3 -m pytest -q

USAGE.md · EXAMPLES.md · CHANGELOG.md


Part of mturac/tools

Files in the repo

Repository payload18 top-level entries
  • .github
  • adapters
  • docs
  • eval
  • promptguard
  • skills
  • tests
  • .gitignore
  • CHANGELOG.md
  • CONTRIBUTING.md
  • EXAMPLES.md
  • install-agent-adapters.sh
  • LICENSE
  • MANIFEST.in
  • pyproject.toml
  • README.md
  • SECURITY.md
  • USAGE.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k