10 Essential Terminal Commands for AI Coding Assistants

    This beginner-friendly guide covers ten essential terminal commands for AI coding assistants, organized into startup and model selection, session management, and context engineering. It explains how to control context, resume or reset sessions, compact long conversations, monitor token usage, and combine commands into practical development workflows for more reliable results.

    Introduction: Use AI Coding Assistants More Effectively by Mastering Commands

    Many developers spend most of their time with an AI coding assistant doing two things: opening a terminal, running a startup command, and entering a conversation. Chatting is useful, but real projects expose several common problems:

    • The model is unfamiliar with the project structure, so it rereads files repeatedly and asks for information already documented.
    • While one task is unfinished, a new requirement is added. The conversation grows longer, and the model starts forgetting earlier agreements or answers off-topic.
    • A task is interrupted halfway. The next day, the developer has to explain the background from scratch.
    • At the end of the month, the usage bill is visible, but it is unclear where tokens were spent.

    These problems usually do not come from insufficient model capability. They come from poor management of session state and context. Unlike web-based chat, a terminal-based AI coding assistant runs inside a code repository. It can read files, execute commands, and modify code. It is both a coding assistant and a tool that needs to be operated carefully. Learning a few common commands is essentially learning how to control this tool.

    This article presents ten commands commonly recommended to beginners. They are grouped into startup and model selection, session management, and context engineering, with explanations of what each command solves and when to use it. Command names or parameter formats may vary slightly across tools, so always rely on the tool’s own help information in practice.

    1. Three Basic Concepts

    Before discussing individual commands, three concepts determine why these commands matter.

    1. Context: The information the model can “see” during a conversation, including your prompts, its answers, file contents it has read, and command output. The context window has a size limit. As the conversation grows longer, early information takes up a larger share. This can reduce answer quality and increase the cost of each interaction, because all history must be processed.

    2. Session: A continuous interaction process from startup to completion. A session can be saved, restored, or cleared. A single session is best used to keep working toward the same goal. When the goal changes, start a new session.

    3. Working directory: The current location in the terminal. It also determines the default code scope the assistant can read and operate on.

    With these three ideas in mind, it becomes clear that seven of the ten commands serve the same purpose: helping the model see the right information at the right time.

    2. Startup and Model Selection: Commands 1–2

    Command 1: Start the Assistant and Enter an Interactive Session

    1. # Enter the project root directory first. By default, the assistant uses the current directory as its working scope.
    2. cd /path/to/your-project
    3. # Start an interactive session
    4. ai-cli
    5. # One-shot execution mode for a self-contained task (example)
    6. ai-cli -p "Explain the responsibility of each file under src/utils"

    This is the most basic and most frequently used command. What matters is not only the command itself, but the directory from which it is executed. The working directory directly determines which files the assistant can see. If you start it in the wrong directory, the model can only guess. Interactive mode is suitable for development tasks that require multiple rounds of communication. One-shot mode is better for lightweight tasks with clear outputs, such as information extraction or code explanation, and is easier to integrate into scripts.

    Command 2: Select a Model at Startup and Balance Speed, Capability, and Cost

    1. # Select a model tier when starting the assistant
    2. ai-cli --model <model-name>
    3. # Switch models during a session at any time
    4. /model <model-name>

    Models differ significantly in reasoning depth, response speed, and token price. Choosing an appropriate model is one of the most direct ways to control cost and improve experience. Coding models are often divided into three tiers, which can be selected according to the task type:

    Model Tier Characteristics Suitable Scenarios
    Lightweight Fast responses and low cost Code comments, variable renaming, formatting, simple Q&A
    Everyday Balanced speed and capability Routine feature development, bug investigation, unit test writing
    Advanced Stronger reasoning, but higher time and cost Complex refactoring, cross-module architecture design, difficult problem diagnosis

    New models are released continuously, so the exact model names available should be confirmed through the tool’s help information or official documentation. In practice, a stable strategy is to use the everyday tier by default, switch to the advanced tier temporarily for difficult problems, and delegate bulk small changes to the lightweight tier.

    3. Session Management: Commands 3–4

    Command 3: Resume the Previous Session and Continue Previous Work

    1. # Choose a previous session to resume from a list
    2. ai-cli --resume
    3. # Continue the most recent session directly
    4. ai-cli -c

    This capability is especially important in real development work. Requirements reviews get interrupted, integration tests wait for external APIs, and developers are reassigned to other tasks. These situations are normal. After resuming a session, previously discussed plans, files that were already read, and agreed conventions are still available, so you do not need to explain the background again.

    However, resuming a session also restores the entire context. If the old session has accumulated a lot of irrelevant content, continuing it may bring unnecessary “historical baggage” into the conversation. In that case, it is better to start a new session and briefly explain the current progress and goal in one or two sentences.

    Command 4: View Help and Discover Overlooked Capabilities

    1. # View command-line argument documentation
    2. ai-cli --help
    3. # After entering a session, use the help command to see available slash commands
    4. /help
    5. # View version and runtime environment information
    6. ai-cli -v

    Many users only know three or five parameters because they have never carefully read the help information. Command-line arguments control how the assistant starts, while slash commands control behavior inside the session. Together, they form the full capability surface of the tool. When you are unsure about a feature, checking the help output is usually more efficient than repeatedly guessing.

    4. Context Engineering: Commands 5–8

    This group of commands focuses on project context and session context. It is central to whether an AI coding assistant can produce stable results over time.

    Command 5: Initialize Project Context and Help the Assistant Understand the Project

    1. /init

    This is the step most likely to be skipped when onboarding a new project, yet it is one of the most important. When run for the first time in a project, the assistant scans the directory structure, identifies the technology stack, outlines major modules and key scripts, and generates a project description file based on that information. A common practice is to create a conventionally named description file in the project root directory. In later sessions, the assistant can read this file first to understand the project more quickly.

    Three principles are recommended when using this command:

    • Commit the file to version control: The project description file should be shared by team members and maintained as the project evolves.
    • Review it after execution: Automatically generated descriptions may contain omissions or inaccuracies. Review and correct them before relying on the file.
    • Add team conventions as needed: Include team standards such as code style, testing requirements, commit conventions, and directory conventions. The clearer the conventions, the more closely AI-generated code will match team practices.

    Command 6: Clear Context and Start a New Task from a Clean State

    1. /clear

    This command clears the conversation history of the current session and allows the model to start again. When the model answers off-topic, repeats mistakes, or ignores previously agreed conventions, many people try rephrasing the question. In reality, when the task has already changed, or when the same topic has repeatedly led to misunderstandings, continuing to ask questions often yields little. Clearing the context and asking again is usually faster. A simple rule of thumb is:

    If you cannot explain the current task in one sentence, the conversation may no longer be suitable for continuation.

    Command 7: Compact Context and Free Up Space for Long Tasks

    1. /compact

    Unlike a full clear, context compaction condenses existing conversation history into a structured summary. It retains key decisions, file modification records, and pending tasks, then continues work from that summary. It is suitable for scenarios such as refactoring multiple modules in one effort, debugging difficult defects over a long period, or iterating continuously on the same feature. When the context approaches its limit, the tool may also perform compaction automatically.

    The limitation is that a summary cannot fully restore every detail. Therefore, important information should be stored in files, such as plan documents, change notes, or to-do lists, rather than remaining only in the conversation.

    Command 8: Adjust Configuration to Match Personal Habits and Team Standards

    1. # Open the configuration interface during a session
    2. /config
    3. # View current context usage
    4. /context

    Common configurable items include the default model, permission modes for automatically accepting changes, allowed scopes for common tools and commands, terminal display style, and other settings. Some tools also support a “plan mode,” which analyzes code and produces an implementation plan first, then executes changes only after confirmation. This is suitable for high-risk changes. /context helps show how much context is being used and what content occupies most of it. This information can help decide whether to clear or compact the context.

    5. Runtime Observation: Commands 9–10

    Command 9: Check Cost and Make Token Consumption Measurable

    1. /cost

    Usage data can show how many tokens the current session has consumed and estimate the corresponding cost. For token-based services, this helps individual developers build cost awareness and helps teams evaluate the return on investment from AI coding assistants. It is worth checking usage periodically during long sessions. If consumption grows unusually fast, check whether large files are being read repeatedly or whether an ineffective long conversation is causing the increase.

    Command 10: Integrate Extensions and Enhance the Workflow as Needed

    1. # Manage custom subagents and skills (names may vary by tool)
    2. /agents

    In addition to basic commands, many AI coding assistants provide extension mechanisms. Three common types are:

    • Subagents: Relatively independent subtasks, such as research or testing, are handled in separate contexts. The main conversation only receives conclusions, avoiding being filled with intermediate information.
    • External tool integration: Through standardized tool integration protocols, the assistant can connect to systems such as defect tracking, documentation, and databases. This allows it to obtain authoritative information directly instead of relying on guesses.
    • Custom skills: High-frequency team operations can be fixed as reusable commands or workflows, such as “generate commit messages according to team conventions” or “add unit tests for a specified module.”

    These capabilities are best introduced after becoming familiar with the first nine commands. For beginners, using basic commands well and developing a basic sense of context is more valuable than adding complex configurations at the start.

    6. Turning Commands into Workflows: From Single Conversations to Sustainable Collaboration

    Individual commands solve local problems. What really determines efficiency is combining them into stable and reusable workflows.

    Workflow 1: First-time onboarding for a new project

    1. cd project-root-directory
    2. → Start the assistant
    3. → Run the project context initialization command
    4. → Manually review and add project conventions
    5. → Describe the task in one sentence, confirm the plan, then execute

    Workflow 2: Parallel development with multiple tasks

    1. Task A reaches a stable point
    2. → Record key conclusions in a task document
    3. → Clear the context
    4. → Start Task B (to avoid interference between tasks)
    5. If you need to return to Task A
    6. → Resume the historical session for Task A and continue

    Workflow 3: Long-term refactoring

    1. Start the assistant
    2. → Clarify goals and risks, then produce an implementation plan
    3. → Execute in phases and verify each phase (run tests, run code checks)
    4. → When context approaches its limit, compact it before continuing
    5. → At the end of each phase, check cost and context usage, and evaluate whether to switch to a lightweight model

    The common point in all three workflows is: think before acting, write down conclusions, and switch context according to task boundaries.

    7. Common Beginner Mistakes and Practical Advice

    Mistake 1: The longer the conversation, the better the AI understands you.
    The context window is limited. More information does not necessarily mean better understanding; it can also cause interference. Instead of continuously adding requirements to the same session, it is better to clear the context when the task changes and start again with a clear task description.

    Mistake 2: Clearing context causes previous modifications to be lost.
    Clearing only affects the conversation history. Code already written to files is not affected. However, the opposite issue is also important: changes confirmed in conversation but not written to files may be lost. Important decisions should be written to files promptly to preserve them over time.

    Mistake 3: A stronger model always produces better results.
    The best strategy is to match model choice to task complexity. Using an advanced model for simple formatting adjustments only increases cost and time.

    Mistake 4: AI-generated code can be deployed directly.
    AI coding assistants generate content probabilistically and may produce code that looks reasonable but has boundary issues. All changes should be reviewed by humans and pass the project’s tests, code checks, and static analysis before merging. Operations involving production environments should be handled with extra caution. It is best to avoid allowing the assistant to perform write operations directly on production systems.

    Mistake 5: Using the assistant only in the terminal wastes existing toolchains.
    The value of AI coding assistants comes from working with the existing engineering system. Include testing commands, code checks, and code review in the workflow so that AI generation, tool validation, and human oversight form a closed loop. This is how teams can gain stable benefits over time. For enterprise teams, it is also worth considering unified configuration management, usage statistics, and access control. For example, Baidu AI Cloud’s AI coding tools typically provide enterprise-level support around the development workflow to help teams roll out and govern the tools consistently.

    8. Conclusion: Three Principles and a Quick Reference

    Looking back, the ten commands come down to three principles:

    1. Keep context fresh: Use one session per task. Clear context when switching tasks, and compact it when long tasks approach the limit.
    2. Store project information in files: Write project background, team conventions, and task conclusions into files instead of leaving them only in conversation.
    3. Make cost and quality observable: Use cost, context, and runtime information to support decisions, and use human review to protect quality.

    After practice, most operations can be completed in seconds, but their impact on development efficiency and code quality is long-term.

    Command Purpose Recommended Timing
    Startup command Enter an interactive session or run a one-shot task At the start of each work session; make sure you are in the correct project directory first
    --model / /model Select or switch model tier Choose according to task complexity; switch to advanced for difficult problems
    --resume / -c Resume a previous session Continue the original task after an interruption
    --help / /help / -v View arguments, session commands, and version information Check help first when unsure about a feature
    /init Generate and maintain a project description file Run when onboarding a new project, then maintain it continuously
    /clear Clear current session context When the task changes or the conversation repeatedly goes off track
    /compact Compact and condense existing conversation When context approaches the limit during a long task
    /config / /context Adjust configuration and view context usage After establishing personal habits, fine-tune periodically with context usage in mind
    /cost Check usage and estimated cost Check periodically during long sessions and investigate abnormal consumption
    /agents and other extension commands Integrate subagents, external tools, and custom skills Enable after becoming comfortable with basic commands and when actual needs arise