← All articles
Strategy

Save Your Tokens: Your AI Agent Is Not Your Terminal

You open Claude Code to investigate a failed build. While you are there, you ask it to check Git status. Then list the project files. Then run the same report you ran yesterday. Each request feels harmless. But at some point, the agent has become your everyday terminal.

I am using Claude Code as an example, but this applies just as much to coding assistants such as OpenAI Codex CLI, Gemini CLI, GitHub Copilot, Cursor, Windsurf, and JetBrains Junie. It also applies when you use a general AI chat to guide development work. The interface may be different, but the question remains: does this step need an AI conversation?

I am not against asking AI for help. When a build fails for a reason I do not understand, I want an agent that can trace the problem. But if I already know the command and only need its output, why start another conversation? That is work my terminal can do.

The details vary by product and plan. Some tools offer direct shell-command modes alongside the agent prompt; those are not the same as asking the model to interpret a request. Skills and reusable instructions are also configured differently, and token limits, quotas, and pricing are not universal. Check how your own tool works before deciding where to run a task.

Not everything needs intelligence. Some things just need execution.

A simple way to choose the right tool

Before asking the agent, pause for a moment: Do I already know the command? Is this a repeatable check with known inputs and rules? Or is there a result I do not understand? Run a known command directly; automate a check worth repeating; bring in the agent when interpretation or investigation would help.

  • Need to check the current branch? Run git status in your terminal.
  • Need the same inventory every week? Use a tested script or a CI job.
  • Need to understand why a test failed? Give the agent the failure and relevant context.
Start hereDefine the task

What do you need to know?

Known stepsRun the check

Terminal · Script · CI

When neededInvestigate

Use an agent to interpret results

Run known checks directly; involve an agent when the results need investigation.

These choices work together. An agent can help you write a script, run a test while fixing a defect, or explain an unexpected report. The opportunity is to take the routine execution out of the conversation once you no longer need help with it.

Skills, agents, and scripts do different jobs

These tools are not interchangeable. A script performs repeatable steps. A skill gives an AI agent reusable instructions or domain knowledge. An agent applies reasoning to a task, or takes on a clearly bounded piece of work. A good workflow can use all three, but each should have a distinct responsibility.

Use a script when the steps are fixed

Imagine a team wants an inventory of framework values declared in its C# project files. The rule is known: find the files and read TargetFramework or TargetFrameworks. Save the following as scripts/inspect_repository.py and run it from the repository root:

from pathlib import Path
import sys
import xml.etree.ElementTree as ET

projects = sorted(Path(".").rglob("*.csproj"))
if not projects:
    print("No project files found; check the current directory.", file=sys.stderr)
    sys.exit(1)

had_error = False
for project in projects:
    try:
        root = ET.parse(project).getroot()
        values = [
            value.strip()
            for node in root.iter()
            if node.tag.rsplit("}", 1)[-1] in {"TargetFramework", "TargetFrameworks"}
            for value in (node.text or "").split(";")
            if value.strip()
        ]
        print(f"{project}: {', '.join(values) or 'not declared'}")
    except (ET.ParseError, OSError) as error:
        print(f"{project}: unable to read project ({error})", file=sys.stderr)
        had_error = True

sys.exit(1 if had_error else 0)

For example, the output might look like this:

src/Commerce/Commerce.csproj: net8.0, netstandard2.0
src/Store/Store.csproj: net8.0
tests/Commerce.Tests.csproj: net8.0

This is a simple inventory of declarations, not an evaluation of the effective MSBuild configuration. Frameworks may be inherited, conditional, or use property expressions; use an MSBuild-aware check when those details matter. The script reports unreadable or malformed project files and exits with a failure status; it also fails if it finds no projects.

Suppose your team is planning a framework upgrade. Before each planning meeting, someone needs a fresh inventory. Run the same script from PowerShell in the repository root and check whether it completed successfully:

python .\scripts\inspect_repository.py
if ($LASTEXITCODE -ne 0) {
    Write-Error "Project inventory failed; review the errors above."
}

If one project reports “not declared,” that is a lead, not proof of a problem: the value may be supplied by an imported MSBuild file. A successful inventory also does not prove that you selected the right repository or found every expected project.

For a one-off inventory, a direct command may be enough. But when the team needs the same check on many branches, save the tested script and run it locally or in CI. If you later add a comparison with approved frameworks, make the policy an explicit input and test that separately.

Use a skill when the knowledge or method should be reused

Now consider a different problem: the team often asks an agent to review D365 Commerce changes. Each time, people have to repeat the same context about supported extension points, coding conventions, and expected tests. That repeated guidance belongs in a skill. For example, a Commerce review skill might include instructions like these:

Purpose: Review D365 Commerce extension changes.

1. Identify whether the change affects POS, CRT, Retail Server, or channel data.
2. Look for the supported extension point used by the changed code.
3. Identify the tests and build commands relevant to the affected component.
4. Check whether failures are new or already present in the supplied baseline.
5. Report evidence with file/line references; separate facts from assumptions.
6. Do not edit product source or claim a test passed unless it was run.

Now imagine a developer changes a CRT request handler and asks: “Review this change for extension compatibility and test coverage; report findings only.” With the skill available and invoked, the agent has a starting checklist: identify the handler, trace the extension point, inspect relevant tests, and say which checks were actually run. Without it, that same team context may need to be explained again in every session.

This is an illustrative checklist, not a complete skill file; skill configuration and invocation depend on your tool. A skill is guidance, not an executable test: it does not prove a build passed or make a stale instruction correct. Keep it specific, review it after platform changes, and use the actual project’s documented build and test commands.

Use an agent when investigation or judgement is needed

Suppose a Commerce test that passed before a change now fails. Here is an illustrative, shortened result from a test run:

Test: DepositRequestHandlerTests.CalculatesDeposit
Expected deposit: 100.00
Actual deposit:   0.00
Result: Failed

The output tells you what failed, but not why. Was the handler changed, was a dependency replaced, or did the test setup stop providing a value? Give an agent the failed test, the relevant diff, and permission to inspect—not a request to investigate the entire repository:

Investigate DepositRequestHandlerTests.CalculatesDeposit.
Use the failed test output and the current change as starting points.
Trace the assertion through the handler and the test setup.
Report evidence-backed causes with file/line references and the next check.
If evidence is inconclusive, say what is still unknown. Do not edit files.

A useful response might identify that the changed handler now reads a value from a dependency that the test substitutes, and point to both the handler and the test setup. It should distinguish what the code shows from what remains a hypothesis, then suggest rerunning the specific test after correcting the setup or implementation. That is an example of a possible finding—not a diagnosis implied by the failure message alone.

You still review the evidence and verify any fix with tests. If the task is only “find every TargetFramework element,” use the script instead. A second agent may help with a genuinely separate investigation; sending several agents to repeat the same search adds coordination and duplicated context, not useful parallelism.

A practical example: repository health check

Now imagine a more complete health check than the inventory script above. A team builds a separate workflow that inventories project declarations, checks approved dependency versions, runs the build, and records the command, exit code, and errors. The team runs it locally or in CI. A skill supplies the agent with the team’s review guidance, such as supported frameworks and the tests expected for Commerce changes.

Step 1Script runs checks

Projects · Dependencies · Build

Step 2Structured report

Results · Errors · Exit status

Step 3Agent interprets

Explain · Compare · Recommend

Collect and validate facts first; use an agent to interpret the structured results when needed.

For example, the separate health-check workflow might produce a report like this. The policy and names are illustrative:

Inventory: Commerce.csproj declares net8.0;netstandard2.0
Framework policy: netstandard2.0 requires review
Build: dotnet build Commerce.sln --no-restore
Exit code: 1
Error: Commerce.Extension.cs(42,18): CS1061: 'Order' does not contain
       a definition for 'CustomerReference'

The policy flag tells you what needs review; it does not by itself explain the compiler error. Give the agent the build command, error, relevant change, and team guidance. Ask it to trace which Order type is in scope, compare the property access with the available definition, and identify the next check. If the build had no findings, you could simply retain the report without starting an investigation.

The inventory script shown earlier does not produce this report or run a build. Those checks would need their own tested implementation. The division remains the same: the repeatable workflow collects facts; the skill provides team context; the agent helps interpret the unexpected result.

Build a small toolbox, not a pile of one-off prompts

Start with the checks your team actually repeats: perhaps a repository inventory, a configuration comparer, or a standard build command. A one-off search probably does not need its own framework. When a script earns a place in your toolbox, give it one clear responsibility and make it easy for someone else to run.

  • Make inputs explicit, such as a path, environment, or configuration file.
  • Use predictable output. JSON or a clearly formatted text report is easier to compare and reuse than unstructured terminal output.
  • Fail visibly when something goes wrong. Include the file or operation that failed, and return a meaningful exit status.
  • Validate inputs before acting. For changes that could delete or modify data, provide a dry-run mode.
  • Make repeated runs safe where practical, and log enough detail to understand what happened.

Scripts are not automatically good engineering just because they use fewer tokens. A brittle script can miss files, hide errors, or change the wrong environment. Test the script on representative inputs, review its output, and be especially careful around production systems, credentials, data, and infrastructure.

Common mistakes to avoid

Here are some habits that are easy to fall into when an AI agent is always open beside your terminal.

1. Using the agent prompt as your everyday terminal

You want to list files, check Git status, or see your current directory. Instead of asking Claude Code each question in turn, open a PowerShell tab and run the commands directly:

Get-ChildItem
git status --short --branch
Get-Location

A conversational request asks the model to interpret the instruction and often inspect and summarise the result. Those steps can consume tokens. An agent prompt is not the same as typing directly into PowerShell, although some tools also provide ways to run shell commands directly. Use your regular shell or your tool’s direct command mode for routine work; ask the agent when you want help interpreting the result.

2. Asking the agent to run the same script every time

Suppose you saved and tested the inventory script above. Run it from PowerShell or CI rather than asking Claude Code to operate it every morning. If the output raises a question you cannot answer, bring the relevant portion to the agent. During an active coding task, however, having the agent run a test and inspect a failure can be part of the investigation. The difference is whether you need its judgement.

3. Feeding the agent an entire log when a smaller result will do

A build can produce thousands of lines. Asking an agent to read the whole log every time may fill its context with successful steps and repeated messages. Save the full log for reference, then use an existing filter or a tested script to extract errors, warnings, and surrounding context. Give the agent the relevant excerpt, the command and exit status; include more context if it is needed to diagnose the failure. Remove secrets and customer data before sharing, and follow your organisation’s policy.

4. Repeating the same instructions in every session

If every Commerce review starts with the same explanation of supported extension points, build commands, and review expectations, put that stable guidance in a maintained skill or project instructions. Then give the agent only the task-specific details. A skill is not a replacement for a test: it guides the review but does not prove that the build or tests passed.

5. Asking for a broad investigation when you have a specific question

“Explore the whole repository and tell me why the build failed” can send an agent through far more files than necessary. Start with the failed command, error, affected project, and the decision you need. Likewise, do not launch multiple agents merely to list files or repeat the same search. Delegate separate, substantial investigations when parallel work is actually useful.

6. Optimising tokens at the expense of correctness

A script is not automatically correct because it is repeatable. For example, the XML script above reports values declared in project files; it does not evaluate MSBuild imports, conditions, or property expansion. Use an MSBuild-aware check when you need the effective framework. For scripts that modify data or environments, validate the target, use a dry run where practical, and obtain the necessary approval. Saving tokens is not worth hiding errors or changing the wrong system.

Keep the boundaries clear

A skill is not a magic prompt that makes every answer correct; treat it as maintained guidance and review it like other project documentation. An agent is not automatically cheaper or faster than doing the work directly; use one when the task is substantial, bounded, and benefits from independent context or parallel investigation. A script is not automatically safe; test it and make its errors visible. Once a workflow is understood and repeatable, move its execution into a tested script or pipeline, and reserve AI for the parts that still need judgement.

Tokens are not the only measure of efficiency, and token use does not always translate directly into a bill. But large or repeated context can consume quotas, slow down work, and make it harder to focus on the important part. Measure the whole workflow: correctness, repeatability, time, and operating cost.

Next time you are about to type into an agent prompt, ask yourself: do I need an answer, or do I just need to run a command? Keep the conversation for the problems that benefit from it. Let your terminal and tested scripts handle the routine.

Stop the madness. Save your tokens. Engineer smarter.

-Hitesh Manglani