Leanpub Header

Skip to main content

Vibe Coding with OpenCode: From Beginner to Pro

Vibe Coding with OpenCode: From Beginner to Pro
This book is 100% completeLast updated on 2026-10-09

You can generate code faster than you can review it. That asymmetry is the real challenge of AI-assisted development — and almost nobody talks about it. Vibe Coding with OpenCode teaches the other half of the skill: not how to make AI write code, but how to make AI write code you can actually trust.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Vibe Coding with OpenCode: From Beginner to Pro
AI coding agents can now write code faster than you can type. The developers who thrive aren't the ones who prompt hardest — they're the ones who know how to *brief, review, verify, and ship*.
This book teaches you the complete craft of vibe coding with OpenCode, the open-source AI coding agent that runs in your terminal.

You'll start from zero: installing OpenCode, connecting your first model provider, and having your first useful conversation about real code. No prior AI tooling experience required.
You'll build real skill: writing prompts that specify outcomes instead of guesses, reading diffs like a reviewer, running a verification ladder that catches what look-right-but-wrong code hides, and planning features in Plan mode before a single line is generated.
You'll work like a professional: decomposing features into prompt-sized tasks, scaffolding contracts before implementation, navigating unfamiliar codebases, refactoring safely, debugging in partnership with the agent, and encoding your team's conventions into AGENTS.md project memory.
You'll go deep: model selection and cost control, MCP servers, custom commands, agent skills, headless automation, security and prompt-injection hygiene, and a full capstone that ships a real product end-to-end.


Inside you'll find:
- The vibe coding cycle — intent → prompt → review → verify → commit — practiced until it's instinct
- Plan Mode vs. Build Mode: when to think, when to act, and how to review a plan like an architect
- A prompt pattern library (Charter, Contract, Menu, Anchor, Diagnose-Then-Fix) you can apply immediately
- Side-by-side transformations of vague prompts into precise specifications
- 22 chapters + appendices, every chapter closing with hands-on exercises
- Realistic guidance on where vibe coding shines — and where it must not be used alone

Written for developers who want speed without surrendering judgment. Because the code may be generated, but the responsibility is still yours.

Author

About the Author

Kristian Reformis

Kristian Reformis is a dedicated IT educator and tech enthusiast with a mission to bridge the gap between complex technology and modern pedagogy. With years of experience in the classroom, he has seen firsthand the challenges teachers face in an increasingly digital world.

Known as "The Reformist Teacher," Kristian specializes in making advanced IT concepts—from coding to Artificial Intelligence—accessible and actionable for educators of all backgrounds. He believes that technology should not be a burden to teachers, but a powerful catalyst that allows them to focus on what truly matters: inspiring the next generation.

When he isn’t exploring the latest AI tools or developing digital solutions for schools, Kristian enjoys sharing his insights on educational reform and the future of work. The AI-Driven Educator is his latest contribution to empowering teachers worldwide to reclaim their time and transform their classrooms.

Contents

Table of Contents

Chapter 1: What Is Vibe Coding?

  1. 1.1 The Shift from Syntax-First to Intent-First Programming
  2. 1.2 How AI Coding Agents Actually Work
  3. 1.3 Where Vibe Coding Fits — and Where It Doesn’t
  4. 1.4 Setting Realistic Expectations: Speed vs. Responsibility
  5. 1.5 A Tour of the AI Coding Tool Landscape (and Why OpenCode)
  6. 1.6 Chapter Summary
  7. 1.7 Exercises
  8. 1.8 What’s Next

Chapter 2: Setting Up OpenCode

  1. 2.1 Prerequisites
  2. 2.2 Installing OpenCode
  3. 2.3 Connecting Your First LLM Provider
  4. 2.4 Tour of the TUI: Panels, Modes, and Keybinds
  5. 2.5 Your First Session: Asking a Question
  6. 2.6 Troubleshooting the Basics
  7. 2.7 Chapter Summary
  8. 2.8 Exercises
  9. 2.9 What’s Next

Chapter 3: Your First Vibe Coding Session

  1. 3.1 The Vibe Coding Cycle
  2. 3.2 Setting Up a Practice Project
  3. 3.3 Your First Change: A Small, Well-Specified Prompt
  4. 3.4 Reading Diffs Like a Reviewer
  5. 3.5 Verification: Trust Nothing, Check Everything
  6. 3.6 Undo: Your Superpower
  7. 3.7 Context in Practice: @, Images, and Conversation History
  8. 3.8 Common Beginner Mistakes (That You Can Now Avoid)
  9. 3.9 Capstone for Part I: A Complete Cycle
  10. 3.10 Chapter Summary
  11. 3.11 Exercises
  12. 3.12 What’s Next — And a Milestone

Chapter 4: The Art of the Prompt

  1. 4.1 Talking to OpenCode Like a Junior Developer
  2. 4.2 Context Is King: Files, Examples, and Screenshots
  3. 4.3 Vague vs. Precise — Side-by-Side Examples
  4. 4.4 Iterating: Multi-Turn Refinement Instead of One Big Prompt
  5. 4.5 Common Beginner Mistakes and How to Fix Them
  6. 4.6 Prompting Patterns Worth Memorizing
  7. 4.7 Chapter Summary
  8. 4.8 Exercises
  9. 4.9 What’s Next

Chapter 5: Plan Mode vs. Build Mode

  1. 5.1 Why Two Modes Exist
  2. 5.2 When to Plan, When to Build
  3. 5.3 Writing Feature Requests That Produce Good Plans
  4. 5.4 Reviewing a Plan Like an Architect
  5. 5.5 From Plan to Implementation: The Handoff
  6. 5.6 Workflows: Four Patterns for Real Situations
  7. 5.7 Anti-Patterns (And the Fix for Each)
  8. 5.8 Chapter Summary
  9. 5.9 Exercises
  10. 5.10 What’s Next — Part II Begins

Chapter 6: Building Features End-to-End

  1. 6.1 The Feature Delivery Pipeline
  2. 6.2 Scaffolding: Models, Routes, UI, Tests
  3. 6.3 Filling In: Vertical Slices That Work End-to-End
  4. 6.4 Working with an Unfamiliar Codebase
  5. 6.5 Refactoring Safely
  6. 6.6 Debugging: Reproduce, Isolate, Fix
  7. 6.7 Capstone: The Full Pipeline
  8. 6.8 Chapter Summary
  9. 6.9 Exercises
  10. 6.10 What’s Next

Chapter 7: Testing and Verification

  1. 7.1 Why Testing Is Non-Negotiable in Vibe Coding
  2. 7.2 Test-First with an AI Agent
  3. 7.3 Getting Good Tests from the Agent (and Spotting Bad Ones)
  4. 7.4 Edge Cases: The Systematic Hunt
  5. 7.5 The Full Verification Stack
  6. 7.6 Test Maintenance: Keeping the Net Strong
  7. 7.7 Capstone: Verification in the Wild
  8. 7.8 Chapter Summary
  9. 7.9 Exercises
  10. 7.10 What’s Next

Chapter 8: Git Workflows with an AI Agent

  1. 8.1 The Safety Model, Revisited
  2. 8.2 Commit Hygiene When AI Writes the Code
  3. 8.3 Staging and Reviewing AI Diffs at the Git Level
  4. 8.4 Branching for Parallel and Experimental Sessions
  5. 8.5 Recovery Patterns
  6. 8.6 Automating Git Hygiene
  7. 8.7 A Reference Workflow
  8. 8.8 Chapter Summary
  9. 8.9 Exercises
  10. 8.10 What’s Next

Chapter 9: Project Memory — AGENTS.md and Rules

  1. 9.1 The Rule of Threes: What Belongs in Project Memory
  2. 9.2 Anatomy of a Great AGENTS.md
  3. 9.3 Writing Rules That Actually Change Behavior
  4. 9.4 Global vs. Project Rules
  5. 9.5 Documenting Conventions: The High-Value Sections
  6. 9.6 Keeping Memory Alive: Maintenance Discipline
  7. 9.7 Team Adoption: Sharing Memory Without Chaos
  8. 9.8 Capstone: Build a Real AGENTS.md
  9. 9.9 Chapter Summary
  10. 9.10 Exercises
  11. 9.11 What’s Next

Chapter 10: Custom Commands and Reusable Prompts

  1. 10.1 Why Commands Beat Retyping
  2. 10.2 How Custom Commands Work
  3. 10.3 What to Encode: The Command Design Criteria
  4. 10.4 A Starter Library
  5. 10.5 Writing Good Command Templates
  6. 10.6 Sharing Commands with a Team
  7. 10.7 Capstone: Build Your Command Library
  8. 10.8 Chapter Summary
  9. 10.9 Exercises
  10. 10.10 What’s Next — Part II Complete

Chapter 11: Choosing and Tuning Models

  1. 11.1 How Models Actually Differ
  2. 11.2 Routing Tasks to the Right Model
  3. 11.3 Configuring Multiple Providers
  4. 11.4 Cost Management and Monitoring
  5. 11.5 Matching Model to Task: Worked Examples
  6. 11.6 When Not to Use the Biggest Model
  7. 11.7 Capstone: Build Your Routing Setup
  8. 11.8 Chapter Summary
  9. 11.9 Exercises
  10. 11.10 What’s Next

Chapter 12: OpenCode Configuration Deep Dive

  1. 12.1 The Configuration Surface at a Glance
  2. 12.2 Themes, Keybinds, and Ergonomics
  3. 12.3 Formatters and LSP: Making the Agent Smarter and Cleaner
  4. 12.4 Permissions: Controlling What the Agent Can Do
  5. 12.5 Policies: Organizational Guardrails
  6. 12.6 Bringing It Together: A Reference Configuration
  7. 12.7 The Division of Labor: Config vs. Memory vs. Prompt
  8. 12.8 Capstone: Configure Your Environment
  9. 12.9 Chapter Summary
  10. 12.10 Exercises
  11. 12.11 What’s Next

Chapter 13: Extending OpenCode with MCP

  1. 13.1 What MCP Is and Why It Matters
  2. 13.2 Adding Your First MCP Server
  3. 13.3 Practical Recipes
  4. 13.4 Custom Tools and Servers for Your Stack
  5. 13.5 Debugging MCP Connections
  6. 13.6 Chapter Summary
  7. 13.7 Exercises
  8. 13.8 What’s Next

Chapter 14: Agent Skills and Subagents

  1. 14.1 Why Structure Beats a Single Agent
  2. 14.2 Skills: Packaged Domain Expertise
  3. 14.3 Subagents: Specialized Helpers and Delegation
  4. 14.4 Combining Skills and Subagents
  5. 14.5 When Not to Add Structure
  6. 14.6 Capstone: Build a Small Team
  7. 14.7 Chapter Summary
  8. 14.8 Exercises
  9. 14.9 What’s Next

Chapter 15: Headless and Automation

  1. 15.1 The Automation Ladder
  2. 15.2 Headless and CLI Modes
  3. 15.3 The SDK and Server Mode
  4. 15.4 Plugins: Extending the Agent Itself
  5. 15.5 Agents in CI/CD
  6. 15.6 Chapter Summary
  7. 15.7 Exercises
  8. 15.8 What’s Next

Chapter 16: Collaboration and Sharing

  1. 16.1 The Conversation as a Shareable Artifact
  2. 16.2 GitHub and GitLab Integrations
  3. 16.3 IDE, Web, and TUI: Working Where You’re Comfortable
  4. 16.4 Pairing With Teammates in an AI Workflow
  5. 16.5 Review Etiquette When AI Wrote the First Draft
  6. 16.6 Capstone: Team-Ready Setup
  7. 16.7 Chapter Summary
  8. 16.8 Exercises
  9. 16.9 What’s Next — Part III Complete

Chapter 17: Architecture and Prompt Strategy

  1. 17.1 Why Architecture Is a Prompt-Strategy Concern
  2. 17.2 Designing Systems an AI Can Extend Safely
  3. 17.3 Spec-Driven Development: Write the Spec, Then Vibe
  4. 17.4 Context Window Management on Large Codebases
  5. 17.5 Knowing What Never to Delegate
  6. 17.6 Prompting for Architecture
  7. 17.7 Capstone: Audit and Harden an Architecture
  8. 17.8 Chapter Summary
  9. 17.9 Exercises
  10. 17.10 What’s Next

Chapter 19: Security, Privacy, and Responsible Vibe Coding

  1. 19.1 The Core Security Shift
  2. 19.2 Secrets, Keys, and the Context Trap
  3. 19.3 Prompt Injection and Untrusted Input
  4. 19.4 Reviewing AI-Generated Code for Vulnerabilities
  5. 19.5 Intellectual Property, Licensing, and Disclosure
  6. 19.6 Enterprise and Compliance Reality
  7. 19.7 Capstone: Security-Harden a Project
  8. 19.8 Chapter Summary
  9. 19.9 Exercises
  10. 19.10 What’s Next

Chapter title

Chapter 20: Performance and Cost Optimization

  1. 20.1 What to Measure (And What Not To)
  2. 20.2 Measuring Vibe-Coding Velocity
  3. 20.3 Reducing Token Spend Without Losing Quality
  4. 20.4 When Slow-and-Thorough Beats Fast-and-Loose
  5. 20.5 Capstone: Build Your Dashboard and Tune
  6. 20.6 Chapter Summary
  7. 20.7 Exercises
  8. 20.8 What’s Next

Chapter 21: From Solo Projects to Production Teams

  1. 21.1 What Changes When You’re No Longer Alone
  2. 21.2 The Shared Handbook: AGENTS.md at Team Scale
  3. 21.3 Shared Standards: Commands, Conventions, Consistency
  4. 21.4 Onboarding as a First-Class Concern
  5. 21.5 Review, Governance, and Trust at Scale
  6. 21.6 Capstone: Make a Solo Project Team-Ready
  7. 21.7 Chapter Summary
  8. 21.8 Exercises
  9. 21.9 What’s Next

Chapter 22: Capstone — Building a Real Product End-to-End

  1. 22.1 The Project and the Ground Rules
  2. 22.2 Stage 1 — Spec: From Idea to Clear Intent
  3. 22.3 Stage 2 — Architecture: Decisions Before Code
  4. 22.4 Stage 3 — Scaffold & the First Vertical Slice
  5. 22.5 Stage 4 — Build in Verified Slices
  6. 22.6 Stage 5 — Secure, Harden, Optimize
  7. 22.7 Stage 6 — CI/CD and the Automated Gates
  8. 22.8 Stage 7 — Launch, Learn, and Retrospect
  9. 22.9 The Whole Practice, in One Table
  10. 22.10 Chapter Summary
  11. 22.11 Exercises
  12. 22.12 Closing — The Durable Practice

Appendix B: AGENTS.md Templates and Rules Library

  1. B.1 Locations and Precedence
  2. B.2 Full AGENTS.md Template
  3. B.3 Rule Blocks Library
  4. B.4 External File References
  5. B.5 A Worked Example (Condensed)

Appendix B: AGENTS.md Templates and Rules Library

  1. B.1 Locations and Precedence
  2. B.2 Full AGENTS.md Template
  3. B.3 Rule Blocks Library
  4. B.4 External File References
  5. B.5 A Worked Example (Condensed)

Appendix C: The Prompt Pattern Library

  1. C.1 Context and Clarity
  2. C.2 Planning
  3. C.3 Building
  4. C.4 Verification
  5. C.5 Debugging
  6. C.6 Explanation and Learning
  7. C.7 Safety and Hygiene
  8. C.8 Meta-Patterns
  9. C.9 Anti-Patterns to Avoid
  10. C.10 The One Rule Behind Them All

Appendix D: Configuration and Permissions Cookbook

  1. D.1 Config Files and Locations
  2. D.2 A Complete Starter Config
  3. D.3 Models and Providers
  4. D.4 Permissions (Chapter 12)
  5. D.5 Permissions in Markdown Agents
  6. D.6 Agents Config
  7. D.7 Commands Config
  8. D.8 TUI Config (tui.json)
  9. D.9 Other Useful Options
  10. D.10 Variable Substitution
  11. D.11 Security-First Config Preset (Ch. 12, 19)

Appendix E: MCP and Integration Cookbook

  1. E.1 Enabling a Server
  2. E.2 Local Server
  3. E.3 Remote Server
  4. E.4 OAuth
  5. E.5 Managing Which Servers Are Active (Chapter 11, 13)
  6. E.6 Worked Examples
  7. E.7 Managing Servers via CLI
  8. E.8 MCP Security Checklist (Chapter 19)

Appendix F: Troubleshooting, FAQ, and Where to Go Next

  1. F.1 Where OpenCode Stores Things
  2. F.2 Common Issues (from the docs)
  3. F.3 The Book’s Disciplines as a Debugging Checklist
  4. F.4 Frequently Asked Questions
  5. F.5 Getting Help
  6. F.6 Where to Go Next
  7. F.7 A Closing Note

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub