Claude Code
Lộ trình phát triển toàn diện Claude Code theo tiêu chuẩn quốc tế nilbuild/developer-roadmap
Hướng dẫn từng bước từ nền tảng đến chuyên sâu giúp bạn làm chủ Claude Code. Tích hợp tài liệu lý thuyết, bài viết thực chiến, video tham khảo và bài tập lập trình trực tiếp trên IDE.
Nền Tảng & Khái Niệm Cốt Lõi
Giai đoạn 1 tập trung hoàn thiện 24 chủ đề then chốt.
File Path Mentions (@)
File path mentions, triggered by typing the `@` symbol followed by a filename or folder, allow you to manually point the AI toward specific parts of your codebase. This creates a direct reference that prioritizes those files in the current conversation, ensuring the assistant analyzes the exact code you are interested in without having to search your entire project first. It supports autocomplete, so as you type after the @ symbol, a list of matching files appears, allowing you to quickly select the correct path and add it to the conversation context.
Multiline input ()
Multiline input allows you to format complex instructions across several lines without immediately sending the prompt to the AI. The fastest way to create multiline input is by typing `\` followed by `Enter`. This works in all terminals by default and tells the system to treat the next line as a continuation of the current one. However, depending on your terminal and configuration, alternative methods may be available.
Bash Mode (!)
Bash Mode (triggered by prefixing your input with an exclamation mark !) is a powerful feature that allows you to execute shell commands directly on your machine without involving the Claude Code's reasoning or consuming any tokens. While the AI assistant normally uses the "Bash tool" to run commands on your behalf (which costs money and takes time for the model to "think"), Bash Mode is your direct line to the terminal.
claude --add-dir
The `claude --add-dir` command is a startup flag that allows you to include extra folders in your working session before the interface even opens. By providing one or more directory paths when you launch the tool (for example, `claude --add-dir ../library --add-dir ./docs`), you grant the assistant permission to read and modify files in those external locations alongside your current project. This is particularly useful for cross-repository tasks, such as updating a shared library and its dependent application simultaneously, as it ensures the AI has a unified view of all relevant codebases from the very first prompt.
Agent Team
Agent Teams are an experimental multi-agent orchestration feature in Claude Code that allows you to coordinate multiple AI instances working in parallel on a single project. Agent Teams function as a collaborative network where a designated Team Lead manages a shared task list and delegates work to Teammates who can message each other directly to share findings or debate solutions.
/agents
The `/agents` command is a specialized management interface used to create, configure, and orchestrate sub-agents within your Claude Code environment. This command transitions from a single-assistant model to a multi-agent workflow, allowing you to delegate specific types of work—like security auditing, unit testing, or architectural planning—to "specialists" that have their own isolated context windows and tailored system prompts.
API Usage
Claude Console authentication uses a pay-as-you-go model where the tool connects directly to the Anthropic API using a personal API key rather than a flat-rate monthly subscription. To set this up, you must first create an account at the Claude Console, generate a secret API key, and ensure you have a balance of credits in your account. This mode is ideal for power users or developers who prefer to pay only for the specific amount of data (or tokens) processed during their coding sessions. Because this connection communicates directly with the API, it also allows you to choose specific model versions and provides more granular control over your billing and usage thresholds.
Be mindful of extensions
Carefully managing extensions, such as MCP servers, skills, and subagents, is vital because every active integration consumes a portion of Claude’s finite context window, and excessive "context pollution" can lead to degraded reasoning or higher operational costs.
Channels
Claude Code channels are MCP server plugins that push messages, alerts, and webhooks into your running Claude Code session, allowing Claude to react to events while you're away from the terminal. Channels enable two-way communication through platforms like Telegram, Discord, and iMessage. You install them as plugins, configure credentials, and pair your account so Claude can receive and respond to messages in real-time. Unlike web sessions that spawn fresh instances, events arrive in your already-open session, making channels ideal for always-on setups where you run Claude in a background process.
claude --add-dir
The `claude --add-dir` command is a startup flag that allows you to include extra folders in your working session before the interface even opens. By providing one or more directory paths when you launch the tool (for example, `claude --add-dir ../library --add-dir ./docs`), you grant the assistant permission to read and modify files in those external locations alongside your current project. This is particularly useful for cross-repository tasks, such as updating a shared library and its dependent application simultaneously, as it ensures the AI has a unified view of all relevant codebases from the very first prompt.
claude -c
The `claude -c` command (short for --continue) is a CLI flag used to instantly reopen the most recent conversation session in your current directory. Instead of starting a fresh chat with a clean context, this command restores the previous conversation history, allowing you to pick up exactly where you left off without having to re-explain your project’s state or repeat previous instructions.
claude -p
The `claude -p` command (short for --print) activates Print Mode, which runs Claude Code as a non-interactive, single-use utility rather than a continuous chat session. When you use this flag, you provide a prompt directly in the command line; Claude then executes its agentic loop—researching, editing files, or running commands as needed—and exits immediately once the task is complete. This mode is designed primarily for automation and scripting, allowing you to integrate Claude's reasoning into CI/CD pipelines, shell scripts, or "one-liners".
claude -r
The `claude -r` command (short for --resume) allows you to restart a specific past conversation by providing its unique Session ID. Unlike the `-c` flag, which automatically opens the very last session you had, `-r` gives you the precision to jump back to any session from your history, ensuring you can continue a specific line of work without losing context or previous tool outputs. If you run the command without an ID—simply typing `claude --resume` —it opens an interactive session picker where you can scroll through a list of recent conversations, see their titles, and choose the one you want to reactivate.
Claude CLI
Claude Code CLI is a command-line tool that acts as an agentic AI coding partner by interacting directly with your local files and terminal. To set it up, you first need an active Claude subscription or an Anthropic Console account. Once installed, navigate to your project folder, type `claude` to start a session, and follow the prompts to log in via your browser.
Claude Code Security
Claude Code Security is a new feature built into Claude Code that scans your codebase for security vulnerabilities and suggests fixes for your team to review. Every finding goes through a verification process before it reaches you, with severity ratings so you know what to fix first. Nothing gets changed automatically; Claude suggests the fix, but a human always approves it. It is currently available as a limited research preview for Enterprise and Team customers, with free access for open-source maintainers.
claude "query"
The `claude "query"` command allows you to start the Claude Code interactive REPL (Read-Eval-Print Loop) with an initial instruction already provided. By passing a string as an argument directly after the `claude` command, the assistant will immediately begin processing that request—such as "explain this project" or "fix the lint errors"—the moment the interface loads. This method is more efficient than opening the tool first and typing your request manually, as it combines the startup and the initial task into a single step while still keeping the session open for further conversation and follow-up actions.
Claude Workflow
The Claude Code workflow operates as a continuous agentic loop where the AI moves through four primary phases: Explore, Plan, Implement, and Verify. It begins by indexing your local codebase and reading persistent instructions from your [CLAUDE.md](http://CLAUDE.md) file to align with your project's specific standards. When you issue a prompt, Claude uses its suite of built-in tools to research the files (Explore), proposes a detailed step-by-step strategy for the change (Plan), and—upon your approval—executes the modifications using file-editing and shell tools (Implement). The cycle concludes by running your defined test suites or linters (Verify) to ensure no regressions were introduced, often utilizing MCP servers to sync the final results with external platforms like GitHub or Jira.
claude command
The `claude` command is the primary entry point used to launch the Claude Code interface from your terminal. When you type this command within a project directory, it initializes the agentic environment, indexes your local files, and establishes a secure connection to the AI model so you can begin issuing natural language instructions. It also supports various flags to customize Claude Code’s behavior.
CLAUDE.md
`CLAUDE.md` is a configuration file placed in a project's root directory that provides the AI assistant with specific rules, project context, and custom instructions for that particular codebase. It acts as a set of persistent guidelines that the AI reads at the start of every session to ensure its code suggestions align with your project's coding standards, tech stack, and architectural patterns.
CLAUDE.md
[CLAUDE.md](http://CLAUDE.md) is a project-specific markdown file that acts as the "persistent memory" and onboarding manual for Claude Code, ensuring the AI adheres to your unique development standards across every session. Since Claude begins each new interaction with a blank context, this file is automatically read at launch to provide essential project "WHY, WHAT, and HOW".
/clear
The `/clear` command is a utility tool that removes all previous messages, tool outputs, and file contents from the active conversation history. It wipes the current context, allowing you to start a fresh dialogue with the AI without exiting the application or losing your current working directory settings. This is particularly useful for reducing token costs and preventing "context drift," where the AI might become confused by old instructions or irrelevant code snippets from a previous task.
Code Intelligence Plugin
Code Intelligence plugins extend the CLI's native search capabilities by integrating with the Language Server Protocol (LSP), granting Claude the same "IDE-level" awareness found in modern editors.
Common Usecases
Claude Code can be used for a wide range of professional software development tasks, from legacy system modernization and large-scale refactoring to rapid prototyping for startups. Organizations use it to navigate and modernize massive codebases containing millions of lines of code, while data science teams employ it to convert exploratory research from notebooks into production-ready data pipelines. In daily engineering workflows, it is frequently applied to automate unit testing, diagnose complex bugs using stack traces, and manage dependency upgrades across entire repositories. Additionally, it has become a powerful tool for infrastructure automation, where DevOps teams use it to manage Kubernetes clusters, configure monitoring systems, and build CI/CD pipelines through natural language instructions.
Community Tools
Community tools extend Claude Code's capabilities by integrating it with external platforms via the Model Context Protocol (MCP) and specialized plugins. These integrations allow the assistant to interact directly with services like GitHub for managing pull requests, Slack for sending project updates, and Jira or Linear for tracking issues. Beyond official offerings, the community has developed numerous third-party extensions, which can be easily added via the `/plugin` command.
Kỹ Năng Trọng Tâm & Thực Hành
Giai đoạn 2 tập trung hoàn thiện 24 chủ đề then chốt.
/compact
The `/compact` command is a context management tool designed to optimize your session's memory when the context window begins to fill up. Instead of completely wiping your history like `/clear`, `/compact` instructs Claude to generate a concise summary of the key decisions, code changes, and project state established so far. It then replaces the bulky, line-by-line conversation history with this summarized version, effectively "compressing" the tokens used while preserving the essential knowledge the AI needs to continue the task.
/config
The `/config` command is the central management tool for customizing your Claude Code experience and fine-tuning how the assistant interacts with your system. Running this command opens an interactive menu—or allows for direct terminal arguments—to modify global and project-specific settings such as default models, theme preferences, and permission levels.
Connecting Tools with MCP
Model Context Protocol (MCP) transforms Claude Code from a local file editor into a connected agent capable of interacting with your entire tech stack, from Jira tickets to live databases. Acting like a "USB-C port for AI," MCP provides a standardized bridge that allows Claude to discover and execute external functions without requiring custom-coded integrations for every service.
/context
The `/context` command is a diagnostic tool that provides a technical breakdown of how the model's context window is currently allocated, using a colored grid. While commands like `/usage` show you the "how much," `/context` shows you the "what." It lists every file, conversation turn, and tool result currently being held in the AI's active memory, allowing you to see exactly which resources are consuming tokens.
Context
A context window is the total amount of information a model can hold in its active memory at one time, including your conversation history, the files it has read, and the results of any terminal commands it has executed. It functions like a temporary workspace where every word and symbol (counted as tokens) fills up a limited capacity. As this window fills, Claude Code may begin to "forget" earlier details or become less accurate, which is why managing context through commands like `/compact` is essential to keep responses sharp and costs under control.
/cost
The `/cost` command is a financial monitoring tool that provides a real-time snapshot of the monetary expenses and token usage for your active session. While the `/usage` command focuses on how much of your context window is occupied, /cost translates that activity into USD amounts, showing you exactly how much your current conversation has cost based on your API pricing tier.
Creating Custom Skills
To create a custom skill in Claude Code, you must establish a new folder within the `.claude/skills/` directory containing a `SKILL.md` file that defines the skill's identity and logic. This file begins with a YAML frontmatter block containing a unique `name` and a detailed `description`, which Claude uses as a trigger to "know" when to activate the skill, and can include an optional `disable-model-invocation: true` flag if you want the skill to run as a manual, deterministic workflow rather than an autonomous one.
Creating Subagents
To create a Subagent in Claude Code, you must define a specialized assistant within a Markdown file located in the `.claude/agents/` directory, using YAML frontmatter to specify its `name`, `description`, `model`, and a restricted set of `tools`.
Ctrl+C
`Ctrl+C` is a keyboard shortcut that immediately sends an interrupt signal to the Claude Code terminal to stop its current activity. It is primarily used to halt a long-running process, such as an accidental infinite loop in your code, a search that is taking too long, or a lengthy model response that you realized was going in the wrong direction. This provides a manual "kill switch" that is essential for maintaining control over the agent's actions and preventing the unnecessary consumption of tokens and time.
Ctrl+R
`Ctrl+R` is a terminal shortcut that opens the command history search, allowing you to quickly find and reuse previous prompts or terminal commands you have typed during your session. Instead of manually retyping complex instructions or scrolling back through hundreds of lines of output, you can press `Ctrl+R` and start typing a few letters to filter your recent activity until the correct entry is highlighted. Once you find the desired command, you can press `Enter` to run it immediately or use the arrow keys to edit the text before execution.
Customize Status Line
Claude Code allows you to personalize your terminal environment by customizing the status line, which is the persistent information bar at the bottom of the interface. You can keep essential data like real-time session costs or context usage percentages visible at all times, helping you manage your budget and "context rot" without manually running diagnostic commands.
Claude Code Desktop
Claude Code desktop is a software application that allows an AI assistant to interact directly with your local files and development tools through a graphical interface. It functions as an agentic coding partner that can read your codebase, edit files, and execute terminal commands to help build features or fix bugs in real time.
/doctor
The `/doctor` command is a diagnostic utility used to troubleshoot and verify the health of your Claude Code installation and its environment. When executed, it runs a series of automated checks to ensure that your authentication tokens are valid, your network connection to the Anthropic servers is stable, and all required system dependencies—like Git and Node.js—are correctly configured. If the tool detects an issue, such as a missing binary or an expired session, it provides a detailed error report and suggested steps to resolve the problem immediately.
CLaude Code in Code Editor
IDE extensions allow you to use Claude Code directly within popular development environments like Visual Studio Code and the JetBrains family (including IntelliJ IDEA, PyCharm, and WebStorm). These extensions provide a graphical sidebar and inline diff viewers, enabling you to review proposed code changes side-by-side with your existing files. By integrating with the IDE, Claude gains automatic awareness of your active workspace, current file selection, and even terminal error messages, which eliminates the need to manually copy and paste context.
Esc + Esc
Double-tapping the `Esc` key in Claude Code activates the Rewind feature, which serves as a temporal navigation system for both your conversation history and your code state. When triggered, it opens an interactive menu that allows you to jump back to any previous prompt in the session, effectively acting as a "undo" button for AI-driven development. You can choose to restore only the conversation (useful for refining instructions without losing current file edits), restore only the code (to revert specific file changes while keeping the chat context), or restore both to a verified checkpoint. This shortcut is particularly valuable for experimental coding because it automatically creates local checkpoints before every change, allowing you to quickly discard an entire branch of reasoning or a failed implementation without manually restoring individual files or managing Git commits.
Esc Command
The `Esc` key is a navigation shortcut used to exit current menus, cancel active inputs, or clear the command line. If you are in the middle of typing a long prompt and want to start over, pressing Esc will wipe the input field clean, and if you have a dropdown menu or a multi-select list open—such as when choosing files to add to context—it will close that menu without making a selection. This shortcut provides a quick way to reset your immediate interface state without interrupting the underlying AI process or closing the terminal session entirely.
/exit
The `/exit` command is a built-in utility used to safely terminate your current Claude Code session and return you to your standard terminal prompt. Unlike force-quitting the application, using this command ensures that the system performs a clean shutdown, which includes saving your conversation history and updating any local session metadata so that you can resume your work later using the `claude -c` flag.
/export
The `/export` command is a data utility that allows you to save your entire current conversation history into a single file on your local machine. This command generates a Markdown-formatted document containing all your prompts, the AI's responses, and the results of any code changes or terminal commands executed during the session. It is designed for documentation and knowledge sharing, enabling you to archive successful debugging sessions, create project reports, or share a complex implementation logic with teammates who do not have access to your local terminal history.
Git Worktrees
Using Git worktrees with Claude Code is a powerful scaling technique that allows you to run multiple independent AI sessions in parallel without the overhead of context switching or the risk of file-edit collisions. This workflow is highly efficient for "fanning out" tasks: you can supervise several separate worktrees simultaneously, leveraging prompt caching across them for shared codebase context, and simply delete the worktree folder once the branch is merged to keep your environment clean.
Haiku
Claude Haiku is the fastest and most cost-effective model in the Claude family, specifically engineered for high-speed, high-volume tasks that require near-instant responsiveness. It provides a compact but powerful solution for real-time applications like customer service chatbots, rapid data extraction, and moderating large content streams where low latency is critical.
Headless mode
Headless mode in Claude Code, enabled by the `-p` (or `--print`) flag, transforms the interactive terminal assistant into a programmable Unix-style utility designed for automation and CI/CD pipelines.
/help
The `/help` command is an interactive directory that provides a comprehensive list of all available slash commands, keyboard shortcuts, and system features. When you type it, Claude Code displays a searchable guide that explains how to use tools such as context management, file mentions, and permission modes. It is designed to be a quick-access manual that helps you discover advanced functionality or refresh your memory of syntax without leaving your terminal or consulting external documentation.
Hook Events & Matchers
In Claude Code, Hook Events represent the specific lifecycle moments when custom logic can be triggered, while Matchers act as the regex-based filters that determine which specific actions within those moments should fire the hook.
Hook Inputs & Outputs
Hooks communicate via a standardized JSON interface: Inputs are passed to the hook via `stdin`, and Outputs are returned via `stdout` to influence the agent's next move. The input payload typically includes a `context` object containing session metadata and event-specific data, such as the `tool` name and its arguments (e.g., the exact code being written or command being run). To respond, your hook must return a JSON object.
Kiến Trúc Nâng Cao & Tối Ưu
Giai đoạn 3 tập trung hoàn thiện 24 chủ đề then chốt.
Hook Types
In Claude Code, you can configure three distinct handler types for your hooks—Command, Prompt, and Agent—depending on whether you need a script, an AI "judgement call," or a specialized researcher to validate actions. Command hooks (`type: "command"`) are deterministic shell scripts that execute standard commands (like `npm run lint`) and use exit codes to either approve the action or block it with an error message. Prompt hooks (`type: "prompt"`) use a lightweight Claude model for single-turn evaluation, where the model analyzes the context (e.g., "Is this commit message descriptive?") and returns a simple JSON yes/no decision. Finally, Agent hooks (`type: "agent"`) are the most sophisticated, spawning a multi-turn subagent with tool access (like `Read` or `Grep`) to conduct deep, autonomous verification before deciding if the main agent should proceed.
Hooks
Hooks are automated triggers that execute specific scripts or commands at key points in the AI's workflow, such as before or after the assistant performs a task. These hooks allow developers to enforce project standards and ensure system reliability without manual intervention, much like Git hooks but designed for an AI-driven development cycle.
/hooks
The `/hooks` command opens an interactive management menu for configuring automated workflows that trigger at specific points in the Claude Code lifecycle. While features like `CLAUDE.md` provide "soft" instructions, hooks offer deterministic control, ensuring that specific shell commands or AI evaluations run every single time a certain event occurs—such as formatting code after an edit or sending a notification when Claude needs your attention.
Hooks
Hooks are automated triggers that execute specific scripts or commands at key points in the AI's workflow, such as before or after the assistant performs a task. These hooks allow developers to enforce project standards and ensure system reliability without manual intervention, much like Git hooks but designed for an AI-driven development cycle.
How to Structure CLAUDE.md
To write an effective [CLAUDE.md](http://CLAUDE.md), you should treat it as a concise, persistent "source of truth" that provides Claude with the project-specific context it cannot infer from the code alone. The file should be kept short and human-readable, focusing on non-obvious information like unique bash commands for building and testing, repository-specific code styles, and architectural decisions.
/init
The `/init` command is the initialization utility used to set up Claude Code for a specific project directory. When you run this command, it creates a [CLAUDE.md](http://CLAUDE.md) file in your current folder. This file serves as the "foundation" for the assistant, allowing you to define project-specific coding standards, build commands, and test suites that Claude will automatically reference in every future session within that repository.
What is Claude Code?
Claude Code is an AI-powered coding tool developed by Anthropic that operates directly in the terminal. Unlike traditional autocomplete tools, Claude Code functions as an autonomous agent capable of understanding entire codebases, executing multi-step tasks, and maintaining context across complex projects. By understanding the entire codebase, Claude Code helps simplify workflows, making it a powerful tool for software development.
Locations of CLAUDE.md
Claude Code manages instructions through a hierarchical memory system that layers context based on the directory structure of your project. At the start of every session, Claude recursively searches from your current working directory up to the root, automatically loading global preferences from `~/.claude/CLAUDE.md` and shared team standards from the project root's `CLAUDE.md`. Claude also supports progressive disclosure via subdirectory [CLAUDE.md](http://CLAUDE.md) files.
Loops
`/loop` is a Claude Code command that reruns a prompt on a repeating interval within an open session, useful for polling a deployment or babysitting a pull request. Giving it an interval and a prompt runs on a fixed schedule, giving just a prompt lets Claude pick the interval dynamically each iteration, and giving neither runs a built-in maintenance prompt that checks unfinished work and pending PR comments. Loops are session-scoped and expire after seven days, and can be stopped early by pressing Es
Manage Context
Active management of the context window is the single most effective way to ensure reliable model performance and predictable operational costs, as Claude Code is billed based on the total number of tokens processed in each turn. Because the tool re-reads the entire conversation history with every new message to maintain state, unmanaged sessions can quickly balloon in size, leading to "context rot" where the model loses track of early instructions or struggles with "lost-in-the-middle" accuracy degradation.
Manage Sessions
Claude Code manages sessions through a persistent, local architecture where every interaction is stored in a unique session file, allowing you to resume work using terminal flags like `claude --continue` (for the most recent thread) or `claude --resume` (to open an interactive picker of past conversations). While each new session initializes with a fresh context window to optimize token usage and avoid irrelevance, Claude automatically snapshots affected files before any modification, enabling you to use the `/rewind` command to revert both code and conversation history to a previous "checkpoint."
MCP
The Model Context Protocol (MCP) is an open-source standard that enables a Claude Code to connect securely to a vast ecosystem of external tools, databases, and third-party services. By acting like a "universal connector" for AI, MCP allows you to extend the Claude Code's core capabilities beyond simple file editing, giving it the power to interact with APIs like GitHub to manage pull requests, query live databases such as PostgreSQL or Snowflake, and much more.
/mcp
The `/mcp` command is the integration hub for the Model Context Protocol, an open standard that connects Claude Code to external data sources and third-party tools. While you use the terminal command `claude mcp add` to install a new server, the `/mcp` slash command is used inside the session to manage those connections, authorize permissions, and view the specific capabilities (tools) available to the AI.
/memory
The `/memory` command is a knowledge management tool used to create and manage persistent information that survives across different Claude Code sessions. Unlike the `/compact` command, which only optimizes the current conversation's temporary window, `/memory` interacts with permanent storage—primarily your project's [CLAUDE.md](http://CLAUDE.md) file and a hidden auto-memory directory. When you run this command, it typically opens your system's default text editor, allowing you to manually refine the coding standards, architectural decisions, and project-specific patterns that Claude should "remember" every time you launch the tool in that directory.
Channels
To use Claude Code with mobile apps through channels, you install a pre-built channel plugin for your messaging platform, like Telegram, Discord, or iMessage. The plugin runs locally on your computer and polls the platform's API for new messages. When someone sends you a message on the mobile app, the plugin receives it and forwards it to Claude Code, which can then read and respond. You configure the plugin in your MCP config file, and Claude Code spawns it automatically. The plugin acts as a bridge between the mobile app and Claude Code, so you can chat with Claude through your phone without exposing any URLs to the internet.
Model Configuration
Claude Code offers a highly flexible model configuration hierarchy that allows you to balance speed, cost, and reasoning depth across different tasks. You can switch models instantly during an active session using the `/model` command, specify a model at startup with the `--model` flag, or set a permanent default in your `~/.claude/settings.json` file using the `model` key. The system supports semantic aliases like sonnet (default for daily coding), haiku (fast and efficient), and opus (high-reasoning for complex architecture), as well as a specialized `opusplan` mode that intelligently uses Opus for strategic planning before automatically switching to Sonnet for the actual code implementation. Furthermore, you can fine-tune performance on supported models by adjusting the `effortLevel` (low, medium, or high), which controls how much "thinking time" Claude allocates to solving difficult logic puzzles versus generating rapid responses.
/model
The `/model` command is a switcher utility that allows you to change which large language model (LLM) is powering your current session without restarting the application. This is particularly useful for cost-performance optimization; you can use a high-intelligence model like Claude Sonnet for complex architectural planning and then switch to a faster, cheaper model like Claude Haiku for repetitive tasks like writing boilerplate code or unit tests.
Claude Code Models
Claude Code is powered by three distinct models—Opus, Sonnet, and Haiku— each optimized for a specific role within the development lifecycle. **Claude Opus** is the "deep thinker" and primary architect, used for complex reasoning, high-level system design, and surgical bug fixes in large codebases. **Claude Sonnet** serves as the versatile "balanced builder," providing a high-speed middle ground for daily tasks like implementing feature logic, writing boilerplate, and managing state across multiple files. **Claude Haiku** is the "fast-response specialist," designed for near-instant execution of lightweight tasks, such as generating rapid UI prototypes, drafting commit messages, or acting as parallel sub-agents to scan logs and run quick checks.
Modes
Permission modes are settings that control the level of autonomy the AI has when interacting with your computer. By default, the system operates in Default Mode, where it must ask for your approval before it edits any files or executes shell commands. You can cycle through other levels of authority, such as Accept-Edits Mode, which allows the AI to modify files automatically while still prompting you for terminal commands, or Plan Mode, which restricts the AI to read-only tools so it can research and outline a strategy without making any actual changes. For advanced workflows, specialized states like Delegate Mode exist to limit a "lead" agent to coordinating other sub-agents, while the high-risk Bypass-Permissions Mode removes all approval prompts entirely for use in secure, isolated environments.
Opus
Claude Opus is the most advanced and capable large language model in the Claude family, designed specifically for high-level reasoning and complex problem-solving. It functions as a "deep thinking" engine that can handle vast amounts of information and follow intricate instructions with a high degree of accuracy and nuance.
Opusplan
`opusplan` is a specialized command alias for Claude Code that combines the high-level reasoning of the most advanced model with the speed and efficiency of a faster one to optimize complex development tasks. When you initiate a session using `claude opusplan`, the tool uses Claude Opus to analyze your request, explore the codebase, and draft a comprehensive technical strategy, ensuring that the initial logic and architectural decisions are as accurate as possible.
Output Styles
Claude Code allows you to switch between different output styles to adapt the agent’s persona and verbosity to your specific needs, effectively modifying its core system prompt. Beyond the standard coding mode, you can use built-in styles like Explanatory, which provides educational insights into implementation choices, or Learning, a collaborative mode where Claude places `TODO(human)` markers to encourage hands-on contribution.
Permission Modes
Claude Code features several permission modes that define the balance between autonomy and safety during your session, ranging from Plan mode, which restricts Claude to a read-only state for exploration and strategy without any tool execution, to BypassPermissions mode (often called "YOLO mode"), which grants the AI full autonomy to run any command or edit any file without interruption.
/permissions
The `/permissions` command is a security management interface that allows you to view and adjust the rules governing what Claude can and cannot do on your machine. By default, Claude Code operates with a "human-in-the-loop" philosophy, meaning it asks for your approval before performing any action that could affect your system—such as modifying a file or running a terminal command. The `/permissions` command allows you to grant "permanent" trust to specific tools or commands, reducing the number of interruptions during your workflow.
Hệ Sinh Thái & Triển Khai Thực Tế
Giai đoạn 4 tập trung hoàn thiện 24 chủ đề then chốt.
Plan Mode
Plan Mode is a strictly read-only permission state that allows Claude to analyze your codebase, research dependencies, and draft a step-by-step implementation strategy without the risk of modifying any files or executing state-changing commands.
/plan
Plan Mode is a read-only environment that allows the AI to research, analyze, and outline a multi-step strategy for a task without making any actual changes to your files or executing state-altering commands. When you enter this mode—either by typing `/plan` or pressing `Shift+Tab`—the assistant focuses on gathering context and identifying dependencies to create a detailed implementation document. This serves as a safety gate where you can review and edit the proposed approach (using `Ctrl+G` to open the plan file) before giving the final approval to transition into an execution mode to apply the changes.
Plugins
Claude Code plugins are shareable packages that bundle multiple customizations, including slash commands, specialized agents, skills, hooks, and Model Context Protocol (MCP) servers, into a single installable unit. They serve as a standardized way to distribute complex AI workflows across different projects or within an engineering team, ensuring that every developer has access to the same tools and coding standards.
Plugins
Claude Code plugins are shareable packages that bundle multiple customizations, including slash commands, specialized agents, skills, hooks, and Model Context Protocol (MCP) servers, into a single installable unit. They serve as a standardized way to distribute complex AI workflows across different projects or within an engineering team, ensuring that every developer has access to the same tools and coding standards.
PostToolUse
The `PostToolUse` hook is a reactive lifecycle event that triggers immediately after a tool (like Bash, Write, Edit, or a custom MCP tool) completes its execution. While the `PreToolUse` hook acts as a guard to block actions, the `PostToolUse` hook is designed for automation, cleanup, and quality control—ensuring that every action Claude takes adheres to your project's standards.
PreToolUse
The `PreToolUse` hook is a validation gate that executes immediately after Claude decides to use a tool (like writing a file or running a shell command) but before that tool actually runs. It is primarily used for security, policy enforcement, and input sanitization, acting as a final check to ensure the AI's proposed action is safe and correct.
Prompt Caching
Prompt caching in Claude Code is a performance-optimizing feature that stores the frequently used "prefixes" of your conversations—such as your entire codebase state, system instructions, and tool definitions—so they don't have to be reprocessed from scratch with every new message. In an agentic environment where Claude often re-reads your files multiple times to maintain context, caching acts as a "checkpoint" system: while the initial write to the cache carries a slight premium, every subsequent interaction that reuses that prefix receives a 90% discount on input tokens and up to an 85% reduction in latency. Claude Code handles this automatically by placing "cache breakpoints" at strategic points in the prompt (like after your [CLAUDE.md](http://CLAUDE.md) and project structure), ensuring that even as your conversation grows, the "static" foundation of your project remains instantly accessible and cost-effective.
Prompt Caching
Prompt caching in Claude Code is a performance-optimizing feature that stores the frequently used "prefixes" of your conversations—such as your entire codebase state, system instructions, and tool definitions—so they don't have to be reprocessed from scratch with every new message. In an agentic environment where Claude often re-reads your files multiple times to maintain context, caching acts as a "checkpoint" system: while the initial write to the cache carries a slight premium, every subsequent interaction that reuses that prefix receives a 90% discount on input tokens and up to an 85% reduction in latency. Claude Code handles this automatically by placing "cache breakpoints" at strategic points in the prompt (like after your CLAUDE.md and project structure), ensuring that even as your conversation grows, the "static" foundation of your project remains instantly accessible and cost-effective.
Resume Conversations
To resume a conversation in Claude Code, you can use the terminal command `claude --continue` (or `-c`) to instantly pick up the most recent session in your current directory, or `claude --resume` (or `-r`) to open an interactive session picker. This picker allows you to browse past conversations and select one using your arrow keys and the Enter key. If you know a specific session ID, you can bypass the menu by running `claude --resume <session_id>`. Once inside a session, you can also use the `/resume` slash command to switch between conversations without exiting the tool.
/rewind
The `/rewind` command is a history management tool that allows you to undo recent turns in your conversation. When executed, it removes the most recent prompt and response from the active context, effectively "winding back" the session to a previous state. This is particularly useful if the AI misunderstood a complex instruction or if a code generation task went in the wrong direction, as it allows you to re-issue the command with better clarity without the baggage of the failed attempt cluttering the model's memory or inflating your token usage.
Rewind Conversations
To rewind a conversation in Claude Code, you can use the `/rewind` slash command or the `Esc + Esc` keyboard shortcut to open the interactive checkpoint menu. This feature leverages the tool's automatic snapshotting, which creates a restore point for every user prompt and file modification throughout your session.
Scaling Claude Code
Claude Code offers several ways to parallelize work across multiple agents or sessions: subagents, agent view, agent teams, and worktrees. Subagents are delegated workers that handle a side task within their own context and return a summary, keeping the main conversation clean. Agent view lets you dispatch independent sessions to the background and monitor them from a single screen. Agent teams coordinate multiple sessions through a shared task list and inter-agent messaging, managed by a lead agent. Worktrees isolate parallel sessions into separate git checkouts so they never conflict over the same files.
Scheduling Jobs
Scheduled tasks let you run prompts automatically on a schedule in Claude Code. You can use the `/loop` command to repeat a prompt at regular intervals (like every 5 minutes or every 2 hours) while your session is open. You can also set one-time reminders for specific times. The tasks run in the background and stop when you close Claude Code. If you need tasks to keep running after you close the program, you should use Cloud or Desktop scheduled tasks instead.
Security Best Practices
Security is the most critical pillar of using Claude Code because giving an AI agent the ability to execute terminal commands and modify files creates a powerful "intern with root access" who is susceptible to prompt injection and data exfiltration.
SessionEnd
The `SessionEnd` hook is a teardown lifecycle event that triggers when you exit Claude Code or terminate a session. While `SessionStart` is for preparation, `SessionEnd` is your dedicated window for cleanup, archiving, and final reporting. It ensures that your environment is left in a clean state and that any important session metrics are captured before the process fully closes.
SessionStart
The `SessionStart` hook is an initialization lifecycle event that triggers at the very beginning of a Claude Code interaction. Unlike other hooks that react to specific user prompts or file edits, `SessionStart` is designed to bootstrap your environment and inject high-priority context before the first prompt is even processed.
Setting up Claude Code
To set up Claude Code, you first install the CLI tool through your terminal using a single command tailored to your operating system. For macOS, Linux, or WSL, you run `curl -fsSL https://claude.ai/install.sh | bash`, while Windows users can use PowerShell to run `irm https://claude.ai/install.ps1 | iex`. Once the installation is complete, you navigate to any code project directory and type `claude`, which will trigger a one-time login process where you authenticate using your Claude account or an Anthropic Console API key. After logging in, the tool is ready to use immediately.
Shift+Tab
`Shift+Tab` is a navigation shortcut that allows you to cycle through different permission modes to control how much autonomy the AI assistant has over your computer. These modes act as a security dial, ranging from Default Mode, where the assistant must ask for your approval before making any file edits or running terminal commands, to Auto-Accept Mode, which grants it the power to modify files automatically while still prompting for shell commands. Additionally, the cycle includes Plan Mode, a specialized read-only state that restricts the assistant to searching and analyzing your codebase without the ability to change any files or execute code. By toggling these modes on the fly, you can switch from a highly controlled "safety-first" workflow for critical system files to a high-speed, autonomous mode for repetitive tasks like styling or unit testing.
Skill Best Practices
When configuring Claude Code skills, the primary best practice is to optimize for discoverability and context efficiency by using precise YAML frontmatter and "lazy loading." Your skill's `description` should act as a clear semantic trigger, using specific keywords that help Claude identify exactly when to activate the expert instructions without bloating the context window of every conversation. Structure the `SKILL.md` with a narrow, modular focus rather than creating a "Swiss Army Knife" skill; if a workflow has non-negotiable side effects, use `disable-model-invocation: true` to ensure it only runs when manually triggered via a slash command. Additionally, leverage argument placeholders (like `$ARGUMENTS`) to make your skills reusable across different files, and store them in the project’s `.claude/skills/` directory so they are version-controlled and shared with your team. Finally, keep skill instructions deterministic by providing step-by-step tool sequences, which ensures Claude follows your project’s "golden path" for complex tasks like deployments or security audits.
Skill Best Practices
When configuring Claude Code skills, the primary best practice is to optimize for discoverability and context efficiency by using precise YAML frontmatter and "lazy loading." Your skill's `description` should act as a clear semantic trigger, using specific keywords that help Claude identify exactly when to activate the expert instructions without bloating the context window of every conversation. Structure the `SKILL.md` with a narrow, modular focus rather than creating a "Swiss Army Knife" skill; if a workflow has non-negotiable side effects, use `disable-model-invocation: true` to ensure it only runs when manually triggered via a slash command. Additionally, leverage argument placeholders (like `$ARGUMENTS`) to make your skills reusable across different files, and store them in the project’s `.claude/skills/` directory so they are version-controlled and shared with your team. Finally, keep skill instructions deterministic by providing step-by-step tool sequences, which ensures Claude follows your project’s "golden path" for complex tasks like deployments or security audits.
Skills for MCP
Skills act as structured, reusable knowledge packages that dramatically improve how Claude interacts with MCP (Model Context Protocol) servers by giving it precise, context-aware instructions for specific tools and workflows. Rather than relying on Claude to infer how to use a given MCP server from scratch each time, skills provide curated guidance that helps Claude make smarter, more reliable decisions when invoking tools, chaining calls, and interpreting results.
Skills
Claude Code skills are modular packages of instructions, scripts, and assets that teach the AI assistant how to perform specific, repeatable workflows. Each skill is stored in a dedicated folder containing a mandatory [SKILL.md](http://SKILL.md) file, which uses YAML frontmatter to define its name and a description that the AI uses to automatically discover and load the skill when relevant.
Skills
In Claude Code, Skills are self-contained folders of "expert knowledge" and repeatable workflows that Claude loads dynamically into its context only when the task requires it. Each skill is anchored by a `SKILL.md` file containing YAML frontmatter, which helps Claude identify the skill's purpose without bloating the context window, and a body of specific instructions
Slash Commands (/)
Slash commands are the steering wheel of Claude Code. They allow you to execute meta-actions, manage your session, and configure the environment without needing to write a natural language request. By typing a forward slash / at the start of your prompt, you gain access to a suite of utility tools that help you control costs, manage context, and extend functionality. These commands are processed locally and do not involve the AI's reasoning engine until necessary, making them instant and efficient
Chuyên Gia & Mở Rộng Hệ Thống
Giai đoạn 5 tập trung hoàn thiện 21 chủ đề then chốt.
Sonnet
Claude Sonnet is a high-performance large language model that strikes an ideal balance between advanced reasoning intelligence and rapid processing speed. It serves as the versatile "workhorse" of the Claude family, capable of handling complex programming tasks, such as multi-file refactoring and autonomous debugging, while operating significantly faster and more cost-effectively than the top-tier Opus model.
/status & /statusline
The `/status` command is an interactive dashboard that provides a comprehensive overview of your current session's health and system configuration. Unlike the `/statusline` command, which places a permanent information bar at the bottom of your terminal, `/status` opens a temporary, tabbed interface that displays detailed metrics such as your Claude Code version, the specific AI model in use, active account details, and real-time usage limits. It is designed for one-off checks to verify connection stability or to monitor your daily and weekly token quotas before starting a large coding task.
Stop
The `Stop` hook is a final-stage lifecycle event that triggers when Claude Code believes it has finished its entire response and is about to return control to the user. Unlike `PostToolUse`, which fires after every single file edit or command, the `Stop` hook only runs once at the very end of the interaction "turn."
Subagents
Subagents are specialized AI assistants that function as independent "team members" to handle focused tasks on behalf of the main agent. Each subagent operates within its own isolated context window, meaning it starts with a clean slate and does not clutter your primary conversation with large amounts of intermediate research or technical logs.
Subagents
Subagents are specialized AI assistants that function as independent "team members" to handle focused tasks on behalf of the main agent. Each subagent operates within its own isolated context window, meaning it starts with a clean slate and does not clutter your primary conversation with large amounts of intermediate research or technical logs. They are typically defined by a markdown file in the `.claude/agents/` directory, where you specify their unique system prompt, expertise, and restricted tool access.
Subscription Options
Subscription options for Claude Code allow users to authenticate and access its features. Individuals with a Claude Pro or Claude Max subscription can link their account for free Claude Code usage. For teams and larger organizations, Team and Enterprise plans offer higher usage limits, enhanced security features like SSO and audit logs, and deeper integration capabilities.
Thinking modes & Effort
Using thinking modes and adjusting effort levels in Claude Code is essential for balancing deep reasoning with operational efficiency. Furthermore, you can fine-tune Claude's cognitive energy using the effort parameter (available through the /model command).
Tools
Tools are specialized functions that allow the AI assistant to perform actions on your computer rather than just generating text. These functions are categorized into client-side tools that interact with your local environment, such as `Bash` for running terminal commands, `Read` and `Edit` for file manipulation, and `Glob` or `Grep` for searching codebases, and server-side tools like `WebSearch` for fetching real-time information from the internet.
MCP Tunnels
MCP Tunnels let you connect Claude to MCP servers running inside your private network without opening inbound firewall ports or exposing services to the public internet. Traffic flows over an outbound-only encrypted connection, meaning your internal tools and data sources stay fully private while still being accessible to Claude. This makes it practical to build agents that interact with internal databases, APIs, or services that you would never expose publicly.
Understand Claude Pricing
Claude Code offers a flexible, dual-path pricing model designed to accommodate both individual power users and high-scale enterprise teams. You can access the tool through a fixed-rate subscription (such as the Pro or Max plans), which provides a generous recurring allocation of messages shared across the web interface and the terminal, making costs predictable for daily development. Alternatively, you can use a pay-as-you-go API model, where you are billed based on the total number of "tokens" (small units of text) processed in each interaction.
Usage Best Practices
Effective utilization of Claude Code involves adopting key strategies for optimal performance and long-term efficiency. This begins with a "Plan First, Implement Second" approach, especially for complex tasks, utilizing Plan Mode to allow Claude to create a plan before altering the source code. Maintaining a `CLAUDE.md` file as a project's central knowledge repository with relevant information, such as build commands and style guides, is crucial. Context management, through regular use of the /compact command and new conversations for separate tasks, helps mitigate performance degradation. Finally, automating routine processes, like generating Git commits with `claude commit` or setting up hooks, ensures efficiency and consistency throughout the development lifecycle.
/usage
The `/usage` command is a specialized diagnostic tool designed specifically for users on Claude Pro or Claude Max subscription plans. Since these plans have unified limits, the command provides a real-time status report of your remaining capacity instead of monetary costs.
Use /compact and /clear
Regularly using `/compact` and `/clear` is the most effective way to prevent "context rot" and manage spiraling API costs while working with Claude Code. Because Claude re-processes your entire conversation history with every new message, a session that has accumulated thousands of lines of terminal output and file diffs will eventually become expensive, slow, and prone to "forgetting" early instructions. Using `/compact` allows you to summarize long research or debugging threads into a lean set of key findings, effectively "zipping" the conversation so you can continue without losing essential progress. In contrast, `/clear` is vital when switching to an unrelated task; it wipes the current history to provide a clean slate.
Use /compact and /clear
Regularly using `/compact` and `/clear` is the most effective way to prevent "context rot" and manage spiraling API costs while working with Claude Code. Because Claude re-processes your entire conversation history with every new message, a session that has accumulated thousands of lines of terminal output and file diffs will eventually become expensive, slow, and prone to "forgetting" early instructions. Using `/compact` allows you to summarize long research or debugging threads into a lean set of key findings, effectively "zipping" the conversation so you can continue without losing essential progress. In contrast, `/clear` is vital when switching to an unrelated task; it wipes the current history to provide a clean slate.
Use subagents and hooks
Subagents and Hooks are powerful architectural tools that manage the context window by practicing "selective attention," ensuring the main conversation stays lean while specialized tasks remain high-precision. Subagents act as isolated "expert bubbles" that run in their own independent context windows with restricted toolsets, while Hooks provide a deterministic way to inject or prune context at key lifecycle moments.
UserPromptSubmit
The `UserPromptSubmit` hook is an interception mechanism that fires the moment you press Enter on a prompt, but before the text is actually sent to the Claude model. It is the most powerful tool for prompt engineering automation, allowing you to programmatically rewrite, validate, or enhance your instructions on the fly.
Using Claude Code
Claude Code is a sophisticated agentic tool that provides significant power through its ability to execute commands and edit files, but it requires a disciplined approach to prevent security risks and runaway costs.
Ways to Use Claude Code
Claude Code offers multiple interfaces to cater to diverse development workflows. These include a Command Line Interface (CLI) for automation and scripting, editor code extensions (like VS Code, JetBrains IDEs) providing a graphical sidebar with inline code diffs, and a standalone Desktop Application for managing complex projects. Each interface leverages the same agentic engine for researching, writing, and executing code, providing options for different development styles. The CLI is accessible via shell scripts for macOS, Linux, and WSL, and through PowerShell for Windows.
Coding Agent
A coding agent is an AI-powered software entity designed to autonomously write, test, and debug code to solve specific programming tasks or complete software development projects. It uses various AI techniques, like large language models and reinforcement learning, to understand requirements, generate code snippets, identify errors, and iterate on its solutions to achieve the desired outcome.
Agentic Loop
An agentic loop is a computational pattern where an agent continuously interacts with its environment through a cycle of perception, planning, and action. The agent observes its surroundings, decides on a course of action based on its goals and current state, executes that action, and then observes the results to inform its next decision. This iterative process allows the agent to learn, adapt, and pursue its objectives in a dynamic and potentially unpredictable environment.
Vibe Coding
Vibe coding is a modern software development approach in which developers use AI agents and large language models (LLMs) to generate, build, and iterate on applications via natural language prompts, rather than writing code manually. Coined by Andrej Karpathy, this method focuses on the "vibe" or overall intent of the application, often involving rapid prototyping and minimal manual code review, making software development more accessible and faster.