Prompt Engineering Codex Β· CH 20

Chapter 20: Building a Personal Prompt Library That Compounds

⏱️ 3 min read·Updated Jul 2026

Prompts Are Intellectual Property

Every prompt you write that works well is a reusable asset. Most developers write a good prompt, use it once, and never find it again. The prompt lives somewhere in a chat history, a Notion page, or a memory that fades.

A prompt library is the practice of treating prompts as code: versioned, organised, tested, and improved over time.

---

The Anatomy of a Prompt Asset

javascript
// prompt-asset structure
{
  id: 'code-review-security-v3',
  title: 'Security-Focused Code Review',
  category: 'code-quality',
  tags: ['security', 'code-review', 'typescript', 'backend'],
  description: 'Reviews code for security vulnerabilities with severity classification',
  use_cases: ['Pre-commit review', 'API route audit', 'Auth system review'],
  
  system_prompt: 'You are a senior application security engineer...',
  user_prompt_template: 'Review this {{language}} code for security issues...',
  
  recommended_settings: {
    model: 'claude-opus-4-5',
    temperature: 0.1,
    max_tokens: 2000,
  },
  
  output_format: 'Severity | Line | Description | Fix',
  
  version: '3.0',
  created: '2025-03-15',
  last_improved: '2026-07-10',
  
  performance_notes: 'v3 adds severity classification -- 40% improvement in actionable findings',
  known_limitations: 'Does not handle infrastructure security (network, IAM)',
  
  test_cases: [
    { input: 'SQL concatenation example', expected_output_contains: 'Critical', pass_rate: '100%' },
    { input: 'Parameterised query example', expected_output_contains: 'no critical issues', pass_rate: '95%' },
  ]
}

---

Library Organisation System

Organise your prompt library into a hierarchy that matches how you work:

``` prompt-library/ β”œβ”€β”€ code/

β”‚ β”œβ”€β”€ generation/ β”‚ β”‚ β”œβ”€β”€ react-component.md β”‚ β”‚ β”œβ”€β”€ api-route-nextjs.md β”‚ β”‚ β”œβ”€β”€ supabase-migration.md β”‚ β”œβ”€β”€ review/ β”‚ β”‚ β”œβ”€β”€ security-audit.md β”‚ β”‚ β”œβ”€β”€ performance-review.md β”‚ β”‚ β”œβ”€β”€ refactor-suggestions.md β”‚ β”œβ”€β”€ debug/ β”‚ β”‚ β”œβ”€β”€ bug-investigation.md β”‚ β”‚ β”œβ”€β”€ error-analysis.md β”œβ”€β”€ content/ β”‚ β”œβ”€β”€ blog-post-outline.md β”‚ β”œβ”€β”€ blog-post-section-writer.md β”‚ β”œβ”€β”€ seo-meta-tags.md β”œβ”€β”€ business/ β”‚ β”œβ”€β”€ user-story-writing.md β”‚ β”œβ”€β”€ prd-section-writer.md β”‚ β”œβ”€β”€ competitor-analysis.md β”œβ”€β”€ analysis/ β”‚ β”œβ”€β”€ market-research.md β”‚ β”œβ”€β”€ user-feedback-themes.md └── meta/ β”œβ”€β”€ prompt-improvement.md β”œβ”€β”€ prompt-testing.md

code
---

## The Prompt Improvement Loop

Your best prompts get better over time when you systematically apply this loop:

**Step 1: Use** β€” Run the prompt on real tasks.

**Step 2: Note failures** β€” When the output is not what you wanted, note: what specifically was wrong?

**Step 3: Hypothesise fix** β€” Write the specific change you believe will fix the failure.

**Step 4: Test** β€” Run the new version against the failure case and 3-5 other test cases.

**Step 5: Commit and version** β€” If the new version is better, update the library with a version bump and changelog entry.

---

## The Meta-Prompt: A Prompt That Improves Prompts
You are an expert prompt engineer. I will give you a prompt that is not producing the quality output I want. Diagnose the problem and improve it.

ORIGINAL PROMPT: {{original_prompt}}

FAILURE CASE - Input that produced bad output: {{failing_input}}

ACTUAL OUTPUT (what the prompt produced): {{actual_output}}

EXPECTED OUTPUT (what I wanted): {{expected_output}}

Analysis task:

    • Identify which of these failure modes applies: [ambiguity, missing context, instruction conflict, format mismatch, complexity overload]
    • Explain exactly what caused the failure
    • Write an improved version of the prompt that prevents this failure
    • Write 2 additional test cases (with expected outputs) that the improved prompt should pass
```

This meta-prompt turns every prompt failure into a prompt improvement. Over time, your library accumulates battle-tested, production-proven prompts for every use case you encounter.

---

Sharing and Monetising Your Prompt Library

A high-quality prompt library for a specific domain (e.g., '50 production-ready prompts for SaaS builders') is a sellable digital product. Consider packaging your best prompts into:

  • A Gumroad product ($9-29)
  • A Notion template ($19-49)
  • A GitHub repository with a license
  • Part of a larger course or membership
Your library is valuable because quality prompts take significant iteration to develop. Others will pay to skip that iteration.

Finished reading this chapter?

Mark it completed to update your AI Builder skill profile score on your dashboard.

πŸ“‹

Download Printable Chapter Checklist

Get a print-friendly, formatted checklist of workspace actions to apply this chapter offline.