Mastering `cm-how-it-work`: The Complete Guide

Hướng dẫn chi tiết về Mastering `cm-how-it-work`: The Complete Guide trong Vibe Coding dành cho None.

Skills used: cm-how-it-work

Mastering cm-how-it-work: The Complete Guide

You’ve likely experienced the “AI Friction” paradox. You have the most advanced Large Language Models at your fingertips, a suite of autonomous CLI tools, and a clear vision for your product. Yet, halfway through a feature implementation, the session dissolves into chaos. The agent forgets the original requirements, starts hallucinating file paths that don’t exist, or worse, begins a recursive loop of fixing the same bug it just created.

This is the “babysitting” phase of AI development, where the cognitive load of managing the agent exceeds the effort of just writing the code yourself. This happens because most AI workflows lack a systematic orchestrator. They rely on general-purpose prompts to solve specific, high-stakes engineering problems.

Enter cm-how-it-work. This isn’t just a help file; it is the strategic heart of the Cody Master (CM) skill kit. It provides the mental model, the architectural map, and the operational discipline required to move from “vague vibes” to “verified production code” without losing your mind. In this guide, we will master the workflow that turns a fragmented AI session into a disciplined engineering pipeline.

The Core Concept: Engineering as Orchestration

At its core, Vibe Coding with the Cody Master kit is based on a single realization: An AI agent is only as good as the constraints you place upon it. If you ask a generalist agent to “build a dashboard,” it will try to do everything at once—planning, styling, database schema design, and deployment—usually failing at all of them because its context window becomes “poisoned” by too much competing information.

The Cody Master kit solves this by breaking the development lifecycle into Specialized Expert Gates. Each gate is a skill (like cm-planning, cm-quality-gate, or cm-debugging) designed to handle one specific phase of development with maximum technical rigor.

cm-how-it-work is the Meta-Skill. Its job is to tell you which gate to open next. It prevents “premature implementation” by forcing you through a research and design phase before a single line of code is written. It ensures that when you finally reach the “Execution” phase, the agent is operating within a tiny, high-signal context window where it is most likely to succeed.

The Five Pillars of the CM Workflow

  1. Intent Discovery: Using TRIZ principles and Jobs-To-Be-Done (JTBD) frameworks to move from a user request to a technical requirement.
  2. Architectural Isolation: Ensuring work happens in git worktrees or isolated branches so your main codebase remains stable.
  3. The Continuity Protocol: Maintaining a “source of truth” file (CONTINUITY.md) that tracks progress and prevents the agent from repeating mistakes.
  4. Evidence-Based Validation: A “No Success Without Evidence” rule. A task is not “done” just because the agent says so; it is done when a test passes and a screenshot is verified.
  5. Context Compaction: Systematically cleaning the agent’s memory to keep it fast and accurate.

How It Works: The Lifecycle of a Feature

To master cm-how-it-work, you must internalize the “Cody Master Loop.” This is the sequence of activations that takes you from an idea to a pull request.

Phase 1: The Brainstorming Gate

Before you touch the code, you must validate the idea. Most developers skip this, leading to “feature creep” or architectural dead-ends.

  • Skill to invoke: activate_skill cm-brainstorm-idea
  • What happens: The agent uses the “Double Diamond” design process to explore the technical and product implications of your request. It identifies risks and suggests 2-3 implementation paths.
  • Output: A clear recommendation on the best path forward.

Phase 2: The Planning Gate

Once the path is chosen, you need a blueprint.

  • Skill to invoke: activate_skill cm-planning
  • What happens: The agent creates a structured implementation plan. This plan includes “Verification Criteria” for every single task.
  • Output: task_plan.md. This becomes the master checklist for the rest of the session.

Phase 3: The Isolation Gate

You should never perform experimental vibe coding on your main branch.

  • Skill to invoke: activate_skill cm-git-worktrees
  • What happens: The agent creates a clean, isolated directory for this specific feature. This protects your environment and ensures that if the agent “breaks” something, it’s isolated to that worktree.

Phase 4: The Execution Loop

This is where the actual coding happens, but it’s done with surgical precision.

  • Skill to invoke: activate_skill cm-execution
  • What happens: The agent executes the tasks from the task_plan.md one by one. It uses the Test-Driven Development (TDD) workflow: Red (fail) -> Green (pass) -> Refactor.
  • Specialized Support: If it hits a bug, you invoke activate_skill cm-debugging. If it needs to run terminal commands, you use the cm-terminal patterns to ensure outputs are captured and analyzed.

Phase 5: The Quality Gate

Before merging, the work must be audited.

  • Skill to invoke: activate_skill cm-quality-gate
  • What happens: This is the most rigorous phase. The agent runs a full suite of linting, type-checking, and unit tests. If even one check fails, the “gate” remains closed. It requires empirical evidence (test logs) to claim completion.

Practical Example: Adding a Theme Switcher

Let’s walk through how exactly you would use cm-how-it-work to build a real feature. Imagine you want to add a Dark/Light mode switcher to an Astro-based project.

Step 1: Initialize the Map

You start the session by asking:

“I want to add a theme switcher. How should I start?”

You then call:

activate_skill cm-how-it-work

The agent will respond with a map: “We are in the Discovery phase. I recommend starting with cm-brainstorm-idea to decide if we should use a library or a vanilla CSS approach.”

Step 2: Strategic Decision

You activate the brainstormer. It analyzes your astro.config.mjs and notices you are using Tailwind. It suggests a “Tailwind + LocalStorage” strategy. You agree.

Step 3: The Blueprint

You activate cm-planning. The agent writes a plan:

  1. Create ThemeToggle.astro component.
  2. Add script to handle document.documentElement.classList.
  3. Add tests to verify state persistence in localStorage.
  4. Update Layout.astro to include the toggle.

Step 4: Safe Execution

You activate cm-git-worktrees to create a branch called feat/theme-switcher. Then, you activate cm-execution. The agent begins coding. It doesn’t just “guess” the code; it looks at your existing UI patterns to ensure the toggle matches your site’s aesthetic.

Step 5: The Final Audit

Once the toggle is built, you don’t just refresh the browser. You call:

activate_skill cm-quality-gate

The agent runs your Playwright tests. It confirms that clicking the toggle actually changes the background color and that the setting survives a page refresh. Only then does it offer to commit the changes.


The Continuity Protocol: Preventing “Groundhog Day”

One of the most powerful features explained in cm-how-it-work is the use of CONTINUITY.md.

In long AI sessions, the model’s “attention” drifts. It might forget that you explicitly told it not to use a specific library in Turn 5, and by Turn 50, it tries to install that library again. cm-how-it-work teaches the agent to maintain a “Long-Term Working Memory” file.

What goes in the Continuity file:

  • The Mission: What are we currently trying to achieve?
  • The Progress: Which tasks are 100% verified?
  • Learnings/Mistakes: “We tried to use fs-extra but it caused a build error on this OS; do not use again.”
  • Context Pointers: “The main logic is in /src/lib/theme.ts; ignore the legacy files in /old.”

By reading this file at the start of every turn and updating it at the end, the agent becomes “self-aware.” It doesn’t repeat past errors, and it maintains a consistent technical direction.


Best Practices & Pro Tips

To truly master the Cody Master kit, follow these “unbreakable” rules:

1. The “First Command” Rule

Always start your workday with activate_skill cm-how-it-work or activate_skill cm-continuity. This forces the agent to load the current project state and your specialized rules before it starts making suggestions.

2. Never Accept “I think it’s fixed”

If an agent says “I’ve applied the fix, it should work now,” immediately invoke activate_skill cm-debugging or cm-quality-gate. Force the agent to provide the terminal output of a passing test. In Vibe Coding, vibes are for design; evidence is for code.

3. Use the “Surgical Strike” Pattern

If you are working on a massive codebase, don’t let the agent “see” the whole thing. Use cm-planning to identify the minimum set of files needed for the change. Then, use the batch_get or read_file tools only on those files. A smaller context window is a faster, smarter context window.

4. Respect the “Isolation” Mandate

If you are about to run a command that modifies the system or a large number of files (like an npm install or a global refactor), always do it in a worktree created by cm-git-worktrees. This allows you to “Undo” a catastrophic agent failure in seconds.

5. Managing the Agent’s Fatigue

If the agent starts giving short, low-quality answers, it’s likely “context-saturated.” Use cm-how-it-work to guide the agent through a “Context Compaction” step: Summarize the current state into CONTINUITY.md, end the session, and start a fresh one using that file as the entry point.


Conclusion: Engineering at the Speed of Thought

Mastering cm-how-it-work is about moving from a “Prompt Engineer” to an “Autonomous Architect.”

The goal is not to have the AI do everything for you, but to have the AI work with you in a structured, safe, and highly efficient manner. By using the Specialized Expert Gates—Brainstorming, Planning, Isolation, Execution, and Quality—you eliminate the randomness that plagues most AI interactions.

The next time you open your CLI, don’t just start prompting. Activate the map. Use cm-how-it-work to establish the ground rules, create your blueprint, and enforce the quality standards that your users deserve.

Your “vibe” is the creative spark, but the Cody Master kit is the engine that turns that spark into a robust, production-grade reality. Start your next track by activating the master guide, and experience what it feels like to code without friction.