← cd ../blog

Chisle: how to cut the cost of an AI coding agent

In one sentence

Chisle shortens the text that a coding agent has to read. It helps you spend less on every work session with the agent.

What it is and what it’s for

A coding agent is a program with artificial intelligence that writes and changes code for you. To do its work, it reads the files of the project and runs commands in the terminal. The text that the agent reads is counted in tokens, which are small pieces of text. The more text it reads, the more tokens it uses, so the higher the cost.

The problem is a real one. When you run a test suite, which is a set of automatic checks on the code, the terminal can print thousands of characters. The agent reads all of it, even if it only needs two lines. The same thing happens with installation logs and with file lists.

Chisle works on two fronts. The first is a filter on the output of commands, such as tests, git (which manages versions of the code) or grep (which searches for text in files). Above a certain length, the filter keeps the beginning, the end and the lines with errors, and removes the middle. The second is a set of style rules, which ask the agent to give shorter answers and shorter code.

The filter does not touch the operations that read and change files. The agent needs the exact text to change a file without errors.

The project says it supports thirteen agents, including Claude Code and Pi. An installation program sets up the rules for all of these agents.

A concrete example

Exercise: run the test suite of Chisle through its filter, and read only the summary. This is useful for someone who wants to know the status of a project without reading thousands of characters of raw output. At the end, you will have in hand the number of tests that passed and the number of tests that failed.

What you will see in the terminal:

TAP version 13
1..40
# tests 40
# suites 0
# pass 40
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 543.39038

Who it’s for (and who it isn’t)

Project card

What you need to try it, and what you DON’T need

You need three tools. The first is the terminal, the window where you type commands. The second is Node.js, a program that runs JavaScript code, the language Chisle is written in. The project asks for version 18 or a later one. The third is git, a program that downloads projects and keeps track of them.

The project is downloaded from https://github.com/JayPokale/Chisle. The first step of the guide downloads it with git.

Let’s try it step by step

Follow the two steps in order: the second one works on the files downloaded by the first.

Step 1: download the project

We download the project and move into its folder. We do this because the demo uses the files of Chisle, such as the filter and the tests. The commands use git clone to download, cd, which means change folder, to go inside, and git checkout to choose the commit bda2483, which is one exact version of the project.

Type this in the terminal, from a folder of your choice:

git clone https://github.com/JayPokale/Chisle
cd Chisle
git checkout bda2483

What you will see in the terminal:

Cloning into 'Chisle'...
Note: switching to 'bda2483'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this

What you will see: the first lines say that the project was downloaded into a folder called Chisle. A warning about detached HEAD also appears: it means you are on a fixed version of the project. The rest of the output is normal.

How to tell that it went well: no lines start with fatal. Git uses that word when something goes wrong.

Step 2: run the tests through the filter

This is the main part of the exercise. We run the test suite through the runner of Chisle, which is the program that runs another command and filters its output. The task asks you to read only the summary. We get it here, instead of the raw output of about 6,900 characters.

We do this because it is the same job Chisle does for the agent: shortening the output before it is read.

Type this in the terminal, from the Chisle folder:

node hooks/chisle-run.js -- node --test tests/test_compress.js

What you will see in the terminal (not to be typed: it is only here for comparison):

TAP version 13
1..40
# tests 40
# suites 0
# pass 40
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 543.39038

What you will see: a summary of a few lines. # pass 40 means 40 tests passed, and # fail 0 means no test failed. The output is shortened by the program itself; here it appears in English. pass means passed, fail means failed.

How to tell that it went well: the result is the expected one if # fail is 0 and # pass is 40. In this case the program ends with exit code 0, which means without errors.

What happened behind the scenes

The command starts with node, the program that runs JavaScript files. It asks it to start hooks/chisle-run.js, the runner. Everything after the double dash -- is the command to run. Here it is node --test tests/test_compress.js.

The second node starts the test tool built into Node.js: it runs the tests in the file tests/test_compress.js.

The runner takes the text produced by the tests and passes it to the filter, which uses the same rules as the automatic integration with the agent. The filter keeps the summary and removes the detail. Then the runner prints the result on the screen.

The summary answers the task. It contains the number of tests that passed and the number of tests that failed, which are the two things the exercise asks you to read.

Things to keep in mind

Where to start reading the code

The first file to open is hooks/chisle-run.js, because it is the program you ran in the demo.

Glossary