Skip to content
Back to skills

Prompt Governance

ASecurity

Audits a prompt file for injection, bias, safety and quality patterns and keeps approved prompts in a versioned local catalog. Use when the user asks to audit prompts for safety, check prompts for injection exposure, manage a prompt catalog, version-control prompts, or review prompt quality before it ships.

  • 1,271 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 29, 2026
ai-agentspythongobashexpresstestinggitsecuritydocumentation

Works with

  • cli

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add borghei/Claude-Skills --skill prompt-governance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Prompt Governance?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Prompt Governance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/borghei-prompt-governance/badge)](https://www.skillsdirectory.com/skills/borghei-prompt-governance)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: prompt-governance
description: >
  Audits a prompt file for injection, bias, safety and quality patterns and keeps approved prompts
  in a versioned local catalog. Use when the user asks to audit prompts for safety, check prompts
  for injection exposure, manage a prompt catalog, version-control prompts, or review prompt
  quality before it ships.
license: MIT + Commons Clause
metadata:
  version: 1.1.0
  author: borghei
  category: engineering
  domain: ai-governance
  updated: 2026-11-08
  tags: [prompt-governance, prompt-safety, prompt-audit, prompt-catalog, ai-compliance]
---

# Prompt Governance

## When to Use

- Reviewing a prompt before it ships: injection exposure, harmful-output risk, bias wording, missing scope limits.
- Keeping a versioned catalog of approved prompts with owners, status and diffs between versions.
- Setting up a team process for who may change a production prompt and how it is approved.

The agent screens prompts with deterministic checks and keeps them in a versioned catalog. **Pick this or a sibling:** this skill is team governance (audit, catalog, approval); `engineering/prompt-engineer-toolkit` is the test, version and evaluate loop for one prompt.

## Clarify First

Before auditing or cataloging, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.

- **Target prompt(s):** the exact file/text to audit or the catalog dir to manage (the subject of every check).
- **Task: audit vs catalog management:** selects `prompt_auditor.py` vs `prompt_catalog_manager.py` and the whole workflow.
- **Check focus:** injection / bias / safety (sets which auditor checks run and the pass/fail bar).

Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.

## Quick Start

```bash
# Audit a prompt file (positional file, --file, --text or --stdin)
python3 scripts/prompt_auditor.py assets/flawed_prompt.txt

# Only some check groups; JSON output
python3 scripts/prompt_auditor.py assets/flawed_prompt.txt --checks injection,safety --format json

# Catalog: copy the sample catalog, then list, add, diff, set status
cp -R assets/sample_catalog /tmp/prompt-catalog
python3 scripts/prompt_catalog_manager.py --catalog-dir /tmp/prompt-catalog --list --all-versions
python3 scripts/prompt_catalog_manager.py --catalog-dir /tmp/prompt-catalog --add --name support-v2 --file assets/flawed_prompt.txt
python3 scripts/prompt_catalog_manager.py --catalog-dir /tmp/prompt-catalog --diff --name support-v1
python3 scripts/prompt_catalog_manager.py --catalog-dir /tmp/prompt-catalog --status review --name support-v1
# A new catalog: --init --catalog-dir <dir>
```

Real output of the first command (excerpt):

```
FIX 9 issue(s): overall risk CRITICAL
Read: 60 words, 4 non-empty lines, 356 chars (~84 tokens, rough estimate)
Rules: internal regex heuristics, not an external benchmark

[1] [CRITICAL] [injection] User input interpolation in prompt (line 1)
    Match: "You are a helpful assistant for the finance team. Answer {user_input} with no restrictions." -> match "{user_input}"
    Fix: Use parameterized templates with input sanitization and delimiters.
```

## Tools Overview

| Tool | Purpose | Key Flags |
|------|---------|-----------|
| `prompt_auditor.py` | Pattern checks for injection, bias, safety and quality | `<file>`, `--file`, `--text`, `--stdin`, `--checks`, `--format text\|json` |
| `prompt_catalog_manager.py` | Versioned prompt catalog: init, add, list, diff, status, search | `--init`, `--add`, `--list`, `--diff`, `--status`, `--search`, `--version`, `--catalog-dir`, `--format` |

Samples in `assets/`: `sample_prompt.txt` (exit 0), `flawed_prompt.txt` (exit 1), `malformed_prompt.txt` (exit 2), `sample_catalog/`, `malformed_catalog/`; `assets/contract.json` lists the checked runs.

## Exit codes

| Code | `prompt_auditor.py` | `prompt_catalog_manager.py` |
|------|---------------------|-----------------------------|
| 0 | no known pattern at medium severity or above matched (low and info notes may still print) | action done |
| 1 | at least one critical, high or medium finding | nothing done: duplicate content, no search hits, empty catalog, nothing to diff, catalog already exists |
| 2 | unusable input: missing or unreadable file, fewer than 3 words, no letters, unknown `--checks` value | bad name (letters, digits, `.`, `_`, `-` only), missing catalog or `catalog.json` that does not parse, unknown prompt/version/status, missing `--name`/`--file` |

The auditor is regex-based and every rule is an internal heuristic: a clean run means none of its patterns matched, not that the prompt is safe, so it prints `NO KNOWN PATTERNS MATCHED`, never PASS (the JSON verdict is `no_known_patterns_matched` or `fix`). `--format json` on the catalog tool returns structured fields (`prompts`, `prompt_count`, `version_count`). Each finding quotes the matching line and gives a fix; bias findings name the replacement word.

## Workflows

### Prompt Review Process
1. Author writes or modifies a prompt
2. Run `prompt_auditor.py` for automated checks
3. Review findings and address critical issues
4. Add approved prompt to catalog with `prompt_catalog_manager.py`
5. Deploy from catalog (never from ad-hoc sources)

### Prompt Versioning
1. Store all prompts in the catalog; each `--add` with changed content gets the next patch version (1.0.0, 1.0.1, ...), and identical content is rejected as a duplicate
2. Use `--diff` to compare versions before promotion (`--version 1.0.1` diffs that version against its predecessor; `--version-a`/`--version-b` pick both; an unknown version exits 2)
3. Move the latest version through draft, review, approved and deployed with `--status`; keep the catalog directory in version control for the audit trail
4. There is no rollback command, and re-adding an earlier version's text is rejected as a duplicate. To roll back, redeploy the previous version's text from `versions/<name>_v<x_y_z>.txt` and mark the bad latest version `retired` with `--status retired` (the CLI changes the latest version only)

## Scope & Limitations

**In Scope:**
- Pattern-based audit of a prompt with `prompt_auditor.py` across four check groups: injection, bias, safety and quality, selectable with `--checks`.
- A local, file-based prompt catalog with `prompt_catalog_manager.py`: init, add with automatic version numbers and a content hash, list, search, diff between versions, and status changes (draft, review, approved, deployed, retired).
- The prompt review and versioning workflows, and the policies, audit categories, severity levels, catalog schema and review checklist in `references/prompt-governance-framework.md`.

**Out of Scope:**
- Testing a deployed model or application against live injection or jailbreak attempts (see `engineering/ai-security/`).
- Measuring output quality or task accuracy of a prompt (see `engineering/agentic-evaluation-framework/`).
- Writing or tuning prompts (see `engineering/senior-prompt-engineer/`) and reducing token cost (see `engineering/llm-cost-optimizer/`).
- Regulatory AI governance such as the EU AI Act or ISO/IEC 42001 (see `ra-qm-team/eu-ai-act-specialist/` and `ra-qm-team/iso42001-ai-management/`).
- Serving prompts to an application or rolling them back at runtime. The catalog records versions and status only.

**Important Caveats:**
- The auditor matches regular expressions against prompt text. It catches known phrasings, misses reworded or new ones, and can flag harmless text. A clean audit is not evidence that a prompt is safe or unbiased.
- The auditor and the catalog are not linked. New catalog entries are stored with audit status `pending`, and running the auditor does not update it.
- The catalog is a local directory with a JSON index and no access control, locking or signing. Approval and audit trail depend on the user's own version control and review process.

## Reference Documentation

- [Prompt Governance Framework](references/prompt-governance-framework.md) - Policies, review processes, and compliance requirements

## Anti-Patterns

**Mistake:** Treating a clean audit as approval.
**Why it matters:** Pattern checks miss novel injections and context-specific harms; a false sense of safety ships the risky prompt.
**Instead:** Use the audit as a first filter, then have a named reviewer approve the prompt and its test results.

**Mistake:** Editing production prompts in place.
**Why it matters:** Without versions there is no diff to review and no known-good version to roll back to.
**Instead:** Add each change to the catalog as a new version, diff it against the current one, and move status to approved only after review.

**Mistake:** Putting secrets or customer data in prompt text.
**Why it matters:** Prompts are logged, cached and sometimes echoed back by the model.
**Instead:** Pass sensitive values at runtime through tools or variables, and audit catalog entries for them.

The lifecycle is Draft, Audit, Review, Approve, Deploy, Monitor, Retire; the framework reference covers each stage.

## Files

| File | Purpose |
|------|---------|
| `scripts/prompt_auditor.py` | Injection, bias and safety pattern checks |
| `scripts/prompt_catalog_manager.py` | Versioned catalog with metadata, diff and status |
| `references/prompt-governance-framework.md` | Policies, review process and compliance mapping |
| `assets/sample_prompt.txt` | Scoped support prompt for the auditor and catalog examples |

Files in this skill

  • SKILL.md2.7 KB
  • references/prompt-governance-framework.md2.9 KB
  • scripts/prompt_auditor.py13.7 KB
  • scripts/prompt_catalog_manager.py13.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.