Terminal Agents: A Practical Guide to Goal-Driven Execution
This guide explains how to get real delivery value from terminal agents by shifting from conversational prompting to verifiable goals. It covers writing goals with explicit constraints and stopping conditions, treating tools as a permission surface rather than a capability list, storing only stable conventions in cross-session memory and skills, choosing models by task risk, adding acceptance checks and circuit breakers before scheduling unattended runs, common failure patterns with fixes, and a repeatable workflow where the agent drafts changes and the human keeps execution authority.
Most people who connect an agent to a terminal for the first time treat it as a dialog box that can run commands: you ask something, it replies with suggestions. The usage that actually improves delivery speed is the opposite. You state an acceptance-ready goal, and the agent chooses tools, executes steps, and verifies results within the scope you authorized, then hands the evidence back. The difference is not in the prose. It is in the control loop: a conversation only produces text, while an agent produces verifiable state changes.
1. Fix the Prompt Before the Model
Inefficient prompts hard-code the process: “cd into a directory, filter the logs with this command, paste me the first twenty lines.” That demotes the agent to a remote keyboard. Effective prompts describe the result and the constraints: “Investigate 5xx responses in the last hour of web access logs, aggregate counts by endpoint, indicate whether they concentrate on a single upstream, and change no configuration.” In the first case you own the correctness of every step; in the second the agent owns exploration and you own the goal and the boundaries.
A usable goal usually contains four things: what result you want, what success looks like, what is forbidden, and where to stop. For example: “Read-only inspection of disk and memory; if a threshold is exceeded, list the process names and PIDs with the highest usage; do not kill processes or delete files.” Tasks without a stopping condition are the ones most likely to widen their scope inside another “let me try once more.”
A schematic task description can look like this:
Goal: Confirm whether error rates increased after the release.Read-only: logs and process list.Forbidden: restarting services, modifying configuration, deleting files.Deliverable: time window, error counts, three sample entries, your reasoning.When uncertain: stop and ask; do not guess production passwords or host addresses.
2. Tools Are a Permission Surface, Not a Capability List
Agents are strong at calling a shell, reading and writing files, retrieving documentation, and issuing read-only queries. Every additional tool adds one more path from “suggestion” to “incident.” In practice, narrow permissions per task instead of leaving everything open by default.
Read-only inspection suits checking disk, memory, load, log tails, and whether configuration exists. Change-oriented work should be split into two stages — produce a change description, then execute in an isolated environment — with a human confirming in between. Actions involving credentials, production databases, bulk deletion, or outbound sending should not be handed to an unattended loop by default. Writing a secret into a conversation or long-term memory amounts to giving a credential to a system that repeats context; use short-lived environment variables or a local secret agent, and clean sensitive fragments out of the session when the task ends.
Keep evidence from the execution: commands, exit codes, summaries of key output, which files changed. “Already fixed” without evidence does not count as done. When results differ from expectations, narrow the goal or add observation first rather than appending more dangerous commands.
3. Memory and Skills: Store Only Stable Patterns
Cross-session memory is suited to project conventions: code style, directory layout, routine read-only checks, release windows, which directories must not be written to. It is not suited to one-off errors, temporary passwords, or unverified architectural guesses. Wrong memories get treated as facts by the next task, which is worse than having no memory.
A skill is best understood as reusable operating instructions: when to use it, what the inputs are, which tools are allowed, the output format, and how to stop on failure. A well-written skill reads like a runbook, not a slogan. A “pre-release check” should be fixed as: is the working tree clean, do tests pass, are configuration differences limited to expected items, and where is the rollback point. After each success or failure, write back only the repeatable decision rules; do not hard-code an incidental path from one machine.
4. Choose Models by Task, Not by Slogan
Simple rewriting, formatting cleanup, and low-risk read-only summaries can use a fast, low-cost model. Cross-file refactoring, diagnosing vague errors, and tasks that need long context to hold constraints are worth a stronger model. The criterion is whether it respects the forbidden list and stops when information is insufficient, rather than generating a long, complete-looking answer in one pass.
Free or low-cost quotas are fine for testing a process, not as the sole dependency for production changes. Regardless of model, assume it will miss files, misread logs, and treat correlation as causation. Key conclusions must therefore trace back to raw output: numbers, timestamps, file names, exit codes. Optimization advice that cannot state its basis is only a hypothesis.
5. Scheduled Automation Requires Acceptance Checks and a Circuit Breaker First
Scheduled jobs suit stable, idempotent, read-only work or work with a very small blast radius: daily error-trend summaries, disk threshold checks, report cleanup that does not touch secrets. They do not suit “detect an anomaly and fix production autonomously.” An automated loop needs at minimum an input scope, a maximum step count, a timeout, a consecutive-failure limit, and a rule that switches to alerting instead of continuing to act once a threshold is crossed.
Reports should be structured so both people and downstream systems can read them: time window, checks performed, normal or abnormal, evidence summary, and a suggested next step that a human still decides whether to execute. Execution records can live in a logging service, and large attachments in object storage. If a team already uses general-purpose capabilities such as logging and object storage on Baidu AI Cloud, it is enough to leave a trail of who ran which read-only check, when, and toward what goal; there is no need to wire the agent directly into change interfaces.
6. Common Failures and Fixes
- Bringing chat habits along: asking only “what do you think?” and getting unexecutable generalities. Replace with an acceptance-ready result.
- Steps too fine-grained and outdated: the environment changes, the step fails, and the agent keeps following it mechanically. Replace with constraints plus a goal, and let it adjust the read-only investigation based on current output.
- Excessive permissions: one “just handle it for me” covers clearing caches, editing configuration, and restarting. Replace with staged authorization.
- Context pollution: half the output of a failed command gets written into memory as a conclusion. Replace with human confirmation of the facts worth keeping at task end.
- No control experiment: it changes something and says “should be fine now.” Replace with running the same check before and after the change and keeping both outputs.
7. A Repeatable Working Rhythm
Before starting, write down the goal, the forbidden items, and the definition of done. During the run, grant only the directories and read-only permissions needed to finish the current goal. Afterward, accept the work with evidence, then decide whether to distill the pattern into a skill. For changes that need human confirmation, the agent produces the draft, the diff, and the rollback notes, while execution authority stays with the person. With this rhythm, a terminal agent stops being a novelty and becomes a stable way of collaborating: you own the goal and the risk, it runs the steps to completion inside the boundaries, and it lays the process open for your review.
