Using Terminal AI Coding Assistants Efficiently: A Practical Guide from Basics to Advanced Tips
This guide explains how to get more out of terminal-based AI coding assistants. It covers permission modes, plan-first workflows, precise file context, project memory files, Git-based rollback, context management, session recovery, and sub-agent code review.
In recent years, AI coding tools have grown rapidly. Terminal-based AI coding assistants in particular have become a regular part of many developers’ workflows because they integrate deeply with the development environment. These tools can read and write project files, run commands, search code, run tests, and even help commit changes. In effect, they put a pair programming partner inside your terminal.
The tool is only the starting point. How effectively you use it is what separates good results from poor ones. This article covers frequently useful techniques from a practical perspective and helps you build a sound mental model of how these assistants work.
1. Basic Operations and Working Modes
1.1 Starting and Interacting
Most mainstream terminal AI coding assistants start with a single command run from the project root directory. Once started, the tool detects the project structure in the current directory, and you can describe what you need in natural language.
1.2 Understanding the Three Core Working Modes
Most terminal AI coding assistants offer three permission levels:
- Read-only mode (Plan mode): The AI analyzes and plans but does not modify any files. This mode suits requirement discussions and design reviews.
- Confirmation mode: The AI proposes changes, but each step requires your approval before it runs. This mode suits most everyday development work.
- Automatic mode: The AI reads files and runs commands without asking for approval. This mode suits highly trusted, repetitive tasks or sandboxed environments.
Recommendation: Start with confirmation mode to learn where the AI’s boundaries are. Increase automation only after you have enough confidence in the code it generates.
2. Plan First, Then Act
When a task is complex, asking the AI to write code right away often gives poor results. A better approach is to switch to plan mode first and have the AI produce a structured implementation plan that includes:
- A requirement breakdown and task list
- The modules and files in scope
- Potential technical risks and dependencies
- A recommended implementation order
After you confirm that the plan is sound, switch back to execution mode and carry it out step by step. This plan-then-execute workflow significantly reduces rework, especially for high-value tasks such as architecture changes and cross-module refactoring.
3. When Requirements Are Vague, Let the AI Interview You
An easily overlooked technique is to ask the AI to interview you when your requirements are unclear. For example:
Before you start coding, ask me 5 key questions to confirm the requirement details. Do not implement anything until I answer them.
The AI will ask about business boundaries, data structures, error handling, compatibility requirements, and similar topics. After a few rounds of questions and answers, a vague idea becomes a clear task description. This approach is much more efficient than repeated rework.
4. Use the @ Symbol to Pin Down Context
In large projects, the AI’s default code search may pull in unrelated files and waste context window space. Use the @ symbol to specify files or directories explicitly:
Based on @src/services/order.ts and @src/types/order.d.ts, add parameter validation logic to the order module.
Precise context has three benefits. First, it reduces noise from unrelated information, which improves output quality. Second, it lowers token consumption, which saves cost. Third, it keeps the AI focused on the code that matters.
5. Trigger Deep Thinking for Complex Problems
For hard problems such as algorithm design, complex bug investigation, and architecture trade-offs, you can ask the AI to enter a deeper reasoning state. Some tools do this through a specific keyword, such as ultrathink. In deep thinking mode, the AI runs more internal reasoning steps, weighs several options, and then gives a conclusion.
Suitable scenarios:
- Concurrency and race condition analysis
- Database transaction and consistency design
- Root cause analysis of performance bottlenecks
Deep thinking uses more tokens and time, so skip it for simple tasks.
6. Use a Project Memory File to Avoid Repeated Explanations
6.1 What a Project Memory File Is
Re-explaining the project background, coding standards, and build commands at the start of every new session is one of the most common frictions in AI-assisted coding. A common fix is to keep a memory file in the project root. This file is typically named CLAUDE.md or follows another Markdown naming convention that your tool reads automatically at startup.
6.2 What to Record
# Project Background- Tech stack: TypeScript + Node.js + a mainstream ORM framework- Package manager: pnpm. Do not use npm.# Code Conventions- Write components in the functional style.- Route all error handling through the wrapper in errors.ts.# Common Commands- Build: pnpm build- Test: pnpm test:unit
6.3 Things to Keep in Mind
- Keep the file concise, ideally within a few hundred lines. An overly long memory file takes up context space.
- Record only stable information. Do not include detailed business logic.
- For team projects, put the file under version control so the whole team shares the same AI coding conventions.
7. Plan for Mistakes: Build a Rollback Habit
AI changes are not always correct, so a reliable way to roll back is a prerequisite for using these tools with confidence. There are three common levels of undo:
- Conversation rollback: Return the conversation to an earlier step. This suits undoing a recent incorrect change.
- Version control rollback: Use Git or a similar tool to create a checkpoint commit before each large AI-driven change. This is the most reliable safety net.
- File-level recovery: Some tools include built-in file snapshots that let you restore individual files.
Best practice: Make Git checkpoints a habit. Before each large change, run git commit or create a new branch so that the AI’s experimental changes stay isolated from your main branch.
8. Manage Context: Compress First, Clear Later
After a long conversation, the AI tends to get worse. It may forget earlier agreements or give answers that miss the point. This usually means the context window is close to full.
Troubleshooting steps:
- Check context usage: Most tools can show current token usage. When you approach the limit, take action.
- Compress the context: Run a
/compact-style command to summarize the conversation history. This keeps the key conclusions, drops redundant details, and frees space while preserving continuity. - Clear the session: If the task has moved to an unrelated stage, run
/clearto reset the session. Then use the project memory file to restore the necessary background quickly.
Rule of thumb: compress when the task continues, and clear when the task changes.
9. Lost a Session? Resume the History
Closing the terminal does not mean your work is gone. Most tools support a resume-style command that restores a past session so you can continue the task context. For important long-running tasks, keep a separate session record. When you pick up development across several days, resume the session before continuing so that you do not have to rebuild the context from scratch.
10. Code Review with Sub-agents
10.1 What a Sub-agent Is
A sub-agent is an independent AI execution unit spawned from the main conversation, with its own context space. Its value lies in isolation. The reviewer does not carry over the thinking habits of the code’s author, so it can spot problems from a more neutral perspective.
10.2 Setup and Usage
Define a code review sub-agent in the project’s configuration file, and specify its responsibilities and review criteria. For example, you might direct it to focus on security, boundary conditions, and error handling. After you finish a feature, invoke it:
Ask the code review sub-agent to review this change under @src/auth/.
10.3 Sub-agents Versus Skills
- Sub-agent: A separate role with its own context. This suits tasks that need a neutral view or multi-step execution, such as code review or bulk refactoring.
- Skill: A bundle of specialized knowledge injected into the current conversation. This suits lightweight tasks such as formatting output or checking conventions.
You can combine the two. Skills provide domain knowledge, and sub-agents provide execution isolation.
Summary
Using terminal AI coding assistants effectively comes down to one workflow loop:
- Plan first: Use plan mode to confirm the approach for complex requirements.
- Provide precise context: Use
@to point to specific files, and use a memory file to keep the project background stable. - Keep context healthy: Compress or clear the context in time to prevent degradation.
- Protect your safety boundaries: Use Git checkpoints and rollback so you can let the AI try bold changes.
- Add a review step: Use sub-agents to create a generate-and-review pairing.
The value of these tools depends on the methods of the person using them. Once you master these techniques, an AI coding assistant stops being an occasional toy and becomes a productivity engine deeply embedded in your development process.
