Claude Code Tutorial: Custom Commands, Hooks, and Skills That Make It Yours
An advanced Claude Code tutorial: custom slash commands, hooks, skills, subagents, and MCP setup, then the capstone, persistent memory across sessions and tools with Vilix AI.
Claude Code Tutorial: Custom Commands, Hooks, and Skills That Make It Yours
This is not another "install Claude Code and say hello" post. This Claude Code tutorial assumes you already run sessions, you have a CLAUDE.md, and you know what plan mode does. Now we go deeper: custom slash commands, hooks, skills, subagents, and a real MCP setup. These are the features that turn Claude Code from a smart terminal into your terminal.
Then the capstone most advanced guides skip: persistent memory, so everything you teach it actually sticks.
Custom slash commands: bottle your best prompts
If you type the same long prompt more than twice, it should be a slash command. Custom commands live in .claude/commands/ in your project (or ~/.claude/commands/ for global ones). Each is a markdown file whose name becomes the command.
Say you always want the same code review. Create .claude/commands/review.md:
Review the changes in the working tree for:
- security issues (injection, auth bypasses, exposed secrets)
- error handling gaps
- deviations from the conventions in CLAUDE.md
Do not fix anything. Report findings ordered by severity, with file and line references.
Now /review runs your exact review process every time, in every session, with zero retyping. Commands can take arguments too: /review auth/ scopes it to a directory. Build a small library of these and your best workflows become one keystroke.
Good candidates for commands: your deploy checklist, your incident triage prompt, your "explain this diff to me" prompt, your test-generation prompt with your project's conventions baked in.
Hooks: automation at the agent's lifecycle points
Hooks are shell commands that fire at specific points in the agent's lifecycle: before a tool runs, after it runs, when the user submits a prompt, when the session ends. They are configured in .claude/settings.json.
The most useful hook pattern for most developers is a guardrail. Example: block the agent from committing directly to main:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo \"$TOOL_INPUT\" | grep -q 'git push origin main' && { echo 'Pushing to main is blocked. Open a PR instead.'; exit 2; } || exit 0"
}
]
}
]
}
}
Other hooks worth having: a PostToolUse hook that runs your linter after every file edit, so style violations get caught and fixed inside the same session. A SessionEnd hook that appends a one-line summary of what happened to a local log, which becomes a crude but useful paper trail of agent work.
Hooks are deterministic where the agent is probabilistic. Use them for the rules you never want debated.
Skills: teach it your domain once
Skills are the step up from slash commands. A slash command is a prompt you trigger; a skill is a capability the agent reaches for on its own when the situation matches. A skill is a directory with a SKILL.md describing when to use it and how.
The classic example: your team's API design conventions. Write a skill once describing your patterns (pagination shape, error envelopes, versioning rules), and the agent applies them whenever it touches the API layer, without you invoking anything.
Skills compound. Every skill you write is knowledge the agent has in every future session. The developers getting the most out of Claude Code are quietly building personal skill libraries: one for their stack's conventions, one for their testing approach, one for how they write database migrations. That library is a durable asset in a way prompts never are.
Subagents: parallelize deliberately
You have seen the agent fan out on its own. You can also define subagents explicitly for work you repeat. A subagent definition names a role, its tools, and its instructions. The pattern that pays off fastest: a dedicated reviewer subagent.
While the main agent implements, it can hand the diff to a reviewer subagent with fresh context and strict instructions ("you are a security reviewer, you have not seen this code before, find flaws"). Fresh eyes catch what the implementer rationalizes away. Because the reviewer runs in its own context, it does not inherit the main agent's assumptions, which is exactly why the review is worth something.
Use explicit subagents for: security review, test generation against fresh requirements, documentation passes, and research spikes that should not pollute the main session's context.
MCP setup: give it your real tools
By now your agent is capable but still terminal-bound. MCP servers connect it to your real systems. The setup worth doing:
Start with your issue tracker. An agent that can read the actual ticket, its comments, and its acceptance criteria writes better code than one working from your paraphrase.
Add your database. Read-only access for investigation ("why is this query slow in production") is the highest-value, lowest-risk MCP connection most developers can make.
Add one domain tool. Whatever your team lives in: the feature flag service, the observability platform, the docs. One is enough to start; the pattern is what matters.
Configure servers in .claude/settings.json or via claude mcp add, and scope permissions tightly. An agent with production database write access is a footgun; read access plus explicit approval for writes is the sane default.
The capstone: persistent memory
Here is the ceiling you will hit with everything above: commands, hooks, skills, and subagents all make individual sessions better, but every session still starts cold. Your skills teach the agent how you work in general. Nothing remembers what you are working on right now, what you decided yesterday, or where you left off. That context lives in session history, and session history evaporates.
The fix is a memory layer underneath the sessions. Vilix AI is a shared memory and work-state layer that connects to Claude Code over MCP, tied to one account. Each client needs its own connection; one approval does not configure the others. Once connected with the memory tools enabled:
- Sessions open with
get_context: the agent loads the relevant saved context, your project state, decisions, rules, exactly where the work stopped. The briefing you used to type every morning disappears. - Work is saved with
save_turn: full exchanges, not just extracted facts, plus derived memories, tasks, and project rules. Retrieval is semantic, so it finds what you meant, not just what you typed, and it pulls only what is relevant. - It follows you past Claude Code. The same memory is there in Codex, Cursor, OpenClaw, Hermes, ChatGPT, any MCP-compatible AI, on your phone and your laptop. Your skills live in the shared store too, so the capabilities you built here are available in every tool. Correct something once and it is corrected everywhere. When two tools save conflicting info, the most recent save wins, so the newest version is always what the AI sees.
The honest caveat, since you are advanced enough to care: the model decides when to call the memory tools, and models can be lazy about it. Nudge it ("check Vilix AI for context first") and it works. That is a property of MCP, not a product bug.
Why this stack is worth building
Commands, hooks, skills, subagents, MCP, and memory form a ladder. Each rung makes the agent more yours: your prompts bottled, your rules enforced deterministically, your domain knowledge on tap, your tools in reach, your context persistent. The developers who climb it stop thinking of the agent as a tool they operate and start thinking of it as an environment they maintain.
Vilix AI is cloud-hosted, so the memory layer needs zero infrastructure from you. It stores full conversation history you can revisit any time. Your data is portable: export everything or delete individual memories (or the whole account) whenever you want, no waiting period. There is a free plan, and the 7-day Pro trial requires no credit card. See the plans: https://vilix.ai/pricing?utm_source=blog&utm_medium=article&utm_campaign=claude-code-tutorial-advanced
You already know the basics. This is the rest: https://vilix.ai?utm_source=blog&utm_medium=article&utm_campaign=claude-code-tutorial-advanced