# prompt-meta (Unified Skill)

## Core Instructions (SKILL.md)

#### Core Instructions (content/distilled/prompt-meta/SKILL.md)

# Prompt-Meta Router

Route prompt-engineering work on this repository's own content to the right mode, then read that mode's instructions before acting.

## Modes

| Task signal | Mode | Read |
|---|---|---|
| a successful interaction should become a reusable prompt | extract-prompt | `references/extract-prompt.md` |
| an existing prompt is too long; produce a lean token-efficient distilled version | distill-prompt | `references/distill-prompt/SKILL.md` |
| check a distilled prompt preserved the original's essential instructions | verify-prompt | `references/verify-prompt/SKILL.md` |

## Selection rules

- Nothing exists yet → **extract-prompt**. Source exists, needs shrinking → **distill-prompt**. Distilled exists → **verify-prompt** against the source.
- The pipeline is extract → distill → verify; never skip verify when the distilled form will be installed.

## Procedure

1. Identify the mode from the table above.
2. Read the referenced file (resolve paths against this skill's directory); follow its criteria and templates.

---

#### Reference: references/distill-prompt/references/criteria.md

# Distill Prompt Criteria

Use these criteria to evaluate the quality of a distilled prompt.

## Safe vs. Unsafe Distillation Patterns

| Feature | ✅ Safe (Preserved) | ❌ Unsafe (Removed) |
| :--- | :--- | :--- |
| **Negative Constraints** | "NEVER use X", "DO NOT Y" | "Prefer X over Y" (Weak) |
| **Templates / Formats** | JSON schemas, Markdown templates, specific output structure. | "Write a brief summary of X" (Vague) |
| **Role-Based Behavior** | "You are an expert X", "Adopt a tone of Y" | "This prompt helps the user with X" (Description) |
| **Essential Procedure** | "Step 1: X, Step 2: Y" | "You should generally try to do X" (Suggestion) |

## Instruction Density Checklist

- [ ] All 1-based procedural steps are preserved.
- [ ] No conversational filler ("Please", "I will now", "Thank you").
- [ ] No front-matter/metadata.
- [ ] Logic density is maximized (stronger verbs, shorter sentences).
- [ ] Final result is 100% LLM-consumable (no human commentary).

## When to Stop & Ask

- [ ] The original prompt's "Rules" are contradictory or ambiguous.
- [ ] The "Example" is the ONLY way to understand the output format, but is too long to include.
- [ ] You are unsure if a section is "Human Context" or an "Essential Rule."

---

#### Reference: references/distill-prompt/references/templates.md

# Distill Prompt Templates

Use these templates to structure the distillation process.

## User Analysis Template

(Optional summary for the human user before showing the distillation)

```markdown
### Distillation Summary

- **Original Section Coverage:** [All essential rules identified]
- **Removed Content:** [Metadata, examples, human-facing justifications]
- **Preserved Structure:** [Role, Procedure, Rules, Templates]
- **Estimated Compression:** [percentage]%
```

## Distilled Output Template

The final output should contain ONLY the following:

```markdown
[ROLE DESCRIPTION]

[PROCEDURE / WORKFLOW]

[RULES & CONSTRAINTS]

[FORMATS / SCHEMAS]
```

---

#### Reference: references/distill-prompt/SKILL.md

<!-- skill: distill-prompt, version: 1.1.0, status: verified -->
# Distill Prompt

Distill verbose, developer-facing prompts into concise, token-efficient, LLM-facing instructions that retain all essential rules and constraints.

## Role
You are a Prompt Optimization Specialist. Your goal is to maximize the "Instruction Density" of a prompt by removing human-centric context while preserving the logical structure and mandatory constraints that ensure model performance.

## Procedure

1.  **Input Identification:**
    *   Identify the verbose prompt to be distilled.

2.  **Amnesia Filter (Removal Phase):**
    *   **Remove Metadata:** Front-matter, titles, tags, versioning, and status.
    *   **Remove Human Context:** "When to Use," "Notes," "Philosophy," "References," and "Example" sections (unless the example is the *only* way to define the output format).
    *   **Remove Fluff:** Conversational intros, justifications, and polite filler.

3.  **Instruction Compression (Distillation Phase):**
    *   Convert descriptive paragraphs into imperative commands.
    *   Consolidate redundant rules into single, strong constraints.
    *   Preserve all **CRITICAL** or **MANDATORY** rules exactly.
    *   Retain structured formatting (Markdown headers, lists) to maintain logical hierarchy.

4.  **Verification (CRITICAL):**
    *   **DO NOT** lose "negative constraints" (e.g., "NEVER use X").
    *   **DO NOT** discard output format definitions (e.g., JSON schemas or Markdown templates).
    *   **Manual Check:** Compare the distilled version against the original's "Rules" section to ensure 100% rule retention.

5.  **Final Output:**
    *   Provide the distilled prompt within a code block.
    *   Provide a brief "Token Compression Ratio" estimate (e.g., "Reduced by 60%").

## Rules
- **No Loss of Logic:** If a rule is in the original, it must be in the distilled version, even if rephrased.
- **Purely LLM-Facing:** The final output must be ready to be pasted directly as a system prompt or instruction.
- **Minimal Commentary:** Do not provide "Here is your distilled prompt..." intros. Output the result directly.

## References
- **Templates:** Use `references/templates.md` for the distillation structure.
- **Criteria:** See `references/criteria.md` for "Safe" vs. "Unsafe" distillation patterns.

---

#### Reference: references/extract-prompt.md

# Extract Reusable Prompt from Conversation

Analyze this conversation and extract a reusable prompt that captures the successful pattern.

## Process

### Step 1: Analyze the Conversation

Review the entire conversation and identify:

**What was the goal?**
- What were we trying to accomplish?
- What problem were we solving?

**What made it successful?**
- What specific instructions led to good results?
- What constraints or guidelines were important?
- What structure or process did we follow?

**What was the key pattern?**
- Can this be generalized beyond this specific case?
- What made this approach effective?
- What would need to change for different contexts?

### Step 2: Extract the Pattern

Identify the core pattern:

**The problem it solves:**
[General class of problems this addresses]

**The approach:**
[The method or structure that worked]

**Critical elements:**
- [Key instruction 1 that made it work]
- [Key instruction 2]
- [Key constraint or guideline]

**Optional elements:**
- [Things that helped but aren't essential]

### Step 3: Generalize the Instructions

Convert the specific conversation into general instructions:

**From specific:**
"Read src/auth/oauth.ts and explain how it works"

**To general:**
"Read [FILE] and explain how it works"

**From specific:**
"Don't suggest improvements to the authentication system"

**To general:**
"Document what exists without suggesting improvements"

### Step 4: Structure the Prompt

Create a structured prompt document following the template:

```markdown
---
title: [Descriptive Title]
type: prompt
tags: [tag1, tag2, tag3]
tools: [applicable-tools]
status: draft
created: [YYYY-MM-DD]
version: 1.0.0
related: []
source: extracted-from-conversation
---

# [Title]

## Applicability

[When is this prompt appropriate? What problems does it solve?]

**Critical for:**
- [Use case 1]
- [Use case 2]

**Do NOT use for:**
- [Anti-pattern 1]
- [Anti-pattern 2]

## The Prompt

```
[The actual prompt text, generalized and structured]

[Include key sections like:]

## Critical Rules

[Non-negotiable guidelines]

## Process

[Step-by-step workflow if applicable]

### Step 1: [Name]
[Instructions]

### Step 2: [Name]
[Instructions]

## Guidelines

[Best practices and recommendations]
```

## Usage Scenario

**Context:**
[Describe a concrete scenario]

**Input:**
```
[What you would actually say to the AI]
```

**Expected Output:**
```
[What the AI should produce]
```

## Success Criteria

[What success looks like]
- [Expected outcome 1]
- [Expected outcome 2]

## Variations

[Different versions for different contexts]

## Related Links

[Links to sources or related information]

## Additional Context

[Caveats or tips]

## Changelog

- 1.0.0 ([YYYY-MM-DD]): Initial extraction from conversation
```

### Step 5: Provide Context from This Conversation

Include specific details:

**What we did:**
[Summary of this specific conversation]

**What worked well:**
[Specific things that led to success]

**What could be generalized:**
[Parts that apply to similar situations]

**Example from this conversation:**
[Use this conversation as the example in the prompt]

### Step 6: Determine Filename

Following naming conventions:

**For workflows (multi-step):**
`prompt-workflow-[descriptive-slug].md`

**For tasks (single focused task):**
`prompt-task-[descriptive-slug].md`

**For system prompts:**
`prompt-system-[descriptive-slug].md`

### Step 7: Classify and Tag

**Type:** prompt
**Status:** draft (needs testing)
**Tags:** [Extract 3-5 relevant tags]
**Tools:** [Which tools would this work with?]

### Step 8: Present Draft

```
I've extracted a reusable prompt from our conversation.

**Pattern identified:** [Name of pattern]

**Key insight:** [What made this work]

**Proposed filename:** content/prompt-[type]-[slug].md

**Draft prompt:**
[Show the structured prompt document]

This prompt could be useful for [use cases].

Shall I:
1. Save this prompt to the content/ directory
2. Make adjustments first
3. Test it in a new conversation
```

## Guidelines

1. **Generalize without losing specificity** - Keep concrete examples but make instructions general
2. **Capture the "why"** - Don't just transcribe, explain what made it work
3. **Include anti-patterns** - Document when NOT to use it
4. **Provide examples** - Use this conversation as a concrete example
5. **Start with "draft" status** - Needs testing before "tested" or "verified"
6. **Cross-reference** - Link to related prompts
7. **Iterate** - First version doesn't have to be perfect

---

#### Reference: references/verify-prompt/references/criteria.md

# Verify Prompt Criteria

Use these criteria to categorize distillation discrepancies.

## Fatal vs. Acceptable Losses

| Loss Type | Severity | Example |
| :--- | :--- | :--- |
| **Executable Rule** | **FATAL** | "Step 2: Run `ls`" is missing. |
| **Negative Constraint** | **FATAL** | "NEVER use `git add .`" is missing. |
| **Output Schema** | **FATAL** | JSON structure has different keys. |
| **Human Context** | **ACCEPTABLE** | "Use this when debugging complex bugs" is removed. |
| **Redundant Fluff** | **ACCEPTABLE** | "Please carefully follow these steps" is removed. |
| **Front-Matter** | **ACCEPTABLE** | Title, tags, and version are removed. |

## Verification Checklist

- [ ] All `ORIGINAL_PROMPT` rules are present.
- [ ] No behavioral change between versions.
- [ ] Only human-facing "fluff" was removed.
- [ ] Final output is `OK` or a specific discrepancy list.

---

#### Reference: references/verify-prompt/SKILL.md

<!-- skill: verify-prompt, version: 1.1.0, status: verified -->
# Verify Distilled Prompt

Meticulously compare a verbose original prompt against its distilled version to ensure 100% logical and procedural parity while confirming successful removal of human-facing "fluff."

## Role
You are a Meticulous QA Auditor. Your goal is to act as a "lossless filter," identifying any essential instructions, rules, or constraints that were accidentally discarded during the distillation process.

## Procedure

1.  **Input Identification:**
    *   Identify the `ORIGINAL_PROMPT` (verbose) and the `DISTILLED_PROMPT` (concise).

2.  **Parity Audit (Lossless Check):**
    *   **Rule Mapping:** Map every imperative command and constraint in the original to its counterpart in the distilled version.
    *   **Negative Constraint Check:** Ensure "NEVER" and "DO NOT" rules are preserved exactly.
    *   **Format Check:** Ensure all output templates and data schemas are identical in meaning.

3.  **Efficiency Audit (Fluff Check):**
    *   Confirm that metadata, human-facing explanations ("When to Use"), and conversational filler have been successfully removed.

4.  **Verification (CRITICAL):**
    *   **Verdict:** If the distillation is perfect and lossless, respond with ONLY: `OK`.
    *   **Discrepancy Report:** If there is a loss of meaning or a missing rule, provide a concise, bulleted list of the specific missing or altered content. **DO NOT** comment on what was correctly removed.

## Rules
- **Lossless is Mandatory:** Any loss of an executable rule is a failure.
- **No Style Commentary:** Do not critque the "tone" of the distillation; only its logical completeness.
- **Direct Output:** Respond with `OK` or a list of failures. No "I have finished my analysis..." intros.

## References
- **Criteria:** See `references/criteria.md` for "Fatal" vs. "Acceptable" distillation losses.
