Vibe Workflows — Spec · Agents · TDD · Git
Vibe Workflows — Spec · Agents · TDD · Git
🎯 After reading this lesson
After completing this lesson, you will be confident doing the following three things.
- ▸✅ The SPEC → Plan → Tasks → Implement flow
- ▸✅ Safe use of Agent mode (dry-run · approval gates)
- ▸✅ Git commit units + how to write PR descriptions for AI-generated code
Keep the learning objectives as a checklist and close the lesson once you can answer every item.
SPEC vs Vibe — When to spec, when to vibe?
One line: Simple tasks = quick vibe / Complex tasks = SPEC first.
When SPEC comes first:
- ▸🟢 Large features (1 week+ of work)
- ▸🟢 Multi-person collaboration (PR reviewers required)
- ▸🟢 Security · payments · authentication
- ▸🟢 Backend API contracts
- ▸🟢 Data schema changes
When Vibe comes first:
- ▸🟢 UI components (boilerplate)
- ▸🟢 Small bug fixes
- ▸🟢 Refactoring · renaming
- ▸🟢 Writing tests
- ▸🟢 Documentation · comments
Spec-Kit workflow (GitHub, 2025):
Can be automated when combined with Anthropic Skills + Claude Code.
Agentic Workflows — "AI that works while you sleep"
Agent = an LLM that autonomously repeats the cycle of calling tools · checking results · deciding the next action.
Basic loop:
Tasks agents excel at:
- ▸🟢 Repetitive tasks: bulk changes across 100 files
- ▸🟢 Exploration: understanding a codebase · validating debugging hypotheses
- ▸🟢 Tedious tasks: migrations · writing tests · updating documentation
- ▸🟢 Overnight / weekend work: auto-generating PRs while the user sleeps
Limitations:
- ▸🔴 Fully autonomous X — user approval every 5–10 minutes recommended
- ▸🔴 Expensive calls (Opus 1M context = $90/M)
- ▸🔴 Dangerous actions (rm -rf · DB DROP) risk being executed directly
- ▸🔴 Hallucinations — fabricated function calls · generated docs
Safety measures:
- ▸Permission modes: ask (approve every action) → acceptEdits (edits only) → plan (no modifications)
- ▸Sandbox: Docker · worktree isolation
- ▸Checkpoints: review after every commit
- ▸Rollback ready: recoverable via git reset
> 💡 2025 trend: Combining GitHub Actions + Claude Code → the pattern of auto-generating PRs and running tests overnight is spreading.
TDD with AI
TDD cycle: Red (failing test) → Green (passing code) → Refactor (clean up)
AI's role:
Tests AI excels at:
- ▸🟢 Unit tests (simple input/output)
- ▸🟢 Edge cases (null · empty arrays · very large numbers)
- ▸🟢 Boilerplate (jest · vitest · pytest setup)
Tests AI struggles with:
- ▸🔴 Complex integration tests (database · external API · authentication flows)
- ▸🔴 Business requirements (domain knowledge required)
- ▸🔴 Performance tests (real environment required)
- ▸🔴 Diagnosing flaky tests (timing · environment dependencies)
Using Cursor · Claude Code:
> 💡 Iron Law: Tests generated by AI must also be read and understood by you. Never trust them based on pass results alone.
Git in the AI Era — Small commits + automated reviews
Principles:
1. Small commits — 1 commit = 1 change intent. Makes AI reviews effective
2. Clear messages — Conventional Commits (feat · fix · refactor)
3. PR automation — Copilot Review · CodeRabbit and similar tools for automated first-pass review
4. Automated tests — CI must pass before merging
AI Git tools:
AI-era PR template:
Common pitfalls:
- ▸❌ Committing all AI-generated code in a single commit — impossible to review
- ▸❌ AI making arbitrary changes elsewhere — surprises at review time
- ▸❌ Merging based only on compile errors — business logic unverified
- ▸✅ Start in Plan mode → small incremental changes → commit immediately
SPEC-Driven — *The token-saving secret*
Why writing a SPEC saves tokens
Old way: every conversation follows "build me this feature → AI asks questions → you answer → AI implements" repeated. The same context is repeated N times.
SPEC-Driven: write spec.md once upfront → all subsequent conversations reference that spec. Context written once + short follow-up messages.
Practical flow
Step 1: Write spec.md together with AI
This spec.md is saved at the project root.
Step 2: Implementation — without repeating explanations
No need to repeat "Toss gateway · subscription · refund policy" every time. Spec written once + short requests only.
Step 3: Code review — against the spec
Spec-Kit (GitHub, 2025)
A SPEC-Driven standard toolset built by GitHub. 4-step automation:
Combined with Claude Code · Cursor, it creates one unified flow from spec to code.
SPEC vs Vibe — Summary
Summary
- ▸Large tasks → SPEC first, then implement = token savings + consistency
- ▸Small tasks → plain Vibe is fine too
- ▸Automate spec → code with Spec-Kit
Agent mode *safe* usage guide (must read)
Core one-liner
Agent = AI that autonomously modifies files and executes commands. Used incorrectly, it can destroy your code · database · production environment. 5 principles for safe use.
⚠️ Never do these
1. Do not use --dangerously-skip-permissions
Among Claude Code options, there is a mode that auto-approves all permissions. It is fast, but the AI can execute dangerous commands like rm -rf without asking. This can destroy production code and databases.
✅ Always start in default mode (Ask or Plan).
2. Permission mode levels — grant gradually
Recommended flow: Start with Plan → review → step-by-step with Ask → AcceptEdits when comfortable
3. Commit to Git frequently — rollback points
Commit after every meaningful unit. Enables partial rollback of only the broken parts.
4. Isolate with a separate worktree
0% risk to original code. If things break, just run git worktree remove ../myapp-experiment.
5. Docker container — true isolation
Dangerous operations (DB migrations · system commands) must be run inside a container.
Dangerous commands blacklist
Double-check before the agent runs these:
- ▸
rm -rf(especially with*or/) - ▸
git reset --hard(loses commits) - ▸
git push --force(overwrites remote) - ▸
DROP TABLE·TRUNCATE(deletes database data) - ▸
npm publish(accidental publish) - ▸
curl ... | sh(executes external scripts) - ▸Any command with
sudo
When something goes wrong — recover fast
1. Stop immediately — Ctrl+C
2. Check changes — git status · git diff
3. Roll back — git reset --hard HEAD or git stash
4. If it is the DB — check the last backup
5. Post-mortem — review transcript in ~/.claude/projects/
Summary
- ▸Never auto-approve all permissions
- ▸Gradual steps: Plan → Ask → AcceptEdits
- ▸Frequent git commits + worktree isolation + Docker are your safety net
- ▸Double-check dangerous commands
Conventional Commits — *5 real-world examples*
Why follow the convention
100 messages like this and you cannot find anything later. Following standard conventions lets you:
- ▸
git log --grep "^feat(auth)"— only new features in the auth area - ▸
semantic-release— automatic versioning + CHANGELOG - ▸CI validation — commitlint blocks PRs with invalid messages
Format
- ▸type — feat · fix · refactor · docs · test · chore · perf · style
- ▸scope — area (auth · api · ui, etc.)
- ▸description — imperative mood, within 50 characters
5 real-world examples
1. feat — new feature
2. fix — bug fix
3. refactor — refactoring (no behavior change)
4. test — adding/modifying tests
5. chore — build · dependencies · tooling
Team convention examples
Additional types (varies by team):
- ▸perf — performance improvements
- ▸style — formatting · semicolons (not CSS)
- ▸ci — GitHub Actions · workflows
- ▸build — webpack · vite configuration
- ▸revert — reverting a previous commit
Automated enforcement with commitlint
GitHub Actions:
→ Automatically validates every commit message in a PR. Invalid formats block the merge.
Summary
- ▸Standard type + scope + description
- ▸One concise line (under 50 chars) + details in body
- ▸Rewarded with semantic-release · automated CHANGELOG
- ▸Enforce team-wide with commitlint
🤖 Try asking AI like this
Knowing the concepts in this lesson lets you give AI specific instructions. Instead of a vague "fix it," you make requests with vocabulary — that is the starting point of token savings.
- ▸"Based on this SPEC, create the Plan → Tasks → Implement flow"
- ▸"Explain the dry-run + approval gate pattern for safely using AI agent mode"
Why this reduces tokens
Without the concepts, even after receiving an AI response you have to ask "what does that mean?" again. That follow-up question is what consumes tokens. Learn the concepts once and the conversation ends in a single round.