Skip to content

Latest commit

 

History

History
577 lines (421 loc) · 21.1 KB

File metadata and controls

577 lines (421 loc) · 21.1 KB

Mastering AI Prompts for Coding 🎯

The comprehensive guide to effective AI-assisted development communication


Why This Matters

Your prompting skill directly determines your vibecoding speed and code quality.

Poor prompting: 10 iterations × 5 minutes = 50 minutes wasted
Good prompting: 1-2 iterations × 2 minutes = 4 minutes total

Time saved: 46 minutes per feature
Cost saved: 95% fewer tokens
Quality improved: First output is production-ready

This guide teaches you: How to write prompts that get high-quality code on the first or second try.


Quick Start

New to AI Prompting?

Start here:

  1. Foundations → Learn the 4-component framework
  2. Template Library → Copy a template, start coding
  3. Task-Specific Patterns → See real examples

Time investment: 30 minutes to read Foundations → immediate improvement


Experienced with AI Coding?

Level up:

  1. Advanced Techniques → Multi-step workflows, chaining
  2. Quality-Focused Prompts → Professional output, prevent vibe coding
  3. Task-Specific Patterns → Specialized strategies
  4. Template Library → Create your own template system

The Five Guides

1. Foundations 📖

→ Read Foundations Guide

Learn the core principles of effective prompting:

┌─────────────────────────────────────┐
│  The 4-Component Prompt Framework   │
├─────────────────────────────────────┤
│  1. CLARITY      │ What you want    │
│  2. CONTEXT      │ What AI needs    │
│  3. CONSTRAINTS  │ Boundaries       │
│  4. CRITERIA     │ Success metrics  │
└─────────────────────────────────────┘

Topics covered:

  • Anatomy of a good prompt
  • 5 universal principles with 15+ examples
  • Context loading strategies
  • 10 common anti-patterns (with fixes)
  • Prompt evolution techniques
  • Best practices checklist

Read time: ~20 minutes Impact: Immediate 50-70% improvement in first-try success rate


2. Task-Specific Patterns 🎨

→ Read Task-Specific Patterns

Specialized prompting for different development scenarios:

Task Type What You'll Learn
Feature Implementation Simple features → Complex multi-component systems
Debugging Runtime errors → Logic bugs → Performance issues
Refactoring Component updates → Architecture migrations
Code Review PR reviews → Security audits → Quality checks
Testing Unit tests → Integration tests → E2E scenarios
Documentation API docs → README files → Code comments
Performance Bottleneck identification → Optimization strategies
Security Vulnerability scanning → Security hardening

Each section includes:

  • 3-5 real-world examples
  • Bad vs Good prompt comparisons
  • Expected outcomes
  • Common pitfalls

Read time: ~45 minutes (or jump to your task type) Impact: Task-specific templates you can reuse


3. Advanced Techniques 🚀

→ Read Advanced Techniques

Expert-level strategies for complex scenarios:

┌────────────────────────────────────────┐
│  Advanced Technique Selection          │
├────────────────────────────────────────┤
│  Complex feature      → Multi-step     │
│  Pipeline processing  → Chaining       │
│  AI made mistake      → Error recovery │
│  Project-specific     → Context-aware  │
│  High token cost      → Optimization   │
│  Quality critical     → Self-correcting│
└────────────────────────────────────────┘

Topics covered:

  • Multi-step workflows (linear & branching)
  • Prompt chaining strategies
  • Error recovery patterns
  • Context-aware prompting
  • Token optimization techniques
  • Meta-prompting
  • Parallel prompting
  • Self-correcting prompts

Read time: ~30 minutes Impact: Handle complex features that require multiple prompts


4. Template Library 📚

→ Browse Template Library

17 copy-paste ready prompt templates:

Feature Implementation:

Debugging:

Refactoring:

Testing:

Documentation:

Code Review:

Performance:

Security:

How to use: Copy template → Fill {{PLACEHOLDERS}} → Send to AI

Read time: ~15 minutes to browse, instant use Impact: Consistent, high-quality prompts without thinking


5. Quality-Focused Prompts 🎨

→ Read Quality-Focused Prompts

System prompts and quality checks that prevent "vibe coded" output:

┌────────────────────────────────────────┐
│  Quality Prompt Applications           │
├────────────────────────────────────────┤
│  Building components  → Quality system │
│  Creating pages       → Page standards │
│  Reviewing code       → Quality audit  │
│  Client projects      → Professional   │
│  Design consistency   → Prevent slop   │
└────────────────────────────────────────┘

Topics covered:

  • Base quality system prompt (apply to any task)
  • Component-specific quality prompts
  • Page-level quality standards
  • Quality review and audit prompts
  • Tailwind-specific quality patterns
  • Copy quality prompts
  • Project-type specific prompts (local business, landing page, portfolio)

Each section includes:

  • Ready-to-use prompt templates
  • Integration with existing prompts
  • Bad vs Good examples
  • Project-specific variations

Read time: ~30 minutes (or jump to specific prompt type) Impact: Professional output from the start, justifies premium pricing

Why this matters: AI defaults to "make it work" not "make it professional." Quality-focused prompts ensure your output looks intentional, consistent, and polished—differentiating your work from cheap "vibe coded" sites.

See also: Design Consistency Guide | Quality Gates


Learning Paths

Path 1: "I need results NOW"

Time: 15 minutes

  1. Browse Template Library
  2. Find template matching your task
  3. Copy template
  4. Fill placeholders with your specifics
  5. Send to AI
  6. Done

Best for: Immediate productivity boost


Path 2: "I want to understand prompting"

Time: 1 hour

  1. Read Foundations (20 min)
  2. Try writing a prompt using the 4-component framework
  3. Compare with Task-Specific Patterns (20 min)
  4. Practice 3-5 prompts on your current project
  5. Review what worked/didn't work
  6. Create your first custom template

Best for: Building solid foundation


Path 3: "I want to master prompting"

Time: 2-3 hours + practice

  1. Read Foundations completely
  2. Study Task-Specific Patterns for your common tasks
  3. Learn Advanced Techniques
  4. Create project-specific templates from Template Library
  5. Practice daily, track success rates
  6. Refine templates based on results
  7. Share best practices with team

Best for: Becoming a prompting expert


Common Scenarios

"My AI generates buggy code"

→ Likely cause: Vague requirements, missing context

Fix:

  1. Read Foundations: Common Anti-Patterns
  2. Use Template 1: Feature Addition
  3. Add specific success criteria

"It takes 10 iterations to get working code"

→ Likely cause: Insufficient detail in initial prompt

Fix:

  1. Read Foundations: The 4-Component Framework
  2. Study examples in Task-Specific Patterns
  3. Use Self-Correcting Prompts

"AI doesn't follow my project conventions"

→ Likely cause: Missing project context

Fix:

  1. Read Advanced Techniques: Context-Aware Prompting
  2. Create .cursorrules file (examples in guide)
  3. Reference existing patterns explicitly

"Prompts are too long, wasting tokens"

→ Solution: Optimization techniques

Fix:

  1. Read Advanced Techniques: Prompt Optimization
  2. Use Documentation-First Approach
  3. Create reusable templates

"Complex features overwhelm AI"

→ Solution 1 (Prompt-Based): Break into steps

Fix:

  1. Read Advanced Techniques: Multi-Step Workflows
  2. Use Prompt Chaining
  3. Verify at each step

→ Solution 2 (Spec-Driven): Use structured specifications

Fix:

  1. Generate specs with Clavix
  2. Break feature into phases and tasks automatically
  3. Prompt AI for each phase individually with clear context
  4. Best for: Projects with 10+ features or complex multi-component systems

Prompts vs Specifications: When to Use Each

Understanding the difference:

  • Prompts = Communication layer (HOW you talk to AI)
  • Specifications = Planning layer (WHAT you're building)
  • Together = Super robust vibecoding workflow

Decision Matrix

┌──────────────────────────────────────────────┐
│  Project Type → Recommended Approach         │
├──────────────────────────────────────────────┤
│  Bug fix               → Prompts only        │
│  Small feature (1-5h)  → Prompts + templates │
│  Medium feature (5-20h)→ Prompts + multi-step│
│  Large project (20h+)  → Clavix + prompts    │
│  Team collaboration    → Clavix required     │
└──────────────────────────────────────────────┘

The Spec-Driven Workflow

When you use Clavix:

  1. Planning Phase: Clavix transforms your PRD into structured specifications

    • Generates phased implementation plan
    • Creates task breakdowns
    • Documents architecture decisions
  2. Implementation Phase: Use this prompting guide to execute each phase

  3. Quality Phase: Combine both for validation

    • Verify implementation against spec acceptance criteria
    • Use Self-Correcting Prompts
    • Iterate between phases as needed

The result: Structured project planning + Quality AI communication = Reliable, scalable development


Quick Reference

Prompt Quality Checklist

Before sending any prompt, verify:

  • Specificity: Is it clear what I want?
  • Context: Does AI have necessary information?
  • Constraints: Are boundaries clearly defined?
  • Success criteria: Can we verify when it's done?
  • File references: Are relevant files/patterns mentioned?
  • Scope: Is this one focused task?
  • Examples: Would an example clarify further?

When to Use Each Guide

┌────────────────────────────────────────────┐
│  Your Situation → Guide to Use             │
├────────────────────────────────────────────┤
│  Learning basics        → Foundations      │
│  Need template now      → Template Library │
│  Specific task          → Task-Specific    │
│  Complex scenario       → Advanced         │
│  Client project         → Quality-Focused  │
│  Prevent vibe coding    → Quality-Focused  │
│  Large project planning → Clavix + Prompts  │
│  Debugging prompt issue → Foundations      │
│  Optimizing workflow    → Advanced         │
└────────────────────────────────────────────┘

Template Selection Quick Guide

Your Task:
├─ New feature
│  ├─ Simple                → [Template 1](./template-library.md#template-1-simple-feature-addition)
│  ├─ API endpoint          → [Template 2](./template-library.md#template-2-api-endpoint-creation)
│  └─ React component       → [Template 3](./template-library.md#template-3-react-component-creation)
│
├─ Fix bug
│  ├─ Runtime error         → [Template 4](./template-library.md#template-4-runtime-error-debugging)
│  └─ Logic bug             → [Template 5](./template-library.md#template-5-logic-bug-debugging)
│
├─ Improve code
│  ├─ Component refactor    → [Template 6](./template-library.md#template-6-component-refactoring)
│  └─ Architecture refactor → [Template 7](./template-library.md#template-7-architecture-refactoring)
│
├─ Add tests
│  ├─ Unit tests            → [Template 8](./template-library.md#template-8-unit-test-generation)
│  └─ Integration tests     → [Template 9](./template-library.md#template-9-integration-test)
│
├─ Write docs
│  ├─ Function/API docs     → [Template 10](./template-library.md#template-10-functionapi-documentation)
│  └─ README/guides         → [Template 11](./template-library.md#template-11-readmeguide-creation)
│
├─ Review code
│  ├─ Pull request          → [Template 12](./template-library.md#template-12-pull-request-review)
│  └─ Security audit        → [Template 13](./template-library.md#template-13-security-audit)
│
├─ Optimize performance
│  ├─ Fix slow code         → [Template 14](./template-library.md#template-14-performance-optimization)
│  └─ Analyze performance   → [Template 15](./template-library.md#template-15-performance-analysis)
│
└─ Security
   ├─ Fix vulnerability     → [Template 16](./template-library.md#template-16-security-fix)
   └─ Add validation        → [Template 17](./template-library.md#template-17-input-validation)

Measuring Your Progress

Track These Metrics:

Before prompting training:

  • Iterations to working code: ___
  • Time per feature: ___
  • Token usage per feature: ___
  • First-try success rate: ___%

After 1 week of using this guide:

  • Iterations to working code: ___
  • Time per feature: ___
  • Token usage per feature: ___
  • First-try success rate: ___%

Expected improvements:

  • ✅ 50-70% fewer iterations
  • ✅ 60-80% faster development
  • ✅ 70-90% fewer tokens used
  • ✅ 3-5× higher first-try success rate

Integration with Vibecoding Workflow

Phase 0: Vibecoder Preparation

Phase 1: Planning

Choose your approach based on project complexity:

Approach 1: Prompts-Only (Small Projects)

  • Use prompts to generate PRDs and start coding directly
  • Reference Documentation Templates
  • Best for: Quick features, 1-5 tasks, solo development

Approach 2: Spec-Driven (Large Projects) ⭐

  • Use Clavix to transform PRDs into structured specifications
  • Clavix breaks features into phases and generates markdown documentation
  • Then apply prompting templates to implement each phase
  • Best for: Complex features, 10+ tasks, team projects

The Robust Combination: Clavix provides structure → Prompts ensure quality implementation

Phase 2: Development

Phase 3: Testing & Debugging

Phase 4: Deployment


Additional Resources

Related Vibecoding Guide Sections

Essential companions:

Tool-specific guidance:

Specification-Driven Development:

  • Clavix → Transform PRDs into structured project plans with phased implementation
  • Combines with this prompting guide for super robust vibecoding workflow

Contributing to This Guide

Found a better prompting pattern?

  1. Test it on real projects
  2. Document the pattern
  3. Compare with existing templates
  4. Submit PR with:
    • Problem it solves
    • Template/example
    • Before/after comparison
    • Success metrics

Next Steps

Choose your path:

Beginner: Start with FoundationsPractical: Jump to Template LibrarySpecific task: Find your scenario in Task-Specific PatternsAdvanced: Level up with Advanced Techniques

Start learning now → Your first improved prompt is 5 minutes away.


Back to: Main Guide