Using Terminal-Based AI Coding Assistants Effectively: A Practical Guide

    This guide explains how to get reliable results from terminal-based AI coding assistants in everyday development. It covers the three working modes and why Plan mode is the best starting point, how to clarify requirements with the AI, how to control context with file references and project memory files, how to roll back unwanted changes, how to manage long sessions, and how to use subagents for code review.

    1. Why Terminal-Based AI Coding Tools Are Worth the Investment

    Over the past year, AI-assisted programming has moved from experiment to a daily productivity tool for engineers. Compared with using a large model in an editor plugin or a web chat window, a terminal-based AI coding assistant has distinct advantages. It runs directly in the command-line environment inside your project directory, so it can see the full code context. It can read and write files, run commands and tests, and even help with commits. You do not need to keep copying and pasting between a chat window and the real project. Every change the AI makes lands directly in the actual codebase.

    For the same reason, using these tools well takes more than knowing how to chat with them. The assistant works like a highly capable junior engineer who needs clear instructions. The clearer the instructions and the more disciplined the workflow, the more consistent the output. Unclear instructions lead to erroneous edits, bloated context, and lower overall efficiency. The sections below describe a practical approach, organized around a typical development workflow.

    2. Basics: Starting Up and the Three Working Modes

    2.1 Starting a Session

    Most terminal-based tools are simple to start. Run the launch command from your project root to enter an interactive session:

    1. cd your-project
    2. ai-code

    On first launch, check two things. First, confirm that the working directory is the project root, because the AI’s default read and write scope is usually based on it. Second, choose a permission mode that fits your needs. At the start, use a conservative mode that asks for confirmation before each change. Loosen the settings once you are comfortable with the tool.

    2.2 The Three Working Modes

    Mature terminal coding assistants typically offer three modes, each with a different level of trust:

    • Q&A mode: The AI only analyzes and explains code. It makes no changes. Use this mode to understand code structure or to think through a bug.
    • Plan mode: The AI produces a complete implementation plan and waits for your approval before doing anything. This is the habit worth building.
    • Execution mode: The AI can edit files and run commands directly. Use it when the approach is settled and the task boundaries are clear.

    Practical advice: start in Plan mode by default. If you ask the AI to change code right away, the result often looks correct but does not match the business logic. When the AI outlines a plan first, you can correct it at low cost.

    3. Plan First, Then Execute

    The main value of Plan mode is that it moves the cost of understanding the problem to the beginning. A typical planning exchange looks like this:

    1. > I want to add automatic refunds for timed-out order cancellations to the order module. Draft the plan first, and do not change any code.

    The AI returns a structured plan. It lists the files involved, explains how the data flow changes, names any new configuration items, and points out edge cases such as duplicate refunds and concurrent cancellations. At this stage, review the plan item by item. Focus on three things:

    1. Impact scope: Does the list of changed files miss any coupling points you already know about?
    2. Design choice: For example, should the feature use a polling scheduled task or a delayed message queue? This is a business decision, so you must make the call.
    3. Rollback strategy: Does the plan account for failure scenarios?

    After you approve the plan, switch to execution mode and let the AI implement it. This three-step cycle of planning, confirming, and executing can reduce the rework rate by an order of magnitude.

    4. When Requirements Are Vague, Let the AI Interview You

    A technique people often overlook: if you have not worked out the details of a requirement yet, do not force a detailed prompt. Ask the AI to act as a requirements analyst and question you instead:

    1. > I want to build a user feedback page. Before we start, ask me the clarifying questions you need, five at a time. I will answer, and then you can ask the next set.

    This approach fills in context through several rounds of conversation. The AI’s questions often reveal blind spots you had not considered: whether feedback requires a logged-in user, where uploaded images will be stored, how to filter sensitive words, how to paginate results, and so on. After a few rounds, you have a reasonably complete requirements specification, and the accuracy of the implementation improves.

    5. Use @ to Target Files and Control Context Quality

    A terminal AI can search the whole codebase, but letting it search blindly has two costs. The search takes time, and irrelevant context can dilute the model’s attention. The better approach is to pass exact files with the file reference syntax:

    1. > @src/services/order.ts @src/types/order.d.ts
    2. Based on these two files, explain the state transition logic of the order state machine, and point out where the type definitions and the service implementation do not match.

    A useful rule of thumb: if a task involves a few files, reference those files, and let the AI find anything else on its own. The more precise the context, the more focused the answer, and the easier it is to control token usage.

    6. Use Deep Thinking for Complex Tasks

    For complex problems such as cross-module refactoring or hard-to-find bugs, you can include an instruction that triggers deeper reasoning. Examples include ultrathink-style keywords, though the exact keywords depend on the tool’s documentation. Deep thinking makes the model run a longer internal reasoning chain. The cost is slower responses and higher token usage, so use it selectively:

    • Good fits: architecture trade-offs, concurrency issues, tracing complex data flows, and root-cause analysis of unclear error messages.
    • Poor fits: renaming a variable, writing a simple function, or routine CRUD work.

    Treat deep thinking as a heavy tool you reach for when needed, not as a default setting.

    7. CLAUDE.md: Giving the Project Long-Term Memory

    7.1 Why a Project Memory File Helps

    Each new session starts with the AI knowing nothing about your project. If you have to explain every time that the project is a monorepo, that commit messages must follow a specific convention, or that tests run with a particular command, the process is slow and inconsistent. A practical fix is to keep a memory file in the project root, such as CLAUDE.md. The AI reads it automatically at startup and uses it as global context.

    7.2 What to Include

    A high-quality project memory file usually covers the following:

    1. # Project Notes
    2. ## Tech Stack
    3. - Language and framework versions
    4. - Package manager and lock file type
    5. ## Common Commands
    6. - Build: npm run build
    7. - Test: npm run test (run only affected tests: npm run test:related)
    8. ## Code Conventions
    9. - Write components in functional style
    10. - Do not manipulate the DOM directly
    11. - Follow Conventional Commits for commit messages
    12. ## Notes
    13. - The src/legacy directory contains legacy code. Explain your reasons before modifying it.
    14. - Database migration files must not be edited by hand.

    7.3 Maintenance Tips

    Keep the memory file concise, ideally a few hundred lines at most. Include only the things the AI tends to get wrong, rather than copying all your documentation. Put the file under version control so it evolves with the project. After a major refactor, you can ask the AI to suggest updates to the file.

    8. When Changes Go Wrong: Rollback Options

    When the AI edits many files in one pass and goes in the wrong direction, undoing each file by hand is painful. Know the rollback features of your tool before you need them. There are generally three options:

    Method Granularity Best for
    Session rewind (rewind-style feature) Restores files to their state before a given conversation turn The AI’s most recent round of changes went off track as a whole
    Version control system Any granularity The fallback for every scenario
    Manual fixes plus asking the AI to self-check Local adjustments The changes are mostly correct, with a few specific issues

    The most important practice: before asking the AI to make a large change, make sure the working tree is clean. A commit in version control gives you a point you can always return to. This is the first safety rule for using AI coding tools.

    9. Context Management: Compact First, Clear When Switching Tasks

    Long sessions reduce efficiency. As the conversation grows, the context window fills up. The AI then starts to forget earlier decisions, give off-target answers, or repeat work. Manage this in three steps:

    1. Monitor usage: Most tools show current token usage in the interface. When the percentage climbs noticeably, pay attention.
    2. Compact the context (/compact-style command): This summarizes the conversation history, keeps the key conclusions and decisions, and frees up space in the window. It suits cases where the current task is not finished.
    3. Clear the context (/clear-style command): When you switch to a completely unrelated task, clear the session and start over so old task information does not contaminate the new one.

    A simple rule: clear when you change tasks, compact when context grows within a task.

    10. Resuming Sessions: Do Not Lose Work to Interruptions

    Terminal sessions usually end when the window closes. Mature tools, however, support resuming past sessions (resume-style feature). If you stop partway through and continue the same task the next day, resume the session. The AI picks up with its full context, which avoids the cost of getting back up to speed. Make it a habit to note the session identifier when you finish an important task, rather than relying on memory.

    11. Using Subagents for Code Review

    11.1 What a Subagent Is

    You can think of a subagent as a separate review session. The main session handles development, while the subagent reads the changed code as an outside observer and gives review feedback. A subagent does not carry the main session’s bias that “the code I wrote must be fine.” Its review is therefore more objective, following the same principle as human development: an author should not review their own work alone.

    11.2 A Typical Setup

    First, configure a code review agent. Most tools let you create one through a configuration file or a command. Define its role and output format:

    1. Role: Senior code reviewer
    2. Responsibilities:
    3. - Check logic correctness and edge cases
    4. - Check consistency with project conventions
    5. - Check for potential security issues (injection, unauthorized access, sensitive data leaks)
    6. Output: List issues grouped by severity, with file names and line numbers

    After development is complete, start the review:

    1. > Use the code review agent to check all the changes you just made to the payment module.

    11.3 Subagents Versus Skills

    The two are easy to confuse. A skill is a capability package. It teaches the AI how to complete a type of task, such as generating components according to team conventions or writing documents from a template. A subagent is an independent worker with its own context. It plays a complete role, such as a reviewer or tester. Package simple, reusable tasks as skills. Use subagents for tasks that need an independent perspective or isolated context.

    12. Summary

    Using a terminal AI coding assistant well depends less on memorizing commands than on following a disciplined workflow:

    1. Plan before executing, and use Plan mode to control direction.
    2. When requirements are unclear, let the AI ask questions to fill in context.
    3. Use @ to reference files, and use a memory file to record project knowledge, so context stays high quality.
    4. Rely on rollback and version control as a safety net, so you can let the AI do the work with confidence.
    5. Compact in time, clear when needed, and use session resume to keep long sessions healthy.
    6. Add subagent reviews to close the loop between development and review.

    Once these practices become routine, the AI becomes a reliable teammate rather than an occasionally impressive toy. If the topic comes up in a technical interview, this framework also provides enough material for an in-depth discussion.