Charly
·5 min de lecture

Claude Code Skills — What They Are and How to Build Your Own

Claude Code Skills are reusable, slash-invoked workflows that turn repetitive tasks into one-command actions. Full guide: what skills are, how to write them, and the patterns that ship.

If you're using Claude Code on the same kinds of tasks every week — committing, shipping, debugging, QA-testing — you're rewriting the same prompts every time. Skills fix that.

A Skill is a Markdown file. You write the workflow once, save it under .claude/skills/, and from then on a single slash command runs it. /commit writes the commit. /ship opens the PR. /qa runs the test sweep. The workflow is captured, versioned, and reusable.

What a Claude Code Skill actually is

A skill is one file. Frontmatter on top, instructions in the body.

---
description: Quick commit with a clean message — never bypass hooks, never use git add -A
---
 
When the user runs /commit:
1. Run git status to see changes
2. Group related changes; suggest splitting if 2+ unrelated topics
3. Draft a conventional-commit message (feat/fix/chore/...)
4. Stage by name (no -A, no .), commit, push
5. Report the resulting commit URL

That's it. Save as .claude/skills/commit.md and /commit works from your next session.

Where Skills live

Two locations, both auto-discovered:

  • Project skills: .claude/skills/ inside your repo. Scoped to the project, version-controlled with the code.
  • User skills: ~/.claude/skills/ in your home directory. Available across every project.

Project skills override user skills with the same name. So you can have a global /ship for most projects and a custom one for a project that ships differently.

Frontmatter fields that matter

FieldPurpose
descriptionThe trigger sentence Claude reads to decide when this skill applies. Keep it specific.
nameOptional. Auto-derived from filename if omitted.
allowed-toolsOptional. Restricts which tools the skill can use (e.g. Read, Bash, Edit).

The description is the part Claude actually reads to route requests. Write it as a trigger: "Use this skill when the user wants to deploy production." Not "This skill deploys production." The first one routes; the second one explains.

The patterns that ship

After building dozens of skills, the ones that consistently get used share three traits.

1. Single clear trigger. /commit is obviously for committing. /ship is obviously for shipping. Avoid /utilities-misc — no one remembers when to invoke it.

2. Idempotent first step. The skill starts by checking state (git status, npm test, current branch). If state is already clean, the skill exits without doing harm. You want to be able to run the skill twice and not break anything.

3. Reports back. The last step is always a summary: what was done, the URL/path of the artifact, what's pending. Without this, you don't know if the skill succeeded silently or stopped halfway.

Skills vs Subagents — when each wins

People confuse the two because both extend Claude Code. They're different tools.

A Skill runs in your main context. It sees your files, edits them, follows your conversation. Best for routine workflows where the result needs to land in your working tree.

A Subagent runs in a fresh, isolated context via the Agent tool. It can't see your conversation. It returns a single result back to the main session. Best for parallelizable research, second-opinion reviews, or anything you want walled off from main context.

If you're doing /commit, that's a Skill. If you're spawning three parallel research agents to investigate a bug from different angles, that's Subagents.

Skills + Hooks — automatic suggestion

Skills are user-triggered. For automatic behavior, pair them with hooks. A hook detects an event (PR opened, test failed, session started) and prints a suggestion: "Run /qa to test this branch." The user still triggers the skill — but the suggestion is automatic.

This combo keeps the workflow explicit (you approve every action) while removing the "what should I run now?" overhead.

Anti-patterns to skip

Don't write a skill for a one-off task. If you'll only run it once, just type the prompt. Skills are for repetition.

Don't write skills that depend on undocumented state. "Run /deploy and it'll work if you set MY_VAR" is fragile. Either check the env in the skill or document the requirement in the description.

Don't write skills longer than 100 lines. If your skill needs more than a page of instructions, it's probably 2 or 3 skills concatenated. Split them.

A first skill to try

If you're starting from zero, build /commit first. Everyone commits. The workflow is universal. Once /commit is in your hands you'll understand the rest of the surface in 10 minutes.

---
description: Quick commit and push. Drafts a clean conventional-commit message from the staged + unstaged diff. Never uses git add -A or --no-verify.
---
 
When invoked:
1. git status (no -uall flag — large repos crash)
2. git diff for both staged and unstaged
3. Group by topic. If 2+ unrelated topics, ask which to commit first
4. Draft message: type(scope): summary — focus on why, not what
5. Stage explicitly by name. Never git add -A or git add .
6. Commit. Never --no-verify
7. Push to current branch's remote
8. Print the commit SHA and short stat

Save that, run /commit, and you'll have committed your last 15 minutes of work with a clean message in 10 seconds.

That's the entire point of Skills: do it once, reuse forever.


Related: Claude Code Plan Mode — shortcut and full guide · Claude Code Hooks — automate without losing control · Claude Code Agents · Claude Code Subagents · Claude Code MCP · The CLAUDE.md every dev should have

Reçois le prochain article par mail

Des astuces concrètes pour construire avec l'IA. Un email par article.

Articles liés