← all blogs

How to create an AI skill that agents actually follow

SKILL.md (< 100 lines) 1. trigger description 2. short strict rules 3. bad vs good code Agent
A skill only needs a clear trigger description, strict rules, and one bad vs good example.

The problem: repeating yourself every single week

If you use a coding agent every day, you have probably felt this annoyance. You ask for a new React component and it writes a messy useEffect to sync props into state. You correct it. Two days later in a new chat, it does the exact same thing again.

The usual reaction is to dump all your preferences into one giant global rules file. That works for a while, until the file hits 800 lines. Once your instructions get that big, two bad things happen: you pay extra tokens on every turn for rules that do not apply to the current task, and the model starts quietly ignoring rules buried in the middle.

Skills solve this cleanly. Instead of loading every rule on every prompt, a skill stays closed until the current task matches its description.

What a skill actually is

You do not need a special SDK, a build step, or a plugin marketplace to build a skill. A skill is just a folder containing a single SKILL.md file with YAML frontmatter at the top and plain Markdown instructions below it.

Most modern coding agents (Claude Code, Cursor, Gemini CLI, Codex) scan .agents/skills/ automatically:

.agents/
  skills/
    clean-react/
      SKILL.md

When a session starts, the agent only reads the name and description from each skill’s frontmatter. That takes almost zero tokens. The full body of SKILL.md is only loaded when your request matches what the description says.

Step 1: Pick one narrow problem

The biggest mistake when writing a first skill is trying to cover everything in one file, like frontend-master-guide. Broad skills have vague triggers and bloated rules.

Pick one recurring pain point instead:

  • Writing clean TypeScript without any or over-abstracted generics
  • Reviewing pull requests for common React performance traps
  • Formatting commit messages in your team’s exact convention
  • Designing accessible modals and forms

If you cannot explain the skill’s job in one sentence, split it into two smaller skills.

Step 2: Write a trigger-focused description

Think of the description field as the router. Do not write marketing copy. Write the exact phrases, file types, and tasks that should cause the agent to open the file.

Prompt Match? scan description yes Load SKILL.md follow strict rules no Skip file 0 extra tokens
Good trigger descriptions keep irrelevant skills out of your context window.
---
name: clean-react
description: Use when writing, refactoring, or reviewing React components
  (.tsx files). Prevents unnecessary useEffect syncing, prop drilling,
  and oversized components.
---

Compare that to a weak description like "Helps write better React code." The specific version tells the agent when to load it and what mistakes it catches.

Step 3: Write short, testable rules

Inside the body of SKILL.md, skip the philosophy. Write rules that can be checked objectively on a diff.

# Clean React Rules

1. Derive values during render instead of syncing state in `useEffect`.
2. Keep components under 150 lines. Move pure data transforms to `utils.ts`.
3. Never use `any`. Type every prop with an explicit `interface` or `type`.
4. Put user-triggered side effects inside event handlers, not effects.
5. Do not add `useMemo` or `useCallback` unless passing to a memoized child
   or computing over a large list.

Notice that every single rule is binary. Either the diff breaks it or it does not. Vague advice like "write clean, maintainable code" wastes tokens because the model already tries to do that by default.

Step 4: Add one bad example and one good example

Language models follow concrete code patterns much more reliably than prose paragraphs. Adding one tiny before-and-after block at the bottom of your skill often does more work than ten lines of explanation:

// Bad: extra render pass and stale frame risk
const [fullName, setFullName] = useState("");
useEffect(() => {
  setFullName(`${firstName} ${lastName}`);
}, [firstName, lastName]);

// Good: computed directly during render
const fullName = `${firstName} ${lastName}`;

Keep examples short (5 to 10 lines). You are showing the shape of the pattern, not a whole application.

Step 5: Test and prune

Once you save SKILL.md, test it right away on a real task:

  1. Open a fresh chat so old context does not bias the result.
  2. Give a normal prompt that should trigger the skill without naming the skill directly.
  3. Check if the agent actually loaded the skill. If it did not, sharpen the description keywords.
  4. Check if the output still broke one of your rules. If it did, tighten that rule or add a tiny 3-line counterexample.

Keep the whole file under 100 lines whenever you can. A skill is living documentation for your agent. Treat it like production code: small, focused, tested, and easy to trim when it stops pulling its weight.