CLI Slash Commands for AI Coding Tools: A Complete Guide

    This article explains how CLI slash commands in AI coding tools support context management, task planning, model selection, code review, permissions, integrations, and cost control. It covers common command categories, usage scenarios, a workflow example, and best practices for building reproducible, auditable development processes.

    As AI coding tools become part of daily development workflows, CLI slash commands are no longer just shortcuts for typing fewer characters. They are becoming an important entry point for managing context, decomposing tasks, controlling costs, constraining permissions, and codifying team standards. Used well, slash commands allow developers to initialize projects, plan solutions, review code, inspect background tasks, switch models, and connect external systems without leaving the terminal.

    This article takes a general technical perspective and systematically explains common CLI slash command categories, how they work, when to use them, and best practices. Command names and parameters in this article are illustrative only. Actual names and supported ranges should be based on the tool in use.

    1. Why CLI Slash Commands Need Systematic Understanding

    The core value of CLI slash commands is standardizing high-frequency operations. Compared with graphical interfaces, command-line entry points are better suited to scripts, terminal workflows, and automation pipelines. Compared with natural language conversation, slash commands are more discoverable, reproducible, and controllable. Developers can trigger fixed capabilities through fixed commands, reducing repeated descriptions and lowering the chance of mistakes.

    Slash commands also take on the responsibility of context governance. The output quality of AI coding tools depends heavily on the context window, and context is a limited resource. Through commands for compression, rollback, side questions, and context usage visualization, developers can manage conversation state more precisely and prevent irrelevant information from crowding out critical information. At the same time, commands for permission confirmation, hooks, and external integrations bring tool calls into auditable processes, helping teams establish security boundaries.

    Therefore, understanding slash commands should not stop at memorizing a command list. It should focus on four underlying goals: reducing interaction costs, improving task decomposability, controlling tokens and expenses, and strengthening security and auditability.

    2. Session State and Context Management Commands

    1. /help: Build a Full Command View

    /help is typically used to list all commands available in the current environment, including built-in commands, custom commands, plugin commands, and commands provided by external integrations. Its value is not only as a dictionary lookup, but also as a way to discover the capabilities loaded in the current workspace. Teams can configure different plugins and custom commands for different projects, and new members can use /help to quickly understand available capabilities, reducing the need to maintain verbal documentation.

    2. /status: Confirm Runtime Environment and Identity State

    /status generally displays information such as the logged-in account, current model, working directory, and software version. When troubleshooting, environment differences are often more hidden than code differences. Confirming the working directory and version through a status command can prevent commands from being executed in the wrong project. Confirming the current model and account helps reproduce output differences. For team collaboration, status information can also be included in problem feedback, but sensitive data should be redacted.

    3. /compact: Compress Conversations and Free Context

    /compact is used to summarize and compress conversation content, free token usage, and optionally specify what should be retained. When context usage approaches the limit, continuing the conversation directly may push key constraints out of the window. A safer approach is to define retention items first, such as “retain API changes, TODO items, failing tests, and open questions,” and then perform compression. Compression is not simple deletion; it turns historical information into a higher-density summary. The clearer the retention design, the more stable subsequent output will be.

    4. /context: Visualize Context Usage Distribution

    /context usually visualizes the token distribution of modules in the context window, such as system prompts, project memory, conversation history, and tool output. It helps developers determine which part is consuming the budget. When tool output is excessive, redundant logs should be trimmed first. When memory files are too long, project conventions should be split or simplified. When conversation history is too long, compression or rollback should then be considered.

    5. /cost and /usage: Track Consumption and Estimate Expenses

    /cost or /usage is used to track token consumption for the current session and estimate usage costs. The key to cost governance is establishing budget awareness: assess context size before starting a long task, observe usage with /context during execution, and review with /cost afterward. For teams with high-frequency usage, cost statistics can be included in regular reviews to identify unnecessary long contexts, repeated tool calls, and excessive reasoning.

    6. /btw: Ask Side Questions Without Polluting the Main Conversation

    Commands such as /btw are used for side questions that are not written into the main conversation and do not consume the main context. Some tools also support asking questions in parallel while AI output is being generated. They are suitable for confirming concepts, asking about command meanings, or temporarily validating ideas. The main conversation should stay focused on task goals. If side questions are mixed into the main thread, they increase the burden of later compression and review.

    7. /rewind: Roll Back to a Historical Checkpoint

    /rewind is used to roll back session state to a historical checkpoint and undo unsatisfactory operations. Compared with simply interrupting, rollback can restore a known state more cleanly and reduce interference from residual context in subsequent reasoning. Developers should develop the habit of setting checkpoints at key moments, such as after a solution review, before applying automated fixes, and before executing high-risk commands.

    3. Project Initialization and Memory Management

    1. /init: Generate Project Convention Files

    /init is typically used to initialize a project and automatically generate a project convention or memory file so that the tool remembers the project structure, technology stack, build commands, test methods, and code standards in later sessions. This file should remain short, accurate, and maintainable, and should not contain a copy of the full documentation. It is recommended to include directory structure explanations, common build and test commands, code style, commit conventions, security constraints, and prohibited actions. Project convention files should be version-controlled and continuously updated as the project evolves.

    2. /memory: View and Edit Project Memory Files

    /memory is used to view and edit all memory files in a project. Memory layering is important: global memory stores personal preferences, project memory stores team conventions, and subdirectory memory stores module-specific rules. More memory is not always better. Overly long memory consumes context. It is recommended to regularly clean up outdated rules, separate stable conventions from temporary tasks, and avoid writing one-off troubleshooting information into long-term memory.

    4. Planning, Task Decomposition, and Parallel Processing

    1. /plan: Pure Planning Mode

    /plan enters pure planning mode, outputs only solution ideas, does not modify files, and does not execute commands. A task description can be appended. It is suitable for clarifying scope, risks, dependencies, and acceptance criteria before taking action. During the planning stage, the output should include steps, affected files, test strategy, and rollback plan. Planning before execution can significantly reduce rework risks caused by broad changes.

    2. /agents: Manage Subagents

    /agents is used to manage subagents, supporting viewing, creation, and editing. Its goal is to split complex tasks into smaller tasks that can be processed in parallel. Subagents are suitable for work with clear boundaries and explicit inputs and outputs, such as “check edge cases in a module,” “map an API call chain,” or “generate a test case list.” When splitting tasks, avoid multiple subagents modifying the same file area to reduce conflicts. Each subagent’s task description should include scope, constraints, and delivery format.

    3. /tasks: View Background Tasks

    /tasks is used to view all tasks currently running in the background, and some tools provide aliases. Background tasks are suitable for long-running retrieval, testing, or analysis. Developers should check task status regularly to avoid duplicate submissions. For failed tasks, keep an error summary rather than repeatedly injecting full logs into the main context.

    5. Model Switching and Reasoning Depth Control

    1. /model: Switch Models or Model Tiers

    /model is used to switch large models and usually supports high-capability tiers, balanced tiers, lightweight tiers, or custom models. The selection principle is not “the stronger, the better,” but matching task complexity. Solution design, complex refactoring, and deep review are suitable for high-capability tiers. Daily completion and simple queries are suitable for balanced or lightweight tiers. For custom models, confirm context length, tool-calling capability, and data compliance requirements.

    2. /effort: Adjust Reasoning Depth

    Commands such as /effort are used to adjust model reasoning depth, such as high-depth reasoning or balanced mode. High-depth modes usually consume more tokens, and some highest tiers are available only for specific high-capability models. Actual support should be based on tool documentation. It is recommended to use them only for complex defect localization, cross-module impact analysis, or high-risk solution review, and to review costs with /cost afterward.

    6. Code Review, Quality Assurance, and Workflow Skills

    1. /code-review: Review the Current Diff

    /code-review is used to review the current diff, checking correctness issues and looking for improvements in reuse, simplification, and efficiency. High-quality review should cover boundary conditions, error handling, concurrency and idempotency, resource release, secure input validation, test coverage, and maintainability. Adding --fix can directly apply fixes, but the change scope should be confirmed before application, and tests and static checks must be run after application.

    2. /hooks: Automatically Run Shell Before or After Tool Execution

    /hooks is used to view hook configuration. Hooks can be set to automatically run shell commands before or after tool execution, commonly for code formatting, lint checks, unit tests, or generation checks. Hooks should remain fast, idempotent, and explainable. On failure, they should output clear error summaries and avoid swallowing errors. High-risk hooks should be version-controlled and reviewed.

    3. /skills: Show Loaded Workflow Skill Packs

    /skills shows all workflow skill packs loaded in the current session. Skill packs turn repeated processes into reusable capabilities, such as release checks, API change reviews, and test completion. Teams should clarify skill pack versions and applicable scopes to avoid result differences caused by inconsistent loading among members.

    7. Permissions, Configuration, Feedback, and External Integrations

    1. /permissions: Control Tool Call Permissions

    /permissions is used to control tool call permissions and configure whether a tool requires manual confirmation on every call. Follow the principle of least privilege: read-only tools can be relaxed appropriately, while high-risk tools such as file writes, command execution, and external system access should require confirmation. For automated workflows, define whitelists and audit logs clearly to avoid “one-time authorization, long-term looseness.”

    2. /config: Open the Configuration Panel

    /config is used to open the configuration panel and adjust interface themes, default parameters, editor modes, and similar settings. Teams can document key configurations in project-level instructions to reduce differences between individual environments. Configuration changes should record their reasons, especially for default models, automatic execution, and permission-related settings.

    3. /feedback: Submit Feedback or Report Issues

    /feedback is used to submit feedback or report issues, usually including the current session context to reduce the cost of manually copying logs. Before submission, check whether sensitive information is included and redact it if necessary. High-quality feedback should include reproduction steps, expected behavior, actual behavior, and minimal context.

    4. External Integration Management: Connect Code Hosting, Issue Tracking, and Databases

    External integration commands are used to manage connectors to external systems such as code hosting, issue tracking, and databases. When using them, define data boundaries clearly: which data can be read, which operations require manual confirmation, and how connection credentials are rotated. The stronger the integration capability, the more permission tiers and audit records are needed.

    8. Typical Workflow Example

    1. /init
    2. /plan Implement login rate limiting and audit logging; list affected files, test strategy, and rollback plan
    3. /agents Create a subagent: review authentication module edge cases in read-only mode; do not modify files
    4. /tasks
    5. /code-review --fix
    6. /compact Retain API changes, failing tests, and TODO items
    7. /context
    8. /cost

    This workflow reflects the sequence of “establish conventions first, then plan, then parallelize, then review, and finally compress and review costs.” Key points include initializing project conventions, writing no files during the planning stage, using read-only subagent analysis to reduce conflicts, applying fixes after review and running tests, specifying retention items during compression, and finally tracking costs.

    9. Best Practices Checklist

    1. Read before write: prioritize planning, review, and analysis; modifications and execution require confirmation.
    2. Use small commits and checkpoints: use rollback checkpoints before high-risk operations to reduce residual state.
    3. Manage context budget: regularly inspect usage distribution and specify key retention items when compressing.
    4. Tier permissions: require manual confirmation for high-risk tools and use whitelists for automated workflows.
    5. Keep memory files concise: project conventions should be short and accurate, and outdated rules should be cleaned regularly.
    6. Close the review-fix loop: after automated fixes, run tests, lint, and diff review.
    7. Codify team standards: put common commands, hooks, and skill packs under version control.
    8. Redact feedback: check context for secrets, paths, and business data before submitting issues.

    10. Conclusion

    CLI slash commands are a key design that moves AI coding tools from “conversation assistants” toward “development workflow entry points.” Mastering commands for session context management, task parallelism, model reasoning control, code review, permission security, and external integrations can help developers balance efficiency, cost, and security. The truly effective approach is not stacking commands, but building a stable process around project conventions, planning first, least privilege, review loops, and cost reviews. Once these slash commands are codified into team standards, AI coding tools can be integrated into daily delivery in a more reproducible and auditable way.