Skip to content
Lesson 12 of 12

Building Your Prompt Library

8 min read

From Ad-Hoc to Systematic

Throughout this course, you have learned techniques for code generation, debugging, refactoring, testing, documentation, architecture, and multi-step workflows. The final step is systematizing these techniques into a personal prompt library -- a reusable collection of templates that makes every future AI interaction faster and more effective.

A prompt library is not a static document. It is a living toolkit that evolves with your projects, your team, and your growing understanding of what works. The best prompt libraries are small, focused, and maintained -- not comprehensive collections that nobody uses.

Organizing Your Library by Category

Structure your prompt library around the types of tasks you perform most frequently. Here are the core categories for most developers:

Code Generation

[New Component]
Create a {{component_type}} component in {{file_path}}.

Props: {{list props with types}}

Behavior:
- {{list key behaviors}}

Styling: {{CSS approach — Tailwind, CSS modules, etc.}}
Pattern reference: Follow the pattern in {{reference_file}}.
[New API Endpoint]
Create a {{method}} {{url}} endpoint in {{file_path}}.

Purpose: {{one-sentence description}}
Authentication: {{required/optional/none}}
Input validation: {{Zod schema or describe fields}}
Database operations: {{what to read/write}}
Response: {{describe success response}}
Errors: {{list error cases with status codes}}

Follow the pattern in {{reference_endpoint_file}}.

Debugging

[Bug Report to AI]
Bug: {{one-sentence description}}

Actual behavior: {{what happens}}
Expected behavior: {{what should happen}}
Steps to reproduce: {{numbered steps}}

Error message:
{{paste exact error}}

Relevant code:
{{paste code or reference file:lines}}

Environment: {{Node version, OS, relevant config}}
My hypothesis: {{what you think is wrong}}

Refactoring

[Refactor Request]
Refactor {{file_path}} to {{target state}}.

Current state: {{describe what exists}}
Target state: {{describe desired result}}

Constraints:
- Do NOT change: {{protected areas}}
- Must pass: {{existing tests}}
- Follow pattern: {{reference file}}

Deliver as: {{single commit / step-by-step / diff only}}

Testing

[Test Generation]
Write {{test_type}} tests for {{function/class}} in {{file_path}}.
Framework: {{Vitest/Jest/pytest/etc.}}

Test cases:
1. {{case description}} — Input: {{input}}, Expected: {{output}}
2. {{case description}} — Input: {{input}}, Expected: {{output}}
3. {{case description}} — Verify: {{error type}} is thrown

Edge cases to include:
- {{edge case 1}}
- {{edge case 2}}

Mock: {{list external dependencies to mock}}
Pattern reference: {{existing test file}}

Documentation

[API Docs]
Generate API documentation for {{file_path}}.

For each endpoint:
- Method, URL, description
- Auth requirements
- Request/response schema with examples
- Error responses

Style: {{Markdown/OpenAPI/custom format}}
Reference: {{existing docs file for style}}

Architecture

[Design Decision]
I need to decide: {{decision description}}

Options:
A: {{option A}}
B: {{option B}}
C: {{option C}}

Evaluation criteria (by priority):
1. {{criterion}} (weight: {{1-5}})
2. {{criterion}} (weight: {{1-5}})
3. {{criterion}} (weight: {{1-5}})

Current stack: {{relevant tech}}
Constraints: {{what limits the solution}}

Compare each option against all criteria. Provide a recommendation with
reasoning.

Code Review

[Review Request]
Review the changes in {{file_path or diff}}.

Focus on:
- {{specific concern: correctness / security / performance}}

Ignore:
- {{out of scope: style nits / naming / etc.}}

Format each finding as:
- Severity: {{must-fix / should-fix / nit}}
- Location: {{file:line}}
- Issue: {{description}}
- Fix: {{suggested change}}

Template Variables

Use a consistent variable syntax like {{variable_name}} so you can quickly find and replace placeholders. Some developers prefer [VARIABLE] or $VARIABLE -- pick one convention and stick with it.

The most commonly used variables across templates:

  • {{file_path}} -- the file being worked on
  • {{reference_file}} -- an existing file to match patterns from
  • {{tech_stack}} -- the relevant technology stack
  • {{constraint_list}} -- things the AI should not change
  • {{test_framework}} -- Vitest, Jest, pytest, etc.

Where to Store Your Prompts

CLAUDE.md

The most accessible storage for prompt templates you use in every session. Add a section to your project CLAUDE.md:

## Prompt Templates

### When generating new service files:
- Follow src/services/UserService.ts as the pattern
- Include constructor injection for dependencies
- Add Zod input validation
- Include error handling with AppError subclasses

### When generating tests:
- Use Vitest with the patterns in src/tests/
- Include factories from src/tests/factories/
- Mock database with src/tests/mocks/prisma.ts

These are not full prompts but prompt fragments that get automatically included in every interaction, ensuring consistency.

Claude Code Skills

Skills are markdown files in your project's .claude/skills/ directory that Claude Code loads automatically when relevant. Create skill files for your most common workflows:

# .claude/skills/new-api-endpoint.md

When creating a new API endpoint:
1. Create the route handler in src/routes/ following the Express router pattern
2. Create or update the Zod schema in src/schemas/
3. Create or update the service method in src/services/
4. Add the route to the router index in src/routes/index.ts
5. Generate tests matching the patterns in src/tests/integration/

Personal Notes

For prompts that are personal to your workflow rather than project-specific, keep a simple file on your machine. A plain text file or a note in your preferred notes app works fine. The key is that you can find and copy them quickly.

Organize by frequency of use, not by category. The prompts you use daily should be at the top. The prompts you use monthly should be further down.

Evolving Your Library

Track What Works

When a prompt produces excellent output on the first try, save it. When a prompt requires multiple rounds of correction, note what was missing and improve it. Over time, your templates become increasingly precise.

Keep a simple scoring system:

  • Prompt produced correct output on first try: keep as-is
  • Prompt needed one correction: add the missing detail to the template
  • Prompt needed multiple corrections: rewrite the template
  • Prompt consistently fails: investigate whether the task needs decomposition

Retire What Does Not Work

Delete prompts that you never use or that consistently produce poor results. A smaller library of effective prompts is more valuable than a large library of mediocre ones. Review your library quarterly and remove anything you have not used in the last 3 months.

Adapt to Tool Updates

AI tools improve constantly. A prompt that needed extensive hand-holding with an older model may work perfectly with a shorter version on a newer model. When you upgrade your AI tools, test your most-used prompts and simplify where possible.

Sharing With Your Team

When your team standardizes on shared prompts, several things improve:

  • Code review consistency: Everyone's AI-generated code follows the same patterns
  • Onboarding speed: New developers get productive immediately with proven prompts
  • Quality floor: Even hastily written prompts produce better output when the project context is well-defined

Standardized Team Prompts

Create shared prompts for team workflows:

[PR Description Generator]
Summarize the changes in this PR for the reviewer.

Format:
## What changed
- {{bullet list of changes}}

## Why
{{one paragraph explaining the motivation}}

## How to test
1. {{step-by-step testing instructions}}

## Risks
- {{potential issues or areas to watch}}
[Incident Response]
We have a {{severity}} incident affecting {{system/feature}}.

Symptoms: {{what users are seeing}}
Timeline: {{when it started, any recent deployments}}
Scope: {{how many users affected, which regions}}

Analyze the following logs and metrics to identify the root cause:
{{paste relevant logs}}

Suggest immediate mitigation steps and a permanent fix.

Five Ready-to-Use Prompt Templates

Here are five prompts you can start using immediately. Copy them, fill in the variables, and iterate.

1. Quick Feature Implementation

Add {{feature_description}} to {{file_path}}.
Stack: {{tech_stack}}.
Follow the pattern in {{reference_file}}.
Constraints: {{what not to change}}.
Include: {{error handling / validation / types / tests}}.

2. Bug Investigation

{{error_message}} occurs in {{file_path}} when {{trigger_condition}}.
Expected: {{expected_behavior}}.
Actual: {{actual_behavior}}.
Relevant code: {{file:lines or paste}}.
Diagnose the root cause and provide a fix.

3. Code Review Checklist

Review {{file_path or git diff}} for:
[ ] Logic errors and missing edge cases
[ ] Security vulnerabilities (injection, auth bypass, data exposure)
[ ] Performance issues (N+1 queries, unnecessary computation)
[ ] Consistency with project patterns
Flag issues as must-fix, should-fix, or nit.

4. Test Suite Generation

Generate tests for {{function/class}} covering:
- Happy path: {{describe normal flow}}
- Error cases: {{list error scenarios}}
- Edge cases: {{list boundary conditions}}
Framework: {{test_framework}}. Mocking: {{mock_approach}}.
Match patterns in {{existing_test_file}}.

5. Explain and Document

Explain {{file_path or code_block}} for a developer who is new to this
codebase. Cover: what it does, why it exists, how it connects to
{{related_systems}}, and common gotchas. Keep it under {{word_count}} words.

Your 7-Day Challenge

Build your personal prompt library in one week:

Day 1: Save the 3 prompts you used most today. Note what worked and what needed correction.

Day 2: Create templates from yesterday's prompts. Replace specific values with {{variables}}.

Day 3: Add 2 new templates for tasks you do weekly but have not templated yet.

Day 4: Test your templates on real tasks. Refine any that produce inconsistent results.

Day 5: Add project-specific context to your CLAUDE.md based on patterns you noticed this week.

Day 6: Share your best 3 templates with a teammate. Get their feedback and incorporate improvements.

Day 7: Review your library. You should have 8-12 templates. Delete any that do not save you time. Organize by frequency of use.

After this week, you will have a working prompt library that accelerates every AI interaction. Keep refining it, and within a month you will wonder how you ever worked without it.