Mastering `cm-example`: The Complete Guide
Hướng dẫn chi tiết về Mastering `cm-example`: The Complete Guide trong Vibe Coding dành cho None.
cm-example I will begin by researching the content and structure of the cm-example skill to ensure the guide is technically accurate and follows the established universal format.
I will read the version of the cm-example skill located in the project’s documentation directory to understand its structure and purpose within the Vibe Coding ecosystem.
Mastering cm-example: The Complete Guide to Universal AI Instructions
In the fast-moving world of “Vibe Coding,” the most significant bottleneck isn’t the AI’s intelligence; it’s the fragmentation of the instructions we give it. If you’ve spent any time building AI-augmented workflows, you’ve likely encountered the “Context Rot” problem: you spend hours fine-tuning a set of instructions for Claude Desktop, only to find that those same instructions fall apart when you switch to Cursor or try to automate them via a CLI agent like Antigravity.
This is where cm-example enters the conversation. Far from being just another “Hello World” template, cm-example serves as the Rosetta Stone for the modern AI-native developer. It represents a shift from “prompting” to “instruction engineering,” providing a universal, platform-agnostic format that ensures your AI skills remain portable, reliable, and consistent regardless of the underlying LLM interface.
The Problem: The “Prompt Fragment” Trap
Before we dive into the mechanics of cm-example, we must understand the pain point it resolves. Traditionally, AI instructions are treated as transient blobs of text. You paste them into a .cursorrules file for one project, a custom-instructions.txt for another, and perhaps a system prompt in a Python script for a third.
This fragmentation leads to three critical failures:
- Version Inconsistency: Your “best” way of handling React state is buried in a chat history from three weeks ago, not codified in your repository.
- Platform Lock-in: Instructions that leverage Claude’s “XML tag” preference might confuse models optimized for Markdown-heavy environments like Cursor or OpenClaw.
- Discovery Friction: New team members (or even your future self) have no centralized way to see what “skills” the AI agent has been taught.
cm-example is the blueprint for the Universal Skill Format. It is a standardized Markdown structure that omni-agent and other Cody Master tools compile into the specific configurations required by different AI platforms.
Core Concepts: How cm-example Works
At its heart, cm-example is a structured Markdown file that separates metadata, execution logic, and environment context. When you use this template, you aren’t just writing a prompt; you are building a “Skill Package.”
1. The YAML Frontmatter: The AI’s Identity Card
The first section of a cm-example skill is the YAML block. This is what the Cody Master ecosystem uses to index and discover the skill.
---
title: "cm-example"
description: "A template demonstrating the universal format compatible with Antigravity, Claude, Cursor, and OpenClaw."
keywords: ["cm-example", "cody master", "ai skill"]
robots: "index, follow"
---
In a Vibe Coding environment, the keywords field is vital. It acts as the “trigger” for the agent. When an agent like Gemini CLI or Antigravity scans your docs/skills directory, it uses these keywords to determine if the current user request matches the capabilities of this skill.
2. The Instructions: The “What” and “How”
This is the core of the skill. In cm-example, the instructions are written in plain, high-signal English. The goal here is to be declarative rather than imperative. You aren’t telling the AI every single step; you are defining the “Target State.”
3. Sub-agent Instructions: Orchestration by Design
One of the most powerful features demonstrated in cm-example is the Sub-agent Instructions section. Modern AI workflows are increasingly moving toward multi-agent orchestration.
## Sub-agent Instructions
1. Subagent A: Translate into French.
2. Subagent B: Translate into Spanish.
Platforms like Antigravity or OpenFang can take these instructions and spawn recursive agents. If a task is too large for a single context window, the skill allows the “Master Agent” to delegate specific sub-tasks to “Specialist Agents.” By defining this in the template, you ensure that your complex workflows can be automated at scale.
4. Context Injection: The Bridge to Reality
Perhaps the most “under the hood” power of cm-example is the Context Injection variables.
{{ workspace_root }}
{{ current_branch }}
These are placeholders. When the Cody Master compiler processes this skill, it replaces these tags with real-time data from your local machine. This allows the AI to “know” its environment without you having to manually tell it where it is every single time.
Practical Example: Building cm-auth-guard
Let’s put the cm-example template to work. Imagine you want to create a skill that ensures every time the AI writes a new API endpoint, it automatically includes your project’s custom authentication middleware and security headers.
We start by copying the cm-example structure.
Step 1: Define the Metadata
Create docs/skills/cm-auth-guard.md.
---
title: "cm-auth-guard"
description: "Enforces authentication middleware and security headers for all new API routes."
keywords: ["new endpoint", "create api", "auth check", "security gate"]
---
Step 2: Write the Core Instructions
Instead of a generic greeting, we define the security constraints.
## The Instructions
Whenever a new API route is requested (Node.js/Express):
1. Always import `validateToken` from `@/middleware/auth`.
2. Wrap the route logic in the `withSecurityHeaders` higher-order function.
3. If the route is in the `/admin` scope, ensure the `requireAdmin` check is applied.
Step 3: Add Sub-agent Logic for Validation
We can use sub-agents to “Self-Audit” the code.
## Sub-agent Instructions
1. Security-Agent: Run a static analysis on the newly generated code to ensure no hardcoded secrets are present.
2. Documentation-Agent: Update the `swagger.yaml` file with the new endpoint definition.
Step 4: Inject Project Context
We want the AI to know the exact path to the middleware.
## Context Injection
`{{ middleware_path }}`: Path to the auth middleware in the current workspace.
By following the cm-example pattern, you have now created a reusable, portable security standard. If you move from a React/Express project to a Python/FastAPI project, you only need to update the Instruction section of the skill; the Structure (Metadata, Sub-agents, Context) remains the same.
Best Practices: Moving Beyond the Template
To truly master cm-example, you must move beyond filling in the blanks and understand the “Philosophy of Instruction Density.”
1. High-Signal, Low-Noise
The LLM context window is a precious resource. Every word costs tokens and reduces the “attention” the model can give to other parts of the prompt. When writing instructions within the cm-example format, avoid conversational filler. Instead of “Please try your best to remember to add comments,” write “Constraint: All functions must include JSDoc comments.”
2. The “XML Tag” Strategy (for Claude compatibility)
Even though the format is universal, many Cody Master users rely on Claude. Claude thrives when instructions are wrapped in XML-style tags. While cm-example uses Markdown headers, you can include tags inside the instruction sections to provide even clearer boundaries for the model.
3. Iterative “Skill Refining”
A skill is a living document. In Vibe Coding, your docs/skills/ directory is essentially your team’s “SOP” (Standard Operating Procedure) for the AI. If the AI makes a mistake (e.g., forgets the security header), don’t just fix the code. Go back to your cm-auth-guard.md file and refine the instructions. This creates a “Self-Improving Development Environment.”
The Vision: Why Standardization is the Final Frontier
The industry is currently obsessed with “Agents.” We talk about agents that can browse the web, agents that can fix bugs, and agents that can write whole apps. But an agent is only as good as its Manual.
Imagine a world where every open-source library comes with a SKILL.md file following the cm-example format. You wouldn’t need to read 50 pages of documentation for a new UI library; you would simply drop the lib-ui-skill.md into your project, and your AI agent would instantly “know” how to use it correctly, following all the best practices defined by the library authors.
cm-example is the first step toward this future. It is a commitment to Instruction Interoperability. By codifying your knowledge into this format, you aren’t just helping the AI today; you are building an asset that will remain valuable as models evolve and platforms shift.
Conclusion: Starting Your Journey
The cm-example skill is purposefully simple. It doesn’t show off complex logic or advanced prompt engineering. Instead, it shows you the Container.
As you continue your journey in Vibe Coding, treat cm-example as your foundation. Every time you find yourself repeating an instruction to your AI, or every time you struggle to get the same results in a different editor, stop and ask: “Should this be a Skill?”
If the answer is yes, open the cm-example template, define your triggers, outline your logic, and join the ranks of developers who are building a more structured, reliable, and portable AI future. Mastering cm-example isn’t about learning a new tool; it’s about adopting a new mindset—one where the human provides the Design, and the Universal Skill provides the Discipline.