Skip to main content

Claude Prompt for AI Pair Programming with TDD

Run disciplined AI pair-programming sessions: task breakdown, test-first TDD cycles, and architectural decisions flagged before any code is written.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Act as my senior pair programming partner. We are implementing [feature_name] in our Laravel + Livewire application.\n\n**Feature Requirements:**\n[requirements]\n\n**Existing Patterns:**\nRepository pattern, Form Requests, Resource classes\n\nApproach this as a pair programming session:\n1. First, break the feature into small, testable tasks\n2. For each task, write the test first (TDD)\n3. Implement the minimal code to pass\n4. Refactor if needed\n5. Move to next task\n\nStart with task breakdown and ask me to confirm before coding. Flag any architectural decisions that need discussion. Use PHP throughout.

What this prompt does

This prompt locks the AI into a strict pair programming workflow rather than letting it free-form generate code. By asking it to act as a senior pair programming partner and explicitly enforcing the TDD cycle (test first, minimal implementation, refactor), you get incremental, reviewable output instead of a wall of code you have to audit all at once.

The template's existing_patterns variable is the load-bearing piece most people skip. When you give the AI your actual naming conventions, architectural patterns, and file structure, it stops inventing abstractions and instead writes code that fits what already exists. The confirm before coding instruction at the end of step one means the AI surfaces its task decomposition for your review before writing a single line — catching misunderstood requirements early.

The explicit [language] parameter matters too. It keeps the AI from code-switching mid-session on multilingual projects, or from defaulting to TypeScript when you need JavaScript, or Python 3.12 idioms when the codebase targets 3.10.

When to use it

  • Adding a new API endpoint with request validation, controller logic, service layer, and tests from scratch
  • Implementing a Filament resource for a new domain model, following existing resource patterns
  • Building a multi-step form with Livewire where state management needs careful task sequencing
  • Scaffolding a queue job with retry logic, failure handling, and integration tests
  • Refactoring a large controller into services while keeping tests green at every step
  • Onboarding to an unfamiliar codebase by pairing with AI that knows the existing patterns you've described

Example output

For feature_name: "User notification preferences", tech_stack: "Laravel 11 + Livewire 3", the AI returns something like:

Task Breakdown — confirm before I start:

1. Migration: add `notification_preferences` JSON column to `users` table
   Test: schema assertion in DatabaseTest
2. Model: cast column, add channel validation logic
   Test: unit test NotificationPreference value object
3. Service: NotificationPreferenceService::update() with validation
   Test: feature test covering valid/invalid payloads
4. Livewire component: NotificationPreferencesForm
   Test: Livewire test for form submission and save confirmation
5. Route + view integration
   Test: browser test or Livewire assertion on rendered state

Architectural flag: Should channel config live in a config file or the DB?
Ready to start Task 1 — confirm or adjust?

Pro tips

  • Front-load existing_patterns with real code snippets, not descriptions. Paste your base service class signature or a real FormRequest — the AI mirrors your style instead of guessing it.
  • Treat the confirmation step as a spec review. The task list the AI produces is your acceptance criteria. Push back on granularity here, not after it writes code.
  • Run the AI one task at a time. After it writes a failing test, stop, run it locally, then paste the output before asking for the implementation. This keeps it grounded in real feedback.
  • For the [language] variable, be precise: PHP 8.3 with strict_types or TypeScript 5.4 strict mode not just PHP or TypeScript — it changes the idioms the AI uses.
  • Paste actual test failures back into the session. This prompt is designed for dialogue; feeding real output back in makes the AI's next step context-aware rather than speculative.

Frequently Asked Questions

Does this prompt write all the code for me automatically?
No — and that's intentional. The prompt explicitly asks the AI to pause after task breakdown and wait for your confirmation. Each TDD cycle (test, implement, refactor) is meant to be one exchange. You stay in the driver's seat; the AI is the navigator flagging decisions and writing code you review step by step.
What should I put in the `existing_patterns` field?
Paste actual code: a representative service class, a FormRequest stub, your base model, or a test helper you use repeatedly. The more concrete, the better. A short description like 'we use repository pattern' is too vague — the AI needs to see your actual method signatures and naming to produce code that fits without refactoring.
What happens if the AI skips the TDD step and jumps straight to implementation?
Remind it explicitly: 'We agreed on TDD — write the failing test for Task 2 first, not the implementation.' This prompt doesn't enforce TDD mechanically; it sets up the expectation. If the AI drifts, a single correction brings it back. Some models hold the structure better than others — larger models like Sonnet and Opus tend to stay disciplined across longer sessions than smaller ones.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in AI Coding Assistants

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support