Turn chats into Skills, Skills into scripts

Automate repeated agent tasks into Agent Skills to reduce token costs, execution time and improve consistency. Scripts can push this further.

Turn chats into Skills, Skills into scripts
Different ways to automate agent tasks. Generated with ChatGPT.

Here's a tip to make your agents faster, burn fewer tokens, and behave more consistently:

  • If you find your agent repeating certain tasks, ask it to reflect on the conversation and turn it into an Agent Skill
  • And if you want to go further, turn repeated Agent Skills into scripts (Bash, Python, etc.)

I find this technique helpful because we're constantly trying to find ways to reduce our token costs or do more with our subscription rate limits.

But it's important not just for costs; I find this is an automation mindset that improves my productivity as well. Consistency is important, especially for complex tasks that I want to happen consistently.

How can Agent Skills save tokens and time?

When you chat with an agent, it has to burn tokens and time to acquire context, understand your intent, reason, and implement.

If you have an Agent Skill (which is basically a natural language script as a Markdown file), your agent has to spend less time reasoning about what you want to do. It just follows the instructions you've specified.

Code scripts save even more tokens and time (sometimes)

By that same logic, classic code scripts (e.g. Bash, Python) have advantages over Agent Skills. An Agent Skill is a natural-language script — a sequence of instructions — but the LLM still has to spend time and tokens to process it. It's also non-deterministic: running the same Skill 10 times can lead to different behavior, sometimes significantly different.

Meanwhile, Bash and Python scripts are clear sequences of instructions that run faster, more consistently, and without burning tokens. So when I have an Agent Skill that's run repeatedly, complex, or expensive, I often convert it into a script.

But I don't always reach for scripts right away — they take time to write, are more rigid in adapting to unexpected scenarios, and can be more brittle. This is the classic automation tradeoff — it takes time and effort to create the scripts.

Transitioning from a Development to Automation or "Ops" mindset

It helps me to recognize that this is an automation technique, which is something that "Operators" (IT, SRE, DevOps) think about more than developers. A few concepts are useful here if you look through an operational lens: repeatability, reliability, cost of automation, cost of operations, and long-term maintenance.

It's useful to recognize that not everything SHOULD be automated; there is a cost to writing and maintaining a Skill. There may be an even higher one for scripts. Even when I ask AI to one-shot a Skill or script, it takes valuable time to refine it.

There are other times where I care about reliability and repeatability. Even if I rarely run it, the task is important or complex enough that I want a repeatable playbook. Agent Skills play an interesting role here.

Since Agent Skills are incredibly easy to write, this changes things. In the past I might have written up a playbook as a natural-language document; now it's easy to ask my agent to simply make that document executable as a Skill.

A "spectrum of determinism" in making agents do tasks

To summarize, these are just ways of getting an agent to perform my task. I like to think about it as a "spectrum of determinism."

AShu_co - Scripting Determinism.png

On one extreme, the most open-ended you can be is to simply chat with your agent. This is what we all do - no tips, no tricks. Just request something, and the agent researches as much as it thinks it needs to fulfill your task.

On the other extreme, you can ask your agent to write a Python script that will behave the same way every time you run it. You can ask your agent to run it for you, instead of trying to reason about that sequence of steps.

(I haven't talked about subagents, but I think they deserve a place on this spectrum. I think of them as a slightly constrained general agent, with context isolation. I think about them like Skills, but even more flexible and less predictable.)

Hybrid skills and scripts blend flexibility and determinism

One final note: you don't have to choose scripting versus Skills. You can blend them — I often embed scripts in my Agent Skills. There are some parts I want to run faster and more consistently, so I spend the time building the scripts.

But Skills shine in their natural-language flexibility and open-endedness. I use Skills as a wrapper for calling my scripts, as the "glue" layer between multiple scripts, and the "transform" layer that validates and transforms inputs and outputs.

In the end, you're just trying to help your agents perform a task. They're pretty good at most general tasks, but giving them constraints may save them tokens and time. The question is whether it's worth your time to automate and tinker with the automation.

Acknowledgments

Shoutout to @InboxZero's tweet for prompting me to write this article. I've been using this technique, and variations of this topic come up regularly when I swap tips with engineers about how I improve my productivity.

Subscribe to Words & Bytes

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe