[VC-05] Leverage âCommands & Hooksâ to boost performance!
This is probably one of the most âunderratedâ features in Claude Code, basically because people often donât have any idea how to use them. Letâs take a look at my ideas.

What are Commands?
Commands are a way to quickly send your pre-made prompt templates.
Unlike CLAUDE.md or AGENTS.md which are âSystem Prompts,â commands are âUser Prompts,â giving them much more weight and priority in processing.
For example, if you find yourself writing the same prompts repeatedly, you can now package them into a command and call it quickly with /<command-name>.
How to create Commands
Itâs very simple. Create a Markdown file in ~/.claude/commands with the following structure:
---
description: Describe this command
---
Write your prompt here
$ARGUMENTSYou can use this command in all your projects with /<command-name>. If you only want to create a command for the current project youâre working on, simply create it in ./.claude/commands.
(*)$ARGUMENTSis the value following the command, inserted at the specified position (e.g.,/fix Default language error).
Pro Tip:
In my first âSubagentsâ article, I mentioned that âCommandsâ are the best way to summon Subagents when needed. Therefore, we can create detailed and clear workflows within each command to customize them according to our needs, suitable for different specific tasks.
For example: fix-ci.md
---
description: Read, analyze, debug, and fix failed Github Actions tests
---
Read, analyze, debug, and fix failed Github Actions tests:
$ARGUMENTS
Process:
- Use âdebuggerâ agent to read and analyze Github Actions logs
- Use âplannerâ agent to plan fixes
- Use âtesterâ agent to test fixes, ensuring all test suites passIâm a bit lazy with this article today đ , and thereâs not much more to say about âCommands,â so Iâll just share a list of the commands Iâve created for use in Claude Code.
Iâve also put all my command files in [this repo](link to repo), along with all the optimized Subagent setups Iâm currently using. Feel free to use them if you need! (If you have any feedback or improvement ideas, please contribute directly to the repo!)
Actually, I was âinspiredâ (a fancy way of saying âborrowed ideasâ) from other peopleâs repos. One of the repos I found quite useful for those using Claude Code is: https://github.com/mrgoonie/claude-code-setup - everyone should check it out!
List of commands I use:
/ask
Use this command to ask anything about the codebase.
---
description: Answer technical and architectural questions.
---
## Context
- Technical question or architecture challenge: $ARGUMENTS
- Relevant system documentation and design artifacts will be referenced using @ file syntax.
- Current system constraints, scale requirements, and business context will be considered.
## Your Role
You are a Senior Systems Architect providing expert consultation and architectural guidance. You focus on high-level design, strategic decisions, and architectural patterns rather than implementation details. You orchestrate four specialized architectural advisors:
1. **Systems Designer** â evaluates system boundaries, interfaces, and component interactions.
2. **Technology Strategist** â recommends technology stacks, frameworks, and architectural patterns.
3. **Scalability Consultant** â assesses performance, reliability, and growth considerations.
4. **Risk Analyst** â identifies potential issues, trade-offs, and mitigation strategies.
## Process
1. **Problem Understanding**: Analyze the technical question and gather architectural context.
2. **Expert Consultation**:
- Systems Designer: Define system boundaries, data flows, and component relationships
- Technology Strategist: Evaluate technology choices, patterns, and industry best practices
- Scalability Consultant: Assess non-functional requirements and scalability implications
- Risk Analyst: Identify architectural risks, dependencies, and decision trade-offs
3. **Architecture Synthesis**: Combine insights to provide comprehensive architectural guidance.
4. **Strategic Validation**: Ensure recommendations align with business goals and technical constraints.
## Output Format
1. **Architecture Analysis** â comprehensive breakdown of the technical challenge and context.
2. **Design Recommendations** â high-level architectural solutions with rationale and alternatives.
3. **Technology Guidance** â strategic technology choices with pros/cons analysis.
4. **Implementation Strategy** â phased approach and architectural decision framework.
5. **Next Actions** â strategic next steps, proof-of-concepts, and architectural validation points.
## Important
This command focuses on architectural consultation and strategic guidance. Do not start implementing anything./cook
In my system prompt, I already have 3 important parts of the workflow for working with subagents: Core Responsibilities, Subagents Team and Development Rules. Call this command to implement a feature or fix a complex bug that requires the entire team of agents.
---
description: Implement a feature
---
Strictly follow your Core Responsibilities, Subagents Team and Development Rules.
Start implementing this task:
$ARGUMENTS/fix
For small bugs that need quick fixes, just use this command for convenience.
---
description: Analyze and fix the issue [FAST]
---
Analyze and fix this issue:
<issue>
$ARGUMENTS
</issue>/fix-test
Run the test suite on my machine (local) to check the results. If there are failed tests, do everything to make them pass, repeat until death :)) pass, repeat until death :))
---
description: Run test flows and fix issues
---
## Reported Issues
$ARGUMENTS
First use the `debugger` subagent and `tester` subagent to find the root cause of the issues, then analyze the reports and implement the fix. Repeat this process until all issues are addressed.
After finish, delegate to `code-reviewer` agent to review code./test
Run the test suite on my machine (local) to check the results, then report back the execution direction.
---
description: Debugging technical issues and providing solutions.
---
Use the `tester` subagent to run tests locally and analyze the summary report./refactor
Typically, ârefactoringâ is a rather complex and... dangerous process. Therefore, I need more strict guidance (I only describe the main ideas, the rest is generated using Meta Prompt with Claude Desktop).
---
description: Refactoring technical debt and improving code quality.
---
Refactoring scope/target: $ARGUMENTS
## Context
- Existing test coverage and dependencies will be preserved.
## Your Role
You are the Refactoring Coordinator orchestrating four refactoring specialists:
1. **Structure Analyst** â evaluates current architecture and identifies improvement opportunities.
2. **Code Surgeon** â performs precise code transformations while preserving functionality.
3. **Design Pattern Expert** â applies appropriate patterns for better maintainability.
4. **Quality Validator** â ensures refactoring improves code quality without breaking changes.
## Process
1. **Current State Analysis**: Use `planner-researcher` agent to map existing code structure, dependencies, and technical debt, and provide the comprehensive implementation plan.
2. **Refactoring Strategy**:
- Structure Analyst: Identify coupling issues, complexity hotspots, and architectural smells
- Code Surgeon: Plan safe transformation steps with rollback strategies
- Design Pattern Expert: Recommend patterns that improve extensibility and testability
- Quality Validator: Establish quality gates and regression prevention measures
- Risk Management: Identify and mitigate risks associated with refactoring
3. **Incremental Transformation**: Design step-by-step refactoring with validation points.
4. **Quality Assurance**: Use `code-reviewer` agent and `tester` agent to Verify improvements in maintainability, readability, and testability.
## Output Format
1. **Refactoring Assessment** â current issues and improvement opportunities.
2. **Transformation Plan** â step-by-step refactoring strategy with risk mitigation.
3. **Implementation Guide** â concrete code changes with before/after examples.
4. **Validation Strategy** â testing approach to ensure functionality preservation.
5. **Next Actions** â monitoring plan and future refactoring opportunities.
**IMPORTANT:** Ask the user for confirmation on the refactoring plan before start implementation./debug
Activate the âdebuggerâ agent to find the root cause of a problem, then report back (do not execute, I need to review it first!).
---
description: Debugging technical issues and providing solutions.
---
**Reported Issues**:
$ARGUMENTS
Use the `debugger` subagent to find the root cause of the issues, then analyze and explain the reports to the user.
**Do not implement the fix automatically.**/watzup
During vibe coding, I found this command quite useful for myself, because AI writes the code, not me. So when I come back the next day or in 2-3 days, I almost canât remember what I did recently, and what I should do next. This command helps review the latest commits, documents in ./docs, and summarizes it for me.
---
description: Review recent changes and wrap up the work
---
Review my current branch and the most recent commits.
Provide a detailed summary of all changes, including what was modified, added, or removed.
Analyze the overall impact and quality of the changes.I think using Commands like this can also be shared among team members, which is quite useful.
Hooks - what are they & what are they for?
Simply put, hooks are like the âautomatic settingsâ you set in a game. Instead of hoping AI remembers to do something, you program it: âEvery time you do X, you must do Y.â No negotiation, no âforgetting,â no âmaybeâ - it just runs.
In other words, if you understand how Webhooks work, then Hooks work similarly.
There are 8 main types of hooks:
UserPromptSubmit - Runs immediately when you send a query (before Claude processes it)
PreToolUse - Runs before Claude uses a tool (can block the tool)
PostToolUse - Runs after Claude finishes using a tool
Notification - Runs when Claude sends a notification
Stop - Runs when Claude completes a response
SubagentStop - Runs when a subagent completes a task
PreCompact - Runs before compaction
SessionStart - Runs when a session starts
Cases where I use hooks:
Send notifications upon completion of work Specifically, I will use a hook here for Claude Code to send notifications via Telegram when it finishes implementing something:
1/ Create a Telegram Bot:
Message /start to @BotFather
Use /newbot to create a new bot
Choose a username (must end with âbotâ)
2/ Get Chat ID:
Message âhelloâ to the newly created bot
Go to https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
Copy chat_id from the JSON response
3/ Set environment variables:
export TELEGRAM_BOT_TOKEN=â123456789:ABCdefGHIjklMNOpqrsTUVwxyzâ
export TELEGRAM_CHAT_ID=â987654321â4/ Install hook: Once installed, the Hook will automatically activate! No additional commands are needed.
Now, every time Claude Code finishes a task, it will send a summary message to my Telegram to notify me. I just need to go back and review it.
TTS + Hook = Voice Assistant!
This is another interesting case study, turning Claude Code into a talking assistant đ
The method is also simple.
First, your machine needs Python support (install it if you havenât already).
1/ Setup hook:
Open
~/.claude/settings.json(or./.claude/settings.jsonif you only want to configure for a single project)Add this snippet:
{
â$schemaâ: âhttps://json.schemastore.org/claude-code-settings.jsonâ,
âhooksâ: {
âNotificationâ: [
{
âmatcherâ: ââ,
âhooksâ: [
{
âtypeâ: âcommandâ,
âcommandâ: âuv run ~/.claude/hooks/notification.pyâ
}
]
}
],
âStopâ: [
{
âmatcherâ: ââ,
âhooksâ: [
{
âtypeâ: âcommandâ,
âcommandâ: âuv run ~/.claude/hooks/stop.pyâ
}
]
}
]
}
}2/ Create the file ~/.claude/hooks/notification.py to play audio
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = â>=3.11â
# dependencies = [
# âpyttsx3â,
# ]
# ///
import sys
import json
import pyttsx3
from typing import Dict, Any
def main() -> None:
âââMain function to handle Claude hook notifications.âââ
try:
input_data = sys.stdin.read().strip()
if not input_data:
print(âNo data received from stdinâ, file=sys.stderr)
sys.exit(1)
hook_data = json.loads(input_data)
handle_notification(hook_data)
except json.JSONDecodeError as e:
print(fâError parsing hook data: {e}â, file=sys.stderr)
sys.exit(1)
except Exception as e:
print(fâError handling notification: {e}â, file=sys.stderr)
sys.exit(1)
def handle_notification(data: Dict[str, Any]) -> None:
âââHandle the notification with text-to-speech.âââ
message = data.get(âmessageâ, âClaude Code notificationâ)
# Initialize TTS engine
engine = pyttsx3.init()
# Make it speak a bit slower so I can understand
rate = engine.getProperty(ârateâ)
engine.setProperty(ârateâ, rate - 50)
# Actually speak the message
engine.say(message)
engine.runAndWait()
print(fâNotification: {message}â)
if __name__ == â__main__â:
main()If you want Claude Codeâs voice to sound better, you can use the ElevenLabs or OpenAI TTS API, but that costs money!
The Trick: âHoisted by my own petardâ
This is my âsecret trickâ for this article. Send Claude Codeâs documentation (copy URL or Markdown) â prompt Claude Code to configure hooks.
Here are some ideas for you:
Read this doc: https://docs.anthropic.com/en/docs/claude-code/hooks-guide
Then write me 3 hooks:
1/ Auto-format Python code
2/ Auto-commit with Git branches
3/ Security Validation: Dangerous prompts are blocked before Claude can act on themA few other tricks

There are many great resources on Claude Code for you to check out here: https://github.com/hesreallyhim/awesome-claude-code
If you donât feel like itâs enough, or rather, you SHOULD check out this website/repo, because it has a lot of cool stuff!