# AI Pair Programming Quick Reference

## When AI Excels vs Struggles

| AI Excels At | AI Struggles With |
|--------------|-------------------|
| Boilerplate, configs, scaffolding | Project-specific context |
| Translating intent → code | Live state, env vars |
| Explaining code | Ambiguity ("make it better") |
| Exploring options | Multi-file refactors |
| Fixing known patterns | Creative design |

## Effective Prompting

| Principle | Bad | Good |
|-----------|-----|------|
| Be specific | "Fix this function." | "Return null when `input` is empty; add JSDoc." |
| Provide context | "Write a React component." | "Avatar component, Tailwind, `user.name` / `avatarUrl`, match `ProfileCard.jsx`." |
| Show examples | "Use our API style." | "Follow: `useApi('/users')` — same hook, different endpoint." |
| Break down tasks | "Build full auth flow." | "Step 1: Login form. Step 2: Wire to `auth.login`. Step 3: Error handling." |

## Iterating on Output

1. **Run and verify** — don't assume; run tests, try the flow
2. **Narrow feedback** — "The `fetch` URL should use `API_BASE` from config"
3. **Escalate** — if AI keeps missing, add context or take over

## Code Review Checklist

- [ ] **Correctness** — does it do what you asked?
- [ ] **Safety** — no hardcoded secrets, proper validation
- [ ] **Fit** — matches patterns, conventions, architecture
- [ ] **Maintainability** — clear, readable, not over-engineered

## When to Take Over

- Subtle bugs AI can't fix after 2–3 tries
- Architecture decisions
- Sensitive logic (auth, billing, security)
- Performance-critical paths

## Claude Code Features

| Feature | Purpose |
|---------|---------|
| **Skills** | Reusable procedures (spec-writer, argus-integration) |
| **Subagents** | Parallel work; main agent coordinates |
| **MCP** | Tools: Argus, appxray, code search |

## Human–AI Loop

```
You: goal + context → AI: proposal → You: verify
         ↑                                ↓
         └── specific feedback ───────────┘
```

**Key:** "Try again" rarely helps. "Use `useCallback` here because the parent re-renders often" does.
