Meta prompt engineering

From lyndonkl/claude · View interactive version

Meta prompt engineering is an AI agent skill from the GitHub repository lyndonkl/claude. Transforms vague or unreliable prompts into structured, constraint-aware prompts with explicit roles, task decomposition, output formats, and quality checks. Use when prompts produce inconsistent outputs, need explicit structure and constraints, require safety guardrails, involve multi-step reasonin

How to use this skill

Skill file

Meta Prompt Engineering

Workflow

Copy this checklist and track your progress:

Meta-Prompt Engineering Progress:
- [ ] Step 1: Analyze current prompt
- [ ] Step 2: Define role and goal
- [ ] Step 3: Add structure and steps
- [ ] Step 4: Specify constraints
- [ ] Step 5: Add quality checks
- [ ] Step 6: Test and iterate

Step 1: Analyze current prompt

Identify weaknesses: vague instructions, missing constraints, no structure, inconsistent outputs. Document specific failure modes. Use resources/template.md as starting structure.

Step 2: Define role and goal

Specify who the AI is (expert, assistant, critic) and what success looks like. Clear persona and objective improve output quality. See Common Patterns for role examples.

Step 3: Add structure and steps

Break complex tasks into numbered steps or sections. Define expected output format (JSON, markdown, sections). For advanced structuring techniques, see resources/methodology.md.

Step 4: Specify constraints

Add explicit limits: length, tone, content restrictions, format requirements. Include domain-specific rules. See Guardrails for constraint patterns.

Step 5: Add quality checks

Include self-evaluation criteria, chain-of-thought requirements, uncertainty expression. Build in failure prevention for known issues.

Step 6: Test and iterate

Run prompt multiple times, measure consistency and quality using resources/evaluators/rubric_meta_prompt_engineering.json. Refine based on failure modes.

Common Patterns

Role Specification Pattern:

You are a [role] with expertise in [domain].
Your goal is to [specific objective] for [audience].
You should prioritize [values/principles].

Task Decomposition Pattern:

To complete this task:
1. [Step 1 with clear deliverable]
2. [Step 2 building on step 1]
3. [Step 3 synthesizing 1 and 2]
4. [Final step with output format]

Constraint Specification Pattern:

Requirements:
- [Format constraint]: Output must be [structure]
- [Length constraint]: [min]-[max] [units]
- [Tone constraint]: [style] appropriate for [audience]
- [Content constraint]: Must include [required elements] / Must avoid [prohibited elements]

Quality Check Pattern:

Before finalizing, verify:
- [ ] [Criterion 1 with specific check]
- [ ] [Criterion 2 with measurable standard]
- [ ] [Criterion 3 with failure mode prevention]

If any check fails, revise before responding.

Few-Shot Pattern:

Here are examples of good outputs:

Example 1:
Input: [example input]
Output: [example output with annotation]

Example 2:
Input: [example input]
Output: [example output with annotation]

Now apply the same approach to:
Input: [actual input]

Guardrails

Avoid Over-Specification:

Test for Robustness:

Prevent Common Failures:

Balance Specificity and Flexibility:

Iterate Based on Failures:

  1. Run prompt 10 times
  2. Identify most common failure modes (3-5 patterns)
  3. Add specific constraints to prevent those failures
  4. Repeat until quality threshold met

Quick Reference

Resources:

Output:

Success Criteria:

Quick Prompt Improvement Checklist:

Common Improvements:

  1. Add role: "You are [expert]" → more authoritative outputs
  2. Number steps: "First..., then..., finally..." → clearer process
  3. Specify format: "Respond in [structure]" → consistent shape
  4. Add examples: "Like this: [example]" → better pattern matching
  5. Include checks: "Verify that [criteria]" → self-correction
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.