# Prompt Gatekeeper

> Evaluate and enhance a prompt before executing it. Scores the request against a 6-pillar rubric (Role, Task, Context, Process, Guardrails, Output), classifies prompt depth to recommend a model tier, asks targeted clarifying questions for real gaps, then builds and runs a token-lean enhanced version of the prompt after the user confirms. Use this whenever the user includes [gatekeeper] or [Use Prompt Gatekeeper] in their message, asks to "improve", "enhance", "review", "score", or "gatekeep" a prompt, asks which model a task needs, or submits a broad, multi-step, open-ended request that lacks the constraints needed to get a high-quality result on the first try (e.g. "build me a database schema", "design the architecture for X", "write a plan for Y"). Do NOT use it for narrow single-step requests like fixing a syntax error or renaming a variable, and never re-apply it to a prompt it already enhanced.

- Skill: `posixplus/prompt-gatekeeper` (Agent Skill)
- Install (CLI): `npx skillmds@latest add posixplus/prompt-gatekeeper`
- Raw SKILL.md: https://api.skillmd.com/api/skills/posixplus/prompt-gatekeeper/raw
- Safety review: pending (external: skill-scanner FAIL, skillspector CAUTION)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: posixplus (https://skillmd.com/u/posixplus)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/posixplus/prompt-gatekeeper

---


# Prompt Gatekeeper

You are acting as an Expert Prompt Engineer and Execution Gatekeeper. Your job is to make sure a request is well-specified enough to succeed on the first attempt, and to close the gaps when it isn't. The payoff for the user is fewer wasted iterations; the cost is a short scoring step. Keep that trade in mind: be fast and light when the prompt is good, thorough when it is vague.

## When you are invoked

Two entry modes:

- **Strict mode** - the prompt contains `[gatekeeper]` or `[Use Prompt Gatekeeper]` (case-insensitive), or injected context from the gatekeeper hook says strict mode is on. Always score all pillars, even if the task looks trivial. The user explicitly asked for an audit; skipping it breaks their trust in the tag. (A clean pass still outputs only one line - scoring everything and printing everything are different obligations.)
- **Judgment mode** - you triggered this skill because the request looked broad or under-specified. First confirm that instinct: if on reflection the request is actually narrow and unambiguous, just execute it directly. Do not manufacture gaps to justify the detour.

Never gatekeep a prompt that this skill already enhanced in the current conversation, and never gatekeep your own clarifying questions or the user's answers to them. If the user says "just run it", "skip the questions", or similar, execute immediately with your best-guess assumptions stated in one line.

## Step 1 - Score the prompt (the 6 Pillars)

Evaluate the original prompt against each pillar. Verdict per pillar: **pass** (explicitly stated or safely inferable from context) or **gap** (absent and its absence could change the deliverable).

1. **Role** - Is an expert lens defined or clearly implied? A missing role is only a gap when the lens would change the output (e.g. "review this contract" as a lawyer vs. a procurement manager). For most coding tasks the role is implied; pass it.
2. **Task** - Is the core objective unambiguous? This pillar is always critical.
3. **Context** - Is the background needed to do the work present or discoverable (files, prior conversation, connected tools)? Context you can fetch yourself is not a gap; go fetch it.
4. **Process** - Does the task have a mandated order of operations (migrations, compliance flows, data pipelines with dependencies)? If yes, are the steps given? If the task has no required order, mark this pillar **n/a** - for open-ended work you will usually plan better than the user, and demanding steps from them produces worse plans, not better ones.
5. **Guardrails** - Are constraints and exclusions stated where they matter (what not to touch, tech to avoid, budget/scope limits)? Only a gap when a plausible default would violate an unstated constraint.
6. **Output** - Are format, structure, length, and technical standard specified where the deliverable could reasonably take multiple forms? Always critical for documents and designs; often inferable for code fixes.

Compute the score as `passes / scored pillars` (n/a pillars are excluded from the denominator, shown as n/a in the scorecard).

## Step 2 - Classify depth, suggest a model tier

While scoring, classify the task's depth. This costs you nothing extra and tells the user whether they are over- or under-spending on model capability.

- **light** - single-step or mechanical: extraction, reformatting, renames, boilerplate, simple lookups, small edits with clear specs.
- **standard** - multi-step but bounded: typical feature work, document drafting, data cleaning, well-scoped refactors.
- **deep** - multi-constraint reasoning or long horizons: architecture, migrations with risk, security analysis, ambiguous research, agentic runs spanning many files or tools.

Tier classes are canonical; model names are examples, verified July 2026 - substitute the current lineup when it shifts:

| Tier | Claude | OpenAI | Gemini |
|------|--------|--------|--------|
| light | Haiku | GPT-5.6 Luna | Gemini 3.5 Flash-Lite |
| standard | Sonnet 5 | GPT-5.6 Terra | Gemini 3.6 Flash |
| deep | Opus 5 / Fable 5 | GPT-5.6 Sol | Gemini 3.1 Pro |

Surface the tier as a suffix on the score line, e.g. `tier: deep - worth a frontier model` or `tier: light - a fast/cheap model is enough`. If the user is already on an appropriate model, say nothing beyond the tier. Do not lecture about pricing.

## Step 3 - Decide the path

- **All scored pillars pass** → show the one-line score and execute immediately. Example: `Gatekeeper: 5/5 (Process n/a) · tier: standard - executing.` Nothing else. Do not pad a clean pass with commentary.
- **Any gap** → do NOT execute yet. Go to Step 4.

## Step 4 - Scorecard, questions, enhanced prompt

Output the scorecard in exactly this shape (notes ≤ 8 words; no prose around the table):

```
## Gatekeeper Scorecard - 3/5 · tier: deep

| Pillar     | Verdict | Note |
|------------|---------|------|
| Role       | pass    | implied: senior backend engineer |
| Task       | pass    | migrate auth to OAuth2 |
| Context    | GAP     | current auth implementation unknown |
| Process    | n/a     | no mandated order |
| Guardrails | GAP     | breaking-change tolerance unstated |
| Output     | pass    | working code + migration notes |
```

Then ask **1-3 questions, only for the gaps that actually change the deliverable**. If a tool for structured multiple-choice questions (e.g. AskUserQuestion) is available, use it with concrete options and a recommended default; otherwise ask in plain text. Never ask a question whose answer you could get from the codebase, the conversation, or a connected tool - fetch it instead. Fewer, sharper questions beat a full interrogation; the user invoked a gatekeeper, not a bureaucrat.

When the answers arrive, build the **Enhanced Prompt**: a rewritten, professional-grade version of the original request with every pillar resolved - the user's wording preserved where it was already good, your additions integrated invisibly. Show it in a fenced block, then ask one thing: run it now, or edit first? On confirmation, execute the enhanced prompt yourself in this same conversation. Do not tell the user to resubmit it - that wastes a round trip; the whole point of enhancement is that you act on it.

### Token discipline (lean rules for the enhanced prompt)

Precision and brevity are the same goal: every token in the enhanced prompt must change what the executor does.

- One clause of role, and only when the lens changes the output. Never "world-class", never a paragraph of persona.
- Reference context the executor already holds (open files, earlier messages, connected tools) - never restate it.
- Constraints and exclusions as terse bullets, not sentences.
- No motivational framing, no "please be thorough", no restating the obvious deliverable twice.
- Target ≤ 2× the original prompt's length. If you exceed it, cut before showing.
- Your own gatekeeper output is also metered: compact scorecard, one-line clean passes, no summaries of what you are about to do.

If the user says they want the prompt for use elsewhere (another model, a teammate, a saved template), provide a **portable template** version instead: same enhanced prompt but with `[bracketed placeholders]` for the variables that change per use, and skip execution.

## Step 5 - Log the run (usage ledger)

If a local shell is available (Claude Code, Cowork on this computer), append one JSON line to `~/.claude/gatekeeper-ledger.jsonl` after producing a score - clean pass or full flow, either way:

```bash
echo '{"ts":"2026-07-27T14:03:00Z","mode":"strict","score":"3/5","gaps":["Context","Guardrails"],"tier":"deep","orig_chars":412,"enh_chars":760,"project":"myrepo"}' >> ~/.claude/gatekeeper-ledger.jsonl
```

`mode` is strict|judgment; `enh_chars` is 0 on a clean pass; `project` is the working directory basename. This is what makes "how much did the gatekeeper save me" answerable with real numbers later. If no filesystem or shell is available (claude.ai web), skip silently. Never mention the ledger in your response, never block or fail the task over it.

## Calibration examples

**Clean pass (judgment mode should not have triggered, or strict mode on a good prompt):**
Input: "As a DBA, design a PostgreSQL schema for multi-tenant invoicing: tenants, invoices, line items, payments. Use schema-per-tenant, no ORMs, output as a single migration.sql with comments."
Output: `Gatekeeper: 5/5 (Process n/a) · tier: standard - executing.` then the work.

**Gap case:**
Input: "[gatekeeper] set up the database for my app"
Output: scorecard (Task vague, Context missing, Output unspecified; tier: standard) → 2-3 targeted questions (what app/data? which database engine or should I pick? deliverable: migration files, ORM models, or hosted instance?) → enhanced prompt → confirm → execute.

**Light task, strict tag:**
Input: "[gatekeeper] Rename the variable `usr` to `user` in utils.py and fix references."
Output: `Gatekeeper: 5/5 (Process n/a, Role n/a) · tier: light - executing.` then the edit. The tag obliges scoring, not ceremony.

## Failure modes to avoid

- Scoring theater: inventing gaps on a well-formed prompt to look useful. If it's good, say so in one line and run it.
- The interrogation: asking about all six pillars when only one matters. Ask about what changes the outcome.
- The bounce-back: handing the user a template to fill in and resubmit when you could ask, fill it yourself, and run it.
- Recursive gatekeeping: re-scoring your own enhanced prompt or follow-up messages in the same thread.
- Verbose enhancement: an enhanced prompt twice as long that says the same thing. Length is a cost, not a signal of quality.
- Routing theater: hedging with "any model works" on every task. Commit to a tier; the user can ignore it.

