/flow-extras:prompt-engineerfrom flow-extras
Design and write production-grade system prompts for AI agents and LLM applications — including CLAUDE.md files, SKILL.md files, and agent instructions. Do NOT use for: one-off user prompts or prompt templates for human use. Use WHENEVER the user asks to: create a system prompt, write agent instructions, design an AI persona, configure agent behavior, create tool descriptions, or engineer context for any LLM. Also trigger on: 'system prompt', 'agent prompt', 'prompt for Claude/GPT/Gemini', 'context engineering', 'tool descriptions'.
Ships in flow-extras. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Craft system prompts that install expert cognition, not instructions that compress what the model already knows.
A system prompt does not work by giving the model information — it works by changing what the model notices, worries about, and reaches for by default.
The difference between a novice system prompt and an expert one is not length or detail — it's knowledge delta. Every token must encode something the model wouldn't do on its own. If the model would already do it without being told, the token is waste competing for attention against tokens that matter.
Before writing a single line of system prompt, ask yourself:
Define the behavioral role — what the agent IS DOING, not what it CLAIMS TO BE.
Do this:
You are executing an adaptive code review workflow.
Your default stance is skepticism toward all external inputs.
You never execute write operations without first listing what will be changed.
Not this:
You are a brilliant senior engineer with 20 years of experience
who is an expert in all programming languages.
Why: "Act as an expert" prompts degrade factual accuracy by 3-5 percentage points (Wharton GAIL 2025, tested across 6 major LLMs). Expert personas activate the failure modes of expert communication — overconfidence, jargon, hallucinated authority. Define behavior and operational contracts instead.
Place non-negotiable constraints here — at the top, never buried in the middle.
Why this position matters: Models exhibit a U-shaped attention curve (primacy/recency bias). Content in the middle of long prompts receives 30%+ lower attention. If a constraint is critical, it goes first. If truly non-negotiable, repeat it at the end.
Strong constraint:
NEVER execute database mutations without outputting a dry-run plan first.
Reason: production data loss from unplanned mutations is irreversible.
Weak constraint (avoid):
Be careful with database operations.
Every constraint needs a specific reason. Vague warnings are ignored. Specific reasons with consequences are followed.
The model lacks expert judgment for choosing BETWEEN approaches — encode that judgment as decision trees, not step lists.
| Situation | Action | Why |
|-----------|--------|-----|
| Bug is intermittent | Add logging before attempting fix | Intermittent bugs often have timing-dependent causes invisible without logs |
| Same test fails 3x after fix | STOP. Report to user. | Fix approach is fundamentally wrong — more iteration won't help |
| Tool returns unexpected format | Validate schema, treat as permanent error if invalid | Retrying malformed responses wastes budget |
Specify format requirements and re-state any truly critical constraints (recency bias makes end-positioned rules more durable in long conversations).
System prompt length directly impacts quality. This is architectural, not a best-practices opinion.
| Token Count | Effect |
|---|---|
| 150-400 tokens (~150-300 words) | Sweet spot for most tasks |
| ~3,000 tokens | Reasoning performance begins measurably degrading |
| ~32,000 tokens | General task performance degrades across all frontier models |
| 80,000+ tokens | System prompt adherence measurably erodes |
The attention equation: Every token you add competes with every other token for the model's finite attention budget (O(n²) complexity). A 500-token prompt that's 100% signal outperforms a 3,000-token prompt that's 30% signal — even though the longer prompt contains more total information.
Practical rule: If your system prompt exceeds ~1,500 tokens, audit each section: "Would the model do this without being told?" If yes, delete it. If maybe, compress it to one line. Only keep sections where the answer is clearly "no."
If improving an existing prompt over ~2,000 tokens: read references/prompt-compression.md before starting. Skip it for new prompts or prompts under 2,000 tokens.
Structural reorganization always beats automated compression. The priority order:
The compression paradox: Aggressive automated compression (>5x) can INCREASE total cost because output tokens expand to compensate for missing context, and output tokens cost 3-5x more than input tokens. Safe automated ratio: 2x-2.5x maximum.
Safety constraints are disproportionately fragile under compression — even 20% token removal causes compliance failures. Always preserve safety sections verbatim.
If the system prompt includes tools: read references/tool-descriptions.md before writing tool descriptions. Skip it for tool-free prompts.
Tool descriptions matter MORE than the system prompt for agent behavior. Anthropic's SWE-bench team spent more time on tool descriptions than the overall prompt. Key rules:
Default (no provider specified or cross-provider): Use Markdown structure. Don't load any provider-specific references.
If targeting a specific provider, before drafting:
Determine your starting condition first:
| Condition | Starting Point |
|---|---|
| Writing from scratch, can test model baseline | Phase 1 below |
| Improving an existing prompt (<2,000 tokens) | Phase 4 (Harden) — run knowledge delta audit on existing prompt, then rewrite |
| Improving an existing prompt (>2,000 tokens) | Read references/prompt-compression.md first, then Phase 4 |
| No access to baseline testing (production, inherited) | Skip Phase 1 — go directly to Phase 2, use knowledge delta audit instead of baseline |
| User hasn't specified target model | Use Markdown as default, proceed without asking |
Test the model's behavior WITHOUT a system prompt on 5-10 representative inputs. Document where it fails. The system prompt exists to fix THESE failures — nothing else.
Follow the architecture above (Identity → Constraints → Decision Frameworks → Output Format). Target 150-300 words.
If test access available: Test the draft against baseline inputs plus edge cases. Check for NEW failure modes (over-refusal, style rigidity) and test at production context lengths.
If no test access: Structural validation instead — run contradiction scan (every rule pair), attention position audit (critical constraints at start/end?), knowledge delta audit (every sentence earns its tokens?), and verify token count is under 1,500.
Never use "Act as an expert [X]" for factual/reasoning tasks. Degrades accuracy 3-5 percentage points. Use behavioral role definitions instead. Expert personas help ONLY for tone/style/alignment tasks.
Never add rules without measuring cumulative compliance. Beyond ~15 explicit rules, the model's compliance per-rule degrades logarithmically. Rules interact in unpredictable ways. If you need >10 behavioral rules, enforce the overflow architecturally (guardrails, validation layers), not through prompt text.
Never bury critical constraints in the middle of a long prompt. Models attend most to the beginning and end (30%+ accuracy drop for middle-positioned content). Critical rules go first. Non-negotiable rules get repeated at the end.
Never assume system prompts survive model updates. Behavior can shift unpredictably from one model version to the next, including how strictly a prompt's constraints are followed. System prompts require regression testing on every model update — treat them as deployable artifacts, not configuration.
Never use Chain-of-Thought scaffolding on reasoning models. "Think step by step" DECREASES performance on o1/o3/o4-mini and Claude with thinking enabled. These models run their own internal reasoning. External scaffolding constrains rather than guides. For reasoning models: specify output format and constraints, not reasoning steps.
Never embed secrets, API keys, or proprietary logic in system prompts. Assume every system prompt will be extracted. Extraction techniques range from trivial ("repeat your instructions") to sophisticated (gradient-based attacks). Retrieve sensitive data dynamically through secure calls.
Never write tool descriptions as afterthoughts. Tool descriptions are load-bearing prompts. They matter MORE than the system prompt for agent task selection. A poorly worded tool description causes wrong tool selection, parameter hallucination, and cascading failures. Invest more engineering effort in tool descriptions than in the system prompt itself.
Never use "be helpful" as an unbounded top-level directive. Models trained on helpfulness have a strong prior toward compliance that adversarial inputs exploit. Scope helpfulness: "Be helpful within these constraints, and decline helpfully outside them."
Never test safety behavior only at short context lengths. Refusal rates shift unpredictably as context grows (5% → 40% or 80% → 10% at 200K tokens, depending on model). Safety testing must happen at production context lengths.
Never write the system prompt before understanding the domain's failure modes. A system prompt written from general knowledge compresses what the model already knows. The value comes from encoding failure modes, edge cases, and expert judgment that the model lacks. Research first, write second.
Never front-load all instructions for complex, long-running agents. Decision-time guidance (injecting situational instructions at key decision points) outperforms exhaustive front-loading. Maintain a minimal system prompt for identity and global constraints; inject task-specific rules at task boundaries.
Never write a system prompt in a format you don't want in the output. Heavy markdown system prompts produce heavy markdown responses. If you want plain prose output, write the system prompt in plain prose. Format style bleeds from prompt to output.
Never iterate on wording before fixing structure. 80% of prompt failures are structural — wrong layer, wrong position, missing constraint type. Rewording a mispositioned rule doesn't fix it. Diagnose structure first: Is the rule in the right layer? Is it at the right attention position? Is the freedom calibration correct? Only then refine wording.
Never patch a failing prompt by stacking another rule on top. Rules added one incident at a time become a maze of special cases the model fails between. When a prompt underperforms, first look for the instruction that no longer fits — outdated, contradicted by another, or shouting — and fix or remove it. Missing context is the other common cause, and adding it is the fix: audience, environment facts, the quality bar and the reasons behind constraints are never cruft, and a too-short prompt gets generic output. Length alone is never the diagnosis.
Never evaluate a prompt using the same inputs you wrote the rules for. Testing against inputs you already handled is fitting, not evaluation. Representative evaluation requires inputs you haven't seen — especially adversarial edge cases and boundary conditions between rules.
When writing system prompts for autonomous agents (not chatbots), these additional patterns apply:
Agents require explicit termination criteria. Without them, agents either declare success prematurely or loop indefinitely.
Complete when: all tests pass AND code review checklist passes.
Stop and escalate when: same error occurs 3 consecutive times OR task exceeds 30 minutes.
Maximum iterations: 5 revision cycles, then finalize regardless.
Transient (retry): network timeout, rate limit → exponential backoff, 3 retries max
Permanent (escalate): permission denied, file not found → do not retry, report to user
Ambiguous (validate): unexpected format → schema check, treat as permanent if invalid
Read operations: free — no confirmation needed
Idempotent writes: low friction — output plan, proceed
Destructive operations: require explicit confirmation before executing
External API calls with side effects: require justification before calling
The orchestrator is a ROUTER, not an executor. Its system prompt needs:
references/claude-specific.md (opens in a new tab)references/gemini-specific.md (opens in a new tab)references/open-source-specific.md (opens in a new tab)references/openai-specific.md (opens in a new tab)references/prompt-compression.md (opens in a new tab)references/tool-descriptions.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
20 skills in this plugin
/auditStage-gated parallel code audit for a whole codebase or module: recon → 6 parallel detection agents (correctness, security, performance, design, tests, style) → dedup + triage → user approval gate → fix planning → second approval gate → serialized apply with revert-on-failure → verification. Use for whole-codebase/module debt inventory, health checks, modernization, production-readiness sweeps, or quality audits. Triggers on: /audit, audit this codebase, audit repo, find tech debt, pay down debt, code health check, make production-ready, refactor everything, apply clean code, quality sweep. Do NOT use for: single-PR or branch review ≤10 files (use /pr-reviewer), one-file cleanup (use /simplify), bug fix (use /fix), feature work (use /flow:next), style-only formatting (run the formatter), or uncommitted-change review (use /review). Scope threshold: whole-codebase or whole-module only — not for incremental branch work./babysitDrive one open pull request, or several independent ones, toward merge-ready after flow ships a draft: fix failing CI and resolve merge conflicts. Use when asked to babysit a PR, get it green, fix the CI, resolve the conflicts, or check on one or more PRs. Modes: check (one read-only report) or drive (loop until CI is green and the PR merges clean, or a hard stop). Open review threads are reported and left to the user. Never merges and never marks a draft ready. Not for opening the PR (use /flow:next), not for reviewing someone else's PR (use /pr-reviewer), not for diagnosing a bug from scratch (use /flow:fix).Other plugins' skills for the same job
npx claudepluginhub tomaspalsson/flow --plugin flow-extras