AI Custom Skills, Commands, CLIs & MCP Servers
Twenty-one lessons on building the tooling layer around AI systems — the skills that shape behaviour, the commands and CLIs people invoke, and the MCP servers that connect models to real systems. Covers everything the 112-card quiz tests.
New to this? Start at Part 0 — five plain-English lessons on what a language model actually is, what "tooling" means here, and what a terminal, a CLI and an API are. No prior experience assumed.
Already building with AI tools? Skip to Part 1.
Part 0 Start here — no experience needed
0.1 What a language model actually does
Strip away the mystique and a large language model does one thing: given some text, it predicts what text should come next. Do that repeatedly and you get sentences, essays, code.
Three consequences follow, and they explain nearly everything in this course:
- It has no memory between conversations. Everything it "knows" about your situation has to be in the text you send it. That's why skills and prompts exist — they're how you supply that context.
- It can be confidently wrong. Predicting plausible text isn't the same as predicting true text. There's no internal fact-checker.
- It can't do anything by itself. Out of the box it produces text. It can't read your files, send an email or query your database — unless you give it tools. That's what MCP is for.
An agent is just a model that's been given tools and allowed to use them in a loop: think, act, look at the result, think again.
0.2 Why AI needs tooling at all
If a model only produces text, why build anything around it? Because typing the same context into a chat box every time doesn't scale.
Say your team has a specific way of writing pull request descriptions. You could explain it in every conversation forever — or write it down once somewhere the AI reads automatically. That written-down instruction is a skill.
Say you run the same eight-step release process weekly. You could describe it each time — or save it as a slash command you invoke by name.
Say the AI needs your live order data. It can't reach your database — unless you build an MCP server that exposes exactly the operations you're willing to allow.
So "AI tooling" isn't a separate technology. It's the ordinary engineering discipline of taking something that works once, and making it work reliably, repeatedly, for everyone.
0.3 The terminal and the command line
The terminal is a window where you type commands instead of clicking. A CLI (command-line interface) is any program you run that way.
ls # list files here cd projects # go into the projects folder git status # ask git what has changed
Each is a program name, then arguments (what to act on) and
flags (options, usually starting with -):
ls -la projects │ │ └── argument: which folder │ └────── flags: long format, include hidden └───────── the program
The one genuinely important idea is the pipe (|), which
feeds one program's output into the next:
cat notes.txt | grep "TODO" | sort
Read the file → keep only lines containing TODO → sort them. Nobody built a "find-and-sort-todos" program; three small tools combined to make one. That composability is why Part 3 cares so much about how a CLI reads input and writes output.
0.4 APIs, protocols and servers
Three words used constantly, all simpler than they sound.
A server is a program that waits for requests and answers them. Nothing more exotic than that — it can run on a machine in a data centre or on your laptop.
An API (application programming interface) is the menu of things a program will let another program ask it to do. A restaurant menu is a good analogy: it lists what you can order, and you don't get to see the kitchen.
A protocol is the agreed format for those requests, so both sides understand each other. If everyone invents their own, nothing connects; agree one, and everything connects to everything.
That last point is exactly why MCP exists. Before it, every AI application needed custom code for every tool — ten apps and ten tools meant a hundred integrations. With a shared protocol you build a tool server once, and any AI app that speaks MCP can use it.
0.5 The four things this course builds
Everything ahead is one of four things, and they differ mainly in who starts it:
- Skills (Part 1) — written instructions the AI loads by itself when it decides they're relevant. Best for "here's how we do X around here".
- Slash commands (Part 2) — saved instructions you trigger by
name, like
/review. Best for a routine you run often. - CLIs (Part 3) — ordinary programs you or the AI run in a terminal. Best when the work is exact and mechanical, needing no judgement.
- MCP servers (Part 4) — a bridge letting the AI reach real systems: your database, your ticketing system, an external API.
One theme runs through all four, so watch for it: a description is an interface. Whether a skill loads, or a tool gets called, depends almost entirely on how well you described it — which is a writing problem as much as a coding one.
How to use this course: read a part, then use the topic filter to quiz just that topic. Every question explains the reasoning, so wrong answers still teach you something.
Part 1 Custom skills
1 What a skill is, and how it gets chosen
A skill is a packaged set of instructions the model loads when it judges them relevant. That last clause is the whole design problem: the body is only read after the skill has been selected, so the description is the most important field in the file. A brilliant skill with a vague description never runs.
Selection is a matching problem, exactly like search:
The strong version names the concrete task, the inputs, and — critically — the words a user would actually type.
Say when not to use it too. Two skills with overlapping descriptions make selection unpredictable; "use for Word .docx files, not PDFs" resolves the ambiguity explicitly instead of leaving it to chance. Over-broad triggers are the mirror failure: "use for all Python work" fires constantly, costs context every time, and gets ignored.
How to test it: triggering is empirical. Run realistic prompts that should fire it and near-miss prompts that shouldn't. False positives are as damaging as false negatives.
2 Structure and progressive disclosure
Everything in a loaded skill competes with the user's actual problem for attention and context. A 3,000-line SKILL.md isn't thorough, it's expensive — and it dilutes the instructions that matter.
Progressive disclosure is the fix: keep the always-loaded entry
point short, and link to reference.md or examples.md that the
model reads only when it needs them. The depth stays available; the cost is paid on
demand.
The discipline for deciding what stays: what must be present to do this job correctly? Everything else moves out.
For a multi-step procedure, use numbered steps in order, with the decision criteria and failure handling at each one. That maps onto how the work is actually performed. A wall of prose containing the same facts is measurably harder to follow.
Keep paths relative to the repository root. A skill is shared code;
/Users/alex/project breaks for everyone else on the team.
3 Writing instructions that get followed
The model already knows a great deal. What it lacks is your specifics — which tool, what order, what to check, what never to do. So encode the workflow, not a textbook. A skill explaining basic Python syntax teaches nothing and costs context on every load.
Three techniques that move the needle:
- Show, don't describe. One worked before-and-after example anchors format, tone and detail far more precisely than adjectives like "concise" or "professional", which different readers interpret very differently.
- State the reason behind a rule. "Never commit to main — CI deploys main straight to production" lets the model extend your intent to situations you didn't enumerate. A bare rule can only be obeyed or not.
- Place rules where they apply. A requirement stated at the step it governs is far more likely to be followed than one buried in a preamble. Emphasis helps less than position.
For preferences with exceptions, state the default and the exceptions: "default to X; use Y when the file is over 10MB". "Always use X" invites either blind application or quiet abandonment when it doesn't fit.
4 Scoping, safety and maintenance
One skill per coherent job. A sprawling "dev-helper" covering testing, deploying and reviewing triggers constantly and does none of them precisely.
Prefer scripts for deterministic work. If every step is mechanical, a bundled script is exact, repeatable and cheaper than spending tokens and risking variance. Reserve model reasoning for judgement.
Set the trust boundary explicitly. Content a skill fetches — a web page, a document, a ticket — is data to consider, never instructions to obey. That's prompt injection at the skill level, and a well-written skill says so.
Check prerequisites. A skill that ploughs ahead without the CLI it needs produces a baffling downstream error; naming the missing piece turns a mystery into a one-line fix.
Keep them in version control with the code they describe. A deploy skill describing a pipeline that changed last month is worse than none — it confidently instructs the wrong thing. Living in the repo puts it in the same review loop as the code.
And remember the hierarchy: a skill is a sensible default, not an override. A user's explicit instruction wins, because they have context the author didn't.
Part 2 Slash commands
5 Commands vs skills
One distinction drives everything: a skill is model-triggered, a command is user-invoked. The command needs no trigger-matching description, which removes the hardest part of skill design — and shifts the effort onto a memorable name and clear arguments.
A slash command is fundamentally a reusable prompt template, expanded into the conversation when invoked. Understanding that explains the rules: it should read as instructions to the model, and arguments are placeholders substituted before the model sees it.
Name commands with verbs — /deploy,
/review, /summarise read as instructions;
/deployment leaves the user guessing whether it acts or reports.
When is it worth writing? When a workflow is repeated often enough and stable enough to be worth encoding. The real value is consistency — everyone gets the same procedure. Encoding something still in flux means constant updates or, worse, a stale command people follow anyway.
6 Arguments and composability
Handle missing arguments gracefully. Users forget them constantly.
/review with no target might sensibly default to the current diff — what it
must not do is silently pick something and leave the user unsure what was reviewed.
Sensible defaults with overrides. Defaults make the common case a single word; flags handle exceptions. Requiring every argument each time is exactly the friction the command was meant to remove.
Document arguments in the command itself, with an example
invocation. /deploy staging --skip-tests communicates the interface
instantly; nobody reads a wiki mid-task.
Composability means doing one well-defined thing and leaving the result in a state other steps can build on. A command that fetches, transforms, commits and posts can't be reused partway. Small commands chain into workflows you didn't anticipate — the same argument as Unix tools.
Prefer several named commands over one /do --mode=review. Separate
commands are self-documenting in a listing; a mode flag hides everything behind knowledge
of the flag values. When two commands share instructions, factor the shared part into a
referenced file rather than duplicating — duplication drifts.
7 Safety, and when to write a script
Commands are easy to fire by accident — mistyped, auto-completed, half-remembered. Anything that deletes, force-pushes or touches production should state what it's about to do and require a deliberate yes.
Related habits that build trust:
- Report what changed. Silent file edits get discovered at the worst moment. Listing them lets the user catch an unintended change before it's committed.
- Be honest about partial failure. Say what succeeded and what didn't, rather than claiming overall success — partial completion is the dangerous case because the user believes the job is done.
- Report progress at milestones on long runs. Silence is indistinguishable from being stuck; a firehose is equally unhelpful.
- Keep output predictable. If the same invocation sometimes yields a table and sometimes prose, nothing can be built on it.
- Ask rather than guess on ambiguous input. One targeted question costs seconds; a wrong guess wastes the run.
When to graduate to a script or CLI: when the logic is fully deterministic and needs no model reasoning. A script is faster, cheaper, testable and runnable in CI. Often the best answer is both — the command sequences the steps and handles judgement, calling scripts for the mechanical parts.
Part 3 CLI tools
8 The Unix philosophy in practice
Do one thing well, and work with text streams so you compose. That's why
grep | sort | uniq solves problems nobody designed for, while a monolith can
only do what its author anticipated.
Composability has concrete requirements:
- Read stdin when no file argument is given, so both
cat data.txt | mytoolandmytool data.txtwork. A bare-conventionally means stdin explicitly. - Stream rather than buffer. Memory use should be constant with respect to input size — that's what lets a tool handle a 10GB file on a laptop.
- Be idempotent where you change state. Scripts get re-run after transient failures; erroring because something already exists forces every caller to special-case it.
Once a tool does several distinct things, use subcommands
(tool db migrate). One flat namespace of mutually exclusive flags becomes
unreadable — git, docker and kubectl all took this
path.
9 Streams, exit codes and TTYs
Three conventions that every script depends on.
stdout is the data channel; stderr is for humans. Errors, warnings
and progress all go to stderr — a warning in the stdout stream corrupts
mytool | jq .. The split also lets a user redirect them separately:
mytool > out.json 2> errors.log.
Exit 0 means success; anything else is failure. This is what
cmd && next and every CI pipeline branch on. A tool that exits 0
after failing breaks automation in the worst possible way — silently.
Detect whether stdout is a TTY. Colour codes and progress bars are
lovely interactively and become garbage in a pipe or log file. Check
isatty, and provide --no-color and --json as
explicit overrides.
A --json mode matters more than it looks: human-readable output should be
free to improve, and scraped text breaks when it does. A JSON mode separates the pretty
format from the machine contract so both can evolve.
In bash scripts, open with set -euo pipefail.
Bash's defaults continue after errors and mask a failing pipeline stage behind a
successful last one.
10 Arguments, config and errors
Configuration precedence runs most-specific-wins: command-line flags override environment variables, which override config files, which override defaults. That lets a user set a project default once and override it for a single run.
Support long flags as well as short ones — scripts are read far more
than written, and someone must understand -rf six months later. Support
-- as end-of-options, so a file literally named -rf is
handled. Ship shell completions: tab completion is how most people learn
a CLI's surface.
Validate arguments before doing any work. Discovering an invalid output path after processing 10,000 records wastes the run and may leave partial state.
Error messages need three things: what failed, why, and what to do:
Error: invalid configConfig error at line 12: "timeout" must be a number, got "30s". Use 30 for seconds.Keep stack traces behind --verbose. And --help should carry
usage, each option with its default, and at least one realistic example — the example is
the highest-value line in it.
11 Safety and packaging
Make the default the safe one. People run tools without reading docs,
so deletion should require --delete and overwriting --force. A
tool whose bare invocation destroys something gets used once, then avoided.
--dry-run is the cheapest safety feature there is: it turns "I hope this is
right" into "I can see this is right".
Never build shell commands by string concatenation with user input. A
filename of ; rm -rf ~ becomes a command. Pass an argument array to the
process API and skip the shell entirely.
Never accept credentials as command-line arguments — they land in shell history and are visible in the process list. Read them from the environment or a secure store.
Don't hang in CI. An interactive prompt with no way to skip blocks
forever where nobody can answer. Provide flags supplying the answers and a
--yes mode; detecting a non-TTY stdin and failing fast beats hanging until
timeout.
Handle SIGINT so Ctrl-C cleans up temp files and stale locks, exiting 130 to signal interruption rather than failure.
Distribution is where adoption dies. A single self-contained binary
sidesteps runtime and dependency installation entirely — the reason Go and Rust tools
spread so easily. For Node, npx-style execution gives first-time users one
command and CI a pinned version. Always support --version.
Part 4 MCP servers
12 What MCP is and why it exists
Before the Model Context Protocol, every integration was bespoke per client: M clients × N services meant M×N pieces of work. A shared protocol turns that into M+N — write the server once, and any MCP-capable client can use it.
That's the entire value proposition, and it explains the design priorities. Your server isn't talking to one application you control; it's publishing an interface to clients and models you don't. So the same discipline applies as to any public API: stable names, clear contracts, careful versioning. Add optional parameters rather than repurposing existing ones, and deprecate before removing — saved workflows and other people's prompts depend on what you shipped.
Keep the server stateless between tool calls where you can. The model may retry after a timeout or interleave calls; hidden state means a retry behaves differently from the first attempt. Pass what a call needs in its arguments.
13 Tools, resources and prompts
Three primitives, distinguished by who initiates:
- Tools — actions the model invokes. Like a POST: they do something and may have effects.
- Resources — data the client reads for context. Like a GET:
identified by URI, ideally side-effect free. URIs give them a stable, meaningful
address —
file:///logs/app.log,db://customers/42. - Prompts — reusable templates the user selects. Effectively a server-provided slash command.
Getting this mapping right matters: exposing a mutating operation as a resource is a design error clients won't expect, because they may fetch resources freely for context.
14 Designing tools models actually call
The model sees only name, description and schema. Nothing else about your implementation exists to it. So the description determines both whether a tool is chosen and whether it's called correctly:
Describe it from the caller's perspective, say what the arguments mean, what comes back, and the limits. Silently returning the first 50 of 4,000 invites confidently wrong conclusions.
Shape tools around tasks, not endpoints. A one-tool-per-REST-endpoint wrapper gives you forty CRUD tools that overwhelm selection and force the model to orchestrate low-level calls. A few task-shaped tools — "find an available slot and book it" — are chosen more reliably and fail less.
Use enums for known values. status: 'open' | 'closed' |
'pending' makes an invalid value structurally impossible rather than relying on the
model to guess your vocabulary.
If a tool is never called, the usual cause is a description that doesn't match how users phrase the task. If they say "what did we invoice Acme last month" and your tool says "Retrieves billing records", the connection may never be made.
15 Transports, auth and context budget
stdio runs the server as a local subprocess — no ports, no auth, lifecycle managed by the client. Simple, and it inherits the local user's access. HTTP lets the server run remotely and serve many clients, which changes the security picture completely.
A hosted server must authenticate callers and scope every tool call to that caller's permissions. Otherwise it's a confused deputy: a server holding database credentials, happily answering anyone who asks.
Two specific traps:
- Never write logs to stdout on a stdio server. stdout carries the
protocol messages; a stray
print()breaks the JSON-RPC framing and the client disconnects. Log to stderr. This catches almost everyone once. - Never expose a raw SQL string tool. You've handed over whatever the credential can do, including DROP. Use intent-shaped tools with typed parameters; if you must allow queries, use a read-only role with a statement timeout and row limit.
Tool results consume context directly. Returning 50,000 rows floods the window and crowds out the actual task. Paginate, cap, and return a total count alongside a page. For long-running work, return promptly with a handle the model can poll rather than blocking the conversation for ten minutes.
Gate destructive tools. Tool calls happen without a human reviewing each one, so either the client gates them or you split the action into preview and commit steps.
16 Testing and failure modes
Test in both directions, because they catch different failures. Direct invocation with known inputs catches broken logic. Running through a real client catches descriptions the model misreads — a tool can be flawless and still never get chosen. The MCP Inspector shortens this loop: list and invoke tools manually to see exactly what the server advertises and returns, separating server bugs from selection issues.
The three failure modes worth memorising:
- Schema mismatch — the declared schema doesn't match what the implementation accepts, so the model sends exactly what was advertised and gets an error it can't diagnose. Generate the schema from the same type definitions the handler uses (FastMCP derives it from annotated parameters), so they can't drift.
- Description ambiguity —
search_usersandfind_customersdoing similar things force a coin flip. Merge them, or state explicitly what each is not for. - Unstructured errors — throwing an unhandled exception ends the attempt. "Invalid date format — expected YYYY-MM-DD, got 03/04/2026" lets the model fix the call itself.
Finally, the security one that ties this course together: a tool fetching web pages or user-submitted tickets returns text someone else wrote. That's a prompt-injection channel, and results should be framed as data to consider rather than commands to obey — the same trust boundary as lesson 4.
▶ Going further
- modelcontextprotocol.io — the specification and SDK docs. This field is young enough that the spec is the primary source; secondary material dates quickly.
- Anthropic — sessions on MCP, skills and agent design.
- Recent MCP tutorials — recency matters more than usual here.
- Best practice: build a small MCP server for an API you already use, then watch a model try to use it. Nothing teaches tool-description design faster than seeing your own tool get ignored.