A Complete Guide to CLI Shortcuts for AI Coding Assistants: Session Management and Context Control

    CLI-based AI coding assistants rely on command systems to make development workflows more efficient, controllable, and automation-friendly. This guide categorizes commonly used commands for session management, context control, task execution, reasoning, integrations, and permission governance, with practical advice for using them effectively.

    1. Why CLI Shortcuts Deserve a Systematic Approach

    As AI-assisted programming becomes part of everyday development, graphical interfaces are no longer the only way to work with coding assistants. CLI-based tools are popular because they are lightweight, scriptable, and easy to integrate with existing terminal workflows.

    Their efficiency largely comes from built-in shortcut commands. Instead of writing a detailed natural-language request, developers can use a short command to inspect context, switch models, configure permissions, or manage tasks.

    However, many developers use these tools only as conversational assistants and lack a complete understanding of the command system. This often leads to three problems:

    • The context window becomes filled with irrelevant content.
    • Mistakes are difficult to undo.
    • Parallel tasks become difficult to track and coordinate.

    The following sections organize common commands by function and provide practical usage recommendations.

    2. Session and State Management Commands

    2.1 Inspecting State: /status, /cost, and /context

    These commands make otherwise invisible session state visible.

    • /status displays the current account, selected model, working directory, and tool version. It is the first place to look when troubleshooting the environment. If the assistant behaves unexpectedly, checking the version and model configuration can prevent a large amount of unnecessary debugging.
    • /cost (/usage) reports token consumption for the current session and estimates the associated cost. In long-running sessions, check it at important milestones—for example, after completing a module—to develop a better understanding of consumption patterns.
    • /context displays how tokens are distributed across the context window. It answers a critical question: what is consuming the available context? System prompts, conversation history, and file contents can be compared at a glance.

    2.2 Context Compression and Memory Management: /compact, /init, and /memory

    The context window is a limited resource, and managing it effectively is essential for completing long-running tasks.

    • /compact summarizes the conversation to free token capacity. It can also preserve specified key information. A practical approach is to run it when context usage exceeds roughly 80%, rather than waiting for the system to truncate content or report an error. Before compacting, ask the assistant to produce a list of key conclusions. Afterward, use that list as the basis for continuing the work so that information loss is easier to control.
    • /init initializes a project by scanning its structure and generating a memory file similar to a project conventions document. This allows the assistant to retain information about the project structure, coding standards, and technical conventions across subsequent sessions. It is strongly recommended as an early step when onboarding a new project.
    • /memory provides an entry point for viewing and editing memory files. If the assistant repeatedly violates a project convention, do not correct it manually in every conversation. Record the rule in a memory file to create a persistent constraint.

    2.3 Rolling Back State: /rewind

    /rewind restores the session to a historical checkpoint and reverses operations performed afterward.

    Its main value is that it provides a safety net. If the assistant makes a series of file changes that do not produce the expected result, returning to a checkpoint is generally more reliable than manually reverting files one by one. Compared with ending the session and starting over, a rollback preserves the existing conversation history and reduces recovery effort.

    Before asking the assistant to make broad changes, confirm that a suitable checkpoint has been created.

    3. Task Execution and Parallel Collaboration

    3.1 Background Tasks and Subagents

    • /tasks—called /bashes in some implementations—displays all background tasks currently running. Long-running commands such as tests, builds, and data migrations can be executed in the background and monitored with this command, preventing the main conversation from being blocked.
    • /agents provides tools for viewing, creating, and editing subagents. Subagents are useful for dividing work into specialized tasks and processing them in parallel. For example, code review, documentation generation, and refactoring can be assigned to subagents with different system prompts and tool permissions, while the main agent coordinates the overall workflow. This is essentially a lightweight multi-agent collaboration model that can significantly improve the quality of complex tasks when used effectively.

    3.2 Planning Mode: /plan

    /plan enters a planning-only mode. The assistant presents an approach without modifying files or executing commands. A task description can be appended to the command.

    Typical use cases include:

    1. Validating a complex refactoring strategy before implementation.
    2. Comparing multiple approaches before selecting an execution path.
    3. Avoiding uncontrolled side effects caused by changing files while still designing the solution.

    A practical workflow is to discuss the task with /plan first, then exit planning mode and execute the agreed approach.

    3.3 Side-Channel Questions: /btw

    /btw supports questions that function like an aside. The question is not added to the main conversation, does not consume the main context, and can be sent while the assistant is generating a response.

    For example, while the primary task is running, you might ask why a particular function was designed in a certain way. This separates temporary questions from the main workflow, keeping the primary context cleaner and helping conserve tokens during long sessions.

    4. Quality and Reasoning Control

    4.1 Code Review and Reasoning Depth

    • /code-review reviews the current code changes. It can identify correctness issues as well as opportunities to improve reuse, simplify implementation, or increase efficiency. Some implementations also support applying suggested fixes by adding a repair-related argument. Making this command part of the pre-commit workflow adds an automated review checkpoint.
    • /effort adjusts the depth of model reasoning. A higher setting is useful for complex architecture decisions and difficult debugging, while a medium setting provides a balance between speed and quality. Reasoning depth is positively correlated with token consumption, so higher settings can be significantly more expensive. Use them for high-value problems and keep the default setting for routine development.
    • /model switches the active model. Models differ in capability, speed, and cost. Lightweight models may be suitable for simple bulk edits, while flagship models may be more appropriate for complex design tasks. Some implementations also support third-party or custom model services. Selecting a model based on the task is an effective way to control costs.

    5. Extensions and Governance

    5.1 Connecting External Capabilities: /mcp, /skills, and /help

    • /mcp manages connections to external services through a common protocol. It can connect the assistant to code hosting, project management, databases, and other external systems, giving it the ability to interact with resources outside the current session. Before enabling a service, carefully evaluate its permission scope and potential data exposure.
    • /skills displays all workflow skills currently loaded in the session. It is a quick way to investigate why a particular capability is not taking effect.
    • /help lists all available commands, including built-in commands, custom commands, and commands supplied by plugins or external service extensions. When working in a new environment, running this command first is one of the fastest ways to understand the available command set.

    5.2 Permissions and Automation Governance: /permissions, /hooks, and /config

    • /permissions controls tool invocation permissions and determines whether a tool requires manual confirmation each time it is used. A useful principle is to require confirmation for high-risk actions while allowing low-risk operations to run automatically. This balances security with workflow efficiency.
    • /hooks runs custom scripts automatically before or after tool execution. Common uses include automatic code formatting and static analysis checks. Hooks turn team standards into machine-enforced rules, making them more reliable than informal agreements.
    • /config opens the configuration panel, where users can adjust interface themes, default parameters, editor modes, and other basic experience settings.

    6. Conclusion

    CLI shortcut systems turn the capabilities of AI coding assistants into commands that can be combined and incorporated into repeatable workflows.

    The goal is not simply to memorize as many commands as possible. The real value lies in building a controllable development process:

    • Use /init and /memory to preserve project conventions.
    • Use /plan to design and validate an approach before implementation.
    • Use /compact and /btw to manage the context budget.
    • Use /rewind as a recovery mechanism.
    • Use /permissions and /hooks to govern the boundaries of automation.

    Once these commands become part of a developer’s regular workflow, AI-assisted programming can evolve from a conversational tool into a more dependable engineering collaboration partner.